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. --- addressbook/gui/contact-editor/e-contact-editor.c | 4 - composer/e-composer-actions.c | 3 +- composer/e-composer-private.h | 2 - composer/e-msg-composer.c | 6 -- doc/reference/shell/eshell-sections.txt | 3 - doc/reference/shell/tmpl/e-attachment-store.sgml | 28 ----- doc/reference/shell/tmpl/eshell-unused.sgml | 25 +++++ mail/evolution-mail.schemas.in | 14 --- shell/apps_evolution_shell.schemas.in | 14 --- shell/e-shell-utils.c | 70 +++--------- shell/e-shell.c | 4 - widgets/misc/e-attachment-store.c | 123 +--------------------- widgets/misc/e-attachment-store.h | 8 -- 13 files changed, 42 insertions(+), 262 deletions(-) diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c index aa0328e9ce..e2dc21c25c 100644 --- a/addressbook/gui/contact-editor/e-contact-editor.c +++ b/addressbook/gui/contact-editor/e-contact-editor.c @@ -3418,10 +3418,6 @@ image_clicked (GtkWidget *button, GTK_DIALOG (editor->file_selector), GTK_RESPONSE_ACCEPT); - gtk_file_chooser_set_current_folder ( - GTK_FILE_CHOOSER (editor->file_selector), - g_get_home_dir ()); - g_signal_connect ( editor->file_selector, "response", G_CALLBACK (file_chooser_response), editor); diff --git a/composer/e-composer-actions.c b/composer/e-composer-actions.c index 163270f24d..cd50f7a39b 100644 --- a/composer/e-composer-actions.c +++ b/composer/e-composer-actions.c @@ -218,8 +218,7 @@ action_save_as_cb (GtkAction *action, gtk_window_set_icon_name ( GTK_WINDOW (dialog), "mail-message-new"); - response = gtkhtml_editor_file_chooser_dialog_run ( - GTKHTML_EDITOR (composer), dialog); + response = gtk_dialog_run (GTK_DIALOG (dialog)); if (response != GTK_RESPONSE_OK) goto exit; diff --git a/composer/e-composer-private.h b/composer/e-composer-private.h index 35eb26696b..69e3169de3 100644 --- a/composer/e-composer-private.h +++ b/composer/e-composer-private.h @@ -73,8 +73,6 @@ MAIL_GCONF_PREFIX "/composer" #define COMPOSER_GCONF_CHARSET_KEY \ COMPOSER_GCONF_PREFIX "/charset" -#define COMPOSER_GCONF_CURRENT_FOLDER_KEY \ - COMPOSER_GCONF_PREFIX "/current_folder" #define COMPOSER_GCONF_INLINE_SPELLING_KEY \ COMPOSER_GCONF_PREFIX "/inline_spelling" #define COMPOSER_GCONF_MAGIC_LINKS_KEY \ diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c index 7790cbb2ea..82541d6aa7 100644 --- a/composer/e-msg-composer.c +++ b/composer/e-msg-composer.c @@ -2114,12 +2114,6 @@ msg_composer_constructed (GObject *object) array = composer->priv->gconf_bridge_binding_ids; - binding_id = gconf_bridge_bind_property ( - gconf_bridge_get (), - COMPOSER_GCONF_CURRENT_FOLDER_KEY, - G_OBJECT (composer), "current-folder"); - g_array_append_val (array, binding_id); - binding_id = gconf_bridge_bind_window ( gconf_bridge_get (), COMPOSER_GCONF_WINDOW_PREFIX, diff --git a/doc/reference/shell/eshell-sections.txt b/doc/reference/shell/eshell-sections.txt index 1f0ecdbc0c..765bb28f8a 100644 --- a/doc/reference/shell/eshell-sections.txt +++ b/doc/reference/shell/eshell-sections.txt @@ -694,12 +694,9 @@ e_attachment_store_add_attachment e_attachment_store_remove_attachment e_attachment_store_add_to_multipart e_attachment_store_get_attachments -e_attachment_store_get_current_folder_uri -e_attachment_store_set_current_folder_uri e_attachment_store_get_num_attachments e_attachment_store_get_num_loading e_attachment_store_get_total_size -e_attachment_store_run_file_chooser_dialog e_attachment_store_run_load_dialog e_attachment_store_run_save_dialog e_attachment_store_get_uris_async diff --git a/doc/reference/shell/tmpl/e-attachment-store.sgml b/doc/reference/shell/tmpl/e-attachment-store.sgml index 34884eacc5..e7d64e85b9 100644 --- a/doc/reference/shell/tmpl/e-attachment-store.sgml +++ b/doc/reference/shell/tmpl/e-attachment-store.sgml @@ -75,24 +75,6 @@ e-attachment-store @Returns: - - - - - -@store: -@Returns: - - - - - - - -@store: -@current_folder: - - @@ -120,16 +102,6 @@ e-attachment-store @Returns: - - - - - -@store: -@dialog: -@Returns: - - diff --git a/doc/reference/shell/tmpl/eshell-unused.sgml b/doc/reference/shell/tmpl/eshell-unused.sgml index 5b67b87993..d8f54f7867 100644 --- a/doc/reference/shell/tmpl/eshell-unused.sgml +++ b/doc/reference/shell/tmpl/eshell-unused.sgml @@ -515,6 +515,23 @@ e-shell-window.sgml @store: @Returns: + + + + + +@store: +@Returns: + + + + + + +@store: +@dialog: +@Returns: + @@ -523,6 +540,14 @@ e-shell-window.sgml @store: @current_folder: + + + + + +@store: +@current_folder: + diff --git a/mail/evolution-mail.schemas.in b/mail/evolution-mail.schemas.in index 82be1319c8..c26c0feb96 100644 --- a/mail/evolution-mail.schemas.in +++ b/mail/evolution-mail.schemas.in @@ -1588,20 +1588,6 @@ - - /schemas/apps/evolution/mail/composer/current_folder - /apps/evolution/mail/composer/current_folder - evolution-mail - string - - - Composer load/attach directory - - Directory for loading/attaching files to composer. - - - - 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"); diff --git a/widgets/misc/e-attachment-store.c b/widgets/misc/e-attachment-store.c index 691fd518b8..2670369a51 100644 --- a/widgets/misc/e-attachment-store.c +++ b/widgets/misc/e-attachment-store.c @@ -34,14 +34,12 @@ struct _EAttachmentStorePrivate { GHashTable *attachment_index; - gchar *current_folder_uri; guint ignore_row_changed : 1; }; enum { PROP_0, - PROP_CURRENT_FOLDER_URI, PROP_NUM_ATTACHMENTS, PROP_NUM_LOADING, PROP_TOTAL_SIZE @@ -52,23 +50,6 @@ G_DEFINE_TYPE ( e_attachment_store, GTK_TYPE_LIST_STORE) -static void -attachment_store_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - switch (property_id) { - case PROP_CURRENT_FOLDER_URI: - e_attachment_store_set_current_folder_uri ( - E_ATTACHMENT_STORE (object), - g_value_get_string (value)); - return; - } - - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); -} - static void attachment_store_get_property (GObject *object, guint property_id, @@ -76,13 +57,6 @@ attachment_store_get_property (GObject *object, GParamSpec *pspec) { switch (property_id) { - case PROP_CURRENT_FOLDER_URI: - g_value_set_string ( - value, - e_attachment_store_get_current_folder_uri ( - E_ATTACHMENT_STORE (object))); - return; - case PROP_NUM_ATTACHMENTS: g_value_set_uint ( value, @@ -126,27 +100,10 @@ attachment_store_finalize (GObject *object) g_hash_table_destroy (priv->attachment_index); - g_free (priv->current_folder_uri); - /* Chain up to parent's finalize() method. */ G_OBJECT_CLASS (e_attachment_store_parent_class)->finalize (object); } -static void -attachment_store_constructed (GObject *object) -{ - GConfBridge *bridge; - const gchar *key; - - bridge = gconf_bridge_get (); - - key = "/apps/evolution/shell/file_chooser_folder"; - gconf_bridge_bind_property (bridge, key, object, "current-folder-uri"); - - /* Chain up to parent's constructed() method. */ - G_OBJECT_CLASS (e_attachment_store_parent_class)->constructed (object); -} - static void e_attachment_store_class_init (EAttachmentStoreClass *class) { @@ -155,22 +112,9 @@ e_attachment_store_class_init (EAttachmentStoreClass *class) g_type_class_add_private (class, sizeof (EAttachmentStorePrivate)); object_class = G_OBJECT_CLASS (class); - object_class->set_property = attachment_store_set_property; object_class->get_property = attachment_store_get_property; object_class->dispose = attachment_store_dispose; object_class->finalize = attachment_store_finalize; - object_class->constructed = attachment_store_constructed; - - g_object_class_install_property ( - object_class, - PROP_CURRENT_FOLDER_URI, - g_param_spec_string ( - "current-folder-uri", - "Current Folder URI", - NULL, - NULL, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT)); g_object_class_install_property ( object_class, @@ -409,34 +353,6 @@ e_attachment_store_get_attachments (EAttachmentStore *store) return g_list_reverse (list); } -const gchar * -e_attachment_store_get_current_folder_uri (EAttachmentStore *store) -{ - g_return_val_if_fail (E_IS_ATTACHMENT_STORE (store), NULL); - - return store->priv->current_folder_uri; -} - -void -e_attachment_store_set_current_folder_uri (EAttachmentStore *store, - const gchar *current_folder_uri) -{ - gchar *allocated; - - g_return_if_fail (E_IS_ATTACHMENT_STORE (store)); - - if (current_folder_uri == NULL) { - const gchar *home_dir = g_get_home_dir (); - allocated = g_filename_to_uri (home_dir, NULL, NULL); - } else - allocated = g_strdup (current_folder_uri); - - g_free (store->priv->current_folder_uri); - store->priv->current_folder_uri = allocated; - - g_object_notify (G_OBJECT (store), "current-folder-uri"); -} - guint e_attachment_store_get_num_attachments (EAttachmentStore *store) { @@ -493,41 +409,6 @@ e_attachment_store_get_total_size (EAttachmentStore *store) return total_size; } -gint -e_attachment_store_run_file_chooser_dialog (EAttachmentStore *store, - GtkWidget *dialog) -{ - GtkFileChooser *file_chooser; - gint response = GTK_RESPONSE_NONE; - const gchar *current_uri; - gboolean update_folder; - - g_return_val_if_fail (E_IS_ATTACHMENT_STORE (store), response); - g_return_val_if_fail (GTK_IS_FILE_CHOOSER_DIALOG (dialog), response); - - file_chooser = GTK_FILE_CHOOSER (dialog); - current_uri = e_attachment_store_get_current_folder_uri (store); - gtk_file_chooser_set_current_folder_uri (file_chooser, current_uri); - - response = gtk_dialog_run (GTK_DIALOG (dialog)); - - update_folder = - (response == GTK_RESPONSE_ACCEPT) || - (response == GTK_RESPONSE_OK) || - (response == GTK_RESPONSE_YES) || - (response == GTK_RESPONSE_APPLY); - - if (update_folder) { - gchar *uri; - - uri = gtk_file_chooser_get_current_folder_uri (file_chooser); - e_attachment_store_set_current_folder_uri (store, uri); - g_free (uri); - } - - return response; -} - void e_attachment_store_run_load_dialog (EAttachmentStore *store, GtkWindow *parent) @@ -560,7 +441,7 @@ e_attachment_store_run_load_dialog (EAttachmentStore *store, gtk_file_chooser_set_extra_widget (file_chooser, option); gtk_widget_show (option); - response = e_attachment_store_run_file_chooser_dialog (store, dialog); + response = gtk_dialog_run (GTK_DIALOG (dialog)); if (response != GTK_RESPONSE_OK) goto exit; @@ -643,7 +524,7 @@ e_attachment_store_run_save_dialog (EAttachmentStore *store, gtk_file_chooser_set_current_name (file_chooser, name); } - response = e_attachment_store_run_file_chooser_dialog (store, dialog); + response = gtk_dialog_run (GTK_DIALOG (dialog)); if (response == GTK_RESPONSE_OK) destination = gtk_file_chooser_get_file (file_chooser); diff --git a/widgets/misc/e-attachment-store.h b/widgets/misc/e-attachment-store.h index cdf33f507a..7309dd9415 100644 --- a/widgets/misc/e-attachment-store.h +++ b/widgets/misc/e-attachment-store.h @@ -87,20 +87,12 @@ void e_attachment_store_add_to_multipart const gchar *default_charset); GList * e_attachment_store_get_attachments (EAttachmentStore *store); -const gchar * e_attachment_store_get_current_folder_uri - (EAttachmentStore *store); -void e_attachment_store_set_current_folder_uri - (EAttachmentStore *store, - const gchar *current_folder); guint e_attachment_store_get_num_attachments (EAttachmentStore *store); guint e_attachment_store_get_num_loading (EAttachmentStore *store); goffset e_attachment_store_get_total_size (EAttachmentStore *store); -gint e_attachment_store_run_file_chooser_dialog - (EAttachmentStore *store, - GtkWidget *dialog); void e_attachment_store_run_load_dialog (EAttachmentStore *store, GtkWindow *parent); -- cgit