[gnome-shell] Replace 'enable-app-monitoring' setting



commit 731e8bfe2b7b628171e56c6168a07e1138247758
Author: Florian Müllner <fmuellner gnome org>
Date:   Sat Mar 2 00:56:18 2013 +0100

    Replace 'enable-app-monitoring' setting
    
    The org.gnome.desktop.privacy schema gained a 'remember-app-usage'
    key, use that instead of our own preference.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=699714

 data/org.gnome.shell.gschema.xml.in.in |   10 ----------
 js/ui/appDisplay.js                    |    7 ++++---
 src/shell-app-usage.c                  |   23 ++++++++++-------------
 3 files changed, 14 insertions(+), 26 deletions(-)
---
diff --git a/data/org.gnome.shell.gschema.xml.in.in b/data/org.gnome.shell.gschema.xml.in.in
index 7aae0ae..460382c 100644
--- a/data/org.gnome.shell.gschema.xml.in.in
+++ b/data/org.gnome.shell.gschema.xml.in.in
@@ -21,16 +21,6 @@
         EnableExtension and DisableExtension DBus methods on org.gnome.Shell.
       </_description>
     </key>
-    <key name="enable-app-monitoring" type="b">
-      <default>true</default>
-      <_summary>Whether to collect stats about applications usage</_summary>
-      <_description>
-        The shell normally monitors active applications in order to present
-        the most used ones (e.g. in launchers). While this data will be
-        kept private, you may want to disable this for privacy reasons.
-        Please note that doing so won't remove already saved data.
-      </_description>
-    </key>
     <key name="favorite-apps" type="as">
       <default>[ 'epiphany.desktop', 'evolution.desktop', 'empathy.desktop', 'rhythmbox.desktop', 
'shotwell.desktop', 'libreoffice-writer.desktop', 'nautilus.desktop', 'gnome-documents.desktop' ]</default>
       <_summary>List of desktop file IDs for favorite applications</_summary>
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index 7ed76b8..d9c0f08 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -343,8 +343,9 @@ const AppDisplay = new Lang.Class({
         global.settings.connect('changed::app-folder-categories', Lang.bind(this, function() {
             Main.queueDeferredWork(this._allAppsWorkId);
         }));
-        global.settings.connect('changed::enable-app-monitoring',
-                                Lang.bind(this, this._updateFrequentVisibility));
+        this._privacySettings = new Gio.Settings({ schema: 'org.gnome.desktop.privacy' });
+        this._privacySettings.connect('changed::remember-app-usage',
+                                      Lang.bind(this, this._updateFrequentVisibility));
 
         this._views = [];
 
@@ -419,7 +420,7 @@ const AppDisplay = new Lang.Class({
     },
 
     _updateFrequentVisibility: function() {
-        let enabled = global.settings.get_boolean('enable-app-monitoring');
+        let enabled = this._privacySettings.get_boolean('remember-app-usage');
         this._views[Views.FREQUENT].control.visible = enabled;
 
         let visibleViews = this._views.filter(function(v) {
diff --git a/src/shell-app-usage.c b/src/shell-app-usage.c
index ab72300..04b1d5b 100644
--- a/src/shell-app-usage.c
+++ b/src/shell-app-usage.c
@@ -39,7 +39,8 @@
  * minutes to signify idle.
  */
 
-#define ENABLE_MONITORING_KEY "enable-app-monitoring"
+#define PRIVACY_SCHEMA "org.gnome.desktop.privacy"
+#define ENABLE_MONITORING_KEY "remember-app-usage"
 
 #define FOCUS_TIME_MIN_SECONDS 7 /* Need 7 continuous seconds of focus */
 
@@ -82,10 +83,10 @@ struct _ShellAppUsage
   GFile *configfile;
   GDBusProxy *session_proxy;
   GdkDisplay *display;
+  GSettings *privacy_settings;
   gulong last_idle;
   guint idle_focus_change_id;
   guint save_id;
-  guint settings_notify;
   gboolean currently_idle;
   gboolean enable_monitoring;
 
@@ -426,25 +427,23 @@ shell_app_usage_init (ShellAppUsage *self)
   restore_from_file (self);
 
 
-  self->settings_notify = g_signal_connect (shell_global_get_settings (global),
-                                            "changed::" ENABLE_MONITORING_KEY,
-                                            G_CALLBACK (on_enable_monitoring_key_changed),
-                                            self);
+  self->privacy_settings = g_settings_new(PRIVACY_SCHEMA);
+  g_signal_connect (self->privacy_settings,
+                    "changed::" ENABLE_MONITORING_KEY,
+                    G_CALLBACK (on_enable_monitoring_key_changed),
+                    self);
   update_enable_monitoring (self);
 }
 
 static void
 shell_app_usage_finalize (GObject *object)
 {
-  ShellGlobal *global;
   ShellAppUsage *self = SHELL_APP_USAGE (object);
 
   if (self->save_id > 0)
     g_source_remove (self->save_id);
 
-  global = shell_global_get ();
-  g_signal_handler_disconnect (shell_global_get_settings (global),
-                               self->settings_notify);
+  g_object_unref (self->privacy_settings);
 
   g_object_unref (self->configfile);
 
@@ -956,11 +955,9 @@ out:
 static void
 update_enable_monitoring (ShellAppUsage *self)
 {
-  ShellGlobal *global;
   gboolean enable;
 
-  global = shell_global_get ();
-  enable = g_settings_get_boolean (shell_global_get_settings (global),
+  enable = g_settings_get_boolean (self->privacy_settings,
                                    ENABLE_MONITORING_KEY);
 
   /* Be sure not to start the timers if they were already set */


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