From 7d91ca31836bf6918bf9b10724ad9b31934b361f Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 30 Jul 2015 10:32:44 -0400 Subject: [PATCH] widget-factory: Test busy state Makes it easy to test insensitive state of widgets.i Also exposes brokenness in the shell busy indicator... --- demos/widget-factory/widget-factory.c | 34 +++++++++++++++++++++++++- demos/widget-factory/widget-factory.ui | 4 +++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/demos/widget-factory/widget-factory.c b/demos/widget-factory/widget-factory.c index f17894d47d..c86fd11c8a 100644 --- a/demos/widget-factory/widget-factory.c +++ b/demos/widget-factory/widget-factory.c @@ -41,6 +41,37 @@ change_theme_state (GSimpleAction *action, g_simple_action_set_state (action, state); } +static gboolean +get_idle (gpointer data) +{ + GtkWidget *window = data; + GtkApplication *app = gtk_window_get_application (GTK_WINDOW (window)); + + gtk_widget_set_sensitive (window, TRUE); + gdk_window_set_cursor (gtk_widget_get_window (window), NULL); + g_application_unmark_busy (G_APPLICATION (app)); + + return G_SOURCE_REMOVE; +} + +static void +get_busy (GSimpleAction *action, + GVariant *parameter, + gpointer user_data) +{ + GtkWidget *window = user_data; + GdkCursor *cursor; + GtkApplication *app = gtk_window_get_application (GTK_WINDOW (window)); + + g_application_mark_busy (G_APPLICATION (app)); + cursor = gdk_cursor_new_from_name (gtk_widget_get_display (window), "wait"); + gdk_window_set_cursor (gtk_widget_get_window (window), cursor); + g_object_unref (cursor); + g_timeout_add (5000, get_idle, window); + + gtk_widget_set_sensitive (window, FALSE); +} + static void activate_search (GSimpleAction *action, GVariant *parameter, @@ -1256,7 +1287,8 @@ activate (GApplication *app) static GActionEntry win_entries[] = { { "dark", NULL, NULL, "false", change_theme_state }, { "search", activate_search, NULL, NULL, NULL }, - { "delete", activate_delete, NULL, NULL, NULL } + { "delete", activate_delete, NULL, NULL, NULL }, + { "busy", get_busy, NULL, NULL, NULL } }; struct { const gchar *action_and_target; diff --git a/demos/widget-factory/widget-factory.ui b/demos/widget-factory/widget-factory.ui index fc6459dda7..fb79661b63 100644 --- a/demos/widget-factory/widget-factory.ui +++ b/demos/widget-factory/widget-factory.ui @@ -3,6 +3,10 @@
+ + Get Busy + win.busy + Dark Theme win.dark