[gnome-software/wip/temp/ubuntu-xenial-rebased: 231/329] Use gs_utils_is_current_desktop () helper



commit 339f6d226db3ca7fd84e4f85706c437ed5b89246
Author: William Hua <william hua canonical com>
Date:   Wed Apr 13 14:50:55 2016 -0400

    Use gs_utils_is_current_desktop () helper

 src/gs-dbus-helper.c    |    9 ++-------
 src/gs-shell-updates.c  |    8 +-------
 src/gs-update-monitor.c |   16 +++++-----------
 src/gs-utils.c          |    8 +-------
 4 files changed, 9 insertions(+), 32 deletions(-)
---
diff --git a/src/gs-dbus-helper.c b/src/gs-dbus-helper.c
index b75e950..f1c1ced 100644
--- a/src/gs-dbus-helper.c
+++ b/src/gs-dbus-helper.c
@@ -32,6 +32,7 @@
 #include "gs-packagekit-modify2-generated.h"
 #include "gs-resources.h"
 #include "gs-shell-extras.h"
+#include "gs-utils.h"
 
 struct _GsDbusHelper {
        GObject                  parent;
@@ -284,12 +285,6 @@ 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,
@@ -350,7 +345,7 @@ notify_search_resources (GsShellExtrasMode   mode,
 
        n = g_notification_new (title);
        g_notification_set_body (n, body);
-       if (!is_unity ()) {
+       if (!gs_utils_is_current_desktop ("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, "");
diff --git a/src/gs-shell-updates.c b/src/gs-shell-updates.c
index 0b5b04d..8e5283c 100644
--- a/src/gs-shell-updates.c
+++ b/src/gs-shell-updates.c
@@ -960,12 +960,6 @@ gs_shell_updates_reboot_failed_cb (GObject *source, GAsyncResult *res, gpointer
                                           self);
 }
 
-static gboolean
-is_unity (void)
-{
-       return g_strcmp0 (g_getenv ("XDG_CURRENT_DESKTOP"), "Unity") == 0;
-}
-
 /**
  * gs_shell_updates_perform_update_cb:
  **/
@@ -1004,7 +998,7 @@ gs_shell_updates_perform_update_cb (GsPluginLoader *plugin_loader,
                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."));
-               if (!is_unity ()) {
+               if (!gs_utils_is_current_desktop ("Unity")) {
                        /* TRANSLATORS: button text */
                        g_notification_add_button (n, _("Not Now"), "app.nop");
                        /* TRANSLATORS: button text */
diff --git a/src/gs-update-monitor.c b/src/gs-update-monitor.c
index c1c6a41..096cc8b 100644
--- a/src/gs-update-monitor.c
+++ b/src/gs-update-monitor.c
@@ -57,12 +57,6 @@ 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)
 {
@@ -96,7 +90,7 @@ 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);
-               if (!is_unity ()) {
+               if (!gs_utils_is_current_desktop ("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");
                }
@@ -106,7 +100,7 @@ notify_offline_update_available (GsUpdateMonitor *monitor)
                body = _("Important OS and application updates are ready to be installed");
                n = g_notification_new (title);
                g_notification_set_body (n, body);
-               if (!is_unity ()) {
+               if (!gs_utils_is_current_desktop ("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");
@@ -247,7 +241,7 @@ 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);
-       if (!is_unity ())
+       if (!gs_utils_is_current_desktop ("Unity"))
                g_notification_set_default_action_and_target (n, "app.set-mode", "s", "updates");
        g_application_send_notification (monitor->application, "upgrades-available", n);
 }
@@ -444,7 +438,7 @@ get_updates_historical_cb (GObject *object, GAsyncResult *res, gpointer data)
                        notification = g_notification_new (_("Software Updates Failed"));
                        /* TRANSLATORS: message when we offline updates have failed */
                        g_notification_set_body (notification, _("An important OS update failed to be 
installed."));
-                       if (!is_unity ()) {
+                       if (!gs_utils_is_current_desktop ("Unity")) {
                                g_notification_add_button (notification, _("Show Details"), 
"app.show-offline-update-error");
                                g_notification_set_default_action (notification, 
"app.show-offline-update-error");
                        }
@@ -476,7 +470,7 @@ 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." */
-       if (!is_unity ()) {
+       if (!gs_utils_is_current_desktop ("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");
        }
diff --git a/src/gs-utils.c b/src/gs-utils.c
index d0bee8b..5c452c5 100644
--- a/src/gs-utils.c
+++ b/src/gs-utils.c
@@ -129,12 +129,6 @@ 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)
 {
@@ -145,7 +139,7 @@ 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 (!is_unity ()) {
+       if (!gs_utils_is_current_desktop ("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"),


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