aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@src.gnome.org>2009-02-14 08:30:08 +0800
committerMatthew Barnes <mbarnes@src.gnome.org>2009-02-14 08:30:08 +0800
commitccd8e3964f548798eb05a430b3ea81b2760069cc (patch)
tree384bc6d1922e4b3ecf98d698fcd921dceeeeef8a /mail
parent4f60c57f314db049153feeb2a8b28cfeaf4fa81a (diff)
downloadgsoc2013-evolution-ccd8e3964f548798eb05a430b3ea81b2760069cc.tar
gsoc2013-evolution-ccd8e3964f548798eb05a430b3ea81b2760069cc.tar.gz
gsoc2013-evolution-ccd8e3964f548798eb05a430b3ea81b2760069cc.tar.bz2
gsoc2013-evolution-ccd8e3964f548798eb05a430b3ea81b2760069cc.tar.lz
gsoc2013-evolution-ccd8e3964f548798eb05a430b3ea81b2760069cc.tar.xz
gsoc2013-evolution-ccd8e3964f548798eb05a430b3ea81b2760069cc.tar.zst
gsoc2013-evolution-ccd8e3964f548798eb05a430b3ea81b2760069cc.zip
Get mail search bar partially working without help from EFilterBar.
Search scope (current folder, current account, etc.) is still ignored. svn path=/branches/kill-bonobo/; revision=37263
Diffstat (limited to 'mail')
-rw-r--r--mail/e-mail-shell-content.c9
-rw-r--r--mail/e-mail-shell-content.h3
-rw-r--r--mail/e-mail-shell-view-actions.c63
-rw-r--r--mail/e-mail-shell-view-private.c262
-rw-r--r--mail/e-mail-shell-view-private.h8
-rw-r--r--mail/em-folder-browser.c326
6 files changed, 502 insertions, 169 deletions
diff --git a/mail/e-mail-shell-content.c b/mail/e-mail-shell-content.c
index 03337b13f0..17d873e8c0 100644
--- a/mail/e-mail-shell-content.c
+++ b/mail/e-mail-shell-content.c
@@ -753,6 +753,15 @@ e_mail_shell_content_set_vertical_view (EMailShellContent *mail_shell_content,
g_object_notify (G_OBJECT (mail_shell_content), "vertical-view");
}
+GalViewInstance *
+e_mail_shell_content_get_view_instance (EMailShellContent *mail_shell_content)
+{
+ g_return_val_if_fail (
+ E_IS_MAIL_SHELL_CONTENT (mail_shell_content), NULL);
+
+ return mail_shell_content->priv->view_instance;
+}
+
void
e_mail_shell_content_update_view_instance (EMailShellContent *mail_shell_content)
{
diff --git a/mail/e-mail-shell-content.h b/mail/e-mail-shell-content.h
index 9d2358590f..2c328ce268 100644
--- a/mail/e-mail-shell-content.h
+++ b/mail/e-mail-shell-content.h
@@ -73,6 +73,9 @@ gboolean e_mail_shell_content_get_vertical_view
void e_mail_shell_content_set_vertical_view
(EMailShellContent *mail_shell_content,
gboolean vertical_view);
+GalViewInstance *
+ e_mail_shell_content_get_view_instance
+ (EMailShellContent *mail_shell_content);
void e_mail_shell_content_update_view_instance
(EMailShellContent *mail_shell_content);
diff --git a/mail/e-mail-shell-view-actions.c b/mail/e-mail-shell-view-actions.c
index 9a67118957..99d3078bde 100644
--- a/mail/e-mail-shell-view-actions.c
+++ b/mail/e-mail-shell-view-actions.c
@@ -22,6 +22,26 @@
#include "e-mail-shell-view-private.h"
static void
+action_gal_save_custom_view_cb (GtkAction *action,
+ EMailShellView *mail_shell_view)
+{
+ EMailShellContent *mail_shell_content;
+ EShellView *shell_view;
+ GalViewInstance *view_instance;
+
+ /* All shell views repond to the activation of this action,
+ * which is defined by EShellWindow. But only the currently
+ * active shell view proceeds with saving the custom view. */
+ shell_view = E_SHELL_VIEW (mail_shell_view);
+ if (!e_shell_view_is_active (shell_view))
+ return;
+
+ mail_shell_content = mail_shell_view->priv->mail_shell_content;
+ view_instance = e_mail_shell_content_get_view_instance (mail_shell_content);
+ gal_view_instance_save_as (view_instance);
+}
+
+static void
action_mail_account_disable_cb (GtkAction *action,
EMailShellView *mail_shell_view)
{
@@ -685,6 +705,22 @@ action_mail_view_cb (GtkRadioAction *action,
}
static void
+action_search_execute_cb (GtkAction *action,
+ EMailShellView *mail_shell_view)
+{
+ EShellView *shell_view;
+
+ /* All shell views respond to the activation of this action,
+ * which is defined by EShellWindow. But only the currently
+ * active shell view proceeds with executing the search. */
+ shell_view = E_SHELL_VIEW (mail_shell_view);
+ if (!e_shell_view_is_active (shell_view))
+ return;
+
+ e_mail_shell_view_execute_search (mail_shell_view);
+}
+
+static void
action_search_filter_cb (GtkRadioAction *action,
GtkRadioAction *current,
EMailShellView *mail_shell_view)
@@ -692,6 +728,14 @@ action_search_filter_cb (GtkRadioAction *action,
e_mail_shell_view_execute_search (mail_shell_view);
}
+static void
+action_search_scope_cb (GtkRadioAction *action,
+ GtkRadioAction *current,
+ EMailShellView *mail_shell_view)
+{
+ e_mail_shell_view_execute_search (mail_shell_view);
+}
+
static GtkActionEntry mail_entries[] = {
{ "mail-account-disable",
@@ -1166,7 +1210,9 @@ e_mail_shell_view_actions_init (EMailShellView *mail_shell_view)
{
EShellView *shell_view;
EShellWindow *shell_window;
+ EShellContent *shell_content;
GtkActionGroup *action_group;
+ GtkRadioAction *radio_action;
GConfBridge *bridge;
GObject *object;
GObject *src_object;
@@ -1177,6 +1223,7 @@ 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 Actions */
action_group = ACTION_GROUP (MAIL);
@@ -1202,7 +1249,11 @@ e_mail_shell_view_actions_init (EMailShellView *mail_shell_view)
action_group, mail_scope_entries,
G_N_ELEMENTS (mail_scope_entries),
MAIL_SCOPE_CURRENT_FOLDER,
- NULL, NULL);
+ 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);
/* Bind GObject properties for GConf keys. */
@@ -1235,6 +1286,14 @@ e_mail_shell_view_actions_init (EMailShellView *mail_shell_view)
dst_object = G_OBJECT (ACTION (MAIL_THREADS_EXPAND_ALL));
e_binding_new (src_object, "active", dst_object, "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_EXECUTE), "activate",
+ G_CALLBACK (action_search_execute_cb), mail_shell_view);
}
/* Helper for e_mail_shell_view_update_popup_labels() */
@@ -1470,7 +1529,7 @@ e_mail_shell_view_update_search_filter (EMailShellView *mail_shell_view)
ii++;
}
- /* User any action in the group; doesn't matter which. */
+ /* Use any action in the group; doesn't matter which. */
e_shell_content_set_filter_action (shell_content, radio_action);
ii = MAIL_FILTER_UNREAD_MESSAGES;
diff --git a/mail/e-mail-shell-view-private.c b/mail/e-mail-shell-view-private.c
index fba8df06f5..994f250565 100644
--- a/mail/e-mail-shell-view-private.c
+++ b/mail/e-mail-shell-view-private.c
@@ -162,12 +162,16 @@ e_mail_shell_view_private_constructed (EMailShellView *mail_shell_view)
EShellWindow *shell_window;
EMFolderTreeModel *folder_tree_model;
EMFolderTree *folder_tree;
+ RuleContext *context;
+ FilterRule *rule = NULL;
GtkTreeModel *tree_model;
GtkUIManager *ui_manager;
MessageList *message_list;
EMailReader *reader;
+ const gchar *source;
guint merge_id;
gchar *uri;
+ gint ii = 0;
shell_view = E_SHELL_VIEW (mail_shell_view);
shell_content = e_shell_view_get_shell_content (shell_view);
@@ -243,6 +247,17 @@ e_mail_shell_view_private_constructed (EMailShellView *mail_shell_view)
e_mail_shell_view_update_search_filter (mail_shell_view);
e_mail_reader_init (reader);
+ /* 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);
+ source = FILTER_SOURCE_DEMAND;
+ while ((rule = rule_context_next_rule (context, rule, source))) {
+ g_assert (ii < MAIL_NUM_SEARCH_RULES);
+ priv->search_rules[ii++] = g_object_ref (rule);
+ }
+ g_assert (ii == MAIL_NUM_SEARCH_RULES);
+
/* Restore the previously selected folder. */
folder_tree_model = em_folder_tree_get_model (folder_tree);
uri = em_folder_tree_model_get_selected (folder_tree_model);
@@ -266,20 +281,263 @@ void
e_mail_shell_view_private_dispose (EMailShellView *mail_shell_view)
{
EMailShellViewPrivate *priv = mail_shell_view->priv;
+ gint ii;
DISPOSE (priv->mail_shell_content);
DISPOSE (priv->mail_shell_sidebar);
+
+ for (ii = 0; ii < MAIL_NUM_SEARCH_RULES; ii++)
+ DISPOSE (priv->search_rules[ii]);
}
void
e_mail_shell_view_private_finalize (EMailShellView *mail_shell_view)
{
+ /* XXX Nothing to do? */
}
void
e_mail_shell_view_execute_search (EMailShellView *mail_shell_view)
{
- /* FIXME */
+ EShell *shell;
+ EShellView *shell_view;
+ EShellWindow *shell_window;
+ EShellContent *shell_content;
+ EShellSettings *shell_settings;
+ EMFormatHTMLDisplay *html_display;
+ MessageList *message_list;
+ FilterRule *rule;
+ EMailReader *reader;
+ CamelFolder *folder;
+ GtkAction *action;
+ GtkTreeModel *model;
+ GtkTreePath *path;
+ GtkTreeIter tree_iter;
+ GString *string;
+ GList *iter;
+ GSList *word_list = NULL;
+ const gchar *folder_uri;
+ const gchar *text;
+ gboolean valid;
+ gchar *query;
+ gchar *temp;
+ gchar *tag;
+ gint value;
+
+ g_return_if_fail (E_IS_MAIL_SHELL_VIEW (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);
+
+ shell = e_shell_window_get_shell (shell_window);
+ shell_settings = e_shell_get_shell_settings (shell);
+
+ reader = E_MAIL_READER (shell_content);
+ html_display = e_mail_reader_get_html_display (reader);
+ message_list = e_mail_reader_get_message_list (reader);
+
+ folder_uri = message_list->folder_uri;
+ folder = message_list->folder;
+
+ /* This returns a new object reference. */
+ model = e_shell_settings_get_object (
+ shell_settings, "mail-label-list-store");
+
+ text = e_shell_content_get_search_text (shell_content);
+ if (text == NULL || *text == '\0') {
+ 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_SENDER_CONTAINS);
+ value = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
+ g_return_if_fail (value >= 0 && value < MAIL_NUM_SEARCH_RULES);
+ rule = mail_shell_view->priv->search_rules[value];
+
+ for (iter = rule->parts; iter != NULL; iter = iter->next) {
+ FilterPart *part = iter->data;
+ FilterElement *element = NULL;
+
+ if (strcmp (part->name, "subject") == 0)
+ element = filter_part_find_element (part, "subject");
+ else if (strcmp (part->name, "body") == 0)
+ element = filter_part_find_element (part, "word");
+ else if (strcmp (part->name, "sender") == 0)
+ element = filter_part_find_element (part, "sender");
+ else if (strcmp (part->name, "to") == 0)
+ element = filter_part_find_element (part, "recipient");
+
+ if (strcmp (part->name, "body") == 0) {
+ struct _camel_search_words *words;
+ gint ii;
+
+ words = camel_search_words_split ((guchar *) text);
+ for (ii = 0; ii < words->len; ii++)
+ word_list = g_slist_prepend (
+ word_list, g_strdup (
+ words->words[ii]->word));
+ camel_search_words_free (words);
+ }
+
+ if (element != NULL) {
+ FilterInput *input = FILTER_INPUT (element);
+ filter_input_set_value (input, text);
+ }
+ }
+
+ string = g_string_sized_new (1024);
+ filter_rule_build_code (rule, string);
+ query = g_string_free (string, FALSE);
+
+filter:
+
+ /* Apply selected filter. */
+
+ value = e_shell_content_get_filter_value (shell_content);
+ switch (value) {
+ case MAIL_FILTER_ALL_MESSAGES:
+ break;
+
+ case MAIL_FILTER_UNREAD_MESSAGES:
+ temp = g_strdup_printf (
+ "(and %s (match-all (not "
+ "(system-flag \"Seen\"))))", query);
+ g_free (query);
+ query = temp;
+ break;
+
+ case MAIL_FILTER_NO_LABEL:
+ string = g_string_sized_new (1024);
+ g_string_append_printf (
+ string, "(and %s (and ", query);
+ valid = gtk_tree_model_get_iter_first (
+ model, &tree_iter);
+ while (valid) {
+ tag = e_mail_label_list_store_get_tag (
+ E_MAIL_LABEL_LIST_STORE (model),
+ &tree_iter);
+ g_string_append_printf (
+ string, " (match-all (not (or "
+ "(= (user-tag \"label\") \"%s\") "
+ "(user-flag \"$Label%s\") "
+ "(user-flag \"%s\"))))",
+ tag, tag, tag);
+ g_free (tag);
+
+ valid = gtk_tree_model_iter_next (
+ model, &tree_iter);
+ }
+ g_string_append_len (string, "))", 2);
+ g_free (query);
+ query = g_string_free (string, FALSE);
+ break;
+
+ case MAIL_FILTER_READ_MESSAGES:
+ temp = g_strdup_printf (
+ "(and %s (match-all "
+ "(system-flag \"Seen\")))", query);
+ g_free (query);
+ query = temp;
+ break;
+
+ case MAIL_FILTER_RECENT_MESSAGES:
+ if (em_utils_folder_is_sent (folder, folder_uri))
+ temp = g_strdup_printf (
+ "(and %s (match-all "
+ "(> (get-sent-date) "
+ "(- (get-current-date) 86400))))",
+ query);
+ else
+ temp = g_strdup_printf (
+ "(and %s (match-all "
+ "(> (get-received-date) "
+ "(- (get_current_date) 86400))))",
+ query);
+ g_free (query);
+ query = temp;
+ break;
+
+ case MAIL_FILTER_LAST_5_DAYS_MESSAGES:
+ if (em_utils_folder_is_sent (folder, folder_uri))
+ temp = g_strdup_printf (
+ "(and %s (match-all "
+ "(> (get-sent-date) "
+ "(- (get-current-date) 432000))))",
+ query);
+ else
+ temp = g_strdup_printf (
+ "(and %s (match-all "
+ "(> (get-received-date) "
+ "(- (get_current_date) 432000))))",
+ query);
+ g_free (query);
+ query = temp;
+ break;
+
+ case MAIL_FILTER_MESSAGES_WITH_ATTACHMENTS:
+ temp = g_strdup_printf (
+ "(and %s (match-all "
+ "(system-flag \"Attachments\")))", query);
+ g_free (query);
+ query = temp;
+ break;
+
+ case MAIL_FILTER_IMPORTANT_MESSAGES:
+ temp = g_strdup_printf (
+ "(and %s (match-all "
+ "(system-flag \"Flagged\")))", query);
+ g_free (query);
+ query = temp;
+ break;
+
+ case MAIL_FILTER_MESSAGES_NOT_JUNK:
+ temp = g_strdup_printf (
+ "(and %s (match-all (not "
+ "(system-flag \"junk\"))))", query);
+ g_free (query);
+ query = temp;
+ break;
+
+ default:
+ /* The action value also serves as a path for
+ * the label list store. That's why we number
+ * the label actions from zero. */
+ path = gtk_tree_path_new_from_indices (value, -1);
+ gtk_tree_model_get_iter (model, &tree_iter, path);
+ gtk_tree_path_free (path);
+
+ tag = e_mail_label_list_store_get_tag (
+ E_MAIL_LABEL_LIST_STORE (model), &tree_iter);
+ temp = g_strdup_printf (
+ "(and %s (match-all (or "
+ "(= (user-tag \"label\") \"%s\") "
+ "(user-flag \"$Label%s\") "
+ "(user-flag \"%s\"))))",
+ query, tag, tag, tag);
+ g_free (tag);
+
+ g_free (query);
+ query = temp;
+ break;
+ }
+
+ message_list_set_search (message_list, query);
+
+ em_format_html_display_set_search (
+ html_display,
+ EM_FORMAT_HTML_DISPLAY_SEARCH_SECONDARY |
+ EM_FORMAT_HTML_DISPLAY_SEARCH_ICASE,
+ word_list);
+
+ g_slist_foreach (word_list, (GFunc) g_free, NULL);
+ g_slist_free (word_list);
+
+ g_object_unref (model);
+ g_free (query);
}
/* Helper for e_mail_shell_view_create_filter_from_selected() */
@@ -427,8 +685,6 @@ e_mail_shell_view_update_sidebar (EMailShellView *mail_shell_view)
guint32 num_unread;
guint32 num_visible;
- /* FIXME The sidebar should handle icon name and primary text. */
-
g_return_if_fail (E_IS_MAIL_SHELL_VIEW (mail_shell_view));
shell_view = E_SHELL_VIEW (mail_shell_view);
diff --git a/mail/e-mail-shell-view-private.h b/mail/e-mail-shell-view-private.h
index cdb3c72b9d..8d295cd2a4 100644
--- a/mail/e-mail-shell-view-private.h
+++ b/mail/e-mail-shell-view-private.h
@@ -27,11 +27,13 @@
#include <glib/gi18n.h>
#include <gtkhtml/gtkhtml.h>
#include <camel/camel-vtrash-folder.h>
+#include <camel/camel-search-private.h> /* for camel_search_word */
#include "e-util/e-util.h"
#include "e-util/e-binding.h"
#include "e-util/gconf-bridge.h"
#include "e-util/e-account-utils.h"
+#include "filter/filter-part.h"
#include "widgets/misc/e-popup-action.h"
#include "widgets/menus/gal-view-instance.h"
@@ -101,7 +103,8 @@ enum {
MAIL_SEARCH_MESSAGE_CONTAINS,
MAIL_SEARCH_SUBJECT_CONTAINS,
MAIL_SEARCH_SENDER_CONTAINS,
- MAIL_SEARCH_BODY_CONTAINS
+ MAIL_SEARCH_BODY_CONTAINS,
+ MAIL_NUM_SEARCH_RULES
};
/* Scope items are displayed in ascending order. */
@@ -123,6 +126,9 @@ struct _EMailShellViewPrivate {
/* For UI merging and unmerging. */
guint merge_id;
guint label_merge_id;
+
+ /* Filter rules correspond to the search entry menu. */
+ FilterRule *search_rules[MAIL_NUM_SEARCH_RULES];
};
void e_mail_shell_view_private_init
diff --git a/mail/em-folder-browser.c b/mail/em-folder-browser.c
index e9e48c9a1b..bcc25002b7 100644
--- a/mail/em-folder-browser.c
+++ b/mail/em-folder-browser.c
@@ -274,34 +274,34 @@ emfb_init(GObject *o)
emfb->view.enable_map = g_slist_prepend(emfb->view.enable_map, (void *)emfb_enable_map);
- if (search_context) {
- const char *systemrules = g_object_get_data (G_OBJECT (search_context), "system");
- const char *userrules = g_object_get_data (G_OBJECT (search_context), "user");
- EFilterBar *efb;
- GConfClient *gconf;
-
- emfb->search = e_filter_bar_new(search_context, systemrules, userrules, emfb_search_config_search, emfb);
- efb = (EFilterBar *)emfb->search;
- efb->account_search_vf = NULL;
- efb->all_account_search_vf = NULL;
- efb->account_search_cancel = NULL;
- e_search_bar_set_menu ((ESearchBar *)emfb->search, emfb_search_items);
- e_search_bar_set_scopeoption ((ESearchBar *)emfb->search, emfb_search_scope_items);
- e_search_bar_scope_enable ((ESearchBar *)emfb->search, E_FILTERBAR_CURRENT_MESSAGE_ID, FALSE);
- emfb->priv->scope_restricted = TRUE;
- g_signal_connect(emfb, "realize", G_CALLBACK(emfb_realize), NULL);
- gtk_widget_show((GtkWidget *)emfb->search);
-
- p->search_menu_activated_id = g_signal_connect(emfb->search, "menu_activated", G_CALLBACK(emfb_search_menu_activated), emfb);
- p->search_activated_id = g_signal_connect(emfb->search, "search_activated", G_CALLBACK(emfb_search_search_activated), emfb);
- g_signal_connect(emfb->search, "search_cleared", G_CALLBACK(emfb_search_search_cleared), NULL);
-
- gtk_box_pack_start((GtkBox *)emfb, (GtkWidget *)emfb->search, FALSE, TRUE, 0);
-
+// if (search_context) {
+// const char *systemrules = g_object_get_data (G_OBJECT (search_context), "system");
+// const char *userrules = g_object_get_data (G_OBJECT (search_context), "user");
+// EFilterBar *efb;
+// GConfClient *gconf;
+//
+// emfb->search = e_filter_bar_new(search_context, systemrules, userrules, emfb_search_config_search, emfb);
+// efb = (EFilterBar *)emfb->search;
+// efb->account_search_vf = NULL;
+// efb->all_account_search_vf = NULL;
+// efb->account_search_cancel = NULL;
+// e_search_bar_set_menu ((ESearchBar *)emfb->search, emfb_search_items);
+// e_search_bar_set_scopeoption ((ESearchBar *)emfb->search, emfb_search_scope_items);
+// e_search_bar_scope_enable ((ESearchBar *)emfb->search, E_FILTERBAR_CURRENT_MESSAGE_ID, FALSE);
+// emfb->priv->scope_restricted = TRUE;
+// g_signal_connect(emfb, "realize", G_CALLBACK(emfb_realize), NULL);
+// gtk_widget_show((GtkWidget *)emfb->search);
+//
+// p->search_menu_activated_id = g_signal_connect(emfb->search, "menu_activated", G_CALLBACK(emfb_search_menu_activated), emfb);
+// p->search_activated_id = g_signal_connect(emfb->search, "search_activated", G_CALLBACK(emfb_search_search_activated), emfb);
+// g_signal_connect(emfb->search, "search_cleared", G_CALLBACK(emfb_search_search_cleared), NULL);
+//
+// gtk_box_pack_start((GtkBox *)emfb, (GtkWidget *)emfb->search, FALSE, TRUE, 0);
+//
// gconf = mail_config_get_gconf_client ();
// emfb->priv->labels_change_notify_id = gconf_client_notify_add (gconf, E_UTIL_LABELS_GCONF_KEY, gconf_labels_changed, emfb, NULL, NULL);
- }
-
+// }
+//
// emfb->priv->show_wide = gconf_client_get_bool(mail_config_get_gconf_client(), "/apps/evolution/mail/display/show_wide", NULL);
// emfb->vpane = emfb->priv->show_wide?gtk_hpaned_new():gtk_vpaned_new();
//
@@ -470,144 +470,144 @@ emfb_search_menu_activated(ESearchBar *esb, int id, EMFolderBrowser *emfb)
}
}
-static void
-emfb_search_config_search(EFilterBar *efb, FilterRule *rule, int id, const char *query, void *data)
-{
- EMFolderBrowser *emfb = data;
- GList *partl;
- struct _camel_search_words *words;
- int i;
- GSList *strings = NULL;
-
- /* we scan the parts of a rule, and set all the types we know about to the query string */
- partl = rule->parts;
- while (partl) {
- FilterPart *part = partl->data;
-
- if (!strcmp(part->name, "subject")) {
- FilterInput *input = (FilterInput *)filter_part_find_element(part, "subject");
- if (input)
- filter_input_set_value(input, query);
- } else if (!strcmp(part->name, "body")) {
- FilterInput *input = (FilterInput *)filter_part_find_element(part, "word");
- if (input)
- filter_input_set_value(input, query);
-
- words = camel_search_words_split((unsigned char *)query);
- for (i=0;i<words->len;i++)
- strings = g_slist_prepend(strings, g_strdup(words->words[i]->word));
- camel_search_words_free (words);
- } else if(!strcmp(part->name, "sender")) {
- FilterInput *input = (FilterInput *)filter_part_find_element(part, "sender");
- if (input)
- filter_input_set_value(input, query);
- } else if(!strcmp(part->name, "to")) {
- FilterInput *input = (FilterInput *)filter_part_find_element(part, "recipient");
- if (input)
- filter_input_set_value(input, query);
- }
-
- partl = partl->next;
- }
-
- em_format_html_display_set_search(emfb->view.preview,
- EM_FORMAT_HTML_DISPLAY_SEARCH_SECONDARY|EM_FORMAT_HTML_DISPLAY_SEARCH_ICASE,
- strings);
- while (strings) {
- GSList *n = strings->next;
- g_free(strings->data);
- g_slist_free_1(strings);
- strings = n;
- }
-}
-
-static char *
-get_view_query (ESearchBar *esb, CamelFolder *folder, const char *folder_uri)
-{
- char *view_sexp = NULL;
- gint id;
- GtkWidget *menu_item;
- char *tag;
- gboolean duplicate = TRUE;
-
- /* Get the current selected view */
- id = e_search_bar_get_viewitem_id (esb);
- menu_item = e_search_bar_get_selected_viewitem (esb);
-
- switch (id & VIEW_ITEMS_MASK) {
- case VIEW_ALL_MESSAGES:
- /* one space indicates no filtering */
- view_sexp = " ";
- break;
-
- case VIEW_UNREAD_MESSAGES:
- view_sexp = "(match-all (not (system-flag \"Seen\")))";
- break;
- case VIEW_READ_MESSAGES:
- view_sexp = "(match-all (system-flag \"Seen\" ))";
- break;
- case VIEW_RECENT_MESSAGES:
- if (!em_utils_folder_is_sent (folder, folder_uri))
- view_sexp = "(match-all (> (get-received-date) (- (get-current-date) 86400)))";
- else
- view_sexp = "(match-all (> (get-sent-date) (- (get-current-date) 86400)))";
- break;
- case VIEW_LAST_FIVE_DAYS:
- if (!em_utils_folder_is_sent (folder, folder_uri))
- view_sexp = " (match-all (> (get-received-date) (- (get-current-date) 432000)))";
- else
- view_sexp = " (match-all (> (get-sent-date) (- (get-current-date) 432000)))";
- break;
- case VIEW_WITH_ATTACHMENTS:
- view_sexp = "(match-all (system-flag \"Attachments\" ))";
- break;
- case VIEW_NOT_JUNK:
- view_sexp = "(match-all (not (system-flag \"junk\")))";
- break;
- case VIEW_NO_LABEL: {
- GSList *l;
- GString *s = g_string_new ("(and");
-
- for (l = mail_config_get_labels (); l; l = l->next) {
- EUtilLabel *label = (EUtilLabel *)l->data;
-
- if (label && label->tag) {
- const gchar *tag = label->tag;
-
- if (strncmp (tag, "$Label", 6) == 0)
- tag += 6;
-
- g_string_append_printf (s, " (match-all (not (or (= (user-tag \"label\") \"%s\") (user-flag \"$Label%s\") (user-flag \"%s\"))))", tag, tag, tag);
- }
- }
-
- g_string_append (s, ")");
-
- duplicate = FALSE;
- view_sexp = g_string_free (s, FALSE);
- } break;
- case VIEW_LABEL:
- tag = (char *)g_object_get_data (G_OBJECT (menu_item), "LabelTag");
- view_sexp = g_strdup_printf ("(match-all (or (= (user-tag \"label\") \"%s\") (user-flag \"$Label%s\") (user-flag \"%s\")))", tag, tag, tag);
- duplicate = FALSE;
- break;
- case VIEW_MESSAGES_MARKED_AS_IMPORTANT:
- view_sexp = "(match-all (system-flag \"Flagged\" ))";
- break;
- case VIEW_ANY_FIELD_CONTAINS:
- break;
-
- case VIEW_CUSTOMIZE:
- /* one space indicates no filtering, so here use two */
- view_sexp = " ";
- break;
- }
-
- if (duplicate)
- view_sexp = g_strdup (view_sexp);
+//static void
+//emfb_search_config_search(EFilterBar *efb, FilterRule *rule, int id, const char *query, void *data)
+//{
+// EMFolderBrowser *emfb = data;
+// GList *partl;
+// struct _camel_search_words *words;
+// int i;
+// GSList *strings = NULL;
+//
+// /* we scan the parts of a rule, and set all the types we know about to the query string */
+// partl = rule->parts;
+// while (partl) {
+// FilterPart *part = partl->data;
+//
+// if (!strcmp(part->name, "subject")) {
+// FilterInput *input = (FilterInput *)filter_part_find_element(part, "subject");
+// if (input)
+// filter_input_set_value(input, query);
+// } else if (!strcmp(part->name, "body")) {
+// FilterInput *input = (FilterInput *)filter_part_find_element(part, "word");
+// if (input)
+// filter_input_set_value(input, query);
+//
+// words = camel_search_words_split((unsigned char *)query);
+// for (i=0;i<words->len;i++)
+// strings = g_slist_prepend(strings, g_strdup(words->words[i]->word));
+// camel_search_words_free (words);
+// } else if(!strcmp(part->name, "sender")) {
+// FilterInput *input = (FilterInput *)filter_part_find_element(part, "sender");
+// if (input)
+// filter_input_set_value(input, query);
+// } else if(!strcmp(part->name, "to")) {
+// FilterInput *input = (FilterInput *)filter_part_find_element(part, "recipient");
+// if (input)
+// filter_input_set_value(input, query);
+// }
+//
+// partl = partl->next;
+// }
+//
+// em_format_html_display_set_search(emfb->view.preview,
+// EM_FORMAT_HTML_DISPLAY_SEARCH_SECONDARY|EM_FORMAT_HTML_DISPLAY_SEARCH_ICASE,
+// strings);
+// while (strings) {
+// GSList *n = strings->next;
+// g_free(strings->data);
+// g_slist_free_1(strings);
+// strings = n;
+// }
+//}
- return view_sexp;
-}
+//static char *
+//get_view_query (ESearchBar *esb, CamelFolder *folder, const char *folder_uri)
+//{
+// char *view_sexp = NULL;
+// gint id;
+// GtkWidget *menu_item;
+// char *tag;
+// gboolean duplicate = TRUE;
+//
+// /* Get the current selected view */
+// id = e_search_bar_get_viewitem_id (esb);
+// menu_item = e_search_bar_get_selected_viewitem (esb);
+//
+// switch (id & VIEW_ITEMS_MASK) {
+// case VIEW_ALL_MESSAGES:
+// /* one space indicates no filtering */
+// view_sexp = " ";
+// break;
+//
+// case VIEW_UNREAD_MESSAGES:
+// view_sexp = "(match-all (not (system-flag \"Seen\")))";
+// break;
+// case VIEW_READ_MESSAGES:
+// view_sexp = "(match-all (system-flag \"Seen\" ))";
+// break;
+// case VIEW_RECENT_MESSAGES:
+// if (!em_utils_folder_is_sent (folder, folder_uri))
+// view_sexp = "(match-all (> (get-received-date) (- (get-current-date) 86400)))";
+// else
+// view_sexp = "(match-all (> (get-sent-date) (- (get-current-date) 86400)))";
+// break;
+// case VIEW_LAST_FIVE_DAYS:
+// if (!em_utils_folder_is_sent (folder, folder_uri))
+// view_sexp = " (match-all (> (get-received-date) (- (get-current-date) 432000)))";
+// else
+// view_sexp = " (match-all (> (get-sent-date) (- (get-current-date) 432000)))";
+// break;
+// case VIEW_WITH_ATTACHMENTS:
+// view_sexp = "(match-all (system-flag \"Attachments\" ))";
+// break;
+// case VIEW_NOT_JUNK:
+// view_sexp = "(match-all (not (system-flag \"junk\")))";
+// break;
+// case VIEW_NO_LABEL: {
+// GSList *l;
+// GString *s = g_string_new ("(and");
+//
+// for (l = mail_config_get_labels (); l; l = l->next) {
+// EUtilLabel *label = (EUtilLabel *)l->data;
+//
+// if (label && label->tag) {
+// const gchar *tag = label->tag;
+//
+// if (strncmp (tag, "$Label", 6) == 0)
+// tag += 6;
+//
+// g_string_append_printf (s, " (match-all (not (or (= (user-tag \"label\") \"%s\") (user-flag \"$Label%s\") (user-flag \"%s\"))))", tag, tag, tag);
+// }
+// }
+//
+// g_string_append (s, ")");
+//
+// duplicate = FALSE;
+// view_sexp = g_string_free (s, FALSE);
+// } break;
+// case VIEW_LABEL:
+// tag = (char *)g_object_get_data (G_OBJECT (menu_item), "LabelTag");
+// view_sexp = g_strdup_printf ("(match-all (or (= (user-tag \"label\") \"%s\") (user-flag \"$Label%s\") (user-flag \"%s\")))", tag, tag, tag);
+// duplicate = FALSE;
+// break;
+// case VIEW_MESSAGES_MARKED_AS_IMPORTANT:
+// view_sexp = "(match-all (system-flag \"Flagged\" ))";
+// break;
+// case VIEW_ANY_FIELD_CONTAINS:
+// break;
+//
+// case VIEW_CUSTOMIZE:
+// /* one space indicates no filtering, so here use two */
+// view_sexp = " ";
+// break;
+// }
+//
+// if (duplicate)
+// view_sexp = g_strdup (view_sexp);
+//
+// return view_sexp;
+//}
struct _setup_msg {