2009-07-21 01:16:56 +00:00
|
|
|
/* Spinner
|
|
|
|
*
|
|
|
|
* GtkSpinner allows to show that background activity is on-going.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
static GtkWidget *window = NULL;
|
|
|
|
static GtkWidget *spinner_sensitive = NULL;
|
|
|
|
static GtkWidget *spinner_unsensitive = NULL;
|
|
|
|
|
|
|
|
static void
|
|
|
|
on_play_clicked (GtkButton *button, gpointer user_data)
|
|
|
|
{
|
|
|
|
gtk_spinner_start (GTK_SPINNER (spinner_sensitive));
|
|
|
|
gtk_spinner_start (GTK_SPINNER (spinner_unsensitive));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
on_stop_clicked (GtkButton *button, gpointer user_data)
|
|
|
|
{
|
|
|
|
gtk_spinner_stop (GTK_SPINNER (spinner_sensitive));
|
|
|
|
gtk_spinner_stop (GTK_SPINNER (spinner_unsensitive));
|
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget *
|
|
|
|
do_spinner (GtkWidget *do_widget)
|
|
|
|
{
|
2010-06-03 07:36:39 +00:00
|
|
|
GtkWidget *content_area;
|
2009-07-21 01:16:56 +00:00
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *button;
|
|
|
|
GtkWidget *spinner;
|
|
|
|
|
|
|
|
if (!window)
|
|
|
|
{
|
|
|
|
window = gtk_dialog_new_with_buttons ("GtkSpinner",
|
|
|
|
GTK_WINDOW (do_widget),
|
|
|
|
0,
|
|
|
|
GTK_STOCK_CLOSE,
|
|
|
|
GTK_RESPONSE_NONE,
|
|
|
|
NULL);
|
|
|
|
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
|
|
|
|
|
|
|
|
g_signal_connect (window, "response",
|
|
|
|
G_CALLBACK (gtk_widget_destroy), NULL);
|
|
|
|
g_signal_connect (window, "destroy",
|
|
|
|
G_CALLBACK (gtk_widget_destroyed), &window);
|
|
|
|
|
2010-06-03 07:36:39 +00:00
|
|
|
content_area = gtk_dialog_get_content_area (GTK_DIALOG (window));
|
|
|
|
|
2010-10-31 17:07:20 +00:00
|
|
|
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
|
2010-06-03 07:36:39 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (content_area), vbox, TRUE, TRUE, 0);
|
2009-07-21 01:16:56 +00:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
|
|
|
|
|
|
|
|
/* Sensitive */
|
2010-10-31 17:07:20 +00:00
|
|
|
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
|
2009-07-21 01:16:56 +00:00
|
|
|
spinner = gtk_spinner_new ();
|
|
|
|
gtk_container_add (GTK_CONTAINER (hbox), spinner);
|
|
|
|
gtk_container_add (GTK_CONTAINER (hbox), gtk_entry_new ());
|
|
|
|
gtk_container_add (GTK_CONTAINER (vbox), hbox);
|
|
|
|
spinner_sensitive = spinner;
|
|
|
|
|
|
|
|
/* Disabled */
|
2010-10-31 17:07:20 +00:00
|
|
|
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
|
2009-07-21 01:16:56 +00:00
|
|
|
spinner = gtk_spinner_new ();
|
|
|
|
gtk_container_add (GTK_CONTAINER (hbox), spinner);
|
|
|
|
gtk_container_add (GTK_CONTAINER (hbox), gtk_entry_new ());
|
|
|
|
gtk_container_add (GTK_CONTAINER (vbox), hbox);
|
|
|
|
spinner_unsensitive = spinner;
|
|
|
|
gtk_widget_set_sensitive (hbox, FALSE);
|
|
|
|
|
|
|
|
button = gtk_button_new_from_stock (GTK_STOCK_MEDIA_PLAY);
|
|
|
|
g_signal_connect (G_OBJECT (button), "clicked",
|
|
|
|
G_CALLBACK (on_play_clicked), spinner);
|
|
|
|
gtk_container_add (GTK_CONTAINER (vbox), button);
|
|
|
|
|
|
|
|
button = gtk_button_new_from_stock (GTK_STOCK_MEDIA_STOP);
|
|
|
|
g_signal_connect (G_OBJECT (button), "clicked",
|
|
|
|
G_CALLBACK (on_stop_clicked), spinner);
|
|
|
|
gtk_container_add (GTK_CONTAINER (vbox), button);
|
2009-10-14 22:11:43 +00:00
|
|
|
|
|
|
|
/* Start by default to test for:
|
|
|
|
* https://bugzilla.gnome.org/show_bug.cgi?id=598496 */
|
|
|
|
on_play_clicked (NULL, NULL);
|
2009-07-21 01:16:56 +00:00
|
|
|
}
|
|
|
|
|
2010-03-01 06:47:38 +00:00
|
|
|
if (!gtk_widget_get_visible (window))
|
2009-07-21 01:16:56 +00:00
|
|
|
gtk_widget_show_all (window);
|
|
|
|
else
|
|
|
|
gtk_widget_destroy (window);
|
|
|
|
|
|
|
|
return window;
|
|
|
|
}
|
|
|
|
|
|
|
|
|