[crossfire] libglade...
Kevin R. Bulgrien
kbulgrien at worldnet.att.net
Fri Aug 10 23:33:52 CDT 2007
Ok, a branch gtk-v2-libglade has been created. I'm making progress on
the conversion now. It's mostly a bunch of rock breaking.
> (crossfire-client-gtk2:1780): Gtk-CRITICAL **: gtk_widget_set_size_request: assertion `GTK_IS_WIDGET (widget)' failed
>
> ** (crossfire-client-gtk2:1780): WARNING **: Widget not found: map_notebook
>
> Program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread 47046947261936 (LWP 1780)]
> 0x00000000004180dd in map_init (window_root=0x9920c0) at map.c:100
> 100 mapgc = gdk_gc_new(map_drawing_area->window);
> (gdb) bt
> #0 0x00000000004180dd in map_init (window_root=0x9920c0) at map.c:100
> #1 0x0000000000417eae in main (argc=1, argv=0x7fffb7d82098) at main.c:695
>
> I only changed code in main.c for the window_root, so perhaps it has
> something to do with needing other things initializing from the .glade
> file too.
The other windows are converted to load from the xml file now, but the
segfault was caused because lookup_widget() calls were returning null
pointers. lookup_widget() is not working with libglade.
The problem is addressed in a libglade FAQ...
| 4.5 How do I get a pointer to a widget from within a signal handler?
|
| If you have a pointer to any widget in a window, you can get a pointer to
| any other widget in the window using the lookup_widget() function that Glade
| provides (in support.c).
|
| You pass it a pointer to any widget in a window, and the name of the widget
| that you want to get. Usually in signal handlers you can use the first argument
| to the signal handler as the first parameter to lookup_widget(), e.g.
|
| void
| on_button1_clicked (GtkButton *button, gpointer user_data)
| {
| GtkWidget *entry1;
|
| entry1 = lookup_widget (GTK_WIDGET (button), "entry1");
| ...
| }
|
| Note that this does not work if you are using libglade. The corresponding
| code for libglade would be:
|
| void on_button1_clicked (GtkButton *button, gpointer user_data)
| {
| GladeXML* xml;
| GtkWidget* entry1;
|
| xml = glade_get_widget_tree (GTK_WIDGET (button1));
| entry1 = glade_xml_get_widget (xml, "entry1");
| ...
| }
And there are a lot of lookup_widget() calls to replace in that client code.
But, after only doing a couple of files, it is obvious that the problem is
fixing. The windows render more completely with each lookup_widget
that is converted.
Kevin R. Bulgrien
More information about the crossfire
mailing list