From 1638bc87bac1eb0bcf842872767d4cc953153a4e Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Sat, 27 Oct 2012 05:40:18 +0200 Subject: [connect-dialog] redesign the dialog According to Allan Day's mockups. http://git.gnome.org/browse/nautilus/commit/?id=7848e74d812c22299962a8ae22b01dbd403929c0 --- src/caja-connect-server-dialog-main.c | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) (limited to 'src/caja-connect-server-dialog-main.c') diff --git a/src/caja-connect-server-dialog-main.c b/src/caja-connect-server-dialog-main.c index 44c57980..c73b0df4 100644 --- a/src/caja-connect-server-dialog-main.c +++ b/src/caja-connect-server-dialog-main.c @@ -171,20 +171,12 @@ main (int argc, char *argv[]) { GtkWidget *dialog; GOptionContext *context; - const char **args; - GFile *location; GError *error; - const GOptionEntry options[] = - { - { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY, &args, NULL, N_("[URI]") }, - { NULL } - }; bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); - args = NULL; error = NULL; /* Translators: This is the --help description for the connect to server app, the initial newlines are between the command line arg and the description */ @@ -208,20 +200,7 @@ main (int argc, char *argv[]) gtk_window_set_default_icon_name (CAJA_ICON_FOLDER); - - /* command line arguments, null terminated array */ - location = NULL; - if (args) - { - location = g_file_new_for_commandline_arg (*args); - } - - dialog = caja_connect_server_dialog_new (NULL, location); - - if (location) - { - g_object_unref (location); - } + dialog = caja_connect_server_dialog_new (NULL); open_dialogs = 0; g_signal_connect (dialog, "destroy", -- cgit v1.2.1 From 2218501731180797c5e29ce677f31fd2b2d3ecea Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Sat, 27 Oct 2012 06:11:08 +0200 Subject: [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 --- src/caja-connect-server-dialog-main.c | 127 ++++++++-------------------------- 1 file changed, 30 insertions(+), 97 deletions(-) (limited to 'src/caja-connect-server-dialog-main.c') 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 + * Cosimo Cecchi */ #include @@ -38,10 +39,9 @@ #include #include -#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); -- cgit v1.2.1