From b4ef6d957f301ab7020acb6ecdae736d3087b79d Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Thu, 19 Feb 2015 00:33:01 +0100 Subject: gapplication: add "is-busy" A property to query the current busy state of an application. https://bugzilla.gnome.org/show_bug.cgi?id=744756 --- docs/reference/gio/gio-sections.txt | 1 + gio/gapplication.c | 50 ++++++++++++++++++++++++++++++++++--- 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 g_application_mark_busy g_application_unmark_busy +g_application_get_is_busy g_application_bind_busy_property g_application_unbind_busy_property 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 (); } @@ -1343,6 +1348,20 @@ g_application_class_init (GApplicationClass *class) G_TYPE_ACTION_GROUP, 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, -- cgit v1.2.1