RE: getting a pointer to a GtkWindow



I'm trying to learn the basics of gtk. I've created a simple app with
the layout done in glade. I can use lookup widget to get a pointer to
the current window, but it doesn't find other windows in the app.

When using glade, the pointer that is returned to you from glade_xml_new():
http://developer.gnome.org/doc/API/2.0/libglade/GladeXML.html#glade-xml-new

is the topmost hierarchical widget, hence, if the pointer is the first
window, you can not then find the second window using this pointer.

The way to do this is:

        GladeXML *xml1 = NULL;
        GladeXML *xml2 = NULL;
        GtkWidget *window1 = NULL;
        GtkWidget *window2 = NULL;

        /* this shows the window - unless it is invisible */
        xml1 = glade_xml_new ("myinterface.glade", "window1", NULL);

        /* this gets the widget pointer for window 1 */
        window1 = glade_xml_get_widget (xml1, "window1");

        /* connect signals here */

        /* clean up */
        if(xml1) g_object_unref(G_OBJECT(xml1));

        /* get window 2 */
        xml2 = glade_xml_new ("myinterface.glade", "window2", NULL);

        /* this gets the widget pointer for window 2*/
        window1 = glade_xml_get_widget (xml2, "window2");

        /* connect signals here */

        /* clean up */
        if(xml2) g_object_unref(G_OBJECT(xml2));


I need to find a way to open a new window (when the user clicks a
button). I also need to figure how to stop the second window from
showing automatically when the program loads up, the visible property
for the window in glade doesn't seem to change anything.

It does work.  Perhaps you have missed something?


Regards,
Martyn



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]