diff options
author | Matthias Clasen <mclasen@redhat.com> | 2018-08-30 01:06:51 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2018-08-30 23:17:37 -0400 |
commit | 813c7b19ea9cf0c3d309c7961bffc40a3118c6f7 (patch) | |
tree | a339d6c471d72b54d968701de5e043e728e17eca /gtk/gtkapplication.c | |
parent | 3fc319ff1be391430f23701673253e1c0994a0cc (diff) | |
download | gtk+-813c7b19ea9cf0c3d309c7961bffc40a3118c6f7.tar.gz |
GtkApplication: track screensaver state
A number of applications want to track the state of the screensaver.
Make this information available as a boolean property. We only listen
for state changes when ::register-session is set to TRUE.
This is implemented for unsandboxed D-Bus access by talking
directly to org.gnome.ScreenSaver or org.freedesktop.ScreenSaver,
and for sandboxed D-Bus by using a (new) portal API.
A Quartz implementation is missing.
Diffstat (limited to 'gtk/gtkapplication.c')
-rw-r--r-- | gtk/gtkapplication.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/gtk/gtkapplication.c b/gtk/gtkapplication.c index 15378d17e2..5d26f07088 100644 --- a/gtk/gtkapplication.c +++ b/gtk/gtkapplication.c @@ -137,6 +137,7 @@ static guint gtk_application_signals[LAST_SIGNAL]; enum { PROP_ZERO, PROP_REGISTER_SESSION, + PROP_SCREENSAVER_ACTIVE, PROP_APP_MENU, PROP_MENUBAR, PROP_ACTIVE_WINDOW, @@ -157,6 +158,7 @@ struct _GtkApplicationPrivate guint last_window_id; gboolean register_session; + gboolean screensaver_active; GtkActionMuxer *muxer; GtkBuilder *menus_builder; gchar *help_overlay_path; @@ -521,6 +523,10 @@ gtk_application_get_property (GObject *object, g_value_set_boolean (value, application->priv->register_session); break; + case PROP_SCREENSAVER_ACTIVE: + g_value_set_boolean (value, application->priv->screensaver_active); + break; + case PROP_APP_MENU: g_value_set_object (value, gtk_application_get_app_menu (application)); break; @@ -652,6 +658,24 @@ gtk_application_class_init (GtkApplicationClass *class) FALSE, G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS); + /** + * GtkApplication:screensaver-active: + * + * This property is %TRUE if GTK+ believes that the screensaver is + * currently active. GTK+ only tracks session state (including this) + * when #GtkApplication::register-session is set to %TRUE. + * + * Tracking the screensaver state is supported on Linux. + * + * Since: 3.24 + */ + gtk_application_props[PROP_SCREENSAVER_ACTIVE] = + g_param_spec_boolean ("screensaver-active", + P_("Screensaver Active"), + P_("Whether the screensaver is active"), + FALSE, + G_PARAM_READABLE|G_PARAM_STATIC_STRINGS); + gtk_application_props[PROP_APP_MENU] = g_param_spec_object ("app-menu", P_("Application menu"), @@ -1460,3 +1484,16 @@ gtk_application_get_menu_by_id (GtkApplication *application, return G_MENU (object); } + +void +gtk_application_set_screensaver_active (GtkApplication *application, + gboolean active) +{ + GtkApplicationPrivate *priv = gtk_application_get_instance_private (application); + + if (priv->screensaver_active != active) + { + priv->screensaver_active = active; + g_object_notify (G_OBJECT (application), "screensaver-active"); + } +} |