2 * Copyright (C) 2007 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 value_changed (GtkWidget *button,
25 g_message ("volume changed to %f", volume);
29 toggle_orientation (GtkWidget *button,
30 GtkWidget *scalebutton)
32 if (gtk_orientable_get_orientation (GTK_ORIENTABLE (scalebutton)) ==
33 GTK_ORIENTATION_HORIZONTAL)
35 gtk_orientable_set_orientation (GTK_ORIENTABLE (scalebutton),
36 GTK_ORIENTATION_VERTICAL);
40 gtk_orientable_set_orientation (GTK_ORIENTABLE (scalebutton),
41 GTK_ORIENTATION_HORIZONTAL);
46 response_cb (GtkDialog *dialog,
50 gtk_widget_destroy (GTK_WIDGET (dialog));
54 show_error (gpointer data)
56 GtkWindow *window = (GtkWindow *) data;
59 g_message ("showing error");
61 dialog = gtk_message_dialog_new (window,
65 "This should have unbroken the grab");
66 g_signal_connect (G_OBJECT (dialog),
68 G_CALLBACK (response_cb), NULL);
69 gtk_widget_show (dialog);
71 return G_SOURCE_REMOVE;
84 gtk_init (&argc, &argv);
86 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
87 button = gtk_volume_button_new ();
88 button2 = gtk_volume_button_new ();
89 box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
91 g_signal_connect (G_OBJECT (button), "value-changed",
92 G_CALLBACK (value_changed),
95 gtk_container_add (GTK_CONTAINER (window), box);
96 gtk_container_add (GTK_CONTAINER (box), button);
97 gtk_container_add (GTK_CONTAINER (box), button2);
99 button3 = gtk_button_new_with_label ("Toggle orientation");
100 gtk_container_add (GTK_CONTAINER (box), button3);
102 g_signal_connect (G_OBJECT (button3), "clicked",
103 G_CALLBACK (toggle_orientation),
105 g_signal_connect (G_OBJECT (button3), "clicked",
106 G_CALLBACK (toggle_orientation),
109 gtk_widget_show_all (window);
110 gtk_button_clicked (GTK_BUTTON (button));
111 g_timeout_add (4000, (GSourceFunc) show_error, window);