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);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
toggle_orientation (GtkWidget *button,
|
|
|
|
GtkWidget *scalebutton)
|
|
|
|
{
|
2009-05-08 14:57:48 +00:00
|
|
|
if (gtk_orientable_get_orientation (GTK_ORIENTABLE (scalebutton)) ==
|
2008-07-21 12:58:36 +00:00
|
|
|
GTK_ORIENTATION_HORIZONTAL)
|
|
|
|
{
|
2009-05-08 14:57:48 +00:00
|
|
|
gtk_orientable_set_orientation (GTK_ORIENTABLE (scalebutton),
|
2008-07-21 12:58:36 +00:00
|
|
|
GTK_ORIENTATION_VERTICAL);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-05-08 14:57:48 +00:00
|
|
|
gtk_orientable_set_orientation (GTK_ORIENTABLE (scalebutton),
|
2008-07-21 12:58:36 +00:00
|
|
|
GTK_ORIENTATION_HORIZONTAL);
|
|
|
|
}
|
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
|
|
|
{
|
2008-07-21 12:58:36 +00:00
|
|
|
gtk_widget_destroy (GTK_WIDGET (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");
|
|
|
|
g_signal_connect (G_OBJECT (dialog),
|
|
|
|
"response",
|
|
|
|
G_CALLBACK (response_cb), NULL);
|
|
|
|
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 *button3;
|
|
|
|
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);
|
2014-02-13 08:51:25 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (vbox), box);
|
2008-07-21 12:58:36 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (box), button);
|
|
|
|
gtk_container_add (GTK_CONTAINER (box), button2);
|
|
|
|
|
|
|
|
button3 = gtk_button_new_with_label ("Toggle orientation");
|
|
|
|
gtk_container_add (GTK_CONTAINER (box), button3);
|
|
|
|
|
|
|
|
g_signal_connect (G_OBJECT (button3), "clicked",
|
|
|
|
G_CALLBACK (toggle_orientation),
|
|
|
|
button);
|
|
|
|
g_signal_connect (G_OBJECT (button3), "clicked",
|
|
|
|
G_CALLBACK (toggle_orientation),
|
|
|
|
button2);
|
|
|
|
|
2017-01-19 09:02:04 +00:00
|
|
|
gtk_widget_show (window);
|
2019-05-18 18:22:12 +00:00
|
|
|
g_signal_emit_by_name (button, "clicked");
|
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;
|
|
|
|
}
|