[gtk+/places-sidebar] Copy code from Nautilus to mount volumes
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/places-sidebar] Copy code from Nautilus to mount volumes
- Date: Mon, 29 Oct 2012 20:30:16 +0000 (UTC)
commit de5f5b7cef09fe2d3527dd22c63e0fd6eefe4cb7
Author: Federico Mena Quintero <federico gnome org>
Date: Mon Oct 29 14:28:12 2012 -0600
Copy code from Nautilus to mount volumes
Instead of having a nested-callback scheme (to preserve internal API compatibility),
we use a direct callback from g_volume_mount().
Signed-off-by: Federico Mena Quintero <federico gnome org>
gtk/gtkplacessidebar.c | 86 +++++++++++++++++++++++++++++++-----------------
1 files changed, 56 insertions(+), 30 deletions(-)
---
diff --git a/gtk/gtkplacessidebar.c b/gtk/gtkplacessidebar.c
index 10ac11c..b9c1936 100644
--- a/gtk/gtkplacessidebar.c
+++ b/gtk/gtkplacessidebar.c
@@ -1823,14 +1823,56 @@ bookmarks_selection_changed_cb (GtkTreeSelection *selection,
}
static void
-volume_mounted_cb (GVolume *volume,
- GObject *user_data)
+drive_start_from_bookmark_cb (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
{
- GMount *mount;
GtkPlacesSidebar *sidebar;
+ GError *error;
+ char *primary;
+ char *name;
sidebar = GTK_PLACES_SIDEBAR (user_data);
+ error = NULL;
+ if (!g_drive_poll_for_media_finish (G_DRIVE (source_object), res, &error)) {
+ if (error->code != G_IO_ERROR_FAILED_HANDLED) {
+ name = g_drive_get_name (G_DRIVE (source_object));
+ primary = g_strdup_printf (_("Unable to start %s"), name);
+ g_free (name);
+ emit_show_error_message (sidebar, primary, error->message);
+ g_free (primary);
+ }
+ g_error_free (error);
+ }
+}
+
+/* Callback from g_volume_mount() */
+static void
+volume_mount_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
+{
+ GtkPlacesSidebar *sidebar = GTK_PLACES_SIDEBAR (user_data);
+ GVolume *volume;
+ GError *error;
+ char *primary;
+ char *name;
+ GMount *mount;
+
+ volume = G_VOLUME (source_object);
+
+ error = NULL;
+ if (!g_volume_mount_finish (volume, result, &error)) {
+ if (error->code != G_IO_ERROR_FAILED_HANDLED &&
+ error->code != G_IO_ERROR_ALREADY_MOUNTED) {
+ name = g_volume_get_name (G_VOLUME (source_object));
+ primary = g_strdup_printf (_("Unable to access â%sâ"), name);
+ g_free (name);
+ emit_show_error_message (sidebar, primary, error->message);
+ g_free (primary);
+ }
+ g_error_free (error);
+ }
+
sidebar->mounting = FALSE;
mount = g_volume_get_mount (volume);
@@ -1843,31 +1885,21 @@ volume_mounted_cb (GVolume *volume,
g_object_unref (G_OBJECT (location));
g_object_unref (G_OBJECT (mount));
}
+
+ g_object_unref (sidebar);
}
+/* This was nautilus_file_operations_mount_volume_full() */
static void
-drive_start_from_bookmark_cb (GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
+mount_volume (GtkPlacesSidebar *sidebar, GVolume *volume)
{
- GtkPlacesSidebar *sidebar;
- GError *error;
- char *primary;
- char *name;
+ GMountOperation *mount_op;
- sidebar = GTK_PLACES_SIDEBAR (user_data);
+ mount_op = gtk_mount_operation_new (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (sidebar))));
+ g_mount_operation_set_password_save (mount_op, G_PASSWORD_SAVE_FOR_SESSION);
- error = NULL;
- if (!g_drive_poll_for_media_finish (G_DRIVE (source_object), res, &error)) {
- if (error->code != G_IO_ERROR_FAILED_HANDLED) {
- name = g_drive_get_name (G_DRIVE (source_object));
- primary = g_strdup_printf (_("Unable to start %s"), name);
- g_free (name);
- emit_show_error_message (sidebar, primary, error->message);
- g_free (primary);
- }
- g_error_free (error);
- }
+ g_object_ref (sidebar);
+ g_volume_mount (volume, 0, mount_op, NULL, volume_mount_cb, sidebar);
}
static void
@@ -1906,11 +1938,7 @@ open_selected_bookmark (GtkPlacesSidebar *sidebar,
sidebar->go_to_after_mount_open_mode = open_mode;
-#if DO_NOT_COMPILE
- nautilus_file_operations_mount_volume_full (NULL, volume,
- volume_mounted_cb,
- G_OBJECT (sidebar));
-#endif
+ mount_volume (sidebar, volume);
} else if (volume == NULL && drive != NULL &&
(g_drive_can_start (drive) || g_drive_can_start_degraded (drive))) {
GMountOperation *mount_op;
@@ -2106,10 +2134,8 @@ mount_shortcut_cb (GtkMenuItem *item,
-1);
if (volume != NULL) {
-#if DO_NOT_COMPILE
- nautilus_file_operations_mount_volume (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (sidebar))), volume);
+ mount_volume (sidebar, volume);
g_object_unref (volume);
-#endif
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]