From 938505da180727fbc56b68b80851adc3cf676523 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sun, 4 Sep 2011 14:30:36 -0400 Subject: Let GtkFileChooser track its own last-used-folder. GtkFileChooser in GTK+ 3.2 now keeps track of the last-used-folder itself, even across applications, so get out of its way and let it handle it. --- shell/apps_evolution_shell.schemas.in | 14 ------- shell/e-shell-utils.c | 70 +++++++---------------------------- shell/e-shell.c | 4 -- 3 files changed, 14 insertions(+), 74 deletions(-) (limited to 'shell') diff --git a/shell/apps_evolution_shell.schemas.in b/shell/apps_evolution_shell.schemas.in index 09c376edda..20e7af463d 100644 --- a/shell/apps_evolution_shell.schemas.in +++ b/shell/apps_evolution_shell.schemas.in @@ -58,20 +58,6 @@ - - - - /schemas/apps/evolution/shell/file_chooser_folder - /apps/evolution/shell/file_chooser_folder - evolution - string - - - Initial file chooser folder - Initial folder for GtkFileChooser dialogs. - - - diff --git a/shell/e-shell-utils.c b/shell/e-shell-utils.c index 05722a0319..b5a1f490ae 100644 --- a/shell/e-shell-utils.c +++ b/shell/e-shell-utils.c @@ -65,11 +65,10 @@ e_shell_configure_ui_manager (EShell *shell, * @customize_data: optional data to pass to @customize_func * * Runs a #GtkFileChooserDialog in open mode with the given title and - * returns the selected #GFile. It automatically remembers the selected - * folder. If @customize_func is provided, the function is called just - * prior to running the dialog (the file chooser is the first argument, - * @customize data is the second). If the user cancels the dialog the - * function will return %NULL. + * returns the selected #GFile. If @customize_func is provided, the + * function is called just prior to running the dialog (the file chooser + * is the first argument, @customize data is the second). If the user + * cancels the dialog the function will return %NULL. * * Returns: the #GFile to open, or %NULL **/ @@ -79,19 +78,13 @@ e_shell_run_open_dialog (EShell *shell, GtkCallback customize_func, gpointer customize_data) { - EShellSettings *shell_settings; GtkFileChooser *file_chooser; GFile *chosen_file = NULL; GtkWidget *dialog; GtkWindow *parent; - const gchar *property_name; - gchar *uri; g_return_val_if_fail (E_IS_SHELL (shell), NULL); - property_name = "file-chooser-folder"; - shell_settings = e_shell_get_shell_settings (shell); - parent = e_shell_get_active_window (shell); dialog = gtk_file_chooser_dialog_new ( @@ -107,27 +100,13 @@ e_shell_run_open_dialog (EShell *shell, gtk_file_chooser_set_local_only (file_chooser, FALSE); - /* Restore the current folder from the previous file chooser. */ - uri = e_shell_settings_get_string (shell_settings, property_name); - if (uri != NULL) - gtk_file_chooser_set_current_folder_uri (file_chooser, uri); - g_free (uri); - /* Allow further customizations before running the dialog. */ if (customize_func != NULL) customize_func (dialog, customize_data); - if (gtk_dialog_run (GTK_DIALOG (dialog)) != GTK_RESPONSE_ACCEPT) - goto exit; - - chosen_file = gtk_file_chooser_get_file (file_chooser); - - /* Save the current folder for subsequent file choosers. */ - uri = gtk_file_chooser_get_current_folder_uri (file_chooser); - e_shell_settings_set_string (shell_settings, property_name, uri); - g_free (uri); + if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) + chosen_file = gtk_file_chooser_get_file (file_chooser); -exit: gtk_widget_destroy (dialog); return chosen_file; @@ -143,16 +122,15 @@ exit: * @customize_data: optional data to pass to @customize_func * * Runs a #GtkFileChooserDialog in save mode with the given title and - * returns the selected #GFile. It automatically remembers the selected - * folder. If @customize_func is provided, the function is called just - * prior to running the dialog (the file chooser is the first argument, - * @customize_data is the second). If the user cancels the dialog the - * function will return %NULL. + * returns the selected #GFile. If @customize_func is provided, the + * function is called just prior to running the dialog (the file chooser + * is the first argument, @customize_data is the second). If the user + * cancels the dialog the function will return %NULL. * * With non-%NULL @filters will be added also file filters to the dialog. * The string format is "pat1:mt1;pat2:mt2:...", where 'pat' is a pattern - * and 'mt' is a MIME type for the pattern to be used. - * There can be more than one MIME type, those are separated by comma. + * and 'mt' is a MIME type for the pattern to be used. There can be more + * than one MIME type, those are separated by comma. * * Returns: the #GFile to save to, or %NULL **/ @@ -164,19 +142,13 @@ e_shell_run_save_dialog (EShell *shell, GtkCallback customize_func, gpointer customize_data) { - EShellSettings *shell_settings; GtkFileChooser *file_chooser; GFile *chosen_file = NULL; GtkWidget *dialog; GtkWindow *parent; - const gchar *property_name; - gchar *uri; g_return_val_if_fail (E_IS_SHELL (shell), NULL); - property_name = "file-chooser-folder"; - shell_settings = e_shell_get_shell_settings (shell); - parent = e_shell_get_active_window (shell); dialog = gtk_file_chooser_dialog_new ( @@ -193,12 +165,6 @@ e_shell_run_save_dialog (EShell *shell, gtk_file_chooser_set_local_only (file_chooser, FALSE); gtk_file_chooser_set_do_overwrite_confirmation (file_chooser, TRUE); - /* Restore the current folder from the previous file chooser. */ - uri = e_shell_settings_get_string (shell_settings, property_name); - if (uri != NULL) - gtk_file_chooser_set_current_folder_uri (file_chooser, uri); - g_free (uri); - if (suggestion != NULL) gtk_file_chooser_set_current_name (file_chooser, suggestion); @@ -254,17 +220,9 @@ e_shell_run_save_dialog (EShell *shell, if (customize_func != NULL) customize_func (dialog, customize_data); - if (gtk_dialog_run (GTK_DIALOG (dialog)) != GTK_RESPONSE_ACCEPT) - goto exit; - - chosen_file = gtk_file_chooser_get_file (file_chooser); - - /* Save the current folder for subsequent file choosers. */ - uri = gtk_file_chooser_get_current_folder_uri (file_chooser); - e_shell_settings_set_string (shell_settings, property_name, uri); - g_free (uri); + if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) + chosen_file = gtk_file_chooser_get_file (file_chooser); -exit: gtk_widget_destroy (dialog); return chosen_file; diff --git a/shell/e-shell.c b/shell/e-shell.c index 8aaefd302e..a9c2fdc22f 100644 --- a/shell/e-shell.c +++ b/shell/e-shell.c @@ -1192,10 +1192,6 @@ e_shell_init (EShell *shell) /* XXX Do this after creating the EShellSettings instance, * otherwise the GConf bindings will not get set up. */ - e_shell_settings_install_property_for_key ( - "file-chooser-folder", - "/apps/evolution/shell/file_chooser_folder"); - e_shell_settings_install_property_for_key ( "start-offline", "/apps/evolution/shell/start_offline"); -- cgit v1.2.3