[gnome-settings-daemon] housekeeping: Remove support for notification serves w/o actions



commit 2812abf34eb3212befba98dafab0d2d061f89cce
Author: Bastien Nocera <hadess hadess net>
Date:   Mon Mar 23 11:52:16 2015 +0100

    housekeeping: Remove support for notification serves w/o actions
    
    gnome-shell's supported this for a long time, and gnome-settings-daemon
    is designed to work in gnome-shell, so the check should be unnecessary.

 plugins/housekeeping/Makefile.am       |    2 -
 plugins/housekeeping/gsd-disk-space.c  |  184 ++++---------
 plugins/housekeeping/gsd-ldsm-dialog.c |  470 --------------------------------
 plugins/housekeeping/gsd-ldsm-dialog.h |   68 -----
 4 files changed, 60 insertions(+), 664 deletions(-)
---
diff --git a/plugins/housekeeping/Makefile.am b/plugins/housekeeping/Makefile.am
index 1d21571..3bf8ba7 100644
--- a/plugins/housekeeping/Makefile.am
+++ b/plugins/housekeeping/Makefile.am
@@ -3,8 +3,6 @@ plugin_name = housekeeping
 COMMON_FILES =                         \
        gsd-disk-space.c                \
        gsd-disk-space.h                \
-       gsd-ldsm-dialog.c               \
-       gsd-ldsm-dialog.h               \
        gsd-disk-space-helper.h         \
        gsd-disk-space-helper.c
 
diff --git a/plugins/housekeeping/gsd-disk-space.c b/plugins/housekeeping/gsd-disk-space.c
index 7930862..996d36c 100644
--- a/plugins/housekeeping/gsd-disk-space.c
+++ b/plugins/housekeeping/gsd-disk-space.c
@@ -35,7 +35,6 @@
 #include <libnotify/notify.h>
 
 #include "gsd-disk-space.h"
-#include "gsd-ldsm-dialog.h"
 #include "gsd-disk-space-helper.h"
 
 #define GIGABYTE                   1024 * 1024 * 1024
@@ -73,7 +72,6 @@ static unsigned int       min_notify_period = 10;
 static GSList            *ignore_paths = NULL;
 static GSettings         *settings = NULL;
 static GSettings         *privacy_settings = NULL;
-static GsdLdsmDialog     *dialog = NULL;
 static NotifyNotification *notification = NULL;
 
 static guint64           *time_read;
@@ -179,28 +177,6 @@ ldsm_analyze_path (const gchar *path)
                         NULL, NULL, NULL, NULL);
 }
 
-static gboolean
-server_has_actions (void)
-{
-        gboolean has;
-        GList   *caps;
-        GList   *l;
-
-        caps = notify_get_server_caps ();
-        if (caps == NULL) {
-                fprintf (stderr, "Failed to receive server caps.\n");
-                return FALSE;
-        }
-
-        l = g_list_find_custom (caps, "actions", (GCompareFunc)strcmp);
-        has = l != NULL;
-
-        g_list_foreach (caps, (GFunc) g_free, NULL);
-        g_list_free (caps);
-
-        return has;
-}
-
 static void
 ignore_callback (NotifyNotification *n,
                  const char         *action)
@@ -584,14 +560,16 @@ ldsm_notify_for_mount (LdsmMountInfo *mount,
 {
         gchar  *name, *program;
         gint64 free_space;
-        gint response;
         gboolean has_trash;
         gboolean has_disk_analyzer;
         gboolean retval = TRUE;
         gchar *path;
+        char *free_space_str;
+        char *summary;
+        char *body;
 
         /* Don't show a notice if one is already displayed */
-        if (dialog != NULL || notification != NULL)
+        if (notification != NULL)
                 return retval;
 
         name = g_unix_mount_guess_name (mount->mount);
@@ -603,111 +581,70 @@ ldsm_notify_for_mount (LdsmMountInfo *mount,
         has_disk_analyzer = (program != NULL);
         g_free (program);
 
-        if (server_has_actions ()) {
-                char *free_space_str;
-                char *summary;
-                char *body;
+        free_space_str = g_format_size (free_space);
 
-                free_space_str = g_format_size (free_space);
-
-                if (multiple_volumes) {
-                        summary = g_strdup_printf (_("Low Disk Space on “%s”"), name);
-                        if (has_trash) {
-                                body = g_strdup_printf (_("The volume “%s” has only %s disk space remaining. 
 You may free up some space by emptying the trash."),
-                                                        name,
-                                                        free_space_str);
-                        } else {
-                                body = g_strdup_printf (_("The volume “%s” has only %s disk space 
remaining."),
-                                                        name,
-                                                        free_space_str);
-                        }
+        if (multiple_volumes) {
+                summary = g_strdup_printf (_("Low Disk Space on “%s”"), name);
+                if (has_trash) {
+                        body = g_strdup_printf (_("The volume “%s” has only %s disk space remaining.  You 
may free up some space by emptying the trash."),
+                                                name,
+                                                free_space_str);
                 } else {
-                        summary = g_strdup (_("Low Disk Space"));
-                        if (has_trash) {
-                                body = g_strdup_printf (_("This computer has only %s disk space remaining.  
You may free up some space by emptying the trash."),
-                                                        free_space_str);
-                        } else {
-                                body = g_strdup_printf (_("This computer has only %s disk space remaining."),
-                                                        free_space_str);
-                        }
-                }
-                g_free (free_space_str);
-
-                notification = notify_notification_new (summary, body, "drive-harddisk-symbolic");
-                g_free (summary);
-                g_free (body);
-
-                g_signal_connect (notification,
-                                  "closed",
-                                  G_CALLBACK (on_notification_closed),
-                                  NULL);
-
-                notify_notification_set_app_name (notification, _("Disk space"));
-                notify_notification_set_hint (notification, "transient", g_variant_new_boolean (TRUE));
-                notify_notification_set_urgency (notification, NOTIFY_URGENCY_CRITICAL);
-                notify_notification_set_timeout (notification, NOTIFY_EXPIRES_DEFAULT);
-                if (has_disk_analyzer) {
-                        notify_notification_add_action (notification,
-                                                        "examine",
-                                                        _("Examine"),
-                                                        (NotifyActionCallback) examine_callback,
-                                                        g_strdup (path),
-                                                        g_free);
+                        body = g_strdup_printf (_("The volume “%s” has only %s disk space remaining."),
+                                                name,
+                                                free_space_str);
                 }
+        } else {
+                summary = g_strdup (_("Low Disk Space"));
                 if (has_trash) {
-                        notify_notification_add_action (notification,
-                                                        "empty-trash",
-                                                        _("Empty Trash"),
-                                                        (NotifyActionCallback) empty_trash_callback,
-                                                        NULL,
-                                                        NULL);
+                        body = g_strdup_printf (_("This computer has only %s disk space remaining.  You may 
free up some space by emptying the trash."),
+                                                free_space_str);
+                } else {
+                        body = g_strdup_printf (_("This computer has only %s disk space remaining."),
+                                                free_space_str);
                 }
+        }
+        g_free (free_space_str);
+
+        notification = notify_notification_new (summary, body, "drive-harddisk-symbolic");
+        g_free (summary);
+        g_free (body);
+
+        g_signal_connect (notification,
+                          "closed",
+                          G_CALLBACK (on_notification_closed),
+                          NULL);
+
+        notify_notification_set_app_name (notification, _("Disk space"));
+        notify_notification_set_hint (notification, "transient", g_variant_new_boolean (TRUE));
+        notify_notification_set_urgency (notification, NOTIFY_URGENCY_CRITICAL);
+        notify_notification_set_timeout (notification, NOTIFY_EXPIRES_DEFAULT);
+        if (has_disk_analyzer) {
                 notify_notification_add_action (notification,
-                                                "ignore",
-                                                _("Ignore"),
-                                                (NotifyActionCallback) ignore_callback,
+                                                "examine",
+                                                _("Examine"),
+                                                (NotifyActionCallback) examine_callback,
+                                                g_strdup (path),
+                                                g_free);
+        }
+        if (has_trash) {
+                notify_notification_add_action (notification,
+                                                "empty-trash",
+                                                _("Empty Trash"),
+                                                (NotifyActionCallback) empty_trash_callback,
                                                 NULL,
                                                 NULL);
-                notify_notification_set_category (notification, "device");
-
-                if (!notify_notification_show (notification, NULL)) {
-                        g_warning ("failed to send disk space notification\n");
-                }
-
-        } else {
-                dialog = gsd_ldsm_dialog_new (other_usable_volumes,
-                                              multiple_volumes,
-                                              has_disk_analyzer,
-                                              has_trash,
-                                              free_space,
-                                              name,
-                                              path);
-
-                g_object_ref (G_OBJECT (dialog));
-                response = gtk_dialog_run (GTK_DIALOG (dialog));
-
-                gtk_widget_destroy (GTK_WIDGET (dialog));
-                dialog = NULL;
-
-                switch (response) {
-                case GTK_RESPONSE_CANCEL:
-                        retval = FALSE;
-                        break;
-                case GSD_LDSM_DIALOG_RESPONSE_ANALYZE:
-                        retval = FALSE;
-                        ldsm_analyze_path (path);
-                        break;
-                case GSD_LDSM_DIALOG_RESPONSE_EMPTY_TRASH:
-                        retval = TRUE;
-                        gsd_ldsm_show_empty_trash ();
-                        break;
-                case GTK_RESPONSE_NONE:
-                case GTK_RESPONSE_DELETE_EVENT:
-                        retval = TRUE;
-                        break;
-                default:
-                        g_assert_not_reached ();
-                }
+        }
+        notify_notification_add_action (notification,
+                                        "ignore",
+                                        _("Ignore"),
+                                        (NotifyActionCallback) ignore_callback,
+                                        NULL,
+                                        NULL);
+        notify_notification_set_category (notification, "device");
+
+        if (!notify_notification_show (notification, NULL)) {
+                g_warning ("failed to send disk space notification\n");
         }
 
         g_free (name);
@@ -1080,7 +1017,6 @@ gsd_ldsm_clean (void)
         g_clear_object (&ldsm_monitor);
         g_clear_object (&settings);
         g_clear_object (&privacy_settings);
-        g_clear_object (&dialog);
         g_clear_pointer (&notification, notify_notification_close);
         g_slist_free_full (ignore_paths, g_free);
         ignore_paths = NULL;


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