3 * GtkSpinner allows to show that background activity is on-going.
9 static GtkWidget *window = NULL;
10 static GtkWidget *spinner_sensitive = NULL;
11 static GtkWidget *spinner_unsensitive = NULL;
14 on_play_clicked (GtkButton *button, gpointer user_data)
16 gtk_spinner_start (GTK_SPINNER (spinner_sensitive));
17 gtk_spinner_start (GTK_SPINNER (spinner_unsensitive));
21 on_stop_clicked (GtkButton *button, gpointer user_data)
23 gtk_spinner_stop (GTK_SPINNER (spinner_sensitive));
24 gtk_spinner_stop (GTK_SPINNER (spinner_unsensitive));
28 do_spinner (GtkWidget *do_widget)
30 GtkWidget *content_area;
38 window = gtk_dialog_new_with_buttons ("GtkSpinner",
39 GTK_WINDOW (do_widget),
44 gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
46 g_signal_connect (window, "response",
47 G_CALLBACK (gtk_widget_destroy), NULL);
48 g_signal_connect (window, "destroy",
49 G_CALLBACK (gtk_widget_destroyed), &window);
51 content_area = gtk_dialog_get_content_area (GTK_DIALOG (window));
53 vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
54 gtk_box_pack_start (GTK_BOX (content_area), vbox, TRUE, TRUE, 0);
55 gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
58 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
59 spinner = gtk_spinner_new ();
60 gtk_container_add (GTK_CONTAINER (hbox), spinner);
61 gtk_container_add (GTK_CONTAINER (hbox), gtk_entry_new ());
62 gtk_container_add (GTK_CONTAINER (vbox), hbox);
63 spinner_sensitive = spinner;
66 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
67 spinner = gtk_spinner_new ();
68 gtk_container_add (GTK_CONTAINER (hbox), spinner);
69 gtk_container_add (GTK_CONTAINER (hbox), gtk_entry_new ());
70 gtk_container_add (GTK_CONTAINER (vbox), hbox);
71 spinner_unsensitive = spinner;
72 gtk_widget_set_sensitive (hbox, FALSE);
74 button = gtk_button_new_from_stock (GTK_STOCK_MEDIA_PLAY);
75 g_signal_connect (G_OBJECT (button), "clicked",
76 G_CALLBACK (on_play_clicked), spinner);
77 gtk_container_add (GTK_CONTAINER (vbox), button);
79 button = gtk_button_new_from_stock (GTK_STOCK_MEDIA_STOP);
80 g_signal_connect (G_OBJECT (button), "clicked",
81 G_CALLBACK (on_stop_clicked), spinner);
82 gtk_container_add (GTK_CONTAINER (vbox), button);
84 /* Start by default to test for:
85 * https://bugzilla.gnome.org/show_bug.cgi?id=598496 */
86 on_play_clicked (NULL, NULL);
89 if (!gtk_widget_get_visible (window))
90 gtk_widget_show_all (window);
92 gtk_widget_destroy (window);