2007-05-19 23:35:00 +00:00
|
|
|
/* testvolumebutton.c
|
|
|
|
* Copyright (C) 2007 Red Hat, Inc.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
2012-02-27 13:01:10 +00:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2007-05-19 23:35:00 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
static void
|
|
|
|
value_changed (GtkWidget *button,
|
2008-07-21 12:58:36 +00:00
|
|
|
gdouble volume,
|
|
|
|
gpointer user_data)
|
2007-05-19 23:35:00 +00:00
|
|
|
{
|
2008-07-21 12:58:36 +00:00
|
|
|
g_message ("volume changed to %f", volume);
|
|
|
|
}
|
|
|
|
|
2007-05-19 23:35:00 +00:00
|
|
|
static void
|
|
|
|
response_cb (GtkDialog *dialog,
|
2008-07-21 12:58:36 +00:00
|
|
|
gint arg1,
|
|
|
|
gpointer user_data)
|
2007-05-19 23:35:00 +00:00
|
|
|
{
|
2020-05-09 14:26:22 +00:00
|
|
|
gtk_window_destroy (GTK_WINDOW (dialog));
|
2007-05-19 23:35:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
show_error (gpointer data)
|
|
|
|
{
|
2008-07-21 12:58:36 +00:00
|
|
|
GtkWindow *window = (GtkWindow *) data;
|
|
|
|
GtkWidget *dialog;
|
|
|
|
|
|
|
|
g_message ("showing error");
|
|
|
|
|
|
|
|
dialog = gtk_message_dialog_new (window,
|
|
|
|
GTK_DIALOG_MODAL,
|
|
|
|
GTK_MESSAGE_INFO,
|
|
|
|
GTK_BUTTONS_CLOSE,
|
|
|
|
"This should have unbroken the grab");
|
2020-05-11 14:54:32 +00:00
|
|
|
g_signal_connect_object (G_OBJECT (dialog),
|
|
|
|
"response",
|
|
|
|
G_CALLBACK (response_cb), NULL, 0);
|
2008-07-21 12:58:36 +00:00
|
|
|
gtk_widget_show (dialog);
|
|
|
|
|
2012-01-31 00:12:27 +00:00
|
|
|
return G_SOURCE_REMOVE;
|
2007-05-19 23:35:00 +00:00
|
|
|
}
|
|
|
|
|
2008-07-21 12:58:36 +00:00
|
|
|
int
|
|
|
|
main (int argc,
|
|
|
|
char **argv)
|
2007-05-19 23:35:00 +00:00
|
|
|
{
|
2008-07-21 12:58:36 +00:00
|
|
|
GtkWidget *window;
|
|
|
|
GtkWidget *button;
|
|
|
|
GtkWidget *button2;
|
|
|
|
GtkWidget *box;
|
2014-02-13 08:51:25 +00:00
|
|
|
GtkWidget *vbox;
|
2008-07-21 12:58:36 +00:00
|
|
|
|
2016-12-28 13:53:22 +00:00
|
|
|
gtk_init ();
|
2007-05-19 23:35:00 +00:00
|
|
|
|
2020-02-14 19:55:36 +00:00
|
|
|
window = gtk_window_new ();
|
2014-02-13 08:51:25 +00:00
|
|
|
gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
|
2008-07-21 12:58:36 +00:00
|
|
|
button = gtk_volume_button_new ();
|
|
|
|
button2 = gtk_volume_button_new ();
|
2014-02-13 08:51:25 +00:00
|
|
|
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
2010-10-31 17:07:20 +00:00
|
|
|
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
2008-07-21 12:58:36 +00:00
|
|
|
|
|
|
|
g_signal_connect (G_OBJECT (button), "value-changed",
|
|
|
|
G_CALLBACK (value_changed),
|
|
|
|
NULL);
|
|
|
|
|
2020-05-02 21:26:54 +00:00
|
|
|
gtk_window_set_child (GTK_WINDOW (window), vbox);
|
2020-05-09 12:26:52 +00:00
|
|
|
gtk_box_append (GTK_BOX (vbox), box);
|
|
|
|
gtk_box_append (GTK_BOX (box), button);
|
|
|
|
gtk_box_append (GTK_BOX (box), button2);
|
2008-07-21 12:58:36 +00:00
|
|
|
|
2017-01-19 09:02:04 +00:00
|
|
|
gtk_widget_show (window);
|
2008-07-21 12:58:36 +00:00
|
|
|
g_timeout_add (4000, (GSourceFunc) show_error, window);
|
|
|
|
|
2020-02-10 03:24:47 +00:00
|
|
|
while (TRUE)
|
|
|
|
g_main_context_iteration (NULL, TRUE);
|
2008-07-21 12:58:36 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|