diff options
author | Milan Crha <mcrha@redhat.com> | 2009-11-19 22:40:50 +0800 |
---|---|---|
committer | Milan Crha <mcrha@redhat.com> | 2009-11-19 22:40:50 +0800 |
commit | aa813bd7cadffa0110ddeeecd2b8df9d367db6e1 (patch) | |
tree | 8580dce61f4952b17225fa5262339432db092e4c /modules/mail | |
parent | 72861cffee5a3f9a5434fe0a94c7ec60beec1cc2 (diff) | |
download | gsoc2013-evolution-aa813bd7cadffa0110ddeeecd2b8df9d367db6e1.tar gsoc2013-evolution-aa813bd7cadffa0110ddeeecd2b8df9d367db6e1.tar.gz gsoc2013-evolution-aa813bd7cadffa0110ddeeecd2b8df9d367db6e1.tar.bz2 gsoc2013-evolution-aa813bd7cadffa0110ddeeecd2b8df9d367db6e1.tar.lz gsoc2013-evolution-aa813bd7cadffa0110ddeeecd2b8df9d367db6e1.tar.xz gsoc2013-evolution-aa813bd7cadffa0110ddeeecd2b8df9d367db6e1.tar.zst gsoc2013-evolution-aa813bd7cadffa0110ddeeecd2b8df9d367db6e1.zip |
Bug #579599 - Let the Advanced Search work again
Diffstat (limited to 'modules/mail')
-rw-r--r-- | modules/mail/e-mail-shell-view-actions.c | 68 | ||||
-rw-r--r-- | modules/mail/e-mail-shell-view-actions.h | 2 | ||||
-rw-r--r-- | modules/mail/e-mail-shell-view-private.h | 1 | ||||
-rw-r--r-- | modules/mail/e-mail-shell-view.c | 30 |
4 files changed, 30 insertions, 71 deletions
diff --git a/modules/mail/e-mail-shell-view-actions.c b/modules/mail/e-mail-shell-view-actions.c index 3473d2a727..4dce2de80b 100644 --- a/modules/mail/e-mail-shell-view-actions.c +++ b/modules/mail/e-mail-shell-view-actions.c @@ -648,29 +648,6 @@ action_mail_label_none_cb (GtkAction *action, } static void -action_mail_search_cb (GtkRadioAction *action, - GtkRadioAction *current, - EMailShellView *mail_shell_view) -{ - EShellView *shell_view; - EShellContent *shell_content; - const gchar *search_hint; - - /* XXX Figure out a way to handle this in EShellContent - * instead of every shell view having to handle it. - * The problem is EShellContent does not know what - * the search option actions are for this view. It - * would have to dig up the popup menu and retrieve - * the action for each menu item. Seems messy. */ - - shell_view = E_SHELL_VIEW (mail_shell_view); - shell_content = e_shell_view_get_shell_content (shell_view); - - search_hint = gtk_action_get_label (GTK_ACTION (current)); - e_shell_content_set_search_hint (shell_content, search_hint); -} - -static void action_mail_show_hidden_cb (GtkAction *action, EMailShellView *mail_shell_view) { @@ -963,31 +940,6 @@ action_search_filter_cb (GtkRadioAction *action, } static void -action_search_quick_cb (GtkAction *action, - EMailShellView *mail_shell_view) -{ - EShellView *shell_view; - EShellWindow *shell_window; - EShellContent *shell_content; - EFilterRule *search_rule; - gint value; - - /* Set the search rule in EShellContent so that "Create - * Search Folder from Search" works for quick searches. */ - - 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); - - action = ACTION (MAIL_SEARCH_SUBJECT_OR_ADDRESSES_CONTAIN); - value = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action)); - g_return_if_fail (value >= 0 && value < MAIL_NUM_SEARCH_RULES); - search_rule = mail_shell_view->priv->search_rules[value]; - - e_shell_content_set_search_rule (shell_content, search_rule); -} - -static void action_search_scope_cb (GtkRadioAction *action, GtkRadioAction *current, EShellView *shell_view) @@ -1445,6 +1397,13 @@ static GtkRadioActionEntry mail_filter_entries[] = { static GtkRadioActionEntry mail_search_entries[] = { + { "mail-search-advanced-hidden", + NULL, + N_("Advanced search"), + NULL, + NULL, + MAIL_SEARCH_ADVANCED }, + { "mail-search-body-contains", NULL, N_("Body contains"), @@ -1548,8 +1507,7 @@ e_mail_shell_view_actions_init (EMailShellView *mail_shell_view) gtk_action_group_add_radio_actions ( action_group, mail_search_entries, G_N_ELEMENTS (mail_search_entries), - MAIL_SEARCH_SUBJECT_OR_ADDRESSES_CONTAIN, - G_CALLBACK (action_mail_search_cb), mail_shell_view); + -1, NULL, NULL); gtk_action_group_add_radio_actions ( action_group, mail_scope_entries, G_N_ELEMENTS (mail_scope_entries), @@ -1560,6 +1518,12 @@ e_mail_shell_view_actions_init (EMailShellView *mail_shell_view) e_shell_content_set_scope_action (shell_content, radio_action); e_shell_content_set_scope_visible (shell_content, 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); + /* Bind GObject properties for GConf keys. */ bridge = gconf_bridge_get (); @@ -1622,10 +1586,6 @@ e_mail_shell_view_actions_init (EMailShellView *mail_shell_view) g_signal_connect ( ACTION (GAL_SAVE_CUSTOM_VIEW), "activate", G_CALLBACK (action_gal_save_custom_view_cb), mail_shell_view); - - g_signal_connect ( - ACTION (SEARCH_QUICK), "activate", - G_CALLBACK (action_search_quick_cb), mail_shell_view); } /* Helper for e_mail_shell_view_update_popup_labels() */ diff --git a/modules/mail/e-mail-shell-view-actions.h b/modules/mail/e-mail-shell-view-actions.h index 6ae2e24a95..0ddc29488e 100644 --- a/modules/mail/e-mail-shell-view-actions.h +++ b/modules/mail/e-mail-shell-view-actions.h @@ -159,6 +159,8 @@ E_SHELL_WINDOW_ACTION ((window), "mail-reply-list") #define E_SHELL_WINDOW_ACTION_MAIL_REPLY_SENDER(window) \ E_SHELL_WINDOW_ACTION ((window), "mail-reply-sender") +#define E_SHELL_WINDOW_ACTION_MAIL_SEARCH_ADVANCED_HIDDEN(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-search-advanced-hidden") #define E_SHELL_WINDOW_ACTION_MAIL_SEARCH_FOLDER_FROM_MAILING_LIST(window) \ E_SHELL_WINDOW_ACTION ((window), "mail-search-folder-from-mailing-list") #define E_SHELL_WINDOW_ACTION_MAIL_SEARCH_FOLDER_FROM_RECIPIENTS(window) \ diff --git a/modules/mail/e-mail-shell-view-private.h b/modules/mail/e-mail-shell-view-private.h index 6142b6e9d8..3c9ec88630 100644 --- a/modules/mail/e-mail-shell-view-private.h +++ b/modules/mail/e-mail-shell-view-private.h @@ -108,6 +108,7 @@ enum { /* Search items are displayed in ascending order. */ enum { + MAIL_SEARCH_ADVANCED = -1, MAIL_SEARCH_SUBJECT_OR_ADDRESSES_CONTAIN, MAIL_SEARCH_RECIPIENTS_CONTAIN, MAIL_SEARCH_MESSAGE_CONTAINS, diff --git a/modules/mail/e-mail-shell-view.c b/modules/mail/e-mail-shell-view.c index 1241716340..895bd33903 100644 --- a/modules/mail/e-mail-shell-view.c +++ b/modules/mail/e-mail-shell-view.c @@ -94,7 +94,6 @@ mail_shell_view_execute_search (EShellView *shell_view) EMailShellContent *mail_shell_content; MessageList *message_list; EFilterRule *rule; - EFilterRule *search_rule; EMailReader *reader; CamelFolder *folder; GtkAction *action; @@ -156,20 +155,29 @@ mail_shell_view_execute_search (EShellView *shell_view) model = e_shell_settings_get_object ( shell_settings, "mail-label-list-store"); + 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); - if (text == NULL || *text == '\0') { - query = g_strdup (""); + if (value == MAIL_SEARCH_ADVANCED || text == NULL || *text == '\0') { + query = e_shell_content_get_search_rule_as_string (shell_content); + + if (!query) + query = g_strdup (""); + goto filter; } /* Replace variables in the selected rule with the * current search text and extract a query string. */ - action = ACTION (MAIL_SEARCH_SUBJECT_OR_ADDRESSES_CONTAIN); - value = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action)); 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 + * Search Folder from Search" works for quick searches. */ + e_shell_content_set_search_rule (shell_content, rule); + for (iter = rule->parts; iter != NULL; iter = iter->next) { EFilterPart *part = iter->data; EFilterElement *element = NULL; @@ -337,18 +345,6 @@ filter: break; } - search_rule = e_shell_content_get_search_rule (shell_content); - if (search_rule != NULL) { - string = g_string_sized_new (1024); - e_filter_rule_build_code (search_rule, string); - temp = g_strconcat ("(and", string->str, query, ")", NULL); - - g_free (query); - query = temp; - - g_string_free (string, TRUE); - } - message_list_set_search (message_list, query); e_mail_shell_content_set_search_strings ( |