[Glade-users] Newbie libglade advice please?



I am just starting out with libglade. I have 2 windows in a glade file.
When the program starts, I want the "window_connect" shown. When the
user selects "Connect" button, I want to destroy the "window_connect"
widget and launch the "main_window". Can you please tell me if there are
any issues or improvements regarding my code below. It works, but is
there a better way.



#include <gtk/gtk.h>
#include <glade/glade.h>
#define FILENAME "../kds.glade"
static  GladeXML *xml;

int main (int argc, char *argv[])
{
        GtkWidget *window1;
        gtk_init(&argc, &argv);
        glade_init();
        xml = glade_xml_new(FILENAME, "window_connect",NULL);
        glade_xml_signal_autoconnect (xml);
        window1 = glade_xml_get_widget (xml, "window_connect");
        gtk_main ();
        return 0;
}

gboolean on_connect_cancel_button_clicked(GtkWidget *button)
{
    gtk_widget_destroy(gtk_widget_get_toplevel(button));
    return TRUE;
}

gboolean on_connect_connect_button_clicked(GtkWidget *button)
{
        GtkWidget *w;
        gtk_widget_destroy(gtk_widget_get_toplevel(button));
        xml = glade_xml_new(FILENAME, "main_window",NULL);
        glade_xml_signal_autoconnect (xml);
        w = glade_xml_get_widget (xml, "main_window");
        gtk_widget_show (w);    
        return TRUE;
}


Thanks,
Kim




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