add GConf option to disable app monitoring
This option only disables timers, so that already collected is still provided to e.g. appDisplay. IMO that's required for privacy concerns...
This commit is contained in:
parent
f4f92a879c
commit
216db2bb12
@ -20,6 +20,8 @@ AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE",
|
||||
|
||||
PKG_PROG_PKG_CONFIG(0.16)
|
||||
|
||||
AM_GCONF_SOURCE_2
|
||||
|
||||
# We need at least this, since gst_plugin_register_static() was added
|
||||
# in 0.10.16, but nothing older than 0.10.21 has been tested.
|
||||
GSTREAMER_MIN_VERSION=0.10.16
|
||||
@ -38,7 +40,7 @@ fi
|
||||
|
||||
AM_CONDITIONAL(BUILD_RECORDER, $build_recorder)
|
||||
|
||||
PKG_CHECK_MODULES(MUTTER_PLUGIN, gtk+-2.0 dbus-glib-1 metacity-plugins gjs-gi-1.0 xscrnsaver libgnome-menu $recorder_modules gdk-x11-2.0 clutter-x11-0.9 clutter-glx-0.9)
|
||||
PKG_CHECK_MODULES(MUTTER_PLUGIN, gtk+-2.0 dbus-glib-1 metacity-plugins gjs-gi-1.0 xscrnsaver libgnome-menu $recorder_modules gconf-2.0 gdk-x11-2.0 clutter-x11-0.9 clutter-glx-0.9)
|
||||
PKG_CHECK_MODULES(TIDY, clutter-0.9)
|
||||
PKG_CHECK_MODULES(BIG, clutter-0.9 gtk+-2.0 librsvg-2.0)
|
||||
PKG_CHECK_MODULES(GDMUSER, dbus-glib-1 gtk+-2.0)
|
||||
|
@ -3,3 +3,10 @@ imagedir = $(pkgdatadir)/images
|
||||
dist_image_DATA = \
|
||||
add-workspace.svg \
|
||||
remove-workspace.svg
|
||||
|
||||
schemadir = @GCONF_SCHEMA_FILE_DIR@
|
||||
schema_DATA = gnome-shell.schemas
|
||||
|
||||
install-data-local:
|
||||
GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule $(top_builddir)/data/$(schema_DATA)
|
||||
|
||||
|
20
data/gnome-shell.schemas
Normal file
20
data/gnome-shell.schemas
Normal file
@ -0,0 +1,20 @@
|
||||
<gconfschemafile>
|
||||
<schemalist>
|
||||
|
||||
<schema>
|
||||
<key>/schemas/desktop/gnome/shell/app_monitor/enable_monitoring</key>
|
||||
<applyto>/desktop/gnome/shell/app_monitor/enable_monitoring</applyto>
|
||||
<owner>gnome-shell</owner>
|
||||
<type>bool</type>
|
||||
<default>true</default>
|
||||
<locale name="C">
|
||||
<short>Whether to collect stats about applications usage</short>
|
||||
<long>
|
||||
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.
|
||||
</long>
|
||||
</locale>
|
||||
</schema>
|
||||
|
||||
</schemalist>
|
||||
|
||||
</gconfschemafile>
|
@ -8,6 +8,9 @@
|
||||
#include <gdk/gdk.h>
|
||||
#include <gdk/gdkx.h>
|
||||
#include <gio/gio.h>
|
||||
#include <gconf/gconf.h>
|
||||
#include <gconf/gconf-client.h>
|
||||
|
||||
|
||||
#include "shell-app-monitor.h"
|
||||
#include "shell-global.h"
|
||||
@ -20,6 +23,8 @@
|
||||
* Copyright Red Hat, Inc. 2006-2008
|
||||
*/
|
||||
|
||||
#define APP_MONITOR_GCONF_DIR SHELL_GCONF_DIR"/app_monitor"
|
||||
|
||||
/* Data is saved to file SHELL_CONFIG_DIR/DATA_FILENAME */
|
||||
#define DATA_FILENAME "applications_usage"
|
||||
|
||||
@ -81,7 +86,9 @@ struct _ShellAppMonitor
|
||||
gulong last_idle;
|
||||
guint poll_id;
|
||||
guint save_apps_id;
|
||||
guint gconf_notify;
|
||||
gboolean currently_idle;
|
||||
gboolean enable_monitoring;
|
||||
|
||||
GHashTable *apps_by_wm_class; /* Seen apps by wm_class */
|
||||
GHashTable *popularities; /* One AppPopularity struct list per activity */
|
||||
@ -133,6 +140,11 @@ static void save_to_file (ShellAppMonitor *monitor);
|
||||
|
||||
static void restore_from_file (ShellAppMonitor *monitor);
|
||||
|
||||
static void on_conf_changed (GConfClient *client,
|
||||
guint cnxn_id,
|
||||
GConfEntry *entry,
|
||||
gpointer monitor);
|
||||
|
||||
static glong
|
||||
get_time (void)
|
||||
{
|
||||
@ -182,9 +194,20 @@ shell_app_monitor_init (ShellAppMonitor *self)
|
||||
Display *xdisplay;
|
||||
char *path;
|
||||
char *shell_config_dir;
|
||||
GConfClient *gconf_client;
|
||||
|
||||
/* Apps usage tracking */
|
||||
|
||||
/* Check conf to see whether to track app usage or not */
|
||||
gconf_client = gconf_client_get_default ();
|
||||
gconf_client_add_dir (gconf_client, APP_MONITOR_GCONF_DIR,
|
||||
GCONF_CLIENT_PRELOAD_NONE, NULL);
|
||||
self->gconf_notify =
|
||||
gconf_client_notify_add (gconf_client, APP_MONITOR_GCONF_DIR"/enable_monitoring",
|
||||
on_conf_changed, self, NULL, NULL);
|
||||
self->enable_monitoring =
|
||||
gconf_client_get_bool (gconf_client, APP_MONITOR_GCONF_DIR"/enable_monitoring", NULL);
|
||||
|
||||
/* FIXME: should we create as many monitors as there are GdkScreens? */
|
||||
display = gdk_display_get_default();
|
||||
xdisplay = GDK_DISPLAY_XDISPLAY (display);
|
||||
@ -218,10 +241,14 @@ shell_app_monitor_init (ShellAppMonitor *self)
|
||||
else
|
||||
self->upload_apps_burst_count = SAVE_APPS_BURST_LENGTH / SAVE_APPS_BURST_TIMEOUT;
|
||||
|
||||
|
||||
/* If monitoring is disabled, we still report apps usage based on (possibly)
|
||||
* saved data, but don't set timers */
|
||||
if (self->enable_monitoring)
|
||||
{
|
||||
self->poll_id = g_timeout_add_seconds (5, poll_for_idleness, self);
|
||||
self->save_apps_id =
|
||||
g_timeout_add_seconds (SAVE_APPS_BURST_TIMEOUT, on_save_apps_timeout, self);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@ -233,6 +260,7 @@ shell_app_monitor_finalize (GObject *object)
|
||||
XFree (self->info);
|
||||
g_source_remove (self->poll_id);
|
||||
g_source_remove (self->save_apps_id);
|
||||
gconf_client_notify_remove (gconf_client_get_default (), self->gconf_notify);
|
||||
g_object_unref (self->display);
|
||||
g_hash_table_destroy (self->apps_by_wm_class);
|
||||
g_hash_table_foreach (self->popularities, destroy_popularity, NULL);
|
||||
@ -964,3 +992,37 @@ out:
|
||||
g_error_free (error);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
on_conf_changed (GConfClient *client,
|
||||
guint cnxn_id,
|
||||
GConfEntry *entry,
|
||||
gpointer monitor)
|
||||
{
|
||||
ShellAppMonitor *self = monitor;
|
||||
GConfValue *value;
|
||||
const char *key;
|
||||
char *key_name;
|
||||
|
||||
key = gconf_entry_get_key (entry);
|
||||
key_name = g_path_get_basename (key);
|
||||
if (strcmp (key_name, "enable_monitoring") != 0)
|
||||
{
|
||||
g_free (key_name);
|
||||
return;
|
||||
}
|
||||
value = gconf_entry_get_value (entry);
|
||||
self->enable_monitoring = gconf_value_get_bool (value);
|
||||
|
||||
if (self->enable_monitoring)
|
||||
{
|
||||
self->poll_id = g_timeout_add_seconds (5, poll_for_idleness, self);
|
||||
self->save_apps_id =
|
||||
g_timeout_add_seconds (SAVE_APPS_BURST_TIMEOUT, on_save_apps_timeout, self);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_source_remove (self->poll_id);
|
||||
g_source_remove (self->save_apps_id);
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,8 @@ typedef struct _ShellGlobalClass ShellGlobalClass;
|
||||
#define SHELL_IS_GLOBAL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SHELL_TYPE_GLOBAL))
|
||||
#define SHELL_GLOBAL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SHELL_TYPE_GLOBAL, ShellGlobalClass))
|
||||
|
||||
#define SHELL_GCONF_DIR "/desktop/gnome/shell"
|
||||
|
||||
struct _ShellGlobalClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
|
Loading…
Reference in New Issue
Block a user