[gnome-software/wip/temp/ubuntu-xenial-rebased: 170/329] Don't use notification actions under Unity



commit 69fcaec7c5846c20d608f1cda604d648c5b32382
Author: William Hua <william hua canonical com>
Date:   Wed Mar 23 10:27:19 2016 -0400

    Don't use notification actions under Unity

 src/gs-dbus-helper.c    |   14 +++++++++++---
 src/gs-update-monitor.c |   37 ++++++++++++++++++++++++++-----------
 src/gs-utils.c          |   22 +++++++++++++++-------
 3 files changed, 52 insertions(+), 21 deletions(-)
---
diff --git a/src/gs-dbus-helper.c b/src/gs-dbus-helper.c
index e657f2a..b75e950 100644
--- a/src/gs-dbus-helper.c
+++ b/src/gs-dbus-helper.c
@@ -284,6 +284,12 @@ is_show_confirm_search_set (const gchar *interaction)
        return ret;
 }
 
+static gboolean
+is_unity (void)
+{
+       return g_strcmp0 (g_getenv ("XDG_CURRENT_DESKTOP"), "Unity") == 0;
+}
+
 static void
 notify_search_resources (GsShellExtrasMode   mode,
                          const gchar        *desktop_id,
@@ -344,9 +350,11 @@ notify_search_resources (GsShellExtrasMode   mode,
 
        n = g_notification_new (title);
        g_notification_set_body (n, body);
-       /* TRANSLATORS: this is a button that launches gnome-software */
-       g_notification_add_button_with_target (n, _("Find in Software"), "app.install-resources", "(s^ass)", 
mode_string, resources, "");
-       g_notification_set_default_action_and_target (n, "app.install-resources", "(s^ass)", mode_string, 
resources, "");
+       if (!is_unity ()) {
+               /* TRANSLATORS: this is a button that launches gnome-software */
+               g_notification_add_button_with_target (n, _("Find in Software"), "app.install-resources", 
"(s^ass)", mode_string, resources, "");
+               g_notification_set_default_action_and_target (n, "app.install-resources", "(s^ass)", 
mode_string, resources, "");
+       }
        g_application_send_notification (g_application_get_default (), "install-resources", n);
 }
 
diff --git a/src/gs-update-monitor.c b/src/gs-update-monitor.c
index cceaedd..69c5cb4 100644
--- a/src/gs-update-monitor.c
+++ b/src/gs-update-monitor.c
@@ -57,6 +57,12 @@ reenable_offline_update_notification (gpointer data)
        return G_SOURCE_REMOVE;
 }
 
+static gboolean
+is_unity (void)
+{
+       return g_strcmp0 (g_getenv ("XDG_CURRENT_DESKTOP"), "Unity") == 0;
+}
+
 static void
 notify_offline_update_available (GsUpdateMonitor *monitor)
 {
@@ -90,17 +96,21 @@ notify_offline_update_available (GsUpdateMonitor *monitor)
                body = _("It is recommended that you install important updates now");
                n = g_notification_new (title);
                g_notification_set_body (n, body);
-               g_notification_add_button (n, _("Restart & Install"), "app.reboot-and-install");
-               g_notification_set_default_action_and_target (n, "app.set-mode", "s", "updates");
+               if (!is_unity ()) {
+                       g_notification_add_button (n, _("Restart & Install"), "app.reboot-and-install");
+                       g_notification_set_default_action_and_target (n, "app.set-mode", "s", "updates");
+               }
                g_application_send_notification (monitor->application, "updates-available", n);
        } else {
                title = _("Software Updates Available");
                body = _("Important OS and application updates are ready to be installed");
                n = g_notification_new (title);
                g_notification_set_body (n, body);
-               g_notification_add_button (n, _("Not Now"), "app.nop");
-               g_notification_add_button_with_target (n, _("View"), "app.set-mode", "s", "updates");
-               g_notification_set_default_action_and_target (n, "app.set-mode", "s", "updates");
+               if (!is_unity ()) {
+                       g_notification_add_button (n, _("Not Now"), "app.nop");
+                       g_notification_add_button_with_target (n, _("View"), "app.set-mode", "s", "updates");
+                       g_notification_set_default_action_and_target (n, "app.set-mode", "s", "updates");
+               }
                g_application_send_notification (monitor->application, "updates-available", n);
        }
 }
@@ -237,7 +247,8 @@ get_upgrades_finished_cb (GObject *object,
        /* TRANSLATORS: this is a distro upgrade */
        n = g_notification_new (_("Software Upgrade Available"));
        g_notification_set_body (n, body);
-       g_notification_set_default_action_and_target (n, "app.set-mode", "s", "updates");
+       if (!is_unity ())
+               g_notification_set_default_action_and_target (n, "app.set-mode", "s", "updates");
        g_application_send_notification (monitor->application, "upgrades-available", n);
 }
 
@@ -434,9 +445,11 @@ get_updates_historical_cb (GObject *object, GAsyncResult *res, gpointer data)
                        /* TRANSLATORS: message when we offline updates have failed */
                        g_notification_set_body (notification, _("An important OS update failed to be 
installed."));
                        g_application_send_notification (monitor->application, "offline-updates", 
notification);
-                       g_notification_add_button (notification, _("Show Details"), 
"app.show-offline-update-error");
-                       g_notification_set_default_action (notification, "app.show-offline-update-error");
-                       g_application_send_notification (monitor->application, "offline-updates", 
notification);
+                       if (!is_unity ()) {
+                               g_notification_add_button (notification, _("Show Details"), 
"app.show-offline-update-error");
+                               g_notification_set_default_action (notification, 
"app.show-offline-update-error");
+                               g_application_send_notification (monitor->application, "offline-updates", 
notification);
+                       }
                }
                return;
        }
@@ -464,8 +477,10 @@ get_updates_historical_cb (GObject *object, GAsyncResult *res, gpointer data)
         * 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 (!is_unity ()) {
+               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 */
diff --git a/src/gs-utils.c b/src/gs-utils.c
index 956a721..d0bee8b 100644
--- a/src/gs-utils.c
+++ b/src/gs-utils.c
@@ -129,6 +129,12 @@ gs_grab_focus_when_mapped (GtkWidget *widget)
                                        G_CALLBACK (grab_focus), NULL);
 }
 
+static gboolean
+is_unity (void)
+{
+       return g_strcmp0 (g_getenv ("XDG_CURRENT_DESKTOP"), "Unity") == 0;
+}
+
 void
 gs_app_notify_installed (GsApp *app)
 {
@@ -139,14 +145,16 @@ gs_app_notify_installed (GsApp *app)
         * has been successfully installed */
        summary = g_strdup_printf (_("%s is now installed"), gs_app_get_name (app));
        n = g_notification_new (summary);
-       if (gs_app_get_kind (app) == AS_APP_KIND_DESKTOP) {
-               /* TRANSLATORS: this is button that opens the newly installed application */
-               g_notification_add_button_with_target (n, _("Launch"),
-                                                      "app.launch", "s",
-                                                      gs_app_get_id (app));
+       if (!is_unity ()) {
+               if (gs_app_get_kind (app) == AS_APP_KIND_DESKTOP) {
+                       /* TRANSLATORS: this is button that opens the newly installed application */
+                       g_notification_add_button_with_target (n, _("Launch"),
+                                                              "app.launch", "s",
+                                                              gs_app_get_id (app));
+               }
+               g_notification_set_default_action_and_target  (n, "app.details", "(ss)",
+                                                              gs_app_get_id (app), "");
        }
-       g_notification_set_default_action_and_target  (n, "app.details", "(ss)",
-                                                      gs_app_get_id (app), "");
        g_application_send_notification (g_application_get_default (), "installed", n);
 }
 


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