diff options
author | Milan Crha <mcrha@redhat.com> | 2009-11-19 22:40:50 +0800 |
---|---|---|
committer | Milan Crha <mcrha@redhat.com> | 2009-11-19 22:40:50 +0800 |
commit | aa813bd7cadffa0110ddeeecd2b8df9d367db6e1 (patch) | |
tree | 8580dce61f4952b17225fa5262339432db092e4c /modules/addressbook | |
parent | 72861cffee5a3f9a5434fe0a94c7ec60beec1cc2 (diff) | |
download | gsoc2013-evolution-aa813bd7cadffa0110ddeeecd2b8df9d367db6e1.tar gsoc2013-evolution-aa813bd7cadffa0110ddeeecd2b8df9d367db6e1.tar.gz gsoc2013-evolution-aa813bd7cadffa0110ddeeecd2b8df9d367db6e1.tar.bz2 gsoc2013-evolution-aa813bd7cadffa0110ddeeecd2b8df9d367db6e1.tar.lz gsoc2013-evolution-aa813bd7cadffa0110ddeeecd2b8df9d367db6e1.tar.xz gsoc2013-evolution-aa813bd7cadffa0110ddeeecd2b8df9d367db6e1.tar.zst gsoc2013-evolution-aa813bd7cadffa0110ddeeecd2b8df9d367db6e1.zip |
Bug #579599 - Let the Advanced Search work again
Diffstat (limited to 'modules/addressbook')
-rw-r--r-- | modules/addressbook/e-book-shell-view-actions.c | 40 | ||||
-rw-r--r-- | modules/addressbook/e-book-shell-view-actions.h | 2 | ||||
-rw-r--r-- | modules/addressbook/e-book-shell-view-private.h | 1 | ||||
-rw-r--r-- | modules/addressbook/e-book-shell-view.c | 67 |
4 files changed, 53 insertions, 57 deletions
diff --git a/modules/addressbook/e-book-shell-view-actions.c b/modules/addressbook/e-book-shell-view-actions.c index 41b88efbc6..85db9d58e8 100644 --- a/modules/addressbook/e-book-shell-view-actions.c +++ b/modules/addressbook/e-book-shell-view-actions.c @@ -599,29 +599,6 @@ exit: } static void -action_contact_search_cb (GtkRadioAction *action, - GtkRadioAction *current, - EBookShellView *book_shell_view) -{ - EShellView *shell_view; - EShellContent *shell_content; - const gchar *search_hint; - - /* XXX Figure out a way to handle this in EShellContent - * instead of every shell view having to handle it. - * The problem is EShellContent does not know what - * the search option actions are for this view. It - * would have to dig up the popup menu and retrieve - * the action for each menu item. Seems messy. */ - - shell_view = E_SHELL_VIEW (book_shell_view); - shell_content = e_shell_view_get_shell_content (shell_view); - - search_hint = gtk_action_get_label (GTK_ACTION (current)); - e_shell_content_set_search_hint (shell_content, search_hint); -} - -static void action_contact_select_all_cb (GtkAction *action, EBookShellView *book_shell_view) { @@ -994,6 +971,13 @@ static GtkRadioActionEntry contact_filter_entries[] = { static GtkRadioActionEntry contact_search_entries[] = { + { "contact-search-advanced-hidden", + NULL, + N_("Advanced search"), + NULL, + NULL, + CONTACT_SEARCH_ADVANCED }, + { "contact-search-any-field-contains", NULL, N_("Any field contains"), @@ -1074,6 +1058,7 @@ e_book_shell_view_actions_init (EBookShellView *book_shell_view) GtkActionGroup *action_group; GConfBridge *bridge; GtkAction *action; + GtkRadioAction *radio_action; GObject *object; const gchar *key; @@ -1101,8 +1086,13 @@ e_book_shell_view_actions_init (EBookShellView *book_shell_view) gtk_action_group_add_radio_actions ( action_group, contact_search_entries, G_N_ELEMENTS (contact_search_entries), - CONTACT_SEARCH_NAME_CONTAINS, - G_CALLBACK (action_contact_search_cb), book_shell_view); + -1, NULL, NULL); + + /* Advanced Search action */ + radio_action = GTK_RADIO_ACTION (ACTION (CONTACT_SEARCH_ADVANCED_HIDDEN)); + e_shell_content_set_search_radio_action (e_shell_view_get_shell_content (shell_view), radio_action); + gtk_action_set_visible (GTK_ACTION (radio_action), FALSE); + gtk_radio_action_set_current_value (radio_action, CONTACT_SEARCH_NAME_CONTAINS); /* Lockdown Printing Actions */ action_group = ACTION_GROUP (LOCKDOWN_PRINTING); diff --git a/modules/addressbook/e-book-shell-view-actions.h b/modules/addressbook/e-book-shell-view-actions.h index e5eea1fb5a..98cd8b6689 100644 --- a/modules/addressbook/e-book-shell-view-actions.h +++ b/modules/addressbook/e-book-shell-view-actions.h @@ -81,6 +81,8 @@ E_SHELL_WINDOW_ACTION ((window), "contact-view-vertical") /* Search Actions */ +#define E_SHELL_WINDOW_ACTION_CONTACT_SEARCH_ADVANCED_HIDDEN(window) \ + E_SHELL_WINDOW_ACTION ((window), "contact-search-advanced-hidden") #define E_SHELL_WINDOW_ACTION_CONTACT_SEARCH_ANY_FIELD_CONTAINS(window) \ E_SHELL_WINDOW_ACTION ((window), "contact-search-any-field-contains") #define E_SHELL_WINDOW_ACTION_CONTACT_SEARCH_EMAIL_BEGINS_WITH(window) \ diff --git a/modules/addressbook/e-book-shell-view-private.h b/modules/addressbook/e-book-shell-view-private.h index c1aa300739..6d513aa273 100644 --- a/modules/addressbook/e-book-shell-view-private.h +++ b/modules/addressbook/e-book-shell-view-private.h @@ -91,6 +91,7 @@ enum { /* List these in the order to be displayed. */ enum { + CONTACT_SEARCH_ADVANCED = -1, CONTACT_SEARCH_NAME_CONTAINS, CONTACT_SEARCH_EMAIL_BEGINS_WITH, CONTACT_SEARCH_ANY_FIELD_CONTAINS diff --git a/modules/addressbook/e-book-shell-view.c b/modules/addressbook/e-book-shell-view.c index e7d26d727d..663f2a109e 100644 --- a/modules/addressbook/e-book-shell-view.c +++ b/modules/addressbook/e-book-shell-view.c @@ -128,11 +128,8 @@ book_shell_view_execute_search (EShellView *shell_view) EShellWindow *shell_window; EShellContent *shell_content; GtkRadioAction *action; - GString *string; EAddressbookView *view; EAddressbookModel *model; - const gchar *format; - const gchar *text; gchar *query; gchar *temp; gint value; @@ -140,40 +137,51 @@ book_shell_view_execute_search (EShellView *shell_view) priv = E_BOOK_SHELL_VIEW_GET_PRIVATE (shell_view); shell_content = e_shell_view_get_shell_content (shell_view); - text = e_shell_content_get_search_text (shell_content); - shell_window = e_shell_view_get_shell_window (shell_view); action = GTK_RADIO_ACTION (ACTION (CONTACT_SEARCH_ANY_FIELD_CONTAINS)); value = gtk_radio_action_get_current_value (action); - if (text == NULL || *text == '\0') { - text = ""; - value = CONTACT_SEARCH_ANY_FIELD_CONTAINS; - } + if (value == CONTACT_SEARCH_ADVANCED) { + query = e_shell_content_get_search_rule_as_string (shell_content); - switch (value) { - case CONTACT_SEARCH_NAME_CONTAINS: - format = "(contains \"full_name\" %s)"; - break; + if (!query) + query = g_strdup (""); + } else { + const gchar *text; + const gchar *format; + GString *string; - case CONTACT_SEARCH_EMAIL_BEGINS_WITH: - format = "(beginswith \"email\" %s)"; - break; + text = e_shell_content_get_search_text (shell_content); - default: + if (text == NULL || *text == '\0') { text = ""; - /* fall through */ + value = CONTACT_SEARCH_ANY_FIELD_CONTAINS; + } - case CONTACT_SEARCH_ANY_FIELD_CONTAINS: - format = "(contains \"x-evolution-any-field\" %s)"; - break; - } + switch (value) { + case CONTACT_SEARCH_NAME_CONTAINS: + format = "(contains \"full_name\" %s)"; + break; + + case CONTACT_SEARCH_EMAIL_BEGINS_WITH: + format = "(beginswith \"email\" %s)"; + break; - /* Build the query. */ - string = g_string_new (""); - e_sexp_encode_string (string, text); - query = g_strdup_printf (format, string->str); - g_string_free (string, TRUE); + default: + text = ""; + /* fall through */ + + case CONTACT_SEARCH_ANY_FIELD_CONTAINS: + format = "(contains \"x-evolution-any-field\" %s)"; + break; + } + + /* Build the query. */ + string = g_string_new (""); + e_sexp_encode_string (string, text); + query = g_strdup_printf (format, string->str); + g_string_free (string, TRUE); + } /* Apply selected filter. */ value = e_shell_content_get_filter_value (shell_content); @@ -207,11 +215,6 @@ book_shell_view_execute_search (EShellView *shell_view) } } - /* XXX This is wrong. We need to programmatically construct an - * EFilterRule, tell it to build code, and pass the resulting - * expression string to EAddressbookModel. */ - e_shell_content_set_search_rule (shell_content, NULL); - /* Submit the query. */ book_shell_content = E_BOOK_SHELL_CONTENT (shell_content); view = e_book_shell_content_get_current_view (book_shell_content); |