[gnome-software/wip/hughsie/notify-firmware-requires-update: 3/3] Show a notification when just one firmware is installed



commit 7eba5e4329020519a931ea163560e66727f1eed7
Author: Richard Hughes <richard hughsie com>
Date:   Fri May 17 17:04:50 2019 +0100

    Show a notification when just one firmware is installed
    
    This means we show the same UI if the user installs all the firmware updates or
    just one of them. We don't want the user to think the update was done live.

 src/gs-common.c          | 28 ++++++++++++++++++++++++++++
 src/gs-common.h          |  1 +
 src/gs-page.c            |  7 +++++++
 src/gs-updates-section.c | 14 ++------------
 4 files changed, 38 insertions(+), 12 deletions(-)
---
diff --git a/src/gs-common.c b/src/gs-common.c
index 06577994..703e8136 100644
--- a/src/gs-common.c
+++ b/src/gs-common.c
@@ -607,3 +607,31 @@ gs_utils_list_has_app_fuzzy (GsAppList *list, GsApp *app)
        }
        return FALSE;
 }
+
+void
+gs_utils_reboot_notify (GsAppList *list)
+{
+       g_autoptr(GNotification) n = NULL;
+       const gchar *title;
+       const gchar *body;
+
+       /* TRANSLATORS: we've just live-updated some apps */
+       title = ngettext ("An update has been installed",
+                         "Updates have been installed",
+                         gs_app_list_length (list));
+
+       /* TRANSLATORS: the new apps will not be run until we restart */
+       body = ngettext ("A restart is required for it to take effect.",
+                        "A restart is required for them to take effect.",
+                        gs_app_list_length (list));
+
+       n = g_notification_new (title);
+       g_notification_set_body (n, body);
+       /* TRANSLATORS: button text */
+       g_notification_add_button (n, _("Not Now"), "app.nop");
+       /* TRANSLATORS: button text */
+       g_notification_add_button_with_target (n, _("Restart"), "app.reboot", NULL);
+       g_notification_set_default_action_and_target (n, "app.set-mode", "s", "updates");
+       g_notification_set_priority (n, G_NOTIFICATION_PRIORITY_URGENT);
+       g_application_send_notification (g_application_get_default (), "restart-required", n);
+}
diff --git a/src/gs-common.h b/src/gs-common.h
index 7b5e9acd..89e6db59 100644
--- a/src/gs-common.h
+++ b/src/gs-common.h
@@ -43,5 +43,6 @@ gchar         *gs_utils_build_unique_id_kind  (AsAppKind       kind,
                                                 const gchar    *id);
 gboolean        gs_utils_list_has_app_fuzzy    (GsAppList      *list,
                                                 GsApp          *app);
+void            gs_utils_reboot_notify         (GsAppList      *list);
 
 G_END_DECLS
diff --git a/src/gs-page.c b/src/gs-page.c
index 5c6ee138..a596bed5 100644
--- a/src/gs-page.c
+++ b/src/gs-page.c
@@ -214,6 +214,13 @@ gs_page_app_installed_cb (GObject *source,
                return;
        }
 
+       /* the single update needs system reboot, e.g. for firmware */
+       if (gs_app_has_quirk (helper->app, GS_APP_QUIRK_NEEDS_REBOOT)) {
+               g_autoptr(GsAppList) list = gs_app_list_new ();
+               gs_app_list_add (list, helper->app);
+               gs_utils_reboot_notify (list);
+       }
+
        /* only show this if the window is not active */
        if (gs_app_is_installed (helper->app) &&
            helper->action == GS_PLUGIN_ACTION_INSTALL &&
diff --git a/src/gs-updates-section.c b/src/gs-updates-section.c
index 384b5ae2..5806371a 100644
--- a/src/gs-updates-section.c
+++ b/src/gs-updates-section.c
@@ -14,6 +14,7 @@
 #include "gs-app-list-private.h"
 #include "gs-app-row.h"
 #include "gs-page.h"
+#include "gs-common.h"
 #include "gs-progress-button.h"
 #include "gs-update-dialog.h"
 #include "gs-updates-section.h"
@@ -314,18 +315,7 @@ _perform_update_cb (GsPluginLoader *plugin_loader, GAsyncResult *res, gpointer u
        /* when we are not doing an offline update, show a notification
         * if any application requires a reboot */
        } else if (helper->do_reboot_notification) {
-               g_autoptr(GNotification) n = NULL;
-               /* TRANSLATORS: we've just live-updated some apps */
-               n = g_notification_new (_("Updates have been installed"));
-               /* TRANSLATORS: the new apps will not be run until we restart */
-               g_notification_set_body (n, _("A restart is required for them to take effect."));
-               /* TRANSLATORS: button text */
-               g_notification_add_button (n, _("Not Now"), "app.nop");
-               /* TRANSLATORS: button text */
-               g_notification_add_button_with_target (n, _("Restart"), "app.reboot", NULL);
-               g_notification_set_default_action_and_target (n, "app.set-mode", "s", "updates");
-               g_notification_set_priority (n, G_NOTIFICATION_PRIORITY_URGENT);
-               g_application_send_notification (g_application_get_default (), "restart-required", n);
+               gs_utils_reboot_notify (self->list);
        }
 
 out:


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