diff options
author | Lars Uebernickel <lars.uebernickel@canonical.com> | 2015-02-19 00:33:01 +0100 |
---|---|---|
committer | Lars Uebernickel <lars.uebernickel@canonical.com> | 2015-02-19 08:39:55 +0100 |
commit | b4ef6d957f301ab7020acb6ecdae736d3087b79d (patch) | |
tree | 022c54f29aea6d28d8166095b3f9f0a182b8d738 | |
parent | 6ef0664017722a5f06739a03973c368c69c9746e (diff) | |
download | glib-b4ef6d957f301ab7020acb6ecdae736d3087b79d.tar.gz |
gapplication: add "is-busy"
A property to query the current busy state of an application.
https://bugzilla.gnome.org/show_bug.cgi?id=744756
-rw-r--r-- | docs/reference/gio/gio-sections.txt | 1 | ||||
-rw-r--r-- | gio/gapplication.c | 50 | ||||
-rw-r--r-- | gio/gapplication.h | 2 |
3 files changed, 50 insertions, 3 deletions
diff --git a/docs/reference/gio/gio-sections.txt b/docs/reference/gio/gio-sections.txt index adc7152da..5b691a440 100644 --- a/docs/reference/gio/gio-sections.txt +++ b/docs/reference/gio/gio-sections.txt @@ -3150,6 +3150,7 @@ g_application_get_default <SUBSECTION> g_application_mark_busy g_application_unmark_busy +g_application_get_is_busy g_application_bind_busy_property g_application_unbind_busy_property <SUBSECTION Standard> diff --git a/gio/gapplication.c b/gio/gapplication.c index c7e7a3c8e..1d2b932f1 100644 --- a/gio/gapplication.c +++ b/gio/gapplication.c @@ -263,7 +263,8 @@ enum PROP_IS_REGISTERED, PROP_IS_REMOTE, PROP_INACTIVITY_TIMEOUT, - PROP_ACTION_GROUP + PROP_ACTION_GROUP, + PROP_IS_BUSY }; enum @@ -1180,6 +1181,10 @@ g_application_get_property (GObject *object, g_application_get_inactivity_timeout (application)); break; + case PROP_IS_BUSY: + g_value_set_boolean (value, g_application_get_is_busy (application)); + break; + default: g_assert_not_reached (); } @@ -1344,6 +1349,20 @@ g_application_class_init (GApplicationClass *class) G_PARAM_DEPRECATED | G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS)); /** + * GApplication:is-busy: + * + * Whether the application is currently marked as busy through + * g_application_mark_busy() or g_application_bind_busy_property(). + * + * Since: 2.44 + */ + g_object_class_install_property (object_class, PROP_IS_BUSY, + g_param_spec_boolean ("is-busy", + P_("Is busy"), + P_("If this application is currently marked busy"), + FALSE, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + + /** * GApplication::startup: * @application: the application * @@ -2544,7 +2563,10 @@ g_application_mark_busy (GApplication *application) application->priv->busy_count++; if (!was_busy) - g_application_impl_set_busy_state (application->priv->impl, TRUE); + { + g_application_impl_set_busy_state (application->priv->impl, TRUE); + g_object_notify (G_OBJECT (application), "is-busy"); + } } /** @@ -2570,7 +2592,29 @@ g_application_unmark_busy (GApplication *application) application->priv->busy_count--; if (application->priv->busy_count == 0) - g_application_impl_set_busy_state (application->priv->impl, FALSE); + { + g_application_impl_set_busy_state (application->priv->impl, FALSE); + g_object_notify (G_OBJECT (application), "is-busy"); + } +} + +/** + * g_application_get_is_busy: + * @application: a #GApplication + * + * Gets the application's current busy state, as set through + * g_application_mark_busy() or g_application_bind_busy_property(). + * + * Returns: %TRUE if @application is currenty marked as busy + * + * Since: 2.44 + */ +gboolean +g_application_get_is_busy (GApplication *application) +{ + g_return_val_if_fail (G_IS_APPLICATION (application), FALSE); + + return application->priv->busy_count > 0; } /* Notifications {{{1 */ diff --git a/gio/gapplication.h b/gio/gapplication.h index 98ceb902c..7cbbf4ca8 100644 --- a/gio/gapplication.h +++ b/gio/gapplication.h @@ -217,6 +217,8 @@ GLIB_AVAILABLE_IN_2_38 void g_application_mark_busy (GApplication *application); GLIB_AVAILABLE_IN_2_38 void g_application_unmark_busy (GApplication *application); +GLIB_AVAILABLE_IN_2_44 +gboolean g_application_get_is_busy (GApplication *application); GLIB_AVAILABLE_IN_2_40 void g_application_send_notification (GApplication *application, |