1 | /* testvolumebutton.c |
2 | * Copyright (C) 2007 Red Hat, Inc. |
3 | * |
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. |
8 | * |
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. |
13 | * |
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/>. |
16 | */ |
17 | |
18 | #include <gtk/gtk.h> |
19 | |
20 | static void |
21 | value_changed (GtkWidget *button, |
22 | double volume, |
23 | gpointer user_data) |
24 | { |
25 | g_message ("volume changed to %f" , volume); |
26 | } |
27 | |
28 | static void |
29 | response_cb (GtkDialog *dialog, |
30 | int arg1, |
31 | gpointer user_data) |
32 | { |
33 | gtk_window_destroy (GTK_WINDOW (dialog)); |
34 | } |
35 | |
36 | static gboolean |
37 | show_error (gpointer data) |
38 | { |
39 | GtkWindow *window = (GtkWindow *) data; |
40 | GtkWidget *dialog; |
41 | |
42 | g_message ("showing error" ); |
43 | |
44 | dialog = gtk_message_dialog_new (parent: window, |
45 | flags: GTK_DIALOG_MODAL, |
46 | type: GTK_MESSAGE_INFO, |
47 | buttons: GTK_BUTTONS_CLOSE, |
48 | message_format: "This should have unbroken the grab" ); |
49 | g_signal_connect_object (G_OBJECT (dialog), |
50 | detailed_signal: "response" , |
51 | G_CALLBACK (response_cb), NULL, connect_flags: 0); |
52 | gtk_widget_show (widget: dialog); |
53 | |
54 | return G_SOURCE_REMOVE; |
55 | } |
56 | |
57 | int |
58 | main (int argc, |
59 | char **argv) |
60 | { |
61 | GtkWidget *window; |
62 | GtkWidget *button; |
63 | GtkWidget *button2; |
64 | GtkWidget *box; |
65 | GtkWidget *vbox; |
66 | |
67 | gtk_init (); |
68 | |
69 | window = gtk_window_new (); |
70 | gtk_window_set_default_size (GTK_WINDOW (window), width: 400, height: 300); |
71 | button = gtk_volume_button_new (); |
72 | button2 = gtk_volume_button_new (); |
73 | vbox = gtk_box_new (orientation: GTK_ORIENTATION_VERTICAL, spacing: 0); |
74 | box = gtk_box_new (orientation: GTK_ORIENTATION_HORIZONTAL, spacing: 0); |
75 | |
76 | g_signal_connect (G_OBJECT (button), "value-changed" , |
77 | G_CALLBACK (value_changed), |
78 | NULL); |
79 | |
80 | gtk_window_set_child (GTK_WINDOW (window), child: vbox); |
81 | gtk_box_append (GTK_BOX (vbox), child: box); |
82 | gtk_box_append (GTK_BOX (box), child: button); |
83 | gtk_box_append (GTK_BOX (box), child: button2); |
84 | |
85 | gtk_widget_show (widget: window); |
86 | g_timeout_add (interval: 4000, function: (GSourceFunc) show_error, data: window); |
87 | |
88 | while (TRUE) |
89 | g_main_context_iteration (NULL, TRUE); |
90 | |
91 | return 0; |
92 | } |
93 | |