aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui/component/e-book-shell-view-actions.c
diff options
context:
space:
mode:
Diffstat (limited to 'addressbook/gui/component/e-book-shell-view-actions.c')
-rw-r--r--addressbook/gui/component/e-book-shell-view-actions.c208
1 files changed, 1 insertions, 207 deletions
diff --git a/addressbook/gui/component/e-book-shell-view-actions.c b/addressbook/gui/component/e-book-shell-view-actions.c
index b9b03b4342..8ade5e6805 100644
--- a/addressbook/gui/component/e-book-shell-view-actions.c
+++ b/addressbook/gui/component/e-book-shell-view-actions.c
@@ -463,93 +463,7 @@ static void
action_search_execute_cb (GtkAction *action,
EBookShellView *book_shell_view)
{
- EBookShellContent *book_shell_content;
- EShellView *shell_view;
- EShellWindow *shell_window;
- EShellContent *shell_content;
- GString *string;
- EAddressbookView *view;
- EAddressbookModel *model;
- FilterRule *rule;
- const gchar *format;
- const gchar *text;
- gchar *query;
- 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 = ACTION (CONTACT_SEARCH_ANY_FIELD_CONTAINS);
- value = gtk_radio_action_get_current_value (
- GTK_RADIO_ACTION (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);
- if (value > CONTACT_FILTER_ANY_CATEGORY) {
- GList *categories;
- const gchar *category_name;
- gchar *temp;
-
- 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);
+ e_book_shell_view_execute_search (book_shell_view);
}
static void
@@ -856,126 +770,6 @@ e_book_shell_view_actions_init (EBookShellView *book_shell_view)
}
void
-e_book_shell_view_actions_update (EBookShellView *book_shell_view)
-{
- EShellView *shell_view;
- EShellWindow *shell_window;
- EAddressbookModel *model;
- EAddressbookView *view;
- EBookShellContent *book_shell_content;
- EBookShellSidebar *book_shell_sidebar;
- ESelectionModel *selection_model;
- ESourceSelector *selector;
- ESource *source;
- GtkAction *action;
- const gchar *label;
- gboolean editable;
- gboolean sensitive;
- gint n_contacts;
- gint n_selected;
-
- shell_view = E_SHELL_VIEW (book_shell_view);
- shell_window = e_shell_view_get_shell_window (shell_view);
-
- book_shell_content = book_shell_view->priv->book_shell_content;
- view = e_book_shell_content_get_current_view (book_shell_content);
-
- book_shell_sidebar = book_shell_view->priv->book_shell_sidebar;
- selector = e_book_shell_sidebar_get_selector (book_shell_sidebar);
- source = e_source_selector_peek_primary_selection (selector);
-
- model = e_addressbook_view_get_model (view);
- editable = e_addressbook_model_get_editable (model);
-
- selection_model = e_addressbook_view_get_selection_model (view);
- n_contacts = (selection_model != NULL) ?
- e_selection_model_row_count (selection_model) : 0;
- n_selected = (selection_model != NULL) ?
- e_selection_model_selected_count (selection_model) : 0;
-
- action = ACTION (ADDRESS_BOOK_STOP);
- sensitive = e_addressbook_model_can_stop (model);
- gtk_action_set_sensitive (action, sensitive);
-
- action = ACTION (CONTACT_CLIPBOARD_COPY);
- sensitive = (n_selected > 0);
- gtk_action_set_sensitive (action, sensitive);
-
- action = ACTION (CONTACT_CLIPBOARD_CUT);
- sensitive = editable && (n_selected > 0);
- gtk_action_set_sensitive (action, sensitive);
-
- action = ACTION (CONTACT_CLIPBOARD_PASTE);
- sensitive = editable;
- gtk_action_set_sensitive (action, sensitive);
-
- action = ACTION (CONTACT_COPY);
- sensitive = (n_selected > 0);
- gtk_action_set_sensitive (action, sensitive);
-
- action = ACTION (CONTACT_DELETE);
- sensitive = editable && (n_selected > 0);
- gtk_action_set_sensitive (action, sensitive);
-
- action = ACTION (CONTACT_FORWARD);
- sensitive = (n_selected > 0);
- gtk_action_set_sensitive (action, sensitive);
- label = ngettext (
- "_Forward Contact",
- "_Forward Contacts", n_selected);
- g_object_set (action, "label", label, NULL);
-
- action = ACTION (CONTACT_MOVE);
- sensitive = editable && (n_selected > 0);
- gtk_action_set_sensitive (action, sensitive);
-
- action = ACTION (CONTACT_OPEN);
- sensitive = (n_selected > 0);
- gtk_action_set_sensitive (action, sensitive);
-
- action = ACTION (CONTACT_PRINT);
- sensitive = (n_contacts > 0);
- gtk_action_set_sensitive (action, sensitive);
-
- action = ACTION (CONTACT_PRINT_PREVIEW);
- sensitive = (n_contacts > 0);
- gtk_action_set_sensitive (action, sensitive);
-
- action = ACTION (CONTACT_SAVE_AS);
- sensitive = (n_selected > 0);
- gtk_action_set_sensitive (action, sensitive);
-
- action = ACTION (CONTACT_SELECT_ALL);
- sensitive = (n_contacts > 0);
- gtk_action_set_sensitive (action, sensitive);
-
- /* FIXME Also check for email address. */
- action = ACTION (CONTACT_SEND_MESSAGE);
- sensitive = (n_selected > 0);
- gtk_action_set_sensitive (action, sensitive);
- label = ngettext (
- "_Send Message to Contact",
- "_Send Message to Contacts", n_selected);
- g_object_set (action, "label", label, NULL);
-
- /* TODO Add some context sensitivity to SEND_MESSAGE:
- * Send Message to Contact (n_selected == 1)
- * Send Message to Contacts (n_selected > 1)
- * Send Message to List (n_selected == 1 && is_list)
- */
-
- action = ACTION (ADDRESS_BOOK_DELETE);
- if (source != NULL) {
- const gchar *uri;
-
- uri = e_source_peek_relative_uri (source);
- sensitive = (uri == NULL || strcmp ("system", uri) != 0);
- } else
- sensitive = FALSE;
- gtk_action_set_sensitive (action, sensitive);
-}
-
-void
e_book_shell_view_update_search_filter (EBookShellView *book_shell_view)
{
EShellContent *shell_content;