diff options
Diffstat (limited to 'addressbook/gui')
7 files changed, 140 insertions, 89 deletions
diff --git a/addressbook/gui/component/addressbook-component.c b/addressbook/gui/component/addressbook-component.c index 5c3ad0999f..49e138e0de 100644 --- a/addressbook/gui/component/addressbook-component.c +++ b/addressbook/gui/component/addressbook-component.c @@ -92,25 +92,7 @@ addressbook_component_class_init (AddressbookComponentClass *class) static void addressbook_component_init (AddressbookComponent *component) { - static int first = TRUE; - #ifdef ENABLE_SMIME smime_component_init (); #endif - - if (first) { - EImportClass *klass; - - first = FALSE; - e_plugin_hook_register_type(eab_popup_hook_get_type()); - e_plugin_hook_register_type(eab_menu_hook_get_type()); - e_plugin_hook_register_type(eab_config_hook_get_type()); - - klass = g_type_class_ref(e_import_get_type()); - e_import_class_add_importer(klass, evolution_ldif_importer_peek(), NULL, NULL); - e_import_class_add_importer(klass, evolution_vcard_importer_peek(), NULL, NULL); - e_import_class_add_importer(klass, evolution_csv_outlook_importer_peek(), NULL, NULL); - e_import_class_add_importer(klass, evolution_csv_mozilla_importer_peek(), NULL, NULL); - e_import_class_add_importer(klass, evolution_csv_evolution_importer_peek(), NULL, NULL); - } } diff --git a/addressbook/gui/component/e-book-shell-module.c b/addressbook/gui/component/e-book-shell-module.c index 1b3e778ce8..480320185e 100644 --- a/addressbook/gui/component/e-book-shell-module.c +++ b/addressbook/gui/component/e-book-shell-module.c @@ -30,6 +30,10 @@ #include <e-shell-module.h> #include <e-shell-window.h> +#include <e-util/e-import.h> +#include <addressbook/importers/evolution-addressbook-importers.h> + +#include <eab-config.h> #include <eab-gui-util.h> #include <e-book-shell-view.h> #include <addressbook-config.h> @@ -178,6 +182,30 @@ book_module_ensure_sources (EShellModule *shell_module) } static void +book_module_init_importers (void) +{ + EImportClass *import_class; + EImportImporter *importer; + + import_class = g_type_class_ref (e_import_get_type ()); + + importer = evolution_ldif_importer_peek (); + e_import_class_add_importer (import_class, importer, NULL, NULL); + + importer = evolution_vcard_importer_peek (); + e_import_class_add_importer (import_class, importer, NULL, NULL); + + importer = evolution_csv_outlook_importer_peek (); + e_import_class_add_importer (import_class, importer, NULL, NULL); + + importer = evolution_csv_mozilla_importer_peek (); + e_import_class_add_importer (import_class, importer, NULL, NULL); + + importer = evolution_csv_evolution_importer_peek (); + e_import_class_add_importer (import_class, importer, NULL, NULL); +} + +static void book_module_book_loaded_cb (EBook *book, EBookStatus status, gpointer user_data) @@ -401,8 +429,11 @@ e_shell_module_init (GTypeModule *type_module) e_shell_module_set_info (shell_module, &module_info); + book_module_init_importers (); book_module_ensure_sources (shell_module); + e_plugin_hook_register_type (eab_config_get_type ()); + g_signal_connect_swapped ( shell, "handle-uri", G_CALLBACK (book_module_handle_uri), shell_module); diff --git a/addressbook/gui/component/e-book-shell-view-actions.c b/addressbook/gui/component/e-book-shell-view-actions.c index 89ca2c22a8..e27474aac0 100644 --- a/addressbook/gui/component/e-book-shell-view-actions.c +++ b/addressbook/gui/component/e-book-shell-view-actions.c @@ -22,7 +22,7 @@ #include <e-util/e-error.h> #include <e-util/e-util.h> -#include <e-util/gconf-bridge.h> +#include <filter/filter-rule.h> #include <addressbook-config.h> @@ -333,12 +333,14 @@ static void action_contact_preview_cb (GtkToggleAction *action, EBookShellView *book_shell_view) { - GtkWidget *widget; + GtkWidget *child; + GtkWidget *paned; gboolean visible; - widget = book_shell_view->priv->preview; + paned = book_shell_view->priv->paned; + child = gtk_paned_get_child2 (GTK_PANED (paned)); visible = gtk_toggle_action_get_active (action); - g_object_set (widget, "visible", visible, NULL); + g_object_set (child, "visible", visible, NULL); } static void @@ -426,10 +428,12 @@ action_search_execute_cb (GtkAction *action, EShellContent *shell_content; GString *string; EAddressbookView *view; + EAddressbookModel *model; EABContactDisplay *display; - const gchar *search_format; - const gchar *search_text; - gchar *search_query; + FilterRule *rule; + const gchar *format; + const gchar *text; + gchar *query; gint value; shell_view = E_SHELL_VIEW (book_shell_view); @@ -437,41 +441,40 @@ action_search_execute_cb (GtkAction *action, return; shell_content = e_shell_view_get_shell_content (shell_view); - search_text = e_shell_content_get_search_text (shell_content); + 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 (search_text == NULL || *search_text == '\0') { - search_text = "\"\""; + if (text == NULL || *text == '\0') { + text = ""; value = CONTACT_SEARCH_ANY_FIELD_CONTAINS; } switch (value) { case CONTACT_SEARCH_NAME_CONTAINS: - search_format = "(contains \"full_name\" %s)"; + format = "(contains \"full_name\" %s)"; break; case CONTACT_SEARCH_EMAIL_BEGINS_WITH: - search_format = "(beginswith \"email\" %s)"; + format = "(beginswith \"email\" %s)"; break; default: - search_text = "\"\""; + text = ""; /* fall through */ case CONTACT_SEARCH_ANY_FIELD_CONTAINS: - search_format = - "(contains \"x-evolution-any-field\" %s)"; + 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); + e_sexp_encode_string (string, text); + query = g_strdup_printf (format, string->str); g_string_free (string, TRUE); /* Filter by category. */ @@ -487,15 +490,23 @@ action_search_execute_cb (GtkAction *action, temp = g_strdup_printf ( "(and (is \"category_list\" \"%s\") %s)", - category_name, search_query); - g_free (search_query); - search_query = temp; + 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. */ view = e_book_shell_view_get_current_view (book_shell_view); - g_object_set (view, "query", search_query, NULL); - g_free (search_query); + model = e_addressbook_view_get_model (view); + e_addressbook_model_set_query (model, query); + g_free (query); display = EAB_CONTACT_DISPLAY (book_shell_view->priv->preview); eab_contact_display_set_contact (display, NULL); @@ -731,7 +742,7 @@ e_book_shell_view_actions_init (EBookShellView *book_shell_view) EShellView *shell_view; EShellWindow *shell_window; GtkActionGroup *action_group; - GtkUIManager *manager; + GtkUIManager *ui_manager; GConfBridge *bridge; GtkAction *action; GObject *object; @@ -740,11 +751,12 @@ e_book_shell_view_actions_init (EBookShellView *book_shell_view) shell_view = E_SHELL_VIEW (book_shell_view); shell_window = e_shell_view_get_shell_window (shell_view); - manager = e_shell_window_get_ui_manager (shell_window); + ui_manager = e_shell_window_get_ui_manager (shell_window); domain = GETTEXT_PACKAGE; - e_load_ui_definition (manager, "evolution-contacts.ui"); + e_load_ui_definition (ui_manager, "evolution-contacts.ui"); + /* Contact Actions */ action_group = book_shell_view->priv->contact_actions; gtk_action_group_set_translation_domain (action_group, domain); gtk_action_group_add_actions ( @@ -758,7 +770,12 @@ e_book_shell_view_actions_init (EBookShellView *book_shell_view) G_N_ELEMENTS (contact_search_entries), CONTACT_SEARCH_NAME_CONTAINS, NULL, NULL); - gtk_ui_manager_insert_action_group (manager, action_group, 0); + gtk_ui_manager_insert_action_group (ui_manager, action_group, 0); + + /* Filter Actions (empty) */ + action_group = book_shell_view->priv->filter_actions; + gtk_action_group_set_translation_domain (action_group, domain); + gtk_ui_manager_insert_action_group (ui_manager, action_group, 0); /* Bind GObject properties to GConf keys. */ @@ -894,3 +911,60 @@ e_book_shell_view_actions_update (EBookShellView *book_shell_view) sensitive = FALSE; gtk_action_set_sensitive (action, sensitive); } + +void +e_book_shell_view_update_search_filter (EBookShellView *book_shell_view) +{ + EShellContent *shell_content; + EShellView *shell_view; + GtkActionGroup *action_group; + GtkRadioAction *action; + GList *list, *iter; + GSList *group = NULL; + gint ii; + + shell_view = E_SHELL_VIEW (book_shell_view); + shell_content = e_shell_view_get_shell_content (shell_view); + action_group = book_shell_view->priv->filter_actions; + + /* XXX Annoying that GTK+ doesn't provide a function for this. + * http://bugzilla.gnome.org/show_bug.cgi?id=550485 */ + list = gtk_action_group_list_actions (action_group); + for (iter = list; iter != NULL; iter = iter->next) + gtk_action_group_remove_action (action_group, iter->data); + g_list_free (list); + + action = gtk_radio_action_new ( + "category-any", _("Any Category"), NULL, NULL, -1); + + /* Activating the action executes a new search. */ + g_signal_connect ( + action, "activate", + G_CALLBACK (action_search_execute_cb), book_shell_view); + + 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); + + /* Activating the action executes a new search. */ + g_signal_connect ( + action, "activate", G_CALLBACK ( + action_search_execute_cb), book_shell_view); + + 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_shell_content_set_filter_action (shell_content, action); +} diff --git a/addressbook/gui/component/e-book-shell-view-actions.h b/addressbook/gui/component/e-book-shell-view-actions.h index a809eeacf9..8119d7440c 100644 --- a/addressbook/gui/component/e-book-shell-view-actions.h +++ b/addressbook/gui/component/e-book-shell-view-actions.h @@ -84,5 +84,7 @@ /* Action Groups */ #define E_SHELL_WINDOW_ACTION_GROUP_CONTACTS(window) \ E_SHELL_WINDOW_ACTION_GROUP ((window), "contacts") +#define E_SHELL_WINDOW_ACTION_GROUP_CONTACTS_FILTER(window) \ + E_SHELL_WINDOW_ACTION_GROUP ((window), "contacts-filter") #endif /* E_BOOK_SHELL_VIEW_ACTIONS_H */ diff --git a/addressbook/gui/component/e-book-shell-view-private.c b/addressbook/gui/component/e-book-shell-view-private.c index 68d8425ef8..4dd88e7758 100644 --- a/addressbook/gui/component/e-book-shell-view-private.c +++ b/addressbook/gui/component/e-book-shell-view-private.c @@ -262,12 +262,6 @@ 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) @@ -384,6 +378,7 @@ e_book_shell_view_private_init (EBookShellView *book_shell_view, priv->source_list = g_object_ref (source_list); priv->contact_actions = gtk_action_group_new ("contacts"); + priv->filter_actions = gtk_action_group_new ("contacts-filter"); priv->uid_to_view = uid_to_view; priv->uid_to_editor = uid_to_editor; @@ -476,7 +471,7 @@ e_book_shell_view_private_constructed (EBookShellView *book_shell_view) book_shell_view); e_categories_register_change_listener ( - G_CALLBACK (book_shell_view_categories_changed_cb), + G_CALLBACK (e_book_shell_view_update_search_filter), book_shell_view); e_book_shell_view_actions_init (book_shell_view); @@ -500,6 +495,7 @@ e_book_shell_view_private_dispose (EBookShellView *book_shell_view) DISPOSE (priv->source_list); DISPOSE (priv->contact_actions); + DISPOSE (priv->filter_actions); DISPOSE (priv->paned); DISPOSE (priv->notebook); @@ -543,41 +539,3 @@ 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) -{ - EShellContent *shell_content; - EShellView *shell_view; - GtkRadioAction *action; - GList *list, *iter; - GSList *group = NULL; - gint ii; - - shell_view = E_SHELL_VIEW (book_shell_view); - shell_content = e_shell_view_get_shell_content (shell_view); - - 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_shell_content_set_filter_action (shell_content, action); -} diff --git a/addressbook/gui/component/e-book-shell-view-private.h b/addressbook/gui/component/e-book-shell-view-private.h index 24af21539b..f4a9d25b91 100644 --- a/addressbook/gui/component/e-book-shell-view-private.h +++ b/addressbook/gui/component/e-book-shell-view-private.h @@ -86,6 +86,7 @@ struct _EBookShellViewPrivate { /*** UI Management ***/ GtkActionGroup *contact_actions; + GtkActionGroup *filter_actions; /*** Other Stuff ***/ diff --git a/addressbook/gui/component/e-book-shell-view.c b/addressbook/gui/component/e-book-shell-view.c index 9a90b1d1f5..c2b8450b79 100644 --- a/addressbook/gui/component/e-book-shell-view.c +++ b/addressbook/gui/component/e-book-shell-view.c @@ -20,6 +20,8 @@ #include "e-book-shell-view-private.h" +#define SEARCH_OPTIONS_PATH "/contact-search-options" + enum { PROP_0, PROP_SOURCE_LIST @@ -166,6 +168,7 @@ book_shell_view_class_init (EBookShellViewClass *class, shell_view_class->icon_name = "x-office-address-book"; shell_view_class->type_module = type_module; shell_view_class->changed = book_shell_view_changed; + shell_view_class->search_options_path = SEARCH_OPTIONS_PATH; shell_view_class->new_shell_sidebar = e_book_shell_sidebar_new; g_object_class_install_property ( |