From eca687589d106ff87cd4fca7bf581cb0532caf96 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Fri, 5 Sep 2008 15:47:38 +0000 Subject: Saving progress. Lots of changes. Things are a bit broken at the moment. svn path=/branches/kill-bonobo/; revision=36260 --- addressbook/gui/component/Makefile.am | 3 + addressbook/gui/component/addressbook-view.c | 546 --------------------- addressbook/gui/component/autocompletion-config.c | 4 +- addressbook/gui/component/e-book-shell-module.c | 56 ++- .../gui/component/e-book-shell-view-actions.c | 144 +++++- .../gui/component/e-book-shell-view-actions.h | 6 + .../gui/component/e-book-shell-view-private.c | 220 ++++++++- .../gui/component/e-book-shell-view-private.h | 11 +- addressbook/gui/component/e-book-shell-view.c | 141 +----- addressbook/gui/widgets/Makefile.am | 3 + .../gui/widgets/e-addressbook-reflow-adapter.c | 1 - addressbook/gui/widgets/e-addressbook-selector.c | 376 ++++++++++++++ addressbook/gui/widgets/e-addressbook-selector.h | 66 +++ addressbook/gui/widgets/e-addressbook-view.c | 114 +---- addressbook/gui/widgets/e-addressbook-view.h | 149 +++--- 15 files changed, 990 insertions(+), 850 deletions(-) create mode 100644 addressbook/gui/widgets/e-addressbook-selector.c create mode 100644 addressbook/gui/widgets/e-addressbook-selector.h (limited to 'addressbook') diff --git a/addressbook/gui/component/Makefile.am b/addressbook/gui/component/Makefile.am index 7eaa46b079..b78e2ba0e1 100644 --- a/addressbook/gui/component/Makefile.am +++ b/addressbook/gui/component/Makefile.am @@ -8,12 +8,15 @@ INCLUDES = \ -I$(top_srcdir)/widgets \ -I$(top_srcdir)/shell \ -I$(top_builddir)/shell \ + -I$(top_srcdir)/widgets/menus \ -I$(top_srcdir)/widgets/misc \ -I$(top_srcdir)/addressbook/util \ -I$(top_srcdir)/addressbook/gui/contact-editor \ -I$(top_srcdir)/addressbook/gui/contact-list-editor \ -I$(top_srcdir)/addressbook/gui/widgets \ -I$(top_srcdir)/a11y/addressbook \ + -DEVOLUTION_ETSPECDIR=\""$(etspecdir)"\" \ + -DEVOLUTION_GALVIEWSDIR=\""$(viewsdir)"\" \ -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \ -DEVOLUTION_UIDIR=\""$(evolutionuidir)"\" \ -DPREFIX=\""$(prefix)"\" \ diff --git a/addressbook/gui/component/addressbook-view.c b/addressbook/gui/component/addressbook-view.c index 34a15c2921..992dd602f4 100644 --- a/addressbook/gui/component/addressbook-view.c +++ b/addressbook/gui/component/addressbook-view.c @@ -92,73 +92,13 @@ struct _AddressbookViewPrivate { EABMenu *menu; }; -enum DndTargetType { - DND_TARGET_TYPE_VCARD_LIST, - DND_TARGET_TYPE_SOURCE_VCARD_LIST -}; -#define VCARD_TYPE "text/x-vcard" -#define SOURCE_VCARD_TYPE "text/x-source-vcard" -static GtkTargetEntry drag_types[] = { - { SOURCE_VCARD_TYPE, 0, DND_TARGET_TYPE_SOURCE_VCARD_LIST }, - { VCARD_TYPE, 0, DND_TARGET_TYPE_VCARD_LIST } -}; -static gint num_drag_types = sizeof(drag_types) / sizeof(drag_types[0]); - static void set_status_message (EABView *eav, const char *message, AddressbookView *view); -static void search_result (EABView *eav, EBookViewStatus status, AddressbookView *view); static void activate_source (AddressbookView *view, ESource *source); static void addressbook_view_init (AddressbookView *view); static void addressbook_view_class_init (AddressbookViewClass *klass); -static void -set_status_message (EABView *eav, const char *message, AddressbookView *view) -{ - AddressbookViewPrivate *priv = view->priv; - EActivityHandler *activity_handler = priv->activity_handler; - - if (!message || !*message) { - if (priv->activity_id != 0) { - e_activity_handler_operation_finished (activity_handler, priv->activity_id); - priv->activity_id = 0; - } - } else if (priv->activity_id == 0) { - char *clientid = g_strdup_printf ("%p", view); - - priv->activity_id = e_activity_handler_operation_started ( - activity_handler, clientid, message, TRUE); - - g_free (clientid); - } else { - e_activity_handler_operation_progressing (activity_handler, priv->activity_id, message, -1.0); - } - -} - -static void -set_folder_bar_message (EABView *eav, const char *message, AddressbookView *view) -{ - AddressbookViewPrivate *priv = view->priv; - EABView *current_view = get_current_view (view); - - if (eav == current_view) { - ESource *source = eav->source; - - if (source) { - const char *name = e_source_peek_name (source); - - e_info_label_set_info((EInfoLabel*)priv->info_widget, name, message); - } - } -} - -static void -search_result (EABView *eav, EBookViewStatus status, AddressbookView *view) -{ - eab_search_result_dialog (NULL /* XXX */, status); -} - static void control_activate (BonoboControl *control, BonoboUIComponent *uic, @@ -230,22 +170,6 @@ load_uri_for_selection (ESourceSelector *selector, activate_source (view, selected_source); } -static void -save_primary_selection (AddressbookView *view) -{ - AddressbookViewPrivate *priv = view->priv; - ESource *source; - - source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (priv->selector)); - if (!source) - return; - - /* Save the selection for next time we start up */ - gconf_client_set_string (priv->gconf_client, - "/apps/evolution/addressbook/display/primary_addressbook", - e_source_peek_uid (source), NULL); -} - /* Folder popup menu callbacks */ typedef struct { AddressbookView *view; @@ -253,319 +177,6 @@ typedef struct { GtkWidget *toplevel; } BookRemovedClosure; -static void -book_removed (EBook *book, EBookStatus status, gpointer data) -{ - BookRemovedClosure *closure = data; - AddressbookView *view = closure->view; - AddressbookViewPrivate *priv = view->priv; - ESource *source = closure->selected_source; - GtkWidget *toplevel = closure->toplevel; - - g_free (closure); - - g_object_unref (book); - - if (E_BOOK_ERROR_OK == status) { - /* Remove source */ - if (e_source_selector_source_is_selected (E_SOURCE_SELECTOR (priv->selector), - source)) - e_source_selector_unselect_source (E_SOURCE_SELECTOR (priv->selector), - source); - - e_source_group_remove_source (e_source_peek_group (source), source); - - e_source_list_sync (priv->source_list, NULL); - } - else { - e_error_run (GTK_WINDOW (toplevel), - "addressbook:remove-addressbook", - NULL); - } -} - -static void -delete_addressbook_cb(EPopup *ep, EPopupItem *pitem, void *data) -{ - AddressbookView *view = data; - AddressbookViewPrivate *priv = view->priv; - ESource *selected_source; - EBook *book; - GError *error = NULL; - GtkWindow *toplevel; - - selected_source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (priv->selector)); - if (!selected_source) - return; - - toplevel = (GtkWindow *)gtk_widget_get_toplevel(ep->target->widget); - - if (e_error_run(toplevel, "addressbook:ask-delete-addressbook", e_source_peek_name(selected_source)) != GTK_RESPONSE_YES) - return; - - /* Remove local data */ - book = e_book_new (selected_source, &error); - if (book) { - BookRemovedClosure *closure = g_new (BookRemovedClosure, 1); - - closure->toplevel = (GtkWidget *)toplevel; - closure->view = view; - closure->selected_source = selected_source; - - if (e_book_async_remove (book, book_removed, closure)) { - e_error_run (toplevel, "addressbook:remove-addressbook", NULL); - g_free (closure); - g_object_unref (book); - } - } -} - -static void -primary_source_selection_changed_callback (ESourceSelector *selector, - AddressbookView *view) -{ - load_uri_for_selection (selector, view, FALSE); - save_primary_selection (view); -} - -static gboolean -selector_tree_drag_drop (GtkWidget *widget, - GdkDragContext *context, - int x, - int y, - guint time, - AddressbookView *view) -{ - GtkTreeViewColumn *column; - int cell_x; - int cell_y; - GtkTreePath *path; - GtkTreeModel *model; - GtkTreeIter iter; - gpointer data; - - if (!gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget), x, y, &path, &column, &cell_x, &cell_y)) - return FALSE; - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget)); - - if (!gtk_tree_model_get_iter (model, &iter, path)) { - gtk_tree_path_free (path); - return FALSE; - } - - gtk_tree_model_get (model, &iter, 0, &data, -1); - - if (E_IS_SOURCE_GROUP (data)) { - g_object_unref (data); - gtk_tree_path_free (path); - return FALSE; - } - - gtk_tree_path_free (path); - return TRUE; -} - -static gboolean -selector_tree_drag_motion (GtkWidget *widget, - GdkDragContext *context, - int x, - int y) -{ - GtkTreePath *path = NULL; - gpointer data = NULL; - GtkTreeViewDropPosition pos; - GtkTreeModel *model; - GtkTreeIter iter; - GdkDragAction action = { 0, }; - - if (!gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW (widget), - x, y, &path, &pos)) - goto finish; - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget)); - - if (!gtk_tree_model_get_iter (model, &iter, path)) - goto finish; - - gtk_tree_model_get (model, &iter, 0, &data, -1); - - if (E_IS_SOURCE_GROUP (data) || e_source_get_readonly (data)) - goto finish; - - gtk_tree_view_set_drag_dest_row(GTK_TREE_VIEW (widget), path, GTK_TREE_VIEW_DROP_INTO_OR_BEFORE); - /* Make default action move, not copy */ - if (context->actions & GDK_ACTION_MOVE) - action = GDK_ACTION_MOVE; - else - action = context->suggested_action; - - finish: - if (path) - gtk_tree_path_free (path); - if (data) - g_object_unref (data); - - gdk_drag_status (context, action, GDK_CURRENT_TIME); - return TRUE; -} - -typedef struct -{ - guint remove_from_source : 1; - guint copy_done : 1; - gint pending_removals; - - EContact *current_contact; - GList *remaining_contacts; - - EBook *source_book; - EBook *target_book; -} -MergeContext; - -static void -destroy_merge_context (MergeContext *merge_context) -{ - if (merge_context->source_book) - g_object_unref (merge_context->source_book); - if (merge_context->target_book) - g_object_unref (merge_context->target_book); - - g_free (merge_context); -} - -static void -removed_contact_cb (EBook *book, EBookStatus status, gpointer closure) -{ - MergeContext *merge_context = closure; - - merge_context->pending_removals--; - - if (merge_context->copy_done && merge_context->pending_removals == 0) { - /* Finished */ - - destroy_merge_context (merge_context); - } -} - -static void -merged_contact_cb (EBook *book, EBookStatus status, const char *id, gpointer closure) -{ - MergeContext *merge_context = closure; - - if (merge_context->remove_from_source && status == E_BOOK_ERROR_OK) { - /* Remove previous contact from source */ - - e_book_async_remove_contact (merge_context->source_book, merge_context->current_contact, - removed_contact_cb, merge_context); - merge_context->pending_removals++; - } - - g_object_unref (merge_context->current_contact); - - if (merge_context->remaining_contacts) { - /* Copy next contact */ - - merge_context->current_contact = merge_context->remaining_contacts->data; - merge_context->remaining_contacts = g_list_delete_link (merge_context->remaining_contacts, - merge_context->remaining_contacts); - eab_merging_book_add_contact (merge_context->target_book, merge_context->current_contact, - merged_contact_cb, merge_context); - } else if (merge_context->pending_removals == 0) { - /* Finished */ - - destroy_merge_context (merge_context); - } else { - /* Finished, but have pending removals */ - - merge_context->copy_done = TRUE; - } -} - -static gboolean -selector_tree_drag_data_received (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - GtkSelectionData *data, - guint info, - guint time, - gpointer user_data) -{ - GtkTreePath *path = NULL; - GtkTreeViewDropPosition pos; - gpointer target = NULL; - GtkTreeModel *model; - GtkTreeIter iter; - gboolean success = FALSE; - EBook *source_book, *target_book; - MergeContext *merge_context = NULL; - GList *contactlist; - AddressbookView *view; - EABView *v; - - if (!gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW (widget), - x, y, &path, &pos)) - goto finish; - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget)); - - if (!gtk_tree_model_get_iter (model, &iter, path)) - goto finish; - - gtk_tree_model_get (model, &iter, 0, &target, -1); - - if (E_IS_SOURCE_GROUP (target) || e_source_get_readonly (target)) - goto finish; - - target_book = e_book_new (target, NULL); - if (!target_book) { - g_message (G_STRLOC ":Couldn't create EBook."); - return FALSE; - } - e_book_open (target_book, FALSE, NULL); - - eab_book_and_contact_list_from_string ((char *)data->data, &source_book, &contactlist); - - view = (AddressbookView *) user_data; - v = get_current_view (view); - g_object_get (v->model, "book",&source_book, NULL); - - /* Set up merge context */ - - merge_context = g_new0 (MergeContext, 1); - - merge_context->source_book = source_book; - merge_context->target_book = target_book; - - merge_context->current_contact = contactlist->data; - merge_context->remaining_contacts = g_list_delete_link (contactlist, contactlist); - - merge_context->remove_from_source = context->action == GDK_ACTION_MOVE ? TRUE : FALSE; - - /* Start merge */ - - eab_merging_book_add_contact (target_book, merge_context->current_contact, - merged_contact_cb, merge_context); - - finish: - if (path) - gtk_tree_path_free (path); - if (target) - g_object_unref (target); - - gtk_drag_finish (context, success, merge_context->remove_from_source, time); - - return TRUE; -} - -static void -selector_tree_drag_leave (GtkWidget *widget, GdkDragContext *context, guint time, gpointer data) -{ - gtk_tree_view_set_drag_dest_row(GTK_TREE_VIEW (widget), NULL, GTK_TREE_VIEW_DROP_BEFORE); -} - static void addressbook_view_init (AddressbookView *view) { @@ -578,16 +189,6 @@ addressbook_view_init (AddressbookView *view) g_signal_connect (priv->folder_view_control, "activate", G_CALLBACK (control_activate_cb), view); - g_signal_connect (priv->selector, "drag-motion", G_CALLBACK (selector_tree_drag_motion), view); - g_signal_connect (priv->selector, "drag-leave", G_CALLBACK (selector_tree_drag_leave), view); - g_signal_connect (priv->selector, "drag-drop", G_CALLBACK (selector_tree_drag_drop), view); - g_signal_connect (priv->selector, "drag-data-received", G_CALLBACK (selector_tree_drag_data_received), view); - gtk_drag_dest_set (priv->selector, GTK_DEST_DEFAULT_ALL, drag_types, num_drag_types, GDK_ACTION_COPY | GDK_ACTION_MOVE); - - g_signal_connect_object (priv->selector, "primary_selection_changed", - G_CALLBACK (primary_source_selection_changed_callback), - G_OBJECT (view), 0); - load_uri_for_selection (E_SOURCE_SELECTOR (priv->selector), view, TRUE); } @@ -604,153 +205,6 @@ destroy_editor (char *key, gtk_widget_destroy (GTK_WIDGET (closure->editor)); } -typedef struct { - EABView *view; - ESource *source; -} BookOpenData; - -static void -book_open_cb (EBook *book, EBookStatus status, gpointer closure) -{ - BookOpenData *data = closure; - EABView *view = data->view; - ESource *source = data->source; - - g_free (data); - - /* we always set the "source" property on the EABView, since - we use it to reload a previously failed book. */ - g_object_set(view, - "source", source, - NULL); - - if (status == E_BOOK_ERROR_OK) { - g_object_set(view, - "book", book, - NULL); - - if (view->model) - eab_model_force_folder_bar_message (view->model); - } - else if (status != E_BOOK_ERROR_CANCELLED) { - eab_load_error_dialog (NULL /* XXX */, source, status); - } - - - g_object_unref (source); -} - -static void -activate_source (AddressbookView *view, - ESource *source) -{ - AddressbookViewPrivate *priv = view->priv; - const char *uid; - GtkWidget *uid_view; - EBook *book; - BookOpenData *data; - - uid = e_source_peek_uid (source); - uid_view = g_hash_table_lookup (priv->uid_to_view, uid); - - if (uid_view) { - /* there is a view for this uid. make - sure that the view actually - contains an EBook (if it doesn't - contain an EBook a previous load - failed. try to load it again */ - g_object_get (uid_view, - "book", &book, - NULL); - - if (book) { - g_object_unref (book); - } - else { - g_object_get (uid_view, - "source", &source, - NULL); - - /* source can be NULL here, if - a previous load hasn't - actually made it to - book_open_cb yet. */ - if (source) { - book = e_book_new (source, NULL); - - if (!book) { - g_object_unref (source); - } - else { - data = g_new (BookOpenData, 1); - data->view = g_object_ref (uid_view); - data->source = source; /* transfer the ref we get back from g_object_get */ - - addressbook_load (book, book_open_cb, data); - } - } - } - } - else { - /* we don't have a view for this uid already - set up. */ - GtkWidget *label = gtk_label_new (uid); - GError *error = NULL; - - uid_view = eab_view_new (); - - gtk_widget_show (uid_view); - gtk_widget_show (label); - - g_object_set (uid_view, "type", EAB_VIEW_TABLE, NULL); - - gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), - uid_view, - label); - - g_hash_table_insert (priv->uid_to_view, g_strdup (uid), uid_view); - - g_signal_connect (uid_view, "status_message", - G_CALLBACK(set_status_message), view); - - g_signal_connect (uid_view, "search_result", - G_CALLBACK(search_result), view); - - g_signal_connect (uid_view, "folder_bar_message", - G_CALLBACK(set_folder_bar_message), view); - - g_signal_connect (uid_view, "command_state_change", - G_CALLBACK(update_command_state), view); - - book = e_book_new (source, &error); - - if (book) { - data = g_new (BookOpenData, 1); - data->view = g_object_ref (uid_view); - data->source = g_object_ref (source); - - addressbook_load (book, book_open_cb, data); - } - else { - g_warning ("error loading addressbook : %s", error->message); - g_error_free (error); - } - } - - gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), - gtk_notebook_page_num (GTK_NOTEBOOK (priv->notebook), - uid_view)); - - if (EAB_VIEW (uid_view)->model) - eab_model_force_folder_bar_message (EAB_VIEW (uid_view)->model); - - /* change menus/toolbars to reflect the new view, assuming we are already displayed */ - if (bonobo_ui_component_get_container (bonobo_control_get_ui_component (priv->folder_view_control)) != CORBA_OBJECT_NIL) { - eab_view_setup_menus (EAB_VIEW (uid_view), bonobo_control_get_ui_component (priv->folder_view_control)); - update_command_state (EAB_VIEW (uid_view), view); - } -} - void addressbook_view_edit_contact (AddressbookView* view, const char* source_uid, diff --git a/addressbook/gui/component/autocompletion-config.c b/addressbook/gui/component/autocompletion-config.c index 060ce01aee..9e42a375f9 100644 --- a/addressbook/gui/component/autocompletion-config.c +++ b/addressbook/gui/component/autocompletion-config.c @@ -118,8 +118,10 @@ autocompletion_config_init (void) initialize_selection (E_SOURCE_SELECTOR (source_selector)); + preferences_window = e_shell_get_preferences_window (); + e_preferences_window_add_page ( - e_shell_get_preferences_window (), + E_PREFERENCES_WINDOW (preferences_window), "autocompletion", "preferences-autocompletion", _("Autocompletion"), diff --git a/addressbook/gui/component/e-book-shell-module.c b/addressbook/gui/component/e-book-shell-module.c index aaaa6fecdb..1be7a6782d 100644 --- a/addressbook/gui/component/e-book-shell-module.c +++ b/addressbook/gui/component/e-book-shell-module.c @@ -30,6 +30,10 @@ #include #include +#include +#include +#include + #include #include #include @@ -42,10 +46,13 @@ #define LDAP_BASE_URI "ldap://" #define PERSONAL_RELATIVE_URI "system" +#define ETSPEC_FILENAME "e-addressbook-view.etspec" /* Module Entry Point */ void e_shell_module_init (GTypeModule *type_module); +GalViewCollection *e_book_shell_module_view_collection = NULL; + static void book_module_ensure_sources (EShellModule *shell_module) { @@ -162,6 +169,52 @@ book_module_ensure_sources (EShellModule *shell_module) g_free (base_uri); } +static void +book_module_init_view_collection (EShellModule *shell_module) +{ + GalViewCollection *collection; + GalViewFactory *factory; + ETableSpecification *spec; + const gchar *base_dir; + gchar *filename; + gchar *system_dir; + gchar *local_dir; + + collection = gal_view_collection_new (); + gal_view_collection_set_title (collection, _("Address Book")); + + base_dir = EVOLUTION_GALVIEWSDIR; + system_dir = g_build_filename (base_dir, "addressbook", NULL); + + base_dir = e_shell_module_get_data_dir (shell_module); + local_dir = g_build_filename (base_dir, "views", NULL); + + gal_view_collection_set_storage_directories ( + collection, system_dir, local_dir); + + g_free (system_dir); + g_free (local_dir); + + base_dir = EVOLUTION_ETSPECDIR; + spec = e_table_specification_new (); + filename = g_build_filename (base_dir, ETSPEC_FILENAME, NULL); + if (!e_table_specification_load_from_file (spec, filename)) + g_error ("Unable to load ETable specification file " + "for address book"); + g_free (filename); + + factory = gal_view_factory_etable_new (spec); + gal_view_collection_add_factory (collection, factory); + g_object_unref (factory); + g_object_unref (spec); + + factory = gal_view_factory_minicard_new (); + gal_view_collection_add_factory (collection, factory); + g_object_unref (factory); + + gal_view_collection_load (collection); +} + static void book_module_book_loaded_cb (EBook *book, EBookStatus status, @@ -245,7 +298,7 @@ static GtkActionEntry item_entries[] = { N_("Create a new contact"), G_CALLBACK (action_contact_new_cb) }, - { "contact-list-new", + { "contact-new-list", "stock_contact-list", N_("Contact _List"), "l", @@ -384,6 +437,7 @@ e_shell_module_init (GTypeModule *type_module) e_shell_module_set_info (shell_module, &module_info); book_module_ensure_sources (shell_module); + book_module_init_view_collection (shell_module); g_signal_connect_swapped ( shell, "handle-uri", diff --git a/addressbook/gui/component/e-book-shell-view-actions.c b/addressbook/gui/component/e-book-shell-view-actions.c index d5f961ec66..5b07b84557 100644 --- a/addressbook/gui/component/e-book-shell-view-actions.c +++ b/addressbook/gui/component/e-book-shell-view-actions.c @@ -22,6 +22,7 @@ #include #include +#include #include @@ -259,6 +260,32 @@ action_contact_move_cb (GtkAction *action, eab_view_move_to_folder (view, FALSE); } +static void +action_contact_new_cb (GtkAction *action, + EBookShellView *book_shell_view) +{ + EContact *contact; + EBook *book; + + contact = e_contact_new (); + book = book_shell_view->priv->book; + eab_show_contact_editor (book, contact, TRUE, TRUE); + g_object_unref (contact); +} + +static void +action_contact_new_list_cb (GtkAction *action, + EBookShellView *book_shell_view) +{ + EContact *contact; + EBook *book; + + contact = e_contact_new (); + book = book_shell_view->priv->book; + eab_show_contact_list_editor (book, contact, TRUE, TRUE); + g_object_unref (contact); +} + static void action_contact_open_cb (GtkAction *action, EBookShellView *book_shell_view) @@ -274,10 +301,12 @@ static void action_contact_preview_cb (GtkToggleAction *action, EBookShellView *book_shell_view) { + EABView *view; gboolean active; + view = e_book_shell_view_get_current_view (book_shell_view); active = gtk_toggle_action_get_active (action); - /* FIXME Unfinished. */ + eab_view_show_contact_preview (view, active); } static void @@ -435,6 +464,20 @@ static GtkActionEntry contact_entries[] = { N_("Move selected contacts to another address book"), G_CALLBACK (action_contact_move_cb) }, + { "contact-new", + "contact-new", + N_("_New Contact..."), + NULL, + N_("Create a new contact"), + G_CALLBACK (action_contact_new_cb) }, + + { "contact-new-list", + "stock_contact-list", + N_("New Contact _List..."), + NULL, + N_("Create a new contact list"), + G_CALLBACK (action_contact_new_list_cb) }, + { "contact-open", NULL, N_("_Open"), @@ -528,8 +571,11 @@ e_book_shell_view_actions_init (EBookShellView *book_shell_view) EShellWindow *shell_window; GtkActionGroup *action_group; GtkUIManager *manager; + GConfBridge *bridge; GtkAction *action; + GObject *object; const gchar *domain; + const gchar *key; shell_view = E_SHELL_VIEW (book_shell_view); shell_window = e_shell_view_get_window (shell_view); @@ -548,8 +594,104 @@ e_book_shell_view_actions_init (EBookShellView *book_shell_view) G_N_ELEMENTS (contact_toggle_entries), book_shell_view); gtk_ui_manager_insert_action_group (manager, action_group, 0); + /* Bind GObject properties to GConf keys. */ + + bridge = gconf_bridge_get (); + + object = G_OBJECT (ACTION (CONTACT_PREVIEW)); + key = "/apps/evolution/addressbook/display/show_preview"; + gconf_bridge_bind_property (bridge, key, object, "active"); + /* Fine tuning. */ action = ACTION (CONTACT_DELETE); g_object_set (action, "short-label", _("Delete"), NULL); } + +void +e_book_shell_view_update_actions (EBookShellView *book_shell_view, + EABView *view) +{ + EShellView *shell_view; + EShellWindow *shell_window; + ESource *source; + ESourceSelector *selector; + GtkAction *action; + gboolean sensitive; + + if (e_book_shell_view_get_current_view (book_shell_view) != view) + return; + + shell_view = E_SHELL_VIEW (book_shell_view); + shell_window = e_shell_view_get_window (shell_view); + + selector = E_SOURCE_SELECTOR (book_shell_view->priv->selector); + source = e_source_selector_peek_primary_selection (selector); + + action = ACTION (ADDRESS_BOOK_STOP); + sensitive = eab_view_can_stop (view); + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (CONTACT_CLIPBOARD_COPY); + sensitive = eab_view_can_copy (view); + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (CONTACT_CLIPBOARD_CUT); + sensitive = eab_view_can_cut (view); + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (CONTACT_CLIPBOARD_PASTE); + sensitive = eab_view_can_paste (view); + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (CONTACT_COPY); + sensitive = eab_view_can_copy_to_folder (view); + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (CONTACT_DELETE); + sensitive = eab_view_can_delete (view); + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (CONTACT_FORWARD); + sensitive = eab_view_can_send (view); + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (CONTACT_MOVE); + sensitive = eab_view_can_move_to_folder (view); + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (CONTACT_OPEN); + sensitive = eab_view_can_view (view); + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (CONTACT_PRINT); + sensitive = eab_view_can_print (view); + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (CONTACT_PRINT_PREVIEW); + sensitive = eab_view_can_print (view); + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (CONTACT_SAVE_AS); + sensitive = eab_view_can_save_as (view); + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (CONTACT_SELECT_ALL); + sensitive = eab_view_can_select_all (view); + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (CONTACT_SEND_MESSAGE); + sensitive = eab_view_can_send_to (view); + gtk_action_set_sensitive (action, sensitive); + + 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); +} + diff --git a/addressbook/gui/component/e-book-shell-view-actions.h b/addressbook/gui/component/e-book-shell-view-actions.h index cc54ca14c2..bce21fe634 100644 --- a/addressbook/gui/component/e-book-shell-view-actions.h +++ b/addressbook/gui/component/e-book-shell-view-actions.h @@ -54,8 +54,14 @@ E_SHELL_WINDOW_ACTION ((window), "contact-forward") #define E_SHELL_WINDOW_ACTION_CONTACT_MOVE(window) \ E_SHELL_WINDOW_ACTION ((window), "contact-move") +#define E_SHELL_WINDOW_ACTION_CONTACT_NEW(window) \ + E_SHELL_WINDOW_ACTION ((window), "contact-new") +#define E_SHELL_WINDOW_ACTION_CONTACT_NEW_LIST(window) \ + E_SHELL_WINDOW_ACTION ((window), "contact-new-list") #define E_SHELL_WINDOW_ACTION_CONTACT_OPEN(window) \ E_SHELL_WINDOW_ACTION ((window), "contact-open") +#define E_SHELL_WINDOW_ACTION_CONTACT_PREVIEW(window) \ + E_SHELL_WINDOW_ACTION ((window), "contact-preview") #define E_SHELL_WINDOW_ACTION_CONTACT_PRINT(window) \ E_SHELL_WINDOW_ACTION ((window), "contact-print") #define E_SHELL_WINDOW_ACTION_CONTACT_PRINT_PREVIEW(window) \ diff --git a/addressbook/gui/component/e-book-shell-view-private.c b/addressbook/gui/component/e-book-shell-view-private.c index 0bf0832c58..b75a8c6f60 100644 --- a/addressbook/gui/component/e-book-shell-view-private.c +++ b/addressbook/gui/component/e-book-shell-view-private.c @@ -20,6 +20,191 @@ #include "e-book-shell-view-private.h" +#include + +static void +set_status_message (EABView *view, + const gchar *message, + EBookShellView *book_shell_view) +{ + /* XXX Give EABView an EShellView pointer + * and have it handle this directly. */ + + EActivityHandler *activity_handler; + guint activity_id; + + activity_handler = book_shell_view->priv->activity_handler; + activity_id = book_shell_view->priv->activity_id; + + if (message == NULL || *message == '\0') { + if (activity_id > 0) { + e_activity_handler_operation_finished ( + activity_handler, activity_id); + activity_id = 0; + } + } else if (activity_id == 0) { + gchar *client_id = g_strdup_printf ("%p", book_shell_view); + + activity_id = e_activity_handler_operation_started ( + activity_handler, client_id, message, TRUE); + } else + e_activity_handler_operation_progressing ( + activity_handler, activity_id, message, -1.0); + + book_shell_view->priv->activity_id = activity_id; +} + +static void +search_result (EABView *view, + EBookViewStatus status, + EBookShellView *book_shell_view) +{ + /* XXX Give EABView an EShellView pointer + * and have it handle this directly. */ + + eab_search_result_dialog (NULL /* XXX */, status); +} + +static void +set_folder_bar_message (EABView *view, + const gchar *message, + EBookShellView *book_shell_view) +{ + /* XXX Give EABView an EShellView pointer + * and have it handle this directly. */ + + EShellView *shell_view; + EABView *current_view; + 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); + + e_shell_view_set_primary_text (shell_view, name); + e_shell_view_set_secondary_text (shell_view, message); +} + +static void +book_open_cb (EBook *book, + EBookStatus status, + gpointer user_data) +{ + EABView *view = user_data; + ESource *source; + + source = e_book_get_source (book); + + /* We always set the "source" property on the EABView + * since we use it to reload a previously failed book. */ + g_object_set (view, "source", source, NULL); + + if (status == E_BOOK_ERROR_OK) { + g_object_set (view, "book", book, NULL); + if (view->model) + eab_model_force_folder_bar_message (view->model); + } else if (status != E_BOOK_ERROR_CANCELLED) + eab_load_error_dialog (NULL /* XXX */, source, status); +} + +static void +book_shell_view_activate_selected_source (EBookShellView *book_shell_view) +{ + ESource *source; + ESourceSelector *selector; + GHashTable *hash_table; + GtkNotebook *notebook; + GtkWidget *uid_view; + const gchar *uid; + gint page_num; + + notebook = GTK_NOTEBOOK (book_shell_view->priv->notebook); + selector = E_SOURCE_SELECTOR (book_shell_view->priv->selector); + source = e_source_selector_peek_primary_selection (selector); + + if (source == NULL) + return; + + /* XXX Add some get/set functions to EABView: + * + * eab_view_get_book() / eab_view_set_book() + * eab_view_get_type() / eab_view_set_type() + * eab_view_get_source() / eab_view_set_source() + */ + + uid = e_source_peek_uid (source); + hash_table = book_shell_view->priv->uid_to_view; + uid_view = g_hash_table_lookup (hash_table, uid); + + if (uid_view != NULL) { + EBook *book; + + /* There is a view for this UID. Make sure the view + * actually contains an EBook. The absence of an EBook + * suggests a previous load failed, so try again. */ + g_object_get (uid_view, "book", &book, NULL); + + if (book != NULL) + g_object_unref (book); + else { + g_object_get (uid_view, "source", &source, NULL); + + /* Source can be NULL if a previous load + * has not yet reached book_open_cb(). */ + if (source != NULL) { + book = e_book_new (source, NULL); + + if (book != NULL) + addressbook_load (book, book_open_cb, uid_view); + + g_object_unref (source); + } + } + + } else { + EBook *book; + + /* Create a view for this UID. */ + uid_view = eab_view_new (); + g_object_set (uid_view, "type", EAB_VIEW_TABLE, NULL); + gtk_widget_show (uid_view); + + gtk_notebook_append_page (notebook, uid_view, NULL); + g_hash_table_insert (hash_table, g_strdup (uid), uid_view); + + g_signal_connect ( + uid_view, "status-message", + G_CALLBACK (set_status_message), book_shell_view); + + g_signal_connect ( + uid_view, "search-result", + G_CALLBACK (search_result), book_shell_view); + + g_signal_connect ( + uid_view, "folder-bar-message", + G_CALLBACK (set_folder_bar_message), book_shell_view); + + g_signal_connect_swapped ( + uid_view, "command-state-change", + G_CALLBACK (e_book_shell_view_update_actions), + book_shell_view); + + book = e_book_new (source, NULL); + + if (book != NULL) + addressbook_load (book, book_open_cb, uid_view); + } + + page_num = gtk_notebook_page_num (notebook, uid_view); + gtk_notebook_set_current_page (notebook, page_num); + + if (EAB_VIEW (uid_view)->model) + eab_model_force_folder_bar_message (EAB_VIEW (uid_view)->model); +} + static gboolean book_shell_view_show_popup_menu (GdkEventButton *event, EShellView *shell_view) @@ -48,6 +233,8 @@ static gboolean book_shell_view_selector_button_press_event_cb (EShellView *shell_view, GdkEventButton *event) { + /* XXX Use ESourceSelector's "popup-event" signal instead. */ + if (event->button == 3 && event->type == GDK_BUTTON_PRESS) return book_shell_view_show_popup_menu (event, shell_view); @@ -57,6 +244,8 @@ book_shell_view_selector_button_press_event_cb (EShellView *shell_view, static gboolean book_shell_view_selector_popup_menu_cb (EShellView *shell_view) { + /* XXX Use ESourceSelector's "popup-event" signal instead. */ + return book_shell_view_show_popup_menu (NULL, shell_view); } @@ -77,15 +266,25 @@ book_shell_view_selector_key_press_event_cb (EShellView *shell_view, return FALSE; } +static void +book_shell_view_primary_selection_changed_cb (EBookShellView *book_shell_view, + ESourceSelector *selector) +{ + book_shell_view_activate_selected_source (book_shell_view); +} + void e_book_shell_view_private_init (EBookShellView *book_shell_view) { EBookShellViewPrivate *priv = book_shell_view->priv; + EShellView *shell_view; GHashTable *uid_to_view; GHashTable *uid_to_editor; GtkWidget *container; GtkWidget *widget; + shell_view = E_SHELL_VIEW (book_shell_view); + uid_to_view = g_hash_table_new_full ( g_str_hash, g_str_equal, (GDestroyNotify) g_free, @@ -103,30 +302,32 @@ e_book_shell_view_private_init (EBookShellView *book_shell_view) e_book_get_addressbooks (&priv->source_list, NULL); + /* Construct view widgets. */ + widget = gtk_notebook_new (); + container = e_shell_view_get_content_widget (shell_view); gtk_notebook_set_show_tabs (GTK_NOTEBOOK (widget), FALSE); gtk_notebook_set_show_border (GTK_NOTEBOOK (widget), FALSE); - priv->notebook = g_object_ref_sink (widget); + gtk_container_add (GTK_CONTAINER (container), widget); gtk_widget_show (widget); - widget = e_task_bar_new (); + widget = e_shell_view_get_taskbar_widget (shell_view); e_activity_handler_attach_task_bar ( priv->activity_handler, E_TASK_BAR (widget)); - priv->task_bar = g_object_ref (widget); - gtk_widget_show (widget); widget = gtk_scrolled_window_new (NULL, NULL); + container = e_shell_view_get_sidebar_widget (shell_view); gtk_scrolled_window_set_policy ( GTK_SCROLLED_WINDOW (widget), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_set_shadow_type ( GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_IN); - priv->scrolled_window = g_object_ref_sink (widget); + gtk_container_add (GTK_CONTAINER (container), widget); gtk_widget_show (widget); container = widget; - widget = e_source_selector_new (priv->source_list); + widget = e_addressbook_selector_new (priv->source_list); e_source_selector_show_selection (E_SOURCE_SELECTOR (widget), FALSE); gtk_container_add (GTK_CONTAINER (container), widget); priv->selector = g_object_ref (widget); @@ -146,6 +347,13 @@ e_book_shell_view_private_init (EBookShellView *book_shell_view) widget, "popup-menu", G_CALLBACK (book_shell_view_selector_popup_menu_cb), book_shell_view); + + g_signal_connect_swapped ( + widget, "primary-selection-changed", + G_CALLBACK (book_shell_view_primary_selection_changed_cb), + book_shell_view); + + book_shell_view_activate_selected_source (book_shell_view); } void diff --git a/addressbook/gui/component/e-book-shell-view-private.h b/addressbook/gui/component/e-book-shell-view-private.h index 426b8e9d11..130e061dcd 100644 --- a/addressbook/gui/component/e-book-shell-view-private.h +++ b/addressbook/gui/component/e-book-shell-view-private.h @@ -30,8 +30,11 @@ #include #include +#include #include +#include #include +#include #include @@ -53,6 +56,9 @@ G_BEGIN_DECLS +/* Defined in e-book-shell-module.c */ +extern GalViewCollection *e_book_shell_module_view_collection; + typedef struct _EditorUidClosure EditorUidClosure; struct _EditorUidClosure { @@ -70,9 +76,7 @@ struct _EBookShellViewPrivate { /*** Other Stuff ***/ GtkWidget *notebook; - GtkWidget *scrolled_window; GtkWidget *selector; - GtkWidget *task_bar; EActivityHandler *activity_handler; @@ -98,6 +102,9 @@ void e_book_shell_view_private_finalize void e_book_shell_view_actions_init (EBookShellView *book_shell_view); +void e_book_shell_view_update_actions + (EBookShellView *book_shell_view, + EABView *view); EABView * e_book_shell_view_get_current_view (EBookShellView *book_shell_view); void e_book_shell_view_editor_weak_notify diff --git a/addressbook/gui/component/e-book-shell-view.c b/addressbook/gui/component/e-book-shell-view.c index 1a5c38940d..d9f34b8d21 100644 --- a/addressbook/gui/component/e-book-shell-view.c +++ b/addressbook/gui/component/e-book-shell-view.c @@ -24,7 +24,7 @@ GType e_book_shell_view_type = 0; static gpointer parent_class; static ESource * -book_shell_view_get_primary_source (EBookShellView *book_shell_view) +book_shell_view_load_primary_source (EBookShellView *book_shell_view) { GConfClient *client; ESourceList *source_list; @@ -32,6 +32,9 @@ book_shell_view_get_primary_source (EBookShellView *book_shell_view) const gchar *key; gchar *uid; + /* XXX If ESourceSelector had a "primary-uid" property, + * we could just bind the GConf key to it. */ + source_list = book_shell_view->priv->source_list; client = gconf_client_get_default (); @@ -66,90 +69,27 @@ book_shell_view_get_primary_source (EBookShellView *book_shell_view) } static void -book_shell_view_update_actions (EBookShellView *book_shell_view, - EABView *view) +book_shell_view_save_primary_source (EBookShellView *book_shell_view) { - EShellView *shell_view; - EShellWindow *shell_window; - ESource *source; + GConfClient *client; ESourceSelector *selector; - GtkAction *action; - gboolean sensitive; - - if (e_book_shell_view_get_current_view (book_shell_view) != view) - return; + ESource *source; + const gchar *key; + const gchar *string; - shell_view = E_SHELL_VIEW (book_shell_view); - shell_window = e_shell_view_get_window (shell_view); + /* XXX If ESourceSelector had a "primary-uid" property, + * we could just bind the GConf key to it. */ selector = E_SOURCE_SELECTOR (book_shell_view->priv->selector); source = e_source_selector_peek_primary_selection (selector); + if (source == NULL) + return; - action = ACTION (ADDRESS_BOOK_STOP); - sensitive = eab_view_can_stop (view); - gtk_action_set_sensitive (action, sensitive); - - action = ACTION (CONTACT_CLIPBOARD_COPY); - sensitive = eab_view_can_copy (view); - gtk_action_set_sensitive (action, sensitive); - - action = ACTION (CONTACT_CLIPBOARD_CUT); - sensitive = eab_view_can_cut (view); - gtk_action_set_sensitive (action, sensitive); - - action = ACTION (CONTACT_CLIPBOARD_PASTE); - sensitive = eab_view_can_paste (view); - gtk_action_set_sensitive (action, sensitive); - - action = ACTION (CONTACT_COPY); - sensitive = eab_view_can_copy_to_folder (view); - gtk_action_set_sensitive (action, sensitive); - - action = ACTION (CONTACT_DELETE); - sensitive = eab_view_can_delete (view); - gtk_action_set_sensitive (action, sensitive); - - action = ACTION (CONTACT_FORWARD); - sensitive = eab_view_can_send (view); - gtk_action_set_sensitive (action, sensitive); - - action = ACTION (CONTACT_MOVE); - sensitive = eab_view_can_move_to_folder (view); - gtk_action_set_sensitive (action, sensitive); - - action = ACTION (CONTACT_OPEN); - sensitive = eab_view_can_view (view); - gtk_action_set_sensitive (action, sensitive); - - action = ACTION (CONTACT_PRINT); - sensitive = eab_view_can_print (view); - gtk_action_set_sensitive (action, sensitive); - - action = ACTION (CONTACT_PRINT_PREVIEW); - sensitive = eab_view_can_print (view); - gtk_action_set_sensitive (action, sensitive); - - action = ACTION (CONTACT_SAVE_AS); - sensitive = eab_view_can_save_as (view); - gtk_action_set_sensitive (action, sensitive); - - action = ACTION (CONTACT_SELECT_ALL); - sensitive = eab_view_can_select_all (view); - gtk_action_set_sensitive (action, sensitive); - - action = ACTION (CONTACT_SEND_MESSAGE); - sensitive = eab_view_can_send_to (view); - gtk_action_set_sensitive (action, sensitive); - - 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); + client = gconf_client_get_default (); + key = "/apps/evolution/addressbook/display/primary_addressbook"; + string = e_source_peek_uid (source); + gconf_client_set_string (client, key, string, NULL); + g_object_unref (client); } static void @@ -205,8 +145,8 @@ book_shell_view_source_list_changed_cb (EBookShellView *book_shell_view, if (view != NULL) { #if 0 eab_view_setup_menus (view, bonobo_uic); - update_command_state (view, book_shell_view); #endif + e_book_shell_view_update_actions (book_shell_view, view); } } @@ -237,36 +177,6 @@ book_shell_view_constructed (GObject *object) G_OBJECT_CLASS (parent_class)->constructed (object); } -static GtkWidget * -book_shell_view_get_content_widget (EShellView *shell_view) -{ - EBookShellViewPrivate *priv; - - priv = E_BOOK_SHELL_VIEW_GET_PRIVATE (shell_view); - - return priv->notebook; -} - -static GtkWidget * -book_shell_view_get_sidebar_widget (EShellView *shell_view) -{ - EBookShellViewPrivate *priv; - - priv = E_BOOK_SHELL_VIEW_GET_PRIVATE (shell_view); - - return priv->scrolled_window; -} - -static GtkWidget * -book_shell_view_get_status_widget (EShellView *shell_view) -{ - EBookShellViewPrivate *priv; - - priv = E_BOOK_SHELL_VIEW_GET_PRIVATE (shell_view); - - return priv->task_bar; -} - static void book_shell_view_changed (EShellView *shell_view) { @@ -301,13 +211,6 @@ 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->get_content_widget = - book_shell_view_get_content_widget; - shell_view_class->get_sidebar_widget = - book_shell_view_get_sidebar_widget; - shell_view_class->get_status_widget = - book_shell_view_get_status_widget; } static void @@ -327,9 +230,13 @@ book_shell_view_init (EBookShellView *book_shell_view) book_shell_view); selector = E_SOURCE_SELECTOR (book_shell_view->priv->selector); - source = book_shell_view_get_primary_source (book_shell_view); + source = book_shell_view_load_primary_source (book_shell_view); if (source != NULL) e_source_selector_set_primary_selection (selector, source); + g_signal_connect_swapped ( + selector, "primary-selection-changed", + G_CALLBACK (book_shell_view_save_primary_source), + book_shell_view); } GType diff --git a/addressbook/gui/widgets/Makefile.am b/addressbook/gui/widgets/Makefile.am index 99a875d278..c39598f516 100644 --- a/addressbook/gui/widgets/Makefile.am +++ b/addressbook/gui/widgets/Makefile.am @@ -12,6 +12,7 @@ INCLUDES = \ -I$(top_srcdir)/addressbook/gui/contact-editor \ -I$(top_srcdir)/addressbook/gui/merging \ -I$(top_srcdir)/addressbook/gui/component \ + -I$(top_srcdir)/addressbook/util \ -I$(top_srcdir)/widgets/misc \ -I$(top_builddir)/shell \ $(EVOLUTION_ADDRESSBOOK_CFLAGS) @@ -54,6 +55,8 @@ libeabwidgets_la_SOURCES = \ e-addressbook-table-adapter.h \ e-addressbook-model.c \ e-addressbook-model.h \ + e-addressbook-selector.c \ + e-addressbook-selector.h \ e-addressbook-view.c \ e-addressbook-view.h \ gal-view-minicard.c \ diff --git a/addressbook/gui/widgets/e-addressbook-reflow-adapter.c b/addressbook/gui/widgets/e-addressbook-reflow-adapter.c index 345a4e9c8b..95452113e8 100644 --- a/addressbook/gui/widgets/e-addressbook-reflow-adapter.c +++ b/addressbook/gui/widgets/e-addressbook-reflow-adapter.c @@ -8,7 +8,6 @@ #include "eab-marshal.h" #include "e-addressbook-reflow-adapter.h" #include "e-addressbook-model.h" -#include "e-addressbook-view.h" #include "eab-gui-util.h" #include "e-minicard.h" diff --git a/addressbook/gui/widgets/e-addressbook-selector.c b/addressbook/gui/widgets/e-addressbook-selector.c new file mode 100644 index 0000000000..e071e948f4 --- /dev/null +++ b/addressbook/gui/widgets/e-addressbook-selector.c @@ -0,0 +1,376 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-addressbook-selector.c + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "e-addressbook-selector.h" + +#include +#include + +#define E_ADDRESSBOOK_SELECTOR_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_ADDRESSBOOK_SELECTOR, EAddressbookSelectorPrivate)) + +typedef struct _MergeContext MergeContext; + +struct _EAddressbookSelectorPrivate { + gint dummy_value; +}; + +struct _MergeContext { + EBook *source_book; + EBook *target_book; + + EContact *current_contact; + GList *remaining_contacts; + guint pending_removals; + + gint remove_from_source : 1; + gint copy_done : 1; +}; + +enum { + DND_TARGET_TYPE_VCARD, + DND_TARGET_TYPE_SOURCE_VCARD +}; + +static GtkTargetEntry drag_types[] = { + { "text/x-vcard", 0, DND_TARGET_TYPE_VCARD }, + { "text/x-source-vcard", 0, DND_TARGET_TYPE_SOURCE_VCARD } +}; + +static gpointer parent_class; + +static void +merge_context_next (MergeContext *merge_context) +{ + GList *list; + + list = merge_context->remaining_contacts; + merge_context->current_contact = list->data; + list = g_list_delete_link (list, list); + merge_context->remaining_contacts = list; +} + +static MergeContext * +merge_context_new (EBook *source_book, + EBook *target_book, + GList *contact_list) +{ + MergeContext *merge_context; + + merge_context = g_slice_new0 (MergeContext); + merge_context->source_book = source_book; + merge_context->target_book = target_book; + merge_context->remaining_contacts = contact_list; + merge_context_next (merge_context); + + return merge_context; +} + +static void +merge_context_free (MergeContext *merge_context) +{ + if (merge_context->source_book != NULL) + g_object_unref (merge_context->source_book); + + if (merge_context->target_book != NULL) + g_object_unref (merge_context->target_book); + + g_slice_free (MergeContext, merge_context); +} + +static void +addressbook_selector_removed_cb (EBook *book, + EBookStatus status, + MergeContext *merge_context) +{ + merge_context->pending_removals--; + + if (merge_context->remaining_contacts != NULL) + return; + + if (merge_context->pending_removals > 0) + return; + + merge_context_free (merge_context); +} + +static void +addressbook_selector_merge_next_cb (EBook *book, + EBookStatus status, + const gchar *id, + MergeContext *merge_context) +{ + if (merge_context->remove_from_source && status == E_BOOK_ERROR_OK) { + /* Remove previous contact from source. */ + e_book_async_remove_contact ( + merge_context->source_book, + merge_context->current_contact, + (EBookCallback) addressbook_selector_removed_cb, + merge_context); + merge_context->pending_removals++; + } + + g_object_unref (merge_context->current_contact); + + if (merge_context->remaining_contacts != NULL) { + merge_context_next (merge_context); + eab_merging_book_add_contact ( + merge_context->target_book, + merge_context->current_contact, + (EBookIdCallback) addressbook_selector_merge_next_cb, + merge_context); + + } else if (merge_context->pending_removals == 0) + merge_context_free (merge_context); +} + +static void +addressbook_selector_drag_leave (GtkWidget *widget, + GdkDragContext *context, + guint time_) +{ + GtkTreeView *tree_view; + GtkTreeViewDropPosition pos; + + tree_view = GTK_TREE_VIEW (widget); + pos = GTK_TREE_VIEW_DROP_BEFORE; + + gtk_tree_view_set_drag_dest_row (tree_view, NULL, pos); +} + +static gboolean +addressbook_selector_drag_motion (GtkWidget *widget, + GdkDragContext *context, + gint x, + gint y, + guint time_) +{ + GtkTreeView *tree_view; + GtkTreeModel *model; + GtkTreePath *path = NULL; + GtkTreeIter iter; + GtkTreeViewDropPosition pos; + GdkDragAction action = 0; + gpointer object; + + tree_view = GTK_TREE_VIEW (widget); + model = gtk_tree_view_get_model (tree_view); + + if (!gtk_tree_view_get_dest_row_at_pos (tree_view, x, y, &path, NULL)) + goto exit; + + if (!gtk_tree_model_get_iter (model, &iter, path)) + goto exit; + + gtk_tree_model_get (model, &iter, 0, &object, -1); + + if (!E_IS_SOURCE (object) || e_source_get_readonly (object)) + goto exit; + + gtk_tree_view_set_drag_dest_row ( + tree_view, path, GTK_TREE_VIEW_DROP_INTO_OR_BEFORE); + + pos = GTK_TREE_VIEW_DROP_INTO_OR_BEFORE; + gtk_tree_view_set_drag_dest_row (tree_view, path, pos); + + if (context->actions & GDK_ACTION_MOVE) + action = GDK_ACTION_MOVE; + else + action = context->suggested_action; + +exit: + if (path != NULL) + gtk_tree_path_free (path); + + if (object != NULL) + g_object_ref (object); + + gdk_drag_status (context, action, GDK_CURRENT_TIME); + + return TRUE; +} + +static gboolean +addressbook_selector_drag_drop (GtkWidget *widget, + GdkDragContext *context, + gint x, + gint y, + guint time_) +{ + GtkTreeView *tree_view; + GtkTreeModel *model; + GtkTreePath *path; + GtkTreeIter iter; + gboolean drop_zone; + gboolean valid; + gpointer object; + + tree_view = GTK_TREE_VIEW (widget); + model = gtk_tree_view_get_model (tree_view); + + if (!gtk_tree_view_get_path_at_pos ( + tree_view, x, y, &path, NULL, NULL, NULL)) + return FALSE; + + valid = gtk_tree_model_get_iter (model, &iter, path); + gtk_tree_path_free (path); + g_return_val_if_fail (valid, FALSE); + + gtk_tree_model_get (model, &iter, 0, &object, -1); + drop_zone = !E_IS_SOURCE_GROUP (object); + g_object_unref (object); + + return drop_zone; +} + +static void +addressbook_selector_drag_data_received (GtkWidget *widget, + GdkDragContext *context, + gint x, + gint y, + GtkSelectionData *selection_data, + guint info, + guint time_) +{ + MergeContext *merge_context; + GtkTreeView *tree_view; + GtkTreeModel *model; + GtkTreePath *path = NULL; + GtkTreeIter iter; + EBook *source_book; + EBook *target_book; + GList *list; + const gchar *string; + gboolean remove_from_source; + gboolean success = FALSE; + gpointer object; + + tree_view = GTK_TREE_VIEW (widget); + model = gtk_tree_view_get_model (tree_view); + + string = (gchar *) selection_data->data; + remove_from_source = (context->action == GDK_ACTION_MOVE); + + if (!gtk_tree_view_get_dest_row_at_pos (tree_view, x, y, &path, NULL)) + goto exit; + + if (!gtk_tree_model_get_iter (model, &iter, path)) + goto exit; + + gtk_tree_model_get (model, &iter, 0, &object, -1); + + if (!E_IS_SOURCE (object) || e_source_get_readonly (object)) + goto exit; + + target_book = e_book_new (object, NULL); + if (target_book == NULL) + goto exit; + + e_book_open (target_book, FALSE, NULL); + + eab_book_and_contact_list_from_string (string, &source_book, &list); + if (list == NULL) + goto exit; + + /* XXX Get the currently selected EBook. */ + + merge_context = merge_context_new (source_book, target_book, list); + merge_context->remove_from_source = remove_from_source; + + eab_merging_book_add_contact ( + target_book, merge_context->current_contact, + (EBookIdCallback) addressbook_selector_merge_next_cb, + merge_context); + + success = TRUE; + +exit: + if (path) + gtk_tree_path_free (path); + + if (object) + g_object_unref (object); + + gtk_drag_finish (context, success, remove_from_source, time_); +} + +static void +addressbook_selector_class_init (EAddressbookSelectorClass *class) +{ + GtkWidgetClass *widget_class; + + parent_class = g_type_class_peek_parent (class); + g_type_class_add_private (class, sizeof (EAddressbookSelectorPrivate)); + + widget_class = GTK_WIDGET_CLASS (class); + widget_class->drag_leave = addressbook_selector_drag_leave; + widget_class->drag_motion = addressbook_selector_drag_motion; + widget_class->drag_drop = addressbook_selector_drag_drop; + widget_class->drag_data_received = addressbook_selector_drag_data_received; +} + +static void +addressbook_selector_init (EAddressbookSelector *selector) +{ + selector->priv = E_ADDRESSBOOK_SELECTOR_GET_PRIVATE (selector); + + gtk_drag_dest_set ( + GTK_WIDGET (selector), GTK_DEST_DEFAULT_ALL, + drag_types, G_N_ELEMENTS (drag_types), + GDK_ACTION_COPY | GDK_ACTION_MOVE); +} + +GType +e_addressbook_selector_get_type (void) +{ + static GType type = 0; + + if (G_UNLIKELY (type == 0)) { + const GTypeInfo type_info = { + sizeof (EAddressbookSelectorClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) addressbook_selector_class_init, + (GClassFinalizeFunc) NULL, + NULL, /* class_data */ + sizeof (EAddressbookSelector), + 0, /* n_preallocs */ + (GInstanceInitFunc) addressbook_selector_init, + NULL /* value_table */ + }; + + type = g_type_register_static ( + E_TYPE_SOURCE_SELECTOR, "EAddressbookSelector", + &type_info, 0); + } + + return type; +} + +GtkWidget * +e_addressbook_selector_new (ESourceList *source_list) +{ + g_return_val_if_fail (E_IS_SOURCE_LIST (source_list), NULL); + + return g_object_new ( + E_TYPE_ADDRESSBOOK_SELECTOR, + "source-list", source_list, NULL); +} diff --git a/addressbook/gui/widgets/e-addressbook-selector.h b/addressbook/gui/widgets/e-addressbook-selector.h new file mode 100644 index 0000000000..f78442601d --- /dev/null +++ b/addressbook/gui/widgets/e-addressbook-selector.h @@ -0,0 +1,66 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-addressbook-selector.h + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef E_ADDRESSBOOK_SELECTOR_H +#define E_ADDRESSBOOK_SELECTOR_H + +#include +#include + +/* Standard GObject macros */ +#define E_TYPE_ADDRESSBOOK_SELECTOR \ + (e_addressbook_selector_get_type ()) +#define E_ADDRESSBOOK_SELECTOR(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), E_TYPE_ADDRESSBOOK_SELECTOR, EAddressbookSelector)) +#define E_ADDRESSBOOK_SELECTOR_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_CAST \ + ((cls), E_TYPE_ADDRESSBOOK_SELECTOR, EAddressbookSelectorClass)) +#define E_IS_ADDRESSBOOK_SELECTOR(obj) \ + (E_TYPE_CHECK_INSTANCE_TYPE \ + ((obj), E_TYPE_ADDRESSBOOK_SELECTOR)) +#define E_IS_ADDRESSBOOK_SELECTOR_CLASS(cls) \ + (E_TYPE_CHECK_CLASS_TYPE \ + ((cls), E_TYPE_ADDRESSBOOK_SELECTOR)) +#define E_ADDRESSBOOK_SELECTOR_GET_CLASS(obj) \ + (E_TYPE_INSTANCE_GET_CLASS \ + ((obj), E_TYPE_ADDRESSBOOK_SELECTOR, EAddressbookSelectorClass)) + +G_BEGIN_DECLS + +typedef struct _EAddressbookSelector EAddressbookSelector; +typedef struct _EAddressbookSelectorClass EAddressbookSelectorClass; +typedef struct _EAddressbookSelectorPrivate EAddressbookSelectorPrivate; + +struct _EAddressbookSelector { + ESourceSelector parent; + EAddressbookSelectorPrivate *priv; +}; + +struct _EAddressbookSelectorClass { + ESourceSelectorClass parent_class; +}; + +GType e_addressbook_selector_get_type (void); +GtkWidget * e_addressbook_selector_new (ESourceList *source_list); + +G_END_DECLS + +#endif /* E_ADDRESSBOOK_SELECTOR_H */ diff --git a/addressbook/gui/widgets/e-addressbook-view.c b/addressbook/gui/widgets/e-addressbook-view.c index ecae7ed8c3..d44898ba1a 100644 --- a/addressbook/gui/widgets/e-addressbook-view.c +++ b/addressbook/gui/widgets/e-addressbook-view.c @@ -156,10 +156,10 @@ enum { #if 0 static ESearchBarItem addressbook_search_option_items[] = { - { N_("Name begins with"), ESB_FULL_NAME, ESB_ITEMTYPE_RADIO }, - { N_("Email begins with"), ESB_EMAIL, ESB_ITEMTYPE_RADIO }, - { N_("Any field contains"), ESB_ANY, ESB_ITEMTYPE_RADIO }, - { NULL, -1, 0 } + { N_("Name begins with"), ESB_FULL_NAME }, + { N_("Email begins with"), ESB_EMAIL }, + { N_("Any field contains"), ESB_ANY }, + { NULL, -1 } }; #endif @@ -293,7 +293,7 @@ eab_view_init (EABView *eav) eav->displayed_contact = -1; eav->view_instance = NULL; - eav->view_menus = NULL; + /*eav->view_menus = NULL;*/ eav->current_view = NULL; eav->uic = NULL; @@ -343,10 +343,10 @@ eab_view_dispose (GObject *object) eav->view_instance = NULL; } - if (eav->view_menus) { + /*if (eav->view_menus) { g_object_unref (eav->view_menus); eav->view_menus = NULL; - } + }*/ if (eav->clipboard_contacts) { g_list_foreach (eav->clipboard_contacts, (GFunc)g_object_unref, NULL); @@ -540,72 +540,6 @@ writable_status (GtkObject *object, gboolean writable, EABView *eav) command_state_change (eav); } -static void -init_collection (void) -{ - GalViewFactory *factory; - ETableSpecification *spec; - char *galview; - char *addressbookdir; - char *etspecfile; - - if (collection == NULL) { - collection = gal_view_collection_new(); - - gal_view_collection_set_title (collection, _("Address Book")); - - galview = gnome_util_prepend_user_home("/.evolution/addressbook/views"); - addressbookdir = g_build_filename (EVOLUTION_GALVIEWSDIR, - "addressbook", - NULL); - gal_view_collection_set_storage_directories - (collection, - addressbookdir, - galview); - g_free(addressbookdir); - g_free(galview); - - spec = e_table_specification_new(); - etspecfile = g_build_filename (EVOLUTION_ETSPECDIR, - "e-addressbook-view.etspec", - NULL); - if (!e_table_specification_load_from_file (spec, etspecfile)) - g_error ("Unable to load ETable specification file " - "for address book"); - g_free (etspecfile); - - factory = gal_view_factory_etable_new (spec); - g_object_unref (spec); - gal_view_collection_add_factory (collection, factory); - g_object_unref (factory); - - factory = gal_view_factory_minicard_new(); - gal_view_collection_add_factory (collection, factory); - g_object_unref (factory); - - gal_view_collection_load(collection); - } -} - -static void -set_view_preview (EABView *view) -{ - /* XXX this should use the addressbook's global gconf client */ - GConfClient *gconf_client; - gboolean state; - - gconf_client = gconf_client_get_default(); - state = gconf_client_get_bool(gconf_client, "/apps/evolution/addressbook/display/show_preview", NULL); - bonobo_ui_component_set_prop (view->uic, - "/commands/ContactsViewPreview", - "state", - state ? "1" : "0", NULL); - - eab_view_show_contact_preview (view, state); - - g_object_unref (gconf_client); -} - static void display_view(GalViewInstance *instance, GalView *view, @@ -623,48 +557,24 @@ display_view(GalViewInstance *instance, address_view->current_view = view; set_paned_position (address_view); - set_view_preview (address_view); -} - -static void -view_preview(BonoboUIComponent *uic, const char *path, Bonobo_UIComponent_EventType type, const char *state, void *data) -{ - /* XXX this should use the addressbook's global gconf client */ - GConfClient *gconf_client; - EABView *view = EAB_VIEW (data); - - if (type != Bonobo_UIComponent_STATE_CHANGED) - return; - - gconf_client = gconf_client_get_default(); - gconf_client_set_bool(gconf_client, "/apps/evolution/addressbook/display/show_preview", state[0] != '0', NULL); - - eab_view_show_contact_preview(view, state[0] != '0'); - - g_object_unref (gconf_client); } static void setup_menus (EABView *view) { if (view->book && view->view_instance == NULL) { - init_collection (); 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); + /*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); } - - bonobo_ui_component_add_listener(view->uic, "ContactsViewPreview", view_preview, view); - - set_view_preview (view); } static void @@ -1635,8 +1545,6 @@ eab_view_setup_menus (EABView *view, g_return_if_fail (uic != NULL); g_return_if_fail (BONOBO_IS_UI_COMPONENT (uic)); - init_collection (); - view->uic = uic; setup_menus (view); @@ -1660,12 +1568,12 @@ 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) { + /*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); diff --git a/addressbook/gui/widgets/e-addressbook-view.h b/addressbook/gui/widgets/e-addressbook-view.h index 2303d6b06f..af5d50a78f 100644 --- a/addressbook/gui/widgets/e-addressbook-view.h +++ b/addressbook/gui/widgets/e-addressbook-view.h @@ -17,8 +17,8 @@ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ -#ifndef __EAB_VIEW_H__ -#define __EAB_VIEW_H__ +#ifndef EAB_VIEW_H +#define EAB_VIEW_H #include #include @@ -26,29 +26,33 @@ #include #include "e-addressbook-model.h" #include "eab-contact-display.h" -#include "widgets/menus/gal-view-menus.h" #include "misc/e-search-bar.h" #include "misc/e-filter-bar.h" +/* Standard GObject macros */ +#define E_TYPE_AB_VIEW \ + (eab_view_get_type ()) +#define EAB_VIEW(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), E_TYPE_AB_VIEW, EABView)) +#define EAB_VIEW_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_CAST \ + ((cls), E_TYPE_AB_VIEW, EABViewClass)) +#define E_IS_ADDRESSBOOK_VIEW(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE \ + ((obj), E_TYPE_AB_VIEW)) +#define E_IS_ADDRESSBOOK_VIEW_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_TYPE \ + ((obj), E_TYPE_AB_VIEW)) +#define E_ADDRESSBOOK_VIEW_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS \ + ((obj), E_TYPE_AB_VIEW, EABViewClass)) + G_BEGIN_DECLS struct _EABMenu; struct _EABMenuTargetSelect; -/* EABView - A card displaying information about a contact. - * - * The following arguments are available: - * - * name type read/write description - * -------------------------------------------------------------------------------- - */ - -#define E_TYPE_AB_VIEW (eab_view_get_type ()) -#define EAB_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_AB_VIEW, EABView)) -#define EAB_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_AB_VIEW, EABViewClass)) -#define E_IS_ADDRESSBOOK_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_AB_VIEW)) -#define E_IS_ADDRESSBOOK_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_AB_VIEW)) - typedef enum { EAB_VIEW_NONE, /* initialized to this */ EAB_VIEW_MINICARD, @@ -56,11 +60,10 @@ typedef enum { } EABViewType; -typedef struct _EABView EABView; -typedef struct _EABViewClass EABViewClass; +typedef struct _EABView EABView; +typedef struct _EABViewClass EABViewClass; -struct _EABView -{ +struct _EABView { GtkVBox parent; /* item specific fields */ @@ -87,7 +90,7 @@ struct _EABView /* Menus handler and the view instance */ GalViewInstance *view_instance; - GalViewMenus *view_menus; + /*GalViewMenus *view_menus;*/ GalView *current_view; BonoboUIComponent *uic; @@ -98,64 +101,66 @@ struct _EABView FilterRule *search_rule; }; -struct _EABViewClass -{ +struct _EABViewClass { GtkVBoxClass parent_class; - /* - * Signals - */ + /* Signals */ void (*status_message) (EABView *view, const gchar *message); void (*search_result) (EABView *view, EBookViewStatus status); void (*folder_bar_message) (EABView *view, const gchar *message); void (*command_state_change) (EABView *view); }; -GtkWidget *eab_view_new (void); -GType eab_view_get_type (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); -void eab_view_send (EABView *view); -void eab_view_send_to (EABView *view); -void eab_view_print (EABView *view, - GtkPrintOperationAction action); -void eab_view_delete_selection (EABView *view, gboolean is_delete); -void eab_view_cut (EABView *view); -void eab_view_copy (EABView *view); -void eab_view_paste (EABView *view); -void eab_view_select_all (EABView *view); -void eab_view_show_all (EABView *view); -void eab_view_stop (EABView *view); -void eab_view_copy_to_folder (EABView *view, gboolean all); -void eab_view_move_to_folder (EABView *view, gboolean all); - -gboolean eab_view_can_create (EABView *view); -gboolean eab_view_can_print (EABView *view); -gboolean eab_view_can_save_as (EABView *view); -gboolean eab_view_can_view (EABView *view); -gboolean eab_view_can_send (EABView *view); -gboolean eab_view_can_send_to (EABView *view); -gboolean eab_view_can_delete (EABView *view); -gboolean eab_view_can_cut (EABView *view); -gboolean eab_view_can_copy (EABView *view); -gboolean eab_view_can_paste (EABView *view); -gboolean eab_view_can_select_all (EABView *view); -gboolean eab_view_can_stop (EABView *view); -gboolean eab_view_can_copy_to_folder (EABView *view); -gboolean eab_view_can_move_to_folder (EABView *view); - -struct _EABMenuTargetSelect *eab_view_get_menu_target (EABView *view, struct _EABMenu *menu); +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); +void eab_view_send (EABView *view); +void eab_view_send_to (EABView *view); +void eab_view_print (EABView *view, + GtkPrintOperationAction action); +void eab_view_delete_selection (EABView *view, + gboolean is_delete); +void eab_view_cut (EABView *view); +void eab_view_copy (EABView *view); +void eab_view_paste (EABView *view); +void eab_view_select_all (EABView *view); +void eab_view_show_all (EABView *view); +void eab_view_stop (EABView *view); +void eab_view_copy_to_folder (EABView *view, + gboolean all); +void eab_view_move_to_folder (EABView *view, + gboolean all); + +gboolean eab_view_can_create (EABView *view); +gboolean eab_view_can_print (EABView *view); +gboolean eab_view_can_save_as (EABView *view); +gboolean eab_view_can_view (EABView *view); +gboolean eab_view_can_send (EABView *view); +gboolean eab_view_can_send_to (EABView *view); +gboolean eab_view_can_delete (EABView *view); +gboolean eab_view_can_cut (EABView *view); +gboolean eab_view_can_copy (EABView *view); +gboolean eab_view_can_paste (EABView *view); +gboolean eab_view_can_select_all (EABView *view); +gboolean eab_view_can_stop (EABView *view); +gboolean eab_view_can_copy_to_folder (EABView *view); +gboolean eab_view_can_move_to_folder (EABView *view); + +struct _EABMenuTargetSelect * + eab_view_get_menu_target (EABView *view, + struct _EABMenu *menu); G_END_DECLS -#endif /* __EAB_VIEW_H__ */ +#endif /* EAB_VIEW_H */ -- cgit