diff options
author | Carlos Garcia Campos <carlosgc@gnome.org> | 2008-04-16 17:50:18 (GMT) |
---|---|---|
committer | Carlos Garcia Campos <carlosgc@src.gnome.org> | 2008-04-16 17:50:18 (GMT) |
commit | 526941f5d40276f39717de95010f0dd87e2e9c16 (patch) | |
tree | 6453f48a9639de811660730af516b16902600fde /shell/ev-window.c | |
parent | dc921b70a94249212cfb0260e0037a46afc6423f (diff) |
Add GtkMountOperation (renamed to avoid conflicts) to be able to open
2008-04-16 Carlos Garcia Campos <carlosgc@gnome.org>
* configure.ac:
* cut-n-paste/evmountoperation/ev-mount-operation.[ch]:
* shell/Makefile.am:
* shell/ev-window.c: (ev_window_load_remote_failed),
(mount_volume_ready_cb), (window_open_file_copy_ready_cb):
Add GtkMountOperation (renamed to avoid conflicts) to be able to
open documents in remote locations that are not mounted.
svn path=/trunk/; revision=3007
Diffstat (limited to 'shell/ev-window.c')
-rw-r--r-- | shell/ev-window.c | 58 |
1 files changed, 48 insertions, 10 deletions
diff --git a/shell/ev-window.c b/shell/ev-window.c index 81c5b9e..1f78e87 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -66,6 +66,7 @@ #include "ev-history.h" #include "ev-image.h" #include "ev-message-area.h" +#include "ev-mount-operation.h" #include <gtk/gtkprintunixdialog.h> @@ -268,6 +269,8 @@ static void find_bar_search_changed_cb (EggFindBar *find_ GParamSpec *param, EvWindow *ev_window); static void ev_window_do_preview_print (EvWindow *window); +static void ev_window_load_file_remote (EvWindow *ev_window, + GFile *source_file); G_DEFINE_TYPE (EvWindow, ev_window, GTK_TYPE_WINDOW) @@ -1422,6 +1425,39 @@ ev_window_close_dialogs (EvWindow *ev_window) } static void +ev_window_load_remote_failed (EvWindow *ev_window, + GError *error) +{ + ev_view_set_loading (EV_VIEW (ev_window->priv->view), FALSE); + ev_window->priv->in_reload = FALSE; + ev_window_error_message (GTK_WINDOW (ev_window), + _("Unable to open document"), + error); + g_free (ev_window->priv->local_uri); + ev_window->priv->local_uri = NULL; +} + +static void +mount_volume_ready_cb (GFile *source, + GAsyncResult *async_result, + EvWindow *ev_window) +{ + GError *error = NULL; + + g_file_mount_enclosing_volume_finish (source, async_result, &error); + + if (error) { + ev_window_load_remote_failed (ev_window, error); + g_object_unref (source); + g_error_free (error); + } else { + /* Volume successfully mounted, + try opening the file again */ + ev_window_load_file_remote (ev_window, source); + } +} + +static void window_open_file_copy_ready_cb (GFile *source, GAsyncResult *async_result, EvWindow *ev_window) @@ -1438,19 +1474,21 @@ window_open_file_copy_ready_cb (GFile *source, if (error->domain == G_IO_ERROR && error->code == G_IO_ERROR_NOT_MOUNTED) { - /* TODO: try to mount */ + GMountOperation *operation; + + operation = ev_mount_operation_new (GTK_WINDOW (ev_window)); + g_file_mount_enclosing_volume (source, + G_MOUNT_MOUNT_NONE, + operation, NULL, + (GAsyncReadyCallback)mount_volume_ready_cb, + ev_window); + g_object_unref (operation); + } else { + ev_window_load_remote_failed (ev_window, error); + g_object_unref (source); } - - ev_view_set_loading (EV_VIEW (ev_window->priv->view), FALSE); - ev_window->priv->in_reload = FALSE; - ev_window_error_message (GTK_WINDOW (ev_window), - _("Unable to open document"), - error); - g_free (ev_window->priv->local_uri); - ev_window->priv->local_uri = NULL; g_error_free (error); - g_object_unref (source); } static void |