summaryrefslogtreecommitdiff
path: root/src/nautilus-connect-server-dialog-main.c
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2008-03-17 11:47:59 +0000
committerAlexander Larsson <alexl@src.gnome.org>2008-03-17 11:47:59 +0000
commitad0618ea48d9fb8fbf8092304088d3edbe6a2fcc (patch)
treee70cecdde53622ac2f9efd105e4113a9710e074f /src/nautilus-connect-server-dialog-main.c
parentdbe1551c532c40c23bb95c2cfe19ce1a426741f0 (diff)
downloadnautilus-ad0618ea48d9fb8fbf8092304088d3edbe6a2fcc.tar.gz
Mount location when using the external connect to server dialog app.
2008-03-17 Alexander Larsson <alexl@redhat.com> * src/nautilus-connect-server-dialog-main.c: * src/nautilus-connect-server-dialog-nonmain.c: * src/nautilus-connect-server-dialog.c: Mount location when using the external connect to server dialog app. (#520390) Patch from Cosimo Cecchi <anarki@lilik.it> svn path=/trunk/; revision=13949
Diffstat (limited to 'src/nautilus-connect-server-dialog-main.c')
-rw-r--r--src/nautilus-connect-server-dialog-main.c107
1 files changed, 77 insertions, 30 deletions
diff --git a/src/nautilus-connect-server-dialog-main.c b/src/nautilus-connect-server-dialog-main.c
index 8b409981b..aa7e48a9c 100644
--- a/src/nautilus-connect-server-dialog-main.c
+++ b/src/nautilus-connect-server-dialog-main.c
@@ -38,6 +38,7 @@
#include <eel/eel-app-launch-context.h>
#include <eel/eel-preferences.h>
#include <eel/eel-stock-dialogs.h>
+#include <eel/eel-mount-operation.h>
#include <libnautilus-private/nautilus-icon-names.h>
@@ -47,27 +48,60 @@
static int open_dialogs;
static void
-dialog_destroyed (GtkWidget *widget,
- gpointer user_data)
+main_dialog_destroyed (GtkWidget *widget,
+ gpointer user_data)
+{
+ /* this only happens when user clicks "cancel"
+ * on the main dialog or when we are all done.
+ */
+ gtk_main_quit ();
+}
+
+static void
+error_dialog_destroyed (GtkWidget *widget,
+ GtkWidget *main_dialog)
{
if (--open_dialogs <= 0)
- gtk_main_quit ();
+ gtk_widget_destroy (main_dialog);
}
static void
-show_uri (const char *uri,
- GdkScreen *screen)
+display_error_dialog (GError *error,
+ const char *uri,
+ GtkWidget *parent)
{
GtkDialog *error_dialog;
+ char *error_message;
+
+ error_message = g_strdup_printf (_("Can't display location \"%s\""),
+ uri);
+ error_dialog = eel_show_error_dialog (error_message,
+ error->message,
+ NULL);
+
+ open_dialogs++;
+
+ g_signal_connect (error_dialog, "destroy",
+ G_CALLBACK (error_dialog_destroyed), parent);
+
+ gtk_window_set_screen (GTK_WINDOW (error_dialog),
+ gtk_widget_get_screen (parent));
+
+ g_free (error_message);
+}
+
+static void
+show_uri (const char *uri,
+ GtkWidget *widget)
+{
GError *error;
- char *error_message;
EelAppLaunchContext *launch_context;
launch_context = eel_app_launch_context_new ();
- eel_app_launch_context_set_screen (launch_context, screen);
+ eel_app_launch_context_set_screen (launch_context,
+ gtk_widget_get_screen (widget));
error = NULL;
- /* FIXME: doesn't automount */
g_app_info_launch_default_for_uri (uri,
G_APP_LAUNCH_CONTEXT (launch_context),
&error);
@@ -75,35 +109,48 @@ show_uri (const char *uri,
g_object_unref (launch_context);
if (error) {
- error_message = g_strdup_printf (_("Can't display location \"%s\""),
- uri);
-
- error_dialog = eel_show_error_dialog (error_message,
- error->message,
- NULL);
-
- open_dialogs++;
-
- g_signal_connect (error_dialog, "destroy",
- G_CALLBACK (dialog_destroyed), NULL);
-
- gtk_window_set_screen (GTK_WINDOW (error_dialog), screen);
-
+ display_error_dialog (error, uri, widget);
g_error_free (error);
- g_free (error_message);
+ } else {
+ /* everything is OK, destroy the main dialog and quit */
+ gtk_widget_destroy (widget);
}
}
+static void
+mount_enclosing_ready_cb (GFile *location,
+ GAsyncResult *res,
+ GtkWidget *widget)
+{
+ char *uri;
+ GError *error = NULL;
+
+ g_file_mount_enclosing_volume_finish (location,
+ res, &error);
+ uri = g_file_get_uri (location);
+ if (error) {
+ display_error_dialog (error, uri, widget);
+ } else {
+ /* volume is mounted, show it */
+ show_uri (uri, widget);
+ g_object_unref (location);
+ }
+ g_free (uri);
+}
+
void
nautilus_connect_server_dialog_present_uri (NautilusApplication *application,
GFile *location,
GtkWidget *widget)
{
- char *uri;
-
- uri = g_file_get_uri (location);
- show_uri (uri, gtk_widget_get_screen (widget));
- g_free (uri);
+ GMountOperation *op;
+
+ op = eel_mount_operation_new (GTK_WINDOW (widget));
+ g_file_mount_enclosing_volume (location,
+ 0, op,
+ NULL,
+ (GAsyncReadyCallback) mount_enclosing_ready_cb,
+ widget);
}
int
@@ -155,9 +202,9 @@ main (int argc, char *argv[])
g_object_unref (location);
}
- open_dialogs = 1;
+ open_dialogs = 0;
g_signal_connect (dialog, "destroy",
- G_CALLBACK (dialog_destroyed), NULL);
+ G_CALLBACK (main_dialog_destroyed), NULL);
gtk_widget_show (dialog);