aboutsummaryrefslogtreecommitdiffstats
path: root/modules/addressbook
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2009-12-19 07:23:48 +0800
committerMatthew Barnes <mbarnes@redhat.com>2009-12-19 11:38:00 +0800
commit4cbbdedf522a6ac10df93a128bbf25f67173d66e (patch)
treefab7bf95e0927e4fa98c58a659e310afff7153ee /modules/addressbook
parenta1efb837566cdac798cd8777dd34e06e9782cf61 (diff)
downloadgsoc2013-evolution-4cbbdedf522a6ac10df93a128bbf25f67173d66e.tar.gz
gsoc2013-evolution-4cbbdedf522a6ac10df93a128bbf25f67173d66e.tar.zst
gsoc2013-evolution-4cbbdedf522a6ac10df93a128bbf25f67173d66e.zip
Refactor the EShell search API.
Move the search interface to a new widget: EShellSearchbar The current search rule is now stored in EShellView, and the search context in EShellViewClass similar to GalViewCollection (since it's class-specific, not instance-specific). Also add a couple new signals to EShellView: "clear-search" and "custom-search" ("custom" refers to an advanced search or a saved search -- something more complex than a quick search). Still working out a few kinks. The search entry is clearly trying to be too many things. We need a different way of indicating that you're looking at search results. Perhaps a search results banner similar to Nautilus.
Diffstat (limited to 'modules/addressbook')
-rw-r--r--modules/addressbook/e-book-shell-content.c55
-rw-r--r--modules/addressbook/e-book-shell-content.h8
-rw-r--r--modules/addressbook/e-book-shell-view-actions.c32
-rw-r--r--modules/addressbook/e-book-shell-view-private.h1
-rw-r--r--modules/addressbook/e-book-shell-view.c23
5 files changed, 85 insertions, 34 deletions
diff --git a/modules/addressbook/e-book-shell-content.c b/modules/addressbook/e-book-shell-content.c
index 46d9824f2e..5eb4459b7b 100644
--- a/modules/addressbook/e-book-shell-content.c
+++ b/modules/addressbook/e-book-shell-content.c
@@ -520,6 +520,9 @@ void
e_book_shell_content_set_current_view (EBookShellContent *book_shell_content,
EAddressbookView *addressbook_view)
{
+ EShellView *shell_view;
+ EShellContent *shell_content;
+ EShellSearchbar *searchbar;
EBookShellView *book_shell_view;
GtkNotebook *notebook;
GtkWidget *child;
@@ -528,6 +531,12 @@ e_book_shell_content_set_current_view (EBookShellContent *book_shell_content,
g_return_if_fail (E_IS_BOOK_SHELL_CONTENT (book_shell_content));
g_return_if_fail (E_IS_ADDRESSBOOK_VIEW (addressbook_view));
+ shell_content = E_SHELL_CONTENT (book_shell_content);
+ shell_view = e_shell_content_get_shell_view (shell_content);
+
+ book_shell_view = E_BOOK_SHELL_VIEW (shell_view);
+ searchbar = e_book_shell_content_get_searchbar (book_shell_content);
+
notebook = GTK_NOTEBOOK (book_shell_content->priv->notebook);
child = GTK_WIDGET (addressbook_view);
page_num = gtk_notebook_page_num (notebook, child);
@@ -537,26 +546,33 @@ e_book_shell_content_set_current_view (EBookShellContent *book_shell_content,
gtk_notebook_set_current_page (notebook, page_num);
if (old_page_num != page_num) {
- EShellContent *shell_content;
+ EActionComboBox *combo_box;
+ GtkRadioAction *action;
gint filter_id = 0, search_id = 0;
gchar *search_text = NULL;
EFilterRule *advanced_search = NULL;
- GtkRadioAction *radio_action;
-
- shell_content = E_SHELL_CONTENT (book_shell_content);
- book_shell_view = E_BOOK_SHELL_VIEW (e_shell_content_get_shell_view (shell_content));
e_book_shell_view_disable_searching (book_shell_view);
- e_addressbook_view_get_search (addressbook_view, &filter_id, &search_id, &search_text, &advanced_search);
- if (e_shell_content_get_filter_action (shell_content))
- e_shell_content_set_filter_value (shell_content, filter_id);
- radio_action = e_shell_content_get_search_radio_action (shell_content);
- gtk_radio_action_set_current_value (radio_action, search_id);
- e_shell_content_set_search_text (shell_content, search_text ? search_text : "");
- e_shell_content_set_search_rule (shell_content, advanced_search);
+
+ e_addressbook_view_get_search (
+ addressbook_view, &filter_id, &search_id,
+ &search_text, &advanced_search);
+
+ combo_box = e_shell_searchbar_get_filter_combo_box (searchbar);
+ e_action_combo_box_set_current_value (combo_box, filter_id);
+
+ action = e_shell_searchbar_get_search_option (searchbar);
+ gtk_radio_action_set_current_value (action, search_id);
+
+ e_shell_searchbar_set_search_text (searchbar, search_text);
+
+ e_shell_view_set_search_rule (shell_view, advanced_search);
+
g_free (search_text);
+
if (advanced_search)
g_object_unref (advanced_search);
+
e_book_shell_view_enable_searching (book_shell_view);
}
@@ -619,6 +635,21 @@ e_book_shell_content_set_preview_visible (EBookShellContent *book_shell_content,
g_object_notify (G_OBJECT (book_shell_content), "preview-visible");
}
+EShellSearchbar *
+e_book_shell_content_get_searchbar (EBookShellContent *book_shell_content)
+{
+ EShellContent *shell_content;
+ GtkWidget *widget;
+
+ g_return_val_if_fail (
+ E_IS_BOOK_SHELL_CONTENT (book_shell_content), NULL);
+
+ shell_content = E_SHELL_CONTENT (book_shell_content);
+ widget = e_shell_content_get_searchbar (shell_content);
+
+ return E_SHELL_SEARCHBAR (widget);
+}
+
void
e_book_shell_content_clipboard_copy (EBookShellContent *book_shell_content)
{
diff --git a/modules/addressbook/e-book-shell-content.h b/modules/addressbook/e-book-shell-content.h
index 5acfae46c8..62cc7bf80f 100644
--- a/modules/addressbook/e-book-shell-content.h
+++ b/modules/addressbook/e-book-shell-content.h
@@ -24,8 +24,9 @@
#include <libebook/e-contact.h>
-#include "shell/e-shell-content.h"
-#include "shell/e-shell-view.h"
+#include <shell/e-shell-content.h>
+#include <shell/e-shell-searchbar.h>
+#include <shell/e-shell-view.h>
#include "addressbook/gui/widgets/e-addressbook-view.h"
#include "eab-composer-util.h"
@@ -104,6 +105,9 @@ gboolean e_book_shell_content_get_preview_visible
void e_book_shell_content_set_preview_visible
(EBookShellContent *book_shell_content,
gboolean preview_visible);
+EShellSearchbar *
+ e_book_shell_content_get_searchbar
+ (EBookShellContent *book_shell_content);
void e_book_shell_content_clipboard_copy
(EBookShellContent *book_shell_content);
diff --git a/modules/addressbook/e-book-shell-view-actions.c b/modules/addressbook/e-book-shell-view-actions.c
index 5214f611d3..904b777c8b 100644
--- a/modules/addressbook/e-book-shell-view-actions.c
+++ b/modules/addressbook/e-book-shell-view-actions.c
@@ -973,7 +973,7 @@ static GtkRadioActionEntry contact_search_entries[] = {
{ "contact-search-advanced-hidden",
NULL,
- N_("Advanced search"),
+ N_("Advanced Search"),
NULL,
NULL,
CONTACT_SEARCH_ADVANCED },
@@ -1051,14 +1051,14 @@ static EPopupActionEntry lockdown_save_to_disk_popup_entries[] = {
void
e_book_shell_view_actions_init (EBookShellView *book_shell_view)
{
+ EBookShellContent *book_shell_content;
EShellView *shell_view;
EShellWindow *shell_window;
- EBookShellContent *book_shell_content;
+ EShellSearchbar *searchbar;
EABContactDisplay *contact_preview;
GtkActionGroup *action_group;
GConfBridge *bridge;
GtkAction *action;
- GtkRadioAction *radio_action;
GObject *object;
const gchar *key;
@@ -1066,6 +1066,7 @@ e_book_shell_view_actions_init (EBookShellView *book_shell_view)
shell_window = e_shell_view_get_shell_window (shell_view);
book_shell_content = book_shell_view->priv->book_shell_content;
+ searchbar = e_book_shell_content_get_searchbar (book_shell_content);
contact_preview = e_book_shell_content_get_preview (book_shell_content);
/* Contact Actions */
@@ -1088,11 +1089,14 @@ e_book_shell_view_actions_init (EBookShellView *book_shell_view)
G_N_ELEMENTS (contact_search_entries),
-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);
+ /* Advanced Search Action */
+ action = ACTION (CONTACT_SEARCH_ADVANCED_HIDDEN);
+ gtk_action_set_visible (action, FALSE);
+ e_shell_searchbar_set_search_option (
+ searchbar, GTK_RADIO_ACTION (action));
+ gtk_radio_action_set_current_value (
+ GTK_RADIO_ACTION (action),
+ CONTACT_SEARCH_NAME_CONTAINS);
/* Lockdown Printing Actions */
action_group = ACTION_GROUP (LOCKDOWN_PRINTING);
@@ -1156,9 +1160,11 @@ e_book_shell_view_actions_init (EBookShellView *book_shell_view)
void
e_book_shell_view_update_search_filter (EBookShellView *book_shell_view)
{
+ EBookShellContent *book_shell_content;
EShellView *shell_view;
- EShellContent *shell_content;
EShellWindow *shell_window;
+ EShellSearchbar *searchbar;
+ EActionComboBox *combo_box;
GtkActionGroup *action_group;
GtkRadioAction *radio_action;
GList *list, *iter;
@@ -1166,7 +1172,6 @@ e_book_shell_view_update_search_filter (EBookShellView *book_shell_view)
gint ii;
shell_view = E_SHELL_VIEW (book_shell_view);
- shell_content = e_shell_view_get_shell_content (shell_view);
shell_window = e_shell_view_get_shell_window (shell_view);
action_group = ACTION_GROUP (CONTACTS_FILTER);
@@ -1230,8 +1235,11 @@ e_book_shell_view_update_search_filter (EBookShellView *book_shell_view)
g_list_free (list);
/* Use any action in the group; doesn't matter which. */
- e_shell_content_set_filter_action (shell_content, radio_action);
+ book_shell_content = book_shell_view->priv->book_shell_content;
+ searchbar = e_book_shell_content_get_searchbar (book_shell_content);
+ combo_box = e_shell_searchbar_get_filter_combo_box (searchbar);
+ e_action_combo_box_set_action (combo_box, radio_action);
ii = CONTACT_FILTER_UNMATCHED;
- e_shell_content_add_filter_separator_after (shell_content, ii);
+ e_action_combo_box_add_separator_after (combo_box, ii);
}
diff --git a/modules/addressbook/e-book-shell-view-private.h b/modules/addressbook/e-book-shell-view-private.h
index f1b23c2cfb..c0fb2f09df 100644
--- a/modules/addressbook/e-book-shell-view-private.h
+++ b/modules/addressbook/e-book-shell-view-private.h
@@ -37,6 +37,7 @@
#include "e-util/e-file-utils.h"
#include "e-util/gconf-bridge.h"
#include "shell/e-shell-content.h"
+#include "shell/e-shell-searchbar.h"
#include "shell/e-shell-sidebar.h"
#include "shell/e-shell-utils.h"
#include "misc/e-popup-action.h"
diff --git a/modules/addressbook/e-book-shell-view.c b/modules/addressbook/e-book-shell-view.c
index ebbf3e79d0..fa5e5bbe29 100644
--- a/modules/addressbook/e-book-shell-view.c
+++ b/modules/addressbook/e-book-shell-view.c
@@ -127,6 +127,8 @@ book_shell_view_execute_search (EShellView *shell_view)
EBookShellContent *book_shell_content;
EShellWindow *shell_window;
EShellContent *shell_content;
+ EShellSearchbar *searchbar;
+ EActionComboBox *combo_box;
GtkRadioAction *action;
EAddressbookView *view;
EAddressbookModel *model;
@@ -141,25 +143,29 @@ book_shell_view_execute_search (EShellView *shell_view)
if (priv->search_locked)
return;
- shell_content = e_shell_view_get_shell_content (shell_view);
shell_window = e_shell_view_get_shell_window (shell_view);
+ shell_content = e_shell_view_get_shell_content (shell_view);
+
+ book_shell_content = E_BOOK_SHELL_CONTENT (shell_content);
+ searchbar = e_book_shell_content_get_searchbar (book_shell_content);
+
action = GTK_RADIO_ACTION (ACTION (CONTACT_SEARCH_ANY_FIELD_CONTAINS));
search_id = gtk_radio_action_get_current_value (action);
if (search_id == CONTACT_SEARCH_ADVANCED) {
- query = e_shell_content_get_search_rule_as_string (shell_content);
+ query = e_shell_view_get_search_query (shell_view);
- if (!query)
+ if (query == NULL)
query = g_strdup ("");
/* internal pointer, no need to free it */
- advanced_search = e_shell_content_get_search_rule (shell_content);
+ advanced_search = e_shell_view_get_search_rule (shell_view);
} else {
const gchar *text;
const gchar *format;
GString *string;
- text = e_shell_content_get_search_text (shell_content);
+ text = e_shell_searchbar_get_search_text (searchbar);
if (text == NULL || *text == '\0') {
text = "";
@@ -194,7 +200,8 @@ book_shell_view_execute_search (EShellView *shell_view)
}
/* Apply selected filter. */
- filter_id = e_shell_content_get_filter_value (shell_content);
+ combo_box = e_shell_searchbar_get_filter_combo_box (searchbar);
+ filter_id = e_action_combo_box_get_current_value (combo_box);
switch (filter_id) {
case CONTACT_FILTER_ANY_CATEGORY:
break;
@@ -226,11 +233,11 @@ book_shell_view_execute_search (EShellView *shell_view)
}
/* 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);
- e_addressbook_view_set_search (view, filter_id, search_id, search_text, advanced_search);
+ e_addressbook_view_set_search (
+ view, filter_id, search_id, search_text, advanced_search);
g_free (query);
g_free (search_text);