From a1d6678af2c9f8a075d9d7832c2a6da981afe216 Mon Sep 17 00:00:00 2001 From: Harish Krishnaswamy Date: Fri, 30 Jun 2006 09:46:32 +0000 Subject: Enhanced search functionality. patch submitted by Johnny Jacob Reviewed 2006-06-30 Harish Krishnaswamy Enhanced search functionality. patch submitted by Johnny Jacob Reviewed and committed by Harish. svn path=/trunk/; revision=32207 --- addressbook/ChangeLog | 9 +++++ addressbook/gui/widgets/addresstypes.xml | 5 --- addressbook/gui/widgets/e-addressbook-view.c | 55 +++++++++++++--------------- 3 files changed, 35 insertions(+), 34 deletions(-) (limited to 'addressbook') diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog index b878b58aa4..3fa22350ef 100644 --- a/addressbook/ChangeLog +++ b/addressbook/ChangeLog @@ -1,3 +1,12 @@ +2006-06-30 Johnny Jacob + * gui/cal-search-bar.c: (get_current_category), + (get_category_sexp), (notify_e_cal_view_contains), + (notify_category_is), (regen_query), (regen_view_query), + (make_suboptions), (cal_search_bar_construct): Added/Removed code + for new search ui. + * gui/e-tasks.c: (search_bar_sexp_changed_cb): + Added/Removed code for search ui. + 2006-06-29 simon.zheng * gui/widgets/eab-gui-util.c: (file_exists): Convert filename diff --git a/addressbook/gui/widgets/addresstypes.xml b/addressbook/gui/widgets/addresstypes.xml index f320a9b03f..b8274a983f 100644 --- a/addressbook/gui/widgets/addresstypes.xml +++ b/addressbook/gui/widgets/addresstypes.xml @@ -160,11 +160,6 @@ - - <_title>Category is - - - <_title>Any field contains diff --git a/addressbook/gui/widgets/e-addressbook-view.c b/addressbook/gui/widgets/e-addressbook-view.c index bf541bb05c..6cfc0913d6 100644 --- a/addressbook/gui/widgets/e-addressbook-view.c +++ b/addressbook/gui/widgets/e-addressbook-view.c @@ -166,10 +166,9 @@ enum { }; static ESearchBarItem addressbook_search_option_items[] = { - { N_("Name begins with"), ESB_FULL_NAME, NULL }, - { N_("Email begins with"), ESB_EMAIL, NULL }, - { N_("Category is"), ESB_CATEGORY, NULL }, /* We attach subitems below */ - { N_("Any field contains"), ESB_ANY, NULL }, + { N_("Name begins with"), ESB_FULL_NAME, ESB_ITEMTYPE_RADIO }, + { N_("Email begins with"), ESB_EMAIL, ESB_ITEMTYPE_RADIO }, + { N_("Any field contains"), ESB_ANY, ESB_ITEMTYPE_RADIO }, { NULL, -1, NULL } }; @@ -1483,19 +1482,17 @@ static void search_activated (ESearchBar *esb, EABView *v) { GList *master_list; - char *search_word, *search_query; + char *search_word, *search_query, *view_sexp; const char *category_name; int search_type, subid; - g_message ("in search_activated"); - g_object_get(esb, "text", &search_word, "item_id", &search_type, NULL); if (search_type == E_FILTERBAR_ADVANCED_ID) { - //gtk_widget_show(eab_search_dialog_new(v)); + gtk_widget_show(eab_search_dialog_new(v)); } else { if ((search_word && strlen (search_word)) || search_type == ESB_CATEGORY) { @@ -1514,26 +1511,26 @@ search_activated (ESearchBar *esb, EABView *v) search_query = g_strdup_printf ("(beginswith \"email\" %s)", s->str); break; - case ESB_CATEGORY: - subid = e_search_bar_get_subitem_id (esb); - - if (subid < 0 || subid == G_MAXINT) { - /* match everything */ - search_query = g_strdup ("(contains \"x-evolution-any-field\" \"\")"); - } else { - master_list = get_master_list (); - category_name = g_list_nth_data (master_list, subid); - search_query = g_strdup_printf ("(is \"category_list\" \"%s\")", category_name); - } - break; default: search_query = g_strdup ("(contains \"x-evolution-any-field\" \"\")"); break; } g_string_free (s, TRUE); - } else + + } else search_query = g_strdup ("(contains \"x-evolution-any-field\" \"\")"); + /* Merge view and sexp */ + subid = e_search_bar_get_viewitem_id (esb); + + if (subid != G_MAXINT) { + master_list = get_master_list (); + category_name = g_list_nth_data (master_list, subid); + view_sexp = g_strdup_printf ("(is \"category_list\" \"%s\")", category_name); + search_query = g_strconcat ("(and ", view_sexp, search_query, ")", NULL); + g_free (view_sexp); + } + if (search_query) g_object_set (v, "query", search_query, @@ -1564,6 +1561,7 @@ query_changed (ESearchBar *esb, EABView *view) search_type = e_search_bar_get_item_id(esb); if (search_type == E_FILTERBAR_ADVANCED_ID) { g_object_get (esb, "query", &query, NULL); + printf ("e-addresbook-view.c : query_changed : query = %s\n",query); g_object_set (view, "query", query, NULL); g_free (query); } @@ -1572,8 +1570,8 @@ query_changed (ESearchBar *esb, EABView *view) static int compare_subitems (const void *a, const void *b) { - const ESearchBarSubitem *subitem_a = a; - const ESearchBarSubitem *subitem_b = b; + const ESearchBarItem *subitem_a = a; + const ESearchBarItem *subitem_b = b; char *collate_a, *collate_b; int ret; @@ -1589,33 +1587,32 @@ compare_subitems (const void *a, const void *b) } static void + make_suboptions (EABView *view) { - ESearchBarSubitem *subitems, *s; + ESearchBarItem *subitems, *s; GList *master_list; gint i, N; master_list = get_master_list (); N = g_list_length (master_list); - subitems = g_new (ESearchBarSubitem, N+2); + subitems = g_new (ESearchBarItem, N+2); subitems[0].id = G_MAXINT; subitems[0].text = g_strdup (_("Any Category")); - subitems[0].translate = FALSE; for (i=0; isearch, ESB_CATEGORY, subitems); + e_search_bar_set_viewoption ( (ESearchBar *) view->search, ESB_CATEGORY, subitems); for (s = subitems; s->id != -1; s++) { if (s->text) -- cgit v1.2.3