diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2009-12-19 07:23:48 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2009-12-19 11:38:00 +0800 |
commit | 4cbbdedf522a6ac10df93a128bbf25f67173d66e (patch) | |
tree | fab7bf95e0927e4fa98c58a659e310afff7153ee /modules/mail | |
parent | a1efb837566cdac798cd8777dd34e06e9782cf61 (diff) | |
download | gsoc2013-evolution-4cbbdedf522a6ac10df93a128bbf25f67173d66e.tar gsoc2013-evolution-4cbbdedf522a6ac10df93a128bbf25f67173d66e.tar.gz gsoc2013-evolution-4cbbdedf522a6ac10df93a128bbf25f67173d66e.tar.bz2 gsoc2013-evolution-4cbbdedf522a6ac10df93a128bbf25f67173d66e.tar.lz gsoc2013-evolution-4cbbdedf522a6ac10df93a128bbf25f67173d66e.tar.xz gsoc2013-evolution-4cbbdedf522a6ac10df93a128bbf25f67173d66e.tar.zst gsoc2013-evolution-4cbbdedf522a6ac10df93a128bbf25f67173d66e.zip |
Refactor the EShell search API.
Move the search interface to a new widget: EShellSearchbar
The current search rule is now stored in EShellView, and the search
context in EShellViewClass similar to GalViewCollection (since it's
class-specific, not instance-specific).
Also add a couple new signals to EShellView: "clear-search" and
"custom-search" ("custom" refers to an advanced search or a saved
search -- something more complex than a quick search).
Still working out a few kinks. The search entry is clearly trying to
be too many things. We need a different way of indicating that you're
looking at search results. Perhaps a search results banner similar to
Nautilus.
Diffstat (limited to 'modules/mail')
-rw-r--r-- | modules/mail/e-mail-shell-content.c | 17 | ||||
-rw-r--r-- | modules/mail/e-mail-shell-content.h | 4 | ||||
-rw-r--r-- | modules/mail/e-mail-shell-view-actions.c | 68 | ||||
-rw-r--r-- | modules/mail/e-mail-shell-view-private.c | 14 | ||||
-rw-r--r-- | modules/mail/e-mail-shell-view-private.h | 1 | ||||
-rw-r--r-- | modules/mail/e-mail-shell-view.c | 21 |
6 files changed, 81 insertions, 44 deletions
diff --git a/modules/mail/e-mail-shell-content.c b/modules/mail/e-mail-shell-content.c index f9b0b7da80..a1d8a40d82 100644 --- a/modules/mail/e-mail-shell-content.c +++ b/modules/mail/e-mail-shell-content.c @@ -31,7 +31,6 @@ #include "widgets/menus/gal-view-instance.h" #include "widgets/misc/e-paned.h" -#include "em-search-context.h" #include "em-utils.h" #include "mail-config.h" #include "mail-ops.h" @@ -610,7 +609,6 @@ mail_shell_content_class_init (EMailShellContentClass *class) object_class->constructed = mail_shell_content_constructed; shell_content_class = E_SHELL_CONTENT_CLASS (class); - shell_content_class->new_search_context = em_search_context_new; shell_content_class->check_state = mail_shell_content_check_state; g_object_class_install_property ( @@ -758,6 +756,21 @@ e_mail_shell_content_set_preview_visible (EMailShellContent *mail_shell_content, g_object_notify (G_OBJECT (mail_shell_content), "preview-visible"); } +EShellSearchbar * +e_mail_shell_content_get_searchbar (EMailShellContent *mail_shell_content) +{ + EShellContent *shell_content; + GtkWidget *widget; + + g_return_val_if_fail ( + E_IS_MAIL_SHELL_CONTENT (mail_shell_content), NULL); + + shell_content = E_SHELL_CONTENT (mail_shell_content); + widget = e_shell_content_get_searchbar (shell_content); + + return E_SHELL_SEARCHBAR (widget); +} + gboolean e_mail_shell_content_get_show_deleted (EMailShellContent *mail_shell_content) { diff --git a/modules/mail/e-mail-shell-content.h b/modules/mail/e-mail-shell-content.h index c11323b5f1..69a1fdc397 100644 --- a/modules/mail/e-mail-shell-content.h +++ b/modules/mail/e-mail-shell-content.h @@ -23,6 +23,7 @@ #define E_MAIL_SHELL_CONTENT_H #include <shell/e-shell-content.h> +#include <shell/e-shell-searchbar.h> #include <shell/e-shell-view.h> #include <mail/em-format-html-display.h> @@ -73,6 +74,9 @@ gboolean e_mail_shell_content_get_preview_visible void e_mail_shell_content_set_preview_visible (EMailShellContent *mail_shell_content, gboolean preview_visible); +EShellSearchbar * + e_mail_shell_content_get_searchbar + (EMailShellContent *mail_shell_content); gboolean e_mail_shell_content_get_show_deleted (EMailShellContent *mail_shell_content); void e_mail_shell_content_set_show_deleted diff --git a/modules/mail/e-mail-shell-view-actions.c b/modules/mail/e-mail-shell-view-actions.c index f300ec0c92..103463b586 100644 --- a/modules/mail/e-mail-shell-view-actions.c +++ b/modules/mail/e-mail-shell-view-actions.c @@ -80,9 +80,10 @@ static void action_mail_create_search_folder_cb (GtkAction *action, EMailShellView *mail_shell_view) { + EMailShellContent *mail_shell_content; EMailReader *reader; EShellView *shell_view; - EShellContent *shell_content; + EShellSearchbar *searchbar; EFilterRule *search_rule; EMVFolderRule *vfolder_rule; const gchar *folder_uri; @@ -92,16 +93,17 @@ action_mail_create_search_folder_cb (GtkAction *action, vfolder_load_storage (); shell_view = E_SHELL_VIEW (mail_shell_view); - shell_content = e_shell_view_get_shell_content (shell_view); - search_rule = e_shell_content_get_search_rule (shell_content); - search_text = e_shell_content_get_search_text (shell_content); - + search_rule = e_shell_view_get_search_rule (shell_view); g_return_if_fail (search_rule != NULL); + mail_shell_content = mail_shell_view->priv->mail_shell_content; + searchbar = e_mail_shell_content_get_searchbar (mail_shell_content); + search_text = e_shell_searchbar_get_search_text (searchbar); + if (search_text == NULL || *search_text == '\0') search_text = "''"; - reader = E_MAIL_READER (shell_content); + reader = E_MAIL_READER (mail_shell_content); folder_uri = e_mail_reader_get_folder_uri (reader); search_rule = vfolder_clone_rule (search_rule); @@ -1427,7 +1429,7 @@ static GtkRadioActionEntry mail_search_entries[] = { { "mail-search-advanced-hidden", NULL, - N_("Advanced search"), + N_("Advanced Search"), NULL, NULL, MAIL_SEARCH_ADVANCED }, @@ -1502,11 +1504,13 @@ static GtkRadioActionEntry mail_scope_entries[] = { void e_mail_shell_view_actions_init (EMailShellView *mail_shell_view) { + EMailShellContent *mail_shell_content; EShellView *shell_view; EShellWindow *shell_window; - EShellContent *shell_content; + EShellSearchbar *searchbar; + EActionComboBox *combo_box; GtkActionGroup *action_group; - GtkRadioAction *radio_action; + GtkAction *action; GConfBridge *bridge; GObject *object; const gchar *key; @@ -1515,7 +1519,9 @@ e_mail_shell_view_actions_init (EMailShellView *mail_shell_view) shell_view = E_SHELL_VIEW (mail_shell_view); shell_window = e_shell_view_get_shell_window (shell_view); - shell_content = e_shell_view_get_shell_content (shell_view); + + mail_shell_content = mail_shell_view->priv->mail_shell_content; + searchbar = e_mail_shell_content_get_searchbar (mail_shell_content); /* Mail Actions */ action_group = ACTION_GROUP (MAIL); @@ -1542,15 +1548,19 @@ e_mail_shell_view_actions_init (EMailShellView *mail_shell_view) MAIL_SCOPE_CURRENT_FOLDER, G_CALLBACK (action_search_scope_cb), mail_shell_view); - radio_action = GTK_RADIO_ACTION (ACTION (MAIL_SCOPE_ALL_ACCOUNTS)); - e_shell_content_set_scope_action (shell_content, radio_action); - e_shell_content_set_scope_visible (shell_content, TRUE); + action = ACTION (MAIL_SCOPE_ALL_ACCOUNTS); + combo_box = e_shell_searchbar_get_scope_combo_box (searchbar); + e_action_combo_box_set_action (combo_box, GTK_RADIO_ACTION (action)); + e_shell_searchbar_set_scope_visible (searchbar, TRUE); - /* Advanced Search action */ - radio_action = GTK_RADIO_ACTION (ACTION (MAIL_SEARCH_ADVANCED_HIDDEN)); - e_shell_content_set_search_radio_action (shell_content, radio_action); - gtk_action_set_visible (GTK_ACTION (radio_action), FALSE); - gtk_radio_action_set_current_value (radio_action, MAIL_SEARCH_SUBJECT_OR_ADDRESSES_CONTAIN); + /* Advanced Search Action */ + action = ACTION (MAIL_SEARCH_ADVANCED_HIDDEN); + gtk_action_set_visible (action, FALSE); + e_shell_searchbar_set_search_option ( + searchbar, GTK_RADIO_ACTION (action)); + gtk_radio_action_set_current_value ( + GTK_RADIO_ACTION (action), + MAIL_SEARCH_SUBJECT_OR_ADDRESSES_CONTAIN); /* Bind GObject properties for GConf keys. */ @@ -1588,7 +1598,7 @@ e_mail_shell_view_actions_init (EMailShellView *mail_shell_view) e_mutual_binding_new ( ACTION (MAIL_PREVIEW), "active", - shell_content, "preview-visible"); + mail_shell_content, "preview-visible"); e_binding_new ( ACTION (MAIL_PREVIEW), "active", @@ -1601,7 +1611,7 @@ e_mail_shell_view_actions_init (EMailShellView *mail_shell_view) /* XXX The boolean sense of the GConf key is the inverse of * the menu item, so we have to maintain two properties. */ e_mutual_binding_new_with_negation ( - shell_content, "show-deleted", + mail_shell_content, "show-deleted", ACTION (MAIL_HIDE_DELETED), "active"); /* Keep the sensitivity of "Create Search Folder from Search" @@ -1772,11 +1782,13 @@ e_mail_shell_view_update_popup_labels (EMailShellView *mail_shell_view) void e_mail_shell_view_update_search_filter (EMailShellView *mail_shell_view) { + EMailShellContent *mail_shell_content; EShell *shell; - EShellContent *shell_content; - EShellSettings *shell_settings; - EShellWindow *shell_window; EShellView *shell_view; + EShellWindow *shell_window; + EShellSettings *shell_settings; + EShellSearchbar *searchbar; + EActionComboBox *combo_box; GtkActionGroup *action_group; GtkRadioAction *radio_action; GtkTreeModel *tree_model; @@ -1789,7 +1801,6 @@ e_mail_shell_view_update_search_filter (EMailShellView *mail_shell_view) g_return_if_fail (E_IS_MAIL_SHELL_VIEW (mail_shell_view)); shell_view = E_SHELL_VIEW (mail_shell_view); - shell_content = e_shell_view_get_shell_content (shell_view); shell_window = e_shell_view_get_shell_window (shell_view); shell = e_shell_window_get_shell (shell_window); @@ -1849,13 +1860,16 @@ e_mail_shell_view_update_search_filter (EMailShellView *mail_shell_view) } /* Use any action in the group; doesn't matter which. */ - e_shell_content_set_filter_action (shell_content, radio_action); + mail_shell_content = mail_shell_view->priv->mail_shell_content; + searchbar = e_mail_shell_content_get_searchbar (mail_shell_content); + combo_box = e_shell_searchbar_get_filter_combo_box (searchbar); + e_action_combo_box_set_action (combo_box, radio_action); ii = MAIL_FILTER_UNREAD_MESSAGES; - e_shell_content_add_filter_separator_after (shell_content, ii); + e_action_combo_box_add_separator_after (combo_box, ii); ii = MAIL_FILTER_READ_MESSAGES; - e_shell_content_add_filter_separator_before (shell_content, ii); + e_action_combo_box_add_separator_after (combo_box, ii); g_object_unref (tree_model); } diff --git a/modules/mail/e-mail-shell-view-private.c b/modules/mail/e-mail-shell-view-private.c index c152b84817..f1e9805752 100644 --- a/modules/mail/e-mail-shell-view-private.c +++ b/modules/mail/e-mail-shell-view-private.c @@ -646,7 +646,7 @@ e_mail_shell_view_private_constructed (EMailShellView *mail_shell_view) /* Populate built-in rules for search entry popup menu. * Keep the assertions, please. If the conditions aren't * met we're going to crash anyway, just more mysteriously. */ - context = e_shell_content_get_search_context (shell_content); + context = E_SHELL_VIEW_GET_CLASS (shell_view)->search_context; source = E_FILTER_SOURCE_DEMAND; while ((rule = e_rule_context_next_rule (context, rule, source))) { g_assert (ii < MAIL_NUM_SEARCH_RULES); @@ -696,8 +696,8 @@ e_mail_shell_view_private_finalize (EMailShellView *mail_shell_view) void e_mail_shell_view_restore_state (EMailShellView *mail_shell_view) { - EShellView *shell_view; - EShellContent *shell_content; + EMailShellContent *mail_shell_content; + EShellSearchbar *searchbar; EMailReader *reader; const gchar *folder_uri; gchar *group_name; @@ -706,17 +706,17 @@ e_mail_shell_view_restore_state (EMailShellView *mail_shell_view) g_return_if_fail (E_IS_MAIL_SHELL_VIEW (mail_shell_view)); - shell_view = E_SHELL_VIEW (mail_shell_view); - shell_content = e_shell_view_get_shell_content (shell_view); + mail_shell_content = mail_shell_view->priv->mail_shell_content; + searchbar = e_mail_shell_content_get_searchbar (mail_shell_content); - reader = E_MAIL_READER (shell_content); + reader = E_MAIL_READER (mail_shell_content); folder_uri = e_mail_reader_get_folder_uri (reader); if (folder_uri == NULL) return; group_name = g_strdup_printf ("Folder %s", folder_uri); - e_shell_content_restore_state (shell_content, group_name); + e_shell_searchbar_restore_state (searchbar, group_name); g_free (group_name); } diff --git a/modules/mail/e-mail-shell-view-private.h b/modules/mail/e-mail-shell-view-private.h index bd99da5a1e..44a02eddbd 100644 --- a/modules/mail/e-mail-shell-view-private.h +++ b/modules/mail/e-mail-shell-view-private.h @@ -51,6 +51,7 @@ #include "em-folder-properties.h" #include "em-folder-selector.h" #include "em-folder-utils.h" +#include "em-search-context.h" #include "em-subscribe-editor.h" #include "em-utils.h" #include "mail-autofilter.h" diff --git a/modules/mail/e-mail-shell-view.c b/modules/mail/e-mail-shell-view.c index 7e1d00393d..de81e131c5 100644 --- a/modules/mail/e-mail-shell-view.c +++ b/modules/mail/e-mail-shell-view.c @@ -87,12 +87,14 @@ static void mail_shell_view_execute_search (EShellView *shell_view) { EMailShellViewPrivate *priv; + EMailShellContent *mail_shell_content; EShell *shell; EShellWindow *shell_window; EShellContent *shell_content; EShellSettings *shell_settings; + EShellSearchbar *searchbar; + EActionComboBox *combo_box; EMFormatHTMLDisplay *html_display; - EMailShellContent *mail_shell_content; GtkWidget *message_list; EFilterRule *rule; EMailReader *reader; @@ -121,6 +123,7 @@ mail_shell_view_execute_search (EShellView *shell_view) shell_settings = e_shell_get_shell_settings (shell); mail_shell_content = E_MAIL_SHELL_CONTENT (shell_content); + searchbar = e_mail_shell_content_get_searchbar (mail_shell_content); reader = E_MAIL_READER (shell_content); folder = e_mail_reader_get_folder (reader); @@ -137,7 +140,7 @@ mail_shell_view_execute_search (EShellView *shell_view) key_file = e_shell_view_get_state_key_file (shell_view); key = STATE_KEY_SEARCH_TEXT; - string = e_shell_content_get_search_text (shell_content); + string = e_shell_searchbar_get_search_text (searchbar); group_name = g_strdup_printf ("Folder %s", folder_uri); if (string != NULL && *string != '\0') @@ -158,12 +161,12 @@ mail_shell_view_execute_search (EShellView *shell_view) action = ACTION (MAIL_SEARCH_SUBJECT_OR_ADDRESSES_CONTAIN); value = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action)); - text = e_shell_content_get_search_text (shell_content); + text = e_shell_searchbar_get_search_text (searchbar); if (value == MAIL_SEARCH_ADVANCED || text == NULL || *text == '\0') { if (value != MAIL_SEARCH_ADVANCED) - e_shell_content_set_search_rule (shell_content, NULL); + e_shell_view_set_search_rule (shell_view, NULL); - query = e_shell_content_get_search_rule_as_string (shell_content); + query = e_shell_view_get_search_query (shell_view); if (!query) query = g_strdup (""); @@ -177,9 +180,9 @@ mail_shell_view_execute_search (EShellView *shell_view) g_return_if_fail (value >= 0 && value < MAIL_NUM_SEARCH_RULES); rule = priv->search_rules[value]; - /* Set the search rule in EShellContent so that "Create + /* Set the search rule in EShellView so that "Create * Search Folder from Search" works for quick searches. */ - e_shell_content_set_search_rule (shell_content, rule); + e_shell_view_set_search_rule (shell_view, rule); for (iter = rule->parts; iter != NULL; iter = iter->next) { EFilterPart *part = iter->data; @@ -220,7 +223,8 @@ filter: /* Apply selected filter. */ - value = e_shell_content_get_filter_value (shell_content); + combo_box = e_shell_searchbar_get_filter_combo_box (searchbar); + value = e_action_combo_box_get_current_value (combo_box); switch (value) { case MAIL_FILTER_ALL_MESSAGES: break; @@ -593,6 +597,7 @@ mail_shell_view_class_init (EMailShellViewClass *class, shell_view_class->icon_name = "evolution-mail"; shell_view_class->ui_definition = "evolution-mail.ui"; shell_view_class->ui_manager_id = "org.gnome.evolution.mail"; + shell_view_class->search_context_type = EM_SEARCH_TYPE_CONTEXT; shell_view_class->search_options = "/mail-search-options"; shell_view_class->search_rules = "searchtypes.xml"; shell_view_class->new_shell_content = e_mail_shell_content_new; |