[gnome-software] Add a GSettings key for disabling automatic update downloads



commit 7de777cabc3f03e4775f55c03d9bf045926876ec
Author: Kalev Lember <kalevlember gmail com>
Date:   Tue Jun 3 12:51:29 2014 +0200

    Add a GSettings key for disabling automatic update downloads
    
    https://bugzilla.gnome.org/show_bug.cgi?id=730686

 data/org.gnome.software.gschema.xml |    5 +++++
 src/gs-application.c                |   23 ++++++++++++++++++++++-
 2 files changed, 27 insertions(+), 1 deletions(-)
---
diff --git a/data/org.gnome.software.gschema.xml b/data/org.gnome.software.gschema.xml
index e182d99..d819ed1 100644
--- a/data/org.gnome.software.gschema.xml
+++ b/data/org.gnome.software.gschema.xml
@@ -5,6 +5,11 @@
       <summary>A list of compatible projects</summary>
       <description>This is a list of compatible projects we should show such as GNOME, KDE and 
XFCE.</description>
     </key>
+    <key name="download-updates" type="b">
+      <default>true</default>
+      <summary>Whether to automatically download updates</summary>
+      <description>If enabled, gnome-software automatically downloads updates in the background and prompts 
the user to install them when ready.</description>
+    </key>
     <key name="require-appdata" type="b">
       <default>false</default>
       <summary>Applications require AppData to be shown in the search results</summary>
diff --git a/src/gs-application.c b/src/gs-application.c
index e445803..0f6903b 100644
--- a/src/gs-application.c
+++ b/src/gs-application.c
@@ -55,6 +55,7 @@ struct _GsApplication {
        GsDbusHelper    *dbus_helper;
        GsShellSearchProvider *search_provider;
        GNetworkMonitor *network_monitor;
+       GSettings       *settings;
 };
 
 struct _GsApplicationClass {
@@ -84,9 +85,27 @@ gs_application_init (GsApplication *application)
 }
 
 static void
+download_updates_setting_changed (GSettings     *settings,
+                                  const gchar   *key,
+                                  GsApplication *app)
+{
+       if (g_settings_get_boolean (settings, key)) {
+               g_debug ("Enabling update monitor");
+               app->update_monitor = gs_update_monitor_new (app);
+       } else {
+               g_debug ("Disabling update monitor");
+               g_clear_object (&app->update_monitor);
+       }
+}
+
+static void
 gs_application_monitor_updates (GsApplication *app)
 {
-       app->update_monitor = gs_update_monitor_new (app);
+       g_signal_connect (app->settings, "changed::download-updates",
+                         G_CALLBACK (download_updates_setting_changed), app);
+       download_updates_setting_changed (app->settings,
+                                         "download-updates",
+                                         app);
 }
 
 static void
@@ -446,6 +465,7 @@ gs_application_startup (GApplication *application)
 
        GS_APPLICATION (application)->proxy_settings = gs_proxy_settings_new ();
        GS_APPLICATION (application)->dbus_helper = gs_dbus_helper_new ();
+       GS_APPLICATION (application)->settings = g_settings_new ("org.gnome.software");
        gs_application_monitor_updates (GS_APPLICATION (application));
        gs_application_provide_search (GS_APPLICATION (application));
        gs_application_monitor_network (GS_APPLICATION (application));
@@ -479,6 +499,7 @@ gs_application_finalize (GObject *object)
        g_clear_object (&app->search_provider);
        g_clear_object (&app->network_monitor);
        g_clear_object (&app->dbus_helper);
+       g_clear_object (&app->settings);
 
        G_OBJECT_CLASS (gs_application_parent_class)->finalize (object);
 }


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