cglade

How to open and close a modal window in Glade with C


I'm trying to do this using show-hide.

Glade-GTK-Terminal pic


Solution

  • To open a window (show the window)
    In Glade
    For main window GtkImageMenuItem, set its ID to: helpabout
    For main window Signals, activate, set: handler on_helpabout_activate, data about
    Create a GtkWindow ID: about. Window flags: remove deletable, add modal
    In C

    void on_helpabout_activate(GtkMenuItem *helpabout, GtkWidget *a)
    {
        printf("Showing about\n");
        gtk_widget_show (a);
    }
    

    To close a window (hide the window)
    In Glade
    For window about, add a button ID: butt
    For butt Signals, clicked, set: handler on_butt_clicked, data about
    In C

    void on_butt_clicked (GtkButton *butt, GtkWidget *a)
    {
        printf("Hiding about\n");
        gtk_widget_hide (a);
    }