[gnome-settings-daemon] media-keys: Use a gsettings key for the maximum screencast length



commit 042f75b21857208680d3c3751dc5a9e755c8418a
Author: Adel Gadllah <adel gadllah gmail com>
Date:   Wed Sep 25 19:43:07 2013 +0200

    media-keys: Use a gsettings key for the maximum screencast length
    
    Don't hardcode an arbitary 30 seconds limit for the maximum screencast
    length but read the value out of gsettings (which defaults to 30 seconds).
    
    https://bugzilla.gnome.org/show_bug.cgi?id=708660

 ...ngs-daemon.plugins.media-keys.gschema.xml.in.in |    5 ++++
 plugins/media-keys/gsd-media-keys-manager.c        |   24 ++++++++++++++-----
 2 files changed, 22 insertions(+), 7 deletions(-)
---
diff --git a/data/org.gnome.settings-daemon.plugins.media-keys.gschema.xml.in.in 
b/data/org.gnome.settings-daemon.plugins.media-keys.gschema.xml.in.in
index 0af3978..822ee0c 100644
--- a/data/org.gnome.settings-daemon.plugins.media-keys.gschema.xml.in.in
+++ b/data/org.gnome.settings-daemon.plugins.media-keys.gschema.xml.in.in
@@ -180,6 +180,11 @@
       <_summary>Magnifier zoom out</_summary>
       <_description>Binding for the magnifier to zoom out</_description>
     </key>
+    <key name="max-screencast-length" type="u">
+      <default>30</default>
+      <_summary>Maximum length of screen recordings</_summary>
+      <_description>The maximum length of single screen cast recordings in seconds or 0 for 
unlimited</_description>
+    </key>
   </schema>
 
   <schema gettext-domain="@GETTEXT_PACKAGE@" 
id="org.gnome.settings-daemon.plugins.media-keys.custom-keybinding">
diff --git a/plugins/media-keys/gsd-media-keys-manager.c b/plugins/media-keys/gsd-media-keys-manager.c
index 55a1f03..1a60bb2 100644
--- a/plugins/media-keys/gsd-media-keys-manager.c
+++ b/plugins/media-keys/gsd-media-keys-manager.c
@@ -76,9 +76,6 @@
 
 #define SHELL_GRABBER_RETRY_INTERVAL 1
 
-/* Screencasts last for 30 seconds */
-#define SCREENCAST_LENGTH 30
-
 static const gchar introspection_xml[] =
 "<node name='/org/gnome/SettingsDaemon/MediaKeys'>"
 "  <interface name='org.gnome.SettingsDaemon.MediaKeys'>"
@@ -177,6 +174,7 @@ struct GsdMediaKeysManagerPrivate
         /* Screencast stuff */
         GDBusProxy      *screencast_proxy;
         guint            screencast_timeout_id;
+        gboolean         screencast_recording;
         GCancellable    *screencast_cancellable;
 
         /* systemd stuff */
@@ -596,6 +594,11 @@ gsettings_changed_cb (GSettings           *settings,
         if (g_str_equal (settings_key, "custom-keybindings"))
                return;
 
+       /* not needed here */
+        if (g_str_equal (settings_key, "max-screencast-length"))
+               return;
+
+
         /* Find the key that was modified */
         for (i = 0; i < manager->priv->keys->len; i++) {
                 MediaKey *key;
@@ -1997,6 +2000,8 @@ screencast_stop (GsdMediaKeysManager *manager)
                            G_DBUS_CALL_FLAGS_NONE, -1,
                            manager->priv->screencast_cancellable,
                            NULL, NULL);
+
+        manager->priv->screencast_recording = FALSE;
 }
 
 static gboolean
@@ -2010,6 +2015,7 @@ screencast_timeout (gpointer user_data)
 static void
 screencast_start (GsdMediaKeysManager *manager)
 {
+        guint max_length;
         g_dbus_proxy_call (manager->priv->screencast_proxy,
                            "Screencast",
                            /* Translators: this is a filename used for screencast
@@ -2022,9 +2028,13 @@ screencast_start (GsdMediaKeysManager *manager)
                            manager->priv->screencast_cancellable,
                            NULL, NULL);
 
-        manager->priv->screencast_timeout_id = g_timeout_add_seconds (SCREENCAST_LENGTH,
-                                                                      screencast_timeout,
-                                                                      manager);
+        max_length = g_settings_get_int (manager->priv->settings, "max-screencast-length");
+
+        if (max_length > 0)
+                manager->priv->screencast_timeout_id = g_timeout_add_seconds (max_length,
+                                                                              screencast_timeout,
+                                                                              manager);
+        manager->priv->screencast_recording = TRUE;
 }
 
 static void
@@ -2033,7 +2043,7 @@ do_screencast_action (GsdMediaKeysManager *manager)
         if (manager->priv->screencast_proxy == NULL)
                 return;
 
-        if (manager->priv->screencast_timeout_id == 0)
+        if (!manager->priv->screencast_recording)
                 screencast_start (manager);
         else
                 screencast_stop (manager);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]