diff options
author | Ettore Perazzoli <ettore@src.gnome.org> | 2003-10-22 02:49:34 +0800 |
---|---|---|
committer | Ettore Perazzoli <ettore@src.gnome.org> | 2003-10-22 02:49:34 +0800 |
commit | 653cfffc0e00dfb59b36813c1b45c53d3f773c65 (patch) | |
tree | 9b486d5e383ec1391d60973d9cc548be0ef6d9d5 /addressbook/gui/widgets/e-addressbook-view.c | |
parent | 0fb08f3ff81575a4749d851404233f34252dd2f2 (diff) | |
download | gsoc2013-evolution-653cfffc0e00dfb59b36813c1b45c53d3f773c65.tar gsoc2013-evolution-653cfffc0e00dfb59b36813c1b45c53d3f773c65.tar.gz gsoc2013-evolution-653cfffc0e00dfb59b36813c1b45c53d3f773c65.tar.bz2 gsoc2013-evolution-653cfffc0e00dfb59b36813c1b45c53d3f773c65.tar.lz gsoc2013-evolution-653cfffc0e00dfb59b36813c1b45c53d3f773c65.tar.xz gsoc2013-evolution-653cfffc0e00dfb59b36813c1b45c53d3f773c65.tar.zst gsoc2013-evolution-653cfffc0e00dfb59b36813c1b45c53d3f773c65.zip |
Merge new-ui-branch to the trunk.
svn path=/trunk/; revision=22965
Diffstat (limited to 'addressbook/gui/widgets/e-addressbook-view.c')
-rw-r--r-- | addressbook/gui/widgets/e-addressbook-view.c | 1147 |
1 files changed, 458 insertions, 689 deletions
diff --git a/addressbook/gui/widgets/e-addressbook-view.c b/addressbook/gui/widgets/e-addressbook-view.c index 08710c71b5..4c5976717f 100644 --- a/addressbook/gui/widgets/e-addressbook-view.c +++ b/addressbook/gui/widgets/e-addressbook-view.c @@ -43,26 +43,24 @@ #include "addressbook/printing/e-contact-print.h" #include "addressbook/printing/e-contact-print-envelope.h" -#include "gal-view-factory-minicard.h" -#include "gal-view-minicard.h" #ifdef WITH_ADDRESSBOOK_VIEW_TREEVIEW #include <gal/widgets/e-treeview-selection-model.h> #include "gal-view-factory-treeview.h" #include "gal-view-treeview.h" #endif +#include "gal-view-minicard.h" +#include "gal-view-factory-minicard.h" -#include "e-addressbook-marshal.h" +#include "eab-marshal.h" #include "e-addressbook-view.h" #include "e-addressbook-model.h" -#include "e-addressbook-util.h" +#include "eab-gui-util.h" +#include "util/eab-book-util.h" #include "e-addressbook-table-adapter.h" #ifdef WITH_ADDRESSBOOK_VIEW_TREEVIEW #include "e-addressbook-treeview-adapter.h" #endif -#include "e-addressbook-reflow-adapter.h" -#include "e-minicard-view-widget.h" -#include "e-contact-save-as.h" -#include "e-card-merging.h" +#include "eab-contact-merging.h" #include "e-contact-editor.h" #include <gdk/gdkkeysyms.h> @@ -76,33 +74,33 @@ #define d(x) -static void e_addressbook_view_init (EAddressbookView *card); -static void e_addressbook_view_class_init (EAddressbookViewClass *klass); +static void eab_view_init (EABView *card); +static void eab_view_class_init (EABViewClass *klass); -static void e_addressbook_view_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); -static void e_addressbook_view_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); +static void eab_view_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); +static void eab_view_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); -static void e_addressbook_view_dispose (GObject *object); -static void change_view_type (EAddressbookView *view, EAddressbookViewType view_type); +static void eab_view_dispose (GObject *object); +static void change_view_type (EABView *view, EABViewType view_type); -static void status_message (GtkObject *object, const gchar *status, EAddressbookView *eav); -static void search_result (GtkObject *object, EBookViewStatus status, EAddressbookView *eav); -static void folder_bar_message (GtkObject *object, const gchar *status, EAddressbookView *eav); -static void stop_state_changed (GtkObject *object, EAddressbookView *eav); -static void writable_status (GtkObject *object, gboolean writable, EAddressbookView *eav); -static void backend_died (GtkObject *object, EAddressbookView *eav); -static void command_state_change (EAddressbookView *eav); -static void alphabet_state_change (EAddressbookView *eav, gunichar letter); +static void status_message (GtkObject *object, const gchar *status, EABView *eav); +static void search_result (GtkObject *object, EBookViewStatus status, EABView *eav); +static void folder_bar_message (GtkObject *object, const gchar *status, EABView *eav); +static void stop_state_changed (GtkObject *object, EABView *eav); +static void writable_status (GtkObject *object, gboolean writable, EABView *eav); +static void backend_died (GtkObject *object, EABView *eav); +static void command_state_change (EABView *eav); static void selection_clear_event (GtkWidget *invisible, GdkEventSelection *event, - EAddressbookView *view); + EABView *view); static void selection_received (GtkWidget *invisible, GtkSelectionData *selection_data, - guint time, EAddressbookView *view); + guint time, EABView *view); static void selection_get (GtkWidget *invisible, GtkSelectionData *selection_data, - guint info, guint time_stamp, EAddressbookView *view); + guint info, guint time_stamp, EABView *view); static void invisible_destroyed (gpointer data, GObject *where_object_was); -static GtkTableClass *parent_class = NULL; +#define PARENT_TYPE GTK_TYPE_EVENT_BOX +static GtkEventBoxClass *parent_class = NULL; /* The arguments we take */ enum { @@ -117,7 +115,6 @@ enum { SEARCH_RESULT, FOLDER_BAR_MESSAGE, COMMAND_STATE_CHANGE, - ALPHABET_STATE_CHANGE, LAST_SIGNAL }; @@ -130,38 +127,38 @@ static GtkTargetEntry drag_types[] = { }; static const int num_drag_types = sizeof (drag_types) / sizeof (drag_types[0]); -static guint e_addressbook_view_signals [LAST_SIGNAL] = {0, }; +static guint eab_view_signals [LAST_SIGNAL] = {0, }; static GdkAtom clipboard_atom = GDK_NONE; static GalViewCollection *collection = NULL; GType -e_addressbook_view_get_type (void) +eab_view_get_type (void) { static GType type = 0; if (!type) { static const GTypeInfo info = { - sizeof (EAddressbookViewClass), + sizeof (EABViewClass), NULL, /* base_init */ NULL, /* base_finalize */ - (GClassInitFunc) e_addressbook_view_class_init, + (GClassInitFunc) eab_view_class_init, NULL, /* class_finalize */ NULL, /* class_data */ - sizeof (EAddressbookView), + sizeof (EABView), 0, /* n_preallocs */ - (GInstanceInitFunc) e_addressbook_view_init, + (GInstanceInitFunc) eab_view_init, }; - type = g_type_register_static (GTK_TYPE_TABLE, "EAddressbookView", &info, 0); + type = g_type_register_static (PARENT_TYPE, "EABView", &info, 0); } return type; } static void -e_addressbook_view_class_init (EAddressbookViewClass *klass) +eab_view_class_init (EABViewClass *klass) { GObjectClass *object_class; GtkWidgetClass *widget_class; @@ -169,11 +166,11 @@ e_addressbook_view_class_init (EAddressbookViewClass *klass) object_class = G_OBJECT_CLASS(klass); widget_class = GTK_WIDGET_CLASS(klass); - parent_class = gtk_type_class (gtk_table_get_type ()); + parent_class = gtk_type_class (PARENT_TYPE); - object_class->set_property = e_addressbook_view_set_property; - object_class->get_property = e_addressbook_view_get_property; - object_class->dispose = e_addressbook_view_dispose; + object_class->set_property = eab_view_set_property; + object_class->get_property = eab_view_get_property; + object_class->dispose = eab_view_dispose; g_object_class_install_property (object_class, PROP_BOOK, g_param_spec_object ("book", @@ -193,137 +190,78 @@ e_addressbook_view_class_init (EAddressbookViewClass *klass) g_param_spec_int ("type", _("Type"), /*_( */"XXX blurb" /*)*/, - E_ADDRESSBOOK_VIEW_NONE, -#ifdef WITH_ADDRESSBOOK_VIEW_TREEVIEW - E_ADDRESSBOOK_VIEW_TREEVIEW, -#else - E_ADDRESSBOOK_VIEW_MINICARD, -#endif - E_ADDRESSBOOK_VIEW_NONE, + EAB_VIEW_NONE, + EAB_VIEW_TABLE, + EAB_VIEW_NONE, G_PARAM_READWRITE)); - e_addressbook_view_signals [STATUS_MESSAGE] = + eab_view_signals [STATUS_MESSAGE] = g_signal_new ("status_message", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EAddressbookViewClass, status_message), + G_STRUCT_OFFSET (EABViewClass, status_message), NULL, NULL, - e_addressbook_marshal_NONE__POINTER, + eab_marshal_NONE__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER); - e_addressbook_view_signals [SEARCH_RESULT] = + eab_view_signals [SEARCH_RESULT] = g_signal_new ("search_result", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EAddressbookViewClass, search_result), + G_STRUCT_OFFSET (EABViewClass, search_result), NULL, NULL, - e_addressbook_marshal_NONE__INT, + eab_marshal_NONE__INT, G_TYPE_NONE, 1, G_TYPE_INT); - e_addressbook_view_signals [FOLDER_BAR_MESSAGE] = + eab_view_signals [FOLDER_BAR_MESSAGE] = g_signal_new ("folder_bar_message", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EAddressbookViewClass, folder_bar_message), + G_STRUCT_OFFSET (EABViewClass, folder_bar_message), NULL, NULL, - e_addressbook_marshal_NONE__POINTER, + eab_marshal_NONE__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER); - e_addressbook_view_signals [COMMAND_STATE_CHANGE] = + eab_view_signals [COMMAND_STATE_CHANGE] = g_signal_new ("command_state_change", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EAddressbookViewClass, command_state_change), + G_STRUCT_OFFSET (EABViewClass, command_state_change), NULL, NULL, - e_addressbook_marshal_NONE__NONE, + eab_marshal_NONE__NONE, G_TYPE_NONE, 0); - e_addressbook_view_signals [ALPHABET_STATE_CHANGE] = - g_signal_new ("alphabet_state_change", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EAddressbookViewClass, alphabet_state_change), - NULL, NULL, - e_addressbook_marshal_NONE__UINT, - G_TYPE_NONE, 1, G_TYPE_UINT); - - if (!clipboard_atom) clipboard_atom = gdk_atom_intern ("CLIPBOARD", FALSE); } static void -e_addressbook_view_init (EAddressbookView *eav) +eab_view_init (EABView *eav) { - eav->view_type = E_ADDRESSBOOK_VIEW_NONE; - - eav->model = e_addressbook_model_new (); - - g_signal_connect (eav->model, - "status_message", - G_CALLBACK (status_message), - eav); - - g_signal_connect (eav->model, - "search_result", - G_CALLBACK (search_result), - eav); - - g_signal_connect (eav->model, - "folder_bar_message", - G_CALLBACK (folder_bar_message), - eav); - - g_signal_connect (eav->model, - "stop_state_changed", - G_CALLBACK (stop_state_changed), - eav); - - g_signal_connect (eav->model, - "writable_status", - G_CALLBACK (writable_status), - eav); - - g_signal_connect (eav->model, - "backend_died", - G_CALLBACK (backend_died), - eav); - - eav->editable = FALSE; - eav->book = NULL; - eav->query = g_strdup (SHOW_ALL_SEARCH); + eav->view_type = EAB_VIEW_NONE; + eav->model = NULL; eav->object = NULL; eav->widget = NULL; + eav->scrolled = NULL; + eav->contact_display = NULL; eav->view_instance = NULL; eav->view_menus = NULL; + eav->current_view = NULL; eav->uic = NULL; - eav->current_alphabet_widget = NULL; - eav->invisible = gtk_invisible_new (); + eav->book = NULL; + eav->query = NULL; - gtk_selection_add_target (eav->invisible, - clipboard_atom, - GDK_SELECTION_TYPE_STRING, - 0); - - g_signal_connect (eav->invisible, "selection_get", - G_CALLBACK (selection_get), - eav); - g_signal_connect (eav->invisible, "selection_clear_event", - G_CALLBACK (selection_clear_event), - eav); - g_signal_connect (eav->invisible, "selection_received", - G_CALLBACK (selection_received), - eav); - g_object_weak_ref (G_OBJECT (eav->invisible), invisible_destroyed, eav); + eav->invisible = NULL; + eav->clipboard_contacts = NULL; } static void -e_addressbook_view_dispose (GObject *object) +eab_view_dispose (GObject *object) { - EAddressbookView *eav = E_ADDRESSBOOK_VIEW(object); + EABView *eav = EAB_VIEW(object); if (eav->model) { g_signal_handlers_disconnect_matched (eav->model, @@ -356,10 +294,10 @@ e_addressbook_view_dispose (GObject *object) eav->view_menus = NULL; } - if (eav->clipboard_cards) { - g_list_foreach (eav->clipboard_cards, (GFunc)g_object_unref, NULL); - g_list_free (eav->clipboard_cards); - eav->clipboard_cards = NULL; + if (eav->clipboard_contacts) { + g_list_foreach (eav->clipboard_contacts, (GFunc)g_object_unref, NULL); + g_list_free (eav->clipboard_contacts); + eav->clipboard_contacts = NULL; } if (eav->invisible) { @@ -372,14 +310,77 @@ e_addressbook_view_dispose (GObject *object) } GtkWidget* -e_addressbook_view_new (void) -{ - GtkWidget *widget = GTK_WIDGET (g_object_new (E_TYPE_ADDRESSBOOK_VIEW, NULL)); +eab_view_new (void) +{ + GtkWidget *widget = GTK_WIDGET (g_object_new (E_TYPE_AB_VIEW, NULL)); + EABView *eav = EAB_VIEW (widget); + + /* create our model */ + eav->model = eab_model_new (); + + g_signal_connect (eav->model, "status_message", + G_CALLBACK (status_message), eav); + g_signal_connect (eav->model, "search_result", + G_CALLBACK (search_result), eav); + g_signal_connect (eav->model, "folder_bar_message", + G_CALLBACK (folder_bar_message), eav); + g_signal_connect (eav->model, "stop_state_changed", + G_CALLBACK (stop_state_changed), eav); + g_signal_connect (eav->model, "writable_status", + G_CALLBACK (writable_status), eav); + g_signal_connect (eav->model, "backend_died", + G_CALLBACK (backend_died), eav); + + eav->editable = FALSE; + eav->query = g_strdup (SHOW_ALL_SEARCH); + + /* create the paned window and contact display */ + eav->paned = gtk_vpaned_new (); + gtk_container_add (GTK_CONTAINER (eav), eav->paned); + + eav->widget = gtk_label_new ("empty label here"); + gtk_container_add (GTK_CONTAINER (eav->paned), eav->widget); + gtk_widget_show (eav->widget); + + eav->scrolled = gtk_scrolled_window_new (NULL, NULL); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (eav->scrolled), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (eav->scrolled), GTK_SHADOW_IN); + eav->contact_display = eab_contact_display_new (); + + gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (eav->scrolled), eav->contact_display); + gtk_widget_show (eav->contact_display); + + gtk_container_add (GTK_CONTAINER (eav->paned), eav->scrolled); + gtk_widget_show (eav->scrolled); + gtk_widget_show (eav->paned); + + /* XXX hack */ + gtk_paned_set_position (GTK_PANED (eav->paned), 144); + + /* gtk selection crap */ + eav->invisible = gtk_invisible_new (); + + gtk_selection_add_target (eav->invisible, + clipboard_atom, + GDK_SELECTION_TYPE_STRING, + 0); + + g_signal_connect (eav->invisible, "selection_get", + G_CALLBACK (selection_get), + eav); + g_signal_connect (eav->invisible, "selection_clear_event", + G_CALLBACK (selection_clear_event), + eav); + g_signal_connect (eav->invisible, "selection_received", + G_CALLBACK (selection_received), + eav); + g_object_weak_ref (G_OBJECT (eav->invisible), invisible_destroyed, eav); + return widget; } static void -writable_status (GtkObject *object, gboolean writable, EAddressbookView *eav) +writable_status (GtkObject *object, gboolean writable, EABView *eav) { eav->editable = writable; command_state_change (eav); @@ -412,7 +413,7 @@ init_collection (void) gal_view_collection_add_factory (collection, factory); g_object_unref (factory); - factory = gal_view_factory_minicard_new (); + factory = gal_view_factory_minicard_new(); gal_view_collection_add_factory (collection, factory); g_object_unref (factory); @@ -431,17 +432,18 @@ display_view(GalViewInstance *instance, GalView *view, gpointer data) { - EAddressbookView *address_view = data; + EABView *address_view = data; if (GAL_IS_VIEW_ETABLE(view)) { - change_view_type (address_view, E_ADDRESSBOOK_VIEW_TABLE); + change_view_type (address_view, EAB_VIEW_TABLE); gal_view_etable_attach_table (GAL_VIEW_ETABLE(view), e_table_scrolled_get_table(E_TABLE_SCROLLED(address_view->widget))); - } else if (GAL_IS_VIEW_MINICARD(view)) { - change_view_type (address_view, E_ADDRESSBOOK_VIEW_MINICARD); - gal_view_minicard_attach (GAL_VIEW_MINICARD(view), E_MINICARD_VIEW_WIDGET (address_view->object)); + } + else if (GAL_IS_VIEW_MINICARD(view)) { + change_view_type (address_view, EAB_VIEW_MINICARD); + gal_view_minicard_attach (GAL_VIEW_MINICARD (view), E_MINICARD_VIEW_WIDGET (address_view->object)); } #ifdef WITH_ADDRESSBOOK_VIEW_TREEVIEW else if (GAL_IS_VIEW_TREEVIEW (view)) { - change_view_type (address_view, E_ADDRESSBOOK_VIEW_TREEVIEW); + change_view_type (address_view, EAB_VIEW_TREEVIEW); gal_view_treeview_attach (GAL_VIEW_TREEVIEW(view), GTK_TREE_VIEW (address_view->object)); } #endif @@ -449,7 +451,7 @@ display_view(GalViewInstance *instance, } static void -setup_menus (EAddressbookView *view) +setup_menus (EABView *view) { if (view->book && view->view_instance == NULL) { init_collection (); @@ -468,9 +470,9 @@ setup_menus (EAddressbookView *view) } static void -e_addressbook_view_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +eab_view_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { - EAddressbookView *eav = E_ADDRESSBOOK_VIEW(object); + EABView *eav = EAB_VIEW(object); switch (prop_id){ case PROP_BOOK: @@ -509,12 +511,6 @@ e_addressbook_view_set_property (GObject *object, guint prop_id, const GValue *v g_object_set(eav->model, "query", eav->query, NULL); - if (eav->current_alphabet_widget != NULL) { - GtkWidget *current = eav->current_alphabet_widget; - - eav->current_alphabet_widget = NULL; - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (current), FALSE); - } break; case PROP_TYPE: change_view_type(eav, g_value_get_int (value)); @@ -526,9 +522,9 @@ e_addressbook_view_set_property (GObject *object, guint prop_id, const GValue *v } static void -e_addressbook_view_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +eab_view_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - EAddressbookView *eav = E_ADDRESSBOOK_VIEW(object); + EABView *eav = EAB_VIEW(object); switch (prop_id) { case PROP_BOOK: @@ -550,44 +546,43 @@ e_addressbook_view_get_property (GObject *object, guint prop_id, GValue *value, } static ESelectionModel* -get_selection_model (EAddressbookView *view) +get_selection_model (EABView *view) { - if (view->view_type == E_ADDRESSBOOK_VIEW_MINICARD) - return e_minicard_view_widget_get_selection_model (E_MINICARD_VIEW_WIDGET(view->object)); - else if (view->view_type == E_ADDRESSBOOK_VIEW_TABLE) + if (view->view_type == EAB_VIEW_TABLE) return e_table_get_selection_model (e_table_scrolled_get_table (E_TABLE_SCROLLED(view->widget))); + else if (view->view_type == EAB_VIEW_MINICARD) + return e_minicard_view_widget_get_selection_model (E_MINICARD_VIEW_WIDGET(view->object)); #ifdef WITH_ADDRESSBOOK_VIEW_TREEVIEW - else if (view->view_type == E_ADDRESSBOOK_VIEW_TREEVIEW) { + else if (view->view_type == EAB_VIEW_TREEVIEW) return e_treeview_get_selection_model (GTK_TREE_VIEW (view->object)); - } #endif g_return_val_if_reached (NULL); } /* Popup menu stuff */ typedef struct { - EAddressbookView *view; + EABView *view; EPopupMenu *submenu; gpointer closure; -} CardAndBook; +} ContactAndBook; static ESelectionModel* -card_and_book_get_selection_model (CardAndBook *card_and_book) +contact_and_book_get_selection_model (ContactAndBook *contact_and_book) { - return get_selection_model (card_and_book->view); + return get_selection_model (contact_and_book->view); } static void -card_and_book_free (CardAndBook *card_and_book) +contact_and_book_free (ContactAndBook *contact_and_book) { - EAddressbookView *view = card_and_book->view; + EABView *view = contact_and_book->view; ESelectionModel *selection; - if (card_and_book->submenu) + if (contact_and_book->submenu) gal_view_instance_free_popup_menu (view->view_instance, - card_and_book->submenu); + contact_and_book->submenu); - selection = card_and_book_get_selection_model (card_and_book); + selection = contact_and_book_get_selection_model (contact_and_book); if (selection) e_selection_model_right_click_up(selection); @@ -595,33 +590,33 @@ card_and_book_free (CardAndBook *card_and_book) } static void -get_card_list_1(gint model_row, - gpointer closure) +get_contact_list_1(gint model_row, + gpointer closure) { - CardAndBook *card_and_book; + ContactAndBook *contact_and_book; GList **list; - EAddressbookView *view; - ECard *card; + EABView *view; + EContact *contact; - card_and_book = closure; - list = card_and_book->closure; - view = card_and_book->view; + contact_and_book = closure; + list = contact_and_book->closure; + view = contact_and_book->view; - card = e_addressbook_model_get_card(view->model, model_row); - *list = g_list_prepend(*list, card); + contact = eab_model_get_contact(view->model, model_row); + *list = g_list_prepend(*list, contact); } static GList * -get_card_list (CardAndBook *card_and_book) +get_contact_list (ContactAndBook *contact_and_book) { GList *list = NULL; ESelectionModel *selection; - selection = card_and_book_get_selection_model (card_and_book); + selection = contact_and_book_get_selection_model (contact_and_book); if (selection) { - card_and_book->closure = &list; - e_selection_model_foreach (selection, get_card_list_1, card_and_book); + contact_and_book->closure = &list; + e_selection_model_foreach (selection, get_contact_list_1, contact_and_book); } return list; @@ -631,135 +626,134 @@ static void has_email_address_1(gint model_row, gpointer closure) { - CardAndBook *card_and_book; + ContactAndBook *contact_and_book; gboolean *has_email; - EAddressbookView *view; - const ECard *card; - EList *email; + EABView *view; + const EContact *contact; + GList *email; - card_and_book = closure; - has_email = card_and_book->closure; - view = card_and_book->view; + contact_and_book = closure; + has_email = contact_and_book->closure; + view = contact_and_book->view; if (*has_email) return; - card = e_addressbook_model_peek_card(view->model, model_row); + contact = eab_model_contact_at(view->model, model_row); - g_object_get (G_OBJECT (card), - "email", &email, - NULL); + email = e_contact_get (E_CONTACT (contact), E_CONTACT_EMAIL); - if (e_list_length (email) > 0) + if (g_list_length (email) > 0) *has_email = TRUE; - g_object_unref (email); + g_list_foreach (email, (GFunc)g_free, NULL); + g_list_free (email); } static gboolean -get_has_email_address (CardAndBook *card_and_book) +get_has_email_address (ContactAndBook *contact_and_book) { ESelectionModel *selection; gboolean has_email = FALSE; - selection = card_and_book_get_selection_model (card_and_book); + selection = contact_and_book_get_selection_model (contact_and_book); if (selection) { - card_and_book->closure = &has_email; - e_selection_model_foreach (selection, has_email_address_1, card_and_book); + contact_and_book->closure = &has_email; + e_selection_model_foreach (selection, has_email_address_1, contact_and_book); } return has_email; } static void -save_as (GtkWidget *widget, CardAndBook *card_and_book) +save_as (GtkWidget *widget, ContactAndBook *contact_and_book) { - GList *cards = get_card_list (card_and_book); - if (cards) { - e_contact_list_save_as(_("Save as VCard"), cards, NULL); - e_free_object_list(cards); + GList *contacts = get_contact_list (contact_and_book); + if (contacts) { + eab_contact_list_save(_("Save as VCard"), contacts, NULL); + e_free_object_list(contacts); } } static void -send_as (GtkWidget *widget, CardAndBook *card_and_book) +send_as (GtkWidget *widget, ContactAndBook *contact_and_book) { - GList *cards = get_card_list (card_and_book); - if (cards) { - e_addressbook_send_card_list(cards, E_ADDRESSBOOK_DISPOSITION_AS_ATTACHMENT); - e_free_object_list(cards); + GList *contacts = get_contact_list (contact_and_book); + if (contacts) { + eab_send_contact_list(contacts, EAB_DISPOSITION_AS_ATTACHMENT); + e_free_object_list(contacts); } } static void -send_to (GtkWidget *widget, CardAndBook *card_and_book) +send_to (GtkWidget *widget, ContactAndBook *contact_and_book) { - GList *cards = get_card_list (card_and_book); + GList *contacts = get_contact_list (contact_and_book); - if (cards) { - e_addressbook_send_card_list(cards, E_ADDRESSBOOK_DISPOSITION_AS_TO); - e_free_object_list(cards); + if (contacts) { + eab_send_contact_list(contacts, EAB_DISPOSITION_AS_TO); + e_free_object_list(contacts); } } static void -print (GtkWidget *widget, CardAndBook *card_and_book) +print (GtkWidget *widget, ContactAndBook *contact_and_book) { - GList *cards = get_card_list (card_and_book); - if (cards) { - if (cards->next) - gtk_widget_show(e_contact_print_card_list_dialog_new(cards)); + GList *contacts = get_contact_list (contact_and_book); + if (contacts) { + if (contacts->next) + gtk_widget_show(e_contact_print_contact_list_dialog_new(contacts)); else - gtk_widget_show(e_contact_print_card_dialog_new(cards->data)); - e_free_object_list(cards); + gtk_widget_show(e_contact_print_contact_dialog_new(contacts->data)); + e_free_object_list(contacts); } } #if 0 /* Envelope printing is disabled for Evolution 1.0. */ static void -print_envelope (GtkWidget *widget, CardAndBook *card_and_book) +print_envelope (GtkWidget *widget, ContactAndBook *contact_and_book) { - GList *cards = get_card_list (card_and_book); + GList *cards = get_card_list (contact_and_book); if (cards) { - gtk_widget_show(e_contact_list_print_envelope_dialog_new(card_and_book->card)); + gtk_widget_show(e_contact_list_print_envelope_dialog_new(contact_and_book->card)); e_free_object_list(cards); } } #endif static void -copy (GtkWidget *widget, CardAndBook *card_and_book) +copy (GtkWidget *widget, ContactAndBook *contact_and_book) { - e_addressbook_view_copy (card_and_book->view); + eab_view_copy (contact_and_book->view); } static void -paste (GtkWidget *widget, CardAndBook *card_and_book) +paste (GtkWidget *widget, ContactAndBook *contact_and_book) { - e_addressbook_view_paste (card_and_book->view); + eab_view_paste (contact_and_book->view); } static void -cut (GtkWidget *widget, CardAndBook *card_and_book) +cut (GtkWidget *widget, ContactAndBook *contact_and_book) { - e_addressbook_view_cut (card_and_book->view); + eab_view_cut (contact_and_book->view); } static void -delete (GtkWidget *widget, CardAndBook *card_and_book) +delete (GtkWidget *widget, ContactAndBook *contact_and_book) { - if (e_contact_editor_confirm_delete(GTK_WINDOW(gtk_widget_get_toplevel(card_and_book->view->widget)))) { + if (e_contact_editor_confirm_delete(GTK_WINDOW(gtk_widget_get_toplevel(contact_and_book->view->widget)))) { EBook *book; - GList *list = get_card_list(card_and_book); + GList *list = get_contact_list(contact_and_book); GList *iterator; gboolean bulk_remove = FALSE; - bulk_remove = e_book_check_static_capability (card_and_book->view->model->book, + bulk_remove = e_book_check_static_capability (contact_and_book->view->model->book, "bulk-remove"); - g_object_get(card_and_book->view->model, + g_object_get(contact_and_book->view->model, "book", &book, NULL); @@ -767,26 +761,28 @@ delete (GtkWidget *widget, CardAndBook *card_and_book) GList *ids = NULL; for (iterator = list; iterator; iterator = iterator->next) { - ECard *card = iterator->data; - ids = g_list_prepend (ids, (char*)e_card_get_id (card)); + EContact *contact = iterator->data; + ids = g_list_prepend (ids, (char*)e_contact_get_const (contact, E_CONTACT_UID)); } /* Remove the cards all at once. */ - e_book_remove_cards (book, - ids, - NULL, - NULL); + /* XXX no callback specified... ugh */ + e_book_async_remove_contacts (book, + ids, + NULL, + NULL); g_list_free (ids); } else { for (iterator = list; iterator; iterator = iterator->next) { - ECard *card = iterator->data; + EContact *contact = iterator->data; /* Remove the card. */ - e_book_remove_card (book, - card, - NULL, - NULL); + /* XXX no callback specified... ugh */ + e_book_async_remove_contact (book, + e_contact_get_const (contact, E_CONTACT_UID), + NULL, + NULL); } } e_free_object_list(list); @@ -795,56 +791,55 @@ delete (GtkWidget *widget, CardAndBook *card_and_book) } static void -copy_to_folder (GtkWidget *widget, CardAndBook *card_and_book) +copy_to_folder (GtkWidget *widget, ContactAndBook *contact_and_book) { - e_addressbook_view_copy_to_folder (card_and_book->view); + eab_view_copy_to_folder (contact_and_book->view); } static void -move_to_folder (GtkWidget *widget, CardAndBook *card_and_book) +move_to_folder (GtkWidget *widget, ContactAndBook *contact_and_book) { - e_addressbook_view_move_to_folder (card_and_book->view); + eab_view_move_to_folder (contact_and_book->view); } static void -free_popup_info (GtkWidget *w, CardAndBook *card_and_book) +free_popup_info (GtkWidget *w, ContactAndBook *contact_and_book) { - card_and_book_free (card_and_book); + contact_and_book_free (contact_and_book); } static void -new_card (GtkWidget *widget, CardAndBook *card_and_book) +new_card (GtkWidget *widget, ContactAndBook *contact_and_book) { EBook *book; - ECard *card; + EContact *contact = e_contact_new(); - g_object_get(card_and_book->view->model, + g_object_get(contact_and_book->view->model, "book", &book, NULL); - e_addressbook_show_contact_editor (book, card = e_card_new(""), TRUE, TRUE); - g_object_unref(book); - g_object_unref(card); + eab_show_contact_editor (book, contact, TRUE, TRUE); + g_object_unref (book); + g_object_unref (contact); } static void -new_list (GtkWidget *widget, CardAndBook *card_and_book) +new_list (GtkWidget *widget, ContactAndBook *contact_and_book) { EBook *book; - ECard *card; + EContact *contact = e_contact_new (); - g_object_get(card_and_book->view->model, + g_object_get(contact_and_book->view->model, "book", &book, NULL); - - e_addressbook_show_contact_list_editor (book, card = e_card_new(""), TRUE, TRUE); + eab_show_contact_list_editor (book, contact, TRUE, TRUE); g_object_unref(book); - g_object_unref(card); + g_object_unref(contact); } #if 0 static void -sources (GtkWidget *widget, CardAndBook *card_and_book) +sources (GtkWidget *widget, ContactAndBook *contact_and_book) { BonoboControl *control; GNOME_Evolution_ShellView shell_view; @@ -874,9 +869,9 @@ sources (GtkWidget *widget, CardAndBook *card_and_book) #define POPUP_NOEMAIL_MASK 0x4 static void -do_popup_menu(EAddressbookView *view, GdkEvent *event) +do_popup_menu(EABView *view, GdkEvent *event) { - CardAndBook *card_and_book; + ContactAndBook *contact_and_book; GtkMenu *popup; EPopupMenu *submenu = NULL; ESelectionModel *selection_model; @@ -921,308 +916,62 @@ do_popup_menu(EAddressbookView *view, GdkEvent *event) E_POPUP_TERMINATOR }; - card_and_book = g_new(CardAndBook, 1); - card_and_book->view = view; - card_and_book->submenu = submenu; + contact_and_book = g_new(ContactAndBook, 1); + contact_and_book->view = view; + contact_and_book->submenu = submenu; - g_object_ref (card_and_book->view); + g_object_ref (contact_and_book->view); - selection_model = card_and_book_get_selection_model (card_and_book); + selection_model = contact_and_book_get_selection_model (contact_and_book); if (selection_model) selection = e_selection_model_selected_count (selection_model) > 0; popup = e_popup_menu_create (menu, 0, - (e_addressbook_model_editable (view->model) ? 0 : POPUP_READONLY_MASK) + + (eab_model_editable (view->model) ? 0 : POPUP_READONLY_MASK) + (selection ? 0 : POPUP_NOSELECTION_MASK) + - (get_has_email_address (card_and_book) ? 0 : POPUP_NOEMAIL_MASK), - card_and_book); + (get_has_email_address (contact_and_book) ? 0 : POPUP_NOEMAIL_MASK), + contact_and_book); g_signal_connect (popup, "selection-done", - G_CALLBACK (free_popup_info), card_and_book); + G_CALLBACK (free_popup_info), contact_and_book); e_popup_menu (popup, event); } - -/* Minicard view stuff */ - -/* Translators: put here a list of labels you want to see on buttons in - addressbook. You may use any character to separate labels but it must - also be placed at the begining ot the string */ -const char *button_labels = N_(",123,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z"); -/* Translators: put here a list of characters that correspond to buttons - in addressbook. You may use any character to separate labels but it - must also be placed at the begining ot the string. - Use lower case letters if possible. */ -const char *button_letters = N_(",0,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z"); - -typedef struct { - EAddressbookView *view; - GtkWidget *button; - GtkWidget *vbox; - gchar *letters; -} LetterClosure; - -static char ** -e_utf8_split (const char *utf8_str, gunichar delim) -{ - GSList *str_list = NULL, *sl; - int n = 0; - const char *str, *s; - char **str_array; - - g_return_val_if_fail (utf8_str != NULL, NULL); - - str = utf8_str; - while (*str != '\0') { - int len; - char *new_str; - - for (s = str; *s != '\0' && g_utf8_get_char (s) != delim; s = g_utf8_next_char (s)) - ; - len = s - str; - new_str = g_new (char, len + 1); - if (len > 0) { - memcpy (new_str, str, len); - } - new_str[len] = '\0'; - str_list = g_slist_prepend (str_list, new_str); - n++; - if (*s != '\0') { - str = g_utf8_next_char (s); - } else { - str = s; - } - } - - str_array = g_new (char *, n + 1); - str_array[n--] = NULL; - for (sl = str_list; sl != NULL; sl = sl->next) { - str_array[n--] = sl->data; - } - g_slist_free (str_list); - - return str_array; -} - static void -jump_to_letters (EAddressbookView *view, gchar* l) -{ - char *query; - char *s; - char buf[6 + 1]; - - if (g_unichar_isdigit (g_utf8_get_char(l))) { - const char *letters = _(button_letters); - char **letter_v; - GString *gstr; - char **p; - - letter_v = e_utf8_split (g_utf8_next_char (letters), - g_utf8_get_char (letters)); - g_assert (letter_v != NULL && letter_v[0] != NULL); - gstr = g_string_new ("(not (or "); - for (p = letter_v + 1; *p != NULL; p++) { - for (s = *p; *s != '\0'; s = g_utf8_next_char (s)) { - buf [g_unichar_to_utf8 (g_utf8_get_char(s), buf)] = '\0'; - g_string_append_printf (gstr, "(beginswith \"file_as\" \"%s\")", buf); - } - } - g_string_append (gstr, "))"); - query = gstr->str; - g_strfreev (letter_v); - g_string_free (gstr, FALSE); - } else { - GString *gstr; - - gstr = g_string_new ("(or "); - - for (s = l; *s != '\0'; s = g_utf8_next_char (s)) { - buf [g_unichar_to_utf8 (g_utf8_get_char(s), buf)] = '\0'; - g_string_append_printf (gstr, "(beginswith \"file_as\" \"%s\")", buf); - } - - g_string_append (gstr, ")"); - query = gstr->str; - g_string_free (gstr, FALSE); - } - g_object_set (view, - "query", query, - NULL); - g_free (query); -} - -static void -button_toggled(GtkWidget *button, LetterClosure *closure) +render_contact (int row, EABView *view) { - EAddressbookView *view = closure->view; - - if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button))) { - GtkWidget *current = view->current_alphabet_widget; + EContact *contact = eab_model_get_contact (view->model, row); - view->current_alphabet_widget = NULL; - if (current && current != button) - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (current), FALSE); - jump_to_letters (view, closure->letters); - view->current_alphabet_widget = button; - alphabet_state_change (view, g_utf8_get_char(closure->letters)); - } else { - if (view->current_alphabet_widget != NULL && - view->current_alphabet_widget == button) { - view->current_alphabet_widget = NULL; - g_object_set (view, - "query", NULL, - NULL); - alphabet_state_change (view, 0); - } - } + eab_contact_display_render (EAB_CONTACT_DISPLAY (view->contact_display), contact, + EAB_CONTACT_DISPLAY_RENDER_NORMAL); } static void -free_closure(gpointer data, GObject *where_object_was) +selection_changed (GObject *o, EABView *view) { - GtkWidget *button = GTK_WIDGET (where_object_was); - LetterClosure *closure = data; - if (button != NULL && - button == closure->view->current_alphabet_widget) { - closure->view->current_alphabet_widget = NULL; - } - g_free (closure->letters); - g_free (closure); -} - -static GtkWidget * -create_alphabet (EAddressbookView *view) -{ - GtkWidget *widget, *viewport, *vbox; - const char *labels, *letters; - char **label_v, **letter_v; - char **pl, **pc; - gunichar sep; - - widget = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (widget), - GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); - - viewport = gtk_viewport_new (NULL, NULL); - gtk_container_add (GTK_CONTAINER (widget), viewport); - gtk_container_set_border_width (GTK_CONTAINER (viewport), 4); - gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport), GTK_SHADOW_NONE); - - vbox = gtk_vbox_new (FALSE, 4); - gtk_container_add (GTK_CONTAINER (viewport), vbox); - - labels = _(button_labels); - sep = g_utf8_get_char (labels); - label_v = e_utf8_split (g_utf8_next_char (labels), sep); - letters = _(button_letters); - sep = g_utf8_get_char (letters); - letter_v = e_utf8_split (g_utf8_next_char (letters), sep); - g_assert (label_v != NULL && letter_v != NULL); - for (pl = label_v, pc = letter_v; *pl != NULL && *pc != NULL; pl++, pc++) { - GtkWidget *button; - LetterClosure *closure; - char *label; - - label = *pl; - button = gtk_toggle_button_new_with_label (label); - gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); - - closure = g_new (LetterClosure, 1); - closure->view = view; - closure->letters = g_strdup (*pc); - closure->button = button; - closure->vbox = vbox; - g_signal_connect(button, "toggled", - G_CALLBACK (button_toggled), closure); - g_object_weak_ref (G_OBJECT (button), free_closure, closure); - - } - g_strfreev (label_v); - g_strfreev (letter_v); - - gtk_widget_show_all (widget); - - return widget; -} + ESelectionModel *selection_model; -static void -selection_changed (GObject *o, EAddressbookView *view) -{ command_state_change (view); -} - -static void -minicard_right_click (EMinicardView *minicard_view_item, GdkEvent *event, EAddressbookView *view) -{ - do_popup_menu(view, event); -} - -static void -create_minicard_view (EAddressbookView *view) -{ - GtkWidget *scrolled_window; - GtkWidget *alphabet; - GtkWidget *minicard_view; - GtkWidget *minicard_hbox; - EAddressbookReflowAdapter *adapter; - - gtk_widget_push_colormap (gdk_rgb_get_cmap ()); - - minicard_hbox = gtk_hbox_new(FALSE, 0); - - adapter = E_ADDRESSBOOK_REFLOW_ADAPTER(e_addressbook_reflow_adapter_new (view->model)); - minicard_view = e_minicard_view_widget_new(adapter); - - /* A hack */ - g_object_set_data (G_OBJECT (adapter), "view", view); - - g_signal_connect(minicard_view, "selection_change", - G_CALLBACK(selection_changed), view); - - g_signal_connect(minicard_view, "right_click", - G_CALLBACK(minicard_right_click), view); - - - view->object = G_OBJECT(minicard_view); - view->widget = minicard_hbox; - - scrolled_window = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); - - gtk_container_add (GTK_CONTAINER (scrolled_window), minicard_view); - - gtk_box_pack_start(GTK_BOX(minicard_hbox), scrolled_window, TRUE, TRUE, 0); - - alphabet = create_alphabet(view); - if (alphabet) - gtk_box_pack_start(GTK_BOX(minicard_hbox), alphabet, FALSE, FALSE, 0); - - gtk_table_attach(GTK_TABLE(view), minicard_hbox, - 0, 1, - 0, 1, - GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, - 0, 0); - - gtk_widget_show_all( GTK_WIDGET(minicard_hbox) ); - - gtk_widget_pop_colormap (); - - e_reflow_model_changed (E_REFLOW_MODEL (adapter)); + selection_model = get_selection_model (view); - g_object_unref (adapter); + if (e_selection_model_selected_count (selection_model) == 1) + e_selection_model_foreach (selection_model, + (EForeachFunc)render_contact, view); + else + eab_contact_display_render (EAB_CONTACT_DISPLAY (view->contact_display), NULL, + EAB_CONTACT_DISPLAY_RENDER_NORMAL); + } static void -table_double_click(ETableScrolled *table, gint row, gint col, GdkEvent *event, EAddressbookView *view) +table_double_click(ETableScrolled *table, gint row, gint col, GdkEvent *event, EABView *view) { if (E_IS_ADDRESSBOOK_TABLE_ADAPTER(view->object)) { - EAddressbookModel *model = view->model; - ECard *card = e_addressbook_model_get_card(model, row); + EABModel *model = view->model; + EContact *contact = eab_model_get_contact (model, row); EBook *book; g_object_get(model, @@ -1231,25 +980,25 @@ table_double_click(ETableScrolled *table, gint row, gint col, GdkEvent *event, E g_assert (E_IS_BOOK (book)); - if (e_card_evolution_list (card)) - e_addressbook_show_contact_list_editor (book, card, FALSE, view->editable); + if (e_contact_get (contact, E_CONTACT_IS_LIST)) + eab_show_contact_list_editor (book, contact, FALSE, view->editable); else - e_addressbook_show_contact_editor (book, card, FALSE, view->editable); + eab_show_contact_editor (book, contact, FALSE, view->editable); g_object_unref (book); - g_object_unref (card); + g_object_unref (contact); } } static gint -table_right_click(ETableScrolled *table, gint row, gint col, GdkEvent *event, EAddressbookView *view) +table_right_click(ETableScrolled *table, gint row, gint col, GdkEvent *event, EABView *view) { do_popup_menu(view, event); return TRUE; } static gint -table_white_space_event(ETableScrolled *table, GdkEvent *event, EAddressbookView *view) +table_white_space_event(ETableScrolled *table, GdkEvent *event, EABView *view) { if (event->type == GDK_BUTTON_PRESS && ((GdkEventButton *)event)->button == 3) { do_popup_menu(view, event); @@ -1269,7 +1018,7 @@ table_drag_data_get (ETable *table, guint time, gpointer user_data) { - EAddressbookView *view = user_data; + EABView *view = user_data; if (!E_IS_ADDRESSBOOK_TABLE_ADAPTER(view->object)) return; @@ -1278,7 +1027,7 @@ table_drag_data_get (ETable *table, case DND_TARGET_TYPE_VCARD: { char *value; - value = e_card_get_vcard(view->model->data[row]); + value = e_vcard_to_string (E_VCARD (view->model->data[row]), EVC_FORMAT_VCARD_30); gtk_selection_data_set (selection_data, selection_data->target, @@ -1290,68 +1039,62 @@ table_drag_data_get (ETable *table, } static void -emit_status_message (EAddressbookView *eav, const gchar *status) +emit_status_message (EABView *eav, const gchar *status) { g_signal_emit (eav, - e_addressbook_view_signals [STATUS_MESSAGE], 0, + eab_view_signals [STATUS_MESSAGE], 0, status); } static void -emit_search_result (EAddressbookView *eav, EBookViewStatus status) +emit_search_result (EABView *eav, EBookViewStatus status) { g_signal_emit (eav, - e_addressbook_view_signals [SEARCH_RESULT], 0, + eab_view_signals [SEARCH_RESULT], 0, status); } static void -emit_folder_bar_message (EAddressbookView *eav, const gchar *message) +emit_folder_bar_message (EABView *eav, const gchar *message) { g_signal_emit (eav, - e_addressbook_view_signals [FOLDER_BAR_MESSAGE], 0, + eab_view_signals [FOLDER_BAR_MESSAGE], 0, message); } static void -status_message (GtkObject *object, const gchar *status, EAddressbookView *eav) +status_message (GtkObject *object, const gchar *status, EABView *eav) { emit_status_message (eav, status); } static void -search_result (GtkObject *object, EBookViewStatus status, EAddressbookView *eav) +search_result (GtkObject *object, EBookViewStatus status, EABView *eav) { emit_search_result (eav, status); } static void -folder_bar_message (GtkObject *object, const gchar *status, EAddressbookView *eav) +folder_bar_message (GtkObject *object, const gchar *status, EABView *eav) { emit_folder_bar_message (eav, status); } static void -stop_state_changed (GtkObject *object, EAddressbookView *eav) +stop_state_changed (GtkObject *object, EABView *eav) { command_state_change (eav); } static void -command_state_change (EAddressbookView *eav) +command_state_change (EABView *eav) { /* Reffing during emission is unnecessary. Gtk automatically refs during an emission. */ - g_signal_emit (eav, e_addressbook_view_signals [COMMAND_STATE_CHANGE], 0); + g_signal_emit (eav, eab_view_signals [COMMAND_STATE_CHANGE], 0); } static void -alphabet_state_change (EAddressbookView *eav, gunichar letter) -{ - g_signal_emit (eav, e_addressbook_view_signals [ALPHABET_STATE_CHANGE], 0, letter); -} - -static void -backend_died (GtkObject *object, EAddressbookView *eav) +backend_died (GtkObject *object, EABView *eav) { char *message = g_strdup_printf (_("The addressbook backend for\n%s\nhas crashed. " "You will have to restart Evolution in order " @@ -1362,12 +1105,52 @@ backend_died (GtkObject *object, EAddressbookView *eav) } static void -create_table_view (EAddressbookView *view) +minicard_right_click (EMinicardView *minicard_view_item, GdkEvent *event, EABView *view) +{ + do_popup_menu(view, event); +} + +static void +create_minicard_view (EABView *view) +{ + GtkWidget *scrolled_window; + GtkWidget *minicard_view; + EAddressbookReflowAdapter *adapter; + + adapter = E_ADDRESSBOOK_REFLOW_ADAPTER(e_addressbook_reflow_adapter_new (view->model)); + minicard_view = e_minicard_view_widget_new(adapter); + + g_signal_connect(minicard_view, "selection_change", + G_CALLBACK(selection_changed), view); + + g_signal_connect(minicard_view, "right_click", + G_CALLBACK(minicard_right_click), view); + + scrolled_window = gtk_scrolled_window_new (NULL, NULL); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), + GTK_POLICY_AUTOMATIC, + GTK_POLICY_AUTOMATIC); + + view->object = G_OBJECT(minicard_view); + view->widget = scrolled_window; + + gtk_container_add (GTK_CONTAINER (scrolled_window), minicard_view); + gtk_widget_show (minicard_view); + + gtk_widget_show_all( GTK_WIDGET(scrolled_window) ); + + gtk_paned_add1 (GTK_PANED (view->paned), scrolled_window); + + e_reflow_model_changed (E_REFLOW_MODEL (adapter)); +} + +static void +create_table_view (EABView *view) { ETableModel *adapter; GtkWidget *table; - adapter = e_addressbook_table_adapter_new(view->model); + adapter = eab_table_adapter_new(view->model); /* Here we create the table. We give it the three pieces of the table we've created, the header, the model, and the @@ -1395,11 +1178,7 @@ create_table_view (EAddressbookView *view) G_CALLBACK (table_drag_data_get), view); - gtk_table_attach(GTK_TABLE(view), table, - 0, 1, - 0, 1, - GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, - 0, 0); + gtk_paned_add1 (GTK_PANED (view->paned), table); gtk_widget_show( GTK_WIDGET(table) ); } @@ -1408,11 +1187,11 @@ create_table_view (EAddressbookView *view) static void treeview_row_activated(GtkTreeView *treeview, GtkTreePath *path, GtkTreeViewColumn *column, - EAddressbookView *view) + EABView *view) { - EAddressbookModel *model = view->model; + EABModel *model = view->model; int row = gtk_tree_path_get_indices (path)[0]; - ECard *card = e_addressbook_model_get_card(model, row); + ECard *card = eab_model_get_card(model, row); EBook *book; g_object_get(model, @@ -1422,16 +1201,16 @@ treeview_row_activated(GtkTreeView *treeview, g_assert (E_IS_BOOK (book)); if (e_card_evolution_list (card)) - e_addressbook_show_contact_list_editor (book, card, FALSE, view->editable); + eab_show_contact_list_editor (book, card, FALSE, view->editable); else - e_addressbook_show_contact_editor (book, card, FALSE, view->editable); + eab_show_contact_editor (book, card, FALSE, view->editable); g_object_unref (book); g_object_unref (card); } static void -create_treeview_view (EAddressbookView *view) +create_treeview_view (EABView *view) { GtkTreeModel *adapter; ECardSimple *simple; @@ -1441,7 +1220,7 @@ create_treeview_view (EAddressbookView *view) simple = e_card_simple_new(NULL); - adapter = e_addressbook_treeview_adapter_new(view->model); + adapter = eab_treeview_adapter_new(view->model); scrolled = gtk_scrolled_window_new (NULL, NULL); treeview = gtk_tree_view_new_with_model (adapter); @@ -1490,11 +1269,7 @@ create_treeview_view (EAddressbookView *view) g_signal_connect(e_treeview_get_selection_model (GTK_TREE_VIEW (treeview)), "selection_changed", G_CALLBACK(selection_changed), view); - gtk_table_attach(GTK_TABLE(view), scrolled, - 0, 1, - 0, 1, - GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, - 0, 0); + gtk_paned_add1 (GTK_PANED (view->paned), scrolled); gtk_widget_show( GTK_WIDGET(scrolled) ); @@ -1503,26 +1278,27 @@ create_treeview_view (EAddressbookView *view) #endif static void -change_view_type (EAddressbookView *view, EAddressbookViewType view_type) +change_view_type (EABView *view, EABViewType view_type) { if (view_type == view->view_type) return; if (view->widget) { + gtk_container_remove (GTK_CONTAINER (view->paned), view->widget); gtk_widget_destroy (view->widget); view->widget = NULL; } view->object = NULL; switch (view_type) { - case E_ADDRESSBOOK_VIEW_MINICARD: - create_minicard_view (view); - break; - case E_ADDRESSBOOK_VIEW_TABLE: + case EAB_VIEW_TABLE: create_table_view (view); break; + case EAB_VIEW_MINICARD: + create_minicard_view (view); + break; #ifdef WITH_ADDRESSBOOK_VIEW_TREEVIEW - case E_ADDRESSBOOK_VIEW_TREEVIEW: + case EAB_VIEW_TREEVIEW: create_treeview_view (view); break; #endif @@ -1614,7 +1390,7 @@ e_contact_print_button(GtkDialog *dialog, gint response, gpointer data) } void -e_addressbook_view_setup_menus (EAddressbookView *view, +eab_view_setup_menus (EABView *view, BonoboUIComponent *uic) { @@ -1631,7 +1407,7 @@ e_addressbook_view_setup_menus (EAddressbookView *view, } /** - * e_addressbook_view_discard_menus: + * eab_view_discard_menus: * @view: An addressbook view. * * Makes an addressbook view discard its GAL view menus and its views instance @@ -1639,7 +1415,7 @@ e_addressbook_view_setup_menus (EAddressbookView *view, * deactivated. **/ void -e_addressbook_view_discard_menus (EAddressbookView *view) +eab_view_discard_menus (EABView *view) { g_return_if_fail (view != NULL); g_return_if_fail (E_IS_ADDRESSBOOK_VIEW (view)); @@ -1661,9 +1437,9 @@ e_addressbook_view_discard_menus (EAddressbookView *view) } void -e_addressbook_view_print(EAddressbookView *view) +eab_view_print(EABView *view) { - if (view->view_type == E_ADDRESSBOOK_VIEW_MINICARD) { + if (view->view_type == EAB_VIEW_MINICARD) { char *query; EBook *book; GtkWidget *print; @@ -1673,12 +1449,10 @@ e_addressbook_view_print(EAddressbookView *view) "book", &book, NULL); print = e_contact_print_dialog_new(book, query); - - g_object_unref(book); g_free(query); gtk_widget_show_all(print); } - else if (view->view_type == E_ADDRESSBOOK_VIEW_TABLE) { + else if (view->view_type == EAB_VIEW_TABLE) { GtkWidget *dialog; EPrintable *printable; ETable *etable; @@ -1709,16 +1483,16 @@ e_addressbook_view_print(EAddressbookView *view) gtk_widget_show(dialog); } #ifdef WITH_ADDRESSBOOK_VIEW_TREEVIEW - else if (view->view_type == E_ADDRESSBOOK_VIEW_TREEVIEW) { + else if (view->view_type == EAB_VIEW_TREEVIEW) { /* XXX */ } #endif } void -e_addressbook_view_print_preview(EAddressbookView *view) +eab_view_print_preview(EABView *view) { - if (view->view_type == E_ADDRESSBOOK_VIEW_MINICARD) { + if (view->view_type == EAB_VIEW_MINICARD) { char *query; EBook *book; @@ -1727,10 +1501,9 @@ e_addressbook_view_print_preview(EAddressbookView *view) "book", &book, NULL); e_contact_print_preview(book, query); - g_object_unref(book); g_free(query); } - else if (view->view_type == E_ADDRESSBOOK_VIEW_TABLE) { + else if (view->view_type == EAB_VIEW_TABLE) { EPrintable *printable; ETable *etable; GnomePrintJob *master; @@ -1769,27 +1542,27 @@ e_addressbook_view_print_preview(EAddressbookView *view) g_object_unref (printable); } #ifdef WITH_ADDRESSBOOK_VIEW_TREEVIEW - else if (view->view_type == E_ADDRESSBOOK_VIEW_TREEVIEW) { + else if (view->view_type == EAB_VIEW_TREEVIEW) { /* XXX */ } #endif } void -e_addressbook_view_delete_selection(EAddressbookView *view) +eab_view_delete_selection(EABView *view) { - CardAndBook card_and_book; + ContactAndBook contact_and_book; - memset (&card_and_book, 0, sizeof (card_and_book)); - card_and_book.view = view; + memset (&contact_and_book, 0, sizeof (contact_and_book)); + contact_and_book.view = view; - delete (GTK_WIDGET (view), &card_and_book); + delete (GTK_WIDGET (view), &contact_and_book); } static void invisible_destroyed (gpointer data, GObject *where_object_was) { - EAddressbookView *view = data; + EABView *view = data; view->invisible = NULL; } @@ -1798,11 +1571,11 @@ selection_get (GtkWidget *invisible, GtkSelectionData *selection_data, guint info, guint time_stamp, - EAddressbookView *view) + EABView *view) { char *value; - value = e_card_list_get_vcard(view->clipboard_cards); + value = eab_contact_list_to_string (view->clipboard_contacts); gtk_selection_data_set (selection_data, GDK_SELECTION_TYPE_STRING, 8, value, strlen (value)); @@ -1812,12 +1585,12 @@ selection_get (GtkWidget *invisible, static void selection_clear_event (GtkWidget *invisible, GdkEventSelection *event, - EAddressbookView *view) + EABView *view) { - if (view->clipboard_cards) { - g_list_foreach (view->clipboard_cards, (GFunc)g_object_unref, NULL); - g_list_free (view->clipboard_cards); - view->clipboard_cards = NULL; + if (view->clipboard_contacts) { + g_list_foreach (view->clipboard_contacts, (GFunc)g_object_unref, NULL); + g_list_free (view->clipboard_contacts); + view->clipboard_contacts = NULL; } } @@ -1825,27 +1598,25 @@ static void selection_received (GtkWidget *invisible, GtkSelectionData *selection_data, guint time, - EAddressbookView *view) + EABView *view) { if (selection_data->length < 0 || selection_data->type != GDK_SELECTION_TYPE_STRING) { return; } else { /* XXX make sure selection_data->data = \0 terminated */ - GList *card_list = e_card_load_cards_from_string_with_default_charset (selection_data->data, "ISO-8859-1"); + GList *contact_list = eab_contact_list_from_string (selection_data->data); GList *l; - if (!card_list /* it wasn't a vcard list */) - return; - - for (l = card_list; l; l = l->next) { - ECard *card = l->data; + for (l = contact_list; l; l = l->next) { + EContact *contact = l->data; - e_card_merging_book_add_card (view->book, card, NULL /* XXX */, NULL); + /* XXX NULL for a callback /sigh */ + eab_merging_book_add_contact (view->book, contact, NULL /* XXX */, NULL); } - g_list_foreach (card_list, (GFunc)g_object_unref, NULL); - g_list_free (card_list); + g_list_foreach (contact_list, (GFunc)g_object_unref, NULL); + g_list_free (contact_list); } } @@ -1857,7 +1628,7 @@ add_to_list (int model_row, gpointer closure) } static GList * -get_selected_cards (EAddressbookView *view) +get_selected_contacts (EABView *view) { GList *list; GList *iterator; @@ -1867,66 +1638,64 @@ get_selected_cards (EAddressbookView *view) e_selection_model_foreach (selection, add_to_list, &list); for (iterator = list; iterator; iterator = iterator->next) { - iterator->data = e_addressbook_model_card_at (view->model, GPOINTER_TO_INT (iterator->data)); - if (iterator->data) - g_object_ref (iterator->data); + iterator->data = eab_model_get_contact (view->model, GPOINTER_TO_INT (iterator->data)); } list = g_list_reverse (list); return list; } void -e_addressbook_view_save_as (EAddressbookView *view) +eab_view_save_as (EABView *view) { - GList *list = get_selected_cards (view); + GList *list = get_selected_contacts (view); if (list) - e_contact_list_save_as (_("Save as VCard"), list, NULL); + eab_contact_list_save (_("Save as VCard"), list, NULL); e_free_object_list(list); } void -e_addressbook_view_view (EAddressbookView *view) +eab_view_view (EABView *view) { - GList *list = get_selected_cards (view); - e_addressbook_show_multiple_cards (view->book, list, view->editable); + GList *list = get_selected_contacts (view); + eab_show_multiple_contacts (view->book, list, view->editable); e_free_object_list(list); } void -e_addressbook_view_send (EAddressbookView *view) +eab_view_send (EABView *view) { - GList *list = get_selected_cards (view); + GList *list = get_selected_contacts (view); if (list) - e_addressbook_send_card_list (list, E_ADDRESSBOOK_DISPOSITION_AS_ATTACHMENT); + eab_send_contact_list (list, EAB_DISPOSITION_AS_ATTACHMENT); e_free_object_list(list); } void -e_addressbook_view_send_to (EAddressbookView *view) +eab_view_send_to (EABView *view) { - GList *list = get_selected_cards (view); + GList *list = get_selected_contacts (view); if (list) - e_addressbook_send_card_list (list, E_ADDRESSBOOK_DISPOSITION_AS_TO); + eab_send_contact_list (list, EAB_DISPOSITION_AS_TO); e_free_object_list(list); } void -e_addressbook_view_cut (EAddressbookView *view) +eab_view_cut (EABView *view) { - e_addressbook_view_copy (view); - e_addressbook_view_delete_selection (view); + eab_view_copy (view); + eab_view_delete_selection (view); } void -e_addressbook_view_copy (EAddressbookView *view) +eab_view_copy (EABView *view) { - view->clipboard_cards = get_selected_cards (view); + view->clipboard_contacts = get_selected_contacts (view); gtk_selection_owner_set (view->invisible, clipboard_atom, GDK_CURRENT_TIME); } void -e_addressbook_view_paste (EAddressbookView *view) +eab_view_paste (EABView *view) { gtk_selection_convert (view->invisible, clipboard_atom, GDK_SELECTION_TYPE_STRING, @@ -1934,7 +1703,7 @@ e_addressbook_view_paste (EAddressbookView *view) } void -e_addressbook_view_select_all (EAddressbookView *view) +eab_view_select_all (EABView *view) { ESelectionModel *model = get_selection_model (view); @@ -1944,7 +1713,7 @@ e_addressbook_view_select_all (EAddressbookView *view) } void -e_addressbook_view_show_all(EAddressbookView *view) +eab_view_show_all(EABView *view) { g_object_set(view, "query", NULL, @@ -1952,44 +1721,44 @@ e_addressbook_view_show_all(EAddressbookView *view) } void -e_addressbook_view_stop(EAddressbookView *view) +eab_view_stop(EABView *view) { if (view) - e_addressbook_model_stop (view->model); + eab_model_stop (view->model); } static void -view_transfer_cards (EAddressbookView *view, gboolean delete_from_source) +view_transfer_contacts (EABView *view, gboolean delete_from_source) { EBook *book; - GList *cards; + GList *contacts; GtkWindow *parent_window; g_object_get(view->model, "book", &book, NULL); - cards = get_selected_cards (view); + contacts = get_selected_contacts (view); parent_window = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (view))); - e_addressbook_transfer_cards (book, cards, delete_from_source, parent_window); + eab_transfer_contacts (book, contacts, delete_from_source, parent_window); g_object_unref(book); } void -e_addressbook_view_copy_to_folder (EAddressbookView *view) +eab_view_copy_to_folder (EABView *view) { - view_transfer_cards (view, FALSE); + view_transfer_contacts (view, FALSE); } void -e_addressbook_view_move_to_folder (EAddressbookView *view) +eab_view_move_to_folder (EABView *view) { - view_transfer_cards (view, TRUE); + view_transfer_contacts (view, TRUE); } static gboolean -e_addressbook_view_selection_nonempty (EAddressbookView *view) +eab_view_selection_nonempty (EABView *view) { ESelectionModel *selection_model; @@ -2001,85 +1770,85 @@ e_addressbook_view_selection_nonempty (EAddressbookView *view) } gboolean -e_addressbook_view_can_create (EAddressbookView *view) +eab_view_can_create (EABView *view) { - return view ? e_addressbook_model_editable (view->model) : FALSE; + return view ? eab_model_editable (view->model) : FALSE; } gboolean -e_addressbook_view_can_print (EAddressbookView *view) +eab_view_can_print (EABView *view) { - return view && view->model ? e_addressbook_model_card_count (view->model) : FALSE; + return view && view->model ? eab_model_contact_count (view->model) : FALSE; } gboolean -e_addressbook_view_can_save_as (EAddressbookView *view) +eab_view_can_save_as (EABView *view) { - return view ? e_addressbook_view_selection_nonempty (view) : FALSE; + return view ? eab_view_selection_nonempty (view) : FALSE; } gboolean -e_addressbook_view_can_view (EAddressbookView *view) +eab_view_can_view (EABView *view) { - return view ? e_addressbook_view_selection_nonempty (view) : FALSE; + return view ? eab_view_selection_nonempty (view) : FALSE; } gboolean -e_addressbook_view_can_send (EAddressbookView *view) +eab_view_can_send (EABView *view) { - return view ? e_addressbook_view_selection_nonempty (view) : FALSE; + return view ? eab_view_selection_nonempty (view) : FALSE; } gboolean -e_addressbook_view_can_send_to (EAddressbookView *view) +eab_view_can_send_to (EABView *view) { - return view ? e_addressbook_view_selection_nonempty (view) : FALSE; + return view ? eab_view_selection_nonempty (view) : FALSE; } gboolean -e_addressbook_view_can_delete (EAddressbookView *view) +eab_view_can_delete (EABView *view) { - return view ? e_addressbook_view_selection_nonempty (view) && e_addressbook_model_editable (view->model) : FALSE; + return view ? eab_view_selection_nonempty (view) && eab_model_editable (view->model) : FALSE; } gboolean -e_addressbook_view_can_cut (EAddressbookView *view) +eab_view_can_cut (EABView *view) { - return view ? e_addressbook_view_selection_nonempty (view) && e_addressbook_model_editable (view->model) : FALSE; + return view ? eab_view_selection_nonempty (view) && eab_model_editable (view->model) : FALSE; } gboolean -e_addressbook_view_can_copy (EAddressbookView *view) +eab_view_can_copy (EABView *view) { - return view ? e_addressbook_view_selection_nonempty (view) : FALSE; + return view ? eab_view_selection_nonempty (view) : FALSE; } gboolean -e_addressbook_view_can_paste (EAddressbookView *view) +eab_view_can_paste (EABView *view) { - return view ? e_addressbook_model_editable (view->model) : FALSE; + return view ? eab_model_editable (view->model) : FALSE; } gboolean -e_addressbook_view_can_select_all (EAddressbookView *view) +eab_view_can_select_all (EABView *view) { - return view ? e_addressbook_model_card_count (view->model) != 0 : FALSE; + return view ? eab_model_contact_count (view->model) != 0 : FALSE; } gboolean -e_addressbook_view_can_stop (EAddressbookView *view) +eab_view_can_stop (EABView *view) { - return view ? e_addressbook_model_can_stop (view->model) : FALSE; + return view ? eab_model_can_stop (view->model) : FALSE; } gboolean -e_addressbook_view_can_copy_to_folder (EAddressbookView *view) +eab_view_can_copy_to_folder (EABView *view) { - return view ? e_addressbook_view_selection_nonempty (view) : FALSE; + return view ? eab_view_selection_nonempty (view) : FALSE; } gboolean -e_addressbook_view_can_move_to_folder (EAddressbookView *view) +eab_view_can_move_to_folder (EABView *view) { - return view ? e_addressbook_view_selection_nonempty (view) && e_addressbook_model_editable (view->model) : FALSE; + return view ? eab_view_selection_nonempty (view) && eab_model_editable (view->model) : FALSE; } |