4 /* I'm going to be lazy and use some global variables to
5 * store the position of the widget within the fixed
10 /* This callback function moves the button to a new position
11 * in the Fixed container. */
12 static void move_button( GtkWidget *widget,
17 gtk_fixed_move (GTK_FIXED (fixed), widget, x, y);
23 /* GtkWidget is the storage type for widgets */
30 gtk_init (&argc, &argv);
32 /* Create a new window */
33 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
34 gtk_window_set_title (GTK_WINDOW (window), "Fixed Container");
36 /* Here we connect the "destroy" event to a signal handler */
37 g_signal_connect (G_OBJECT (window), "destroy",
38 G_CALLBACK (gtk_main_quit), NULL);
40 /* Sets the border width of the window. */
41 gtk_container_set_border_width (GTK_CONTAINER (window), 10);
43 /* Create a Fixed Container */
44 fixed = gtk_fixed_new ();
45 gtk_container_add (GTK_CONTAINER (window), fixed);
46 gtk_widget_show (fixed);
48 for (i = 1 ; i <= 3 ; i++) {
49 /* Creates a new button with the label "Press me" */
50 button = gtk_button_new_with_label ("Press me");
52 /* When the button receives the "clicked" signal, it will call the
53 * function move_button() passing it the Fixed Container as its
55 g_signal_connect (G_OBJECT (button), "clicked",
56 G_CALLBACK (move_button), (gpointer) fixed);
58 /* This packs the button into the fixed containers window. */
59 gtk_fixed_put (GTK_FIXED (fixed), button, i*50, i*50);
61 /* The final step is to display this newly created widget. */
62 gtk_widget_show (button);
65 /* Display the window */
66 gtk_widget_show (window);
68 /* Enter the event loop */