2009-07-21 01:16:56 +00:00
|
|
|
/* Spinner
|
|
|
|
*
|
|
|
|
* GtkSpinner allows to show that background activity is on-going.
|
|
|
|
*/
|
|
|
|
|
2013-06-21 17:46:54 +00:00
|
|
|
#include <glib/gi18n.h>
|
2009-07-21 01:16:56 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2015-06-28 13:23:28 +00:00
|
|
|
static GtkWidget *window = NULL;
|
2009-07-21 01:16:56 +00:00
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *button;
|
|
|
|
GtkWidget *spinner;
|
|
|
|
|
|
|
|
if (!window)
|
|
|
|
{
|
2023-08-03 19:24:04 +00:00
|
|
|
window = gtk_window_new ();
|
|
|
|
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
|
|
|
|
gtk_window_set_title (GTK_WINDOW (window), "Spinner");
|
2009-07-21 01:16:56 +00:00
|
|
|
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
|
2020-05-09 16:03:11 +00:00
|
|
|
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
2009-07-21 01:16:56 +00:00
|
|
|
|
2023-08-03 19:24:04 +00:00
|
|
|
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
|
2020-02-26 01:57:20 +00:00
|
|
|
gtk_widget_set_margin_top (vbox, 5);
|
|
|
|
gtk_widget_set_margin_bottom (vbox, 5);
|
2023-08-03 19:24:04 +00:00
|
|
|
gtk_widget_set_margin_start (vbox, 5);
|
|
|
|
gtk_widget_set_margin_end (vbox, 5);
|
|
|
|
|
|
|
|
gtk_window_set_child (GTK_WINDOW (window), vbox);
|
2009-07-21 01:16:56 +00:00
|
|
|
|
|
|
|
/* 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 ();
|
2020-05-09 12:26:52 +00:00
|
|
|
gtk_box_append (GTK_BOX (hbox), spinner);
|
|
|
|
gtk_box_append (GTK_BOX (hbox), gtk_entry_new ());
|
|
|
|
gtk_box_append (GTK_BOX (vbox), hbox);
|
2009-07-21 01:16:56 +00:00
|
|
|
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 ();
|
2020-05-09 12:26:52 +00:00
|
|
|
gtk_box_append (GTK_BOX (hbox), spinner);
|
|
|
|
gtk_box_append (GTK_BOX (hbox), gtk_entry_new ());
|
|
|
|
gtk_box_append (GTK_BOX (vbox), hbox);
|
2009-07-21 01:16:56 +00:00
|
|
|
spinner_unsensitive = spinner;
|
|
|
|
gtk_widget_set_sensitive (hbox, FALSE);
|
|
|
|
|
2013-06-21 17:46:54 +00:00
|
|
|
button = gtk_button_new_with_label (_("Play"));
|
2009-07-21 01:16:56 +00:00
|
|
|
g_signal_connect (G_OBJECT (button), "clicked",
|
|
|
|
G_CALLBACK (on_play_clicked), spinner);
|
2020-05-09 12:26:52 +00:00
|
|
|
gtk_box_append (GTK_BOX (vbox), button);
|
2009-07-21 01:16:56 +00:00
|
|
|
|
2013-06-21 17:46:54 +00:00
|
|
|
button = gtk_button_new_with_label (_("Stop"));
|
2009-07-21 01:16:56 +00:00
|
|
|
g_signal_connect (G_OBJECT (button), "clicked",
|
|
|
|
G_CALLBACK (on_stop_clicked), spinner);
|
2020-05-09 12:26:52 +00:00
|
|
|
gtk_box_append (GTK_BOX (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))
|
2022-11-28 04:03:14 +00:00
|
|
|
gtk_widget_set_visible (window, TRUE);
|
2009-07-21 01:16:56 +00:00
|
|
|
else
|
2020-05-09 14:26:22 +00:00
|
|
|
gtk_window_destroy (GTK_WINDOW (window));
|
2009-07-21 01:16:56 +00:00
|
|
|
|
|
|
|
return window;
|
|
|
|
}
|