4 print_hello (GtkWidget
*widget
,
7 gchar
* msg
= (gchar
*) data
;
13 activate (GtkApplication
*app
,
20 /* create a new window, and set its title */
21 window
= gtk_application_window_new (app
);
22 gtk_window_set_title (GTK_WINDOW (window
), "Window");
23 gtk_container_set_border_width (GTK_CONTAINER (window
), 10);
25 /* Here we construct the container that is going pack our buttons */
26 grid
= gtk_grid_new ();
28 /* Pack the container in the window */
29 gtk_container_add (GTK_CONTAINER (window
), grid
);
31 button
= gtk_button_new_with_label ("Button 1");
32 g_signal_connect (button
, "clicked", G_CALLBACK (print_hello
), "Hello World #1");
34 /* Place the first button in the grid cell (0, 0), and make it fill
35 * just 1 cell horizontally and vertically (ie no spanning)
37 gtk_grid_attach (GTK_GRID (grid
), button
, 0, 0, 1, 1);
39 button
= gtk_button_new_with_label ("Button 2");
40 g_signal_connect (button
, "clicked", G_CALLBACK (print_hello
), "Hello World #2");
42 /* Place the second button in the grid cell (1, 0), and make it fill
43 * just 1 cell horizontally and vertically (ie no spanning)
45 gtk_grid_attach (GTK_GRID (grid
), button
, 1, 0, 1, 1);
47 button
= gtk_button_new_with_label ("Quit");
48 g_signal_connect_swapped (button
, "clicked", G_CALLBACK (gtk_widget_destroy
), window
);
50 /* Place the Quit button in the grid cell (0, 1), and make it
53 gtk_grid_attach (GTK_GRID (grid
), button
, 0, 1, 2, 1);
55 /* Now that we are done packing our widgets, we show them all
56 * in one go, by calling gtk_widget_show_all() on the window.
57 * This call recursively calls gtk_widget_show() on all widgets
58 * that are contained in the window, directly or indirectly.
60 gtk_widget_show_all (window
);
71 app
= gtk_application_new ("org.gtk.example", G_APPLICATION_DEFAULT_FLAGS
);
72 g_signal_connect (app
, "activate", G_CALLBACK (activate
), NULL
);
73 status
= g_application_run (G_APPLICATION (app
), argc
, argv
);