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, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
23 value_changed (GtkWidget *button,
27 g_message ("volume changed to %f", volume);
31 toggle_orientation (GtkWidget *button,
32 GtkWidget *scalebutton)
34 if (gtk_orientable_get_orientation (GTK_ORIENTABLE (scalebutton)) ==
35 GTK_ORIENTATION_HORIZONTAL)
37 gtk_orientable_set_orientation (GTK_ORIENTABLE (scalebutton),
38 GTK_ORIENTATION_VERTICAL);
42 gtk_orientable_set_orientation (GTK_ORIENTABLE (scalebutton),
43 GTK_ORIENTATION_HORIZONTAL);
48 response_cb (GtkDialog *dialog,
52 gtk_widget_destroy (GTK_WIDGET (dialog));
56 show_error (gpointer data)
58 GtkWindow *window = (GtkWindow *) data;
61 g_message ("showing error");
63 dialog = gtk_message_dialog_new (window,
67 "This should have unbroken the grab");
68 g_signal_connect (G_OBJECT (dialog),
70 G_CALLBACK (response_cb), NULL);
71 gtk_widget_show (dialog);
86 gtk_init (&argc, &argv);
88 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
89 button = gtk_volume_button_new ();
90 button2 = gtk_volume_button_new ();
91 box = gtk_hbox_new (FALSE, 0);
93 g_signal_connect (G_OBJECT (button), "value-changed",
94 G_CALLBACK (value_changed),
97 gtk_container_add (GTK_CONTAINER (window), box);
98 gtk_container_add (GTK_CONTAINER (box), button);
99 gtk_container_add (GTK_CONTAINER (box), button2);
101 button3 = gtk_button_new_with_label ("Toggle orientation");
102 gtk_container_add (GTK_CONTAINER (box), button3);
104 g_signal_connect (G_OBJECT (button3), "clicked",
105 G_CALLBACK (toggle_orientation),
107 g_signal_connect (G_OBJECT (button3), "clicked",
108 G_CALLBACK (toggle_orientation),
111 gtk_widget_show_all (window);
112 gtk_button_clicked (GTK_BUTTON (button));
113 g_timeout_add (4000, (GSourceFunc) show_error, window);