[Xfce4-commits] <thunar:master> Use mount operations with eject and unmount.

Nick Schermer noreply at xfce.org
Thu Apr 19 22:26:01 CEST 2012


Updating branch refs/heads/master
         to 630dcf35ab247b91892f73746cfca34ec78ed991 (commit)
       from 18c4dee71ff0e1de70c88d7517de214c850458fa (commit)

commit 630dcf35ab247b91892f73746cfca34ec78ed991
Author: Nick Schermer <nick at xfce.org>
Date:   Thu Apr 19 22:21:49 2012 +0200

    Use mount operations with eject and unmount.
    
    This removed some deprecated abi and gives to possibility
    for communication with the user when performing the operation.

 thunar/thunar-shortcuts-view.c |   23 +++++++++++++++--------
 thunar/thunar-tree-view.c      |   27 +++++++++++++++++----------
 2 files changed, 32 insertions(+), 18 deletions(-)

diff --git a/thunar/thunar-shortcuts-view.c b/thunar/thunar-shortcuts-view.c
index 17e712d..f7d91d1 100644
--- a/thunar/thunar-shortcuts-view.c
+++ b/thunar/thunar-shortcuts-view.c
@@ -1401,7 +1401,7 @@ thunar_shortcuts_view_eject_finish (GObject      *object,
   _thunar_return_if_fail (THUNAR_IS_SHORTCUTS_VIEW (view));
 
   /* check if there was an error */
-  if (!g_volume_eject_finish (volume, result, &error))
+  if (!g_volume_eject_with_operation_finish (volume, result, &error))
     {
       /* ignore GIO errors already handled */
       if (error->domain != G_IO_ERROR || error->code != G_IO_ERROR_FAILED_HANDLED)
@@ -1442,7 +1442,7 @@ thunar_shortcuts_view_unmount_finish (GObject      *object,
   _thunar_return_if_fail (THUNAR_IS_SHORTCUTS_VIEW (view));
 
   /* check if there was an error */
-  if (!g_mount_unmount_finish (mount, result, &error))
+  if (!g_mount_unmount_with_operation_finish (mount, result, &error))
     {
       /* ignore GIO errors already handled */
       if (error->domain != G_IO_ERROR || error->code != G_IO_ERROR_FAILED_HANDLED)
@@ -1475,6 +1475,8 @@ thunar_shortcuts_view_eject (ThunarShortcutsView *view)
   GtkTreeIter       iter;
   GVolume          *volume;
   GMount           *mount;
+  GMountOperation  *mount_operation;
+  GtkWidget        *window;
 
   _thunar_return_if_fail (THUNAR_IS_SHORTCUTS_VIEW (view));
 
@@ -1486,6 +1488,10 @@ thunar_shortcuts_view_eject (ThunarShortcutsView *view)
       gtk_tree_model_get (model, &iter, THUNAR_SHORTCUTS_MODEL_COLUMN_VOLUME, &volume, -1);
       if (G_UNLIKELY (volume != NULL))
         {
+          /* prepare a mount operation */
+          window = gtk_widget_get_toplevel (GTK_WIDGET (view));
+          mount_operation = gtk_mount_operation_new (GTK_WINDOW (window));
+
           /* determine what the appropriate method is: eject or unmount */
           if (g_volume_can_eject (volume))
             {
@@ -1494,9 +1500,9 @@ thunar_shortcuts_view_eject (ThunarShortcutsView *view)
 #endif
 
               /* try to to eject the volume asynchronously */
-              g_volume_eject (volume, G_MOUNT_UNMOUNT_NONE, NULL, 
-                              thunar_shortcuts_view_eject_finish, 
-                              g_object_ref (view));
+              g_volume_eject_with_operation (volume, G_MOUNT_UNMOUNT_NONE, mount_operation, NULL,
+                                             thunar_shortcuts_view_eject_finish,
+                                             g_object_ref (view));
             }
           else
             {
@@ -1509,9 +1515,9 @@ thunar_shortcuts_view_eject (ThunarShortcutsView *view)
 #endif
 
                   /* the volume is mounted, try to unmount the mount */
-                  g_mount_unmount (mount, G_MOUNT_UNMOUNT_NONE, NULL,
-                                   thunar_shortcuts_view_unmount_finish, 
-                                   g_object_ref (view));
+                  g_mount_unmount_with_operation (mount, G_MOUNT_UNMOUNT_NONE, mount_operation, NULL,
+                                                  thunar_shortcuts_view_unmount_finish,
+                                                  g_object_ref (view));
 
                   /* release the mount */
                   g_object_unref (mount);
@@ -1520,6 +1526,7 @@ thunar_shortcuts_view_eject (ThunarShortcutsView *view)
 
           /* cleanup */
           g_object_unref (volume);
+          g_object_unref (mount_operation);
         }
     }
 }
diff --git a/thunar/thunar-tree-view.c b/thunar/thunar-tree-view.c
index 76d66f8..bdbc367 100644
--- a/thunar/thunar-tree-view.c
+++ b/thunar/thunar-tree-view.c
@@ -1736,7 +1736,7 @@ thunar_tree_view_action_eject_finish (GObject      *object,
   _thunar_return_if_fail (THUNAR_IS_TREE_VIEW (view));
 
   /* check if there was an error */
-  if (!g_volume_eject_finish (volume, result, &error))
+  if (!g_volume_eject_with_operation_finish (volume, result, &error))
     {
       /* ignore GIO errors already handled */
       if (error->domain != G_IO_ERROR || error->code != G_IO_ERROR_FAILED_HANDLED)
@@ -1777,7 +1777,7 @@ thunar_tree_view_action_unmount_finish (GObject      *object,
   _thunar_return_if_fail (THUNAR_IS_TREE_VIEW (view));
 
   /* check if there was an error */
-  if (!g_mount_unmount_finish (mount, result, &error))
+  if (!g_mount_unmount_with_operation_finish (mount, result, &error))
     {
       /* ignore GIO errors already handled */
       if (error->domain != G_IO_ERROR || error->code != G_IO_ERROR_FAILED_HANDLED)
@@ -1805,8 +1805,10 @@ thunar_tree_view_action_unmount_finish (GObject      *object,
 static void
 thunar_tree_view_action_eject (ThunarTreeView *view)
 {
-  GVolume *volume;
-  GMount  *mount;
+  GVolume         *volume;
+  GMount          *mount;
+  GMountOperation *mount_operation;
+  GtkWidget       *window;
 
   _thunar_return_if_fail (THUNAR_IS_TREE_VIEW (view));
 
@@ -1814,6 +1816,10 @@ thunar_tree_view_action_eject (ThunarTreeView *view)
   volume = thunar_tree_view_get_selected_volume (view);
   if (G_LIKELY (volume != NULL))
     {
+      /* prepare a mount operation */
+      window = gtk_widget_get_toplevel (GTK_WIDGET (view));
+      mount_operation = gtk_mount_operation_new (GTK_WINDOW (window));
+
       /* determine what the appropriate method is: eject or unmount */
       if (g_volume_can_eject (volume))
         {
@@ -1822,9 +1828,9 @@ thunar_tree_view_action_eject (ThunarTreeView *view)
 #endif
 
           /* try to to eject the volume asynchronously */
-          g_volume_eject (volume, G_MOUNT_UNMOUNT_NONE, NULL, 
-                          thunar_tree_view_action_eject_finish, 
-                          g_object_ref (view));
+          g_volume_eject_with_operation (volume, G_MOUNT_UNMOUNT_NONE, mount_operation, NULL,
+                                         thunar_tree_view_action_eject_finish,
+                                         g_object_ref (view));
         }
       else
         {
@@ -1837,9 +1843,9 @@ thunar_tree_view_action_eject (ThunarTreeView *view)
 #endif
 
               /* the volume is mounted, try to unmount the mount */
-              g_mount_unmount (mount, G_MOUNT_UNMOUNT_NONE, NULL,
-                               thunar_tree_view_action_unmount_finish, 
-                               g_object_ref (view));
+              g_mount_unmount_with_operation (mount, G_MOUNT_UNMOUNT_NONE, mount_operation, NULL,
+                                              thunar_tree_view_action_unmount_finish,
+                                              g_object_ref (view));
 
               /* release the mount */
               g_object_unref (mount);
@@ -1848,6 +1854,7 @@ thunar_tree_view_action_eject (ThunarTreeView *view)
 
       /* release the volume */
       g_object_unref (volume);
+      g_object_unref (mount_operation);
     }
 }
 


More information about the Xfce4-commits mailing list