summaryrefslogtreecommitdiff
path: root/demos
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2015-07-30 10:32:44 -0400
committerMatthias Clasen <mclasen@redhat.com>2015-07-30 10:36:34 -0400
commit7d91ca31836bf6918bf9b10724ad9b31934b361f (patch)
tree844572400db93d25c773b3936dc2da8155b9cb8a /demos
parentffec25b0155304e7d047dedde514c61de1ffcdc2 (diff)
downloadgtk+-7d91ca31836bf6918bf9b10724ad9b31934b361f.tar.gz
widget-factory: Test busy state
Makes it easy to test insensitive state of widgets.i Also exposes brokenness in the shell busy indicator...
Diffstat (limited to 'demos')
-rw-r--r--demos/widget-factory/widget-factory.c34
-rw-r--r--demos/widget-factory/widget-factory.ui4
2 files changed, 37 insertions, 1 deletions
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
@@ -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>