2 * Copyright (C) 2004 Red Hat, Inc.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
21 orient_toggled (GtkToggleButton *button, gpointer user_data)
23 GList *orientables = (GList *) user_data, *ptr;
24 gboolean state = gtk_toggle_button_get_active (button);
25 GtkOrientation orientation;
29 orientation = GTK_ORIENTATION_VERTICAL;
30 gtk_button_set_label (GTK_BUTTON (button), "Vertical");
34 orientation = GTK_ORIENTATION_HORIZONTAL;
35 gtk_button_set_label (GTK_BUTTON (button), "Horizontal");
38 for (ptr = orientables; ptr; ptr = ptr->next)
40 GtkOrientable *orientable = GTK_ORIENTABLE (ptr->data);
42 gtk_orientable_set_orientation (orientable, orientation);
47 main (int argc, char **argv)
51 GtkWidget *box, *button;
52 GList *orientables = NULL;
54 gtk_init (&argc, &argv);
56 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
57 grid= gtk_grid_new ();
58 gtk_grid_set_row_spacing (GTK_GRID (grid), 12);
59 gtk_grid_set_column_spacing (GTK_GRID (grid), 12);
62 box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
63 orientables = g_list_prepend (orientables, box);
64 gtk_grid_attach (GTK_GRID (grid), box, 0, 1, 1, 1);
65 gtk_box_pack_start (GTK_BOX (box),
66 gtk_button_new_with_label ("GtkBox 1"),
68 gtk_box_pack_start (GTK_BOX (box),
69 gtk_button_new_with_label ("GtkBox 2"),
71 gtk_box_pack_start (GTK_BOX (box),
72 gtk_button_new_with_label ("GtkBox 3"),
76 box = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
77 orientables = g_list_prepend (orientables, box);
78 gtk_grid_attach (GTK_GRID (grid), box, 1, 1, 1, 1);
79 gtk_box_pack_start (GTK_BOX (box),
80 gtk_button_new_with_label ("GtkButtonBox 1"),
82 gtk_box_pack_start (GTK_BOX (box),
83 gtk_button_new_with_label ("GtkButtonBox 2"),
85 gtk_box_pack_start (GTK_BOX (box),
86 gtk_button_new_with_label ("GtkButtonBox 3"),
90 box = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
91 orientables = g_list_prepend (orientables, box);
92 gtk_grid_attach (GTK_GRID (grid), box, 2, 1, 1, 1);
94 button = gtk_toggle_button_new_with_label ("Horizontal");
95 gtk_grid_attach (GTK_GRID (grid), button, 0, 0, 1, 1);
96 g_signal_connect (button, "toggled",
97 G_CALLBACK (orient_toggled), orientables);
99 gtk_container_add (GTK_CONTAINER (window), grid);
100 gtk_widget_show_all (window);
102 g_signal_connect (window, "destroy",
103 G_CALLBACK (gtk_main_quit), NULL);