Add powerbox hook
[gtk-with-powerbox.git] / tests / testvolumebutton.c
blob28ccede8524e3d86c8a3198b03ad2e2577023a0f
1 /* testvolumebutton.c
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.
20 #include <gtk/gtk.h>
22 static void
23 value_changed (GtkWidget *button,
24 gdouble volume,
25 gpointer user_data)
27 g_message ("volume changed to %f", volume);
30 static void
31 response_cb (GtkDialog *dialog,
32 gint arg1,
33 gpointer user_data)
35 gtk_widget_destroy (GTK_WIDGET (dialog));
38 static gboolean
39 show_error (gpointer data)
41 GtkWindow *window = (GtkWindow *) data;
42 GtkWidget *dialog;
44 g_message ("showing error");
46 dialog = gtk_message_dialog_new (window,
47 GTK_DIALOG_MODAL,
48 GTK_MESSAGE_INFO,
49 GTK_BUTTONS_CLOSE,
50 "This should have unbroken the grab");
51 g_signal_connect (G_OBJECT (dialog),
52 "response",
53 G_CALLBACK (response_cb), NULL);
54 gtk_widget_show (dialog);
56 return FALSE;
59 int main (int argc, char **argv)
61 GtkWidget *window;
62 GtkWidget *button;
63 GtkWidget *button2;
64 GtkWidget *box;
66 gtk_init (&argc, &argv);
68 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
69 button = gtk_volume_button_new ();
70 button2 = gtk_volume_button_new ();
71 box = gtk_hbox_new (FALSE, 0);
73 g_signal_connect (G_OBJECT (button),
74 "value-changed",
75 G_CALLBACK (value_changed), NULL);
76 gtk_container_add (GTK_CONTAINER (window), box);
77 gtk_container_add (GTK_CONTAINER (box), button);
78 gtk_container_add (GTK_CONTAINER (box), button2);
80 gtk_widget_show_all (window);
81 gtk_button_clicked (GTK_BUTTON (button));
82 g_timeout_add (4000, (GSourceFunc) show_error, window);
84 gtk_main ();
86 return 0;