[gnome-software/wip/kalev/distro-upgrade-notification: 2/2] Show a different notification after finishing a system upgrade



commit 5a02388f224f6689da7b79d6f1cf2dae879d7c06
Author: Kalev Lember <klember redhat com>
Date:   Thu Oct 26 15:37:42 2017 +0200

    Show a different notification after finishing a system upgrade
    
    Previously we showed the same notification for both regular updates and
    distro upgrades. Now that PackageKit 1.1.8 saves the transaction role to
    the offline update results file, we can make use of that in
    gnome-software and show a better notification after system upgrades.

 plugins/packagekit/gs-plugin-packagekit-offline.c |   17 +++++++
 src/gs-update-monitor.c                           |   53 ++++++++++++++-------
 2 files changed, 52 insertions(+), 18 deletions(-)
---
diff --git a/plugins/packagekit/gs-plugin-packagekit-offline.c 
b/plugins/packagekit/gs-plugin-packagekit-offline.c
index 779b60f..f2346ec 100644
--- a/plugins/packagekit/gs-plugin-packagekit-offline.c
+++ b/plugins/packagekit/gs-plugin-packagekit-offline.c
@@ -144,6 +144,23 @@ gs_plugin_add_updates_historical (GsPlugin *plugin,
                                                           pk_error_get_details (error_code));
        }
 
+       /* distro upgrade? */
+       if (pk_results_get_role (results) == PK_ROLE_ENUM_UPGRADE_SYSTEM) {
+               g_autoptr(GsApp) app = NULL;
+
+               app = gs_app_new (NULL);
+               gs_app_set_from_unique_id (app, "*/*/*/*/system/*");
+               gs_app_set_management_plugin (app, "packagekit");
+               gs_app_set_state (app, AS_APP_STATE_INSTALLED);
+               gs_app_set_kind (app, AS_APP_KIND_OS_UPGRADE);
+               gs_app_set_install_date (app, mtime);
+               gs_app_set_metadata (app, "GnomeSoftware::Creator",
+                                    gs_plugin_get_name (plugin));
+               gs_app_list_add (list, app);
+
+               return TRUE;
+       }
+
        /* get list of package-ids */
        package_array = pk_results_get_package_array (results);
        for (i = 0; i < package_array->len; i++) {
diff --git a/src/gs-update-monitor.c b/src/gs-update-monitor.c
index 5453e29..6681929 100644
--- a/src/gs-update-monitor.c
+++ b/src/gs-update-monitor.c
@@ -631,24 +631,40 @@ get_updates_historical_cb (GObject *object, GAsyncResult *res, gpointer data)
        if (time_last_notified >= gs_app_get_install_date (app))
                return;
 
-       /* TRANSLATORS: title when we've done offline updates */
-       title = ngettext ("Software Update Installed",
-                         "Software Updates Installed",
-                         gs_app_list_length (apps));
-       /* TRANSLATORS: message when we've done offline updates */
-       message = ngettext ("An important OS update has been installed.",
-                           "Important OS updates have been installed.",
-                           gs_app_list_length (apps));
-
-       notification = g_notification_new (title);
-       g_notification_set_body (notification, message);
-       /* TRANSLATORS: Button to look at the updates that were installed.
-        * Note that it has nothing to do with the application reviews, the
-        * users can't express their opinions here. In some languages
-        * "Review (evaluate) something" is a different translation than
-        * "Review (browse) something." */
-       g_notification_add_button_with_target (notification, C_("updates", "Review"), "app.set-mode", "s", 
"updated");
-       g_notification_set_default_action_and_target (notification, "app.set-mode", "s", "updated");
+       if (gs_app_get_kind (app) == AS_APP_KIND_OS_UPGRADE) {
+               /* TRANSLATORS: This is the title for the notification when
+                * we've done a distro upgrade. First %s is the distro name and
+                * the 2nd %s is the version, e.g. "Fedora 28 Installed" */
+               title = g_strdup_printf (_("%s %s Installed"),
+                                        gs_app_get_name (app),
+                                        gs_app_get_version (app));
+               /* TRANSLATORS: message when we've done a distro upgrade. %s is
+                * the distro name */
+               message = g_strdup_printf (_("System upgrade completed. Enjoy your new %s!"),
+                                          gs_app_get_name (app));
+
+               notification = g_notification_new (title);
+               g_notification_set_body (notification, message);
+       } else {
+               /* TRANSLATORS: title when we've done offline updates */
+               title = ngettext ("Software Update Installed",
+                                 "Software Updates Installed",
+                                 gs_app_list_length (apps));
+               /* TRANSLATORS: message when we've done offline updates */
+               message = ngettext ("An important OS update has been installed.",
+                                   "Important OS updates have been installed.",
+                                   gs_app_list_length (apps));
+
+               notification = g_notification_new (title);
+               g_notification_set_body (notification, message);
+               /* TRANSLATORS: Button to look at the updates that were installed.
+                * Note that it has nothing to do with the application reviews, the
+                * users can't express their opinions here. In some languages
+                * "Review (evaluate) something" is a different translation than
+                * "Review (browse) something." */
+               g_notification_add_button_with_target (notification, C_("updates", "Review"), "app.set-mode", 
"s", "updated");
+               g_notification_set_default_action_and_target (notification, "app.set-mode", "s", "updated");
+       }
        g_application_send_notification (monitor->application, "offline-updates", notification);
 
        /* update the timestamp so we don't show again */
@@ -667,6 +683,7 @@ cleanup_notifications_cb (gpointer user_data)
        g_debug ("getting historical updates for fresh session");
        plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_GET_UPDATES_HISTORICAL,
                                         "failure-flags", GS_PLUGIN_FAILURE_FLAGS_NONE,
+                                        "refine-flags", GS_PLUGIN_REFINE_FLAGS_REQUIRE_UPGRADE_REMOVED,
                                         NULL);
        gs_plugin_loader_job_process_async (monitor->plugin_loader,
                                            plugin_job,


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