g_application_run
g_application_set_default
g_application_get_default
+<SUBSECTION>
+g_application_mark_busy
+g_application_unmark_busy
<SUBSECTION Standard>
G_TYPE_APPLICATION
G_APPLICATION
guint inactivity_timeout_id;
guint inactivity_timeout;
guint use_count;
+ guint busy_count;
guint is_registered : 1;
guint is_remote : 1;
application->priv->must_quit_now = TRUE;
}
+/**
+ * g_application_mark_busy:
+ * @application: a #GApplication
+ *
+ * Increases the busy count of @application.
+ *
+ * Use this function to indicate that the application is busy, for instance
+ * while a long running operation is pending.
+ *
+ * The busy state will be exposed to other processes, so a session shell will
+ * use that information to indicate the state to the user (e.g. with a
+ * spinner).
+ *
+ * To cancel the busy indication, use g_application_unmark_busy().
+ *
+ * Since: 2.38
+ **/
+void
+g_application_mark_busy (GApplication *application)
+{
+ gboolean was_busy;
+
+ g_return_if_fail (G_IS_APPLICATION (application));
+
+ was_busy = (application->priv->busy_count > 0);
+ application->priv->busy_count++;
+
+ if (!was_busy)
+ g_application_impl_set_busy_state (application->priv->impl, TRUE);
+}
+
+/**
+ * g_application_unmark_busy:
+ * @application: a #GApplication
+ *
+ * Decreases the busy count of @application.
+ *
+ * When the busy count reaches zero, the new state will be propagated
+ * to other processes.
+ *
+ * This function must only be called to cancel the effect of a previous
+ * call to g_application_mark_busy().
+ *
+ * Since: 2.38
+ **/
+void
+g_application_unmark_busy (GApplication *application)
+{
+ g_return_if_fail (G_IS_APPLICATION (application));
+ g_return_if_fail (application->priv->busy_count > 0);
+
+ application->priv->busy_count--;
+
+ if (application->priv->busy_count == 0)
+ g_application_impl_set_busy_state (application->priv->impl, FALSE);
+}
+
/* Epilogue {{{1 */
/* vim:set foldmethod=marker: */
GLIB_AVAILABLE_IN_2_32
void g_application_set_default (GApplication *application);
+GLIB_AVAILABLE_IN_2_38
+void g_application_mark_busy (GApplication *application);
+GLIB_AVAILABLE_IN_2_38
+void g_application_unmark_busy (GApplication *application);
+
G_END_DECLS
#endif /* __G_APPLICATION_H__ */
"<arg type='a{sv}' name='platform-data' direction='in'/>"
"<arg type='i' name='exit-status' direction='out'/>"
"</method>"
+ "<property name='Busy' type='b' access='read'/>"
"</interface>"
"</node>";
gboolean properties_live;
gboolean primary;
+ gboolean busy;
GApplication *app;
};
static GApplicationCommandLine *
g_dbus_command_line_new (GDBusMethodInvocation *invocation);
+static GVariant *
+g_application_impl_get_property (GDBusConnection *connection,
+ const gchar *sender,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *property_name,
+ GError **error,
+ gpointer user_data)
+{
+ GApplicationImpl *impl = user_data;
+
+ if (strcmp (property_name, "Busy") == 0)
+ return g_variant_new_boolean (impl->busy);
+
+ g_assert_not_reached ();
+
+ return NULL;
+}
+
+static void
+send_property_change (GApplicationImpl *impl)
+{
+ GVariantBuilder builder;
+
+ g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY);
+ g_variant_builder_add (&builder,
+ "{sv}",
+ "Busy", g_variant_new_boolean (impl->busy));
+
+ g_dbus_connection_emit_signal (impl->session_bus,
+ NULL,
+ impl->object_path,
+ "org.freedesktop.DBus.Properties",
+ "PropertiesChanged",
+ g_variant_new ("(sa{sv}as)",
+ "org.gtk.Application",
+ &builder,
+ NULL),
+ NULL);
+}
static void
g_application_impl_method_call (GDBusConnection *connection,
{
const static GDBusInterfaceVTable vtable = {
g_application_impl_method_call,
+ g_application_impl_get_property,
+ NULL /* set_property */
};
GApplicationClass *app_class = G_APPLICATION_GET_CLASS (impl->app);
GVariant *reply;
}
void
+g_application_impl_set_busy_state (GApplicationImpl *impl,
+ gboolean busy)
+{
+ if (impl->busy != busy)
+ {
+ impl->busy = busy;
+ send_property_change (impl);
+ }
+}
+
+void
g_application_impl_destroy (GApplicationImpl *impl)
{
g_application_impl_stop_primary (impl);
GDBusConnection * g_application_impl_get_dbus_connection (GApplicationImpl *impl);
const gchar * g_application_impl_get_dbus_object_path (GApplicationImpl *impl);
+
+void g_application_impl_set_busy_state (GApplicationImpl *impl,
+ gboolean busy);