Re: [java-gnome-hackers] EntryCompletion work
Brought to you by:
afcowie
From: Guillaume M. <res...@gm...> - 2009-06-25 16:24:49
|
I'm still stuck with another problem now. A NULL value is killing the example when I try to select a completion possibility. Exception in thread "main" org.gnome.glib.FatalError: GLib-GObject-WARNING invalid (NULL) pointer instance at org.gnome.gtk.GtkMain.gtk_main(Native Method) at org.gnome.gtk.GtkMain.main(GtkMain.java:57) at org.gnome.gtk.Gtk.main(Gtk.java:95) at ExampleEntryCompletion.main(ExampleEntryCompletion.java:205) By the way, just by curiosity, I add a "printf("Key: %s\n", key);" in emit_match() method and I noticed that the signal is emitted (2 * size_of_completion_list). Does someone know why? The unit-test class is in progress but I do not know how to use the complete() method. I try it also with pygtk and it doesn't seem to work. Did somebody use this method with another GTK library/binding? 2009/6/25 Andrew Cowie <an...@op...> On Wed, 2009-06-24 at 21:22 +0200, Guillaume Mazoyer wrote: > I attach a diff Could you send a patch bundle? [then other people (like me :))] can merge your branch into their own branches and try and duplicate the problem — and maybe even contribute a fix. While you're at it, please make sure to include the unit test that you're using to exhibit this problem. ++ The type for NULL terminated strings in GLib is G_TYPE_STRING. ++ > src/bindings/org/gnome/gtk/GtkEntryCompletionOverride.c: In function > ‘Java_org_gnome_gtk_GtkEntryCompletionOverride_gtk_1entry_1completion_1set_1match_1func’: > src/bindings/org/gnome/gtk/GtkEntryCompletionOverride.c:76: > attention : passing argument 2 of > ‘gtk_entry_completion_set_match_func’ from incompatible pointer type I'm guessing this is coming from > + // call function > + gtk_entry_completion_set_match_func(self, emit_match, self, NULL); if so, that means that you've got the signature of emit_match() wrong. It needs to be (*GtkEntryCompletionMatchFunc) which is gboolean something( GtkEntryCompletion *completion, const gchar *key, GtkTreeIter *iter, gpointer user_data) { } and you have +gboolean +emit_match +( + GtkEntryCompletion *source, + gchar *key, + GtkTreeIter *iter, + gpointer instance +) So I'd guess that the missing const qualifier is the reason you're getting a warning. ++ > + gtk_entry_completion_set_match_func(self, emit_match, self, NULL); Why are passing "self" as the user_data parameter? I'm guessing the answer to that is that copy & paste has bit you. The comment "note 2" in GtkTreeModelFilterOverride.c does not apply here. So you probably want: gtk_entry_completion_set_match_func(self, emit_match, NULL, NULL); and then I'm guessing: g_signal_emit_by_name(source, "match", key, iter, &result); up above in emit_match(). You will note that what you have now has one more parameter. g_signal_emit_by_name(GTK_ENTRY_COMPLETION(instance), "match", source, key, iter, &result); which would most certainly cause things to break if wrong. ++ It's things like this that make you begin to appreciate just how amazingly helpful a static strongly-typed language like Java is. We Java developers tend not to think about it. But when I try to do the "same" stuff in C, and you realize what one had to put up with trying to get signatures and function call arguments right, I really start to appreciate java-gnome proxying all this crap for me. As I said on IRC, you didn't pick an easy one. This is probably the most complicated hand-written override we have. That said, you are probably now getting a glimmer of why I'm so insistent in reusing the signal handling code path - imagine going through this parameter nonsense by hand every time you want to callback from C to Java. No thanks. AfC Sydney ------------------------------------------------------------------------------ _______________________________________________ java-gnome-hackers mailing list jav...@li... https://lists.sourceforge.net/lists/listinfo/java-gnome-hackers -- Guillaume Mazoyer (Respawner) - http://www.respawner.fr/ |