aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook
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
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')
-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
-rw-r--r--addressbook/gui/widgets/Makefile.am5
-rw-r--r--addressbook/gui/widgets/e-addressbook-view.c399
-rw-r--r--addressbook/gui/widgets/e-addressbook-view.h15
10 files changed, 205 insertions, 437 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
diff --git a/addressbook/gui/widgets/Makefile.am b/addressbook/gui/widgets/Makefile.am
index c39598f516..af8a069800 100644
--- a/addressbook/gui/widgets/Makefile.am
+++ b/addressbook/gui/widgets/Makefile.am
@@ -7,6 +7,7 @@ INCLUDES = \
-DEVOLUTION_GALVIEWSDIR=\""$(viewsdir)"\" \
-DSEARCH_RULE_DIR=\"$(ruledir)\" \
-I$(top_srcdir) \
+ -I$(top_srcdir)/filter \
-I$(top_srcdir)/widgets \
-I$(top_srcdir)/addressbook \
-I$(top_srcdir)/addressbook/gui/contact-editor \
@@ -80,5 +81,5 @@ etspec_DATA= e-addressbook-view.etspec
EXTRA_DIST = \
$(etspec_DATA) \
- eab-marshal.list \
- addresstypes.xml
+ $(rule_DATA) \
+ eab-marshal.list
diff --git a/addressbook/gui/widgets/e-addressbook-view.c b/addressbook/gui/widgets/e-addressbook-view.c
index d44898ba1a..3a221342d8 100644
--- a/addressbook/gui/widgets/e-addressbook-view.c
+++ b/addressbook/gui/widgets/e-addressbook-view.c
@@ -98,13 +98,6 @@ static void selection_get (GtkWidget *invisible, GtkSelectionData *selection_dat
guint info, guint time_stamp, EABView *view);
static void invisible_destroyed (gpointer data, GObject *where_object_was);
-static void categories_changed_cb (gpointer object, gpointer user_data);
-static void make_suboptions (EABView *view);
-static void query_changed (ESearchBar *esb, EABView *view);
-static void search_activated (ESearchBar *esb, EABView *view);
-static void search_menu_activated (ESearchBar *esb, int id, EABView *view);
-static GList *get_master_list (gboolean force_rebuild);
-
static gpointer parent_class;
/* The arguments we take */
@@ -131,11 +124,6 @@ enum DndTargetType {
#define VCARD_TYPE "text/x-vcard"
#define SOURCE_VCARD_TYPE "text/x-source-vcard"
-typedef struct EABSearchBarItem {
- ESearchBarItem search;
- char *image;
-}EABSearchBarItem;
-
static GtkTargetEntry drag_types[] = {
{ SOURCE_VCARD_TYPE, 0, DND_TARGET_TYPE_SOURCE_VCARD },
{ VCARD_TYPE, 0, DND_TARGET_TYPE_VCARD }
@@ -148,29 +136,6 @@ static GdkAtom clipboard_atom = GDK_NONE;
static GalViewCollection *collection = NULL;
-enum {
- ESB_FULL_NAME,
- ESB_EMAIL,
- ESB_ANY,
-};
-
-#if 0
-static ESearchBarItem addressbook_search_option_items[] = {
- { N_("Name begins with"), ESB_FULL_NAME },
- { N_("Email begins with"), ESB_EMAIL },
- { N_("Any field contains"), ESB_ANY },
- { NULL, -1 }
-};
-#endif
-
-static ESearchBarItem addressbook_search_items[] = {
- E_FILTERBAR_ADVANCED,
- {NULL, 0, 0},
- E_FILTERBAR_SAVE,
- E_FILTERBAR_EDIT,
- {NULL, -1, 0}
-};
-
GType
eab_view_get_type (void)
{
@@ -295,7 +260,6 @@ eab_view_init (EABView *eav)
eav->view_instance = NULL;
/*eav->view_menus = NULL;*/
eav->current_view = NULL;
- eav->uic = NULL;
eav->book = NULL;
eav->source = NULL;
@@ -310,8 +274,6 @@ eab_view_dispose (GObject *object)
{
EABView *eav = EAB_VIEW(object);
- e_categories_unregister_change_listener (G_CALLBACK (categories_changed_cb), eav);
-
if (eav->model) {
g_signal_handlers_disconnect_matched (eav->model,
G_SIGNAL_MATCH_DATA,
@@ -336,8 +298,6 @@ eab_view_dispose (GObject *object)
eav->query = NULL;
}
- eav->uic = NULL;
-
if (eav->view_instance) {
g_object_unref (eav->view_instance);
eav->view_instance = NULL;
@@ -359,18 +319,6 @@ eab_view_dispose (GObject *object)
eav->invisible = NULL;
}
- /*
- if (eav->search_context) {
- g_object_unref (eav->search_context);
- eav->search_context = NULL;
- }
- */
-
- if (eav->search_rule) {
- g_object_unref (eav->search_rule);
- eav->search_rule = NULL;
- }
-
G_OBJECT_CLASS (parent_class)->dispose (object);
}
@@ -413,9 +361,6 @@ eab_view_new (void)
{
GtkWidget *widget = GTK_WIDGET (g_object_new (E_TYPE_AB_VIEW, NULL));
EABView *eav = EAB_VIEW (widget);
- FilterPart *part;
- char *xmlfile;
- char *userfile;
/* create our model */
eav->model = eab_model_new ();
@@ -440,49 +385,6 @@ eab_view_new (void)
eav->editable = FALSE;
eav->query = g_strdup (SHOW_ALL_SEARCH);
- /* create the search context */
- eav->search_context = rule_context_new ();
- rule_context_add_part_set (eav->search_context, "partset", filter_part_get_type (),
- rule_context_add_part, rule_context_next_part);
- rule_context_add_rule_set (eav->search_context, "ruleset", filter_rule_get_type (),
- rule_context_add_rule, rule_context_next_rule);
-
- userfile = g_build_filename ( g_get_home_dir (), ".evolution/addressbook/searches.xml", NULL);
- xmlfile = g_build_filename (SEARCH_RULE_DIR, "addresstypes.xml", NULL);
-
- g_object_set_data_full (G_OBJECT (eav->search_context), "user", userfile, g_free);
- g_object_set_data_full (G_OBJECT (eav->search_context), "system", xmlfile, g_free);
-
- rule_context_load (eav->search_context, xmlfile, userfile);
-
- eav->search_rule = filter_rule_new ();
- part = rule_context_next_part (eav->search_context, NULL);
-
- if (part == NULL)
- g_warning ("Could not load addressbook search; no parts.");
- else
- filter_rule_add_part (eav->search_rule, filter_part_clone (part));
-
- eav->search = e_filter_bar_new (eav->search_context, xmlfile, userfile, NULL, eav);
-
- g_free (xmlfile);
- g_free (userfile);
-
- e_search_bar_set_menu ( (ESearchBar *) eav->search, addressbook_search_items);
- gtk_widget_show (GTK_WIDGET (eav->search));
- make_suboptions (eav);
-
- e_categories_register_change_listener (G_CALLBACK (categories_changed_cb), eav);
-
- g_signal_connect (eav->search, "query_changed",
- G_CALLBACK (query_changed), eav);
- g_signal_connect (eav->search, "search_activated",
- G_CALLBACK (search_activated), eav);
- g_signal_connect (eav->search, "menu_activated",
- G_CALLBACK (search_menu_activated), eav);
-
- gtk_box_pack_start (GTK_BOX (eav), GTK_WIDGET (eav->search), FALSE, FALSE, 0);
-
/* create the paned window and contact display */
eav->paned = gtk_vpaned_new ();
gtk_box_pack_start (GTK_BOX (eav), eav->paned, TRUE, TRUE, 0);
@@ -521,18 +423,6 @@ eab_view_new (void)
return widget;
}
-RuleContext *
-eab_view_peek_search_context (EABView *view)
-{
- return view->search_context;
-}
-
-FilterRule *
-eab_view_peek_search_rule (EABView *view)
-{
- return view->search_rule;
-}
-
static void
writable_status (GtkObject *object, gboolean writable, EABView *eav)
{
@@ -560,24 +450,6 @@ display_view(GalViewInstance *instance,
}
static void
-setup_menus (EABView *view)
-{
- if (view->book && view->view_instance == NULL) {
- view->view_instance = gal_view_instance_new (collection, e_book_get_uri (view->book));
- }
-
- if (view->view_instance && view->uic) {
- /*view->view_menus = gal_view_menus_new(view->view_instance);
- gal_view_menus_apply(view->view_menus, view->uic, NULL);*/
-
- display_view (view->view_instance, gal_view_instance_get_current_view (view->view_instance), view);
-
- g_signal_connect(view->view_instance, "display_view",
- G_CALLBACK (display_view), view);
- }
-}
-
-static void
eab_view_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
{
EABView *eav = EAB_VIEW(object);
@@ -590,11 +462,9 @@ eab_view_set_property (GObject *object, guint prop_id, const GValue *value, GPar
if (g_value_get_object (value)) {
eav->book = E_BOOK(g_value_get_object (value));
g_object_ref (eav->book);
- gtk_widget_set_sensitive (GTK_WIDGET (eav->search), TRUE);
}
else {
eav->book = NULL;
- gtk_widget_set_sensitive (GTK_WIDGET (eav->search), FALSE);
}
if (eav->view_instance) {
@@ -606,8 +476,6 @@ eab_view_set_property (GObject *object, guint prop_id, const GValue *value, GPar
"book", eav->book,
NULL);
- setup_menus (eav);
-
break;
case PROP_SOURCE:
if (eav->source) {
@@ -1263,225 +1131,6 @@ change_view_type (EABView *view, EABViewType view_type)
command_state_change (view);
}
-
-
-static void
-search_activated (ESearchBar *esb, EABView *v)
-{
- GList *master_list;
- char *search_word, *search_query, *view_sexp;
- const char *category_name;
- int search_type, subid;
-
- g_object_get(esb,
- "text", &search_word,
- "item_id", &search_type,
- NULL);
-
- if (search_type == E_FILTERBAR_ADVANCED_ID) {
- // gtk_widget_show(eab_search_dialog_new(v));
- }
- else {
- if ((search_word && strlen (search_word))) {
- GString *s = g_string_new ("");
- e_sexp_encode_string (s, search_word);
- switch (search_type) {
- case ESB_ANY:
- search_query = g_strdup_printf ("(contains \"x-evolution-any-field\" %s)",
- s->str);
- break;
- case ESB_FULL_NAME:
- search_query = g_strdup_printf ("(contains \"full_name\" %s)",
- s->str);
- break;
- case ESB_EMAIL:
- search_query = g_strdup_printf ("(beginswith \"email\" %s)",
- s->str);
- break;
- default:
- search_query = g_strdup ("(contains \"x-evolution-any-field\" \"\")");
- break;
- }
- g_string_free (s, TRUE);
-
- } else
- search_query = g_strdup ("(contains \"x-evolution-any-field\" \"\")");
-
- /* Merge view and sexp */
- subid = e_search_bar_get_viewitem_id (esb);
-
- if (subid) {
- master_list = get_master_list (FALSE);
- category_name = g_list_nth_data (master_list, subid-1);
- view_sexp = g_strdup_printf ("(is \"category_list\" \"%s\")", category_name);
- search_query = g_strconcat ("(and ", view_sexp, search_query, ")", NULL);
- g_free (view_sexp);
- }
-
- if (search_query)
- g_object_set (v,
- "query", search_query,
- NULL);
-
- g_free (search_query);
- }
-
- g_free (search_word);
- v->displayed_contact = -1;
- eab_contact_display_render (EAB_CONTACT_DISPLAY (v->contact_display), NULL,
- EAB_CONTACT_DISPLAY_RENDER_NORMAL);
-}
-
-static void
-search_menu_activated (ESearchBar *esb, int id, EABView *view)
-{
- if (id == E_FILTERBAR_ADVANCED_ID)
- e_search_bar_set_item_id (esb, id);
-}
-
-static void
-query_changed (ESearchBar *esb, EABView *view)
-{
- int search_type;
- char *query;
-
- search_type = e_search_bar_get_item_id(esb);
- if (search_type == E_FILTERBAR_ADVANCED_ID) {
- g_object_get (esb, "query", &query, NULL);
- g_object_set (view, "query", query, NULL);
- g_free (query);
- }
-}
-
-static int
-compare_subitems (const void *a, const void *b)
-{
- const ESearchBarItem *subitem_a = a;
- const ESearchBarItem *subitem_b = b;
- char *collate_a, *collate_b;
- int ret;
-
- collate_a = g_utf8_collate_key (subitem_a->text, -1);
- collate_b = g_utf8_collate_key (subitem_b->text, -1);
-
- ret = strcmp (collate_a, collate_b);
-
- g_free (collate_a);
- g_free (collate_b);
-
- return ret;
-}
-
-static GtkWidget *
-generate_viewoption_menu (EABSearchBarItem *subitems)
-{
- GtkWidget *menu, *menu_item;
- gint i = 0;
-
- menu = gtk_menu_new ();
-
- for (i = 0; subitems[i].search.id != -1; ++i) {
- if (subitems[i].search.text) {
- char *str = NULL;
- str = e_str_without_underscores (subitems[i].search.text);
- menu_item = gtk_image_menu_item_new_with_label (str);
- if (subitems[i].image) {
- GtkWidget *image;
-
- image = gtk_image_new_from_icon_name (
- subitems[i].image,
- GTK_ICON_SIZE_MENU);
- gtk_image_menu_item_set_image (
- GTK_IMAGE_MENU_ITEM (menu_item),
- image);
- }
- g_free (str);
- } else {
- menu_item = gtk_menu_item_new ();
- gtk_widget_set_sensitive (menu_item, FALSE);
- }
-
- g_object_set_data (G_OBJECT (menu_item), "EsbItemId",
- GINT_TO_POINTER (subitems[i].search.id));
-
- gtk_widget_show (menu_item);
- gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
- }
-
- return menu;
-}
-
-static void
-categories_changed_cb (gpointer object, gpointer user_data)
-{
- get_master_list (TRUE);
- make_suboptions (user_data);
-}
-
-static void
-make_suboptions (EABView *view)
-{
- EABSearchBarItem *subitems, *s;
- GList *master_list;
- gint i, N;
- GtkWidget *menu;
-
- master_list = get_master_list (FALSE);
- N = g_list_length (master_list);
- subitems = g_new (EABSearchBarItem, N+2);
-
- subitems[0].search.id = 0;
- subitems[0].search.text = g_strdup (_("Any Category"));
- subitems[0].image = NULL;
-
- for (i=0; i<N; ++i) {
- const char *category = g_list_nth_data (master_list, i);
- subitems[i+1].search.id = i+1;
- subitems[i+1].search.text = g_strdup (category);
- subitems[i+1].image = (char *)e_categories_get_icon_file_for (category);
- }
-
- subitems[N+1].search.id = -1;
- subitems[N+1].search.text = NULL;
- subitems[N+1].image = NULL;
-
- qsort (subitems + 1, N, sizeof (subitems[0]), compare_subitems);
- menu = generate_viewoption_menu (subitems);
- e_search_bar_set_viewoption_menu ((ESearchBar *)view->search, menu);
-
- for (s = subitems; ((ESearchBarItem *)s)->id != -1; s++) {
- if (((ESearchBarItem *)s)->text)
- g_free (((ESearchBarItem *)s)->text);
- }
- g_free (subitems);
-}
-
-static GList *
-get_master_list (gboolean force_rebuild)
-{
- static GList *category_list = NULL;
-
- if (force_rebuild) {
- g_list_free (category_list);
- category_list = NULL;
- }
-
- if (category_list == NULL) {
- GList *l, *p = e_categories_get_list ();
-
- for (l = p; l; l = l->next) {
- if (e_categories_is_searchable ((const char *) l->data))
- category_list = g_list_prepend (category_list, l->data);
- }
-
- category_list = g_list_reverse (category_list);
-
- g_list_free (p);
- }
-
- return category_list;
-}
-
static void
contact_print_button_draw_page (GtkPrintOperation *operation,
GtkPrintContext *context,
@@ -1536,54 +1185,6 @@ eab_view_show_contact_preview (EABView *view, gboolean show)
}
void
-eab_view_setup_menus (EABView *view,
- BonoboUIComponent *uic)
-{
-
- g_return_if_fail (view != NULL);
- g_return_if_fail (E_IS_ADDRESSBOOK_VIEW (view));
- g_return_if_fail (uic != NULL);
- g_return_if_fail (BONOBO_IS_UI_COMPONENT (uic));
-
- view->uic = uic;
-
- setup_menus (view);
-
- /* XXX toshok - yeah this really doesn't belong here, but it
- needs to happen at the same time and takes the uic */
- e_search_bar_set_ui_component ( (ESearchBar *)view->search, uic);
-}
-
-/**
- * eab_view_discard_menus:
- * @view: An addressbook view.
- *
- * Makes an addressbook view discard its GAL view menus and its views instance
- * objects. This should be called when the corresponding Bonobo component is
- * deactivated.
- **/
-void
-eab_view_discard_menus (EABView *view)
-{
- g_return_if_fail (view != NULL);
- g_return_if_fail (E_IS_ADDRESSBOOK_VIEW (view));
-
- /*if (view->view_menus) {
- gal_view_menus_unmerge (view->view_menus, NULL);
-
- g_object_unref (view->view_menus);
- view->view_menus = NULL;
- }*/
-
- if (view->view_instance) {
- g_object_unref (view->view_instance);
- view->view_instance = NULL;
- }
-
- view->uic = NULL;
-}
-
-void
eab_view_print (EABView *view, GtkPrintOperationAction action)
{
if (view->view_type == EAB_VIEW_MINICARD) {
diff --git a/addressbook/gui/widgets/e-addressbook-view.h b/addressbook/gui/widgets/e-addressbook-view.h
index af5d50a78f..eae3b54861 100644
--- a/addressbook/gui/widgets/e-addressbook-view.h
+++ b/addressbook/gui/widgets/e-addressbook-view.h
@@ -27,7 +27,6 @@
#include "e-addressbook-model.h"
#include "eab-contact-display.h"
#include "misc/e-search-bar.h"
-#include "misc/e-filter-bar.h"
/* Standard GObject macros */
#define E_TYPE_AB_VIEW \
@@ -92,13 +91,6 @@ struct _EABView {
GalViewInstance *view_instance;
/*GalViewMenus *view_menus;*/
GalView *current_view;
- BonoboUIComponent *uic;
-
- /* the search bar and related machinery */
- EFilterBar *search;
- gint ecml_changed_id;
- RuleContext *search_context;
- FilterRule *search_rule;
};
struct _EABViewClass {
@@ -115,13 +107,6 @@ GType eab_view_get_type (void);
GtkWidget * eab_view_new (void);
void eab_view_show_contact_preview (EABView *view,
gboolean show);
-void eab_view_setup_menus (EABView *view,
- BonoboUIComponent *uic);
-void eab_view_discard_menus (EABView *view);
-
-RuleContext * eab_view_peek_search_context (EABView *view);
-FilterRule * eab_view_peek_search_rule (EABView *view);
-
void eab_view_save_as (EABView *view,
gboolean all);
void eab_view_view (EABView *view);