diff options
author | Jasmine Hassan <[email protected]> | 2012-10-27 06:11:08 +0200 |
---|---|---|
committer | Jasmine Hassan <[email protected]> | 2012-11-16 09:45:51 +0200 |
commit | 2218501731180797c5e29ce677f31fd2b2d3ecea (patch) | |
tree | 95c65483458db3010cc112ee919e7f6c0c035a99 /src/caja-connect-server-dialog-main.c | |
parent | eade711fe26dc22391a60bc33f423817c39d9f43 (diff) | |
download | caja-2218501731180797c5e29ce677f31fd2b2d3ecea.tar.bz2 caja-2218501731180797c5e29ce677f31fd2b2d3ecea.tar.xz |
[connect-dialog] handle psswds, display warns/errs in info bar, tweak UI details
connect-dialog: integrate password handling
Also, use the info bar to display warnings/errors, and tweak the UI details.
http://git.gnome.org/browse/nautilus/commit/?id=7d004452f333b7b8b804d87de49c858e8743a115
Diffstat (limited to 'src/caja-connect-server-dialog-main.c')
-rw-r--r-- | src/caja-connect-server-dialog-main.c | 127 |
1 files changed, 30 insertions, 97 deletions
diff --git a/src/caja-connect-server-dialog-main.c b/src/caja-connect-server-dialog-main.c index c73b0df4..4c80fc16 100644 --- a/src/caja-connect-server-dialog-main.c +++ b/src/caja-connect-server-dialog-main.c @@ -22,6 +22,7 @@ * * Authors: * Vincent Untz <[email protected]> + * Cosimo Cecchi <[email protected]> */ #include <config.h> @@ -38,10 +39,9 @@ #include <libcaja-private/caja-icon-names.h> #include <libcaja-private/caja-global-preferences.h> -#include "caja-window.h" #include "caja-connect-server-dialog.h" -static int open_dialogs; +static GSimpleAsyncResult *display_location_res = NULL; static void main_dialog_destroyed (GtkWidget *widget, @@ -53,117 +53,53 @@ main_dialog_destroyed (GtkWidget *widget, gtk_main_quit (); } -static void -error_dialog_destroyed (GtkWidget *widget, - GtkWidget *main_dialog) -{ - if (--open_dialogs <= 0) - gtk_widget_destroy (main_dialog); -} - -static void -display_error_dialog (GError *error, - const char *uri, - GtkWidget *parent) +gboolean +caja_connect_server_dialog_display_location_finish (CajaConnectServerDialog *self, + GAsyncResult *res, + GError **error) { - GtkDialog *error_dialog; - char *error_message; - - error_message = g_strdup_printf (_("Cannot 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)); + if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error)) { + return FALSE; + } - g_free (error_message); + return TRUE; } -static void -show_uri (const char *uri, - GtkWidget *widget) +void +caja_connect_server_dialog_display_location_async (CajaConnectServerDialog *self, + CajaApplication *application, + GFile *location, + GAsyncReadyCallback callback, + gpointer user_data) { - GError *error; + GError *error; GdkAppLaunchContext *launch_context; + gchar *uri; + display_location_res = g_simple_async_result_new (G_OBJECT (self), + callback, user_data, + caja_connect_server_dialog_display_location_async); + + error = NULL; + uri = g_file_get_uri (location); launch_context = gdk_app_launch_context_new (); gdk_app_launch_context_set_screen (launch_context, - gtk_widget_get_screen (widget)); + gtk_widget_get_screen (GTK_WIDGET (self))); - error = NULL; g_app_info_launch_default_for_uri (uri, G_APP_LAUNCH_CONTEXT (launch_context), &error); g_object_unref (launch_context); - if (error) - { - display_error_dialog (error, uri, widget); - g_error_free (error); - } - 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; - gboolean success; - GError *error = NULL; - - uri = g_file_get_uri (location); - success = g_file_mount_enclosing_volume_finish (location, - res, &error); - - if (success || - g_error_matches (error, G_IO_ERROR, G_IO_ERROR_ALREADY_MOUNTED)) - { - /* volume is mounted, show it */ - show_uri (uri, widget); - } - else - { - display_error_dialog (error, uri, widget); - } - - if (error) - { + if (error != NULL) { + g_simple_async_result_set_from_error (display_location_res, error); g_error_free (error); } + g_simple_async_result_complete_in_idle (display_location_res); - g_object_unref (location); - g_free (uri); -} - -void -caja_connect_server_dialog_present_uri (CajaApplication *application, - GFile *location, - GtkWidget *widget) -{ - GMountOperation *op; - - op = gtk_mount_operation_new (GTK_WINDOW (widget)); - g_mount_operation_set_password_save (op, G_PASSWORD_SAVE_FOR_SESSION); - g_file_mount_enclosing_volume (location, - 0, op, - NULL, - (GAsyncReadyCallback) mount_enclosing_ready_cb, - widget); - g_object_unref (op); + g_object_unref (display_location_res); + display_location_res = NULL; } int @@ -181,8 +117,6 @@ main (int argc, char *argv[]) /* Translators: This is the --help description for the connect to server app, the initial newlines are between the command line arg and the description */ context = g_option_context_new (N_("\n\nAdd connect to server mount")); - g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE); - g_option_context_set_translation_domain (context, GETTEXT_PACKAGE); g_option_context_add_group (context, gtk_get_option_group (TRUE)); @@ -202,7 +136,6 @@ main (int argc, char *argv[]) dialog = caja_connect_server_dialog_new (NULL); - open_dialogs = 0; g_signal_connect (dialog, "destroy", G_CALLBACK (main_dialog_destroyed), NULL); |