[Xfce4-commits] <xfce4-places-plugin:master> Fixed "mount and open".

Andrzej noreply at xfce.org
Tue Aug 28 10:08:02 CEST 2012


Updating branch refs/heads/master
         to ae286d50bf8d1e31e9b97185394fd29e08a5e84c (commit)
       from 69080e9afba518b8e51d11dbd14c93ab673a6e0a (commit)

commit ae286d50bf8d1e31e9b97185394fd29e08a5e84c
Author: Andrzej <ndrwrdck at gmail.com>
Date:   Tue Aug 28 17:04:53 2012 +0900

    Fixed "mount and open".
    
    It wasn't opening the mounted volume.

 panel-plugin/model_volumes.c |   52 ++++++++++++++++++++++++++++++++++-------
 1 files changed, 43 insertions(+), 9 deletions(-)

diff --git a/panel-plugin/model_volumes.c b/panel-plugin/model_volumes.c
index 893c762..d1f786a 100644
--- a/panel-plugin/model_volumes.c
+++ b/panel-plugin/model_volumes.c
@@ -176,6 +176,42 @@ pbvol_mount_finish(GObject *object,
 }
 
 static void
+pbvol_mount_finish_and_open(GObject *object,
+                            GAsyncResult *result,
+                            gpointer user_data)
+{
+    GVolume *volume = G_VOLUME(object);
+    GError *error = NULL;
+
+    DBG("Mount finish and open");
+
+    if (!g_volume_mount_finish(volume, result, &error)) {
+         /* ignore GIO errors handled internally */
+         if (error->domain != G_IO_ERROR || error->code != G_IO_ERROR_FAILED_HANDLED) {
+             gchar *volume_name = g_volume_get_name(volume);
+             places_show_error_dialog(error,
+                                     _("Failed to mount \"%s\""),
+                                     volume_name);
+             g_free(volume_name);
+         }
+         g_error_free (error);
+    } else {
+        GMount *mount;
+        gchar *uri;
+        mount = g_volume_get_mount(volume);
+
+        if (mount) {
+            GFile *file = g_mount_get_root(mount);
+            uri = g_file_get_uri(file);
+            places_load_file_browser(uri);
+            g_free(uri);
+            g_object_unref(file);
+            g_object_unref(mount);
+        }
+    }
+}
+
+static void
 pbvol_mount(PlacesBookmarkAction *action)
 {
     GVolume *volume;
@@ -211,16 +247,14 @@ pbvol_mount_and_open(PlacesBookmarkAction *action)
     volume = G_VOLUME(action->priv);
     mount = g_volume_get_mount(volume);
 
-    if (!mount)
-        pbvol_mount(action);
+    if (!mount) {
+        GMountOperation *operation = gtk_mount_operation_new(NULL);
 
-    if (mount) {
-        GFile *file = g_mount_get_root(mount);
-        uri = g_file_get_uri(file);
-        places_load_file_browser(uri);
-        g_free(uri);
-        g_object_unref(file);
-        g_object_unref(mount);
+        g_volume_mount(volume, G_MOUNT_MOUNT_NONE, operation, NULL,
+                       pbvol_mount_finish_and_open,
+                       g_object_ref(volume));
+
+        g_object_unref(operation);
     }
 }
 


More information about the Xfce4-commits mailing list