[Java-gnome-developer] LibGlade patch
Brought to you by:
afcowie
From: Julian F. <jfi...@ho...> - 2001-02-23 01:12:14
|
Hi, I'm a friend of Avi's and I'm using the LibGlade stuff on a project. In trying to access the second parameter of the libglade constructor I noticed that your code didn't allow me to pass it. When I asked Avi he said he had written code for it but you mustn't have got it. So I merged his changes into your new naming scheme and here is the patch. Also note that you need to add "-lz" to the libraries (as well as -lxml) if you are compiling the LibGlade stuff. Since Java doesn't seem to support default method parameters (I'm fairly new to Java) I don't know if you want to have two LibGlade constructors, one that takes two parameters and one that takes three? If you just want to load the whole Glade file, you can pass null as the third parameter... otherwise you pass the name of the widget you want to load. Julian Fitzell Index: LibGlade.java =================================================================== RCS file: /cvsroot/java-gnome/java-gnome/src/other/LibGlade.java,v retrieving revision 1.2 diff -r1.2 LibGlade.java 1c1 < /* --- > /* 18a19 > * @author Julian Fitzell 34,35c35,36 < < public LibGlade(String file, Object owner) --- > > public LibGlade(Object owner, String file, String root) 38c39,45 < glade = construct(file); --- > try { > glade = construct(file, root); > } > catch(Exception e) { > System.out.println("GladeKit error: " + e); > } > 69c76 < protected native long construct(String file); --- > protected native long construct(String file, String root); Index: gnu_glade_LibGlade.c =================================================================== RCS file: /cvsroot/java-gnome/java-gnome/src/other/gnu_glade_LibGlade.c,v retrieving revision 1.2 diff -r1.2 gnu_glade_LibGlade.c 72c72 < (JNIEnv *env, jobject o, jstring file) --- > (JNIEnv *env, jobject o, jstring file, jstring root) 76a77 > char *rootname; 81a83,87 > if(root) > rootname = (*env)->GetStringUTFChars(env, root, 0); > else > rootname = 0L; > 84c90 < xml = glade_xml_new(filename, 0L); --- > xml = glade_xml_new(filename, rootname); 90a97,98 > if(rootname) > (*env)->ReleaseStringUTFChars(env, root, rootname); 163a172,173 > > |