diff options
-rw-r--r-- | mail/searchtypes.xml | 142 | ||||
-rw-r--r-- | modules/mail/e-mail-shell-view-actions.c | 73 |
2 files changed, 138 insertions, 77 deletions
diff --git a/mail/searchtypes.xml b/mail/searchtypes.xml index f3a89603ed..e7e82edce0 100644 --- a/mail/searchtypes.xml +++ b/mail/searchtypes.xml @@ -6,7 +6,7 @@ <input type="optionlist" name="sender-type"> <option value="contains"> <title>contains</title> - <code>(match-all (header-contains "From" ${sender}))</code> + <code>(match-all (header-contains "From" ${sender}))</code> </option> <option value="not contains"> <title>does not contain</title> @@ -14,7 +14,7 @@ </option> <option value="is"> <title>is</title> - <code>(match-all (header-matches "From" ${sender}))</code> + <code>(match-all (header-matches "From" ${sender}))</code> </option> <option value="is not"> <title>is not</title> @@ -54,38 +54,38 @@ <option value="contains"> <title>contains</title> <code> - (match-all (or (header-contains "To" ${recipient}) - (header-contains "Cc" ${recipient}))) + (match-all (or (header-contains "To" ${recipient}) + (header-contains "Cc" ${recipient}))) </code> </option> <option value="not contains"> <title>does not contain</title> <code> - (match-all (not (or + (match-all (not (or (header-contains "To" ${recipient}) - (header-contains "Cc" ${recipient})))) + (header-contains "Cc" ${recipient})))) </code> </option> <option value="is"> <title>is</title> <code> - (match-all (or (header-matches "To" ${recipient}) - (header-matches "Cc" ${recipient}))) + (match-all (or (header-matches "To" ${recipient}) + (header-matches "Cc" ${recipient}))) </code> </option> <option value="is not"> <title>is not</title> <code> - (match-all (not (or + (match-all (not (or (header-matches "To" ${recipient}) - (header-matches "Cc" ${recipient})))) + (header-matches "Cc" ${recipient})))) </code> </option> <option value="starts with"> <title>starts with</title> <code> (match-all (or (header-starts-with "To" ${recipient}) - (header-starts-with "Cc" ${recipient}))) + (header-starts-with "Cc" ${recipient}))) </code> </option> <option value="not starts with"> @@ -93,14 +93,14 @@ <code> (match-all (not (or (header-starts-with "To" ${recipient}) - (header-starts-with "Cc" ${recipient})))) + (header-starts-with "Cc" ${recipient})))) </code> </option> <option value="ends with"> <title>ends with</title> <code> (match-all (or (header-ends-with "To" ${recipient}) - (header-ends-with "Cc" ${recipient}))) + (header-ends-with "Cc" ${recipient}))) </code> </option> <option value="not ends with"> @@ -108,7 +108,7 @@ <code> (match-all (not (or (header-ends-with "To" ${recipient}) - (header-ends-with "Cc" ${recipient})))) + (header-ends-with "Cc" ${recipient})))) </code> </option> </input> @@ -121,25 +121,25 @@ <option value="contains"> <title>contains</title> <code> - (match-all (header-contains "Cc" ${recipient})) + (match-all (header-contains "Cc" ${recipient})) </code> </option> <option value="not contains"> <title>does not contain</title> <code> - (match-all (not (header-contains "Cc" ${recipient}))) + (match-all (not (header-contains "Cc" ${recipient}))) </code> </option> <option value="is"> <title>is</title> <code> - (match-all (header-matches "Cc" ${recipient})) + (match-all (header-matches "Cc" ${recipient})) </code> </option> <option value="is not"> <title>is not</title> <code> - (match-all (not (header-matches "Cc" ${recipient}))) + (match-all (not (header-matches "Cc" ${recipient}))) </code> </option> <option value="starts with"> @@ -169,13 +169,13 @@ <option value="matches soundex"> <title>sounds like</title> <code> - (match-all (header-soundex "Cc" ${recipient})) + (match-all (header-soundex "Cc" ${recipient})) </code> </option> <option value="not match soundex"> <title>does not sound like</title> <code> - (match-all (not (header-soundex "Cc" ${recipient}))) + (match-all (not (header-soundex "Cc" ${recipient}))) </code> </option> </input> @@ -188,25 +188,25 @@ <option value="contains"> <title>contains</title> <code> - (match-all (header-contains "Bcc" ${recipient})) + (match-all (header-contains "Bcc" ${recipient})) </code> </option> <option value="not contains"> <title>does not contain</title> <code> - (match-all (not (header-contains "Bcc" ${recipient}))) + (match-all (not (header-contains "Bcc" ${recipient}))) </code> </option> <option value="is"> <title>is</title> <code> - (match-all (header-matches "Bcc" ${recipient})) + (match-all (header-matches "Bcc" ${recipient})) </code> </option> <option value="is not"> <title>is not</title> <code> - (match-all (not (header-matches "Bcc" ${recipient}))) + (match-all (not (header-matches "Bcc" ${recipient}))) </code> </option> <option value="starts with"> @@ -236,13 +236,13 @@ <option value="matches soundex"> <title>sounds like</title> <code> - (match-all (header-soundex "Bcc" ${recipient})) + (match-all (header-soundex "Bcc" ${recipient})) </code> </option> <option value="not match soundex"> <title>does not sound like</title> <code> - (match-all (not (header-soundex "Bcc" ${recipient}))) + (match-all (not (header-soundex "Bcc" ${recipient}))) </code> </option> </input> @@ -255,48 +255,48 @@ <option value="contains"> <title>contains</title> <code> - (match-all (or (header-contains "From" ${recipient}) - (header-contains "To" ${recipient}) - (header-contains "Cc" ${recipient}) - (header-contains "Bcc" ${recipient}))) + (match-all (or (header-contains "From" ${recipient}) + (header-contains "To" ${recipient}) + (header-contains "Cc" ${recipient}) + (header-contains "Bcc" ${recipient}))) </code> </option> <option value="not contains"> <title>does not contain</title> <code> - (match-all (not (or + (match-all (not (or (header-contains "From" ${recipient}) (header-contains "To" ${recipient}) (header-contains "Cc" ${recipient}) - (header-contains "Bcc" ${recipient})))) + (header-contains "Bcc" ${recipient})))) </code> </option> <option value="is"> <title>is</title> <code> - (match-all (or (header-matches "From" ${recipient}) - (header-matches "To" ${recipient}) - (header-matches "Cc" ${recipient}) - (header-matches "Bcc" ${recipient}))) + (match-all (or (header-matches "From" ${recipient}) + (header-matches "To" ${recipient}) + (header-matches "Cc" ${recipient}) + (header-matches "Bcc" ${recipient}))) </code> </option> <option value="is not"> <title>is not</title> <code> - (match-all (not (or + (match-all (not (or (header-matches "From" ${recipient}) (header-matches "To" ${recipient}) (header-matches "Cc" ${recipient}) - (header-matches "Bcc" ${recipient})))) + (header-matches "Bcc" ${recipient})))) </code> </option> <option value="starts with"> <title>starts with</title> <code> (match-all (or (header-starts-with "From" ${recipient}) - (header-starts-with "To" ${recipient}) - (header-starts-with "Cc" ${recipient}) - (header-starts-with "Bcc" ${recipient}))) + (header-starts-with "To" ${recipient}) + (header-starts-with "Cc" ${recipient}) + (header-starts-with "Bcc" ${recipient}))) </code> </option> <option value="not starts with"> @@ -306,16 +306,16 @@ (header-starts-with "From" ${recipient}) (header-starts-with "To" ${recipient}) (header-starts-with "Cc" ${recipient}) - (header-starts-with "Bcc" ${recipient})))) + (header-starts-with "Bcc" ${recipient})))) </code> </option> <option value="ends with"> <title>ends with</title> <code> (match-all (or (header-ends-with "From" ${recipient}) - (header-ends-with "To" ${recipient}) - (header-ends-with "Cc" ${recipient}) - (header-ends-with "Bcc" ${recipient}))) + (header-ends-with "To" ${recipient}) + (header-ends-with "Cc" ${recipient}) + (header-ends-with "Bcc" ${recipient}))) </code> </option> <option value="not ends with"> @@ -325,7 +325,7 @@ (header-ends-with "From" ${recipient}) (header-ends-with "To" ${recipient}) (header-ends-with "Cc" ${recipient}) - (header-ends-with "Bcc" ${recipient})))) + (header-ends-with "Bcc" ${recipient})))) </code> </option> </input> @@ -338,49 +338,49 @@ <option value="contains"> <title>contains</title> <code> - (match-all (header-contains "Subject" ${subject})) + (match-all (header-contains "Subject" ${subject})) </code> </option> <option value="not contains"> <title>does not contain</title> <code> - (match-all (not (header-contains "Subject" ${subject}))) + (match-all (not (header-contains "Subject" ${subject}))) </code> </option> <option value="is"> <title>is</title> <code> - (match-all (header-matches "Subject" ${subject})) + (match-all (header-matches "Subject" ${subject})) </code> </option> <option value="is not"> <title>is not</title> <code> - (match-all (not (header-matches "Subject" ${subject}))) + (match-all (not (header-matches "Subject" ${subject}))) </code> </option> <option value="starts with"> <title>starts with</title> <code> - (match-all (header-starts-with "Subject" ${subject})) + (match-all (header-starts-with "Subject" ${subject})) </code> </option> <option value="not starts with"> <title>does not start with</title> <code> - (match-all (not (header-starts-with "Subject" ${subject}))) + (match-all (not (header-starts-with "Subject" ${subject}))) </code> </option> <option value="ends with"> <title>ends with</title> <code> - (match-all (header-ends-with "Subject" ${subject})) + (match-all (header-ends-with "Subject" ${subject})) </code> </option> <option value="not ends with"> <title>does not end with</title> <code> - (match-all (not (header-ends-with "Subject" ${subject}))) + (match-all (not (header-ends-with "Subject" ${subject}))) </code> </option> </input> @@ -394,61 +394,61 @@ <option value="contains"> <title>contains</title> <code> - (match-all (header-contains ${header-field} ${word})) + (match-all (header-contains ${header-field} ${word})) </code> </option> <option value="not contains"> <title>does not contain</title> <code> - (match-all (not (header-contains ${header-field} ${word}))) + (match-all (not (header-contains ${header-field} ${word}))) </code> </option> <option value="is"> <title>is</title> <code> - (match-all (header-matches ${header-field} ${word})) + (match-all (header-matches ${header-field} ${word})) </code> </option> <option value="is not"> <title>is not</title> <code> - (match-all (not (header-matches ${header-field} ${word}))) + (match-all (not (header-matches ${header-field} ${word}))) </code> </option> <option value="starts with"> <title>starts with</title> <code> - (match-all (header-starts-with ${header-field} ${word})) + (match-all (header-starts-with ${header-field} ${word})) </code> </option> <option value="not starts with"> <title>does not start with</title> <code> - (match-all (not (header-starts-with ${header-field} ${word}))) + (match-all (not (header-starts-with ${header-field} ${word}))) </code> </option> <option value="ends with"> <title>ends with</title> <code> - (match-all (header-ends-with ${header-field} ${word})) + (match-all (header-ends-with ${header-field} ${word})) </code> </option> <option value="not ends with"> <title>does not end with</title> <code> - (match-all (not (header-ends-with ${header-field} ${word}))) + (match-all (not (header-ends-with ${header-field} ${word}))) </code> </option> <option value="exists"> <title>exists</title> <code> - (match-all (header-exists ${header-field})) + (match-all (header-exists ${header-field})) </code> </option> <option value="not exists"> <title>does not exist</title> <code> - (match-all (not (header-exists ${header-field}))) + (match-all (not (header-exists ${header-field}))) </code> </option> <option value="matches soundex"> @@ -473,13 +473,13 @@ <option value="contains"> <title>contains</title> <code> - (body-contains ${word}) + (body-contains ${word}) </code> </option> <option value="not contains"> <title>does not contain</title> <code> - (not (body-contains ${word})) + (not (body-contains ${word})) </code> </option> </input> @@ -770,19 +770,11 @@ <part name="subject"> <value name="subject-type" type="option" value="contains"/> <value name="subject" type="string"/> - </part> + </part> <part name="sender"> <value name="sender-type" type="option" value="contains"/> <value name="sender" type="string"/> </part> - <part name="to"> - <value name="recipient-type" type="option" value="contains"/> - <value name="recipient" type="address"/> - </part> - <part name="to"> - <value name="recipient-type" type="option" value="contains"/> - <value name="recipient" type="address"/> - </part> <part name="to"> <value name="recipient-type" type="option" value="contains"/> <value name="recipient" type="address"/> diff --git a/modules/mail/e-mail-shell-view-actions.c b/modules/mail/e-mail-shell-view-actions.c index cfa8599bb3..ca82272fee 100644 --- a/modules/mail/e-mail-shell-view-actions.c +++ b/modules/mail/e-mail-shell-view-actions.c @@ -80,8 +80,41 @@ static void action_mail_create_search_folder_cb (GtkAction *action, EMailShellView *mail_shell_view) { - /* FIXME */ - g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action))); + EMailReader *reader; + EShellView *shell_view; + EShellContent *shell_content; + MessageList *message_list; + FilterRule *search_rule; + EMVFolderRule *vfolder_rule; + const gchar *folder_uri; + const gchar *search_text; + gchar *rule_name; + + 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); + + g_return_if_fail (search_rule != NULL); + + if (search_text == NULL || *search_text == '\0') + search_text = "''"; + + reader = E_MAIL_READER (shell_content); + message_list = e_mail_reader_get_message_list (reader); + folder_uri = message_list->folder_uri; + + search_rule = vfolder_clone_rule (search_rule); + rule_name = g_strdup_printf ("%s %s", search_rule->name, search_text); + filter_rule_set_source (search_rule, FILTER_SOURCE_INCOMING); + filter_rule_set_name (search_rule, rule_name); + g_free (rule_name); + + vfolder_rule = EM_VFOLDER_RULE (search_rule); + em_vfolder_rule_add_source (vfolder_rule, folder_uri); + vfolder_gui_add_rule (vfolder_rule); } static void @@ -933,6 +966,31 @@ 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; + FilterRule *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) @@ -1550,9 +1608,20 @@ e_mail_shell_view_actions_init (EMailShellView *mail_shell_view) shell_content, "show-deleted", ACTION (MAIL_HIDE_DELETED), "active"); + /* Keep the sensitivity of "Create Search Folder from Search" + * in sync with "Save Search" so that its only selectable when + * showing search results. */ + e_binding_new ( + ACTION (SEARCH_SAVE), "sensitive", + ACTION (MAIL_CREATE_SEARCH_FOLDER), "sensitive"); + 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() */ |