[gnome-software] Remove stale notifications after an offline update has completed



commit bfa2ade7cf615c0f30d0522f1b537aab56a5fbd6
Author: Kalev Lember <kalevlember gmail com>
Date:   Wed Mar 19 17:40:54 2014 +0100

    Remove stale notifications after an offline update has completed
    
    https://bugzilla.gnome.org/show_bug.cgi?id=726645

 src/gs-offline-updates.c |    8 +++++++-
 src/gs-offline-updates.h |   17 +++++++++--------
 src/gs-update-monitor.c  |   15 +++++++++++++++
 3 files changed, 31 insertions(+), 9 deletions(-)
---
diff --git a/src/gs-offline-updates.c b/src/gs-offline-updates.c
index 727c13b..416e674 100644
--- a/src/gs-offline-updates.c
+++ b/src/gs-offline-updates.c
@@ -112,6 +112,12 @@ gs_offline_updates_cancel (void)
 #define PK_OFFLINE_UPDATE_RESULTS_FILENAME     "/var/lib/PackageKit/offline-update-competed"
 
 gboolean
+gs_offline_updates_results_available (void)
+{
+       return g_file_test (PK_OFFLINE_UPDATE_RESULTS_FILENAME, G_FILE_TEST_EXISTS);
+}
+
+gboolean
 gs_offline_updates_get_status (gboolean  *success,
                               guint     *num_packages,
                               gchar    **error_code,
@@ -135,7 +141,7 @@ gs_offline_updates_get_status (gboolean  *success,
        if (error_details)
                *error_details = NULL;
 
-       if (!g_file_test (PK_OFFLINE_UPDATE_RESULTS_FILENAME, G_FILE_TEST_EXISTS))
+       if (!gs_offline_updates_results_available ())
                goto out;
 
        key_file = g_key_file_new ();
diff --git a/src/gs-offline-updates.h b/src/gs-offline-updates.h
index ed7bc16..8b146e3 100644
--- a/src/gs-offline-updates.h
+++ b/src/gs-offline-updates.h
@@ -26,14 +26,15 @@
 
 G_BEGIN_DECLS
 
-void    gs_offline_updates_trigger       (void);
-void    gs_offline_updates_cancel        (void);
-void    gs_offline_updates_clear_status  (void);
-gboolean gs_offline_updates_get_status    (gboolean  *success,
-                                          guint     *num_packages,
-                                          gchar    **error_code,
-                                          gchar    **error_details);
-void    gs_offline_updates_show_error    (void);
+void     gs_offline_updates_trigger            (void);
+void     gs_offline_updates_cancel             (void);
+void     gs_offline_updates_clear_status       (void);
+gboolean gs_offline_updates_results_available  (void);
+gboolean gs_offline_updates_get_status         (gboolean  *success,
+                                                guint     *num_packages,
+                                                gchar    **error_code,
+                                                gchar    **error_details);
+void     gs_offline_updates_show_error         (void);
 
 
 G_END_DECLS
diff --git a/src/gs-update-monitor.c b/src/gs-update-monitor.c
index 8a7018f..059d712 100644
--- a/src/gs-update-monitor.c
+++ b/src/gs-update-monitor.c
@@ -561,6 +561,19 @@ gs_update_monitor_class_init (GsUpdateMonitorClass *klass)
 }
 
 static void
+remove_stale_notifications (GsUpdateMonitor *monitor)
+{
+       if (gs_offline_updates_results_available ()) {
+               g_debug ("Withdrawing stale notifications");
+
+               g_application_withdraw_notification (monitor->application,
+                                                    "updates-available");
+               g_application_withdraw_notification (monitor->application,
+                                                    "offline-updates");
+       }
+}
+
+static void
 do_reschedule_updates (GSimpleAction   *action,
                       GVariant        *parameter,
                       GsUpdateMonitor *monitor)
@@ -586,6 +599,8 @@ gs_update_monitor_new (GsApplication *application)
        monitor->application = G_APPLICATION (application);
        g_application_hold (monitor->application);
 
+       remove_stale_notifications (monitor);
+
        reschedule_updates = g_simple_action_new ("reschedule-updates", NULL);
        g_signal_connect_object (reschedule_updates, "activate",
                                 G_CALLBACK (do_reschedule_updates), monitor, 0);


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