aboutsummaryrefslogtreecommitdiffstats
path: root/mail/em-folder-browser.c
diff options
context:
space:
mode:
authorHarish Krishnaswamy <kharish@novell.com>2006-06-30 17:46:32 +0800
committerHarish Krishnaswamy <kharish@src.gnome.org>2006-06-30 17:46:32 +0800
commita1d6678af2c9f8a075d9d7832c2a6da981afe216 (patch)
tree9004c48377a85caf85ce21a5f91df6f18bd3ca7c /mail/em-folder-browser.c
parentefd7b846b86bafc3efc361a316b9fd204a75ac89 (diff)
downloadgsoc2013-evolution-a1d6678af2c9f8a075d9d7832c2a6da981afe216.tar.gz
gsoc2013-evolution-a1d6678af2c9f8a075d9d7832c2a6da981afe216.tar.zst
gsoc2013-evolution-a1d6678af2c9f8a075d9d7832c2a6da981afe216.zip
Enhanced search functionality. patch submitted by Johnny Jacob Reviewed
2006-06-30 Harish Krishnaswamy <kharish@novell.com> Enhanced search functionality. patch submitted by Johnny Jacob Reviewed and committed by Harish. svn path=/trunk/; revision=32207
Diffstat (limited to 'mail/em-folder-browser.c')
-rw-r--r--mail/em-folder-browser.c617
1 files changed, 592 insertions, 25 deletions
diff --git a/mail/em-folder-browser.c b/mail/em-folder-browser.c
index 0493035075..f15df9984c 100644
--- a/mail/em-folder-browser.c
+++ b/mail/em-folder-browser.c
@@ -60,6 +60,8 @@
#include <camel/camel-stream.h>
#include <camel/camel-url.h>
+#include <camel/camel-vee-folder.h>
+#include <camel/camel-vee-store.h>
#include <bonobo/bonobo-main.h>
#include <bonobo/bonobo-object.h>
@@ -74,6 +76,7 @@
#include "em-vfolder-rule.h"
#include <misc/e-filter-bar.h>
#include <camel/camel-search-private.h>
+#include <camel/camel-store.h>
#include "e-util/e-dialog-utils.h"
#include "e-util/e-error.h"
@@ -94,6 +97,9 @@
#include "evolution-shell-component-utils.h" /* Pixmap stuff, sigh */
+extern CamelSession *session;
+CamelStore *vfolder_store; /* the 1 static vfolder store */
+
#define d(x)
struct _EMFolderBrowserPrivate {
@@ -122,6 +128,7 @@ struct _EMFolderBrowserPrivate {
static void emfb_activate(EMFolderView *emfv, BonoboUIComponent *uic, int state);
static void emfb_set_folder(EMFolderView *emfv, CamelFolder *folder, const char *uri);
+static void emfb_set_search_folder(EMFolderView *emfv, CamelFolder *folder, const char *uri);
/* FilterBar stuff ... */
static void emfb_search_config_search(EFilterBar *efb, FilterRule *rule, int id, const char *query, void *data);
@@ -135,17 +142,70 @@ static void emfb_list_message_selected (MessageList *ml, const char *uid, EMFold
static const EMFolderViewEnable emfb_enable_map[];
enum {
+ ACCOUNT_SEARCH_ACTIVATED,
+ ACCOUNT_SEARCH_CLEARED,
+ LAST_SIGNAL
+};
+
+static guint folder_browser_signals [LAST_SIGNAL] = {0, };
+
+enum {
ESB_SAVE,
};
static ESearchBarItem emfb_search_items[] = {
E_FILTERBAR_ADVANCED,
- { NULL, 0, NULL },
+ { NULL, 0, 0 },
E_FILTERBAR_SAVE,
E_FILTERBAR_EDIT,
- { NULL, 0, NULL },
- { N_("C_reate Search Folder From Search..."), ESB_SAVE, NULL },
- { NULL, -1, NULL }
+ { NULL, 0, 0 },
+ { N_("C_reate Search Folder From Search..."), ESB_SAVE, 0},
+ { NULL, -1, 0 }
+};
+
+/* IDs and option items for the ESearchBar */
+enum {
+ VIEW_ALL_MESSAGES,
+ VIEW_UNREAD_MESSAGES,
+ VIEW_READ_MESSAGES,
+ VIEW_RECENT_MESSAGES,
+ VIEW_LAST_FIVE_DAYS,
+ VIEW_WITH_ATTACHMENTS,
+ VIEW_NOT_JUNK,
+ VIEW_NO_LABEL,
+ VIEW_LABEL,
+ VIEW_ANY_FIELD_CONTAINS,
+ VIEW_CUSTOMIZE
+};
+
+/* Options for View */
+static ESearchBarItem emfb_view_items[] = {
+ { N_("All Messages"), VIEW_ALL_MESSAGES, 0 },
+ { N_("Unread Messages"), VIEW_UNREAD_MESSAGES, 0 },
+ { NULL, 0, 0 },
+ { N_("No Label"),VIEW_NO_LABEL, 0 },
+ { NULL, -1, 0 }
+};
+
+/* TODO: Following options should be customizable */
+static ESearchBarItem temp_view_items[] = {
+ { NULL, 0, 0 },
+ { N_("Read Messages"), VIEW_READ_MESSAGES, 0 },
+ { N_("Recent Messages"), VIEW_RECENT_MESSAGES, 0 },
+ { N_("Last 5 Days Messages"), VIEW_LAST_FIVE_DAYS, 0 },
+ { N_("Messages with Attachments"), VIEW_WITH_ATTACHMENTS, 0 },
+ { N_("Messages Not Junk"), VIEW_NOT_JUNK, 0 },
+/* { NULL, 0, NULL }, */
+/* { N_("Customize"), NOT_IMPLEMENTED, NULL }, */
+ { NULL, -1, 0 }
+};
+
+static ESearchBarItem emfb_search_scope_items[] = {
+ E_FILTERBAR_ALL_ACCOUNTS,
+ E_FILTERBAR_CURRENT_ACCOUNT,
+ E_FILTERBAR_CURRENT_FOLDER,
+ E_FILTERBAR_CURRENT_MESSAGE,
+ { NULL, -1, 0 }
};
static EMFolderViewClass *emfb_parent;
@@ -189,12 +249,136 @@ free_one_ui_file (gpointer data,
g_free (data);
}
+static char *
+string_without_underscores (const char *s)
+{
+ char *new_string;
+ const char *sp;
+ char *dp;
+
+ new_string = g_malloc (strlen (s) + 1);
+
+ dp = new_string;
+ for (sp = s; *sp != '\0'; sp ++) {
+ if (*sp != '_') {
+ *dp = *sp;
+ dp ++;
+ } else if (sp[1] == '_') {
+ /* Translate "__" in "_". */
+ *dp = '_';
+ dp ++;
+ sp ++;
+ }
+ }
+ *dp = 0;
+
+ return new_string;
+}
+
+static GtkWidget *
+generate_viewoption_menu ()
+{
+ GtkWidget *menu, *menu_item;
+ gint i = 0;
+ GSList *l;
+
+ menu = gtk_menu_new ();
+
+ for (i = 0; emfb_view_items[i].id != -1; ++i) {
+ if (emfb_view_items[i].text) {
+ char *str;
+ str = string_without_underscores (emfb_view_items[i].text);
+ menu_item = gtk_menu_item_new_with_label (str);
+ g_free (str);
+ } else {
+ menu_item = gtk_menu_item_new ();
+ gtk_widget_set_sensitive (menu_item, FALSE);
+ }
+
+ g_object_set_data (G_OBJECT (menu_item), "EsbItemId",
+ GINT_TO_POINTER (emfb_view_items[i].id));
+
+ gtk_widget_show (menu_item);
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
+ }
+
+ /* Add the labels */
+ for (l = mail_config_get_labels(); l; l = l->next) {
+ MailConfigLabel *label = l->data;
+ if (label->name && *(label->name)) {
+ char *str;
+ str = string_without_underscores (label->name);
+ menu_item = gtk_menu_item_new_with_label (str);
+ g_free (str);
+
+ g_object_set_data (G_OBJECT (menu_item), "EsbItemId",
+ GINT_TO_POINTER (VIEW_LABEL));
+
+ g_object_set_data (G_OBJECT (menu_item), "LabelTag",
+ g_strdup(label->tag));
+ }
+
+ gtk_widget_show (menu_item);
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
+ }
+
+ for (i = 0; temp_view_items[i].id != -1; ++i) {
+ if (temp_view_items[i].text) {
+ char *str;
+ str = string_without_underscores (temp_view_items[i].text);
+ menu_item = gtk_menu_item_new_with_label (str);
+ g_free (str);
+ } else {
+ menu_item = gtk_menu_item_new ();
+ gtk_widget_set_sensitive (menu_item, FALSE);
+ }
+
+ g_object_set_data (G_OBJECT (menu_item), "EsbItemId",
+ GINT_TO_POINTER (temp_view_items[i].id));
+
+ gtk_widget_show (menu_item);
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
+ }
+
+ return menu;
+}
+
+
+static GArray *
+viewoption_menu_generator ()
+{
+ GArray *menu = g_array_new (FALSE, FALSE, sizeof (ESearchBarItem));
+ gint i = 0;
+ ESearchBarItem dup_item;
+ GSList *l;
+
+ for (i = 0; emfb_view_items[i].id != -1; i++)
+ g_array_append_vals (menu, &emfb_view_items[i], 1);
+
+ for (l = mail_config_get_labels(); l; l = l->next) {
+ ESearchBarItem item;
+ MailConfigLabel *label = l->data;
+
+ item.text = label->name;
+ item.id = VIEW_LABEL;
+
+ g_array_append_vals (menu, &item, 1);
+ }
+
+ dup_item.id = -1;
+ dup_item.text = NULL;
+ g_array_append_vals (menu, &dup_item, 1);
+
+ return menu;
+}
+
static void
emfb_init(GObject *o)
{
EMFolderBrowser *emfb = (EMFolderBrowser *)o;
RuleContext *search_context = mail_component_peek_search_context (mail_component_peek ());
struct _EMFolderBrowserPrivate *p;
+ GtkWidget *menu;
p = emfb->priv = g_malloc0(sizeof(struct _EMFolderBrowserPrivate));
@@ -222,9 +406,13 @@ emfb_init(GObject *o)
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");
-
+
emfb->search = e_filter_bar_new(search_context, systemrules, userrules, emfb_search_config_search, emfb);
e_search_bar_set_menu ((ESearchBar *)emfb->search, emfb_search_items);
+ e_search_bar_set_scopeoption ((ESearchBar *)emfb->search, emfb_search_scope_items);
+
+ menu = generate_viewoption_menu();
+ e_search_bar_set_viewoption_menu ((ESearchBar *)emfb->search, menu);
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);
@@ -261,6 +449,7 @@ emfb_init(GObject *o)
g_signal_connect (((EMFolderView *) emfb)->list->tree, "key_press", G_CALLBACK(emfb_list_key_press), emfb);
g_signal_connect (((EMFolderView *) emfb)->list, "message_selected", G_CALLBACK (emfb_list_message_selected), emfb);
+
}
static void
@@ -305,6 +494,27 @@ emfb_class_init(GObjectClass *klass)
{
klass->finalize = emfb_finalise;
+ folder_browser_signals[ACCOUNT_SEARCH_ACTIVATED] =
+ g_signal_new ("account_search_activated",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EMFolderBrowserClass, account_search_activated),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE, 1, G_TYPE_STRING);
+
+ folder_browser_signals[ACCOUNT_SEARCH_CLEARED] =
+ g_signal_new ("account_search_cleared",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EMFolderBrowserClass, account_search_cleared),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE, 1, G_TYPE_STRING);
+
+
((GtkObjectClass *)klass)->destroy = emfb_destroy;
((EMFolderViewClass *)klass)->set_folder = emfb_set_folder;
((EMFolderViewClass *)klass)->activate = emfb_activate;
@@ -465,7 +675,7 @@ emfb_search_config_search(EFilterBar *efb, FilterRule *rule, int id, const char
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) {
@@ -502,40 +712,360 @@ emfb_search_config_search(EFilterBar *efb, FilterRule *rule, int id, const char
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)
+{
+ char *view_sexp = NULL;
+ gint id;
+ GtkWidget *menu_item;
+ char *tag;
+
+ /* Get the current selected view */
+ id = e_search_bar_get_viewitem_id (esb);
+ menu_item = e_search_bar_get_selected_viewitem (esb);
+
+ switch (id) {
+ case VIEW_ALL_MESSAGES:
+ 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:
+ view_sexp = "(match-all (> (get-received-date) (- (get-current-date) 86400)))";
+ break;
+ case VIEW_LAST_FIVE_DAYS:
+ view_sexp = " (match-all (> (get-received-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:
+ /* FIXME : cannot hard code this query */
+ view_sexp = "(and (match-all (not (= (user-tag \"label\") \"important\")))"
+ "(match-all (not (= (user-tag \"label\") \"work\"))) (match-all (not (= (user-tag \"label\") \"personal\")))"
+ "(match-all (not (= (user-tag \"label\") \"todo\"))) (match-all (not (= (user-tag \"label\") \"later\"))) ))";
+ break;
+ case VIEW_LABEL:
+ tag = (char *)g_object_get_data (G_OBJECT (menu_item), "LabelTag");
+ view_sexp = g_strdup_printf ("(match-all (= (user-tag \"label\") \"%s\"))",tag);
+ break;
+ case VIEW_ANY_FIELD_CONTAINS:
+ break;
+
+ case VIEW_CUSTOMIZE:
+ view_sexp = " ";
+ break;
+ }
+ return view_sexp;
+}
+
+
+struct _setup_msg {
+ struct _mail_msg msg;
+
+ CamelFolder *folder;
+ char *query;
+ GList *sources_uri;
+ GList *sources_folder;
+};
+
+static char *
+vfolder_setup_desc(struct _mail_msg *mm, int done)
+{
+ struct _setup_msg *m = (struct _setup_msg *)mm;
+
+ return g_strdup(_("Searching"));
+}
+
+static void
+vfolder_setup_do(struct _mail_msg *mm)
+{
+ struct _setup_msg *m = (struct _setup_msg *)mm;
+ GList *l, *list = NULL;
+ CamelFolder *folder;
+
+ d(printf("Setting up Search Folder: %s\n", m->folder->full_name));
+
+ camel_vee_folder_set_expression((CamelVeeFolder *)m->folder, m->query);
+
+ l = m->sources_uri;
+ while (l) {
+ d(printf(" Adding uri: %s\n", (char *)l->data));
+ folder = mail_tool_uri_to_folder (l->data, 0, &mm->ex);
+ if (folder) {
+ list = g_list_append(list, folder);
+ } else {
+ g_warning("Could not open vfolder source: %s", (char *)l->data);
+ camel_exception_clear(&mm->ex);
+ }
+ l = l->next;
+ }
+
+ l = m->sources_folder;
+ while (l) {
+ d(printf(" Adding folder: %s\n", ((CamelFolder *)l->data)->full_name));
+ camel_object_ref(l->data);
+ list = g_list_append(list, l->data);
+ l = l->next;
+ }
+
+ camel_vee_folder_set_folders((CamelVeeFolder *)m->folder, list);
+
+ l = list;
+ while (l) {
+ camel_object_unref(l->data);
+ l = l->next;
+ }
+ g_list_free(list);
+}
+
+static void
+vfolder_setup_done(struct _mail_msg *mm)
+{
+ struct _setup_msg *m = (struct _setup_msg *)mm;
+
+ m = m;
+}
+
+static void
+vfolder_setup_free (struct _mail_msg *mm)
+{
+ struct _setup_msg *m = (struct _setup_msg *)mm;
+ GList *l;
+
+ camel_object_unref(m->folder);
+ g_free(m->query);
+
+ l = m->sources_uri;
+ while (l) {
+ g_free(l->data);
+ l = l->next;
+ }
+ g_list_free(m->sources_uri);
+
+ l = m->sources_folder;
+ while (l) {
+ camel_object_unref(l->data);
+ l = l->next;
+ }
+ g_list_free(m->sources_folder);
+}
+
+static struct _mail_msg_op vfolder_setup_op = {
+ vfolder_setup_desc,
+ vfolder_setup_do,
+ vfolder_setup_done,
+ vfolder_setup_free,
+};
+
+/* sources_uri should be camel uri's */
+static int
+vfolder_setup(CamelFolder *folder, const char *query, GList *sources_uri, GList *sources_folder)
+{
+ struct _setup_msg *m;
+ int id;
+
+ m = mail_msg_new(&vfolder_setup_op, NULL, sizeof (*m));
+ m->folder = folder;
+ camel_object_ref(folder);
+ m->query = g_strdup(query);
+ m->sources_uri = sources_uri;
+ m->sources_folder = sources_folder;
+
+ id = m->msg.seq;
+ e_thread_put(mail_thread_queued_slow, (EMsg *)m);
+
+ return id;
+}
+
static void
emfb_search_search_activated(ESearchBar *esb, EMFolderBrowser *emfb)
{
EMFolderView *emfv = (EMFolderView *) emfb;
- char *search_word, *search_state;
-
+ EFilterBar *efb = (EFilterBar *)esb;
+ char *search_state, *view_sexp, *folder_uri;
+ char *word = NULL, *storeuri = NULL, *search_word = NULL;;
+ gint id, i;
+ CamelFolder *folder;
+ CamelStore *store;
+ GPtrArray *folders;
+ GList *folder_list_account = NULL ;
+ GList *l, *folder_list = NULL ;
+ CamelException *ex;
+
+ ex = camel_exception_new ();
+
if (emfv->list == NULL || emfv->folder == NULL)
return;
+ id = e_search_bar_get_search_scope (esb);
+
+ switch (id) {
+ case E_FILTERBAR_CURRENT_MESSAGE_ID:
+ word = e_search_bar_get_text (esb);
+ if ( word && *word ) {
+ gtk_widget_set_sensitive (esb->option_button, FALSE);
+ em_format_html_display_search_with (emfb->view.preview, word);
+ } else {
+ em_format_html_display_search_close (emfb->view.preview);
+ }
+ return;
+ break;
+
+ case E_FILTERBAR_CURRENT_FOLDER_ID:
+ g_object_get (esb, "query", &search_word, NULL);
+ break;
+
+ case E_FILTERBAR_CURRENT_ACCOUNT_ID:
+ word = e_search_bar_get_text (esb);
+ if (!(word && *word)) {
+ g_signal_emit (emfb, folder_browser_signals [ACCOUNT_SEARCH_CLEARED], 0);
+ gtk_widget_set_sensitive (esb->scopeoption, TRUE);
+ break;
+ }
+
+ gtk_widget_set_sensitive (esb->scopeoption, FALSE);
+
+ /* Disable the folder tree */
+ g_signal_emit (emfb, folder_browser_signals [ACCOUNT_SEARCH_ACTIVATED], 0);
+
+ store = emfv->folder->parent_store;
+ if (store->folders) {
+ folders = camel_object_bag_list(store->folders);
+ for (i=0;i<folders->len;i++) {
+ folder = folders->pdata[i];
+ folder_list_account = g_list_append(folder_list_account, folder);
+ }
+ }
+
+ /* Create a camel vee folder */
+ storeuri = g_strdup_printf("vfolder:%s/mail/vfolder", mail_component_peek_base_directory (mail_component_peek ()));
+ vfolder_store = camel_session_get_store (session, storeuri, NULL);
+ efb->account_search_vf = camel_vee_folder_new (vfolder_store,"Account Search",CAMEL_STORE_VEE_FOLDER_AUTO);
+
+ /* Set the search expression */
+ g_object_get (esb, "query", &search_word, NULL);
+
+ vfolder_setup (efb->account_search_vf, search_word, NULL, folder_list_account);
+
+ folder_uri = mail_tools_folder_to_url ((CamelFolder *)efb->account_search_vf);
+ emfb_set_search_folder (emfv, (CamelFolder *)efb->account_search_vf, folder_uri);
+
+/* g_list_free (folder_list_account); */
+/* g_free (folder_uri); */
+/* g_free (storeuri); */
+ break;
+
+ case E_FILTERBAR_ALL_ACCOUNTS_ID:
+ word = e_search_bar_get_text (esb);
+ if (!(word && *word)) {
+ g_signal_emit (emfb, folder_browser_signals [ACCOUNT_SEARCH_CLEARED], 0);
+ gtk_widget_set_sensitive (esb->scopeoption, TRUE);
+ break;
+ }
+
+ gtk_widget_set_sensitive (esb->scopeoption, FALSE);
+ g_signal_emit (emfb, folder_browser_signals [ACCOUNT_SEARCH_ACTIVATED], 0);
+
+ /* Create a camel vee folder */
+ storeuri = g_strdup_printf("vfolder:%s/mail/vfolder", mail_component_peek_base_directory (mail_component_peek ()));
+ vfolder_store = camel_session_get_store (session, storeuri, NULL);
+ efb->all_account_search_vf = camel_vee_folder_new (vfolder_store,"All Account Search",CAMEL_STORE_VEE_FOLDER_AUTO);
+
+ /* Set sexp */
+ g_object_get (esb, "query", &search_word, NULL);
+
+ /* FIXME: there got to be a better way :) */
+
+ /* Add the local folders */
+ l = mail_vfolder_get_sources_local ();
+ while (l) {
+ folder = mail_tool_uri_to_folder ((const char *)l->data, 0,ex);
+ if (folder)
+ folder_list = g_list_append(folder_list, folder);
+ else {
+ g_warning("Could not open vfolder source: %s", (char *)l->data);
+ camel_exception_clear(ex);
+ }
+ l = l->next;
+ }
+
+ /* Add the remote source folder */
+ l = mail_vfolder_get_sources_remote ();
+ while (l) {
+ folder = mail_tool_uri_to_folder ((const char *)l->data, 0,ex);
+ if (folder)
+ folder_list = g_list_append(folder_list, folder);
+ else {
+ g_warning("Could not open vfolder source: %s", (char *)l->data);
+ camel_exception_clear(ex);
+ }
+ l = l->next;
+ }
+
+ vfolder_setup (efb->all_account_search_vf, search_word, NULL, folder_list);
+
+ folder_uri = mail_tools_folder_to_url ((CamelFolder *)efb->all_account_search_vf);
+ emfb_set_search_folder (emfv, (CamelFolder *)efb->all_account_search_vf, folder_uri);
+
+ g_list_free (l);
+ break;
+ }
+
+ /* Merge the view and search expresion*/
+ view_sexp = get_view_query (esb);
g_object_get (esb, "query", &search_word, NULL);
+
+ if (search_word && *search_word)
+ search_word = g_strconcat ("(and ", view_sexp, search_word, " )", NULL);
+ else
+ search_word = g_strdup (view_sexp);
+
message_list_set_search(emfb->view.list, search_word);
- g_free (search_word);
-
+
+ /* Fixme */
g_object_get (esb, "state", &search_state, NULL);
camel_object_meta_set (emfv->folder, "evolution:search_state", search_state);
camel_object_state_write (emfv->folder);
- g_free (search_state);
+
+ camel_exception_free (ex);
}
static void
emfb_search_query_changed(ESearchBar *esb, EMFolderBrowser *emfb)
{
- int id;
+ int search_scope;
+ int item_id;
+
+ search_scope = e_search_bar_get_search_scope (esb);
+ item_id = e_search_bar_get_item_id (esb);
+
+ /* Close the current message search bar */
+ if ( search_scope != E_FILTERBAR_CURRENT_MESSAGE_ID ) {
+ em_format_html_display_search_close (emfb->view.preview);
+ gtk_widget_set_sensitive (esb->option_button, TRUE);
+ } else
+ gtk_widget_set_sensitive (esb->option_button, FALSE);
- id = e_search_bar_get_item_id(esb);
- if (id == E_FILTERBAR_ADVANCED_ID)
- emfb_search_search_activated(esb, emfb);
+ switch (item_id) {
+ case E_FILTERBAR_ADVANCED_ID:
+ emfb_search_search_activated(esb, emfb);
+ break;
+ }
}
/* ********************************************************************** */
@@ -581,12 +1111,12 @@ emfb_edit_cut(BonoboUIComponent *uid, void *data, const char *path)
/* TODO: pity we can't sucblass this method, ugh, virtualise it? */
- if (GTK_WIDGET_HAS_FOCUS(((ESearchBar *)emfb->search)->entry))
- gtk_editable_cut_clipboard((GtkEditable *)((ESearchBar *)emfb->search)->entry);
- else if (GTK_WIDGET_HAS_FOCUS(emfb->view.preview->formathtml.html))
- em_format_html_display_cut(emfb->view.preview);
- else
- message_list_copy(emfb->view.list, TRUE);
+/* if (GTK_HAS_FOCUS(((ESearchBar *)emfb->search)->entry)) */
+/* gtk_editable_cut_clipboard((GtkEditable *)((ESearchBar *)emfb->search)->entry); */
+/* else if (GTK_WIDGET_HAS_FOCUS(emfb->view.preview->formathtml.html)) */
+/* em_format_html_display_cut(emfb->view.preview); */
+/* else */
+/* message_list_copy(emfb->view.list, TRUE); */
}
static void
@@ -1143,6 +1673,42 @@ emfb_list_built (MessageList *ml, EMFolderBrowser *emfb)
}
static void
+emfb_set_search_folder(EMFolderView *emfv, CamelFolder *folder, const char *uri)
+{
+ EMFolderBrowser *emfb = (EMFolderBrowser *) emfv;
+
+ message_list_freeze(emfv->list);
+
+ if (emfb->priv->list_scrolled_id) {
+ g_signal_handler_disconnect (emfv->list, emfb->priv->list_scrolled_id);
+ emfb->priv->list_scrolled_id = 0;
+ }
+
+ if (emfb->priv->idle_scroll_id) {
+ g_source_remove (emfb->priv->idle_scroll_id);
+ emfb->priv->idle_scroll_id = 0;
+ }
+
+ if (emfb->view.folder) {
+ camel_object_remove_event(emfb->view.folder, emfb->priv->folder_changed_id);
+ emfb->priv->folder_changed_id = 0;
+ }
+
+ emfb_parent->set_folder(emfv, folder, uri);
+
+ /* etspec for search results */
+ char *state = "<ETableState>"
+ "<column source=\"0\"/> <column source=\"3\"/> <column source=\"1\"/>"
+ "<column source=\"14\"/> <column source=\"5\"/>"
+ "<column source=\"7\"/> <column source=\"13\"/> "
+ "<grouping> </grouping> </ETableState>";
+ e_tree_set_state (((MessageList *)emfv->list)->tree, state);
+
+ message_list_thaw(emfv->list);
+}
+
+
+static void
emfb_set_folder(EMFolderView *emfv, CamelFolder *folder, const char *uri)
{
EMFolderBrowser *emfb = (EMFolderBrowser *) emfv;
@@ -1207,9 +1773,10 @@ emfb_set_folder(EMFolderView *emfv, CamelFolder *folder, const char *uri)
bonobo_ui_component_set_prop(emfv->uic, "/commands/HideDeleted", "sensitive", state?"1":"0", NULL);
}
- sstate = camel_object_meta_get(folder, "evolution:search_state");
- g_object_set(emfb->search, "state", sstate, NULL);
- g_free(sstate);
+ /* Fixme */
+/* sstate = camel_object_meta_get(folder, "evolution:search_state"); */
+/* g_object_set(emfb->search, "state", sstate, NULL); */
+/* g_free(sstate); */
/* set the query manually, so we dont pop up advanced or saved search stuff */
g_object_get(emfb->search, "query", &sstate, NULL);