aboutsummaryrefslogtreecommitdiffstats
path: root/modules/addressbook/e-book-shell-view.c
diff options
context:
space:
mode:
Diffstat (limited to 'modules/addressbook/e-book-shell-view.c')
-rw-r--r--modules/addressbook/e-book-shell-view.c67
1 files changed, 35 insertions, 32 deletions
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);