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, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
23 orient_toggled (GtkToggleButton *button, gpointer user_data)
25 GList *orientables = (GList *) user_data, *ptr;
26 gboolean state = gtk_toggle_button_get_active (button);
27 GtkOrientation orientation;
31 orientation = GTK_ORIENTATION_VERTICAL;
32 gtk_button_set_label (GTK_BUTTON (button), "Vertical");
36 orientation = GTK_ORIENTATION_HORIZONTAL;
37 gtk_button_set_label (GTK_BUTTON (button), "Horizontal");
40 for (ptr = orientables; ptr; ptr = ptr->next)
42 GtkOrientable *orientable = GTK_ORIENTABLE (ptr->data);
44 gtk_orientable_set_orientation (orientable, orientation);
49 main (int argc, char **argv)
53 GtkWidget *box, *button;
54 GList *orientables = NULL;
56 gtk_init (&argc, &argv);
58 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
59 table = gtk_table_new (2, 3, FALSE);
60 gtk_table_set_row_spacings (GTK_TABLE (table), 12);
61 gtk_table_set_col_spacings (GTK_TABLE (table), 12);
64 box = gtk_hbox_new (6, FALSE);
65 orientables = g_list_prepend (orientables, box);
66 gtk_table_attach_defaults (GTK_TABLE (table), box, 0, 1, 1, 2);
67 gtk_box_pack_start (GTK_BOX (box),
68 gtk_button_new_with_label ("GtkBox 1"),
70 gtk_box_pack_start (GTK_BOX (box),
71 gtk_button_new_with_label ("GtkBox 2"),
73 gtk_box_pack_start (GTK_BOX (box),
74 gtk_button_new_with_label ("GtkBox 3"),
78 box = gtk_hbutton_box_new ();
79 orientables = g_list_prepend (orientables, box);
80 gtk_table_attach_defaults (GTK_TABLE (table), box, 1, 2, 1, 2);
81 gtk_box_pack_start (GTK_BOX (box),
82 gtk_button_new_with_label ("GtkButtonBox 1"),
84 gtk_box_pack_start (GTK_BOX (box),
85 gtk_button_new_with_label ("GtkButtonBox 2"),
87 gtk_box_pack_start (GTK_BOX (box),
88 gtk_button_new_with_label ("GtkButtonBox 3"),
92 box = gtk_hseparator_new ();
93 orientables = g_list_prepend (orientables, box);
94 gtk_table_attach_defaults (GTK_TABLE (table), box, 2, 3, 1, 2);
96 button = gtk_toggle_button_new_with_label ("Horizontal");
97 gtk_table_attach (GTK_TABLE (table), button, 0, 1, 0, 1,
98 GTK_FILL, GTK_FILL, 0, 0);
99 g_signal_connect (button, "toggled",
100 G_CALLBACK (orient_toggled), orientables);
102 gtk_container_add (GTK_CONTAINER (window), table);
103 gtk_widget_show_all (window);
105 g_signal_connect (window, "destroy",
106 G_CALLBACK (gtk_main_quit), NULL);