Thread: RE: [java-gnome-hackers] Tree/List widgets
Brought to you by:
afcowie
From: Jeffrey M. <Jef...@Br...> - 2002-08-30 11:13:13
|
I will look at it now. -Jeff > On Sat, 2002-08-24 at 14:35, Jeffrey Morgan wrote: > > I will look into this over the weekend. > > did you get anywhere with this? > > or has anybody else got any ideas? > > > > > On Sat, 2002-08-24 at 06:00, Mark Howard wrote: > > > On Fri, 2002-08-23 at 17:46, Mark Howard wrote: > > > > public Value(Type type) { > > > > int [] vptr = new int[1]; > > > > Value.g_value_init(vptr, type.getHandle()); > > > > handle = vptr[0]; > > > > } > > > > > > Has anyone successfully used the glib.Value object? > > > > > > The gtk reference says: > > > GValue* g_value_init (GValue *value, > > > GType g_type); > > > Initializes value with the default value of type. > > > value : A zero-filled (uninitialized) GValue structure. > > > g_type : Type the GValue should hold values of. > > > Returns : <no comment> > > > > > > > > > The JNI code, however, uses the return statement: > > > /* > > > * Class: org.gnu.glib.Value > > > * Method: g_value_init > > > * Signature: ([Lint ;I)I > > > */ > > > JNIEXPORT jint JNICALL > Java_org_gnu_glib_Value_g_1value_1init (JNIEnv > > > *env, jclass cls, > > > jintArray value, jint type) > > > { > > > gint *value_g_g = (gint *) > (*env)->GetIntArrayElements (env, value, > > > NULL); > > > GValue *value_g = (GValue *)value_g_g; > > > GType type_g = (GType)&type; > > > { > > > return (jint)g_value_init (value_g, type_g); > > > } > > > } > > > > > > > > > Although this return value is ignored in the java code: > > > /** > > > * Construct a new Value from a given org.gnu.glib.Value. > > > */ > > > public Value(Type type) { > > > int [] vptr = new int[1]; > > > Value.g_value_init(vptr, type.getHandle()); > > > handle = vptr[0]; > > > } > > > > > > Could someone who knows more about this please check it and either > > > confirm that the Value code is correct or try to fix it. > > > > > > Thanks > > > -- > > -- > > +----------------------------------------------+ > | Mark Howard cam.ac.uk mh344@ | > | http://www.tildemh.com tildemh.com mh@ | > +----------------------------------------------+ > |
From: Jeffrey M. <Jef...@Br...> - 2002-08-30 11:24:30
|
I just checked some code into cvs that I think should resolve this issue. I don't have a test case to verify if it works. Are you in a position to test this method? -Jeff > On Sat, 2002-08-24 at 14:35, Jeffrey Morgan wrote: > > I will look into this over the weekend. > > did you get anywhere with this? > > or has anybody else got any ideas? > > > > > On Sat, 2002-08-24 at 06:00, Mark Howard wrote: > > > On Fri, 2002-08-23 at 17:46, Mark Howard wrote: > > > > public Value(Type type) { > > > > int [] vptr = new int[1]; > > > > Value.g_value_init(vptr, type.getHandle()); > > > > handle = vptr[0]; > > > > } > > > > > > Has anyone successfully used the glib.Value object? > > > > > > The gtk reference says: > > > GValue* g_value_init (GValue *value, > > > GType g_type); > > > Initializes value with the default value of type. > > > value : A zero-filled (uninitialized) GValue structure. > > > g_type : Type the GValue should hold values of. > > > Returns : <no comment> > > > > > > > > > The JNI code, however, uses the return statement: > > > /* > > > * Class: org.gnu.glib.Value > > > * Method: g_value_init > > > * Signature: ([Lint ;I)I > > > */ > > > JNIEXPORT jint JNICALL > Java_org_gnu_glib_Value_g_1value_1init (JNIEnv > > > *env, jclass cls, > > > jintArray value, jint type) > > > { > > > gint *value_g_g = (gint *) > (*env)->GetIntArrayElements (env, value, > > > NULL); > > > GValue *value_g = (GValue *)value_g_g; > > > GType type_g = (GType)&type; > > > { > > > return (jint)g_value_init (value_g, type_g); > > > } > > > } > > > > > > > > > Although this return value is ignored in the java code: > > > /** > > > * Construct a new Value from a given org.gnu.glib.Value. > > > */ > > > public Value(Type type) { > > > int [] vptr = new int[1]; > > > Value.g_value_init(vptr, type.getHandle()); > > > handle = vptr[0]; > > > } > > > > > > Could someone who knows more about this please check it and either > > > confirm that the Value code is correct or try to fix it. > > > > > > Thanks > > > -- > > -- > > +----------------------------------------------+ > | Mark Howard cam.ac.uk mh344@ | > | http://www.tildemh.com tildemh.com mh@ | > +----------------------------------------------+ > |
From: Mark H. <mh...@ti...> - 2002-08-30 13:59:02
|
On Fri, 2002-08-30 at 12:24, Jeffrey Morgan wrote: > I just checked some code into cvs that I think should resolve > this issue. I don't have a test case to verify if it works. > Are you in a position to test this method? My original test is in src/examples/gtk/tree/TreeExample.java (it's actually a list example, but that's not important) I'm now getting a different error: (java-gnome:2091): Gtk-CRITICAL **: file gtkliststore.c: line 1294 (gtk_list_store_append): assertion `iter !=3D NULL' failed (java-gnome:2091): GLib-GObject-WARNING **: gvalue.c:86:g_value_init(): cannot initialize GValue with type `(null)', the value has already been initialized as `(null)' An unexpected exception has been detected in native code outside the VM. Unexpected Signal : 11 occurred at PC=3D0x49df27d2 Function name=3Dg_type_check_value_holds Library=3D/usr/lib/libgobject-2.0.so.0 Current Java thread: at org.gnu.glib.Value.g_value_set_string(Native Method) at org.gnu.glib.Value.setString(Value.java:55) at tree.TreeExample.<init>(TreeExample.java:35) at tree.TreeExample.main(TreeExample.java:48) It's the same line, but looks like a problem with glib.Type this time.=20 --=20 +----------------------------------------------+ | Mark Howard cam.ac.uk mh344@ | | http://www.tildemh.com tildemh.com mh@ | +----------------------------------------------+ |
From: Jeffrey M. <ku...@zo...> - 2002-08-31 12:08:25
|
I will try to take a look over the weekend. On Fri, 2002-08-30 at 09:39, Mark Howard wrote: > On Fri, 2002-08-30 at 12:24, Jeffrey Morgan wrote: > > I just checked some code into cvs that I think should resolve > > this issue. I don't have a test case to verify if it works. > > Are you in a position to test this method? > > My original test is in src/examples/gtk/tree/TreeExample.java > (it's actually a list example, but that's not important) > > I'm now getting a different error: > (java-gnome:2091): Gtk-CRITICAL **: file gtkliststore.c: line 1294 > (gtk_list_store_append): assertion `iter != NULL' failed > > (java-gnome:2091): GLib-GObject-WARNING **: gvalue.c:86:g_value_init(): > cannot initialize GValue with type `(null)', the value has already been > initialized as `(null)' > An unexpected exception has been detected in native code outside the VM. > Unexpected Signal : 11 occurred at PC=0x49df27d2 > Function name=g_type_check_value_holds > Library=/usr/lib/libgobject-2.0.so.0 > > Current Java thread: > at org.gnu.glib.Value.g_value_set_string(Native Method) > at org.gnu.glib.Value.setString(Value.java:55) > at tree.TreeExample.<init>(TreeExample.java:35) > at tree.TreeExample.main(TreeExample.java:48) > > It's the same line, but looks like a problem with glib.Type this time. > > -- > > +----------------------------------------------+ > | Mark Howard cam.ac.uk mh344@ | > | http://www.tildemh.com tildemh.com mh@ | > +----------------------------------------------+ |
From: Jeffrey M. <Jef...@Br...> - 2002-09-03 13:23:24
|
Are you still having this problem? If so I hope to look into it now. -Jeff > -----Original Message----- > From: Mark Howard [mailto:mh...@ti...] > Sent: Friday, August 30, 2002 9:40 AM > To: jav...@li... > Subject: RE: [java-gnome-hackers] Tree/List widgets > > > On Fri, 2002-08-30 at 12:24, Jeffrey Morgan wrote: > > I just checked some code into cvs that I think should resolve > > this issue. I don't have a test case to verify if it works. > > Are you in a position to test this method? > > My original test is in src/examples/gtk/tree/TreeExample.java > (it's actually a list example, but that's not important) > > I'm now getting a different error: > (java-gnome:2091): Gtk-CRITICAL **: file gtkliststore.c: line 1294 > (gtk_list_store_append): assertion `iter != NULL' failed > > (java-gnome:2091): GLib-GObject-WARNING **: > gvalue.c:86:g_value_init(): > cannot initialize GValue with type `(null)', the value has > already been > initialized as `(null)' > An unexpected exception has been detected in native code > outside the VM. > Unexpected Signal : 11 occurred at PC=0x49df27d2 > Function name=g_type_check_value_holds > Library=/usr/lib/libgobject-2.0.so.0 > > Current Java thread: > at org.gnu.glib.Value.g_value_set_string(Native Method) > at org.gnu.glib.Value.setString(Value.java:55) > at tree.TreeExample.<init>(TreeExample.java:35) > at tree.TreeExample.main(TreeExample.java:48) > > It's the same line, but looks like a problem with glib.Type > this time. > > -- > > +----------------------------------------------+ > | Mark Howard cam.ac.uk mh344@ | > | http://www.tildemh.com tildemh.com mh@ | > +----------------------------------------------+ > |
From: Mark H. <mh...@ti...> - 2002-09-03 15:41:58
|
On Tue, 2002-09-03 at 14:23, Jeffrey Morgan wrote: > Are you still having this problem? =20 yes. >If so I hope > to look into it now. Thanks. > > -Jeff >=20 > > -----Original Message----- > > From: Mark Howard [mailto:mh...@ti...] > > Sent: Friday, August 30, 2002 9:40 AM > > To: jav...@li... > > Subject: RE: [java-gnome-hackers] Tree/List widgets > >=20 > >=20 > > On Fri, 2002-08-30 at 12:24, Jeffrey Morgan wrote: > > > I just checked some code into cvs that I think should resolve > > > this issue. I don't have a test case to verify if it works. > > > Are you in a position to test this method? > >=20 > > My original test is in src/examples/gtk/tree/TreeExample.java > > (it's actually a list example, but that's not important) > >=20 > > I'm now getting a different error: > > (java-gnome:2091): Gtk-CRITICAL **: file gtkliststore.c: line 1294 > > (gtk_list_store_append): assertion `iter !=3D NULL' failed > >=20 > > (java-gnome:2091): GLib-GObject-WARNING **:=20 > > gvalue.c:86:g_value_init(): > > cannot initialize GValue with type `(null)', the value has=20 > > already been > > initialized as `(null)' > > An unexpected exception has been detected in native code=20 > > outside the VM. > > Unexpected Signal : 11 occurred at PC=3D0x49df27d2 > > Function name=3Dg_type_check_value_holds > > Library=3D/usr/lib/libgobject-2.0.so.0 > >=20 > > Current Java thread: > > at org.gnu.glib.Value.g_value_set_string(Native Method) > > at org.gnu.glib.Value.setString(Value.java:55) > > at tree.TreeExample.<init>(TreeExample.java:35) > > at tree.TreeExample.main(TreeExample.java:48) > >=20 > > It's the same line, but looks like a problem with glib.Type=20 > > this time.=20 > >=20 > > --=20 > >=20 > > +----------------------------------------------+ > > | Mark Howard cam.ac.uk mh344@ | > > | http://www.tildemh.com tildemh.com mh@ | > > +----------------------------------------------+ > >=20 --=20 +----------------------------------------------+ | Mark Howard cam.ac.uk mh344@ | | http://www.tildemh.com tildemh.com mh@ | +----------------------------------------------+ |
From: Jeffrey M. <Jef...@Br...> - 2002-09-03 18:11:19
|
The primary problem with the first and third errors below are that you must provide a valid TreeIter on a call to append. You are just passing 0 as the TreeIter argument to gtk_list_store_append. This is causing the first error. Next, you are constructing a TreeIter passing 0 to the constructor in the append method. This creates an invalid TreeIter which is later used, causing the third error. To resolve these problems I suggest making a change to the generated code for ListStore (and all like classes) passing a TreeIter* as an argument. This will cause the native methods to take an int array as the argument. Using this method you will be able to retrieve the updated TreeIter once the call is made. You should be able to safely create a java TreeIter from this handle. Also, you will need to change the public interface for the append method requiring a valid TreeIter. Let me know if you want help with this. -Jeff > I'm now getting a different error: > (java-gnome:2091): Gtk-CRITICAL **: file gtkliststore.c: line 1294 > (gtk_list_store_append): assertion `iter != NULL' failed > > (java-gnome:2091): GLib-GObject-WARNING **: > gvalue.c:86:g_value_init(): > cannot initialize GValue with type `(null)', the value has > already been > initialized as `(null)' > An unexpected exception has been detected in native code > outside the VM. > Unexpected Signal : 11 occurred at PC=0x49df27d2 > Function name=g_type_check_value_holds > Library=/usr/lib/libgobject-2.0.so.0 > > Current Java thread: > at org.gnu.glib.Value.g_value_set_string(Native Method) > at org.gnu.glib.Value.setString(Value.java:55) > at tree.TreeExample.<init>(TreeExample.java:35) > at tree.TreeExample.main(TreeExample.java:48) > > It's the same line, but looks like a problem with glib.Type > this time. > > -- > > +----------------------------------------------+ > | Mark Howard cam.ac.uk mh344@ | > | http://www.tildemh.com tildemh.com mh@ | > +----------------------------------------------+ > |
From: Mark H. <mh...@ti...> - 2002-09-03 20:13:09
|
Thanks. That does solve part of the problem. I will look into the rest in the morning when I have more time.=20 The gtk.TreeModel class (jni and java) hasn't been created. Is there any reason for this? > > (java-gnome:2091): GLib-GObject-WARNING **:=20 > > gvalue.c:86:g_value_init(): > > cannot initialize GValue with type `(null)', the value has=20 > > already been > > initialized as `(null)' This error is still occurring though. I will see what I can find in the morning. --=20 +----------------------------------------------+ | Mark Howard cam.ac.uk mh344@ | | http://www.tildemh.com tildemh.com mh@ | +----------------------------------------------+ |
From: Mark H. <mh...@ti...> - 2002-09-04 09:46:37
|
On Tue, 2002-09-03 at 19:11, Jeffrey Morgan wrote: > Let me know if you want help with this. I do. I've been trying for quite a while now but have made little progress. I changed the TreeIter append method to=20 JNIEXPORT jint JNICALL Java_org_gnu_gtk_ListStore_gtk_1list_1store_1append (JNIEnv *env, jclass cls, jint listStore)=20 { GtkListStore *listStore_g =3D (GtkListStore *)listStore; GtkTreeIter *iter_g =3D (GtkTreeIter *) g_malloc(sizeof(GtkTreeIter)); { gtk_list_store_append (listStore_g, iter_g); } return (jint)iter_g; } This removed the iter errors.=20 But then there are a number of error relating the the glib.Value and glib.Type classes. A number of them were resolved by bypassing those classes and creating new set methods in ListStore (I had planned to do something similar in the java code anyway): JNIEXPORT void JNICALL Java_org_gnu_gtk_ListStore_gtk_1list_1store_1set_1value_1string (JNIEnv *env,=20 jclass cls, jint listStore, jint iter, jint column, char* strvalue)=20 { GtkListStore *listStore_g =3D (GtkListStore *)listStore; GtkTreeIter *iter_g =3D (GtkTreeIter *)iter; gint32 column_g =3D (gint32) column;=09 =09 GValue *test; GValue *value_g =3D g_value_init(test, G_TYPE_STRING); { gtk_list_store_set_value (listStore_g, iter_g, column_g, test); } } This removed more of the warnings, but then I started to get strange errors from the ListStore constructor (which still uses glib.Type).=20 I think the main error is probably something to do with constructing and returning glib.Type objects. Also, there could be problems with gtk_value_init in some places - this takes and empty gvalue as an argument and should initialise it, but there is also a gvalue returned - I'm not sure what this is. I've not committed any of the above changes.=20 The src/examples/gtk/tree/TreeExample.java is still the current target for testing.=20 --=20 +----------------------------------------------+ | Mark Howard cam.ac.uk mh344@ | | http://www.tildemh.com tildemh.com mh@ | +----------------------------------------------+ |
From: Jeffrey M. <Jef...@Br...> - 2002-09-04 11:47:41
|
Let me give it a try this morning. I'll let you know once it is in cvs. -Jeff > On Tue, 2002-09-03 at 19:11, Jeffrey Morgan wrote: > > Let me know if you want help with this. > I do. > > I've been trying for quite a while now but have made little > progress. I > changed the TreeIter append method to > JNIEXPORT jint JNICALL > Java_org_gnu_gtk_ListStore_gtk_1list_1store_1append (JNIEnv > *env, jclass > cls, jint listStore) > { > GtkListStore *listStore_g = (GtkListStore *)listStore; > GtkTreeIter *iter_g = (GtkTreeIter *) > g_malloc(sizeof(GtkTreeIter)); > { > gtk_list_store_append (listStore_g, iter_g); > } > return (jint)iter_g; > } > > This removed the iter errors. > > But then there are a number of error relating the the glib.Value and > glib.Type classes. A number of them were resolved by bypassing those > classes and creating new set methods in ListStore (I had planned to do > something similar in the java code anyway): > JNIEXPORT void JNICALL > Java_org_gnu_gtk_ListStore_gtk_1list_1store_1set_1value_1strin > g (JNIEnv > *env, > jclass cls, jint listStore, jint iter, jint column, char* > strvalue) > { > GtkListStore *listStore_g = (GtkListStore *)listStore; > GtkTreeIter *iter_g = (GtkTreeIter *)iter; > gint32 column_g = (gint32) column; > > GValue *test; > GValue *value_g = g_value_init(test, G_TYPE_STRING); > { > gtk_list_store_set_value (listStore_g, iter_g, column_g, > test); > } > } > > This removed more of the warnings, but then I started to get strange > errors from the ListStore constructor (which still uses glib.Type). > > I think the main error is probably something to do with > constructing and > returning glib.Type objects. > > Also, there could be problems with gtk_value_init in some > places - this > takes and empty gvalue as an argument and should initialise it, but > there is also a gvalue returned - I'm not sure what this is. > > I've not committed any of the above changes. > The src/examples/gtk/tree/TreeExample.java is still the current target > for testing. > -- > > +----------------------------------------------+ > | Mark Howard cam.ac.uk mh344@ | > | http://www.tildemh.com tildemh.com mh@ | > +----------------------------------------------+ > |
From: Jeffrey M. <ku...@zo...> - 2002-09-04 23:06:51
|
Sorry. I wasn't able to get to this today. I will give it a try tomorrow. -Jeff On Wed, 2002-09-04 at 07:47, Jeffrey Morgan wrote: > Let me give it a try this morning. I'll let you know once it > is in cvs. > > -Jeff > > > On Tue, 2002-09-03 at 19:11, Jeffrey Morgan wrote: > > > Let me know if you want help with this. > > I do. > > > > I've been trying for quite a while now but have made little > > progress. I > > changed the TreeIter append method to > > JNIEXPORT jint JNICALL > > Java_org_gnu_gtk_ListStore_gtk_1list_1store_1append (JNIEnv > > *env, jclass > > cls, jint listStore) > > { > > GtkListStore *listStore_g = (GtkListStore *)listStore; > > GtkTreeIter *iter_g = (GtkTreeIter *) > > g_malloc(sizeof(GtkTreeIter)); > > { > > gtk_list_store_append (listStore_g, iter_g); > > } > > return (jint)iter_g; > > } > > > > This removed the iter errors. > > > > But then there are a number of error relating the the glib.Value and > > glib.Type classes. A number of them were resolved by bypassing those > > classes and creating new set methods in ListStore (I had planned to do > > something similar in the java code anyway): > > JNIEXPORT void JNICALL > > Java_org_gnu_gtk_ListStore_gtk_1list_1store_1set_1value_1strin > > g (JNIEnv > > *env, > > jclass cls, jint listStore, jint iter, jint column, char* > > strvalue) > > { > > GtkListStore *listStore_g = (GtkListStore *)listStore; > > GtkTreeIter *iter_g = (GtkTreeIter *)iter; > > gint32 column_g = (gint32) column; > > > > GValue *test; > > GValue *value_g = g_value_init(test, G_TYPE_STRING); > > { > > gtk_list_store_set_value (listStore_g, iter_g, column_g, > > test); > > } > > } > > > > This removed more of the warnings, but then I started to get strange > > errors from the ListStore constructor (which still uses glib.Type). > > > > I think the main error is probably something to do with > > constructing and > > returning glib.Type objects. > > > > Also, there could be problems with gtk_value_init in some > > places - this > > takes and empty gvalue as an argument and should initialise it, but > > there is also a gvalue returned - I'm not sure what this is. > > > > I've not committed any of the above changes. > > The src/examples/gtk/tree/TreeExample.java is still the current target > > for testing. > > -- > > > > +----------------------------------------------+ > > | Mark Howard cam.ac.uk mh344@ | > > | http://www.tildemh.com tildemh.com mh@ | > > +----------------------------------------------+ > > |
From: Jeffrey M. <Jef...@Br...> - 2002-09-04 12:11:33
|
> The gtk.TreeModel class (jni and java) hasn't been created. > Is there any > reason for this? GTypeInterface, the base class for GtkTreeModel, is the glib attempt to provide the equalivant to a Java interface. In my opinion it is implemented poorly and provides very little benefit. GtkTreeModel suffers from some of the problems that exist in GTypeInterface. When I have the time I will go into more details on this topic. TreeModel wasn't created because when I put together the defs file for the latest gtk implementation I wasn't quite sure how to best implement this beast. I currently believe that TreeModel should be implemented as an abstract base class. We should be able to use the code generator to generate the class and then make a few manual changes (like making it abstract). -Jeff |