[gvfs] udisks2: Refactor notification handling



commit c6a3c83668fea1a9545e8e8991562d26ccd8e32e
Author: Ondrej Holy <oholy redhat com>
Date:   Thu Dec 22 16:41:11 2016 +0100

    udisks2: Refactor notification handling
    
    The generic_text variable is used currently to determine which strings
    should be used for notifications. It is TRUE if unmounting (i.e. mount
    is set) and FALSE otherwise (i.e. drive is set). Remove this variable
    and make it more obvious...
    
    https://bugzilla.gnome.org/show_bug.cgi?id=775891

 monitor/udisks2/gvfsudisks2drive.c |    4 ++--
 monitor/udisks2/gvfsudisks2mount.c |    3 +--
 monitor/udisks2/gvfsudisks2utils.c |   14 +++++---------
 monitor/udisks2/gvfsudisks2utils.h |    3 +--
 4 files changed, 9 insertions(+), 15 deletions(-)
---
diff --git a/monitor/udisks2/gvfsudisks2drive.c b/monitor/udisks2/gvfsudisks2drive.c
index 021b0a2..609bf08 100644
--- a/monitor/udisks2/gvfsudisks2drive.c
+++ b/monitor/udisks2/gvfsudisks2drive.c
@@ -882,7 +882,7 @@ gvfs_udisks2_drive_eject_with_operation (GDrive              *_drive,
   if (mount_operation != NULL)
     {
       g_object_set_data (G_OBJECT (mount_operation), "x-udisks2-is-eject", GINT_TO_POINTER (1));
-      gvfs_udisks2_unmount_notify_start (mount_operation, NULL, _drive, FALSE);
+      gvfs_udisks2_unmount_notify_start (mount_operation, NULL, _drive);
     }
 
   /* first we need to go through all the volumes and unmount their assoicated mounts (if any) */
@@ -1024,7 +1024,7 @@ gvfs_udisks2_drive_stop (GDrive              *_drive,
   if (mount_operation != NULL)
     {
       g_object_set_data (G_OBJECT (mount_operation), "x-udisks2-is-stop", GINT_TO_POINTER (1));
-      gvfs_udisks2_unmount_notify_start (mount_operation, NULL, _drive, FALSE);
+      gvfs_udisks2_unmount_notify_start (mount_operation, NULL, _drive);
     }
 
   /* first we need to go through all the volumes and unmount their assoicated mounts (if any) */
diff --git a/monitor/udisks2/gvfsudisks2mount.c b/monitor/udisks2/gvfsudisks2mount.c
index 860903c..ead65c9 100644
--- a/monitor/udisks2/gvfsudisks2mount.c
+++ b/monitor/udisks2/gvfsudisks2mount.c
@@ -961,8 +961,7 @@ unmount_do (UnmountData *data,
 
   if (data->mount_operation != NULL)
     gvfs_udisks2_unmount_notify_start (data->mount_operation, 
-                                       G_MOUNT (data->mount), NULL,
-                                       TRUE);
+                                       G_MOUNT (data->mount), NULL);
 
   /* Use the umount(8) command if there is no block device / filesystem */
   if (data->filesystem == NULL)
diff --git a/monitor/udisks2/gvfsudisks2utils.c b/monitor/udisks2/gvfsudisks2utils.c
index 1ad1731..26d76b9 100644
--- a/monitor/udisks2/gvfsudisks2utils.c
+++ b/monitor/udisks2/gvfsudisks2utils.c
@@ -608,7 +608,6 @@ typedef struct {
 
   GMountOperation *op;
   gboolean op_aborted;
-  gboolean generic_text;
   gboolean show_processes_up;
 
   guint unmount_timer_id;
@@ -671,7 +670,7 @@ unmount_notify_timer_cb (gpointer user_data)
   data->unmount_fired = TRUE;
 
   name = unmount_notify_get_name (data);
-  if (data->generic_text)
+  if (data->mount)
     message = g_strdup_printf (_("Unmounting %s\nDisconnecting from filesystem."), name);
   else
     message = g_strdup_printf (_("Writing data to %s\nDevice should not be unplugged."), name);
@@ -755,8 +754,7 @@ unmount_notify_data_free (gpointer user_data)
 static UnmountNotifyData *
 unmount_notify_data_for_operation (GMountOperation *op,
                                    GMount          *mount,
-                                   GDrive          *drive,
-                                   gboolean         generic_text)
+                                   GDrive          *drive)
 {
   UnmountNotifyData *data;
 
@@ -766,7 +764,6 @@ unmount_notify_data_for_operation (GMountOperation *op,
 
   data = g_slice_new0 (UnmountNotifyData);
   data->op = op;
-  data->generic_text = generic_text;
 
   if (mount)
     data->mount = g_object_ref (mount);
@@ -790,12 +787,11 @@ unmount_notify_data_for_operation (GMountOperation *op,
 void
 gvfs_udisks2_unmount_notify_start (GMountOperation *op,
                                    GMount          *mount,
-                                   GDrive          *drive,
-                                   gboolean         generic_text)
+                                   GDrive          *drive)
 {
   UnmountNotifyData *data;
 
-  data = unmount_notify_data_for_operation (op, mount, drive, generic_text);
+  data = unmount_notify_data_for_operation (op, mount, drive);
   unmount_notify_ensure_timer (data);
 }
 
@@ -815,7 +811,7 @@ gvfs_udisks2_unmount_notify_stop (GMountOperation *op,
     return;
 
   name = unmount_notify_get_name (data);
-  if (data->generic_text)
+  if (data->mount)
     message = g_strdup_printf (_("%s unmounted\nFilesystem has been disconnected."), name);
   else
     message = g_strdup_printf (_("%s can be safely unplugged\nDevice can be removed."), name);
diff --git a/monitor/udisks2/gvfsudisks2utils.h b/monitor/udisks2/gvfsudisks2utils.h
index 2ee0da2..fbd699b 100644
--- a/monitor/udisks2/gvfsudisks2utils.h
+++ b/monitor/udisks2/gvfsudisks2utils.h
@@ -55,8 +55,7 @@ gboolean gvfs_udisks2_utils_is_drive_on_our_seat (UDisksDrive *drive);
 
 void     gvfs_udisks2_unmount_notify_start (GMountOperation *op,
                                             GMount          *mount,
-                                            GDrive          *drive,
-                                            gboolean         generic_text);
+                                            GDrive          *drive);
 void     gvfs_udisks2_unmount_notify_stop  (GMountOperation *op,
                                             gboolean         unmount_failed);
 


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