[gtk+] widget-factory: Test busy state



commit 7d91ca31836bf6918bf9b10724ad9b31934b361f
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Jul 30 10:32:44 2015 -0400

    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 deletions(-)
---
diff --git a/demos/widget-factory/widget-factory.c b/demos/widget-factory/widget-factory.c
index f17894d..c86fd11 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 fc6459d..fb79661 100644
--- a/demos/widget-factory/widget-factory.ui
+++ b/demos/widget-factory/widget-factory.ui
@@ -4,6 +4,10 @@
   <menu id="gear_menu">
     <section>
       <item>
+        <attribute name="label" translatable="yes">Get Busy</attribute>
+        <attribute name="action">win.busy</attribute>
+      </item>
+      <item>
         <attribute name="label" translatable="yes">Dark Theme</attribute>
         <attribute name="action">win.dark</attribute>
       </item>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]