1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
void callback(GtkWidget *wid, gpointer ptr)
{
GtkWidget *win = static_cast<GtkWidget*>(ptr);
gtk_window_fullscreen(GTK_WINDOW(win));
}
int main() {
gtk_init(NULL,NULL);
GtkWidget *window1 = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(window1), "1th window");
gtk_window_fullscreen(GTK_WINDOW(window1));
GtkWidget *btn1 = gtk_button_new_with_label ("Go to 2th window");
gtk_container_add (GTK_CONTAINER (window1), btn1);
gtk_widget_show_all(window1);
GtkWidget *window2 = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(window2), "2th window");
//gtk_window_fullscreen(GTK_WINDOW(window2));
GtkWidget *btn2 = gtk_button_new_with_label ("Go back to 1th window");
gtk_container_add (GTK_CONTAINER (window2), btn2);
g_signal_connect(window1,"delete-event",G_CALLBACK(gtk_main_quit),NULL);
g_signal_connect(window2,"delete-event",G_CALLBACK(gtk_main_quit),NULL);
g_signal_connect (btn1, "clicked", G_CALLBACK (callback),window2);
g_signal_connect (btn2, "clicked", G_CALLBACK (callback),window1);
gtk_widget_show_all(window2);
gtk_main();
return 0;
}
| |