Commit ad0618ea authored by Alexander Larsson's avatar Alexander Larsson Committed by Alexander Larsson

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
parent dbe1551c
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>
2008-03-14 A. Walton <awalton@svn.gnome.org> 2008-03-14 A. Walton <awalton@svn.gnome.org>
* src/nautilus-connect-server-dialog.c * src/nautilus-connect-server-dialog.c
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include <eel/eel-app-launch-context.h> #include <eel/eel-app-launch-context.h>
#include <eel/eel-preferences.h> #include <eel/eel-preferences.h>
#include <eel/eel-stock-dialogs.h> #include <eel/eel-stock-dialogs.h>
#include <eel/eel-mount-operation.h>
#include <libnautilus-private/nautilus-icon-names.h> #include <libnautilus-private/nautilus-icon-names.h>
...@@ -47,27 +48,60 @@ ...@@ -47,27 +48,60 @@
static int open_dialogs; static int open_dialogs;
static void static void
dialog_destroyed (GtkWidget *widget, main_dialog_destroyed (GtkWidget *widget,
gpointer user_data) 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) if (--open_dialogs <= 0)
gtk_main_quit (); gtk_widget_destroy (main_dialog);
} }
static void static void
show_uri (const char *uri, display_error_dialog (GError *error,
GdkScreen *screen) const char *uri,
GtkWidget *parent)
{ {
GtkDialog *error_dialog; 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; GError *error;
char *error_message;
EelAppLaunchContext *launch_context; EelAppLaunchContext *launch_context;
launch_context = eel_app_launch_context_new (); 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; error = NULL;
/* FIXME: doesn't automount */
g_app_info_launch_default_for_uri (uri, g_app_info_launch_default_for_uri (uri,
G_APP_LAUNCH_CONTEXT (launch_context), G_APP_LAUNCH_CONTEXT (launch_context),
&error); &error);
...@@ -75,35 +109,48 @@ show_uri (const char *uri, ...@@ -75,35 +109,48 @@ show_uri (const char *uri,
g_object_unref (launch_context); g_object_unref (launch_context);
if (error) { if (error) {
error_message = g_strdup_printf (_("Can't display location \"%s\""), display_error_dialog (error, uri, widget);
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);
g_error_free (error); 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 void
nautilus_connect_server_dialog_present_uri (NautilusApplication *application, nautilus_connect_server_dialog_present_uri (NautilusApplication *application,
GFile *location, GFile *location,
GtkWidget *widget) GtkWidget *widget)
{ {
char *uri; GMountOperation *op;
uri = g_file_get_uri (location); op = eel_mount_operation_new (GTK_WINDOW (widget));
show_uri (uri, gtk_widget_get_screen (widget)); g_file_mount_enclosing_volume (location,
g_free (uri); 0, op,
NULL,
(GAsyncReadyCallback) mount_enclosing_ready_cb,
widget);
} }
int int
...@@ -155,9 +202,9 @@ main (int argc, char *argv[]) ...@@ -155,9 +202,9 @@ main (int argc, char *argv[])
g_object_unref (location); g_object_unref (location);
} }
open_dialogs = 1; open_dialogs = 0;
g_signal_connect (dialog, "destroy", g_signal_connect (dialog, "destroy",
G_CALLBACK (dialog_destroyed), NULL); G_CALLBACK (main_dialog_destroyed), NULL);
gtk_widget_show (dialog); gtk_widget_show (dialog);
......
...@@ -50,4 +50,7 @@ nautilus_connect_server_dialog_present_uri (NautilusApplication *application, ...@@ -50,4 +50,7 @@ nautilus_connect_server_dialog_present_uri (NautilusApplication *application,
location, location,
gtk_widget_get_screen (widget)); gtk_widget_get_screen (widget));
} }
gtk_widget_destroy (widget);
g_object_unref (location);
} }
...@@ -325,10 +325,6 @@ connect_to_server (NautilusConnectServerDialog *dialog) ...@@ -325,10 +325,6 @@ connect_to_server (NautilusConnectServerDialog *dialog)
nautilus_connect_server_dialog_present_uri (dialog->details->application, nautilus_connect_server_dialog_present_uri (dialog->details->application,
location, location,
GTK_WIDGET (dialog)); GTK_WIDGET (dialog));
g_object_unref (location);
gtk_widget_destroy (GTK_WIDGET (dialog));
} }
static void static void
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment