Hi all,
I'm trying to make a program with 2 toplevel windows. With below code it somewhat works. After I launch the program, if I click on the preferences button it shows me the preferences window, but after I close the latter clicking on the preferences button does not show the preferences window anymore and just returns this error in the terminal:
[code=]Gtk-CRITICAL **: gtk_widget_show_all: assertion `GTK_IS_WIDGET (widget)' failed [/code]
Many thanks for any help in advance,
Rouslan
Code:
/* Create preference window */
pref_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_resizable (GTK_WINDOW (pref_window), FALSE);
gtk_widget_set_size_request (pref_window, 400, 250);
g_signal_connect (GTK_OBJECT (pref_window), "destroy",
G_CALLBACK (gtk_widget_destroy), pref_window);
gtk_window_set_title (GTK_WINDOW (pref_window), "Preferences");
gtk_container_set_border_width (GTK_CONTAINER (pref_window), 0);
vbox = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (pref_window), vbox);
/* Create main window */
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
gtk_widget_set_size_request (window, 800, 700);
g_signal_connect (GTK_OBJECT (window), "destroy",
G_CALLBACK (gtk_main_quit), NULL);
gtk_widget_show (window);
gtk_window_set_title (GTK_WINDOW (window), "Main window");
gtk_container_set_border_width (GTK_CONTAINER (window), 0);
hbox = gtk_hbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (window), hbox);
// here goes the rest of the code
config_button = gtk_button_new_from_stock (GTK_STOCK_PREFERENCES);
g_signal_connect (GTK_OBJECT (config_button), "clicked",
G_CALLBACK (show_prefs), NULL);
gtk_box_pack_start (GTK_BOX (vbox), config_button, TRUE, TRUE, 5);
The callback:
Code:
void show_prefs() {
gtk_widget_show_all (pref_window);
}