aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSrinivasa Ragavan <sragavan@src.gnome.org>2006-09-29 15:37:56 +0800
committerSrinivasa Ragavan <sragavan@src.gnome.org>2006-09-29 15:37:56 +0800
commit1992a65ef8d2a2ff0aad65b708c4eb023c53caaa (patch)
treebb95ffd8544b5956f61ada1ce2abab4b7036bb48
parent0e5cccbd8a13b407422e2c1bdd2f3228bc87506b (diff)
downloadgsoc2013-evolution-1992a65ef8d2a2ff0aad65b708c4eb023c53caaa.tar
gsoc2013-evolution-1992a65ef8d2a2ff0aad65b708c4eb023c53caaa.tar.gz
gsoc2013-evolution-1992a65ef8d2a2ff0aad65b708c4eb023c53caaa.tar.bz2
gsoc2013-evolution-1992a65ef8d2a2ff0aad65b708c4eb023c53caaa.tar.lz
gsoc2013-evolution-1992a65ef8d2a2ff0aad65b708c4eb023c53caaa.tar.xz
gsoc2013-evolution-1992a65ef8d2a2ff0aad65b708c4eb023c53caaa.tar.zst
gsoc2013-evolution-1992a65ef8d2a2ff0aad65b708c4eb023c53caaa.zip
Fixes a lot of search issues.
svn path=/trunk/; revision=32821
-rw-r--r--mail/ChangeLog8
-rw-r--r--mail/em-folder-browser.c194
-rw-r--r--widgets/misc/ChangeLog16
-rw-r--r--widgets/misc/e-filter-bar.c124
-rw-r--r--widgets/misc/e-search-bar.c117
-rw-r--r--widgets/misc/e-search-bar.h6
6 files changed, 316 insertions, 149 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 231789dd8a..21dd6c728a 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,11 @@
+2006-09-29 Srinivasa Ragavan <sragavan@novell.com>
+
+ ** Fixes a lot of search issue.
+
+ * em-folder-browser.c: (emfb_init), (em_folder_browser_show_wide),
+ (vfolder_setup_desc), (emfb_search_search_activated),
+ (emfb_edit_cut), (emfb_edit_select_all), (emfb_set_folder):
+
2006-09-28 Srinivasa Ragavan <sragavan@novell.com>
** Pushing a downstream fix in SUSE.
diff --git a/mail/em-folder-browser.c b/mail/em-folder-browser.c
index 82ac86801f..b995b31631 100644
--- a/mail/em-folder-browser.c
+++ b/mail/em-folder-browser.c
@@ -372,7 +372,7 @@ generate_viewoption_menu (GtkWidget *emfv)
return menu;
}
-
+#if 0
static GArray *
viewoption_menu_generator ()
{
@@ -400,6 +400,7 @@ viewoption_menu_generator ()
return menu;
}
+#endif
static void
emfb_realize (GtkWidget *widget)
@@ -417,7 +418,6 @@ 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));
@@ -445,8 +445,12 @@ 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");
-
+ EFilterBar *efb;
+
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;
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);
@@ -456,7 +460,7 @@ emfb_init(GObject *o)
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);
- p->search_query_changed_id = g_signal_connect(emfb->search, "query_changed", G_CALLBACK(emfb_search_query_changed), emfb);
+/* p->search_query_changed_id = g_signal_connect(emfb->search, "query_changed", G_CALLBACK(emfb_search_query_changed), 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);
@@ -681,7 +685,7 @@ void em_folder_browser_show_wide(EMFolderBrowser *emfb, gboolean state)
gtk_widget_reparent((GtkWidget *)emfb->view.list, w);
gtk_widget_reparent((GtkWidget *)emfb->priv->preview, w);
gtk_widget_destroy(emfb->vpane);
- gtk_container_resize_children (w);
+ gtk_container_resize_children ((GtkContainer *)w);
emfb->vpane = w;
gtk_widget_show(w);
@@ -847,8 +851,6 @@ struct _setup_msg {
static char *
vfolder_setup_desc(struct _mail_msg *mm, int done)
{
- struct _setup_msg *m = (struct _setup_msg *)mm;
-
return g_strdup(_("Searching"));
}
@@ -958,7 +960,7 @@ emfb_search_search_activated(ESearchBar *esb, EMFolderBrowser *emfb)
{
EMFolderView *emfv = (EMFolderView *) emfb;
EFilterBar *efb = (EFilterBar *)esb;
- char *search_state, *view_sexp, *folder_uri;
+ char *search_state, *view_sexp, *folder_uri=NULL;
char *word = NULL, *storeuri = NULL, *search_word = NULL;;
gint id, i;
CamelFolder *folder;
@@ -994,100 +996,130 @@ emfb_search_search_activated(ESearchBar *esb, EMFolderBrowser *emfb)
word = e_search_bar_get_text (esb);
if (!(word && *word)) {
mail_cancel_all ();
+ if (efb->account_search_vf) {
+ camel_object_unref (efb->account_search_vf);
+ efb->account_search_vf = NULL;
+ }
g_signal_emit (emfb, folder_browser_signals [ACCOUNT_SEARCH_CLEARED], 0);
gtk_widget_set_sensitive (esb->scopeoption, TRUE);
break;
}
+ g_object_get (esb, "query", &search_word, NULL);
+ if (efb->account_search_vf && !strcmp (search_word, ((CamelVeeFolder *) efb->account_search_vf)->expression) ) {
+ 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);
+ if (!efb->account_search_vf) {
+ 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);
+ /* 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 = (CamelVeeFolder *)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);
+ /* Set the search expression */
- vfolder_setup (efb->account_search_vf, search_word, NULL, folder_list_account);
+ vfolder_setup ((CamelFolder *)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); */
+ 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_free (folder_uri);
+ g_free (storeuri);
+ } else {
+ /* Reuse the existing search folder */
+ camel_vee_folder_set_expression((CamelVeeFolder *)efb->account_search_vf, search_word);
+ }
+
break;
case E_FILTERBAR_ALL_ACCOUNTS_ID:
word = e_search_bar_get_text (esb);
if (!(word && *word)) {
- mail_cancel_all ();
+ mail_cancel_all ();
+ if (efb->all_account_search_vf) {
+ camel_object_unref (efb->all_account_search_vf);
+ efb->all_account_search_vf=NULL;
+ }
g_signal_emit (emfb, folder_browser_signals [ACCOUNT_SEARCH_CLEARED], 0);
gtk_widget_set_sensitive (esb->scopeoption, TRUE);
break;
}
+
+ g_object_get (esb, "query", &search_word, NULL);
+
+ if (efb->all_account_search_vf && !strcmp (search_word, ((CamelVeeFolder *) efb->all_account_search_vf)->expression) ) {
+ /* No real search apart from the existing one */
+ 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);
+ if (!efb->all_account_search_vf) {
+ /* 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 = (CamelVeeFolder *)camel_vee_folder_new (vfolder_store,_("All Account Search"),CAMEL_STORE_VEE_FOLDER_AUTO);
+
+ /* Set sexp */
+
+ /* 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;
}
- 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);
+ /* 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;
}
- 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);
+ vfolder_setup ((CamelFolder *)efb->all_account_search_vf, search_word, NULL, folder_list);
- g_list_free (l);
+ 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_free (folder_uri);
+ g_free (storeuri);
+ } else {
+ /* Reuse the existing search folder */
+ camel_vee_folder_set_expression((CamelVeeFolder *)efb->all_account_search_vf, search_word);
+ }
+
break;
}
-
+ 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);
+
/* Merge the view and search expresion*/
view_sexp = get_view_query (esb);
g_object_get (esb, "query", &search_word, NULL);
@@ -1099,10 +1131,7 @@ emfb_search_search_activated(ESearchBar *esb, EMFolderBrowser *emfb)
message_list_set_search(emfb->view.list, 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);
+
camel_exception_free (ex);
}
@@ -1188,12 +1217,12 @@ emfb_edit_cut(BonoboUIComponent *uid, void *data, const char *path)
/* TODO: pity we can't sucblass this method, ugh, virtualise it? */
-/* 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); */
+ 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);
}
static void
@@ -1234,7 +1263,7 @@ emfb_edit_select_all(BonoboUIComponent *uid, void *data, const char *path)
EMFolderView *emfv = data;
message_list_select_all(emfv->list);
- gtk_widget_grab_focus (emfv->list);
+ gtk_widget_grab_focus ((GtkWidget *)emfv->list);
}
static void
@@ -1850,14 +1879,11 @@ emfb_set_folder(EMFolderView *emfv, CamelFolder *folder, const char *uri)
}
/* Fixme */
-/* sstate = camel_object_meta_get(folder, "evolution:search_state"); */
-/* g_object_set(emfb->search, "state", sstate, NULL); */
-/* g_free(sstate); */
+ 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);
- message_list_set_search(emfb->view.list, sstate);
- g_free(sstate);
if ((sstate = camel_object_meta_get (folder, "evolution:selected_uid"))) {
emfb->priv->select_uid = sstate;
diff --git a/widgets/misc/ChangeLog b/widgets/misc/ChangeLog
index 615912f4e8..3776029d95 100644
--- a/widgets/misc/ChangeLog
+++ b/widgets/misc/ChangeLog
@@ -1,5 +1,21 @@
2006-09-29 Srinivasa Ragavan <sragavan@novell.com>
+ ** Fixes a lot of search issues.
+
+ * e-filter-bar.c: (rule_advanced_response), (do_advanced),
+ (menubar_activated), (option_changed), (free_items),
+ (get_property), (set_property):
+ * e-search-bar.c: (clear_search), (clear_verb_cb),
+ (paint_search_text), (e_search_bar_paint), (viewitem_activated_cb),
+ (scopeitem_activated_cb), (option_activated_cb),
+ (clear_button_clicked_cb), (scopeoption_changed_cb), (set_option),
+ (init), (e_search_bar_construct), (e_search_bar_set_viewitem_id),
+ (e_search_bar_set_item_id), (e_search_bar_set_item_menu),
+ (e_search_bar_set_search_scope), (e_search_bar_set_ids):
+ * e-search-bar.h:
+
+2006-09-29 Srinivasa Ragavan <sragavan@novell.com>
+
** Fixes bug #341474 patch from Ushveen
* e-attachment-bar.c: (size_to_string): Use
diff --git a/widgets/misc/e-filter-bar.c b/widgets/misc/e-filter-bar.c
index 363a0127ae..ce4ebf2658 100644
--- a/widgets/misc/e-filter-bar.c
+++ b/widgets/misc/e-filter-bar.c
@@ -107,7 +107,7 @@ rule_advanced_response (GtkWidget *dialog, int response, void *data)
{
EFilterBar *efb = data;
/* the below generates a compiler warning about incompatible pointer types */
- ESearchBar *esb = efb;
+ ESearchBar *esb = (ESearchBar *)efb;
FilterRule *rule;
if (response == GTK_RESPONSE_OK || response == GTK_RESPONSE_APPLY) {
@@ -157,8 +157,10 @@ do_advanced (ESearchBar *esb)
if (efb->current_query)
rule = filter_rule_clone (efb->current_query);
- else
+ else {
rule = filter_rule_new ();
+ efb->current_query = rule;
+ }
w = filter_rule_get_widget (rule, efb->context);
filter_rule_set_source (rule, FILTER_SOURCE_INCOMING);
@@ -239,7 +241,7 @@ static void
menubar_activated (ESearchBar *esb, int id, void *data)
{
EFilterBar *efb = (EFilterBar *)esb;
- GtkWidget *dialog, *w;
+ GtkWidget *dialog;
d(printf ("menubar activated!\n"));
@@ -294,7 +296,13 @@ option_changed (ESearchBar *esb, void *data)
int id = e_search_bar_get_item_id (esb);
char *query;
- d(printf("option changed, id = %d, setquery = %s\n", id, efb->setquery ? "true" : "false"));
+ d(printf("option changed, id = %d, setquery = %s %d\n", id, efb->setquery ? "true" : "false", esb->block_search));
+
+ if (esb->scopeitem_id == E_FILTERBAR_CURRENT_MESSAGE_ID) {
+ gtk_widget_set_sensitive (esb->option_button, FALSE);
+ } else {
+ gtk_widget_set_sensitive (esb->option_button, TRUE);
+ }
if (efb->setquery)
return;
@@ -306,7 +314,8 @@ option_changed (ESearchBar *esb, void *data)
break;
case E_FILTERBAR_ADVANCED_ID:
d(printf ("do_advanced\n"));
- do_advanced (esb);
+ if (!esb->block_search)
+ do_advanced (esb);
break;
default:
if (id >= efb->option_base && id < efb->option_base + efb->option_rules->len) {
@@ -321,6 +330,7 @@ option_changed (ESearchBar *esb, void *data)
gtk_widget_modify_text (esb->entry, GTK_STATE_NORMAL, NULL);
gtk_widget_modify_base (esb->icon_entry, GTK_STATE_NORMAL, NULL);
efb->current_query = NULL;
+ gtk_entry_set_text ((GtkEntry *)esb->entry, "");
}
}
}
@@ -464,7 +474,7 @@ generate_menu (ESearchBar *esb, ESearchBarItem *items)
static void
free_items (ESearchBarItem *items)
{
- int i, j;
+ int i;
for (i = 0; items[i].id != -1; i++)
g_free (items[i].text);
@@ -549,6 +559,7 @@ static void
get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
{
EFilterBar *efb = (EFilterBar *) object;
+ ESearchBar *esb = E_SEARCH_BAR (object);
switch (property_id) {
case PROP_QUERY:
@@ -565,7 +576,7 @@ get_property (GObject *object, guint property_id, GValue *value, GParamSpec *psp
case PROP_STATE: {
/* FIXME: we should have ESearchBar save its own state to the xmlDocPtr */
char *xmlbuf, *text, buf[12];
- int searchscope, item_id, n;
+ int searchscope, item_id, n, view_id;
xmlNodePtr root, node;
xmlDocPtr doc;
@@ -574,15 +585,27 @@ get_property (GObject *object, guint property_id, GValue *value, GParamSpec *psp
doc = xmlNewDoc ("1.0");
root = xmlNewDocNode (doc, NULL, "state", NULL);
xmlDocSetRootElement (doc, root);
+ searchscope = e_search_bar_get_search_scope ((ESearchBar *) efb);
+ view_id = e_search_bar_get_viewitem_id ((ESearchBar *) efb);
+
+ if (searchscope < E_FILTERBAR_CURRENT_FOLDER_ID)
+ item_id = esb->last_search_option;
if (item_id == E_FILTERBAR_ADVANCED_ID) {
/* advanced query, save the filterbar state */
node = xmlNewChild (root, NULL, "filter-bar", NULL);
- xmlAddChild (node, filter_rule_xml_encode (efb->current_query));
+
+ sprintf (buf, "%d", esb->last_search_option);
+ xmlSetProp (node, "item_id", buf);
+ sprintf (buf, "%d", searchscope);
+ xmlSetProp (node, "searchscope", buf);
+ sprintf (buf, "%d", view_id);
+ xmlSetProp (node, "view_id", buf);
+
+ xmlAddChild (node, filter_rule_xml_encode (efb->current_query));
} else {
/* simple query, save the searchbar state */
text = e_search_bar_get_text ((ESearchBar *) efb);
- searchscope = e_search_bar_get_search_scope ((ESearchBar *) efb);
node = xmlNewChild (root, NULL, "search-bar", NULL);
xmlSetProp (node, "text", text ? text : "");
@@ -590,6 +613,8 @@ get_property (GObject *object, guint property_id, GValue *value, GParamSpec *psp
xmlSetProp (node, "item_id", buf);
sprintf (buf, "%d", searchscope);
xmlSetProp (node, "searchscope", buf);
+ sprintf (buf, "%d", view_id);
+ xmlSetProp (node, "view_id", buf);
g_free (text);
}
@@ -631,11 +656,12 @@ static void
set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
{
EFilterBar *efb = (EFilterBar *) object;
+ ESearchBar *esb = E_SEARCH_BAR (object);
xmlNodePtr root, node;
const char *state;
xmlDocPtr doc;
-
-
+ gboolean rule_set = FALSE, is_cur_folder=FALSE;
+ int view_id, scope, item_id;
switch (property_id) {
case PROP_STATE:
@@ -653,18 +679,28 @@ set_property (GObject *object, guint property_id, const GValue *value, GParamSpe
while (node != NULL) {
if (!strcmp (node->name, "filter-bar")) {
FilterRule *rule = NULL;
+
+
+ view_id = xml_get_prop_int (node, "view_id");
+ scope = xml_get_prop_int (node, "searchscope");
+ item_id = xml_get_prop_int (node, "item_id");
+
+ if (scope == E_FILTERBAR_CURRENT_FOLDER_ID)
+ is_cur_folder = TRUE;
if ((node = node->children)) {
GtkStyle *style = gtk_widget_get_default_style ();
rule = filter_rule_new ();
- if (filter_rule_xml_decode (rule, node, efb->context) != 0) {
+ if (filter_rule_xml_decode (rule, node, efb->context) != 0) {
gtk_widget_modify_base (((ESearchBar *)efb)->entry, GTK_STATE_NORMAL, NULL);
gtk_widget_modify_text (((ESearchBar *)efb)->entry, GTK_STATE_NORMAL, NULL);
gtk_widget_modify_base (((ESearchBar *)efb)->icon_entry, GTK_STATE_NORMAL, NULL);
g_object_unref (rule);
rule = NULL;
} else {
+ rule_set = TRUE;
+ gtk_widget_set_sensitive (esb->clear_button, TRUE);
gtk_widget_modify_base (((ESearchBar *)efb)->entry, GTK_STATE_NORMAL, &(style->base[GTK_STATE_SELECTED]));
gtk_widget_modify_text (((ESearchBar *)efb)->entry, GTK_STATE_NORMAL, &(style->text[GTK_STATE_SELECTED]));
gtk_widget_modify_base (((ESearchBar *)efb)->icon_entry, GTK_STATE_NORMAL, &(style->base[GTK_STATE_SELECTED]));
@@ -672,23 +708,59 @@ set_property (GObject *object, guint property_id, const GValue *value, GParamSpe
g_object_set_data_full (object, "rule", rule, (GDestroyNotify) g_object_unref);
}
}
-
+
+
+ if (rule_set) {
+ esb->block_search = TRUE;
+ e_search_bar_set_text (esb, _("Advanced Search"));
+ e_search_bar_set_item_menu ((ESearchBar *) efb, item_id);
+ e_search_bar_set_search_scope ((ESearchBar *) efb, scope);
+ esb->block_search = FALSE;
+ efb->current_query = (FilterRule *)efb->option_rules->pdata[item_id - efb->option_base];
+ if (efb->config && efb->current_query) {
+ char *query = e_search_bar_get_text (esb);
+ efb->config (efb, efb->current_query, item_id, query, efb->config_data);
+ g_free (query);
+
+ }
+ }
+ e_search_bar_set_viewitem_id ((ESearchBar *) efb, view_id);
efb->current_query = rule;
-
efb->setquery = TRUE;
- e_search_bar_set_item_id ((ESearchBar *) efb, E_FILTERBAR_ADVANCED_ID);
+ e_search_bar_set_item_id ((ESearchBar *) efb, E_FILTERBAR_ADVANCED_ID);
efb->setquery = FALSE;
break;
} else if (!strcmp (node->name, "search-bar")) {
- int subitem_id, item_id;
+ int subitem_id, item_id, scope, view_id;
char *text;
GtkStyle *style = gtk_widget_get_default_style ();
/* set the text first (it doesn't emit a signal) */
+
+
+ /* now set the item_id and subitem_id */
+ item_id = xml_get_prop_int (node, "item_id");
+ subitem_id = xml_get_prop_int (node, "subitem_id");
+
+ esb->block_search = TRUE;
+ if (subitem_id >= 0)
+ e_search_bar_set_ids ((ESearchBar *) efb, item_id, subitem_id);
+ else
+ e_search_bar_set_item_menu ((ESearchBar *) efb, item_id);
+ esb->block_search = FALSE;
+ view_id = xml_get_prop_int (node, "view_id");
+ e_search_bar_set_viewitem_id ((ESearchBar *) efb, view_id);
+ scope = xml_get_prop_int (node, "searchscope");
+ e_search_bar_set_search_scope ((ESearchBar *) efb, scope);
+
text = xmlGetProp (node, "text");
e_search_bar_set_text ((ESearchBar *) efb, text);
if (text && *text) {
+ efb->current_query = (FilterRule *)efb->option_rules->pdata[item_id - efb->option_base];
+ if (efb->config && efb->current_query)
+ efb->config (efb, efb->current_query, item_id, text, efb->config_data);
+ gtk_widget_set_sensitive (esb->clear_button, TRUE);
gtk_widget_modify_base (((ESearchBar *)efb)->entry, GTK_STATE_NORMAL, &(style->base[GTK_STATE_SELECTED]));
gtk_widget_modify_text (((ESearchBar *)efb)->entry, GTK_STATE_NORMAL, &(style->text[GTK_STATE_SELECTED]));
gtk_widget_modify_base (((ESearchBar *)efb)->icon_entry, GTK_STATE_NORMAL, &(style->base[GTK_STATE_SELECTED]));
@@ -697,18 +769,13 @@ set_property (GObject *object, guint property_id, const GValue *value, GParamSpe
gtk_widget_modify_base (((ESearchBar *)efb)->entry, GTK_STATE_NORMAL, NULL);
gtk_widget_modify_text (((ESearchBar *)efb)->entry, GTK_STATE_NORMAL, NULL);
gtk_widget_modify_base (((ESearchBar *)efb)->icon_entry, GTK_STATE_NORMAL, NULL);
+ e_search_bar_paint (esb);
+ efb->current_query = NULL;
}
- xmlFree (text);
-
- /* now set the item_id and subitem_id */
- item_id = xml_get_prop_int (node, "item_id");
- subitem_id = xml_get_prop_int (node, "subitem_id");
-
- if (subitem_id >= 0)
- e_search_bar_set_ids ((ESearchBar *) efb, item_id, subitem_id);
- else
- e_search_bar_set_item_id ((ESearchBar *) efb, item_id);
+ xmlFree (text);
+
+
break;
}
@@ -718,13 +785,14 @@ set_property (GObject *object, guint property_id, const GValue *value, GParamSpe
xmlFreeDoc (doc);
} else {
/* set default state */
- e_search_bar_set_text ((ESearchBar *) efb, "");
e_search_bar_set_item_id ((ESearchBar *) efb, 0);
+ e_search_bar_set_viewitem_id ((ESearchBar *) efb, 0);
+ e_search_bar_set_search_scope ((ESearchBar *) efb, E_FILTERBAR_CURRENT_FOLDER_ID);
}
/* we don't want to run option_changed */
efb->setquery = TRUE;
- g_signal_emit_by_name (efb, "search-activated", NULL);
+ g_signal_emit_by_name (efb, "search_activated", NULL);
efb->setquery = FALSE;
break;
diff --git a/widgets/misc/e-search-bar.c b/widgets/misc/e-search-bar.c
index 5d771854ca..50969d7078 100644
--- a/widgets/misc/e-search-bar.c
+++ b/widgets/misc/e-search-bar.c
@@ -107,12 +107,14 @@ verb_name_from_id (int id)
static void
clear_search (ESearchBar *esb)
{
+ e_search_bar_set_text (esb, "");
+ esb->block_search = TRUE;
if (esb->item_id < 0)
- e_search_bar_set_item_id (esb, esb->last_search_option);
-
- e_search_bar_set_text (esb, "");
+ e_search_bar_set_item_id (esb, esb->last_search_option);
e_search_bar_set_viewitem_id (esb, 0);
+ esb->block_search = FALSE;
emit_search_activated (esb);
+
}
static void
@@ -212,6 +214,7 @@ clear_verb_cb (BonoboUIComponent *ui_component,
gtk_widget_modify_base (esb->icon_entry, GTK_STATE_NORMAL, NULL);
clear_search (esb);
+ gtk_entry_set_text (GTK_ENTRY (esb->entry), "");
gtk_widget_grab_focus (esb->entry);
}
@@ -302,7 +305,7 @@ paint_search_text (GtkWidget *widget, ESearchBar *esb)
if (!GTK_WIDGET_SENSITIVE (esb->option_button)) {
menu_widget = esb->scopeoption_menu;
- text = g_object_get_data (gtk_menu_get_active ( GTK_MENU (esb->scopeoption_menu)),"string");
+ text = g_object_get_data (G_OBJECT(gtk_menu_get_active ( GTK_MENU (esb->scopeoption_menu))),"string");
} else if (!GTK_IS_RADIO_MENU_ITEM (gtk_menu_get_active ( GTK_MENU (esb->option_menu))))
return FALSE;
else /* no query in search entry .. so set the current option */
@@ -310,8 +313,10 @@ paint_search_text (GtkWidget *widget, ESearchBar *esb)
if (text && *text) {
- gtk_widget_modify_text (esb->entry, GTK_STATE_NORMAL, &(style->text[GTK_STATE_INSENSITIVE]));
- gtk_entry_set_text (GTK_ENTRY (esb->entry), text);
+ if (!GTK_WIDGET_HAS_FOCUS(esb->entry)) {
+ gtk_entry_set_text (GTK_ENTRY (esb->entry), text);
+ gtk_widget_modify_text (esb->entry, GTK_STATE_NORMAL, &(style->text[GTK_STATE_INSENSITIVE]));
+ }
gtk_tooltips_set_tip (esb->tooltips, esb->option_button, text, "Search type");
gtk_widget_set_sensitive (esb->clear_button, FALSE);
}
@@ -319,6 +324,12 @@ paint_search_text (GtkWidget *widget, ESearchBar *esb)
return FALSE;
}
+void
+e_search_bar_paint (ESearchBar *search_bar)
+{
+ paint_search_text (search_bar->entry, search_bar);
+}
+
static gboolean
entry_focus_out_cb (GtkWidget *widget,
GdkEventFocus *event,
@@ -387,7 +398,9 @@ viewitem_activated_cb(GtkWidget *widget, ESearchBar *esb)
gtk_widget_modify_text (esb->entry, GTK_STATE_NORMAL, NULL);
}
+ esb->block_search = TRUE;
emit_search_activated (esb);
+ esb->block_search = FALSE;
}
static void
@@ -406,11 +419,14 @@ scopeitem_activated_cb(GtkWidget *widget, ESearchBar *esb)
/* If the text is grayed, Its not the query string */
if (gdk_color_equal (&(entry_style->text[GTK_STATE_NORMAL]), &(default_style->text[GTK_STATE_INSENSITIVE]))) {
+ gtk_widget_grab_focus (esb->entry);
gtk_entry_set_text (GTK_ENTRY (esb->entry), "");
gtk_widget_modify_text (esb->entry, GTK_STATE_NORMAL, NULL);
}
+ esb->block_search = TRUE;
emit_search_activated (esb);
+ esb->block_search = FALSE;
}
static char *
@@ -443,12 +459,12 @@ static void
option_activated_cb (GtkWidget *widget,
ESearchBar *esb)
{
-/* int id; */
-
-/* id = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "EsbItemId")); */
+ int id;
+ const char *text;
+
+ id = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "EsbItemId"));
-/* esb->item_id = id; */
- char *text;
+ e_search_bar_set_item_id (esb, id);
if (GTK_IS_RADIO_MENU_ITEM (gtk_menu_get_active ( GTK_MENU (esb->option_menu)))) {
text = get_selected_item_label (esb->option_menu);
@@ -456,8 +472,12 @@ option_activated_cb (GtkWidget *widget,
gtk_tooltips_set_tip (esb->tooltips, esb->option_button, text, "Search type");
}
- emit_query_changed (esb);
- emit_search_activated (esb);
+ if (!esb->block_search) {
+ emit_query_changed (esb);
+ }
+ if (!esb->block_search && id > 0) {
+ emit_search_activated (esb);
+ }
}
static void
@@ -478,7 +498,7 @@ clear_button_clicked_cb (GtkWidget *widget, GdkEventButton *event,
gtk_widget_modify_base (esb->icon_entry, GTK_STATE_NORMAL, NULL);
clear_search (esb);
-
+ gtk_entry_set_text (GTK_ENTRY (esb->entry), "");
gtk_widget_grab_focus (esb->entry);
}
@@ -496,21 +516,24 @@ entry_key_press_cb (GtkWidget *widget,
return FALSE;
}
+#if 0
static void
scopeoption_changed_cb (GtkWidget *option_menu, ESearchBar *search_bar)
{
const gchar *text = NULL;
- GtkStyle *style = gtk_widget_get_default_style ();
text = e_search_bar_get_text (search_bar);
if (!(text && *text))
gtk_widget_grab_focus (search_bar->entry);
-
- emit_query_changed (search_bar);
+
+ if(!search_bar->block_search)
+ emit_query_changed (search_bar);
}
+#endif
/* Widgetry creation. */
+#if 0
/* This function exists to fix the irreparable GtkOptionMenu stupidity. In
fact, this lame-ass widget adds a 1-pixel-wide empty border around the
button for no reason. So we have add a 1-pixel-wide border around the the
@@ -527,6 +550,7 @@ put_in_spacer_widget (GtkWidget *widget)
return holder;
}
+#endif
static void
append_xml_menu_item (GString *xml,
@@ -705,7 +729,7 @@ set_option (ESearchBar *esb, ESearchBarItem *items)
}
gtk_widget_show_all (menu);
- g_object_set_data (esb->option_menu, "group", group);
+ g_object_set_data (G_OBJECT(esb->option_menu), "group", group);
entry_focus_out_cb (esb->entry, NULL, esb);
}
@@ -903,6 +927,7 @@ init (ESearchBar *esb)
esb->item_id = 0;
esb->scopeitem_id = 0;
esb->last_search_option = 0;
+ esb->block_search = FALSE;
}
@@ -951,11 +976,11 @@ e_search_bar_construct (ESearchBar *search_bar,
G_CALLBACK (entry_key_press_cb), search_bar);
search_bar->clear_button = e_icon_entry_create_button ("gtk-clear");
- g_signal_connect (G_OBJECT (search_bar->clear_button), "button-press-event", clear_button_clicked_cb, search_bar);
+ g_signal_connect (G_OBJECT (search_bar->clear_button), "button-press-event", G_CALLBACK(clear_button_clicked_cb), search_bar);
e_icon_entry_pack_widget (E_ICON_ENTRY (search_bar->icon_entry), search_bar->clear_button, FALSE);
search_bar->option_button = e_icon_entry_create_button ("gtk-find");
- g_signal_connect (G_OBJECT (search_bar->option_button), "button-press-event", option_button_clicked_cb, search_bar);
+ g_signal_connect (G_OBJECT (search_bar->option_button), "button-press-event", G_CALLBACK(option_button_clicked_cb), search_bar);
e_icon_entry_pack_widget (E_ICON_ENTRY (search_bar->icon_entry), search_bar->option_button, TRUE);
gtk_box_pack_start (GTK_BOX(search_bar->entry_box), search_bar->icon_entry, FALSE, FALSE, 0);
@@ -973,7 +998,7 @@ e_search_bar_construct (ESearchBar *search_bar,
gtk_box_pack_start (GTK_BOX(search_bar->viewoption_box), label, FALSE, FALSE, 0);
search_bar->viewoption = gtk_option_menu_new ();
- gtk_label_set_mnemonic_widget (label, search_bar->viewoption);
+ gtk_label_set_mnemonic_widget ((GtkLabel *)label, search_bar->viewoption);
gtk_box_pack_start (GTK_BOX(search_bar->viewoption_box), search_bar->viewoption, FALSE, TRUE, 0);
gtk_widget_show_all (search_bar->viewoption_box);
gtk_box_pack_start (GTK_BOX(search_bar), search_bar->viewoption_box, FALSE, FALSE, 0);
@@ -990,7 +1015,7 @@ e_search_bar_construct (ESearchBar *search_bar,
gtk_box_pack_start (GTK_BOX(hbox), label, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX(hbox), search_bar->entry_box, FALSE, FALSE, 0);
gtk_widget_show (search_bar->entry_box);
- gtk_label_set_mnemonic_widget (label, search_bar->entry);
+ gtk_label_set_mnemonic_widget ((GtkLabel *)label, search_bar->entry);
/* Search Scope Widgets */
search_bar->scopeoption_box = gtk_hbox_new (0, FALSE);
@@ -1002,11 +1027,11 @@ e_search_bar_construct (ESearchBar *search_bar,
gtk_box_pack_start (GTK_BOX(search_bar->scopeoption_box), label, FALSE, FALSE, 0);
search_bar->scopeoption = gtk_option_menu_new ();
- g_signal_connect (GTK_OPTION_MENU (search_bar->scopeoption), "changed", scopeoption_changed_cb, search_bar);
+/* g_signal_connect (GTK_OPTION_MENU (search_bar->scopeoption), "changed", scopeoption_changed_cb, search_bar); */
gtk_box_pack_start (GTK_BOX(search_bar->scopeoption_box), search_bar->scopeoption, FALSE, FALSE, 0);
gtk_widget_show_all (search_bar->scopeoption_box);
gtk_widget_hide (hbox);
- gtk_label_set_mnemonic_widget (label, search_bar->scopeoption);
+ gtk_label_set_mnemonic_widget ((GtkLabel *)label, search_bar->scopeoption);
gtk_box_pack_end (GTK_BOX(hbox), search_bar->scopeoption_box, FALSE, FALSE, 0);
gtk_widget_hide (search_bar->scopeoption_box);
@@ -1305,8 +1330,8 @@ e_search_bar_set_viewitem_id (ESearchBar *search_bar, int id)
g_return_if_fail (E_IS_SEARCH_BAR (search_bar));
row = find_id (search_bar->viewoption_menu, id, "EsbItemId", NULL);
- g_return_if_fail (row != -1);
-
+ if (row == -1)
+ return;
search_bar->viewitem_id = id;
gtk_option_menu_set_history (GTK_OPTION_MENU (search_bar->viewoption), row);
@@ -1328,14 +1353,32 @@ e_search_bar_set_item_id (ESearchBar *search_bar, int id)
g_return_if_fail (E_IS_SEARCH_BAR (search_bar));
row = find_id (search_bar->option_menu, id, "EsbItemId", NULL);
- g_return_if_fail (row != -1);
+ if (row == -1)
+ return;
if (id>=0)
search_bar->last_search_option = id;
search_bar->item_id = id;
- gtk_menu_set_active (search_bar->option_menu, row);
+ gtk_menu_set_active ((GtkMenu *)search_bar->option_menu, row);
- emit_query_changed (search_bar);
+ if (!search_bar->block_search)
+ emit_query_changed (search_bar);
+}
+
+void
+e_search_bar_set_item_menu (ESearchBar *search_bar, int id)
+{
+ int row;
+ GtkWidget *item;
+ g_return_if_fail (E_IS_SEARCH_BAR (search_bar));
+
+ row = find_id (search_bar->option_menu, id, "EsbItemId", &item);
+ if (row == -1)
+ return;
+
+ gtk_menu_set_active ((GtkMenu *)search_bar->option_menu, row);
+ if (id>=0)
+ gtk_check_menu_item_set_active ((GtkCheckMenuItem *)item, TRUE);
}
/**
@@ -1352,13 +1395,15 @@ e_search_bar_set_search_scope (ESearchBar *search_bar, int id)
g_return_if_fail (E_IS_SEARCH_BAR (search_bar));
- row = find_id (search_bar->option_menu, id, "EsbItemId", NULL);
- g_return_if_fail (row != -1);
+ row = find_id (search_bar->scopeoption_menu, id, "EsbItemId", NULL);
+ if (row == -1)
+ return;
- search_bar->item_id = id;
- gtk_option_menu_set_history (GTK_OPTION_MENU (search_bar->option), row);
+ search_bar->scopeitem_id = id;
+ gtk_option_menu_set_history (GTK_OPTION_MENU (search_bar->scopeoption), row);
- emit_query_changed (search_bar);
+ if (!search_bar->block_search)
+ emit_query_changed (search_bar);
}
@@ -1457,8 +1502,8 @@ e_search_bar_set_ids (ESearchBar *search_bar, int item_id, int subitem_id)
g_return_if_fail (E_IS_SEARCH_BAR (search_bar));
item_row = find_id (search_bar->option_menu, item_id, "EsbChoiceId", &item_widget);
- g_return_if_fail (item_row != -1);
- g_assert (item_widget != NULL);
+ if (item_row == -1 || !item_widget)
+ return;
search_bar->item_id = item_id;
gtk_option_menu_set_history (GTK_OPTION_MENU (search_bar->option), item_row);
diff --git a/widgets/misc/e-search-bar.h b/widgets/misc/e-search-bar.h
index 3693b8055d..e6ccb27121 100644
--- a/widgets/misc/e-search-bar.h
+++ b/widgets/misc/e-search-bar.h
@@ -101,6 +101,8 @@ struct _ESearchBar
int viewitem_id; /* Current View Id */
int scopeitem_id; /* Scope of search */
int last_search_option;
+
+ gboolean block_search;
};
struct _ESearchBarClass
@@ -140,7 +142,7 @@ void e_search_bar_add_menu (ESearchBar *search_bar,
void e_search_bar_set_option (ESearchBar *search_bar,
ESearchBarItem *option_items);
-
+void e_search_bar_paint (ESearchBar *search_bar);
void e_search_bar_set_viewoption (ESearchBar *search_bar,
int option_id,
ESearchBarItem *subitems);
@@ -151,6 +153,8 @@ void e_search_bar_set_menu_sensitive (ESearchBar *search_bar,
void e_search_bar_set_item_id (ESearchBar *search_bar,
int id);
+void e_search_bar_set_item_menu (ESearchBar *search_bar,
+ int id);
int e_search_bar_get_item_id (ESearchBar *search_bar);
int e_search_bar_get_viewitem_id (ESearchBar *search_bar);