aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui/component
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@src.gnome.org>2008-09-07 12:02:27 +0800
committerMatthew Barnes <mbarnes@src.gnome.org>2008-09-07 12:02:27 +0800
commit52d683e48cf1103a9806da95c72abce2db3ae1f4 (patch)
treeb6cee16af70a03666a2d7add2e5bff5c6ed8035c /addressbook/gui/component
parenteca687589d106ff87cd4fca7bf581cb0532caf96 (diff)
downloadgsoc2013-evolution-52d683e48cf1103a9806da95c72abce2db3ae1f4.tar.gz
gsoc2013-evolution-52d683e48cf1103a9806da95c72abce2db3ae1f4.tar.zst
gsoc2013-evolution-52d683e48cf1103a9806da95c72abce2db3ae1f4.zip
Progress update:
- Contacts module mostly working now. - View and search UI not yet working. - Still refining shell design. svn path=/branches/kill-bonobo/; revision=36268
Diffstat (limited to 'addressbook/gui/component')
-rw-r--r--addressbook/gui/component/Makefile.am1
-rw-r--r--addressbook/gui/component/addressbook-view.c14
-rw-r--r--addressbook/gui/component/e-book-shell-module.c2
-rw-r--r--addressbook/gui/component/e-book-shell-view-actions.c121
-rw-r--r--addressbook/gui/component/e-book-shell-view-actions.h10
-rw-r--r--addressbook/gui/component/e-book-shell-view-private.c61
-rw-r--r--addressbook/gui/component/e-book-shell-view-private.h14
7 files changed, 202 insertions, 21 deletions
diff --git a/addressbook/gui/component/Makefile.am b/addressbook/gui/component/Makefile.am
index b78e2ba0e1..adf68f4e15 100644
--- a/addressbook/gui/component/Makefile.am
+++ b/addressbook/gui/component/Makefile.am
@@ -60,7 +60,6 @@ libevolution_addressbook_la_LIBADD = \
$(top_builddir)/widgets/table/libetable.la \
$(top_builddir)/widgets/text/libetext.la \
$(top_builddir)/widgets/misc/libemiscwidgets.la \
- $(top_builddir)/widgets/misc/libefilterbar.la \
$(top_builddir)/widgets/menus/libmenus.la \
$(top_builddir)/a11y/addressbook/libevolution-addressbook-a11y.la \
$(top_builddir)/addressbook/importers/libevolution-addressbook-importers.la \
diff --git a/addressbook/gui/component/addressbook-view.c b/addressbook/gui/component/addressbook-view.c
index 992dd602f4..c3bb7c43d7 100644
--- a/addressbook/gui/component/addressbook-view.c
+++ b/addressbook/gui/component/addressbook-view.c
@@ -109,20 +109,6 @@ control_activate (BonoboControl *control,
EABView *v = get_current_view (view);
char *xmlfile;
- remote_ui_container = bonobo_control_get_remote_ui_container (control, NULL);
- bonobo_ui_component_set_container (uic, remote_ui_container, NULL);
- bonobo_object_release_unref (remote_ui_container, NULL);
-
- bonobo_ui_component_freeze (uic, NULL);
-
- xmlfile = g_build_filename (EVOLUTION_UIDIR,
- "evolution-addressbook.xml",
- NULL);
- bonobo_ui_util_set_ui (uic, PREFIX,
- xmlfile,
- "evolution-addressbook", NULL);
- g_free (xmlfile);
-
if (v)
eab_view_setup_menus (v, uic);
diff --git a/addressbook/gui/component/e-book-shell-module.c b/addressbook/gui/component/e-book-shell-module.c
index 1be7a6782d..08c372f220 100644
--- a/addressbook/gui/component/e-book-shell-module.c
+++ b/addressbook/gui/component/e-book-shell-module.c
@@ -42,6 +42,7 @@
#define MODULE_NAME "addressbook"
#define MODULE_ALIASES ""
#define MODULE_SCHEMES ""
+#define MODULE_SEARCHES "addresstypes.xml"
#define MODULE_SORT_ORDER 300
#define LDAP_BASE_URI "ldap://"
@@ -417,6 +418,7 @@ static EShellModuleInfo module_info = {
MODULE_NAME,
MODULE_ALIASES,
MODULE_SCHEMES,
+ MODULE_SEARCHES,
MODULE_SORT_ORDER,
/* Methods */
diff --git a/addressbook/gui/component/e-book-shell-view-actions.c b/addressbook/gui/component/e-book-shell-view-actions.c
index 5b07b84557..e5e08e34a2 100644
--- a/addressbook/gui/component/e-book-shell-view-actions.c
+++ b/addressbook/gui/component/e-book-shell-view-actions.c
@@ -364,6 +364,93 @@ action_contact_send_message_cb (GtkAction *action,
eab_view_send_to (view);
}
+static void
+action_search_execute_cb (GtkAction *action,
+ EBookShellView *book_shell_view)
+{
+ EShellView *shell_view;
+ EShellWindow *shell_window;
+ GtkWidget *widget;
+ GString *string;
+ EABView *view;
+ const gchar *search_format;
+ const gchar *search_text;
+ gchar *search_query;
+ gint value;
+
+ shell_view = E_SHELL_VIEW (book_shell_view);
+ if (!e_shell_view_is_selected (shell_view))
+ return;
+
+ /* Dig up the search text. */
+ widget = e_shell_view_get_content_widget (shell_view);
+ widget = e_shell_content_get_search_bar (E_SHELL_CONTENT (widget));
+ search_text = e_search_bar_get_search_text (E_SEARCH_BAR (widget));
+
+ shell_window = e_shell_view_get_window (shell_view);
+ action = ACTION (CONTACT_SEARCH_ANY_FIELD_CONTAINS);
+ value = gtk_radio_action_get_current_value (
+ GTK_RADIO_ACTION (action));
+
+ if (search_text == NULL || *search_text == '\0') {
+ search_text = "\"\"";
+ value = CONTACT_SEARCH_ANY_FIELD_CONTAINS;
+ }
+
+ switch (value) {
+ case CONTACT_SEARCH_NAME_CONTAINS:
+ search_format = "(contains \"full_name\" %s)";
+ break;
+
+ case CONTACT_SEARCH_EMAIL_BEGINS_WITH:
+ search_format = "(beginswith \"email\" %s)";
+ break;
+
+ default:
+ search_text = "\"\"";
+ /* fall through */
+
+ case CONTACT_SEARCH_ANY_FIELD_CONTAINS:
+ search_format =
+ "(contains \"x-evolution-any-field\" %s)";
+ break;
+ }
+
+ /* Build the query. */
+ string = g_string_new ("");
+ e_sexp_encode_string (string, search_text);
+ search_query = g_strdup_printf (search_format, string->str);
+ g_string_free (string, TRUE);
+
+ /* Filter by category. */
+ value = e_search_bar_get_filter_value (E_SEARCH_BAR (widget));
+ if (value >= 0) {
+ 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, search_query);
+ g_free (search_query);
+ search_query = temp;
+ }
+
+ /* Submit the query. */
+ view = e_book_shell_view_get_current_view (book_shell_view);
+ g_object_set (view, "query", search_query, NULL);
+ g_free (search_query);
+
+ view->displayed_contact = -1;
+ eab_contact_display_render (
+ EAB_CONTACT_DISPLAY (view->contact_display),
+ NULL, EAB_CONTACT_DISPLAY_RENDER_NORMAL);
+}
+
static GtkActionEntry contact_entries[] = {
{ "address-book-copy",
@@ -564,6 +651,30 @@ static GtkToggleActionEntry contact_toggle_entries[] = {
TRUE }
};
+static GtkRadioActionEntry contact_search_entries[] = {
+
+ { "contact-search-any-field-contains",
+ NULL,
+ N_("Any field contains"),
+ NULL,
+ NULL, /* XXX Add a tooltip! */
+ CONTACT_SEARCH_ANY_FIELD_CONTAINS },
+
+ { "contact-search-email-begins-with",
+ NULL,
+ N_("Email begins with"),
+ NULL,
+ NULL, /* XXX Add a tooltip! */
+ CONTACT_SEARCH_EMAIL_BEGINS_WITH },
+
+ { "contact-search-name-contains",
+ NULL,
+ N_("Name contains"),
+ NULL,
+ NULL, /* XXX Add a tooltip! */
+ CONTACT_SEARCH_NAME_CONTAINS }
+};
+
void
e_book_shell_view_actions_init (EBookShellView *book_shell_view)
{
@@ -592,6 +703,11 @@ e_book_shell_view_actions_init (EBookShellView *book_shell_view)
gtk_action_group_add_toggle_actions (
action_group, contact_toggle_entries,
G_N_ELEMENTS (contact_toggle_entries), book_shell_view);
+ gtk_action_group_add_radio_actions (
+ action_group, contact_search_entries,
+ G_N_ELEMENTS (contact_search_entries),
+ CONTACT_SEARCH_NAME_CONTAINS,
+ NULL, NULL);
gtk_ui_manager_insert_action_group (manager, action_group, 0);
/* Bind GObject properties to GConf keys. */
@@ -606,6 +722,10 @@ e_book_shell_view_actions_init (EBookShellView *book_shell_view)
action = ACTION (CONTACT_DELETE);
g_object_set (action, "short-label", _("Delete"), NULL);
+
+ g_signal_connect (
+ ACTION (SEARCH_EXECUTE), "activate",
+ G_CALLBACK (action_search_execute_cb), book_shell_view);
}
void
@@ -694,4 +814,3 @@ e_book_shell_view_update_actions (EBookShellView *book_shell_view,
sensitive = FALSE;
gtk_action_set_sensitive (action, sensitive);
}
-
diff --git a/addressbook/gui/component/e-book-shell-view-actions.h b/addressbook/gui/component/e-book-shell-view-actions.h
index bce21fe634..a809eeacf9 100644
--- a/addressbook/gui/component/e-book-shell-view-actions.h
+++ b/addressbook/gui/component/e-book-shell-view-actions.h
@@ -43,7 +43,7 @@
#define E_SHELL_WINDOW_ACTION_CONTACT_CLIPBOARD_COPY(window) \
E_SHELL_WINDOW_ACTION ((window), "contact-clipboard-copy")
#define E_SHELL_WINDOW_ACTION_CONTACT_CLIPBOARD_CUT(window) \
- E_SHELL_WINDOW_ACTION ((window), "contact-clipbard-cut")
+ E_SHELL_WINDOW_ACTION ((window), "contact-clipboard-cut")
#define E_SHELL_WINDOW_ACTION_CONTACT_CLIPBOARD_PASTE(window) \
E_SHELL_WINDOW_ACTION ((window), "contact-clipboard-paste")
#define E_SHELL_WINDOW_ACTION_CONTACT_COPY(window) \
@@ -73,6 +73,14 @@
#define E_SHELL_WINDOW_ACTION_CONTACT_SEND_MESSAGE(window) \
E_SHELL_WINDOW_ACTION ((window), "contact-send-message")
+/* Search Actions */
+#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) \
+ E_SHELL_WINDOW_ACTION ((window), "contact-search-email-begins-with")
+#define E_SHELL_WINDOW_ACTION_CONTACT_SEARCH_NAME_CONTAINS(window) \
+ E_SHELL_WINDOW_ACTION ((window), "contact-search-name-contains")
+
/* Action Groups */
#define E_SHELL_WINDOW_ACTION_GROUP_CONTACTS(window) \
E_SHELL_WINDOW_ACTION_GROUP ((window), "contacts")
diff --git a/addressbook/gui/component/e-book-shell-view-private.c b/addressbook/gui/component/e-book-shell-view-private.c
index b75a8c6f60..71be4b5254 100644
--- a/addressbook/gui/component/e-book-shell-view-private.c
+++ b/addressbook/gui/component/e-book-shell-view-private.c
@@ -75,17 +75,20 @@ set_folder_bar_message (EABView *view,
EShellView *shell_view;
EABView *current_view;
+ GtkWidget *widget;
const gchar *name;
shell_view = E_SHELL_VIEW (book_shell_view);
+
current_view = e_book_shell_view_get_current_view (book_shell_view);
if (view != current_view || view->source == NULL)
return;
name = e_source_peek_name (view->source);
+ widget = e_shell_view_get_sidebar_widget (shell_view);
- e_shell_view_set_primary_text (shell_view, name);
- e_shell_view_set_secondary_text (shell_view, message);
+ e_shell_sidebar_set_primary_text (E_SHELL_SIDEBAR (widget), name);
+ e_shell_sidebar_set_secondary_text (E_SHELL_SIDEBAR (widget), message);
}
static void
@@ -229,6 +232,12 @@ book_shell_view_show_popup_menu (GdkEventButton *event,
return TRUE;
}
+static void
+book_shell_view_categories_changed_cb (EBookShellView *book_shell_view)
+{
+ e_book_shell_view_update_search_filter (book_shell_view);
+}
+
static gboolean
book_shell_view_selector_button_press_event_cb (EShellView *shell_view,
GdkEventButton *event)
@@ -309,6 +318,7 @@ e_book_shell_view_private_init (EBookShellView *book_shell_view)
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (widget), FALSE);
gtk_notebook_set_show_border (GTK_NOTEBOOK (widget), FALSE);
gtk_container_add (GTK_CONTAINER (container), widget);
+ priv->notebook = g_object_ref (widget);
gtk_widget_show (widget);
widget = e_shell_view_get_taskbar_widget (shell_view);
@@ -354,6 +364,11 @@ e_book_shell_view_private_init (EBookShellView *book_shell_view)
book_shell_view);
book_shell_view_activate_selected_source (book_shell_view);
+
+ e_categories_register_change_listener (
+ G_CALLBACK (book_shell_view_categories_changed_cb),
+ book_shell_view);
+ e_book_shell_view_update_search_filter (book_shell_view);
}
void
@@ -364,9 +379,7 @@ e_book_shell_view_private_dispose (EBookShellView *book_shell_view)
DISPOSE (priv->contact_actions);
DISPOSE (priv->notebook);
- DISPOSE (priv->scrolled_window);
DISPOSE (priv->selector);
- DISPOSE (priv->task_bar);
DISPOSE (priv->activity_handler);
@@ -413,3 +426,43 @@ e_book_shell_view_editor_weak_notify (EditorUidClosure *closure,
hash_table = closure->view->priv->uid_to_editor;
g_hash_table_remove (hash_table, closure->uid);
}
+
+void
+e_book_shell_view_update_search_filter (EBookShellView *book_shell_view)
+{
+ EShellView *shell_view;
+ GtkRadioAction *action;
+ GtkWidget *widget;
+ GList *list, *iter;
+ GSList *group = NULL;
+ gint ii;
+
+ /* Dig up the search bar. */
+ shell_view = E_SHELL_VIEW (book_shell_view);
+ widget = e_shell_view_get_content_widget (shell_view);
+ widget = e_shell_content_get_search_bar (E_SHELL_CONTENT (widget));
+
+ action = gtk_radio_action_new (
+ "category-any", _("Any Category"), NULL, NULL, -1);
+
+ gtk_radio_action_set_group (action, group);
+ group = gtk_radio_action_get_group (action);
+
+ list = e_categories_get_list ();
+ for (iter = list, ii = 0; iter != NULL; iter = iter->next, ii++) {
+ const gchar *category_name = iter->data;
+ gchar *action_name;
+
+ action_name = g_strdup_printf ("category-%d", ii);
+ action = gtk_radio_action_new (
+ action_name, category_name, NULL, NULL, ii);
+ g_free (action_name);
+
+ gtk_radio_action_set_group (action, group);
+ group = gtk_radio_action_get_group (action);
+ }
+ g_list_free (list);
+
+ /* Use any action in the group; doesn't matter which. */
+ e_search_bar_set_filter_action (E_SEARCH_BAR (widget), action);
+}
diff --git a/addressbook/gui/component/e-book-shell-view-private.h b/addressbook/gui/component/e-book-shell-view-private.h
index 130e061dcd..80fb21dbde 100644
--- a/addressbook/gui/component/e-book-shell-view-private.h
+++ b/addressbook/gui/component/e-book-shell-view-private.h
@@ -27,8 +27,13 @@
#include <glib/gi18n.h>
#include <gdk/gdkkeysyms.h>
#include <libebook/e-book.h>
+#include <libedataserver/e-categories.h>
+#include <libedataserver/e-sexp.h>
#include <libedataserverui/e-source-selector.h>
+#include <shell/e-shell-content.h>
+#include <shell/e-shell-sidebar.h>
+
#include <eab-menu.h>
#include <eab-gui-util.h>
#include <e-activity-handler.h>
@@ -67,6 +72,13 @@ struct _EditorUidClosure {
EBookShellView *view;
};
+/* List these in the order to be displayed. */
+enum {
+ CONTACT_SEARCH_NAME_CONTAINS,
+ CONTACT_SEARCH_EMAIL_BEGINS_WITH,
+ CONTACT_SEARCH_ANY_FIELD_CONTAINS
+};
+
struct _EBookShellViewPrivate {
/*** UI Management ***/
@@ -110,6 +122,8 @@ EABView * e_book_shell_view_get_current_view
void e_book_shell_view_editor_weak_notify
(EditorUidClosure *closure,
GObject *where_the_object_was);
+void e_book_shell_view_update_search_filter
+ (EBookShellView *book_shell_view);
G_END_DECLS