[gnome-software/wip/ubuntu-changes] Revert "Manually disable update monitor"



commit 7f28326d40e810b6adcfcc843a1b363637f52da3
Author: William Hua <william hua canonical com>
Date:   Tue Apr 5 12:09:11 2016 +0100

    Revert "Manually disable update monitor"
    
    This reverts commit 64a0a8074d4c72de1c689a46291ee9892ac0d788.

 src/gs-application.c |   49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 49 insertions(+), 0 deletions(-)
---
diff --git a/src/gs-application.c b/src/gs-application.c
index fa24d56..bffb138 100644
--- a/src/gs-application.c
+++ b/src/gs-application.c
@@ -118,6 +118,53 @@ gs_application_init (GsApplication *application)
 }
 
 static void
+download_updates_setting_changed (GSettings     *settings,
+                                 const gchar   *key,
+                                 GsApplication *app)
+{
+       if (!gs_update_monitor_is_managed () &&
+           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
+on_permission_changed (GPermission *permission,
+                       GParamSpec  *pspec,
+                       gpointer     data)
+{
+       GsApplication *app = data;
+
+       if (app->settings)
+               download_updates_setting_changed (app->settings, "download-updates", app);
+}
+
+static void
+gs_application_monitor_permission (GsApplication *app)
+{
+       GPermission *permission;
+
+       permission = gs_update_monitor_permission_get ();
+       if (permission != NULL)
+               g_signal_connect (permission, "notify",
+                                 G_CALLBACK (on_permission_changed), app);
+}
+
+static void
+gs_application_monitor_updates (GsApplication *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
 network_changed_cb (GNetworkMonitor *monitor,
                    gboolean available,
                    GsApplication *app)
@@ -621,6 +668,8 @@ gs_application_startup (GApplication *application)
        GS_APPLICATION (application)->dbus_helper = gs_dbus_helper_new ();
 #endif
        GS_APPLICATION (application)->settings = g_settings_new ("org.gnome.software");
+       gs_application_monitor_permission (GS_APPLICATION (application));
+       gs_application_monitor_updates (GS_APPLICATION (application));
        gs_application_monitor_network (GS_APPLICATION (application));
        gs_folders_convert ();
 }


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