aboutsummaryrefslogtreecommitdiffstats
path: root/modules/addressbook
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2009-09-03 03:21:35 +0800
committerMatthew Barnes <mbarnes@redhat.com>2009-09-03 03:26:49 +0800
commit53268d5516083c47607dbd3acbbd6bafd6d15747 (patch)
treec2a35758d36f00a2ce51633674c811eb1c5070ba /modules/addressbook
parent5cbcdddfe769c0df81122b8d4944507f4739a618 (diff)
downloadgsoc2013-evolution-53268d5516083c47607dbd3acbbd6bafd6d15747.tar
gsoc2013-evolution-53268d5516083c47607dbd3acbbd6bafd6d15747.tar.gz
gsoc2013-evolution-53268d5516083c47607dbd3acbbd6bafd6d15747.tar.bz2
gsoc2013-evolution-53268d5516083c47607dbd3acbbd6bafd6d15747.tar.lz
gsoc2013-evolution-53268d5516083c47607dbd3acbbd6bafd6d15747.tar.xz
gsoc2013-evolution-53268d5516083c47607dbd3acbbd6bafd6d15747.tar.zst
gsoc2013-evolution-53268d5516083c47607dbd3acbbd6bafd6d15747.zip
Introduce an EShellView::execute-search signal.
This addresses bug #593896 but is also a cleaner design than before. It introduces an EShellView::execute-search signal and renames the "search-execute" action to "search-quick" to clarify that it's only meant for the "quick" search bar in the main window. Shell view subclasses should implement the execute_search() method to actually execute a search. e_shell_view_execute_search() emits the new signal.
Diffstat (limited to 'modules/addressbook')
-rw-r--r--modules/addressbook/e-book-shell-view-actions.c30
-rw-r--r--modules/addressbook/e-book-shell-view-private.c108
-rw-r--r--modules/addressbook/e-book-shell-view-private.h2
-rw-r--r--modules/addressbook/e-book-shell-view.c107
4 files changed, 109 insertions, 138 deletions
diff --git a/modules/addressbook/e-book-shell-view-actions.c b/modules/addressbook/e-book-shell-view-actions.c
index bbe613786f..1d875ba91a 100644
--- a/modules/addressbook/e-book-shell-view-actions.c
+++ b/modules/addressbook/e-book-shell-view-actions.c
@@ -582,33 +582,11 @@ action_gal_save_custom_view_cb (GtkAction *action,
}
static void
-action_search_execute_cb (GtkAction *action,
- EBookShellView *book_shell_view)
-{
- EShellView *shell_view;
-
- /* All shell views respond to the activation of this action,
- * which is defined by EShellWindow. But only the currently
- * active shell view proceeds with executing the search. */
- shell_view = E_SHELL_VIEW (book_shell_view);
- if (!e_shell_view_is_active (shell_view))
- return;
-
- e_book_shell_view_execute_search (book_shell_view);
-}
-
-static void
action_search_filter_cb (GtkRadioAction *action,
GtkRadioAction *current,
- EBookShellView *book_shell_view)
+ EShellView *shell_view)
{
- EShellView *shell_view;
- EShellWindow *shell_window;
-
- shell_view = E_SHELL_VIEW (book_shell_view);
- shell_window = e_shell_view_get_shell_window (shell_view);
-
- gtk_action_activate (ACTION (SEARCH_EXECUTE));
+ e_shell_view_execute_search (shell_view);
}
static GtkActionEntry contact_entries[] = {
@@ -1004,10 +982,6 @@ e_book_shell_view_actions_init (EBookShellView *book_shell_view)
ACTION (GAL_SAVE_CUSTOM_VIEW), "activate",
G_CALLBACK (action_gal_save_custom_view_cb), book_shell_view);
- g_signal_connect (
- ACTION (SEARCH_EXECUTE), "activate",
- G_CALLBACK (action_search_execute_cb), book_shell_view);
-
e_binding_new (
ACTION (CONTACT_PREVIEW), "active",
ACTION (CONTACT_VIEW_CLASSIC), "sensitive");
diff --git a/modules/addressbook/e-book-shell-view-private.c b/modules/addressbook/e-book-shell-view-private.c
index 6770800dbd..55a2e8c433 100644
--- a/modules/addressbook/e-book-shell-view-private.c
+++ b/modules/addressbook/e-book-shell-view-private.c
@@ -516,114 +516,6 @@ e_book_shell_view_private_finalize (EBookShellView *book_shell_view)
}
void
-e_book_shell_view_execute_search (EBookShellView *book_shell_view)
-{
- EBookShellContent *book_shell_content;
- EShellView *shell_view;
- EShellWindow *shell_window;
- EShellContent *shell_content;
- GtkRadioAction *action;
- GString *string;
- EAddressbookView *view;
- EAddressbookModel *model;
- FilterRule *rule;
- const gchar *format;
- const gchar *text;
- gchar *query;
- gchar *temp;
- gint value;
-
- shell_view = E_SHELL_VIEW (book_shell_view);
- if (!e_shell_view_is_active (shell_view))
- return;
-
- 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;
- }
-
- switch (value) {
- case CONTACT_SEARCH_NAME_CONTAINS:
- format = "(contains \"full_name\" %s)";
- break;
-
- case CONTACT_SEARCH_EMAIL_BEGINS_WITH:
- format = "(beginswith \"email\" %s)";
- break;
-
- 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);
- switch (value) {
- case CONTACT_FILTER_ANY_CATEGORY:
- break;
-
- case CONTACT_FILTER_UNMATCHED:
- temp = g_strdup_printf (
- "(and (not (and (exists \"CATEGORIES\") "
- "(not (is \"CATEGORIES\" \"\")))) %s)",
- query);
- g_free (query);
- query = temp;
- break;
-
- default:
- {
- GList *categories;
- const gchar *category_name;
-
- categories = e_categories_get_list ();
- category_name = g_list_nth_data (categories, value);
- g_list_free (categories);
-
- temp = g_strdup_printf (
- "(and (is \"category_list\" \"%s\") %s)",
- category_name, query);
- g_free (query);
- query = temp;
- }
- }
-
- /* XXX This is wrong. We need to programmatically construct a
- * FilterRule, tell it to build code, and pass the resulting
- * expression string to EAddressbookModel. */
- rule = filter_rule_new ();
- e_shell_content_set_search_rule (shell_content, rule);
- g_object_unref (rule);
-
- /* Submit the query. */
- book_shell_content = book_shell_view->priv->book_shell_content;
- view = e_book_shell_content_get_current_view (book_shell_content);
- model = e_addressbook_view_get_model (view);
- e_addressbook_model_set_query (model, query);
- g_free (query);
-
- e_book_shell_content_set_preview_contact (book_shell_content, NULL);
- book_shell_view->priv->preview_index = -1;
-}
-
-void
e_book_shell_view_editor_weak_notify (EditorUidClosure *closure,
GObject *where_the_object_was)
{
diff --git a/modules/addressbook/e-book-shell-view-private.h b/modules/addressbook/e-book-shell-view-private.h
index 31165e49b3..8b8da3f4c6 100644
--- a/modules/addressbook/e-book-shell-view-private.h
+++ b/modules/addressbook/e-book-shell-view-private.h
@@ -119,8 +119,6 @@ void e_book_shell_view_private_finalize
void e_book_shell_view_actions_init
(EBookShellView *book_shell_view);
-void e_book_shell_view_execute_search
- (EBookShellView *book_shell_view);
void e_book_shell_view_editor_weak_notify
(EditorUidClosure *closure,
GObject *where_the_object_was);
diff --git a/modules/addressbook/e-book-shell-view.c b/modules/addressbook/e-book-shell-view.c
index ea48bb534c..f7019b0b3a 100644
--- a/modules/addressbook/e-book-shell-view.c
+++ b/modules/addressbook/e-book-shell-view.c
@@ -121,6 +121,112 @@ book_shell_view_constructed (GObject *object)
}
static void
+book_shell_view_execute_search (EShellView *shell_view)
+{
+ EBookShellViewPrivate *priv;
+ EBookShellContent *book_shell_content;
+ EShellWindow *shell_window;
+ EShellContent *shell_content;
+ GtkRadioAction *action;
+ GString *string;
+ EAddressbookView *view;
+ EAddressbookModel *model;
+ FilterRule *rule;
+ const gchar *format;
+ const gchar *text;
+ gchar *query;
+ gchar *temp;
+ gint value;
+
+ 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;
+ }
+
+ switch (value) {
+ case CONTACT_SEARCH_NAME_CONTAINS:
+ format = "(contains \"full_name\" %s)";
+ break;
+
+ case CONTACT_SEARCH_EMAIL_BEGINS_WITH:
+ format = "(beginswith \"email\" %s)";
+ break;
+
+ 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);
+ switch (value) {
+ case CONTACT_FILTER_ANY_CATEGORY:
+ break;
+
+ case CONTACT_FILTER_UNMATCHED:
+ temp = g_strdup_printf (
+ "(and (not (and (exists \"CATEGORIES\") "
+ "(not (is \"CATEGORIES\" \"\")))) %s)",
+ query);
+ g_free (query);
+ query = temp;
+ break;
+
+ default:
+ {
+ GList *categories;
+ const gchar *category_name;
+
+ categories = e_categories_get_list ();
+ category_name = g_list_nth_data (categories, value);
+ g_list_free (categories);
+
+ temp = g_strdup_printf (
+ "(and (is \"category_list\" \"%s\") %s)",
+ category_name, query);
+ g_free (query);
+ query = temp;
+ }
+ }
+
+ /* XXX This is wrong. We need to programmatically construct a
+ * FilterRule, tell it to build code, and pass the resulting
+ * expression string to EAddressbookModel. */
+ rule = filter_rule_new ();
+ e_shell_content_set_search_rule (shell_content, rule);
+ g_object_unref (rule);
+
+ /* Submit the query. */
+ book_shell_content = E_BOOK_SHELL_CONTENT (shell_content);
+ view = e_book_shell_content_get_current_view (book_shell_content);
+ model = e_addressbook_view_get_model (view);
+ e_addressbook_model_set_query (model, query);
+ g_free (query);
+
+ e_book_shell_content_set_preview_contact (book_shell_content, NULL);
+ priv->preview_index = -1;
+}
+
+static void
book_shell_view_update_actions (EShellView *shell_view)
{
EBookShellViewPrivate *priv;
@@ -277,6 +383,7 @@ book_shell_view_class_init (EBookShellViewClass *class)
shell_view_class->search_rules = "addresstypes.xml";
shell_view_class->new_shell_content = e_book_shell_content_new;
shell_view_class->new_shell_sidebar = e_book_shell_sidebar_new;
+ shell_view_class->execute_search = book_shell_view_execute_search;
shell_view_class->update_actions = book_shell_view_update_actions;
}