From 653cfffc0e00dfb59b36813c1b45c53d3f773c65 Mon Sep 17 00:00:00 2001 From: Ettore Perazzoli Date: Tue, 21 Oct 2003 18:49:34 +0000 Subject: Merge new-ui-branch to the trunk. svn path=/trunk/; revision=22965 --- .../GNOME_Evolution_Addressbook.server.in.in | 27 +- addressbook/gui/component/Makefile.am | 21 +- addressbook/gui/component/addressbook-component.c | 653 ++-------- addressbook/gui/component/addressbook-component.h | 45 +- addressbook/gui/component/addressbook-config.c | 16 +- addressbook/gui/component/addressbook.c | 216 ++-- addressbook/gui/component/addressbook.h | 4 +- addressbook/gui/component/component-factory.c | 29 +- addressbook/gui/component/e-address-popup.c | 1261 -------------------- addressbook/gui/component/e-address-popup.h | 88 -- addressbook/gui/component/e-address-widget.c | 568 --------- addressbook/gui/component/e-address-widget.h | 82 -- addressbook/gui/component/e-cardlist-model.c | 239 ---- addressbook/gui/component/e-cardlist-model.h | 42 - .../Evolution-Addressbook-SelectNames.idl | 72 -- ..._Evolution_Addressbook_SelectNames.server.in.in | 4 +- addressbook/gui/component/select-names/Makefile.am | 4 +- .../component/select-names/e-select-names-bonobo.c | 41 +- .../select-names/e-select-names-completion.c | 238 ++-- .../select-names/e-select-names-completion.h | 2 +- .../select-names/e-select-names-manager.c | 27 +- .../component/select-names/e-select-names-model.c | 181 +-- .../component/select-names/e-select-names-model.h | 27 +- .../component/select-names/e-select-names-popup.c | 96 +- .../select-names/e-select-names-table-model.c | 18 +- .../select-names/e-select-names-text-model.c | 65 +- .../gui/component/select-names/e-select-names.c | 83 +- .../gui/component/select-names/e-select-names.h | 2 +- .../component/select-names/e-simple-card-bonobo.c | 216 ---- .../component/select-names/e-simple-card-bonobo.h | 71 -- 30 files changed, 606 insertions(+), 3832 deletions(-) delete mode 100644 addressbook/gui/component/e-address-popup.c delete mode 100644 addressbook/gui/component/e-address-popup.h delete mode 100644 addressbook/gui/component/e-address-widget.c delete mode 100644 addressbook/gui/component/e-address-widget.h delete mode 100644 addressbook/gui/component/e-cardlist-model.c delete mode 100644 addressbook/gui/component/e-cardlist-model.h delete mode 100644 addressbook/gui/component/select-names/e-simple-card-bonobo.c delete mode 100644 addressbook/gui/component/select-names/e-simple-card-bonobo.h (limited to 'addressbook/gui/component') diff --git a/addressbook/gui/component/GNOME_Evolution_Addressbook.server.in.in b/addressbook/gui/component/GNOME_Evolution_Addressbook.server.in.in index 6d46c5fbbe..6b3b252377 100644 --- a/addressbook/gui/component/GNOME_Evolution_Addressbook.server.in.in +++ b/addressbook/gui/component/GNOME_Evolution_Addressbook.server.in.in @@ -1,6 +1,6 @@ - @@ -13,9 +13,9 @@ - + location="OAFIID:GNOME_Evolution_Addressbook_Factory_2"> @@ -32,9 +32,9 @@ - + location="OAFIID:GNOME_Evolution_Addressbook_Factory_2"> @@ -46,27 +46,22 @@ - + location="OAFIID:GNOME_Evolution_Addressbook_Factory_2"> - + - - - + location="OAFIID:GNOME_Evolution_Addressbook_Factory_2"> @@ -80,7 +75,7 @@ + location="OAFIID:GNOME_Evolution_Addressbook_Factory_2"> @@ -94,7 +89,7 @@ + location="OAFIID:GNOME_Evolution_Addressbook_Factory_2"> diff --git a/addressbook/gui/component/Makefile.am b/addressbook/gui/component/Makefile.am index e13f8d853b..4234997e1d 100644 --- a/addressbook/gui/component/Makefile.am +++ b/addressbook/gui/component/Makefile.am @@ -9,7 +9,6 @@ INCLUDES = \ -I$(top_srcdir)/widgets/misc \ -I$(top_srcdir)/addressbook/gui/contact-editor \ -I$(top_srcdir)/addressbook/gui/contact-list-editor \ - -I$(top_srcdir)/addressbook/gui/minicard \ -I$(top_srcdir)/addressbook/gui/widgets \ -I$(top_srcdir)/addressbook/backend \ -I$(top_builddir)/addressbook/backend \ @@ -38,26 +37,22 @@ libevolution_addressbook_la_SOURCES = \ addressbook-storage.h \ addressbook.c \ addressbook.h \ - component-factory.c \ - e-cardlist-model.c \ - e-cardlist-model.h \ - e-address-widget.h \ - e-address-widget.c \ - e-address-popup.h \ - e-address-popup.c + component-factory.c + +# $(top_builddir)/addressbook/printing/libecontactprint.la libevolution_addressbook_la_LIBADD = \ - select-names/libeselectnames.la \ + $(top_builddir)/addressbook/gui/component/select-names/libeselectnames.la \ $(top_builddir)/shell/libeshell.la \ - $(top_builddir)/addressbook/gui/widgets/libeminicard.la \ - $(top_builddir)/addressbook/printing/libecontactprint.la \ + $(top_builddir)/addressbook/gui/merging/libeabbookmerging.la \ + $(top_builddir)/addressbook/gui/widgets/libeabwidgets.la \ $(top_builddir)/addressbook/gui/search/libeaddressbooksearch.la \ $(top_builddir)/filter/libfilter.la \ + $(top_builddir)/addressbook/util/libeabutil.la \ $(top_builddir)/addressbook/backend/ebook/libebook.la \ - $(top_builddir)/addressbook/gui/contact-list-editor/libecontactlisteditor.la \ $(top_builddir)/addressbook/gui/contact-editor/libecontacteditor.la \ + $(top_builddir)/addressbook/gui/contact-list-editor/libecontactlisteditor.la \ $(top_builddir)/widgets/misc/libemiscwidgets.la \ - $(top_builddir)/addressbook/gui/merging/libecardmerging.la \ $(top_builddir)/widgets/menus/libmenus.la \ $(EVOLUTION_ADDRESSBOOK_LIBS) $(LDAP_LIBS) diff --git a/addressbook/gui/component/addressbook-component.c b/addressbook/gui/component/addressbook-component.c index cdfeeb9755..c323a1bd78 100644 --- a/addressbook/gui/component/addressbook-component.c +++ b/addressbook/gui/component/addressbook-component.c @@ -1,7 +1,7 @@ /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ /* addressbook-component.c * - * Copyright (C) 2000 Ximian, Inc. + * Copyright (C) 2003 Ettore Perazzoli * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public @@ -17,633 +17,170 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * - * Author: Ettore Perazzoli + * Author: Ettore Perazzoli */ -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include - -#include "evolution-shell-component.h" -#include "evolution-shell-component-dnd.h" -#include "evolution-storage.h" -#include "e-folder-list.h" - -#include "ebook/e-book.h" -#include "ebook/e-card.h" -#include "ebook/e-book-util.h" - -#include "addressbook-config.h" -#include "addressbook-storage.h" -#include "addressbook-component.h" -#include "addressbook.h" -#include "addressbook/gui/merging/e-card-merging.h" -#include "addressbook/gui/widgets/e-addressbook-util.h" - - - -#define GNOME_EVOLUTION_ADDRESSBOOK_COMPONENT_ID "OAFIID:GNOME_Evolution_Addressbook_ShellComponent" - -EvolutionShellClient *global_shell_client = NULL; +/* EPFIXME: Add autocompletion setting. */ -EvolutionShellClient * -addressbook_component_get_shell_client (void) -{ - return global_shell_client; -} -static char *accepted_dnd_types[] = { - "text/x-vcard", - NULL -}; +#include -static const EvolutionShellComponentFolderType folder_types[] = { - { "contacts", "evolution-contacts.png", N_("Contacts"), N_("Folder containing contact information"), - TRUE, accepted_dnd_types, NULL }, - { "contacts/ldap", "ldap.png", N_("LDAP Server"), N_("LDAP server containing contact information"), - FALSE, accepted_dnd_types, NULL }, - { "contacts/public", "evolution-contacts.png", N_("Public Contacts"), N_("Public folder containing contact information"), - FALSE, accepted_dnd_types, NULL }, - { NULL } -}; +#include "addressbook-component.h" -#define IS_CONTACT_TYPE(x) (g_ascii_strcasecmp((x), "contacts") == 0 || g_ascii_strcasecmp ((x), "contacts/ldap") == 0 || g_ascii_strcasecmp((x), "contacts/public") == 0) - -/* EvolutionShellComponent methods and signals. */ - -static EvolutionShellComponentResult -create_view (EvolutionShellComponent *shell_component, - const char *physical_uri, - const char *type, - const char *view_info, - BonoboControl **control_return, - void *closure) -{ - BonoboControl *control; +#include "addressbook.h" - if (!IS_CONTACT_TYPE (type)) - return EVOLUTION_SHELL_COMPONENT_UNSUPPORTEDTYPE; +#include "widgets/misc/e-source-selector.h" - control = addressbook_new_control (); - bonobo_control_set_property (control, NULL, "folder_uri", TC_CORBA_string, physical_uri, NULL); +#include +#include - *control_return = control; - return EVOLUTION_SHELL_COMPONENT_OK; -} +#define PARENT_TYPE bonobo_object_get_type () +static BonoboObjectClass *parent_class = NULL; -static void -create_folder (EvolutionShellComponent *shell_component, - const char *physical_uri, - const char *type, - const GNOME_Evolution_ShellComponentListener listener, - void *closure) -{ - CORBA_Environment ev; - GNOME_Evolution_ShellComponentListener_Result result; +struct _AddressbookComponentPrivate { + GConfClient *gconf_client; + ESourceList *source_list; +}; - if (!IS_CONTACT_TYPE (type)) - result = GNOME_Evolution_ShellComponentListener_UNSUPPORTED_TYPE; - else - result = GNOME_Evolution_ShellComponentListener_OK; - CORBA_exception_init(&ev); - GNOME_Evolution_ShellComponentListener_notifyResult(listener, result, &ev); - CORBA_exception_free(&ev); -} +/* Utility functions. */ static void -remove_folder (EvolutionShellComponent *shell_component, - const char *physical_uri, - const char *type, - const GNOME_Evolution_ShellComponentListener listener, - void *closure) +load_uri_for_selection (ESourceSelector *selector, + BonoboControl *view_control) { - CORBA_Environment ev; - char *db_path, *summary_path, *subdir_path; - struct stat sb; - int rv; - - CORBA_exception_init(&ev); - - if (!IS_CONTACT_TYPE (type)) { - GNOME_Evolution_ShellComponentListener_notifyResult (listener, - GNOME_Evolution_ShellComponentListener_UNSUPPORTED_TYPE, - &ev); - CORBA_exception_free(&ev); - return; - } - - if (!strncmp (physical_uri, "ldap://", 7)) { - GNOME_Evolution_ShellComponentListener_notifyResult (listener, - GNOME_Evolution_ShellComponentListener_UNSUPPORTED_OPERATION, - &ev); - CORBA_exception_free(&ev); - return; - } - if (strncmp (physical_uri, "file://", 7)) { - GNOME_Evolution_ShellComponentListener_notifyResult (listener, - GNOME_Evolution_ShellComponentListener_INVALID_URI, - &ev); - CORBA_exception_free(&ev); - return; - } - - subdir_path = g_build_filename (physical_uri + 7, "subfolders", NULL); - rv = stat (subdir_path, &sb); - g_free (subdir_path); - if (rv != -1) { - GNOME_Evolution_ShellComponentListener_notifyResult (listener, - GNOME_Evolution_ShellComponentListener_HAS_SUBFOLDERS, - &ev); - CORBA_exception_free(&ev); - return; - } - - db_path = g_build_filename (physical_uri + 7, "addressbook.db", NULL); - summary_path = g_build_filename (physical_uri + 7, "addressbook.db.summary", NULL); - rv = unlink (db_path); - - if (rv == 0 || (rv == -1 && errno == ENOENT)) - rv = unlink (summary_path); + ESource *selected_source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (selector)); - if (rv == 0 || (rv == -1 && errno == ENOENT)) { - GNOME_Evolution_ShellComponentListener_notifyResult (listener, - GNOME_Evolution_ShellComponentListener_OK, - &ev); - } - else { - GNOME_Evolution_ShellComponentListener_notifyResult (listener, - GNOME_Evolution_ShellComponentListener_PERMISSION_DENIED, - &ev); + if (selected_source != NULL) { + char *uri = e_source_get_uri (selected_source); + bonobo_control_set_property (view_control, NULL, "folder_uri", TC_CORBA_string, uri, NULL); + g_free (uri); } - - g_free (db_path); - g_free (summary_path); - - CORBA_exception_free(&ev); } -/* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** */ -/* This code is cut & pasted from calendar/gui/component-factory.c */ +/* Callbacks. */ -static GNOME_Evolution_ShellComponentListener_Result -xfer_file (GnomeVFSURI *base_src_uri, - GnomeVFSURI *base_dest_uri, - const char *file_name, - int remove_source) +static void +primary_source_selection_changed_callback (ESourceSelector *selector, + BonoboControl *view_control) { - GnomeVFSURI *src_uri, *dest_uri; - GnomeVFSHandle *hin, *hout; - GnomeVFSResult result; - GnomeVFSFileInfo file_info; - GnomeVFSFileSize size; - char *buffer; - - src_uri = gnome_vfs_uri_append_file_name (base_src_uri, file_name); - - result = gnome_vfs_open_uri (&hin, src_uri, GNOME_VFS_OPEN_READ); - if (result == GNOME_VFS_ERROR_NOT_FOUND) { - gnome_vfs_uri_unref (src_uri); - return GNOME_Evolution_ShellComponentListener_OK; /* No need to xfer anything. */ - } - if (result != GNOME_VFS_OK) { - gnome_vfs_uri_unref (src_uri); - return GNOME_Evolution_ShellComponentListener_PERMISSION_DENIED; - } + load_uri_for_selection (selector, view_control); +} - result = gnome_vfs_get_file_info_uri (src_uri, &file_info, GNOME_VFS_FILE_INFO_DEFAULT); - if (result != GNOME_VFS_OK) { - gnome_vfs_uri_unref (src_uri); - return GNOME_Evolution_ShellComponentListener_PERMISSION_DENIED; - } - dest_uri = gnome_vfs_uri_append_file_name (base_dest_uri, file_name); +/* Evolution::Component CORBA methods. */ - result = gnome_vfs_create_uri (&hout, dest_uri, GNOME_VFS_OPEN_WRITE, FALSE, 0600); - if (result != GNOME_VFS_OK) { - gnome_vfs_close (hin); - gnome_vfs_uri_unref (src_uri); - gnome_vfs_uri_unref (dest_uri); - return GNOME_Evolution_ShellComponentListener_PERMISSION_DENIED; - } +static void +impl_createControls (PortableServer_Servant servant, + Bonobo_Control *corba_sidebar_control, + Bonobo_Control *corba_view_control, + CORBA_Environment *ev) +{ + AddressbookComponent *addressbook_component = ADDRESSBOOK_COMPONENT (bonobo_object_from_servant (servant)); + GtkWidget *selector; + GtkWidget *selector_scrolled_window; + BonoboControl *sidebar_control; + BonoboControl *view_control; - /* write source file to destination file */ - buffer = g_malloc (file_info.size); - result = gnome_vfs_read (hin, buffer, file_info.size, &size); - if (result != GNOME_VFS_OK) { - gnome_vfs_close (hin); - gnome_vfs_close (hout); - gnome_vfs_uri_unref (src_uri); - gnome_vfs_uri_unref (dest_uri); - g_free (buffer); - return GNOME_Evolution_ShellComponentListener_PERMISSION_DENIED; - } + selector = e_source_selector_new (addressbook_component->priv->source_list); + e_source_selector_show_selection (E_SOURCE_SELECTOR (selector), FALSE); + gtk_widget_show (selector); - result = gnome_vfs_write (hout, buffer, file_info.size, &size); - if (result != GNOME_VFS_OK) { - gnome_vfs_close (hin); - gnome_vfs_close (hout); - gnome_vfs_uri_unref (src_uri); - gnome_vfs_uri_unref (dest_uri); - g_free (buffer); - return GNOME_Evolution_ShellComponentListener_PERMISSION_DENIED; - } + selector_scrolled_window = gtk_scrolled_window_new (NULL, NULL); + gtk_container_add (GTK_CONTAINER (selector_scrolled_window), selector); + gtk_widget_show (selector_scrolled_window); - if (remove_source) { - char *text_uri; + sidebar_control = bonobo_control_new (selector_scrolled_window); - /* Sigh, we have to do this as there is no gnome_vfs_unlink_uri(). :-( */ + view_control = addressbook_new_control (); + g_signal_connect_object (selector, "primary_selection_changed", + G_CALLBACK (primary_source_selection_changed_callback), + G_OBJECT (view_control), 0); + load_uri_for_selection (E_SOURCE_SELECTOR (selector), view_control); - text_uri = gnome_vfs_uri_to_string (src_uri, GNOME_VFS_URI_HIDE_NONE); - result = gnome_vfs_unlink (text_uri); - g_free (text_uri); - } + *corba_sidebar_control = CORBA_Object_duplicate (BONOBO_OBJREF (sidebar_control), ev); + *corba_view_control = CORBA_Object_duplicate (BONOBO_OBJREF (view_control), ev); +} - gnome_vfs_close (hin); - gnome_vfs_close (hout); - gnome_vfs_uri_unref (src_uri); - gnome_vfs_uri_unref (dest_uri); - g_free (buffer); - return GNOME_Evolution_ShellComponentListener_OK; -} +/* GObject methods. */ static void -xfer_folder (EvolutionShellComponent *shell_component, - const char *source_physical_uri, - const char *destination_physical_uri, - const char *type, - gboolean remove_source, - const GNOME_Evolution_ShellComponentListener listener, - void *closure) +impl_dispose (GObject *object) { - CORBA_Environment ev; - - GnomeVFSURI *src_uri; - GnomeVFSURI *dest_uri; - GnomeVFSResult result; - GNOME_Evolution_ShellComponentListener_Result e_result; - - CORBA_exception_init (&ev); - - if (!IS_CONTACT_TYPE (type)) { - GNOME_Evolution_ShellComponentListener_notifyResult (listener, - GNOME_Evolution_ShellComponentListener_UNSUPPORTED_TYPE, - &ev); - CORBA_exception_free(&ev); - return; - } - - if (!strncmp (source_physical_uri, "ldap://", 7) - || !strncmp (destination_physical_uri, "ldap://", 7)) { - GNOME_Evolution_ShellComponentListener_notifyResult (listener, - GNOME_Evolution_ShellComponentListener_UNSUPPORTED_OPERATION, - &ev); - CORBA_exception_free(&ev); - return; - } - - if (strncmp (source_physical_uri, "file://", 7) - || strncmp (destination_physical_uri, "file://", 7)) { - GNOME_Evolution_ShellComponentListener_notifyResult (listener, - GNOME_Evolution_ShellComponentListener_INVALID_URI, - &ev); - CORBA_exception_free(&ev); - return; - } + AddressbookComponentPrivate *priv = ADDRESSBOOK_COMPONENT (object)->priv; - /* check URIs */ - src_uri = gnome_vfs_uri_new (source_physical_uri); - dest_uri = gnome_vfs_uri_new (destination_physical_uri); - if (!src_uri || ! dest_uri) { - GNOME_Evolution_ShellComponentListener_notifyResult ( - listener, - GNOME_Evolution_ShellComponentListener_INVALID_URI, - &ev); - gnome_vfs_uri_unref (src_uri); - gnome_vfs_uri_unref (dest_uri); - CORBA_exception_free (&ev); - return; + if (priv->source_list != NULL) { + g_object_unref (priv->source_list); + priv->source_list = NULL; } - e_result = xfer_file (src_uri, dest_uri, "addressbook.db", remove_source); - - if ((e_result == GNOME_Evolution_ShellComponentListener_OK) && remove_source) { - char *summary_uri; - - summary_uri = g_strconcat (source_physical_uri, "/addressbook.db.summary", NULL); - result = gnome_vfs_unlink (summary_uri); - if (result != GNOME_VFS_OK && result != GNOME_VFS_ERROR_NOT_FOUND) - e_result = GNOME_Evolution_ShellComponentListener_PERMISSION_DENIED; - g_free (summary_uri); + if (priv->gconf_client != NULL) { + g_object_unref (priv->gconf_client); + priv->gconf_client = NULL; } - GNOME_Evolution_ShellComponentListener_notifyResult (listener, e_result, &ev); - - gnome_vfs_uri_unref (src_uri); - gnome_vfs_uri_unref (dest_uri); - - CORBA_exception_free (&ev); -} - -static char* -get_dnd_selection (EvolutionShellComponent *shell_component, - const char *physical_uri, - int type, - int *format_return, - const char **selection_return, - int *selection_length_return, - void *closure) -{ - /* g_print ("should get dnd selection for %s\n", physical_uri); */ - return NULL; + (* G_OBJECT_CLASS (parent_class)->dispose) (object); } -static int owner_count = 0; - static void -owner_set_cb (EvolutionShellComponent *shell_component, - EvolutionShellClient *shell_client, - const char *evolution_homedir, - gpointer user_data) +impl_finalize (GObject *object) { - owner_count ++; + AddressbookComponentPrivate *priv = ADDRESSBOOK_COMPONENT (object)->priv; - if (global_shell_client == NULL) - global_shell_client = shell_client; + g_free (priv); - addressbook_storage_setup (shell_component, evolution_homedir); + (* G_OBJECT_CLASS (parent_class)->finalize) (object); } -static void -owner_unset_cb (EvolutionShellComponent *shell_component, - GNOME_Evolution_Shell shell_interface, - gpointer user_data) -{ - owner_count --; - - if (owner_count == 0) - global_shell_client = NULL; - addressbook_storage_cleanup (); -} +/* Initialization. */ -/* FIXME We should perhaps take the time to figure out if the book is editable. */ static void -new_item_cb (EBook *book, gpointer closure) +addressbook_component_class_init (AddressbookComponentClass *class) { - gboolean is_list = GPOINTER_TO_INT (closure); - ECard *card; - - if (book == NULL) - return; - - card = e_card_new (""); - if (is_list) - e_addressbook_show_contact_list_editor (book, card, TRUE, TRUE); - else - e_addressbook_show_contact_editor (book, card, TRUE, TRUE); - g_object_unref (card); -} + POA_GNOME_Evolution_Component__epv *epv = &class->epv; + GObjectClass *object_class = G_OBJECT_CLASS (class); -static void -user_create_new_item_cb (EvolutionShellComponent *shell_component, - const char *id, - const char *parent_folder_physical_uri, - const char *parent_folder_type, - gpointer data) -{ - gboolean is_contact_list; - if (!strcmp (id, "contact")) { - is_contact_list = FALSE; - } else if (!strcmp (id, "contact_list")) { - is_contact_list = TRUE; - } else { - g_warning ("Don't know how to create item of type \"%s\"", id); - return; - } - if (IS_CONTACT_TYPE (parent_folder_type)) { - e_book_use_address_book_by_uri (parent_folder_physical_uri, - new_item_cb, GINT_TO_POINTER (is_contact_list)); - } else { - e_book_use_default_book (new_item_cb, GINT_TO_POINTER (is_contact_list)); - } -} + epv->createControls = impl_createControls; - -/* Destination side DnD */ + object_class->dispose = impl_dispose; + object_class->finalize = impl_finalize; -static CORBA_boolean -destination_folder_handle_motion (EvolutionShellComponentDndDestinationFolder *folder, - const char *physical_uri, - const char *folder_type, - const GNOME_Evolution_ShellComponentDnd_DestinationFolder_Context * destination_context, - GNOME_Evolution_ShellComponentDnd_Action * suggested_action_return, - gpointer user_data) -{ - *suggested_action_return = GNOME_Evolution_ShellComponentDnd_ACTION_MOVE; - return TRUE; + parent_class = g_type_class_peek_parent (class); } static void -dnd_drop_book_open_cb (EBook *book, EBookStatus status, GList *card_list) -{ - GList *l; - - for (l = card_list; l; l = l->next) { - ECard *card = l->data; - - e_card_merging_book_add_card (book, card, NULL /* XXX */, NULL); - } -} - -static CORBA_boolean -destination_folder_handle_drop (EvolutionShellComponentDndDestinationFolder *folder, - const char *physical_uri, - const char *folder_type, - const GNOME_Evolution_ShellComponentDnd_DestinationFolder_Context * destination_context, - const GNOME_Evolution_ShellComponentDnd_Action action, - const GNOME_Evolution_ShellComponentDnd_Data * data, - gpointer user_data) +addressbook_component_init (AddressbookComponent *component) { - EBook *book; - GList *card_list; - char *expanded_uri; - - if (action == GNOME_Evolution_ShellComponentDnd_ACTION_LINK) - return FALSE; /* we can't create links in our addressbook format */ - - /* g_print ("in destination_folder_handle_drop (%s)\n", physical_uri); */ - - card_list = e_card_load_cards_from_string_with_default_charset (data->bytes._buffer, "ISO-8859-1"); - - expanded_uri = e_book_expand_uri (physical_uri); + AddressbookComponentPrivate *priv; - book = e_book_new (); - addressbook_load_uri (book, expanded_uri, - (EBookCallback)dnd_drop_book_open_cb, card_list); + priv = g_new0 (AddressbookComponentPrivate, 1); - g_free (expanded_uri); + /* EPFIXME: Should use a custom one instead? Also we should add + addressbook_component_peek_gconf_client(). */ + priv->gconf_client = gconf_client_get_default (); - return TRUE; -} - - -/* Quitting. */ + priv->source_list = e_source_list_new_for_gconf (priv->gconf_client, + "/apps/evolution/addressbook/sources"); -static gboolean -request_quit (EvolutionShellComponent *shell_component, - void *data) -{ - if (! e_contact_editor_request_close_all () - || ! e_contact_list_editor_request_close_all ()) - return FALSE; - else - return TRUE; + component->priv = priv; } - -/* The factory function. */ - -static void -add_creatable_item (EvolutionShellComponent *shell_component, - const char *id, - const char *description, - const char *menu_description, - const char *tooltip, - char menu_shortcut, - const char *icon_name) -{ - char *icon_path; - GdkPixbuf *icon; - - if (icon_name == NULL) { - icon_path = NULL; - icon = NULL; - } else { - icon_path = g_build_filename (EVOLUTION_IMAGESDIR, icon_name, NULL); - icon = gdk_pixbuf_new_from_file (icon_path, NULL); - } - - evolution_shell_component_add_user_creatable_item (shell_component, - id, - description, - menu_description, - tooltip, - "contacts", - menu_shortcut, - icon); - - if (icon != NULL) - gdk_pixbuf_unref (icon); - g_free (icon_path); -} +/* Public API. */ -static BonoboObject * -create_component (void) +AddressbookComponent * +addressbook_component_peek (void) { - EvolutionShellComponent *shell_component; - EvolutionShellComponentDndDestinationFolder *destination_interface; - - shell_component = evolution_shell_component_new (folder_types, NULL, - create_view, create_folder, - remove_folder, xfer_folder, - NULL, NULL, - get_dnd_selection, - request_quit, - NULL); - - destination_interface = evolution_shell_component_dnd_destination_folder_new (destination_folder_handle_motion, - destination_folder_handle_drop, - shell_component); - - bonobo_object_add_interface (BONOBO_OBJECT (shell_component), - BONOBO_OBJECT (destination_interface)); - - add_creatable_item (shell_component, "contact", - _("New Contact"), _("_Contact"), - _("Create a new contact"), 'c', - "evolution-contacts-mini.png"); - add_creatable_item (shell_component, "contact_list", - _("New Contact List"), _("Contact _List"), - _("Create a new contact list"), 'l', - "contact-list-16.png"); - - g_signal_connect (shell_component, "owner_set", - G_CALLBACK (owner_set_cb), NULL); - g_signal_connect (shell_component, "owner_unset", - G_CALLBACK (owner_unset_cb), NULL); - g_signal_connect (shell_component, "user_create_new_item", - G_CALLBACK (user_create_new_item_cb), NULL); - - return BONOBO_OBJECT (shell_component); -} + static AddressbookComponent *component = NULL; -static void -ensure_completion_uris_exist() -{ - /* Initialize the completion uris if they aren't set yet. The - default set is just the local Contacts folder. */ - EConfigListener *db; - char *val; - - db = e_book_get_config_database (); - - val = e_config_listener_get_string (db, "/apps/evolution/addressbook/completion/uris"); - - if (val && !*val) { - g_free (val); - val = NULL; - } - - if (!val) { - EFolderListItem f[2]; - char *dirname, *uri; - /* in the case where the user is running for the first - time, populate the list with the local contact - folder */ - dirname = g_build_filename (g_get_home_dir (), "evolution/local/Contacts", NULL); - uri = g_strdup_printf ("file://%s", dirname); - - f[0].uri = "evolution:/local/Contacts"; - f[0].physical_uri = uri; - f[0].display_name = _("Contacts"); - - memset (&f[1], 0, sizeof (f[1])); - - val = e_folder_list_create_xml (f); - - g_free (dirname); - g_free (uri); - e_config_listener_set_string (db, "/apps/evolution/addressbook/completion/uris", val); - } + if (component == NULL) + component = g_object_new (addressbook_component_get_type (), NULL); - g_free (val); + return component; } - -/* FIXME this is wrong. */ -BonoboObject * -addressbook_component_init (void) -{ - ensure_completion_uris_exist (); - return create_component (); -} +BONOBO_TYPE_FUNC_FULL (AddressbookComponent, GNOME_Evolution_Component, PARENT_TYPE, addressbook_component) diff --git a/addressbook/gui/component/addressbook-component.h b/addressbook/gui/component/addressbook-component.h index 4c6f0cdd8b..bf72a431d8 100644 --- a/addressbook/gui/component/addressbook-component.h +++ b/addressbook/gui/component/addressbook-component.h @@ -1,7 +1,7 @@ /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ /* addressbook-component.h * - * Copyright (C) 2000 Ximian, Inc. + * Copyright (C) 2003 Ximian, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public @@ -17,16 +17,43 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * - * Author: Ettore Perazzoli + * Author: Ettore Perazzoli */ -#ifndef _ADDRESSBOOK_COMPONENT_H -#define _ADDRESSBOOK_COMPONENT_H +#ifndef _ADDRESSBOOK_COMPONENT_H_ +#define _ADDRESSBOOK_COMPONENT_H_ -#include "evolution-shell-component.h" -#include "evolution-storage.h" +#include -BonoboObject *addressbook_component_init (void); -EvolutionShellClient *addressbook_component_get_shell_client (void); +#include "Evolution.h" -#endif /* _ADDRESSBOOK_COMPONENT_H */ +#define ADDRESSBOOK_TYPE_COMPONENT (addressbook_component_get_type ()) +#define ADDRESSBOOK_COMPONENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ADDRESSBOOK_TYPE_COMPONENT, AddressbookComponent)) +#define ADDRESSBOOK_COMPONENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ADDRESSBOOK_TYPE_COMPONENT, AddressbookComponentClass)) +#define ADDRESSBOOK_IS_COMPONENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ADDRESSBOOK_TYPE_COMPONENT)) +#define ADDRESSBOOK_IS_COMPONENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), ADDRESSBOOK_TYPE_COMPONENT)) + + +typedef struct _AddressbookComponent AddressbookComponent; +typedef struct _AddressbookComponentPrivate AddressbookComponentPrivate; +typedef struct _AddressbookComponentClass AddressbookComponentClass; + +struct _AddressbookComponent { + BonoboObject parent; + + AddressbookComponentPrivate *priv; +}; + +struct _AddressbookComponentClass { + BonoboObjectClass parent_class; + + POA_GNOME_Evolution_Component__epv epv; +}; + + +GType addressbook_component_get_type (void); + +AddressbookComponent *addressbook_component_peek (void); + + +#endif /* _ADDRESSBOOK_COMPONENT_H_ */ diff --git a/addressbook/gui/component/addressbook-config.c b/addressbook/gui/component/addressbook-config.c index e2855ac7f4..c5fc9c127a 100644 --- a/addressbook/gui/component/addressbook-config.c +++ b/addressbook/gui/component/addressbook-config.c @@ -107,7 +107,6 @@ struct _AddressbookDialog { GtkWidget *page; GladeXML *gui; - GNOME_Evolution_Shell shell; GtkWidget *sourcesTable; GtkTreeModel *sourcesModel; @@ -1555,7 +1554,7 @@ sources_table_row_activated (GtkTreeView *tree_view, GtkTreePath *path, static AddressbookDialog * -ldap_dialog_new (GNOME_Evolution_Shell shell) +ldap_dialog_new (void) { AddressbookDialog *dialog; GList *l; @@ -1564,7 +1563,6 @@ ldap_dialog_new (GNOME_Evolution_Shell shell) dialog = g_new0 (AddressbookDialog, 1); dialog->gui = glade_xml_new (EVOLUTION_GLADEDIR "/" GLADE_FILE_NAME, NULL, NULL); - dialog->shell = shell; scrolled = glade_xml_get_widget (dialog->gui, "sourcesTable"); dialog->sourcesTable = g_object_get_data (G_OBJECT (scrolled), "table"); @@ -1657,7 +1655,7 @@ addressbook_dialog_create_sources_table (char *name, char *string1, char *string #endif /* HAVE_LDAP */ static EvolutionConfigControl * -ldap_config_control_new (GNOME_Evolution_Shell shell) +ldap_config_control_new (void) { GtkWidget *control_widget; EvolutionConfigControl *control; @@ -1665,7 +1663,7 @@ ldap_config_control_new (GNOME_Evolution_Shell shell) #ifdef HAVE_LDAP AddressbookDialog *dialog; - dialog = ldap_dialog_new (shell); + dialog = ldap_dialog_new (); control_widget = dialog->page; @@ -1697,13 +1695,7 @@ ldap_config_control_new (GNOME_Evolution_Shell shell) EvolutionConfigControl * addressbook_config_control_new (void) { - GNOME_Evolution_Shell shell; - - shell = evolution_shell_client_corba_objref (addressbook_component_get_shell_client ()); - if (! shell) - return NULL; - - return ldap_config_control_new (shell); + return ldap_config_control_new (); } void diff --git a/addressbook/gui/component/addressbook.c b/addressbook/gui/component/addressbook.c index b21c70a83d..32c5ab1288 100644 --- a/addressbook/gui/component/addressbook.c +++ b/addressbook/gui/component/addressbook.c @@ -24,7 +24,6 @@ #include #include -#include #include #include #include @@ -41,23 +40,20 @@ #include "e-util/e-categories-master-list-wombat.h" #include "e-util/e-sexp.h" #include "e-util/e-passwords.h" -#include "select-names/e-select-names.h" -#include "select-names/e-select-names-manager.h" #include "evolution-shell-component-utils.h" #include "evolution-activity-client.h" #include "e-contact-editor.h" -#include "e-contact-save-as.h" #include "addressbook-config.h" #include "addressbook.h" #include "addressbook-component.h" #include "addressbook/gui/search/e-addressbook-search-dialog.h" #include "addressbook/gui/widgets/e-addressbook-view.h" -#include "addressbook/gui/widgets/e-addressbook-util.h" +#include "addressbook/gui/widgets/eab-gui-util.h" #include "addressbook/printing/e-contact-print.h" +#include "addressbook/util/eab-book-util.h" -#include -#include +#include #include #include @@ -73,7 +69,7 @@ static GdkPixbuf *progress_icon[2] = { NULL, NULL }; typedef struct { gint refs; - EAddressbookView *view; + EABView *view; ESearchBar *search; gint ecml_changed_id; GtkWidget *vbox; @@ -100,7 +96,7 @@ save_contact_cb (BonoboUIComponent *uih, void *user_data, const char *path) { AddressbookView *view = (AddressbookView *) user_data; if (view->view) - e_addressbook_view_save_as(view->view); + eab_view_save_as(view->view); } static void @@ -108,7 +104,7 @@ view_contact_cb (BonoboUIComponent *uih, void *user_data, const char *path) { AddressbookView *view = (AddressbookView *) user_data; if (view->view) - e_addressbook_view_view(view->view); + eab_view_view(view->view); } static void @@ -117,7 +113,7 @@ search_cb (BonoboUIComponent *uih, void *user_data, const char *path) AddressbookView *view = (AddressbookView *) user_data; if (view->view) - gtk_widget_show(e_addressbook_search_dialog_new(view->view)); + gtk_widget_show(eab_search_dialog_new(view->view)); } static void @@ -125,7 +121,7 @@ delete_contact_cb (BonoboUIComponent *uih, void *user_data, const char *path) { AddressbookView *view = (AddressbookView *) user_data; if (view->view) { - e_addressbook_view_delete_selection(view->view); + eab_view_delete_selection(view->view); } } @@ -134,7 +130,7 @@ print_cb (BonoboUIComponent *uih, void *user_data, const char *path) { AddressbookView *view = (AddressbookView *) user_data; if (view->view) - e_addressbook_view_print(view->view); + eab_view_print(view->view); } static void @@ -142,7 +138,7 @@ print_preview_cb (BonoboUIComponent *uih, void *user_data, const char *path) { AddressbookView *view = (AddressbookView *) user_data; if (view->view) - e_addressbook_view_print_preview(view->view); + eab_view_print_preview(view->view); } static void @@ -150,7 +146,7 @@ stop_loading_cb (BonoboUIComponent *uih, void *user_data, const char *path) { AddressbookView *view = (AddressbookView *) user_data; if (view->view) - e_addressbook_view_stop(view->view); + eab_view_stop(view->view); } static void @@ -158,7 +154,7 @@ cut_contacts_cb (BonoboUIComponent *uih, void *user_data, const char *path) { AddressbookView *view = (AddressbookView *) user_data; if (view->view) - e_addressbook_view_cut(view->view); + eab_view_cut(view->view); } static void @@ -166,7 +162,7 @@ copy_contacts_cb (BonoboUIComponent *uih, void *user_data, const char *path) { AddressbookView *view = (AddressbookView *) user_data; if (view->view) - e_addressbook_view_copy(view->view); + eab_view_copy(view->view); } static void @@ -174,7 +170,7 @@ paste_contacts_cb (BonoboUIComponent *uih, void *user_data, const char *path) { AddressbookView *view = (AddressbookView *) user_data; if (view->view) - e_addressbook_view_paste(view->view); + eab_view_paste(view->view); } static void @@ -182,7 +178,7 @@ select_all_contacts_cb (BonoboUIComponent *uih, void *user_data, const char *pat { AddressbookView *view = (AddressbookView *) user_data; if (view->view) - e_addressbook_view_select_all (view->view); + eab_view_select_all (view->view); } static void @@ -190,7 +186,7 @@ send_contact_cb (BonoboUIComponent *uih, void *user_data, const char *path) { AddressbookView *view = (AddressbookView *) user_data; if (view->view) - e_addressbook_view_send (view->view); + eab_view_send (view->view); } static void @@ -198,7 +194,7 @@ send_contact_to_cb (BonoboUIComponent *uih, void *user_data, const char *path) { AddressbookView *view = (AddressbookView *) user_data; if (view->view) - e_addressbook_view_send_to (view->view); + eab_view_send_to (view->view); } static void @@ -206,7 +202,7 @@ copy_contact_to_cb (BonoboUIComponent *uih, void *user_data, const char *path) { AddressbookView *view = (AddressbookView *) user_data; if (view->view) - e_addressbook_view_copy_to_folder (view->view); + eab_view_copy_to_folder (view->view); } static void @@ -214,7 +210,7 @@ move_contact_to_cb (BonoboUIComponent *uih, void *user_data, const char *path) { AddressbookView *view = (AddressbookView *) user_data; if (view->view) - e_addressbook_view_move_to_folder (view->view); + eab_view_move_to_folder (view->view); } static void @@ -224,7 +220,7 @@ forget_passwords_cb (BonoboUIComponent *uih, void *user_data, const char *path) } static void -update_command_state (EAddressbookView *eav, AddressbookView *view) +update_command_state (EABView *eav, AddressbookView *view) { BonoboUIComponent *uic; @@ -239,78 +235,78 @@ update_command_state (EAddressbookView *eav, AddressbookView *view) bonobo_ui_component_set_prop (uic, "/commands/ContactsSaveAsVCard", "sensitive", - e_addressbook_view_can_save_as (view->view) ? "1" : "0", NULL); + eab_view_can_save_as (view->view) ? "1" : "0", NULL); bonobo_ui_component_set_prop (uic, "/commands/ContactsView", "sensitive", - e_addressbook_view_can_view (view->view) ? "1" : "0", NULL); + eab_view_can_view (view->view) ? "1" : "0", NULL); /* Print Contact */ bonobo_ui_component_set_prop (uic, "/commands/ContactsPrint", "sensitive", - e_addressbook_view_can_print (view->view) ? "1" : "0", NULL); + eab_view_can_print (view->view) ? "1" : "0", NULL); /* Print Contact */ bonobo_ui_component_set_prop (uic, "/commands/ContactsPrintPreview", "sensitive", - e_addressbook_view_can_print (view->view) ? "1" : "0", NULL); + eab_view_can_print (view->view) ? "1" : "0", NULL); /* Delete Contact */ bonobo_ui_component_set_prop (uic, "/commands/ContactDelete", "sensitive", - e_addressbook_view_can_delete (view->view) ? "1" : "0", NULL); + eab_view_can_delete (view->view) ? "1" : "0", NULL); bonobo_ui_component_set_prop (uic, "/commands/ContactsCut", "sensitive", - e_addressbook_view_can_cut (view->view) ? "1" : "0", NULL); + eab_view_can_cut (view->view) ? "1" : "0", NULL); bonobo_ui_component_set_prop (uic, "/commands/ContactsCopy", "sensitive", - e_addressbook_view_can_copy (view->view) ? "1" : "0", NULL); + eab_view_can_copy (view->view) ? "1" : "0", NULL); bonobo_ui_component_set_prop (uic, "/commands/ContactsPaste", "sensitive", - e_addressbook_view_can_paste (view->view) ? "1" : "0", NULL); + eab_view_can_paste (view->view) ? "1" : "0", NULL); bonobo_ui_component_set_prop (uic, "/commands/ContactsSelectAll", "sensitive", - e_addressbook_view_can_select_all (view->view) ? "1" : "0", NULL); + eab_view_can_select_all (view->view) ? "1" : "0", NULL); bonobo_ui_component_set_prop (uic, "/commands/ContactsSendContactToOther", "sensitive", - e_addressbook_view_can_send (view->view) ? "1" : "0", NULL); + eab_view_can_send (view->view) ? "1" : "0", NULL); bonobo_ui_component_set_prop (uic, "/commands/ContactsSendMessageToContact", "sensitive", - e_addressbook_view_can_send_to (view->view) ? "1" : "0", NULL); + eab_view_can_send_to (view->view) ? "1" : "0", NULL); bonobo_ui_component_set_prop (uic, "/commands/ContactsMoveToFolder", "sensitive", - e_addressbook_view_can_move_to_folder (view->view) ? "1" : "0", NULL); + eab_view_can_move_to_folder (view->view) ? "1" : "0", NULL); bonobo_ui_component_set_prop (uic, "/commands/ContactsCopyToFolder", "sensitive", - e_addressbook_view_can_copy_to_folder (view->view) ? "1" : "0", NULL); + eab_view_can_copy_to_folder (view->view) ? "1" : "0", NULL); /* Stop */ bonobo_ui_component_set_prop (uic, "/commands/ContactStop", "sensitive", - e_addressbook_view_can_stop (view->view) ? "1" : "0", NULL); + eab_view_can_stop (view->view) ? "1" : "0", NULL); } addressbook_view_unref (view); } static void -change_view_type (AddressbookView *view, EAddressbookViewType view_type) +change_view_type (AddressbookView *view, EABViewType view_type) { g_object_set (view->view, "type", view_type, NULL); } @@ -379,7 +375,7 @@ control_activate (BonoboControl *control, EVOLUTION_UIDIR "/evolution-addressbook.xml", "evolution-addressbook", NULL); - e_addressbook_view_setup_menus (view->view, uic); + eab_view_setup_menus (view->view, uic); e_pixmaps_update (uic, pixmaps); @@ -401,25 +397,21 @@ control_activate_cb (BonoboControl *control, if (activate) { control_activate (control, uic, view); if (activate && view->view && view->view->model) - e_addressbook_model_force_folder_bar_message (view->view->model); + eab_model_force_folder_bar_message (view->view->model); /* if the book failed to load, we kick off another load here */ if (view->failed_to_load && view->uri) { EBook *book; - char *uri_data; book = e_book_new (); - uri_data = e_book_expand_uri (view->uri); - addressbook_load_uri (book, uri_data, book_open_cb, view); - - g_free(uri_data); + addressbook_load_uri (book, view->uri, book_open_cb, view); } } else { bonobo_ui_component_unset_container (uic, NULL); - e_addressbook_view_discard_menus (view->view); + eab_view_discard_menus (view->view); } } @@ -482,7 +474,7 @@ book_open_cb (EBook *book, EBookStatus status, gpointer closure) { AddressbookView *view = closure; - if (status == E_BOOK_STATUS_SUCCESS) { + if (status == E_BOOK_ERROR_OK) { view->failed_to_load = FALSE; g_object_set(view->view, "book", book, @@ -596,8 +588,8 @@ load_uri_auth_cb (EBook *book, EBookStatus status, gpointer closure) { LoadUriData *data = closure; - if (status != E_BOOK_STATUS_SUCCESS) { - if (status == E_BOOK_STATUS_CANCELLED) { + if (status != E_BOOK_ERROR_OK) { + if (status == E_BOOK_ERROR_CANCELLED) { /* the user clicked cancel in the password dialog */ GtkWidget *dialog; dialog = gtk_message_dialog_new (NULL, @@ -607,7 +599,7 @@ load_uri_auth_cb (EBook *book, EBookStatus status, gpointer closure) _("Accessing LDAP Server anonymously")); g_signal_connect (dialog, "response", G_CALLBACK(gtk_widget_destroy), NULL); gtk_widget_show (dialog); - data->cb (book, E_BOOK_STATUS_SUCCESS, data->closure); + data->cb (book, E_BOOK_ERROR_OK, data->closure); g_free (data->clean_uri); g_free (data); return; @@ -682,15 +674,15 @@ addressbook_authenticate (EBook *book, gboolean previous_failure, AddressbookSou user = source->email_addr; if (!user) user = ""; - e_book_authenticate_user (book, user, password ? password : pass_dup, - addressbook_storage_auth_type_to_string (source->auth), - cb, closure); + e_book_async_authenticate_user (book, user, password ? password : pass_dup, + addressbook_storage_auth_type_to_string (source->auth), + cb, closure); g_free (pass_dup); return; } else { /* they hit cancel */ - cb (book, E_BOOK_STATUS_CANCELLED, closure); + cb (book, E_BOOK_ERROR_CANCELLED, closure); } } @@ -699,7 +691,7 @@ load_uri_cb (EBook *book, EBookStatus status, gpointer closure) { LoadUriData *load_uri_data = closure; - if (status == E_BOOK_STATUS_SUCCESS && book != NULL) { + if (status == E_BOOK_ERROR_OK && book != NULL) { /* check if the addressbook needs authentication */ @@ -728,18 +720,18 @@ addressbook_load_uri (EBook *book, const char *uri, load_uri_data->cb = cb; load_uri_data->closure = closure; - e_book_load_uri (book, uri, load_uri_cb, load_uri_data); + e_book_async_load_uri (book, uri, load_uri_cb, load_uri_data); } void -addressbook_load_default_book (EBook *book, EBookCallback cb, gpointer closure) +addressbook_load_default_book (EBookCallback cb, gpointer closure) { LoadUriData *load_uri_data = g_new (LoadUriData, 1); load_uri_data->cb = cb; load_uri_data->closure = closure; - e_book_load_default_book (book, load_uri_cb, load_uri_data); + e_book_async_get_default_addressbook (load_uri_cb, load_uri_data); } static void @@ -751,14 +743,12 @@ set_prop (BonoboPropertyBag *bag, { AddressbookView *view = user_data; - char *uri_data; - switch (arg_id) { case PROPERTY_FOLDER_URI_IDX: if (view->uri) { /* we've already had a uri set on this view, so unload it */ - e_book_unload_uri (view->book); + e_book_async_unload_uri (view->book); g_free (view->uri); } else { view->book = e_book_new (); @@ -768,11 +758,7 @@ set_prop (BonoboPropertyBag *bag, view->uri = g_strdup(BONOBO_ARG_GET_STRING (arg)); - uri_data = e_book_expand_uri (view->uri); - - addressbook_load_uri (view->book, uri_data, book_open_cb, view); - - g_free(uri_data); + addressbook_load_uri (view->book, view->uri, book_open_cb, view); break; @@ -799,19 +785,6 @@ static ESearchBarItem addressbook_search_option_items[] = { { NULL, -1, NULL } }; -static void -alphabet_state_changed (EAddressbookView *eav, gunichar letter, AddressbookView *view) -{ - view->ignore_search_changes = TRUE; - if (letter == 0) { - e_search_bar_set_item_id (view->search, ESB_FULL_NAME); - e_search_bar_set_text (view->search, ""); - } else { - e_search_bar_set_item_id (view->search, ESB_FULL_NAME); - } - view->ignore_search_changes = FALSE; -} - static void addressbook_search_activated (ESearchBar *esb, AddressbookView *view) { @@ -830,7 +803,7 @@ addressbook_search_activated (ESearchBar *esb, AddressbookView *view) NULL); if (search_type == ESB_ADVANCED) { - gtk_widget_show(e_addressbook_search_dialog_new(view->view)); + gtk_widget_show(eab_search_dialog_new(view->view)); } else { if ((search_word && strlen (search_word)) || search_type == ESB_CATEGORY) { @@ -890,7 +863,7 @@ addressbook_query_changed (ESearchBar *esb, AddressbookView *view) NULL); if (search_type == ESB_ADVANCED) { - gtk_widget_show(e_addressbook_search_dialog_new(view->view)); + gtk_widget_show(eab_search_dialog_new(view->view)); } } @@ -916,7 +889,7 @@ retrieve_shell_view_interface_from_control (BonoboControl *control) } static void -set_status_message (EAddressbookView *eav, const char *message, AddressbookView *view) +set_status_message (EABView *eav, const char *message, AddressbookView *view) { if (!message || !*message) { @@ -925,6 +898,7 @@ set_status_message (EAddressbookView *eav, const char *message, AddressbookView view->activity = NULL; } } +#if 0 /* EPFIXME */ else if (!view->activity) { int display; char *clientid = g_strdup_printf ("%p", view); @@ -937,6 +911,7 @@ set_status_message (EAddressbookView *eav, const char *message, AddressbookView g_free (clientid); } +#endif else { evolution_activity_client_update (view->activity, message, -1.0); } @@ -944,12 +919,12 @@ set_status_message (EAddressbookView *eav, const char *message, AddressbookView } static void -search_result (EAddressbookView *eav, EBookViewStatus status, AddressbookView *view) +search_result (EABView *eav, EBookViewStatus status, AddressbookView *view) { char *str = NULL; switch (status) { - case E_BOOK_VIEW_STATUS_SUCCESS: + case E_BOOK_VIEW_STATUS_OK: return; case E_BOOK_VIEW_STATUS_SIZE_LIMIT_EXCEEDED: str = _("More cards matched this query than either the server is \n" @@ -963,14 +938,13 @@ search_result (EAddressbookView *eav, EBookViewStatus status, AddressbookView *v "more specific or raise the time limit in the directory server\n" "preferences for this addressbook."); break; - case E_BOOK_VIEW_STATUS_INVALID_QUERY: + case E_BOOK_VIEW_ERROR_INVALID_QUERY: str = _("The backend for this addressbook was unable to parse this query."); break; - case E_BOOK_VIEW_STATUS_QUERY_REFUSED: + case E_BOOK_VIEW_ERROR_QUERY_REFUSED: str = _("The backend for this addressbook refused to perform this query."); break; - case E_BOOK_VIEW_STATUS_OTHER_ERROR: - case E_BOOK_VIEW_STATUS_UNKNOWN: + case E_BOOK_VIEW_ERROR_OTHER_ERROR: str = _("This query did not complete successfully."); break; } @@ -988,7 +962,7 @@ search_result (EAddressbookView *eav, EBookViewStatus status, AddressbookView *v } static void -set_folder_bar_label (EAddressbookView *eav, const char *message, AddressbookView *view) +set_folder_bar_label (EABView *eav, const char *message, AddressbookView *view) { CORBA_Environment ev; GNOME_Evolution_ShellView shell_view_interface; @@ -1023,18 +997,6 @@ set_folder_bar_label (EAddressbookView *eav, const char *message, AddressbookVie bonobo_object_release_unref (shell_view_interface, NULL); } -/* Our global singleton config database */ -static Bonobo_ConfigDatabase config_db = NULL; - -Bonobo_ConfigDatabase -addressbook_config_database (CORBA_Environment *ev) -{ - if (config_db == NULL) - config_db = bonobo_get_object ("wombat:", "Bonobo/ConfigDatabase", ev); - - return config_db; -} - static int compare_subitems (const void *a, const void *b) { @@ -1098,10 +1060,6 @@ BonoboControl * addressbook_new_control (void) { AddressbookView *view; - GtkWidget *frame; - - frame = gtk_frame_new (NULL); - gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); view = g_new0 (AddressbookView, 1); view->refs = 1; @@ -1125,15 +1083,13 @@ addressbook_new_control (void) g_signal_connect (view->search, "search_activated", G_CALLBACK (addressbook_search_activated), view); - view->view = E_ADDRESSBOOK_VIEW(e_addressbook_view_new()); - gtk_container_add (GTK_CONTAINER (frame), GTK_WIDGET (view->view)); - gtk_box_pack_start (GTK_BOX (view->vbox), frame, + view->view = EAB_VIEW(eab_view_new()); + gtk_box_pack_start (GTK_BOX (view->vbox), GTK_WIDGET (view->view), TRUE, TRUE, 0); /* create the initial view */ - change_view_type (view, E_ADDRESSBOOK_VIEW_MINICARD); + change_view_type (view, EAB_VIEW_TABLE); - gtk_widget_show (frame); gtk_widget_show (view->vbox); gtk_widget_show (GTK_WIDGET(view->view)); gtk_widget_show (GTK_WIDGET(view->search)); @@ -1142,36 +1098,24 @@ addressbook_new_control (void) bonobo_property_bag_add (view->properties, PROPERTY_FOLDER_URI, PROPERTY_FOLDER_URI_IDX, - BONOBO_ARG_STRING, NULL, _("The URI that the Folder Browser will display"), 0); + BONOBO_ARG_STRING, NULL, + _("URI of the contacts that the control will display"), 0); bonobo_control_set_properties (view->control, bonobo_object_corba_objref (BONOBO_OBJECT (view->properties)), NULL); - g_signal_connect (view->view, - "status_message", - G_CALLBACK(set_status_message), - view); - - g_signal_connect (view->view, - "search_result", - G_CALLBACK(search_result), - view); - - g_signal_connect (view->view, - "folder_bar_message", - G_CALLBACK(set_folder_bar_label), - view); - - g_signal_connect (view->view, - "command_state_change", - G_CALLBACK(update_command_state), - view); - - g_signal_connect (view->view, - "alphabet_state_change", - G_CALLBACK(alphabet_state_changed), - view); + g_signal_connect (view->view, "status_message", + G_CALLBACK(set_status_message), view); + + g_signal_connect (view->view, "search_result", + G_CALLBACK(search_result), view); + + g_signal_connect (view->view, "folder_bar_message", + G_CALLBACK(set_folder_bar_label), view); + + g_signal_connect (view->view, "command_state_change", + G_CALLBACK(update_command_state), view); view->uri = NULL; diff --git a/addressbook/gui/component/addressbook.h b/addressbook/gui/component/addressbook.h index 3d4bba5187..573adbf38d 100644 --- a/addressbook/gui/component/addressbook.h +++ b/addressbook/gui/component/addressbook.h @@ -5,12 +5,12 @@ #include #include #include -#include +#include /* use this instead of e_book_load_uri everywhere where you want the authentication to be handled for you. */ void addressbook_load_uri (EBook *book, const char *uri, EBookCallback cb, gpointer closure); -void addressbook_load_default_book (EBook *book, EBookCallback open_response, gpointer closure); +void addressbook_load_default_book (EBookCallback open_response, gpointer closure); BonoboControl *addressbook_new_control (void); diff --git a/addressbook/gui/component/component-factory.c b/addressbook/gui/component/component-factory.c index 9d5e946dc0..512ab72f2a 100644 --- a/addressbook/gui/component/component-factory.c +++ b/addressbook/gui/component/component-factory.c @@ -26,20 +26,18 @@ #include "addressbook.h" #include "addressbook-component.h" #include "addressbook-config.h" -#include "e-address-popup.h" -#include "e-address-widget.h" -#include "e-minicard-control.h" +#include "eab-popup-control.h" +#include "eab-vcard-control.h" #include "select-names/e-select-names-bonobo.h" #include -#define FACTORY_ID "OAFIID:GNOME_Evolution_Addressbook_Factory" +#define FACTORY_ID "OAFIID:GNOME_Evolution_Addressbook_Factory_2" -#define MINICARD_CONTROL_ID "OAFIID:GNOME_Evolution_Addressbook_MiniCard_Control" +#define VCARD_CONTROL_ID "OAFIID:GNOME_Evolution_Addressbook_VCard_Control" #define ADDRESSBOOK_CONTROL_ID "OAFIID:GNOME_Evolution_Addressbook_Control" -#define SHELL_COMPONENT_ID "OAFIID:GNOME_Evolution_Addressbook_ShellComponent" -#define ADDRESS_WIDGET_ID "OAFIID:GNOME_Evolution_Addressbook_AddressWidget" +#define COMPONENT_ID "OAFIID:GNOME_Evolution_Addressbook_Component" #define ADDRESS_POPUP_ID "OAFIID:GNOME_Evolution_Addressbook_AddressPopup" #define SELECT_NAMES_ID "OAFIID:GNOME_Evolution_Addressbook_SelectNames" #define LDAP_STORAGE_CONFIG_CONTROL_ID "OAFIID:GNOME_Evolution_LDAPStorage_ConfigControl" @@ -50,16 +48,19 @@ factory (BonoboGenericFactory *factory, const char *component_id, void *closure) { - if (strcmp (component_id, MINICARD_CONTROL_ID) == 0) - return BONOBO_OBJECT (e_minicard_control_new ()); + printf ("asked to activate component_id `%s'\n", component_id); + + if (strcmp (component_id, VCARD_CONTROL_ID) == 0) + return BONOBO_OBJECT (eab_vcard_control_new ()); if (strcmp (component_id, ADDRESSBOOK_CONTROL_ID) == 0) return BONOBO_OBJECT (addressbook_new_control ()); - if (strcmp (component_id, SHELL_COMPONENT_ID) == 0) - return addressbook_component_init (); - if (strcmp (component_id, ADDRESS_WIDGET_ID) == 0) - return BONOBO_OBJECT (e_address_widget_new_control ()); + if (strcmp (component_id, COMPONENT_ID) == 0) { + BonoboObject *object = BONOBO_OBJECT (addressbook_component_peek ()); + bonobo_object_ref (object); + return object; + } if (strcmp (component_id, ADDRESS_POPUP_ID) == 0) - return BONOBO_OBJECT (e_address_popup_new_control ()); + return BONOBO_OBJECT (eab_popup_control_new ()); if (strcmp (component_id, LDAP_STORAGE_CONFIG_CONTROL_ID) == 0) return BONOBO_OBJECT (addressbook_config_control_new ()); if (strcmp (component_id, SELECT_NAMES_ID) == 0) diff --git a/addressbook/gui/component/e-address-popup.c b/addressbook/gui/component/e-address-popup.c deleted file mode 100644 index 9d87fd0fb3..0000000000 --- a/addressbook/gui/component/e-address-popup.c +++ /dev/null @@ -1,1261 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * e-address-popup.c - * - * Copyright (C) 2001 Ximian, Inc. - * - * Developed by Jon Trowbridge - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - */ - -/* - * This file is too big and this widget is too complicated. Forgive me. - */ - -#include -#include -#include "addressbook.h" -#include "e-address-popup.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "e-util/e-gui-utils.h" - -/* - * Some general scaffolding for our widgets. Think of this as a really, really - * lame implementation of a wizard (...which is still somewhat more general that - * we really need it to be). - */ - -typedef struct _MiniWizard MiniWizard; -struct _MiniWizard { - GtkWidget *body; - - GtkWidget *vbox; - GtkWidget *ok_button; - GtkWidget *cancel_button; - - void (*ok_cb) (MiniWizard *, gpointer); - void (*cleanup_cb) (gpointer); - gpointer closure; - - void (*destroy_cb) (MiniWizard *, gpointer); - gpointer destroy_closure; -}; - -static void -mini_wizard_container_add (MiniWizard *wiz, GtkWidget *w) -{ - GList *iter = gtk_container_get_children (GTK_CONTAINER (wiz->vbox)); - while (iter != NULL) { - GtkWidget *oldw = (GtkWidget *) iter->data; - iter = g_list_next (iter); - gtk_container_remove (GTK_CONTAINER (wiz->vbox), oldw); - } - gtk_container_add (GTK_CONTAINER (wiz->vbox), w); -} - -static void -mini_wizard_destroy (MiniWizard *wiz) -{ - if (wiz->cleanup_cb) - wiz->cleanup_cb (wiz->closure); - wiz->cleanup_cb = NULL; - - if (wiz->destroy_cb) - wiz->destroy_cb (wiz, wiz->destroy_closure); -} - -static void -mini_wizard_ok_cb (GtkWidget *b, gpointer closure) -{ - MiniWizard *wiz = (MiniWizard *) closure; - - gpointer old_closure = wiz->closure; - void (*old_cleanup) (gpointer) = wiz->cleanup_cb; - - wiz->cleanup_cb = NULL; - - if (wiz->ok_cb) - wiz->ok_cb (wiz, wiz->closure); - - if (old_cleanup) - old_cleanup (old_closure); - -} - -static void -mini_wizard_cancel_cb (GtkWidget *b, gpointer closure) -{ - mini_wizard_destroy ((MiniWizard *) closure); -} - -static void -mini_wizard_destroy_cb (gpointer closure, GObject *where_object_was) -{ - MiniWizard *wiz = (MiniWizard *) closure; - if (wiz->cleanup_cb) - wiz->cleanup_cb (wiz->closure); - g_free (wiz); -} - -static MiniWizard * -mini_wizard_new (void) -{ - MiniWizard *wiz = g_new (MiniWizard, 1); - GtkWidget *bbox; - - wiz->body = gtk_vbox_new (FALSE, 2); - wiz->vbox = gtk_vbox_new (FALSE, 2); - wiz->ok_button = gtk_button_new_from_stock (GTK_STOCK_OK); - wiz->cancel_button = gtk_button_new_from_stock (GTK_STOCK_CANCEL); - - wiz->ok_cb = NULL; - wiz->cleanup_cb = NULL; - wiz->closure = NULL; - - wiz->destroy_cb = NULL; - wiz->destroy_closure = NULL; - - bbox = gtk_hbutton_box_new (); - gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), - GTK_BUTTONBOX_END); - - gtk_box_pack_start (GTK_BOX (bbox), wiz->cancel_button, FALSE, TRUE, 0); - gtk_box_pack_start (GTK_BOX (bbox), wiz->ok_button, FALSE, TRUE, 0); - - gtk_box_set_spacing (GTK_BOX (bbox), - 10 /* ugh */); - - gtk_box_pack_start (GTK_BOX (wiz->body), wiz->vbox, TRUE, TRUE, 2); - gtk_box_pack_start (GTK_BOX (wiz->body), gtk_hseparator_new (), FALSE, TRUE, 2); - gtk_box_pack_start (GTK_BOX (wiz->body), bbox, FALSE, TRUE, 2); - - gtk_widget_show_all (wiz->body); - - g_signal_connect (wiz->ok_button, - "clicked", - G_CALLBACK (mini_wizard_ok_cb), - wiz); - g_signal_connect (wiz->cancel_button, - "clicked", - G_CALLBACK (mini_wizard_cancel_cb), - wiz); - - g_object_weak_ref (G_OBJECT (wiz->body), - mini_wizard_destroy_cb, - wiz); - - return wiz; - -} - - - -/* - * This is the code for the UI thingie that lets you manipulate the e-mail - * addresses (and *only* the e-mail addresses) associated with an existing - * card. - */ - -#define EMPTY_ENTRY N_("(none)") - -typedef struct _EMailMenu EMailMenu; -struct _EMailMenu { - GtkWidget *option_menu; - GList *options; - gchar *current_selection; -}; - -static void -email_menu_free (EMailMenu *menu) -{ - if (menu == NULL) - return; - - g_list_foreach (menu->options, (GFunc) g_free, NULL); - g_list_free (menu->options); - g_free (menu); -} - -static EMailMenu * -email_menu_new (void) -{ - EMailMenu *menu = g_new (EMailMenu, 1); - - menu->option_menu = gtk_option_menu_new (); - menu->options = NULL; - menu->current_selection = NULL; - - gtk_option_menu_set_menu (GTK_OPTION_MENU (menu->option_menu), gtk_menu_new ()); - - return menu; -} - -static void -menu_activate_cb (GtkWidget *w, gpointer closure) -{ - EMailMenu *menu = (EMailMenu *) closure; - gchar *addr = (gchar *) g_object_get_data (G_OBJECT (w), "addr"); - - menu->current_selection = addr; -} - -static void -email_menu_add_option (EMailMenu *menu, const gchar *addr) -{ - GtkWidget *menu_item; - gchar *addr_cpy; - - g_return_if_fail (menu != NULL); - if (addr == NULL) - return; - - addr_cpy = g_strdup (addr); - menu->options = g_list_append (menu->options, addr_cpy); - - menu_item = gtk_menu_item_new_with_label (addr); - g_object_set_data (G_OBJECT (menu_item), "addr", addr_cpy); - gtk_widget_show_all (menu_item); - gtk_menu_shell_append (GTK_MENU_SHELL (gtk_option_menu_get_menu (GTK_OPTION_MENU (menu->option_menu))), menu_item); - - g_signal_connect (menu_item, - "activate", - G_CALLBACK (menu_activate_cb), - menu); -} - -static void -email_menu_add_options_from_card (EMailMenu *menu, ECard *card, const gchar *extra_addr) -{ - ECardSimple *simple; - - g_return_if_fail (card && E_IS_CARD (card)); - - simple = e_card_simple_new (card); - - /* If any of these three e-mail fields are NULL, email_menu_add_option will just - return without doing anything. */ - email_menu_add_option (menu, e_card_simple_get_email (simple, E_CARD_SIMPLE_EMAIL_ID_EMAIL)); - email_menu_add_option (menu, e_card_simple_get_email (simple, E_CARD_SIMPLE_EMAIL_ID_EMAIL_2)); - email_menu_add_option (menu, e_card_simple_get_email (simple, E_CARD_SIMPLE_EMAIL_ID_EMAIL_3)); - email_menu_add_option (menu, extra_addr); - email_menu_add_option (menu, EMPTY_ENTRY); - - g_object_unref (simple); -} - -static void -email_menu_set_option (EMailMenu *menu, const gchar *addr) -{ - guint count = 0; - GList *iter; - - g_return_if_fail (menu != NULL); - - if (addr == NULL) { - email_menu_set_option (menu, EMPTY_ENTRY); - return; - } - - iter = menu->options; - while (iter && strcmp (addr, (gchar *) iter->data)) { - ++count; - iter = g_list_next (iter); - } - - if (iter) { - gtk_option_menu_set_history (GTK_OPTION_MENU (menu->option_menu), count); - menu->current_selection = (gchar *) iter->data; - } -} - -#ifdef UNDEFINED_FUNCTIONS_SHOULD_PLEASE_BE_INCLUDED -static void -email_menu_unset_option (EMailMenu *menu, const gchar *addr) -{ - GList *iter; - - g_return_if_fail (menu != NULL); - g_return_if_fail (addr != NULL); - - if (menu->current_selection == NULL || strcmp (addr, menu->current_selection)) - return; - - iter = menu->options; - while (iter && strcmp (addr, (gchar *) iter->data)) { - iter = g_list_next (iter); - } - if (iter) { - iter = g_list_next (iter); - if (iter) { - email_menu_set_option (menu, (gchar *) iter->data); - } else { - email_menu_set_option (menu, EMPTY_ENTRY); - } - } -} -#endif - - - -typedef struct _EMailTable EMailTable; -struct _EMailTable { - GtkWidget *table; - ECard *card; - EMailMenu *primary; - EMailMenu *email2; - EMailMenu *email3; -}; - -static void -email_table_cleanup_cb (gpointer closure) -{ - EMailTable *et = (EMailTable *) closure; - - if (et == NULL) - return; - - g_object_unref (et->card); - email_menu_free (et->primary); - email_menu_free (et->email2); - email_menu_free (et->email3); - - g_free (et); -} - -static void -email_table_from_card (EMailTable *et) -{ - ECardSimple *simple; - - g_return_if_fail (et != NULL); - - simple = e_card_simple_new (et->card); - email_menu_set_option (et->primary, e_card_simple_get_email (simple, E_CARD_SIMPLE_EMAIL_ID_EMAIL)); - email_menu_set_option (et->email2, e_card_simple_get_email (simple, E_CARD_SIMPLE_EMAIL_ID_EMAIL_2)); - email_menu_set_option (et->email3, e_card_simple_get_email (simple, E_CARD_SIMPLE_EMAIL_ID_EMAIL_3)); - g_object_unref (simple); -} - -static void -email_table_to_card (EMailTable *et) -{ - ECardSimple *simple; - gchar *curr; - - g_return_if_fail (et != NULL); - - simple = e_card_simple_new (et->card); - - curr = et->primary->current_selection; - if (curr && !strcmp (curr, _(EMPTY_ENTRY))) - curr = NULL; - e_card_simple_set_email (simple, E_CARD_SIMPLE_EMAIL_ID_EMAIL, curr); - - curr = et->email2->current_selection; - if (curr && !strcmp (curr, _(EMPTY_ENTRY))) - curr = NULL; - e_card_simple_set_email (simple, E_CARD_SIMPLE_EMAIL_ID_EMAIL_2, curr); - - curr = et->email3->current_selection; - if (curr && !strcmp (curr, _(EMPTY_ENTRY))) - curr = NULL; - e_card_simple_set_email (simple, E_CARD_SIMPLE_EMAIL_ID_EMAIL_3, curr); - - e_card_simple_sync_card (simple); - g_object_unref (simple); -} - -static void -email_table_save_card_cb (EBook *book, EBookStatus status, gpointer closure) -{ - ECard *card = E_CARD (closure); - - if (status == E_BOOK_STATUS_SUCCESS) { - e_book_commit_card (book, card, NULL, NULL); - } - if (book) - g_object_unref (book); - g_object_unref (card); -} - -/* - * We have to do this in an idle function because of what might be a - * re-entrancy problems with EBook. - */ -static gint -add_card_idle_cb (gpointer closure) -{ - EBook *book; - - book = e_book_new (); - addressbook_load_default_book (book, email_table_save_card_cb, closure); - - return 0; -} - -static void -email_table_ok_cb (MiniWizard *wiz, gpointer closure) -{ - EMailTable *et = (EMailTable *) closure; - - email_table_to_card (et); - - g_object_ref (et->card); - gtk_idle_add (add_card_idle_cb, et->card); - - mini_wizard_destroy (wiz); -} - -static void -email_table_init (MiniWizard *wiz, ECard *card, const gchar *extra_address) -{ - EMailTable *et; - - gchar *name_str; - gint xpad, ypad; - GtkAttachOptions label_x_opts, label_y_opts; - GtkAttachOptions menu_x_opts, menu_y_opts; - - g_return_if_fail (card && E_IS_CARD (card)); - - et = g_new (EMailTable, 1); - - et->card = card; - g_object_ref (et->card); - - et->table = gtk_table_new (4, 2, FALSE); - - et->primary = email_menu_new (); - et->email2 = email_menu_new (); - et->email3 = email_menu_new (); - - email_menu_add_options_from_card (et->primary, et->card, extra_address); - email_menu_add_options_from_card (et->email2, et->card, extra_address); - email_menu_add_options_from_card (et->email3, et->card, extra_address); - - email_table_from_card (et); - - label_x_opts = GTK_FILL; - label_y_opts = GTK_FILL; - menu_x_opts = GTK_EXPAND | GTK_FILL; - menu_y_opts = GTK_EXPAND | GTK_FILL; - xpad = 3; - ypad = 3; - - name_str = e_card_name_to_string (et->card->name); - gtk_table_attach (GTK_TABLE (et->table), - gtk_label_new (name_str), - 0, 2, 0, 1, - label_x_opts, label_y_opts, xpad, ypad); - g_free (name_str); - - gtk_table_attach (GTK_TABLE (et->table), - gtk_label_new (_("Primary Email")), - 0, 1, 1, 2, - label_x_opts, label_y_opts, xpad, ypad); - - gtk_table_attach (GTK_TABLE (et->table), - et->primary->option_menu, - 1, 2, 1, 2, - menu_x_opts, menu_y_opts, xpad, ypad); - - gtk_table_attach (GTK_TABLE (et->table), - gtk_label_new (_("Email 2")), - 0, 1, 2, 3, - label_x_opts, label_y_opts, xpad, ypad); - - gtk_table_attach (GTK_TABLE (et->table), - et->email2->option_menu, - 1, 2, 2, 3, - menu_x_opts, menu_y_opts, xpad, ypad); - - gtk_table_attach (GTK_TABLE (et->table), - gtk_label_new (_("Email 3")), - 0, 1, 3, 4, - label_x_opts, label_y_opts, xpad, ypad); - - gtk_table_attach (GTK_TABLE (et->table), - et->email3->option_menu, - 1, 2, 3, 4, - menu_x_opts, menu_y_opts, xpad, ypad); - - gtk_widget_show_all (et->primary->option_menu); - gtk_widget_show_all (et->email2->option_menu); - gtk_widget_show_all (et->email3->option_menu); - - gtk_widget_show_all (et->table); - mini_wizard_container_add (wiz, et->table); - wiz->ok_cb = email_table_ok_cb; - wiz->cleanup_cb = email_table_cleanup_cb; - wiz->closure = et; -} - -/* - * This code is for the little UI thing that lets you pick from a set of cards - * and decide which one you want to add the e-mail address to. - */ - -typedef struct _CardPicker CardPicker; -struct _CardPicker { - GtkWidget *body; - GtkWidget *list; - GtkListStore *model; - GList *cards; - gchar *new_name; - gchar *new_email; - - ECard *current_card; -}; - -enum { - COLUMN_ACTION, - COLUMN_CARD -}; - -static void -card_picker_selection_changed (GtkTreeSelection *selection, gpointer closure) -{ - MiniWizard *wiz = (MiniWizard *) closure; - CardPicker *pick = (CardPicker *) wiz->closure; - gboolean selected; - GtkTreeIter iter; - - selected = gtk_tree_selection_get_selected (selection, NULL, &iter); - - gtk_widget_set_sensitive (wiz->ok_button, selected); - - if (selected) { - gtk_tree_model_get (GTK_TREE_MODEL (pick->model), &iter, - COLUMN_CARD, &pick->current_card, - -1); - } - else { - pick->current_card = NULL; - } -} - -static void -card_picker_ok_cb (MiniWizard *wiz, gpointer closure) -{ - CardPicker *pick = (CardPicker *) closure; - - if (pick->current_card == NULL) { - e_contact_quick_add (pick->new_name, pick->new_email, NULL, NULL); - mini_wizard_destroy (wiz); - } else { - email_table_init (wiz, pick->current_card, pick->new_email); - } -} - -static void -card_picker_cleanup_cb (gpointer closure) -{ - CardPicker *pick = (CardPicker *) closure; - - g_list_foreach (pick->cards, (GFunc) g_object_unref, NULL); - g_list_free (pick->cards); - - g_free (pick->new_name); - g_free (pick->new_email); -} - -static void -free_str (gpointer data, - GObject *where_the_object_was) -{ - g_free (data); -} - -static void -card_picker_init (MiniWizard *wiz, const GList *cards, const gchar *new_name, const gchar *new_email) -{ - CardPicker *pick; - gchar *str; - GtkWidget *w; - GtkTreeIter iter; - - pick = g_new (CardPicker, 1); - - pick->body = gtk_vbox_new (FALSE, 2); - - pick->model = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_POINTER); - - pick->list = gtk_tree_view_new_with_model (GTK_TREE_MODEL (pick->model)); - - gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (pick->list), TRUE); - - gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (pick->list), - COLUMN_ACTION, - _("Select an Action"), - gtk_cell_renderer_text_new (), - "text", COLUMN_ACTION, - NULL); - - gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (pick->list)), - GTK_SELECTION_SINGLE); - - str = g_strdup_printf (_("Create a new contact \"%s\""), new_name); - gtk_list_store_append (pick->model, &iter); - gtk_list_store_set (pick->model, &iter, - COLUMN_ACTION, str, - COLUMN_CARD, NULL, - -1); - g_object_weak_ref (G_OBJECT (pick->model), free_str, str); - - pick->cards = NULL; - while (cards) { - ECard *card = (ECard *) cards->data; - gchar *name_str = e_card_name_to_string (card->name); - - pick->cards = g_list_append (pick->cards, card); - g_object_ref (card); - - str = g_strdup_printf (_("Add address to existing contact \"%s\""), name_str); - gtk_list_store_append (pick->model, &iter); - gtk_list_store_set (pick->model, &iter, - COLUMN_ACTION, str, - COLUMN_CARD, card, - -1); - g_free (name_str); - - g_object_weak_ref (G_OBJECT (pick->model), free_str, str); - - cards = g_list_next (cards); - } - - pick->new_name = g_strdup (new_name); - pick->new_email = g_strdup (new_email); - - pick->current_card = NULL; - gtk_widget_set_sensitive (wiz->ok_button, FALSE); - - /* Connect some signals & callbacks */ - - wiz->ok_cb = card_picker_ok_cb; - wiz->cleanup_cb = card_picker_cleanup_cb; - - g_signal_connect (gtk_tree_view_get_selection (GTK_TREE_VIEW (pick->list)), - "changed", G_CALLBACK (card_picker_selection_changed), - wiz); - - /* Build our widget */ - - w = gtk_label_new (new_email); - gtk_box_pack_start (GTK_BOX (pick->body), w, FALSE, TRUE, 3); - - gtk_box_pack_start (GTK_BOX (pick->body), pick->list, TRUE, TRUE, 2); - gtk_widget_show_all (pick->body); - - - /* Put it in our mini-wizard */ - - wiz->closure = pick; - mini_wizard_container_add (wiz, pick->body); -} - -/* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** */ - -/* - * The code for the actual EAddressPopup widget begins here. - */ - -/* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** */ - - -static GtkObjectClass *parent_class; - -static void e_address_popup_dispose (GObject *); -static void e_address_popup_query (EAddressPopup *); - - -static void -e_address_popup_class_init (EAddressPopupClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - parent_class = g_type_class_peek_parent (klass); - - object_class->dispose = e_address_popup_dispose; -} - -static void -e_address_popup_init (EAddressPopup *pop) -{ - pop->transitory = TRUE; -} - -static void -e_address_popup_cleanup (EAddressPopup *pop) -{ - if (pop->card) { - g_object_unref (pop->card); - pop->card = NULL; - } - - if (pop->scheduled_refresh) { - gtk_timeout_remove (pop->scheduled_refresh); - pop->scheduled_refresh = 0; - } - - if (pop->query_tag) { - e_book_simple_query_cancel (pop->book, pop->query_tag); - pop->query_tag = 0; - } - - if (pop->book) { - g_object_unref (pop->book); - pop->book = NULL; - } - - g_free (pop->name); - pop->name = NULL; - - g_free (pop->email); - pop->email = NULL; -} - -static void -e_address_popup_dispose (GObject *obj) -{ - EAddressPopup *pop = E_ADDRESS_POPUP (obj); - - e_address_popup_cleanup (pop); - - if (G_OBJECT_CLASS (parent_class)->dispose) - G_OBJECT_CLASS (parent_class)->dispose (obj); -} - -GType -e_address_popup_get_type (void) -{ - static GType pop_type = 0; - - if (!pop_type) { - static const GTypeInfo pop_info = { - sizeof (EAddressPopupClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) e_address_popup_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (EAddressPopup), - 0, /* n_preallocs */ - (GInstanceInitFunc) e_address_popup_init, - }; - - pop_type = g_type_register_static (gtk_event_box_get_type (), "EAddressPopup", &pop_info, 0); - } - - return pop_type; -} - -static void -e_address_popup_refresh_names (EAddressPopup *pop) -{ - if (pop->name_widget) { - if (pop->name && *pop->name) { - gtk_label_set_text (GTK_LABEL (pop->name_widget), pop->name); - gtk_widget_show (pop->name_widget); - } else { - gtk_widget_hide (pop->name_widget); - } - } - - if (pop->email_widget) { - if (pop->email && *pop->email) { - gtk_label_set_text (GTK_LABEL (pop->email_widget), pop->email); - gtk_widget_show (pop->email_widget); - } else { - gtk_widget_hide (pop->email_widget); - } - } - - e_address_popup_query (pop); -} - -static gint -refresh_timeout_cb (gpointer ptr) -{ - EAddressPopup *pop = E_ADDRESS_POPUP (ptr); - e_address_popup_refresh_names (pop); - pop->scheduled_refresh = 0; - return 0; -} - -static void -e_address_popup_schedule_refresh (EAddressPopup *pop) -{ - if (pop->scheduled_refresh == 0) - pop->scheduled_refresh = gtk_timeout_add (20, refresh_timeout_cb, pop); -} - -/* If we are handed something of the form "Foo ", - do the right thing. */ -static gboolean -e_address_popup_set_free_form (EAddressPopup *pop, const gchar *txt) -{ - gchar *lt, *gt = NULL; - - g_return_val_if_fail (pop && E_IS_ADDRESS_POPUP (pop), FALSE); - - if (txt == NULL) - return FALSE; - - lt = strchr (txt, '<'); - if (lt) - gt = strchr (txt, '>'); - - if (lt && gt && lt+1 < gt) { - gchar *name = g_strndup (txt, lt-txt); - gchar *email = g_strndup (lt+1, gt-lt-1); - e_address_popup_set_name (pop, name); - e_address_popup_set_email (pop, email); - - g_free (name); - g_free (email); - - return TRUE; - } - - return FALSE; -} - -void -e_address_popup_set_name (EAddressPopup *pop, const gchar *name) -{ - g_return_if_fail (pop && E_IS_ADDRESS_POPUP (pop)); - - /* We only allow the name to be set once. */ - if (pop->name) - return; - - if (!e_address_popup_set_free_form (pop, name)) { - pop->name = g_strdup (name); - if (pop->name) - g_strstrip (pop->name); - } - - e_address_popup_schedule_refresh (pop); -} - -void -e_address_popup_set_email (EAddressPopup *pop, const gchar *email) -{ - g_return_if_fail (pop && E_IS_ADDRESS_POPUP (pop)); - - /* We only allow the e-mail to be set once. */ - if (pop->email) - return; - - if (!e_address_popup_set_free_form (pop, email)) { - pop->email = g_strdup (email); - if (pop->email) - g_strstrip (pop->email); - } - - e_address_popup_schedule_refresh (pop); -} - -void -e_address_popup_construct (EAddressPopup *pop) -{ - GtkWidget *vbox, *name_holder; - GdkColor color = { 0x0, 0xffff, 0xffff, 0xffff }; - - g_return_if_fail (pop && E_IS_ADDRESS_POPUP (pop)); - - pop->main_vbox = gtk_vbox_new (FALSE, 0); - - /* Build Generic View */ - - name_holder = gtk_event_box_new (); - vbox = gtk_vbox_new (FALSE, 2); - pop->name_widget = gtk_label_new (""); - pop->email_widget = gtk_label_new (""); - - gtk_box_pack_start (GTK_BOX (vbox), pop->name_widget, TRUE, TRUE, 2); - gtk_box_pack_start (GTK_BOX (vbox), pop->email_widget, TRUE, TRUE, 2); - gtk_container_add (GTK_CONTAINER (name_holder), GTK_WIDGET (vbox)); - - if (gdk_colormap_alloc_color (gtk_widget_get_colormap (GTK_WIDGET (name_holder)), &color, FALSE, TRUE)) { - GtkStyle *style = gtk_style_copy (gtk_widget_get_style (GTK_WIDGET (name_holder))); - style->bg[0] = color; - gtk_widget_set_style (GTK_WIDGET (name_holder), style); - g_object_unref (style); - } - - pop->generic_view = gtk_frame_new (NULL); - gtk_container_add (GTK_CONTAINER (pop->generic_view), name_holder); - gtk_box_pack_start (GTK_BOX (pop->main_vbox), pop->generic_view, TRUE, TRUE, 0); - gtk_widget_show_all (pop->generic_view); - - pop->query_msg = gtk_label_new (_("Querying Addressbook...")); - gtk_box_pack_start (GTK_BOX (pop->main_vbox), pop->query_msg, TRUE, TRUE, 0); - gtk_widget_show (pop->query_msg); - - /* Build Minicard View */ - pop->minicard_view = e_minicard_widget_new (); - gtk_box_pack_start (GTK_BOX (pop->main_vbox), pop->minicard_view, TRUE, TRUE, 0); - - - /* Final assembly */ - - gtk_container_add (GTK_CONTAINER (pop), pop->main_vbox); - gtk_widget_show (pop->main_vbox); - - gtk_container_set_border_width (GTK_CONTAINER (vbox), 3); - gtk_container_set_border_width (GTK_CONTAINER (pop), 2); -} - -GtkWidget * -e_address_popup_new (void) -{ - EAddressPopup *pop = g_object_new (E_TYPE_ADDRESS_POPUP, NULL); - e_address_popup_construct (pop); - return GTK_WIDGET (pop); -} - -static void -emit_event (EAddressPopup *pop, const char *event) -{ - if (pop->es) { - BonoboArg *arg; - - arg = bonobo_arg_new (BONOBO_ARG_BOOLEAN); - BONOBO_ARG_SET_BOOLEAN (arg, TRUE); - bonobo_event_source_notify_listeners_full (pop->es, - "GNOME/Evolution/Addressbook/AddressPopup", - "Event", - event, - arg, NULL); - bonobo_arg_release (arg); - } -} - -static void -contact_editor_cb (EBook *book, EBookStatus status, gpointer closure) -{ - if (status == E_BOOK_STATUS_SUCCESS) { - EAddressPopup *pop = E_ADDRESS_POPUP (closure); - EContactEditor *ce = e_addressbook_show_contact_editor (book, pop->card, FALSE, TRUE); - e_address_popup_cleanup (pop); - emit_event (pop, "Destroy"); - e_contact_editor_raise (ce); - } - - if (book) - g_object_unref (book); -} - -static void -edit_contact_info_cb (GtkWidget *button, EAddressPopup *pop) -{ - EBook *book; - emit_event (pop, "Hide"); - - book = e_book_new (); - addressbook_load_default_book (book, contact_editor_cb, pop); -} - -static void -e_address_popup_cardify (EAddressPopup *pop, ECard *card) -{ - GtkWidget *b; - - g_return_if_fail (pop && E_IS_ADDRESS_POPUP (pop)); - g_return_if_fail (card && E_IS_CARD (card)); - g_return_if_fail (pop->card == NULL); - - pop->card = card; - g_object_ref (pop->card); - - e_minicard_widget_set_card (E_MINICARD_WIDGET (pop->minicard_view), card); - gtk_widget_show (pop->minicard_view); - gtk_widget_hide (pop->generic_view); - - b = gtk_button_new_with_label (_("Edit Contact Info")); - gtk_box_pack_start (GTK_BOX (pop->main_vbox), b, TRUE, TRUE, 0); - g_signal_connect (b, - "clicked", - G_CALLBACK (edit_contact_info_cb), - pop); - gtk_widget_show (b); -} - -static void -add_contacts_cb (GtkWidget *button, EAddressPopup *pop) -{ - if (pop->email && *pop->email) { - if (pop->name && *pop->name) - e_contact_quick_add (pop->name, pop->email, NULL, NULL); - else - e_contact_quick_add_free_form (pop->email, NULL, NULL); - - } - e_address_popup_cleanup (pop); - emit_event (pop, "Destroy"); -} - -static void -e_address_popup_no_matches (EAddressPopup *pop) -{ - GtkWidget *b; - - g_return_if_fail (pop && E_IS_ADDRESS_POPUP (pop)); - - b = e_button_new_with_stock_icon (_("Add to Contacts"), "gtk-add"); - - gtk_box_pack_start (GTK_BOX (pop->main_vbox), b, TRUE, TRUE, 0); - g_signal_connect (b, - "clicked", - G_CALLBACK (add_contacts_cb), - pop); - gtk_widget_show (b); -} - -static void -wizard_destroy_cb (MiniWizard *wiz, gpointer closure) -{ - gtk_widget_destroy (GTK_WIDGET (closure)); -} - -static void -e_address_popup_ambiguous_email_add (EAddressPopup *pop, const GList *cards) -{ - MiniWizard *wiz = mini_wizard_new (); - GtkWidget *win = gtk_window_new (GTK_WINDOW_TOPLEVEL); - - wiz->destroy_cb = wizard_destroy_cb; - wiz->destroy_closure = win; - - gtk_window_set_title (GTK_WINDOW (win), _("Merge E-Mail Address")); - gtk_window_set_position (GTK_WINDOW (win), GTK_WIN_POS_MOUSE); - - card_picker_init (wiz, cards, pop->name, pop->email); - - e_address_popup_cleanup (pop); - emit_event (pop, "Destroy"); - - gtk_container_add (GTK_CONTAINER (win), wiz->body); - gtk_widget_show_all (win); -} - -static void -e_address_popup_multiple_matches (EAddressPopup *pop, const GList *cards) -{ - pop->multiple_matches = TRUE; - - e_address_popup_ambiguous_email_add (pop, cards); -} - -/** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **/ - -/* - * Addressbook Query Fun - */ - -static void -name_only_query_cb (EBook *book, EBookSimpleQueryStatus status, const GList *cards, gpointer closure) -{ - EAddressPopup *pop; - - if (status != E_BOOK_SIMPLE_QUERY_STATUS_SUCCESS) - return; - - pop = E_ADDRESS_POPUP (closure); - - pop->query_tag = 0; - - if (cards == NULL) { - e_address_popup_no_matches (pop); - } else { - e_address_popup_ambiguous_email_add (pop, cards); - } -} - -static void -query_cb (EBook *book, EBookSimpleQueryStatus status, const GList *cards, gpointer closure) -{ - EAddressPopup *pop; - - if (status != E_BOOK_SIMPLE_QUERY_STATUS_SUCCESS) - return; - - pop = E_ADDRESS_POPUP (closure); - - pop->query_tag = 0; - gtk_widget_hide (pop->query_msg); - - if (cards == NULL) { - - /* Do a name-only query if: - (1) The name is non-empty. - (2) The e-mail is also non-empty (so that the query we just did wasn't actually a name-only query. - */ - if (pop->name && *pop->name && pop->email && *pop->email) { - pop->query_tag = e_book_name_and_email_query (book, pop->name, NULL, name_only_query_cb, pop); - } else { - e_address_popup_no_matches (pop); - } - - } else { - if (g_list_length ((GList *) cards) == 1) - e_address_popup_cardify (pop, E_CARD (cards->data)); - else - e_address_popup_multiple_matches (pop, cards); - } -} - -static void -start_query (EBook *book, EBookStatus status, gpointer closure) -{ - EAddressPopup *pop = E_ADDRESS_POPUP (closure); - - if (status != E_BOOK_STATUS_SUCCESS) { - e_address_popup_no_matches (pop); - if (book) - g_object_unref (book); - return; - } - - if (pop->query_tag) - e_book_simple_query_cancel (book, pop->query_tag); - - if (pop->book != book) { - g_object_ref (book); - if (pop->book) - g_object_unref (pop->book); - pop->book = book; - } - - pop->query_tag = e_book_name_and_email_query (book, pop->name, pop->email, query_cb, pop); - - g_object_unref (pop); -} - -static void -e_address_popup_query (EAddressPopup *pop) -{ - EBook *book; - - g_return_if_fail (pop && E_IS_ADDRESS_POPUP (pop)); - - book = e_book_new (); - g_object_ref (pop); - - addressbook_load_default_book (book, start_query, pop); -} - -/** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **/ - -enum { - PROPERTY_NAME, - PROPERTY_EMAIL, - PROPERTY_TRANSITORY -}; - -static void -set_prop (BonoboPropertyBag *bag, const BonoboArg *arg, guint arg_id, CORBA_Environment *ev, gpointer user_data) -{ - EAddressPopup *pop = E_ADDRESS_POPUP (user_data); - - switch (arg_id) { - - case PROPERTY_NAME: - e_address_popup_set_name (pop, BONOBO_ARG_GET_STRING (arg)); - break; - - case PROPERTY_EMAIL: - e_address_popup_set_email (pop, BONOBO_ARG_GET_STRING (arg)); - break; - - default: - g_assert_not_reached (); - } -} - -static void -get_prop (BonoboPropertyBag *bag, BonoboArg *arg, guint arg_id, CORBA_Environment *ev, gpointer user_data) -{ - EAddressPopup *pop = E_ADDRESS_POPUP (user_data); - - switch (arg_id) { - - case PROPERTY_NAME: - BONOBO_ARG_SET_STRING (arg, pop->name); - break; - - case PROPERTY_EMAIL: - BONOBO_ARG_SET_STRING (arg, pop->email); - break; - - case PROPERTY_TRANSITORY: - BONOBO_ARG_SET_BOOLEAN (arg, pop->transitory); - break; - - default: - g_assert_not_reached (); - } -} - -BonoboControl * -e_address_popup_new_control (void) -{ - BonoboControl *control; - BonoboPropertyBag *bag; - EAddressPopup *addy; - GtkWidget *w; - - w = e_address_popup_new (); - addy = E_ADDRESS_POPUP (w); - - control = bonobo_control_new (w); - gtk_widget_show (w); - - bag = bonobo_property_bag_new (get_prop, set_prop, w); - bonobo_property_bag_add (bag, "name", PROPERTY_NAME, - BONOBO_ARG_STRING, NULL, NULL, - BONOBO_PROPERTY_WRITEABLE | BONOBO_PROPERTY_READABLE); - - bonobo_property_bag_add (bag, "email", PROPERTY_EMAIL, - BONOBO_ARG_STRING, NULL, NULL, - BONOBO_PROPERTY_WRITEABLE | BONOBO_PROPERTY_READABLE); - - bonobo_property_bag_add (bag, "transitory", PROPERTY_TRANSITORY, - BONOBO_ARG_BOOLEAN, NULL, NULL, - BONOBO_PROPERTY_READABLE); - - bonobo_control_set_properties (control, bonobo_object_corba_objref (BONOBO_OBJECT (bag)), NULL); - bonobo_object_unref (BONOBO_OBJECT (bag)); - - addy->es = bonobo_event_source_new (); - bonobo_object_add_interface (BONOBO_OBJECT (control), - BONOBO_OBJECT (addy->es)); - - return control; -} diff --git a/addressbook/gui/component/e-address-popup.h b/addressbook/gui/component/e-address-popup.h deleted file mode 100644 index b2519b0ee6..0000000000 --- a/addressbook/gui/component/e-address-popup.h +++ /dev/null @@ -1,88 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * e-address-popup.h - * - * Copyright (C) 2001 Ximian, Inc. - * - * Developed by Jon Trowbridge - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - */ - -#ifndef __E_ADDRESS_POPUP_H__ -#define __E_ADDRESS_POPUP_H__ - -#include -#include -#include -#include - -G_BEGIN_DECLS - -#define E_TYPE_ADDRESS_POPUP (e_address_popup_get_type ()) -#define E_ADDRESS_POPUP(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), E_TYPE_ADDRESS_POPUP, EAddressPopup)) -#define E_ADDRESS_POPUP_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), E_TYPE_ADDRESS_POPUP, EAddressPopupClass)) -#define E_IS_ADDRESS_POPUP(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_TYPE_ADDRESS_POPUP)) -#define E_IS_ADDRESS_POPUP_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), E_TYPE_ADDRESS_POPUP)) - -typedef struct _EAddressPopup EAddressPopup; -typedef struct _EAddressPopupClass EAddressPopupClass; - -struct _EAddressPopup { - GtkEventBox parent; - - gchar *name; - gchar *email; - - GtkWidget *name_widget; - GtkWidget *email_widget; - GtkWidget *query_msg; - - GtkWidget *main_vbox; - GtkWidget *generic_view; - GtkWidget *minicard_view; - - gboolean transitory; - - guint scheduled_refresh; - EBook *book; - guint query_tag; - gboolean multiple_matches; - ECard *card; - - BonoboEventSource *es; -}; - -struct _EAddressPopupClass { - GtkEventBoxClass parent_class; -}; - -GType e_address_popup_get_type (void); - -void e_address_popup_set_name (EAddressPopup *, const gchar *name); -void e_address_popup_set_email (EAddressPopup *, const gchar *email); - -void e_address_popup_construct (EAddressPopup *); -GtkWidget *e_address_popup_new (void); - -BonoboControl *e_address_popup_new_control (void); - -G_END_DECLS - -#endif /* __E_ADDRESS_POPUP_H__ */ - diff --git a/addressbook/gui/component/e-address-widget.c b/addressbook/gui/component/e-address-widget.c deleted file mode 100644 index 9ec1e6ebba..0000000000 --- a/addressbook/gui/component/e-address-widget.c +++ /dev/null @@ -1,568 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * e-address-widget.c - * - * Copyright (C) 2001 Ximian, Inc. - * - * Developed by Jon Trowbridge - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "e-address-widget.h" - -static void e_address_widget_class_init (EAddressWidgetClass *klass); -static void e_address_widget_init (EAddressWidget *obj); -static void e_address_widget_destroy (GtkObject *obj); - -static gint e_address_widget_button_press_handler (GtkWidget *w, GdkEventButton *ev); -static void e_address_widget_popup (EAddressWidget *, GdkEventButton *ev); -static void e_address_widget_schedule_query (EAddressWidget *); - -static GtkObjectClass *parent_class; - -static EBook *common_book = NULL; /* sort of lame */ - -static gboolean doing_queries = FALSE; - -static void -e_address_widget_class_init (EAddressWidgetClass *klass) -{ - GtkObjectClass *object_class = (GtkObjectClass *) klass; - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - - parent_class = g_type_class_peek_parent (klass); - - object_class->destroy = e_address_widget_destroy; - - widget_class->button_press_event = e_address_widget_button_press_handler; -} - -static void -e_address_widget_init (EAddressWidget *addr) -{ - -} - -static void -e_address_widget_destroy (GtkObject *obj) -{ - EAddressWidget *addr = E_ADDRESS_WIDGET (obj); - - g_free (addr->name); - addr->name = NULL; - - g_free (addr->email); - addr->email = NULL; - - if (addr->query_tag) { - e_book_simple_query_cancel (common_book, addr->query_tag); - addr->query_tag = 0; - } - - if (addr->query_idle_tag) { - g_source_remove (addr->query_idle_tag); - addr->query_idle_tag = 0; - } - - (* GTK_OBJECT_CLASS (parent_class)->destroy) (obj); -} - -static gint -e_address_widget_button_press_handler (GtkWidget *w, GdkEventButton *ev) -{ - EAddressWidget *addr = E_ADDRESS_WIDGET (w); - if (ev->button == 3 && ev->state == 0) { - e_address_widget_popup (addr, ev); - return TRUE; - } - - return FALSE; -} - -GType -e_address_widget_get_type (void) -{ - static GType aw_type = 0; - - if (!aw_type) { - static const GTypeInfo aw_info = { - sizeof (EAddressWidgetClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) e_address_widget_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (EAddressWidget), - 0, /* n_preallocs */ - (GInstanceInitFunc) e_address_widget_init, - }; - - aw_type = g_type_register_static (gtk_event_box_get_type (), "EAddressWidget", &aw_info, 0); - } - - return aw_type; -} - -static void -gtk_widget_visible (GtkWidget *w, gboolean x) -{ - if (x) - gtk_widget_show (w); - else - gtk_widget_hide (w); -} - -static void -e_address_widget_refresh (EAddressWidget *addr) -{ - gchar *str; - gboolean have_name, have_email; - - g_return_if_fail (addr && E_IS_ADDRESS_WIDGET (addr)); - - have_name = addr->name && *addr->name; - have_email = addr->email && *addr->email && (addr->card == NULL || !addr->known_email); - - gtk_label_set_text (GTK_LABEL (addr->name_widget), have_name ? addr->name : ""); - gtk_widget_visible (addr->name_widget, have_name); - if (addr->card) { - gint i, N = strlen (addr->name); - gchar *pattern = g_malloc (N+1); - for (i=0; iname_widget), pattern); - g_free (pattern); - } else { - gtk_label_set_pattern (GTK_LABEL (addr->name_widget), ""); - } - - if (have_email) { - str = g_strdup_printf (have_name ? "<%s>" : "%s", addr->email); - gtk_label_set_text (GTK_LABEL (addr->email_widget), str); - g_free (str); - } else { - gtk_label_set_text (GTK_LABEL (addr->email_widget), ""); - } - gtk_widget_visible (addr->email_widget, have_email); - - gtk_widget_visible (addr->spacer, have_name && have_email); - - /* Launch a query to find the appropriate card, if necessary. */ - if (addr->card == NULL) - e_address_widget_schedule_query (addr); -} - -void -e_address_widget_set_name (EAddressWidget *addr, const gchar *name) -{ - g_return_if_fail (addr && E_IS_ADDRESS_WIDGET (addr)); - - g_free (addr->name); - addr->name = g_strdup (name); - - e_address_widget_refresh (addr); -} - -void -e_address_widget_set_email (EAddressWidget *addr, const gchar *email) -{ - g_return_if_fail (addr && E_IS_ADDRESS_WIDGET (addr)); - - g_free (addr->email); - addr->email = g_strdup (email); - - e_address_widget_refresh (addr); -} - - -void -e_address_widget_set_text (EAddressWidget *addr, const gchar *text) -{ - g_return_if_fail (addr && E_IS_ADDRESS_WIDGET (addr)); - - e_address_widget_set_email (addr, text); /* CRAP */ -} - -void -e_address_widget_construct (EAddressWidget *addr) -{ - GtkWidget *box; - - g_return_if_fail (addr && E_IS_ADDRESS_WIDGET (addr)); - - box = gtk_hbox_new (FALSE, 2); - - addr->name_widget = gtk_label_new (""); - addr->spacer = gtk_label_new (" "); - addr->email_widget = gtk_label_new (""); - - gtk_box_pack_start (GTK_BOX (box), addr->name_widget, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (box), addr->spacer, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (box), addr->email_widget, FALSE, FALSE, 0); - - gtk_container_add (GTK_CONTAINER (addr), box); - - gtk_widget_show (box); - gtk_widget_show (addr->name_widget); - gtk_widget_show (addr->email_widget); -} - -GtkWidget * -e_address_widget_new (void) -{ - EAddressWidget *addr = g_object_new (E_TYPE_ADDRESS_WIDGET, NULL); - e_address_widget_construct (addr); - return GTK_WIDGET (addr); -} - -/* - * - * Cardification - * - */ - -static void -e_address_widget_cardify (EAddressWidget *addr, ECard *card, gboolean known_email) -{ - if (addr->card != card || addr->known_email != known_email) { - - if (addr->card != card) { - if (addr->card) - g_object_unref (addr->card); - addr->card = card; - g_object_ref (addr->card); - } - - addr->known_email = known_email; - - if (!(addr->name && *addr->name)) { - gchar *s = e_card_name_to_string (card->name); - e_address_widget_set_name (addr, s); - g_free (s); - } - - e_address_widget_refresh (addr); - } -} - -static void -query_results_cb (EBook *book, EBookSimpleQueryStatus status, const GList *cards, gpointer user_data) -{ - EAddressWidget *addr = user_data; - - if (g_list_length ((GList *) cards) == 1) { - ECard *card = E_CARD (cards->data); - e_address_widget_cardify (addr, card, TRUE); - } - - addr->query_tag = 0; -} - -static void -e_address_widget_do_query (EAddressWidget *addr) -{ - e_book_name_and_email_query (common_book, addr->name, addr->email, query_results_cb, addr); -} - -static void -book_ready_cb (EBook *book, EBookStatus status, gpointer user_data) -{ - EAddressWidget *addr = E_ADDRESS_WIDGET (user_data); - - if (common_book == NULL) { - common_book = book; - g_object_ref (common_book); - } else - g_object_unref (book); - - e_address_widget_do_query (addr); -} - -static gint -query_idle_fn (gpointer ptr) -{ - EAddressWidget *addr = E_ADDRESS_WIDGET (ptr); - - if (common_book) { - e_address_widget_do_query (addr); - } else { - e_book_load_default_book (e_book_new (), book_ready_cb, addr); - } - - addr->query_idle_tag = 0; - return FALSE; -} - -static void -e_address_widget_schedule_query (EAddressWidget *addr) -{ - if (addr->query_idle_tag || !doing_queries) - return; - addr->query_idle_tag = g_idle_add (query_idle_fn, addr); -} - -/* - * - * Popup Menu - * - */ - -#define ARBITRARY_UIINFO_LIMIT 64 - -static gint -popup_add_name_and_address (EAddressWidget *addr, GnomeUIInfo *uiinfo, gint i) -{ - gboolean flag = FALSE; - - if (addr->name && *addr->name) { - uiinfo[i].type = GNOME_APP_UI_ITEM; - uiinfo[i].label = addr->name; - ++i; - flag = TRUE; - } - - if (addr->email && *addr->email) { - uiinfo[i].type = GNOME_APP_UI_ITEM; - uiinfo[i].label = addr->email; - ++i; - flag = TRUE; - } - - if (flag) { - uiinfo[i].type = GNOME_APP_UI_SEPARATOR; - ++i; - } - - return i; -} - -static void -flip_queries_flag_cb (GtkWidget *w, gpointer user_data) -{ - doing_queries = !doing_queries; -} - -static gint -popup_add_query_change (EAddressWidget *addr, GnomeUIInfo *uiinfo, gint i) -{ - uiinfo[i].type = GNOME_APP_UI_SEPARATOR; - ++i; - - uiinfo[i].type = GNOME_APP_UI_ITEM; - uiinfo[i].label = doing_queries ? _("Disable Queries") : _("Enable Queries (Dangerous!)"); - uiinfo[i].moreinfo = flip_queries_flag_cb; - ++i; - - return i; -} - - -static GtkWidget * -popup_menu_card (EAddressWidget *addr) -{ - GnomeUIInfo uiinfo[ARBITRARY_UIINFO_LIMIT]; - GtkWidget *pop; - gint i=0; - ECard *card = E_CARD (addr->card); - - g_return_val_if_fail (card != NULL, NULL); - - memset (uiinfo, 0, sizeof (uiinfo)); - - i = popup_add_name_and_address (addr, uiinfo, i); - - uiinfo[i].type = GNOME_APP_UI_ITEM; - uiinfo[i].label = _("Edit Contact Info"); - ++i; - - i = popup_add_query_change (addr, uiinfo, i); - - uiinfo[i].type = GNOME_APP_UI_ENDOFINFO; - pop = gnome_popup_menu_new (uiinfo); - return pop; -} - -static void -post_quick_add_cb (ECard *card, gpointer user_data) -{ - e_address_widget_cardify (E_ADDRESS_WIDGET (user_data), card, TRUE); -} - -static void -add_contacts_cb (GtkWidget *w, gpointer user_data) -{ - EAddressWidget *addr = E_ADDRESS_WIDGET (user_data); - - e_contact_quick_add (addr->name, addr->email, post_quick_add_cb, addr); -} - -static GtkWidget * -popup_menu_nocard (EAddressWidget *addr) -{ - GnomeUIInfo uiinfo[ARBITRARY_UIINFO_LIMIT]; - GtkWidget *pop; - gint i=0; - - memset (uiinfo, 0, sizeof (uiinfo)); - - i = popup_add_name_and_address (addr, uiinfo, i); - - uiinfo[i].type = GNOME_APP_UI_ITEM; - uiinfo[i].label = _("Add to Contacts"); - uiinfo[i].moreinfo = add_contacts_cb; - ++i; - - i = popup_add_query_change (addr, uiinfo, i); - - uiinfo[i].type = GNOME_APP_UI_ENDOFINFO; - pop = gnome_popup_menu_new (uiinfo); - return pop; -} - -static void -e_address_widget_popup (EAddressWidget *addr, GdkEventButton *ev) -{ - GtkWidget *pop; - - g_return_if_fail (addr && E_IS_ADDRESS_WIDGET (addr)); - - pop = addr->card ? popup_menu_card (addr) : popup_menu_nocard (addr); - - if (pop) - gnome_popup_menu_do_popup (pop, NULL, NULL, ev, addr, GTK_WIDGET (addr)); -} - -/* - * - * Bonobo Control Magic - * - */ - -enum { - ADDRESS_PROPERTY_NAME, - ADDRESS_PROPERTY_EMAIL, - ADDRESS_PROPERTY_TEXT, - ADDRESS_PROPERTY_BACKGROUND_RGB -}; - - -static void -get_prop (BonoboPropertyBag *bag, BonoboArg *arg, guint arg_id, CORBA_Environment *ev, gpointer user_data) -{ - EAddressWidget *addr = E_ADDRESS_WIDGET (user_data); - - switch (arg_id) { - - case ADDRESS_PROPERTY_NAME: - BONOBO_ARG_SET_STRING (arg, addr->name ? addr->name :""); - break; - - case ADDRESS_PROPERTY_EMAIL: - BONOBO_ARG_SET_STRING (arg, addr->email ? addr->email : ""); - break; - - case ADDRESS_PROPERTY_TEXT: - BONOBO_ARG_SET_STRING (arg, "?"); - break; - } -} - -static void -set_prop (BonoboPropertyBag *bag, const BonoboArg *arg, guint arg_id, CORBA_Environment *ev, gpointer user_data) -{ - EAddressWidget *addr = E_ADDRESS_WIDGET (user_data); - - switch (arg_id) { - case ADDRESS_PROPERTY_NAME: - e_address_widget_set_name (addr, BONOBO_ARG_GET_STRING (arg)); - break; - - case ADDRESS_PROPERTY_EMAIL: - e_address_widget_set_email (addr, BONOBO_ARG_GET_STRING (arg)); - break; - - case ADDRESS_PROPERTY_TEXT: - e_address_widget_set_text (addr, BONOBO_ARG_GET_STRING (arg)); - break; - - - case ADDRESS_PROPERTY_BACKGROUND_RGB: - { - gint bg = BONOBO_ARG_GET_INT (arg); - GdkColor color; - - color.red = (bg & 0xff0000) >> 8; - color.green = (bg & 0x00ff00); - color.blue = (bg & 0x0000ff) << 8; - - if (gdk_colormap_alloc_color (gtk_widget_get_colormap (GTK_WIDGET (addr)), &color, FALSE, TRUE)) { - GtkStyle *style = gtk_style_copy (gtk_widget_get_style (GTK_WIDGET (addr))); - style->bg[0] = color; - gtk_widget_set_style (GTK_WIDGET (addr), style); - } - } - - break; - } -} - -BonoboControl * -e_address_widget_factory_new_control (void) -{ - BonoboControl *control; - BonoboPropertyBag *bag; - GtkWidget *w; - - w = e_address_widget_new (); - gtk_widget_show (w); - - control = bonobo_control_new (w); - - bag = bonobo_property_bag_new (get_prop, set_prop, w); - bonobo_property_bag_add (bag, "name", ADDRESS_PROPERTY_NAME, - BONOBO_ARG_STRING, NULL, NULL, - BONOBO_PROPERTY_READABLE | BONOBO_PROPERTY_WRITEABLE); - - bonobo_property_bag_add (bag, "email", ADDRESS_PROPERTY_EMAIL, - BONOBO_ARG_STRING, NULL, NULL, - BONOBO_PROPERTY_READABLE | BONOBO_PROPERTY_WRITEABLE); - - bonobo_property_bag_add (bag, "text", ADDRESS_PROPERTY_TEXT, - BONOBO_ARG_STRING, NULL, NULL, - BONOBO_PROPERTY_READABLE | BONOBO_PROPERTY_WRITEABLE); - - bonobo_property_bag_add (bag, "background_rgb", ADDRESS_PROPERTY_BACKGROUND_RGB, - BONOBO_ARG_INT, NULL, NULL, - BONOBO_PROPERTY_WRITEABLE); - - bonobo_control_set_properties (control, bonobo_object_corba_objref (BONOBO_OBJECT (bag)), NULL); - bonobo_object_unref (BONOBO_OBJECT (bag)); - - return control; -} diff --git a/addressbook/gui/component/e-address-widget.h b/addressbook/gui/component/e-address-widget.h deleted file mode 100644 index 13e4a417d0..0000000000 --- a/addressbook/gui/component/e-address-widget.h +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * e-address-widget.h - * - * Copyright (C) 2001 Ximian, Inc. - * - * Developed by Jon Trowbridge - */ - -/* - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - */ - -#ifndef __E_ADDRESS_WIDGET_H__ -#define __E_ADDRESS_WIDGET_H__ - -#include -#include -#include -#include -#include -#include - -G_BEGIN_DECLS - -#define E_TYPE_ADDRESS_WIDGET (e_address_widget_get_type ()) -#define E_ADDRESS_WIDGET(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), E_TYPE_ADDRESS_WIDGET, EAddressWidget)) -#define E_ADDRESS_WIDGET_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), E_TYPE_ADDRESS_WIDGET, EAddressWidgetClass)) -#define E_IS_ADDRESS_WIDGET(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_TYPE_ADDRESS_WIDGET)) -#define E_IS_ADDRESS_WIDGET_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), E_TYPE_ADDRESS_WIDGET)) - -typedef struct _EAddressWidget EAddressWidget; -typedef struct _EAddressWidgetClass EAddressWidgetClass; - -struct _EAddressWidget { - GtkEventBox parent; - - gchar *name; - gchar *email; - - GtkWidget *name_widget; - GtkWidget *email_widget; - GtkWidget *spacer; - - guint query_idle_tag; - guint query_tag; - - ECard *card; - gboolean known_email; -}; - -struct _EAddressWidgetClass { - GtkEventBoxClass parent_class; -}; - -GType e_address_widget_get_type (void); - -void e_address_widget_set_name (EAddressWidget *, const gchar *name); -void e_address_widget_set_email (EAddressWidget *, const gchar *email); -void e_address_widget_set_text (EAddressWidget *, const gchar *text); - -void e_address_widget_construct (EAddressWidget *); -GtkWidget *e_address_widget_new (void); - -BonoboControl *e_address_widget_new_control (void); - -G_END_DECLS - -#endif /* __E_ADDRESS_WIDGET_H__ */ diff --git a/addressbook/gui/component/e-cardlist-model.c b/addressbook/gui/component/e-cardlist-model.c deleted file mode 100644 index be1ff3ddd2..0000000000 --- a/addressbook/gui/component/e-cardlist-model.c +++ /dev/null @@ -1,239 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * - * Author: - * Christopher James Lahey - * - * (C) 1999 Ximian, Inc. - */ - -#include -#include -#include -#include - -#include - -#include "e-cardlist-model.h" - -#define PARENT_TYPE e_table_model_get_type() - -static GObjectClass *parent_class = NULL; - -static void -e_cardlist_model_dispose(GObject *object) -{ - ECardlistModel *model = E_CARDLIST_MODEL(object); - int i; - - if (model->data != NULL) { - for ( i = 0; i < model->data_count; i++ ) { - g_object_unref(model->data[i]); - } - g_free(model->data); - model->data = NULL; - } - - if (G_OBJECT_CLASS (parent_class)->dispose) - (* G_OBJECT_CLASS (parent_class)->dispose) (object); -} - -/* This function returns the number of columns in our ETableModel. */ -static int -e_cardlist_model_col_count (ETableModel *etc) -{ - return E_CARD_SIMPLE_FIELD_LAST; -} - -/* This function returns the number of rows in our ETableModel. */ -static int -e_cardlist_model_row_count (ETableModel *etc) -{ - ECardlistModel *e_cardlist_model = E_CARDLIST_MODEL(etc); - return e_cardlist_model->data_count; -} - -/* This function returns the value at a particular point in our ETableModel. */ -static void * -e_cardlist_model_value_at (ETableModel *etc, int col, int row) -{ - ECardlistModel *e_cardlist_model = E_CARDLIST_MODEL(etc); - const char *value; - if ( col >= E_CARD_SIMPLE_FIELD_LAST - 1|| row >= e_cardlist_model->data_count ) - return NULL; - value = e_card_simple_get_const(e_cardlist_model->data[row], - col + 1); - return (void *)(value ? value : ""); -} - -/* This function sets the value at a particular point in our ETableModel. */ -static void -e_cardlist_model_set_value_at (ETableModel *etc, int col, int row, const void *val) -{ - ECardlistModel *e_cardlist_model = E_CARDLIST_MODEL(etc); - - if ( col >= E_CARD_SIMPLE_FIELD_LAST - 1|| row >= e_cardlist_model->data_count ) - return; - e_table_model_pre_change(etc); - e_card_simple_set(e_cardlist_model->data[row], - col + 1, - val); - - e_table_model_cell_changed(etc, col, row); -} - -/* This function returns whether a particular cell is editable. */ -static gboolean -e_cardlist_model_is_cell_editable (ETableModel *etc, int col, int row) -{ - return TRUE; -} - -/* This function duplicates the value passed to it. */ -static void * -e_cardlist_model_duplicate_value (ETableModel *etc, int col, const void *value) -{ - return g_strdup(value); -} - -/* This function frees the value passed to it. */ -static void -e_cardlist_model_free_value (ETableModel *etc, int col, void *value) -{ - g_free(value); -} - -static void * -e_cardlist_model_initialize_value (ETableModel *etc, int col) -{ - return g_strdup(""); -} - -static gboolean -e_cardlist_model_value_is_empty (ETableModel *etc, int col, const void *value) -{ - return !(value && *(char *)value); -} - -static char * -e_cardlist_model_value_to_string (ETableModel *etc, int col, const void *value) -{ - return g_strdup(value); -} - -void -e_cardlist_model_add(ECardlistModel *model, - ECard **cards, - int count) -{ - int i; - model->data = g_realloc(model->data, model->data_count + count * sizeof(ECard *)); - for (i = 0; i < count; i++) { - gboolean found = FALSE; - const gchar *id = e_card_get_id(cards[i]); - for ( i = 0; i < model->data_count; i++) { - if ( !strcmp(e_card_simple_get_id(model->data[i]), id) ) { - found = TRUE; - break; - } - } - if (!found) { - e_table_model_pre_change(E_TABLE_MODEL(model)); - g_object_ref(cards[i]); - model->data[model->data_count++] = e_card_simple_new (cards[i]); - e_table_model_row_inserted(E_TABLE_MODEL(model), model->data_count - 1); - } - } -} - -void -e_cardlist_model_remove(ECardlistModel *model, - const char *id) -{ - int i; - for ( i = 0; i < model->data_count; i++) { - if ( !strcmp(e_card_simple_get_id(model->data[i]), id) ) { - e_table_model_pre_change(E_TABLE_MODEL(model)); - g_object_unref(model->data[i]); - memmove(model->data + i, model->data + i + 1, (model->data_count - i - 1) * sizeof (ECard *)); - e_table_model_row_deleted(E_TABLE_MODEL(model), i); - } - } -} - -static void -e_cardlist_model_class_init (GObjectClass *object_class) -{ - ETableModelClass *model_class = (ETableModelClass *) object_class; - - parent_class = g_type_class_peek_parent (object_class); - - object_class->dispose = e_cardlist_model_dispose; - - model_class->column_count = e_cardlist_model_col_count; - model_class->row_count = e_cardlist_model_row_count; - model_class->value_at = e_cardlist_model_value_at; - model_class->set_value_at = e_cardlist_model_set_value_at; - model_class->is_cell_editable = e_cardlist_model_is_cell_editable; - model_class->duplicate_value = e_cardlist_model_duplicate_value; - model_class->free_value = e_cardlist_model_free_value; - model_class->initialize_value = e_cardlist_model_initialize_value; - model_class->value_is_empty = e_cardlist_model_value_is_empty; - model_class->value_to_string = e_cardlist_model_value_to_string; -} - -static void -e_cardlist_model_init (GObject *object) -{ - ECardlistModel *model = E_CARDLIST_MODEL(object); - model->data = NULL; - model->data_count = 0; -} - -ECard * -e_cardlist_model_get(ECardlistModel *model, - int row) -{ - if (model->data && row < model->data_count) { - ECard *card; - g_object_get(model->data[row], - "card", &card, - NULL); - return card; - } - return NULL; -} - -GType -e_cardlist_model_get_type (void) -{ - static GType aw_type = 0; - - if (!aw_type) { - static const GTypeInfo aw_info = { - sizeof (ECardlistModelClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) e_cardlist_model_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (ECardlistModel), - 0, /* n_preallocs */ - (GInstanceInitFunc) e_cardlist_model_init, - }; - - aw_type = g_type_register_static (PARENT_TYPE, "ECardlistModel", &aw_info, 0); - } - - return aw_type; -} - -ETableModel * -e_cardlist_model_new (void) -{ - ECardlistModel *et; - - et = g_object_new (E_TYPE_CARDLIST_MODEL, NULL); - - return E_TABLE_MODEL(et); -} diff --git a/addressbook/gui/component/e-cardlist-model.h b/addressbook/gui/component/e-cardlist-model.h deleted file mode 100644 index 0968e936fc..0000000000 --- a/addressbook/gui/component/e-cardlist-model.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -#ifndef _E_CARDLIST_MODEL_H_ -#define _E_CARDLIST_MODEL_H_ - -#include -#include -#include -#include - -#define E_TYPE_CARDLIST_MODEL (e_cardlist_model_get_type ()) -#define E_CARDLIST_MODEL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), E_TYPE_CARDLIST_MODEL, ECardlistModel)) -#define E_CARDLIST_MODEL_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), E_TYPE_CARDLIST_MODEL, ECardlistModelClass)) -#define E_IS_CARDLIST_MODEL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_TYPE_CARDLIST_MODEL)) -#define E_IS_CARDLIST_MODEL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), E_TYPE_CARDLIST_MODEL)) - -typedef struct { - ETableModel parent; - - /* item specific fields */ - ECardSimple **data; - int data_count; -} ECardlistModel; - - -typedef struct { - ETableModelClass parent_class; -} ECardlistModelClass; - - -GType e_cardlist_model_get_type (void); -ETableModel *e_cardlist_model_new (void); - -/* Returns object with an extra ref count. */ -ECard *e_cardlist_model_get (ECardlistModel *model, - int row); -void e_cardlist_model_add (ECardlistModel *model, - ECard **card, - int count); -void e_cardlist_model_remove (ECardlistModel *model, - const char *id); - -#endif /* _E_CARDLIST_MODEL_H_ */ diff --git a/addressbook/gui/component/select-names/Evolution-Addressbook-SelectNames.idl b/addressbook/gui/component/select-names/Evolution-Addressbook-SelectNames.idl index 2959597cc5..6feb6b54bb 100644 --- a/addressbook/gui/component/select-names/Evolution-Addressbook-SelectNames.idl +++ b/addressbook/gui/component/select-names/Evolution-Addressbook-SelectNames.idl @@ -14,78 +14,6 @@ module GNOME { module Evolution { module Addressbook { - interface SimpleCard : Bonobo::Unknown { - struct Arbitrary { - string key; - string type; - string value; - }; - - enum Field { - FileAs, - FullName, - Email, - PhonePrimary, - PhoneAssistant, - PhoneBusiness, - PhoneCallback, - PhoneCompany, - PhoneHome, - Org, - AddressBusiness, - AddressHome, - PhoneMobile, - PhoneCar, - PhoneBusinessFax, - PhoneHomeFax, - PhoneBusiness2, - PhoneHome2, - PhoneIsdn, - PhoneOther, - PhoneOtherFax, - PhonePager, - PhoneRadio, - PhoneTelex, - PhoneTtytdd, - AddressOther, - Email2, - Email3, - Url, - OrgUnit, - Office, - Title, - Role, - Manager, - Assistant, - Nickname, - Spouse, - Note, - Caluri, - Fburl, - Icscalendar, - Anniversary, - BirthDate, - Mailer, - NameOrOrg, - Categories, - FamilyName, - GivenName, - AdditionalName, - NameSuffix, - WantsHtml, - IsList, - Last - }; - - Arbitrary getArbitrary (in string key); - void setArbitrary (in string key, in string type, in string value); - - string get (in Field field); - void set (in Field field, in string value); - }; - - typedef sequence SimpleCardList; - interface SelectNames : Bonobo::Unknown { struct Section { string id; diff --git a/addressbook/gui/component/select-names/GNOME_Evolution_Addressbook_SelectNames.server.in.in b/addressbook/gui/component/select-names/GNOME_Evolution_Addressbook_SelectNames.server.in.in index 6e4d156051..80b138f1dc 100644 --- a/addressbook/gui/component/select-names/GNOME_Evolution_Addressbook_SelectNames.server.in.in +++ b/addressbook/gui/component/select-names/GNOME_Evolution_Addressbook_SelectNames.server.in.in @@ -17,7 +17,7 @@ + location="OAFIID:GNOME_Evolution_Addressbook_Factory_2"> @@ -28,4 +28,4 @@ - \ No newline at end of file + diff --git a/addressbook/gui/component/select-names/Makefile.am b/addressbook/gui/component/select-names/Makefile.am index 051a168815..b78e5b69fe 100644 --- a/addressbook/gui/component/select-names/Makefile.am +++ b/addressbook/gui/component/select-names/Makefile.am @@ -69,9 +69,7 @@ libeselectnames_la_SOURCES = \ e-select-names-text-model.c \ e-select-names-text-model.h \ e-select-names.c \ - e-select-names.h \ - e-simple-card-bonobo.c \ - e-simple-card-bonobo.h + e-select-names.h libeselectnames_la_LIBADD = \ $(top_builddir)/addressbook/backend/ebook/libebook.la \ diff --git a/addressbook/gui/component/select-names/e-select-names-bonobo.c b/addressbook/gui/component/select-names/e-select-names-bonobo.c index 10fc9caee7..f10fa3b804 100644 --- a/addressbook/gui/component/select-names/e-select-names-bonobo.c +++ b/addressbook/gui/component/select-names/e-select-names-bonobo.c @@ -25,7 +25,6 @@ #endif #include "e-select-names-bonobo.h" -#include "e-simple-card-bonobo.h" #include @@ -63,7 +62,6 @@ enum _EntryPropertyID { ENTRY_PROPERTY_ID_TEXT, ENTRY_PROPERTY_ID_ADDRESSES, ENTRY_PROPERTY_ID_DESTINATIONS, - ENTRY_PROPERTY_ID_SIMPLE_CARD_LIST, ENTRY_PROPERTY_ID_ALLOW_CONTACT_LISTS, ENTRY_PROPERTY_ID_ENTRY_CHANGED }; @@ -122,38 +120,6 @@ entry_get_property_fn (BonoboPropertyBag *bag, } break; - case ENTRY_PROPERTY_ID_SIMPLE_CARD_LIST: - { - ESelectNamesModel *model; - int count; - int i; - GNOME_Evolution_Addressbook_SimpleCardList *card_list; - - model = E_SELECT_NAMES_MODEL (g_object_get_data (G_OBJECT (w), "select_names_model")); - g_assert (model != NULL); - - count = e_select_names_model_count (model); - - card_list = GNOME_Evolution_Addressbook_SimpleCardList__alloc (); - card_list->_buffer = CORBA_sequence_GNOME_Evolution_Addressbook_SimpleCard_allocbuf (count); - card_list->_maximum = count; - card_list->_length = count; - - for (i = 0; i < count; i++) { - const EDestination *destination = e_select_names_model_get_destination (model, i); - const ECard *card = e_destination_get_card (destination); - ECardSimple *simple = e_card_simple_new ((ECard *) card); - ESimpleCardBonobo *simple_card = e_simple_card_bonobo_new (simple); - g_object_unref (simple); - - card_list->_buffer[i] = bonobo_object_corba_objref (BONOBO_OBJECT (simple_card)); - } - - CORBA_free (*(GNOME_Evolution_Addressbook_SimpleCardList **)arg->_value); - BONOBO_ARG_SET_GENERAL (arg, *card_list, TC_GNOME_Evolution_Addressbook_SimpleCardList, GNOME_Evolution_Addressbook_SimpleCardList, NULL); - } - break; - case ENTRY_PROPERTY_ID_ALLOW_CONTACT_LISTS: { ESelectNamesCompletion *comp; @@ -195,7 +161,7 @@ entry_set_property_fn (BonoboPropertyBag *bag, g_assert (model != NULL); e_entry_set_text (E_ENTRY (w), BONOBO_ARG_GET_STRING (arg)); - e_select_names_model_cardify_all (model, NULL, 0); + e_select_names_model_load_all_contacts (model, NULL); break; } @@ -206,7 +172,7 @@ entry_set_property_fn (BonoboPropertyBag *bag, g_assert (model != NULL); e_select_names_model_import_destinationv (model, BONOBO_ARG_GET_STRING (arg)); - e_select_names_model_cardify_all (model, NULL, 0); + e_select_names_model_load_all_contacts (model, NULL); break; } @@ -499,9 +465,6 @@ impl_SelectNames_get_entry_for_section (PortableServer_Servant servant, bonobo_property_bag_add (property_bag, "destinations", ENTRY_PROPERTY_ID_DESTINATIONS, BONOBO_ARG_STRING, NULL, NULL, BONOBO_PROPERTY_READABLE | BONOBO_PROPERTY_WRITEABLE); - bonobo_property_bag_add (property_bag, "simple_card_list", ENTRY_PROPERTY_ID_SIMPLE_CARD_LIST, - TC_GNOME_Evolution_Addressbook_SimpleCardList, NULL, NULL, - BONOBO_PROPERTY_READABLE); bonobo_property_bag_add (property_bag, "allow_contact_lists", ENTRY_PROPERTY_ID_ALLOW_CONTACT_LISTS, BONOBO_ARG_BOOLEAN, NULL, NULL, BONOBO_PROPERTY_READABLE | BONOBO_PROPERTY_WRITEABLE); diff --git a/addressbook/gui/component/select-names/e-select-names-completion.c b/addressbook/gui/component/select-names/e-select-names-completion.c index 5a9fc2deb4..7bfbfd2a5a 100644 --- a/addressbook/gui/component/select-names/e-select-names-completion.c +++ b/addressbook/gui/component/select-names/e-select-names-completion.c @@ -34,17 +34,17 @@ #include -#include -#include -#include -#include +#include +#include +#include +#include typedef struct { EBook *book; guint book_view_tag; EBookView *book_view; ESelectNamesCompletion *comp; - guint card_added_tag; + guint contacts_added_tag; guint seq_complete_tag; gboolean sequence_complete_received; @@ -76,7 +76,7 @@ static void e_select_names_completion_init (ESelectNamesCompletion *); static void e_select_names_completion_dispose (GObject *object); static void e_select_names_completion_got_book_view_cb (EBook *book, EBookStatus status, EBookView *view, gpointer user_data); -static void e_select_names_completion_card_added_cb (EBookView *, const GList *cards, gpointer user_data); +static void e_select_names_completion_contacts_added_cb (EBookView *, const GList *cards, gpointer user_data); static void e_select_names_completion_seq_complete_cb (EBookView *, EBookViewStatus status, gpointer user_data); static void e_select_names_completion_do_query (ESelectNamesCompletion *, const gchar *query_text, gint pos, gint limit); @@ -95,7 +95,7 @@ static FILE *out; */ typedef gchar *(*BookQuerySExp) (ESelectNamesCompletion *); -typedef ECompletionMatch *(*BookQueryMatchTester) (ESelectNamesCompletion *, EDestination *); +typedef ECompletionMatch *(*BookQueryMatchTester) (ESelectNamesCompletion *, EABDestination *); static int utf8_casefold_collate_len (const gchar *str1, const gchar *str2, int len) @@ -125,14 +125,16 @@ our_match_destroy (ECompletionMatch *match) } static ECompletionMatch * -make_match (EDestination *dest, const gchar *menu_form, double score) +make_match (EABDestination *dest, const gchar *menu_form, double score) { ECompletionMatch *match; - ECard *card = e_destination_get_card (dest); +#if notyet + EContact *contact = eab_destination_get_contact (dest); +#endif - match = e_completion_match_new (e_destination_get_name (dest), menu_form, score); + match = e_completion_match_new (eab_destination_get_name (dest), menu_form, score); - e_completion_match_set_text (match, e_destination_get_name (dest), menu_form); + e_completion_match_set_text (match, eab_destination_get_name (dest), menu_form); /* Reject any match that has null text fields. */ if (! (e_completion_match_get_match_text (match) && e_completion_match_get_menu_text (match))) { @@ -140,10 +142,15 @@ make_match (EDestination *dest, const gchar *menu_form, double score) return NULL; } +#if notyet + /* XXX toshok - EContact doesn't have the use_score stuff */ /* Since we sort low to high, we negate so that larger use scores will come first */ - match->sort_major = card ? -floor (e_card_get_use_score (card)) : 0; + match->sort_major = contact ? -floor (e_contact_get_use_score (contact)) : 0; +#else + match->sort_major = 0; +#endif - match->sort_minor = e_destination_get_email_num (dest); + match->sort_minor = eab_destination_get_email_num (dest); match->user_data = dest; g_object_ref (dest); @@ -166,31 +173,33 @@ sexp_nickname (ESelectNamesCompletion *comp) } static ECompletionMatch * -match_nickname (ESelectNamesCompletion *comp, EDestination *dest) +match_nickname (ESelectNamesCompletion *comp, EABDestination *dest) { ECompletionMatch *match = NULL; gint len; - ECard *card = e_destination_get_card (dest); + EContact *contact = eab_destination_get_contact (dest); double score; + const char *nickname; - if (card->nickname == NULL) + nickname = e_contact_get_const (contact, E_CONTACT_NICKNAME); + if (nickname == NULL) return NULL; len = g_utf8_strlen (comp->priv->query_text, -1); - if (card->nickname && !utf8_casefold_collate_len (comp->priv->query_text, card->nickname, len)) { + if (nickname && !utf8_casefold_collate_len (comp->priv->query_text, nickname, len)) { const gchar *name; gchar *str; score = len * 2; /* nickname gives 2 points per matching character */ - if (len == g_utf8_strlen (card->nickname, -1)) /* boost score on an exact match */ + if (len == g_utf8_strlen (nickname, -1)) /* boost score on an exact match */ score *= 10; - name = e_destination_get_name (dest); + name = eab_destination_get_name (dest); if (name && *name) - str = g_strdup_printf ("'%s' %s <%s>", card->nickname, name, e_destination_get_email (dest)); + str = g_strdup_printf ("'%s' %s <%s>", nickname, name, eab_destination_get_email (dest)); else - str = g_strdup_printf ("'%s' <%s>", card->nickname, e_destination_get_email (dest)); + str = g_strdup_printf ("'%s' <%s>", nickname, eab_destination_get_email (dest)); match = make_match (dest, str, score); g_free (str); @@ -210,17 +219,17 @@ sexp_email (ESelectNamesCompletion *comp) } static ECompletionMatch * -match_email (ESelectNamesCompletion *comp, EDestination *dest) +match_email (ESelectNamesCompletion *comp, EABDestination *dest) { ECompletionMatch *match; gint len = strlen (comp->priv->query_text); - const gchar *name = e_destination_get_name (dest); - const gchar *email = e_destination_get_email (dest); + const gchar *name = eab_destination_get_name (dest); + const gchar *email = eab_destination_get_email (dest); double score; if (email && !utf8_casefold_collate_len (comp->priv->query_text, email, len) - && !e_destination_is_evolution_list (dest)) { + && !eab_destination_is_evolution_list (dest)) { gchar *str; @@ -294,78 +303,82 @@ sexp_name (ESelectNamesCompletion *comp) } static ECompletionMatch * -match_name (ESelectNamesCompletion *comp, EDestination *dest) +match_name (ESelectNamesCompletion *comp, EABDestination *dest) { ECompletionMatch *final_match = NULL; gchar *menu_text = NULL; - ECard *card; + EContact *contact; const gchar *email; gint match_len = 0; - ECardMatchType match; - ECardMatchPart first_match; + EABContactMatchType match; + EABContactMatchPart first_match; double score = 0; gboolean have_given, have_additional, have_family; + EContactName *contact_name; - card = e_destination_get_card (dest); - - if (card->name == NULL) + contact = eab_destination_get_contact (dest); + + contact_name = e_contact_get (contact, E_CONTACT_NAME); + if (!contact_name) return NULL; - email = e_destination_get_email (dest); + email = eab_destination_get_email (dest); - match = e_card_compare_name_to_string_full (card, comp->priv->query_text, TRUE /* yes, allow partial matches */, - NULL, &first_match, &match_len); + match = eab_contact_compare_name_to_string_full (contact, comp->priv->query_text, TRUE /* yes, allow partial matches */, + NULL, &first_match, &match_len); - if (match <= E_CARD_MATCH_NONE) + if (match <= EAB_CONTACT_MATCH_NONE) { + e_contact_name_free (contact_name); return NULL; + } score = match_len * 3; /* three points per match character */ - have_given = card->name->given && *card->name->given; - have_additional = card->name->additional && *card->name->additional; - have_family = card->name->family && *card->name->family; + have_given = contact_name->given && *contact_name->given; + have_additional = contact_name->additional && *contact_name->additional; + have_family = contact_name->family && *contact_name->family; - if (e_card_evolution_list (card)) { + if (e_contact_get (contact, E_CONTACT_IS_LIST)) { - menu_text = e_card_name_to_string (card->name); + menu_text = e_contact_name_to_string (contact_name); - } else if (first_match == E_CARD_MATCH_PART_GIVEN_NAME) { + } else if (first_match == EAB_CONTACT_MATCH_PART_GIVEN_NAME) { if (have_family) - menu_text = g_strdup_printf ("%s %s <%s>", card->name->given, card->name->family, email); + menu_text = g_strdup_printf ("%s %s <%s>", contact_name->given, contact_name->family, email); else - menu_text = g_strdup_printf ("%s <%s>", card->name->given, email); + menu_text = g_strdup_printf ("%s <%s>", contact_name->given, email); - } else if (first_match == E_CARD_MATCH_PART_ADDITIONAL_NAME) { + } else if (first_match == EAB_CONTACT_MATCH_PART_ADDITIONAL_NAME) { if (have_given) { menu_text = g_strdup_printf ("%s%s%s, %s <%s>", - card->name->additional, + contact_name->additional, have_family ? " " : "", - have_family ? card->name->family : "", - card->name->given, + have_family ? contact_name->family : "", + contact_name->given, email); } else { menu_text = g_strdup_printf ("%s%s%s <%s>", - card->name->additional, + contact_name->additional, have_family ? " " : "", - have_family ? card->name->family : "", + have_family ? contact_name->family : "", email); } - } else if (first_match == E_CARD_MATCH_PART_FAMILY_NAME) { + } else if (first_match == EAB_CONTACT_MATCH_PART_FAMILY_NAME) { if (have_given) menu_text = g_strdup_printf ("%s, %s%s%s <%s>", - card->name->family, - card->name->given, + contact_name->family, + contact_name->given, have_additional ? " " : "", - have_additional ? card->name->additional : "", + have_additional ? contact_name->additional : "", email); else - menu_text = g_strdup_printf ("%s <%s>", card->name->family, email); + menu_text = g_strdup_printf ("%s <%s>", contact_name->family, email); } else { /* something funny happened */ @@ -379,6 +392,8 @@ match_name (ESelectNamesCompletion *comp, EDestination *dest) g_free (menu_text); } + e_contact_name_free (contact_name); + return final_match; } @@ -393,7 +408,7 @@ sexp_file_as (ESelectNamesCompletion *comp) } static ECompletionMatch * -match_file_as (ESelectNamesCompletion *comp, EDestination *dest) +match_file_as (ESelectNamesCompletion *comp, EABDestination *dest) { const gchar *name; const gchar *email; @@ -402,8 +417,8 @@ match_file_as (ESelectNamesCompletion *comp, EDestination *dest) double score = 0.00001; ECompletionMatch *match; - name = e_destination_get_name (dest); - email = e_destination_get_email (dest); + name = eab_destination_get_name (dest); + email = eab_destination_get_email (dest); if (!(name && *name)) return NULL; @@ -491,13 +506,13 @@ book_query_sexp (ESelectNamesCompletion *comp) * string that applies to a given destination. */ static ECompletionMatch * -book_query_score (ESelectNamesCompletion *comp, EDestination *dest) +book_query_score (ESelectNamesCompletion *comp, EABDestination *dest) { ECompletionMatch *best_match = NULL; gint i; g_return_val_if_fail (E_IS_SELECT_NAMES_COMPLETION (comp), NULL); - g_return_val_if_fail (E_IS_DESTINATION (dest), NULL); + g_return_val_if_fail (EAB_IS_DESTINATION (dest), NULL); if (! (comp->priv->query_text && *comp->priv->query_text)) return NULL; @@ -506,7 +521,7 @@ book_query_score (ESelectNamesCompletion *comp, EDestination *dest) ECompletionMatch *this_match = NULL; - if (book_queries[i].tester && e_destination_get_card (dest)) { + if (book_queries[i].tester && eab_destination_get_contact (dest)) { this_match = book_queries[i].tester (comp, dest); } @@ -524,18 +539,18 @@ book_query_score (ESelectNamesCompletion *comp, EDestination *dest) } static void -book_query_process_card_list (ESelectNamesCompletion *comp, const GList *cards) +book_query_process_card_list (ESelectNamesCompletion *comp, const GList *contacts) { - while (cards) { - ECard *card = E_CARD (cards->data); + while (contacts) { + EContact *contact = E_CONTACT (contacts->data); - if (e_card_evolution_list (card)) { + if (e_contact_get (contact, E_CONTACT_IS_LIST)) { if (comp->priv->match_contact_lists) { - EDestination *dest = e_destination_new (); + EABDestination *dest = eab_destination_new (); ECompletionMatch *match; - e_destination_set_card (dest, card, 0); + eab_destination_set_contact (dest, contact, 0); match = book_query_score (comp, dest); if (match && match->score > 0) { e_completion_found_match (E_COMPLETION (comp), match); @@ -546,31 +561,38 @@ book_query_process_card_list (ESelectNamesCompletion *comp, const GList *cards) } - } else if (card->email) { - gint i; - for (i=0; iemail); ++i) { - EDestination *dest = e_destination_new (); - const gchar *email; - ECompletionMatch *match; + } + else { + GList *email = e_contact_get (contact, E_CONTACT_EMAIL); + if (email) { + GList *iter; + gint i; + for (i=0, iter = email; iter; ++i, iter = iter->next) { + EABDestination *dest = eab_destination_new (); + gchar *e; + ECompletionMatch *match; - e_destination_set_card (dest, card, i); - email = e_destination_get_email (dest); + eab_destination_set_contact (dest, contact, i); + e = iter->data; - if (email && *email) { + if (e && *e) { - match = book_query_score (comp, dest); - if (match && match->score > 0) { - e_completion_found_match (E_COMPLETION (comp), match); - } else { - e_completion_match_unref (match); + match = book_query_score (comp, dest); + if (match && match->score > 0) { + e_completion_found_match (E_COMPLETION (comp), match); + } else { + e_completion_match_unref (match); + } } - } - g_object_unref (dest); + g_object_unref (dest); + } } + g_list_foreach (email, (GFunc)g_free, NULL); + g_list_free (email); } - cards = g_list_next (cards); + contacts = contacts->next; } } @@ -640,9 +662,9 @@ e_select_names_completion_clear_book_data (ESelectNamesCompletion *comp) for (l = comp->priv->book_data; l; l = l->next) { ESelectNamesCompletionBookData *book_data = l->data; - if (book_data->card_added_tag) { - g_signal_handler_disconnect (book_data->book_view, book_data->card_added_tag); - book_data->card_added_tag = 0; + if (book_data->contacts_added_tag) { + g_signal_handler_disconnect (book_data->book_view, book_data->contacts_added_tag); + book_data->contacts_added_tag = 0; } if (book_data->seq_complete_tag) { @@ -756,7 +778,7 @@ e_select_names_completion_got_book_view_cb (EBook *book, EBookStatus status, EBo book_data = (ESelectNamesCompletionBookData*)user_data; comp = book_data->comp; - if (status != E_BOOK_STATUS_SUCCESS) { + if (status != E_BOOK_ERROR_OK) { comp->priv->pending_completion_seq--; if (!comp->priv->pending_completion_seq) e_select_names_completion_done (comp); @@ -765,9 +787,9 @@ e_select_names_completion_got_book_view_cb (EBook *book, EBookStatus status, EBo book_data->book_view_tag = 0; - if (book_data->card_added_tag) { - g_signal_handler_disconnect (book_data->book_view, book_data->card_added_tag); - book_data->card_added_tag = 0; + if (book_data->contacts_added_tag) { + g_signal_handler_disconnect (book_data->book_view, book_data->contacts_added_tag); + book_data->contacts_added_tag = 0; } if (book_data->seq_complete_tag) { g_signal_handler_disconnect (book_data->book_view, book_data->seq_complete_tag); @@ -781,10 +803,10 @@ e_select_names_completion_got_book_view_cb (EBook *book, EBookStatus status, EBo } book_data->book_view = view; - book_data->card_added_tag = + book_data->contacts_added_tag = g_signal_connect (view, - "card_added", - G_CALLBACK (e_select_names_completion_card_added_cb), + "contacts_added", + G_CALLBACK (e_select_names_completion_contacts_added_cb), book_data); book_data->seq_complete_tag = @@ -792,11 +814,14 @@ e_select_names_completion_got_book_view_cb (EBook *book, EBookStatus status, EBo "sequence_complete", G_CALLBACK (e_select_names_completion_seq_complete_cb), book_data); + + e_book_view_start (view); + book_data->sequence_complete_received = FALSE; } static void -e_select_names_completion_card_added_cb (EBookView *book_view, const GList *cards, gpointer user_data) +e_select_names_completion_contacts_added_cb (EBookView *book_view, const GList *cards, gpointer user_data) { ESelectNamesCompletionBookData *book_data = user_data; ESelectNamesCompletion *comp = book_data->comp; @@ -834,7 +859,7 @@ e_select_names_completion_seq_complete_cb (EBookView *book_view, EBookViewStatus } if (book_data->cached_query_text - && status == E_BOOK_STATUS_SUCCESS + && status == E_BOOK_ERROR_OK && !book_data->cache_complete && !strcmp (book_data->cached_query_text, comp->priv->query_text)) book_data->cache_complete = TRUE; @@ -845,9 +870,9 @@ e_select_names_completion_seq_complete_cb (EBookView *book_view, EBookViewStatus if (!book_data->sequence_complete_received) { book_data->sequence_complete_received = TRUE; - if (book_data->card_added_tag) { - g_signal_handler_disconnect (book_data->book_view, book_data->card_added_tag); - book_data->card_added_tag = 0; + if (book_data->contacts_added_tag) { + g_signal_handler_disconnect (book_data->book_view, book_data->contacts_added_tag); + book_data->contacts_added_tag = 0; } if (book_data->seq_complete_tag) { g_signal_handler_disconnect (book_data->book_view, book_data->seq_complete_tag); @@ -888,13 +913,15 @@ e_select_names_completion_stop_query (ESelectNamesCompletion *comp) for (l = comp->priv->book_data; l; l = l->next) { ESelectNamesCompletionBookData *book_data = l->data; if (book_data->book_view_tag) { +#if notyet e_book_cancel (book_data->book, book_data->book_view_tag); +#endif book_data->book_view_tag = 0; } if (book_data->book_view) { - if (book_data->card_added_tag) { - g_signal_handler_disconnect (book_data->book_view, book_data->card_added_tag); - book_data->card_added_tag = 0; + if (book_data->contacts_added_tag) { + g_signal_handler_disconnect (book_data->book_view, book_data->contacts_added_tag); + book_data->contacts_added_tag = 0; } if (book_data->seq_complete_tag) { g_signal_handler_disconnect (book_data->book_view, book_data->seq_complete_tag); @@ -977,13 +1004,10 @@ e_select_names_completion_start_query (ESelectNamesCompletion *comp, const gchar e_select_names_completion_clear_cache (book_data); book_data->cached_query_text = g_strdup (query_text); - book_data->book_view_tag = e_book_get_completion_view (book_data->book, + book_data->book_view_tag = e_book_async_get_book_view (book_data->book, sexp, e_select_names_completion_got_book_view_cb, book_data); - if (! book_data->book_view_tag) - g_warning ("Exception calling e_book_get_completion_view"); - else - comp->priv->pending_completion_seq++; + comp->priv->pending_completion_seq++; } if (out) diff --git a/addressbook/gui/component/select-names/e-select-names-completion.h b/addressbook/gui/component/select-names/e-select-names-completion.h index 6565208378..435fe80041 100644 --- a/addressbook/gui/component/select-names/e-select-names-completion.h +++ b/addressbook/gui/component/select-names/e-select-names-completion.h @@ -28,7 +28,7 @@ #define E_SELECT_NAMES_COMPLETION_H #include -#include +#include #include "e-select-names-text-model.h" G_BEGIN_DECLS diff --git a/addressbook/gui/component/select-names/e-select-names-manager.c b/addressbook/gui/component/select-names/e-select-names-manager.c index a3875cea97..e095f7308f 100644 --- a/addressbook/gui/component/select-names/e-select-names-manager.c +++ b/addressbook/gui/component/select-names/e-select-names-manager.c @@ -24,8 +24,8 @@ #include "e-select-names-completion.h" #include "e-select-names-popup.h" #include "e-folder-list.h" -#include -#include +#include +#include #include "addressbook/gui/component/addressbook.h" #include @@ -175,7 +175,7 @@ focus_in_cb (GtkWidget *w, GdkEventFocus *ev, gpointer user_data) entry->cleaning_tag = 0; } - e_select_names_model_cancel_cardify_all (entry->model); + e_select_names_model_cancel_all_contact_load (entry->model); return FALSE; } @@ -189,7 +189,7 @@ focus_out_cb (GtkWidget *w, GdkEventFocus *ev, gpointer user_data) gboolean visible = e_entry_completion_popup_is_visible (entry->entry); if (! visible) { - e_select_names_model_cardify_all (entry->model, entry->manager->completion_book, 100); + e_select_names_model_load_all_contacts (entry->model, entry->manager->completion_book, 100); if (entry->cleaning_tag == 0) entry->cleaning_tag = gtk_timeout_add (100, clean_cb, entry); } @@ -205,7 +205,7 @@ completion_popup_cb (EEntry *w, gint visible, gpointer user_data) ESelectNamesManagerEntry *entry = user_data; if (!visible && !GTK_WIDGET_HAS_FOCUS (GTK_WIDGET (entry->entry->canvas))) - e_select_names_model_cardify_all (entry->model, entry->manager->completion_book, 0); + e_select_names_model_load_all_contacts (entry->model, entry->manager->completion_book, 0); #endif } @@ -214,14 +214,14 @@ completion_handler (EEntry *entry, ECompletionMatch *match) { ESelectNamesManagerEntry *mgr_entry; ESelectNamesTextModel *text_model; - EDestination *dest; + EABDestination *dest; gint i, pos, start_pos, len; if (match == NULL || match->user_data == NULL) return; mgr_entry = get_entry_info (entry); - dest = E_DESTINATION (match->user_data); + dest = EAB_DESTINATION (match->user_data); /* Sometimes I really long for garbage collection. Reference counting makes you feel 31337, but sometimes it is just a @@ -377,7 +377,7 @@ e_select_names_manager_discard_saved_models (ESelectNamesManager *manager) static void open_book_cb (EBook *book, EBookStatus status, ESelectNamesManager *manager) { - if (status == E_BOOK_STATUS_SUCCESS) { + if (status == E_BOOK_ERROR_OK) { GList *l; for (l = manager->entries; l; l = l->next) { ESelectNamesManagerEntry *entry = l->data; @@ -398,15 +398,10 @@ load_completion_books (ESelectNamesManager *manager) EFolderListItem *f; for (f = folders; f && f->physical_uri; f++) { - char *uri; EBook *book = e_book_new (); g_object_ref (manager); /* ref ourself before our async call */ - uri = e_book_expand_uri (f->physical_uri); - - addressbook_load_uri (book, uri, (EBookCallback)open_book_cb, manager); - - g_free (uri); + addressbook_load_uri (book, f->physical_uri, (EBookCallback)open_book_cb, manager); } e_folder_list_free_items (folders); } @@ -485,7 +480,7 @@ e_select_names_manager_new (void) ESelectNamesManager *manager = g_object_new (E_TYPE_SELECT_NAMES_MANAGER, NULL); EConfigListener *db; - db = e_book_get_config_database(); + db = eab_get_config_database(); manager->listener_id = g_signal_connect (db, "key_changed", @@ -685,7 +680,7 @@ e_select_names_manager_dispose (GObject *object) } if (manager->listener_id) { - g_signal_handler_disconnect (e_book_get_config_database(), manager->listener_id); + g_signal_handler_disconnect (eab_get_config_database(), manager->listener_id); manager->listener_id = 0; } diff --git a/addressbook/gui/component/select-names/e-select-names-model.c b/addressbook/gui/component/select-names/e-select-names-model.c index 6c3cb0f9c6..d95aebde5d 100644 --- a/addressbook/gui/component/select-names/e-select-names-model.c +++ b/addressbook/gui/component/select-names/e-select-names-model.c @@ -19,7 +19,7 @@ #include "e-select-names-model.h" #include "e-select-names-marshal.h" -#include "addressbook/backend/ebook/e-card-simple.h" +#include "addressbook/backend/ebook/e-contact.h" #define MAX_LENGTH 2047 @@ -35,14 +35,14 @@ static guint e_select_names_model_signals[E_SELECT_NAMES_MODEL_LAST_SIGNAL] = { /* Object argument IDs */ enum { ARG_0, - ARG_CARD, + ARG_CONTACT, }; struct _ESelectNamesModelPrivate { gchar *id; gchar *title; - GList *data; /* of EDestination */ + GList *data; /* of EABDestination */ gint limit; @@ -159,7 +159,7 @@ e_select_names_model_changed (ESelectNamesModel *model) } static void -destination_changed_proxy (EDestination *dest, gpointer closure) +destination_changed_proxy (EABDestination *dest, gpointer closure) { e_select_names_model_changed (E_SELECT_NAMES_MODEL (closure)); } @@ -184,7 +184,7 @@ e_select_names_model_duplicate (ESelectNamesModel *old) model->priv->title = g_strdup (old->priv->title); for (iter = old->priv->data; iter != NULL; iter = g_list_next (iter)) { - EDestination *dup = e_destination_copy (E_DESTINATION (iter->data)); + EABDestination *dup = eab_destination_copy (EAB_DESTINATION (iter->data)); e_select_names_model_append (model, dup); } @@ -212,8 +212,8 @@ e_select_names_model_get_textification (ESelectNamesModel *model, const char *se GList *iter = model->priv->data; while (iter) { - EDestination *dest = E_DESTINATION (iter->data); - strv[i] = (gchar *) e_destination_get_textrep (dest, FALSE); + EABDestination *dest = EAB_DESTINATION (iter->data); + strv[i] = (gchar *) eab_destination_get_textrep (dest, FALSE); ++i; iter = g_list_next (iter); } @@ -252,8 +252,8 @@ e_select_names_model_get_address_text (ESelectNamesModel *model, const char *sep GList *iter = model->priv->data; while (iter) { - EDestination *dest = E_DESTINATION (iter->data); - strv[i] = (gchar *) e_destination_get_address (dest); + EABDestination *dest = EAB_DESTINATION (iter->data); + strv[i] = (gchar *) eab_destination_get_address (dest); if (strv[i]) ++i; iter = g_list_next (iter); @@ -304,43 +304,42 @@ e_select_names_model_at_limit (ESelectNamesModel *model) return model->priv->limit >= 0 && g_list_length (model->priv->data) >= model->priv->limit; } -const EDestination * +const EABDestination * e_select_names_model_get_destination (ESelectNamesModel *model, gint index) { g_return_val_if_fail (model && E_IS_SELECT_NAMES_MODEL (model), NULL); g_return_val_if_fail (0 <= index, NULL); g_return_val_if_fail (index < g_list_length (model->priv->data), NULL); - return E_DESTINATION (g_list_nth_data (model->priv->data, index)); + return EAB_DESTINATION (g_list_nth_data (model->priv->data, index)); } gchar * e_select_names_model_export_destinationv (ESelectNamesModel *model) { - EDestination **destv; + EABDestination **destv; gchar *str; gint i, len = 0; GList *j; g_return_val_if_fail (model && E_IS_SELECT_NAMES_MODEL (model), NULL); len = g_list_length (model->priv->data); - destv = g_new0 (EDestination *, len+1); + destv = g_new0 (EABDestination *, len+1); for (i=0, j = model->priv->data; j != NULL; j = g_list_next (j)) { - EDestination *dest = E_DESTINATION (j->data); + EABDestination *dest = EAB_DESTINATION (j->data); if (dest) destv[i++] = dest; } - str = e_destination_exportv (destv); + str = eab_destination_exportv (destv); g_free (destv); return str; } -static -void send_changed (EDestination *dest, ECard *card, gpointer closure) +static void send_changed (EABDestination *dest, EContact *contact, gpointer closure) { ESelectNamesModel *model = closure; e_select_names_model_changed (model); @@ -350,12 +349,12 @@ void e_select_names_model_import_destinationv (ESelectNamesModel *model, gchar *destinationv) { - EDestination **destv; + EABDestination **destv; gint i; g_return_if_fail (model && E_IS_SELECT_NAMES_MODEL (model)); - destv = e_destination_importv (destinationv); + destv = eab_destination_importv (destinationv); e_select_names_model_delete_all (model); @@ -363,30 +362,30 @@ e_select_names_model_import_destinationv (ESelectNamesModel *model, return; for (i = 0; destv[i]; i++) { - e_destination_use_card (destv[i], send_changed, model); + eab_destination_use_contact (destv[i], send_changed, model); e_select_names_model_append (model, destv[i]); } g_free (destv); } -ECard * -e_select_names_model_get_card (ESelectNamesModel *model, gint index) +EContact * +e_select_names_model_get_contact (ESelectNamesModel *model, gint index) { - const EDestination *dest; + const EABDestination *dest; g_return_val_if_fail (model && E_IS_SELECT_NAMES_MODEL (model), NULL); g_return_val_if_fail (0 <= index, NULL); g_return_val_if_fail (index < g_list_length (model->priv->data), NULL); dest = e_select_names_model_get_destination (model, index); - return dest ? e_destination_get_card (dest) : NULL; + return dest ? eab_destination_get_contact (dest) : NULL; } const gchar * e_select_names_model_get_string (ESelectNamesModel *model, gint index) { - const EDestination *dest; + const EABDestination *dest; g_return_val_if_fail (model && E_IS_SELECT_NAMES_MODEL (model), NULL); g_return_val_if_fail (0 <= index, NULL); @@ -394,11 +393,11 @@ e_select_names_model_get_string (ESelectNamesModel *model, gint index) dest = e_select_names_model_get_destination (model, index); - return dest ? e_destination_get_textrep (dest, FALSE) : ""; + return dest ? eab_destination_get_textrep (dest, FALSE) : ""; } static void -connect_destination (ESelectNamesModel *model, EDestination *dest) +connect_destination (ESelectNamesModel *model, EABDestination *dest) { g_signal_connect (dest, "changed", @@ -407,21 +406,21 @@ connect_destination (ESelectNamesModel *model, EDestination *dest) } static void -disconnect_destination (ESelectNamesModel *model, EDestination *dest) +disconnect_destination (ESelectNamesModel *model, EABDestination *dest) { g_signal_handlers_disconnect_by_func (dest, destination_changed_proxy, model); } gboolean -e_select_names_model_contains (ESelectNamesModel *model, const EDestination *dest) +e_select_names_model_contains (ESelectNamesModel *model, const EABDestination *dest) { GList *iter; g_return_val_if_fail (E_IS_SELECT_NAMES_MODEL (model), FALSE); - g_return_val_if_fail (E_IS_DESTINATION (dest), FALSE); + g_return_val_if_fail (EAB_IS_DESTINATION (dest), FALSE); for (iter = model->priv->data; iter != NULL; iter = g_list_next (iter)) { - if (iter->data != NULL && e_destination_equal (dest, E_DESTINATION (iter->data))) + if (iter->data != NULL && eab_destination_equal (dest, EAB_DESTINATION (iter->data))) return TRUE; } @@ -429,12 +428,12 @@ e_select_names_model_contains (ESelectNamesModel *model, const EDestination *des } void -e_select_names_model_insert (ESelectNamesModel *model, gint index, EDestination *dest) +e_select_names_model_insert (ESelectNamesModel *model, gint index, EABDestination *dest) { g_return_if_fail (model != NULL); g_return_if_fail (E_IS_SELECT_NAMES_MODEL (model)); g_return_if_fail (0 <= index && index <= g_list_length (model->priv->data)); - g_return_if_fail (dest && E_IS_DESTINATION (dest)); + g_return_if_fail (dest && EAB_IS_DESTINATION (dest)); if (e_select_names_model_at_limit (model)) { /* FIXME: This is bad. */ @@ -452,10 +451,10 @@ e_select_names_model_insert (ESelectNamesModel *model, gint index, EDestination } void -e_select_names_model_append (ESelectNamesModel *model, EDestination *dest) +e_select_names_model_append (ESelectNamesModel *model, EABDestination *dest) { g_return_if_fail (model && E_IS_SELECT_NAMES_MODEL (model)); - g_return_if_fail (dest && E_IS_DESTINATION (dest)); + g_return_if_fail (dest && EAB_IS_DESTINATION (dest)); if (e_select_names_model_at_limit (model)) { /* FIXME: This is bad. */ @@ -473,7 +472,7 @@ e_select_names_model_append (ESelectNamesModel *model, EDestination *dest) } void -e_select_names_model_replace (ESelectNamesModel *model, gint index, EDestination *dest) +e_select_names_model_replace (ESelectNamesModel *model, gint index, EABDestination *dest) { GList *node; const gchar *new_str, *old_str; @@ -482,9 +481,9 @@ e_select_names_model_replace (ESelectNamesModel *model, gint index, EDestination g_return_if_fail (model != NULL); g_return_if_fail (E_IS_SELECT_NAMES_MODEL (model)); g_return_if_fail (model->priv->data == NULL || (0 <= index && index < g_list_length (model->priv->data))); - g_return_if_fail (dest && E_IS_DESTINATION (dest)); + g_return_if_fail (dest && EAB_IS_DESTINATION (dest)); - new_str = e_destination_get_textrep (dest, FALSE); + new_str = eab_destination_get_textrep (dest, FALSE); new_strlen = new_str ? strlen (new_str) : 0; if (model->priv->data == NULL) { @@ -500,10 +499,10 @@ e_select_names_model_replace (ESelectNamesModel *model, gint index, EDestination if (node->data != dest) { - disconnect_destination (model, E_DESTINATION (node->data)); + disconnect_destination (model, EAB_DESTINATION (node->data)); connect_destination (model, dest); - old_str = e_destination_get_textrep (E_DESTINATION (node->data), FALSE); + old_str = eab_destination_get_textrep (EAB_DESTINATION (node->data), FALSE); old_strlen = old_str ? strlen (old_str) : 0; g_object_unref (node->data); @@ -523,14 +522,14 @@ void e_select_names_model_delete (ESelectNamesModel *model, gint index) { GList *node; - EDestination *dest; + EABDestination *dest; g_return_if_fail (model != NULL); g_return_if_fail (E_IS_SELECT_NAMES_MODEL (model)); g_return_if_fail (0 <= index && index < g_list_length (model->priv->data)); node = g_list_nth (model->priv->data, index); - dest = E_DESTINATION (node->data); + dest = EAB_DESTINATION (node->data); disconnect_destination (model, dest); g_object_unref (dest); @@ -552,16 +551,16 @@ e_select_names_model_clean (ESelectNamesModel *model, gboolean clean_last_entry) iter = model->priv->data; while (iter) { - EDestination *dest; + EABDestination *dest; next = g_list_next (iter); if (next == NULL && !clean_last_entry) break; - dest = iter->data ? E_DESTINATION (iter->data) : NULL; + dest = iter->data ? EAB_DESTINATION (iter->data) : NULL; - if (dest == NULL || e_destination_is_empty (dest)) { + if (dest == NULL || eab_destination_is_empty (dest)) { if (dest) { disconnect_destination (model, dest); g_object_unref (dest); @@ -581,7 +580,7 @@ e_select_names_model_clean (ESelectNamesModel *model, gboolean clean_last_entry) static void delete_all_iter (gpointer data, gpointer closure) { - disconnect_destination (E_SELECT_NAMES_MODEL (closure), E_DESTINATION (data)); + disconnect_destination (E_SELECT_NAMES_MODEL (closure), EAB_DESTINATION (data)); g_object_unref (data); } @@ -611,9 +610,9 @@ e_select_names_model_overwrite_copy (ESelectNamesModel *dest, ESelectNamesModel e_select_names_model_delete_all (dest); len = e_select_names_model_count (src); for (i = 0; i < len; ++i) { - const EDestination *d = e_select_names_model_get_destination (src, i); + const EABDestination *d = e_select_names_model_get_destination (src, i); if (d) - e_select_names_model_append (dest, e_destination_copy (d)); + e_select_names_model_append (dest, eab_destination_copy (d)); } } @@ -630,9 +629,9 @@ e_select_names_model_merge (ESelectNamesModel *dest, ESelectNamesModel *src) len = e_select_names_model_count (src); for (i = 0; i < len; ++i) { - const EDestination *d = e_select_names_model_get_destination (src, i); + const EABDestination *d = e_select_names_model_get_destination (src, i); if (d && !e_select_names_model_contains (dest, d)) - e_select_names_model_append (dest, e_destination_copy (d)); + e_select_names_model_append (dest, eab_destination_copy (d)); } } @@ -650,7 +649,7 @@ e_select_names_model_name_pos (ESelectNamesModel *model, gint seplen, gint index iter = model->priv->data; while (iter && i <= index) { rp += len + (i > 0 ? seplen : 0); - str = e_destination_get_textrep (E_DESTINATION (iter->data), FALSE); + str = eab_destination_get_textrep (EAB_DESTINATION (iter->data), FALSE); len = str ? g_utf8_strlen (str, -1) : 0; ++i; iter = g_list_next (iter); @@ -680,7 +679,7 @@ e_select_names_model_text_pos (ESelectNamesModel *model, gint seplen, gint pos, iter = model->priv->data; while (iter != NULL) { - str = e_destination_get_textrep (E_DESTINATION (iter->data), FALSE); + str = eab_destination_get_textrep (EAB_DESTINATION (iter->data), FALSE); len = str ? g_utf8_strlen (str, -1) : 0; if (sp <= pos && pos <= sp + len + adj) { @@ -719,65 +718,7 @@ e_select_names_model_text_pos (ESelectNamesModel *model, gint seplen, gint pos, } void -e_select_names_model_cardify (ESelectNamesModel *model, EBook *book, gint index, gint delay) -{ - EDestination *dest; - - g_return_if_fail (E_IS_SELECT_NAMES_MODEL (model)); - g_return_if_fail (book == NULL || E_IS_BOOK (book)); - g_return_if_fail (0 <= index && index < g_list_length (model->priv->data)); - - dest = E_DESTINATION (g_list_nth_data (model->priv->data, index)); - - if (!e_destination_is_empty (dest)) { - - if (delay > 0) - e_destination_cardify_delayed (dest, book, delay); - else - e_destination_cardify (dest, book); - } -} - -gboolean -e_select_names_model_uncardify (ESelectNamesModel *model, gint index) -{ - EDestination *dest; - gboolean rv = FALSE; - - g_return_val_if_fail (E_IS_SELECT_NAMES_MODEL (model), FALSE); - g_return_val_if_fail (0 <= index && index < g_list_length (model->priv->data), FALSE); - - dest = E_DESTINATION (g_list_nth_data (model->priv->data, index)); - - if (!e_destination_is_empty (dest)) { - EDestination *cpy_dest = e_destination_copy (dest); - - rv = e_destination_uncardify (cpy_dest); - - if (rv) { - e_select_names_model_replace (model, index, cpy_dest); - } - - } - - return rv; -} - -void -e_select_names_model_cancel_cardify (ESelectNamesModel *model, gint index) -{ - EDestination *dest; - - g_return_if_fail (E_IS_SELECT_NAMES_MODEL (model)); - g_return_if_fail (0 <= index && index < g_list_length (model->priv->data)); - - dest = E_DESTINATION (g_list_nth_data (model->priv->data, index)); - - e_destination_cancel_cardify (dest); -} - -void -e_select_names_model_cardify_all (ESelectNamesModel *model, EBook *book, gint delay) +e_select_names_model_load_all_contacts (ESelectNamesModel *model, EBook *book) { GList *iter; @@ -785,27 +726,27 @@ e_select_names_model_cardify_all (ESelectNamesModel *model, EBook *book, gint de g_return_if_fail (book == NULL || E_IS_BOOK (book)); for (iter = model->priv->data; iter != NULL; iter = g_list_next (iter)) { - EDestination *dest = E_DESTINATION (iter->data); - if (!e_destination_is_empty (dest)) { + EABDestination *dest = EAB_DESTINATION (iter->data); + if (!eab_destination_is_empty (dest)) { - if (delay > 0) - e_destination_cardify_delayed (dest, book, delay); - else - e_destination_cardify (dest, book); + eab_destination_load_contact (dest, book); } } } void -e_select_names_model_cancel_cardify_all (ESelectNamesModel *model) +e_select_names_model_cancel_all_contact_load (ESelectNamesModel *model) { GList *iter; g_return_if_fail (E_IS_SELECT_NAMES_MODEL (model)); for (iter = model->priv->data; iter != NULL; iter = g_list_next (iter)) { - EDestination *dest = E_DESTINATION (iter->data); - e_destination_cancel_cardify (dest); + EABDestination *dest = EAB_DESTINATION (iter->data); + if (!eab_destination_is_empty (dest)) { + + eab_destination_cancel_contact_load (dest); + } } } diff --git a/addressbook/gui/component/select-names/e-select-names-model.h b/addressbook/gui/component/select-names/e-select-names-model.h index 8a3c5381b7..41d5100f59 100644 --- a/addressbook/gui/component/select-names/e-select-names-model.h +++ b/addressbook/gui/component/select-names/e-select-names-model.h @@ -15,8 +15,8 @@ #include #include #include -#include -#include +#include +#include #define E_TYPE_SELECT_NAMES_MODEL (e_select_names_model_get_type ()) #define E_SELECT_NAMES_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_SELECT_NAMES_MODEL, ESelectNamesModel)) @@ -54,18 +54,18 @@ gint e_select_names_model_get_limit (ESelectNamesModel void e_select_names_model_set_limit (ESelectNamesModel *model, gint limit); gboolean e_select_names_model_at_limit (ESelectNamesModel *model); -const EDestination *e_select_names_model_get_destination (ESelectNamesModel *model, gint index); -gchar *e_select_names_model_export_destinationv (ESelectNamesModel *model); -void e_select_names_model_import_destinationv (ESelectNamesModel *model, +const EABDestination *e_select_names_model_get_destination (ESelectNamesModel *model, gint index); +gchar *e_select_names_model_export_destinationv (ESelectNamesModel *model); +void e_select_names_model_import_destinationv (ESelectNamesModel *model, gchar *destinationv); -ECard *e_select_names_model_get_card (ESelectNamesModel *model, gint index); +EContact *e_select_names_model_get_contact (ESelectNamesModel *model, gint index); const gchar *e_select_names_model_get_string (ESelectNamesModel *model, gint index); -gboolean e_select_names_model_contains (ESelectNamesModel *model, const EDestination *dest); +gboolean e_select_names_model_contains (ESelectNamesModel *model, const EABDestination *dest); -void e_select_names_model_insert (ESelectNamesModel *model, gint index, EDestination *dest); -void e_select_names_model_append (ESelectNamesModel *model, EDestination *dest); -void e_select_names_model_replace (ESelectNamesModel *model, gint index, EDestination *dest); +void e_select_names_model_insert (ESelectNamesModel *model, gint index, EABDestination *dest); +void e_select_names_model_append (ESelectNamesModel *model, EABDestination *dest); +void e_select_names_model_replace (ESelectNamesModel *model, gint index, EABDestination *dest); void e_select_names_model_delete (ESelectNamesModel *model, gint index); void e_select_names_model_delete_all (ESelectNamesModel *model); void e_select_names_model_overwrite_copy (ESelectNamesModel *dest, ESelectNamesModel *src); @@ -76,11 +76,8 @@ void e_select_names_model_clean (ESelectNamesModel *model, gboolea void e_select_names_model_name_pos (ESelectNamesModel *model, gint seplen, gint index, gint *pos, gint *length); void e_select_names_model_text_pos (ESelectNamesModel *model, gint seplen, gint pos, gint *index, gint *start_pos, gint *length); -void e_select_names_model_cardify (ESelectNamesModel *model, EBook *book, gint index, gint delay); -gboolean e_select_names_model_uncardify (ESelectNamesModel *model, gint index); -void e_select_names_model_cancel_cardify (ESelectNamesModel *model, gint index); -void e_select_names_model_cardify_all (ESelectNamesModel *model, EBook *book, gint delay); -void e_select_names_model_cancel_cardify_all (ESelectNamesModel *model); +void e_select_names_model_load_all_contacts (ESelectNamesModel *model, EBook *book); +void e_select_names_model_cancel_all_contact_load (ESelectNamesModel *model); /* This is a mildly annoying freeze/thaw pair, in that it only applies to the 'changed' signal and not to 'resized'. This could cause unexpected results in some cases. */ diff --git a/addressbook/gui/component/select-names/e-select-names-popup.c b/addressbook/gui/component/select-names/e-select-names-popup.c index d7fabd9426..bb0f331516 100644 --- a/addressbook/gui/component/select-names/e-select-names-popup.c +++ b/addressbook/gui/component/select-names/e-select-names-popup.c @@ -39,10 +39,11 @@ #include #include -#include +#include #include +#include #include -#include "e-addressbook-util.h" +#include "eab-gui-util.h" #include "e-select-names-popup.h" #define LIST_ICON_FILENAME "contact-list-16.png" @@ -51,13 +52,13 @@ typedef struct _PopupInfo PopupInfo; struct _PopupInfo { ESelectNamesTextModel *text_model; - EDestination *dest; + EABDestination *dest; gint pos; gint index; }; static PopupInfo * -popup_info_new (ESelectNamesTextModel *text_model, EDestination *dest, gint pos, gint index) +popup_info_new (ESelectNamesTextModel *text_model, EABDestination *dest, gint pos, gint index) { PopupInfo *info = g_new0 (PopupInfo, 1); info->text_model = text_model; @@ -97,29 +98,29 @@ popup_info_cleanup (GtkWidget *w, gpointer info) /* You are in a maze of twisty little callbacks, all alike... */ +#if TOO_MANY_MENU_ITEMS static void make_contact_editor_cb (EBook *book, gpointer user_data) { if (book) { - EDestination *dest = E_DESTINATION (user_data); - ECard *card; + EABDestination *dest = EAB_DESTINATION (user_data); + EContact *contact; - card = (ECard *) e_destination_get_card (dest); - if (e_card_evolution_list (card)) { + contact = (EContact *) eab_destination_get_contact (dest); + if (e_contact_get (contact, E_CONTACT_IS_LIST)) { EContactListEditor *ce; - ce = e_addressbook_show_contact_list_editor (book, card, FALSE, TRUE); + ce = e_addressbook_show_contact_list_editor (book, contact, FALSE, TRUE); e_contact_list_editor_raise (ce); } else { EContactEditor *ce; - ce = e_addressbook_show_contact_editor (book, card, FALSE, TRUE); + ce = e_addressbook_show_contact_editor (book, contact, FALSE, TRUE); e_contact_editor_raise (ce); } g_object_unref (dest); } } -#if TOO_MANY_MENU_ITEMS static void edit_contact_info_cb (GtkWidget *w, gpointer user_data) { @@ -137,7 +138,7 @@ change_email_num_cb (GtkWidget *w, gpointer user_data) { PopupInfo *info = (PopupInfo *) user_data; gint n; - EDestination *dest; + EABDestination *dest; if (info == NULL) return; @@ -147,9 +148,9 @@ change_email_num_cb (GtkWidget *w, gpointer user_data) n = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (w), "number")); - if (n != e_destination_get_email_num (info->dest)) { - dest = e_destination_new (); - e_destination_set_card (dest, e_destination_get_card (info->dest), n); + if (n != eab_destination_get_email_num (info->dest)) { + dest = eab_destination_new (); + eab_destination_set_contact (dest, eab_destination_get_contact (info->dest), n); e_select_names_model_replace (info->text_model->source, info->index, dest); } } @@ -174,7 +175,7 @@ toggle_html_mail_cb (GtkWidget *w, gpointer user_data) { PopupInfo *info = (PopupInfo *) user_data; GtkCheckMenuItem *item = GTK_CHECK_MENU_ITEM (w); - const EDestination *dest; + const EABDestination *dest; if (info == NULL) return; @@ -182,19 +183,19 @@ toggle_html_mail_cb (GtkWidget *w, gpointer user_data) dest = info->dest; item = GTK_CHECK_MENU_ITEM (item); - e_destination_set_html_mail_pref ((EDestination *) dest, item->active); + eab_destination_set_html_mail_pref ((EABDestination *) dest, item->active); } #endif static void -populate_popup_card (GtkWidget *pop, gboolean list, PopupInfo *info) +populate_popup_contact (GtkWidget *pop, gboolean list, PopupInfo *info) { GtkWidget *image; - ECard *card; - EIterator *iterator; + EContact *contact; GtkWidget *menuitem; + GList *email_list; - card = e_destination_get_card (info->dest); + contact = eab_destination_get_contact (info->dest); #if TOO_MANY_MENU_ITEMS menuitem = gtk_separator_menu_item_new(); @@ -224,7 +225,7 @@ populate_popup_card (GtkWidget *pop, gboolean list, PopupInfo *info) menuitem = gtk_check_menu_item_new_with_label (_("Send HTML Mail?")); gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menuitem), - e_destination_get_html_mail_pref (info->dest)); + eab_destination_get_html_mail_pref (info->dest)); g_signal_connect (menuitem, "toggled", G_CALLBACK (toggle_html_mail_cb), info); @@ -232,25 +233,27 @@ populate_popup_card (GtkWidget *pop, gboolean list, PopupInfo *info) gtk_menu_shell_prepend (GTK_MENU_SHELL (pop), menuitem); #endif - if (card->email) { + email_list = e_contact_get (contact, E_CONTACT_EMAIL); + + if (email_list) { menuitem = gtk_separator_menu_item_new(); gtk_widget_show (menuitem); gtk_menu_shell_prepend (GTK_MENU_SHELL (pop), menuitem); - if (e_list_length (card->email) > 1) { + if (g_list_length (email_list) > 1) { + GList *l; GSList *radiogroup = NULL; - gint n = e_destination_get_email_num (info->dest); - gint j = e_list_length (card->email) - 1; + gint n = eab_destination_get_email_num (info->dest); + gint j = g_list_length (email_list) - 1; - iterator = e_list_get_iterator (card->email); - for (e_iterator_last (iterator); e_iterator_is_valid (iterator); e_iterator_prev (iterator)) { - char *email = (char *)e_iterator_get (iterator); + for (l = g_list_last (email_list); l; l = l->prev) { + char *email = l->data; char *label = NULL; if (!strncmp (email, "dest)); + menuitem = gtk_menu_item_new_with_label (eab_destination_get_email (info->dest)); gtk_widget_show (menuitem); gtk_menu_shell_prepend (GTK_MENU_SHELL (pop), menuitem); } + + g_list_foreach (email_list, (GFunc)g_free, NULL); + g_list_free (email_list); } menuitem = gtk_separator_menu_item_new (); @@ -297,7 +301,7 @@ populate_popup_card (GtkWidget *pop, gboolean list, PopupInfo *info) ? EVOLUTION_IMAGESDIR "/" LIST_ICON_FILENAME : EVOLUTION_IMAGESDIR "/" CONTACT_ICON_FILENAME); gtk_widget_show (image); - menuitem = gtk_image_menu_item_new_with_label (e_destination_get_name (info->dest)); + menuitem = gtk_image_menu_item_new_with_label (eab_destination_get_name (info->dest)); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image); gtk_widget_show (menuitem); @@ -308,11 +312,11 @@ static void quick_add_cb (GtkWidget *w, gpointer user_data) { PopupInfo *info = (PopupInfo *) user_data; - e_contact_quick_add_free_form (e_destination_get_address (info->dest), NULL, NULL); + e_contact_quick_add_free_form (eab_destination_get_address (info->dest), NULL, NULL); } static void -populate_popup_nocard (GtkWidget *pop, PopupInfo *info) +populate_popup_nocontact (GtkWidget *pop, PopupInfo *info) { const gchar *str; GtkWidget *menuitem; @@ -331,7 +335,7 @@ populate_popup_nocard (GtkWidget *pop, PopupInfo *info) #if TOO_MANY_MENU_ITEMS menuitem = gtk_check_menu_item_new_with_label (_("Send HTML Mail?")); gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menuitem), - e_destination_get_html_mail_pref (info->dest)); + eab_destination_get_html_mail_pref (info->dest)); g_signal_connect (menuitem, "toggled", G_CALLBACK (toggle_html_mail_cb), info); @@ -343,9 +347,9 @@ populate_popup_nocard (GtkWidget *pop, PopupInfo *info) gtk_widget_show (menuitem); gtk_menu_shell_prepend (GTK_MENU_SHELL (pop), menuitem); - str = e_destination_get_name (info->dest); + str = eab_destination_get_name (info->dest); if (! (str && *str)) - str = e_destination_get_email (info->dest); + str = eab_destination_get_email (info->dest); if (! (str && *str)) str = _("Unnamed Contact"); @@ -360,7 +364,7 @@ e_select_names_populate_popup (GtkWidget *menu, ESelectNamesTextModel *text_mode { ESelectNamesModel *model; PopupInfo *info; - EDestination *dest; + EABDestination *dest; gint index; g_return_if_fail (GTK_IS_MENU_SHELL (menu)); @@ -375,16 +379,16 @@ e_select_names_populate_popup (GtkWidget *menu, ESelectNamesTextModel *text_mode return; /* XXX yuck, why does this return a const? */ - dest = (EDestination *)e_select_names_model_get_destination (model, index); - if (e_destination_is_empty (dest)) + dest = (EABDestination *)e_select_names_model_get_destination (model, index); + if (eab_destination_is_empty (dest)) return; info = popup_info_new (text_model, dest, pos, index); - if (e_destination_contains_card (dest)) { - populate_popup_card (menu, e_destination_is_evolution_list (dest), info); + if (eab_destination_get_contact (dest)) { + populate_popup_contact (menu, eab_destination_is_evolution_list (dest), info); } else { - populate_popup_nocard (menu, info); + populate_popup_nocontact (menu, info); } /* Clean up our info item after we've made our selection. */ diff --git a/addressbook/gui/component/select-names/e-select-names-table-model.c b/addressbook/gui/component/select-names/e-select-names-table-model.c index 1c55c3804d..14261e9d80 100644 --- a/addressbook/gui/component/select-names/e-select-names-table-model.c +++ b/addressbook/gui/component/select-names/e-select-names-table-model.c @@ -16,7 +16,7 @@ #include #include "e-select-names-table-model.h" -#include "addressbook/backend/ebook/e-card-simple.h" +#include "addressbook/backend/ebook/e-contact.h" /* Object argument IDs */ enum { @@ -118,21 +118,19 @@ fill_in_info (ESelectNamesTableModel *model) model->data = g_new(ESelectNamesTableModelData, count); for (i = 0; i < count; ++i) { - const EDestination *dest = e_select_names_model_get_destination (model->source, i); - ECard *card = dest ? e_destination_get_card (dest) : NULL; + const EABDestination *dest = e_select_names_model_get_destination (model->source, i); + EContact *contact = dest ? eab_destination_get_contact (dest) : NULL; - if (card) { - ECardSimple *simple = e_card_simple_new(card); - model->data[i].name = e_card_simple_get(simple, E_CARD_SIMPLE_FIELD_NAME_OR_ORG); + if (contact) { + model->data[i].name = e_contact_get(contact, E_CONTACT_FULL_NAME); if (model->data[i].name == 0) model->data[i].name = g_strdup(""); - model->data[i].email = e_card_simple_get(simple, E_CARD_SIMPLE_FIELD_EMAIL); + model->data[i].email = e_contact_get(contact, E_CONTACT_EMAIL_1); if (model->data[i].email == 0) model->data[i].email = g_strdup(""); - g_object_unref(simple); } else { - const gchar *name = e_destination_get_name (dest); - const gchar *email = e_destination_get_email (dest); + const gchar *name = eab_destination_get_name (dest); + const gchar *email = eab_destination_get_email (dest); model->data[i].name = g_strdup (name && *name ? name : email); model->data[i].email = g_strdup (email); diff --git a/addressbook/gui/component/select-names/e-select-names-text-model.c b/addressbook/gui/component/select-names/e-select-names-text-model.c index 7859d5b056..e885de5bf6 100644 --- a/addressbook/gui/component/select-names/e-select-names-text-model.c +++ b/addressbook/gui/component/select-names/e-select-names-text-model.c @@ -19,7 +19,7 @@ #include #include "e-select-names-text-model.h" -#include "e-addressbook-util.h" +#include "eab-gui-util.h" static FILE *out = NULL; /* stream for debugging spew */ @@ -137,7 +137,7 @@ dump_model (ESelectNamesTextModel *text_model) for (i=0; i" : ""); + e_select_names_model_get_contact (model, i) ? "" : ""); fprintf (out, "\n"); } @@ -372,9 +372,9 @@ e_select_names_text_model_insert_length (ETextModel *model, gint pos, const gcha /* Is this a quoted or an unquoted separator we are dealing with? */ if (ut == g_utf8_get_char(text_model->sep) && index >= 0) { - const EDestination *dest = e_select_names_model_get_destination (source, index); + const EABDestination *dest = e_select_names_model_get_destination (source, index); if (dest) { - const gchar *str = e_destination_get_textrep (dest, FALSE); + const gchar *str = eab_destination_get_textrep (dest, FALSE); int j; const char *jp; @@ -400,8 +400,8 @@ e_select_names_text_model_insert_length (ETextModel *model, gint pos, const gcha if (index == -1) { EReposAbsolute repos; - e_select_names_model_insert (source, 0, e_destination_new ()); - e_select_names_model_insert (source, 0, e_destination_new ()); + e_select_names_model_insert (source, 0, eab_destination_new ()); + e_select_names_model_insert (source, 0, eab_destination_new ()); repos.model = model; repos.pos = -1; /* At end */ @@ -420,7 +420,7 @@ e_select_names_text_model_insert_length (ETextModel *model, gint pos, const gcha (e_select_names_model_get_string (source, ins_point) == NULL)) || (ins_point > 0 && (e_select_names_model_get_string (source, ins_point-1) == NULL)))) { - e_select_names_model_insert (source, ins_point, e_destination_new ()); + e_select_names_model_insert (source, ins_point, eab_destination_new ()); repos.model = model; repos.pos = pos; @@ -435,10 +435,10 @@ e_select_names_text_model_insert_length (ETextModel *model, gint pos, const gcha const gchar *str = e_select_names_model_get_string (source, index); gchar *str1 = g_strndup (str, offset); gchar *str2 = g_strdup (str+offset); - EDestination *d1 = e_destination_new (), *d2 = e_destination_new (); + EABDestination *d1 = eab_destination_new (), *d2 = eab_destination_new (); - e_destination_set_raw (d1, str1); - e_destination_set_raw (d2, str2); + eab_destination_set_raw (d1, str1); + eab_destination_set_raw (d2, str2); e_select_names_model_replace (source, index, d1); e_select_names_model_insert (source, index+1, d2); @@ -498,9 +498,9 @@ e_select_names_text_model_insert_length (ETextModel *model, gint pos, const gcha if (new_str->len) { - EDestination *dest; - dest = index >= 0 ? e_destination_copy (e_select_names_model_get_destination (source, index)) : e_destination_new (); - e_destination_set_raw (dest, new_str->str); + EABDestination *dest; + dest = index >= 0 ? eab_destination_copy (e_select_names_model_get_destination (source, index)) : eab_destination_new (); + eab_destination_set_raw (dest, new_str->str); e_select_names_model_replace (source, index, dest); /* e_select_names_model_replace (source, index, dest); */ @@ -589,7 +589,7 @@ e_select_names_text_model_delete (ETextModel *model, gint pos, gint length) if (index+1 < e_select_names_model_count (source)) { EReposDeleteShift repos; - EDestination *new_dest; + EABDestination *new_dest; const gchar *str1 = e_select_names_model_get_string (source, index); const gchar *str2 = e_select_names_model_get_string (source, index+1); gchar *new_str; @@ -613,8 +613,8 @@ e_select_names_text_model_delete (ETextModel *model, gint pos, gint length) e_select_names_model_delete (source, index+1); - new_dest = e_destination_new (); - e_destination_set_raw (new_dest, new_str); + new_dest = eab_destination_new (); + eab_destination_set_raw (new_dest, new_str); e_select_names_model_replace (source, index, new_dest); g_free (new_str); @@ -689,7 +689,7 @@ e_select_names_text_model_delete (ETextModel *model, gint pos, gint length) char *np; int i; EReposDeleteShift repos; - EDestination *dest; + EABDestination *dest; new_str = g_new0 (char, strlen (str) * 6 + 1); /* worse case it can't be any longer than this */ @@ -718,8 +718,8 @@ e_select_names_text_model_delete (ETextModel *model, gint pos, gint length) np = g_utf8_next_char (np); } - dest = index >= 0 ? e_destination_copy (e_select_names_model_get_destination (source, index)) : e_destination_new (); - e_destination_set_raw (dest, new_str); + dest = index >= 0 ? eab_destination_copy (e_select_names_model_get_destination (source, index)) : eab_destination_new (); + eab_destination_set_raw (dest, new_str); e_select_names_model_replace (source, index, dest); if (out) @@ -764,10 +764,10 @@ e_select_names_text_model_obj_count (ETextModel *model) count = i = e_select_names_model_count (source); while (i > 0) { - const EDestination *dest; + const EABDestination *dest; --i; dest = e_select_names_model_get_destination (source, i); - if (e_destination_get_card (dest) == NULL) + if (eab_destination_get_contact (dest) == NULL) --count; } @@ -783,8 +783,8 @@ nth_obj_index (ESelectNamesModel *source, gint n) N = e_select_names_model_count (source); do { - const EDestination *dest = e_select_names_model_get_destination (source, i); - if (e_destination_get_card (dest)) + const EABDestination *dest = e_select_names_model_get_destination (source, i); + if (eab_destination_get_contact (dest)) --n; ++i; } while (n >= 0 && i < N); @@ -820,27 +820,32 @@ e_select_names_text_model_get_nth_obj (ETextModel *model, gint n, gint *len) static void e_select_names_text_model_activate_obj (ETextModel *model, gint n) { +#if notyet + /* XXX the new ebook doesn't have e_contact_get_book, and we + don't really want to add it, so this can't be implemented + this simply anymore */ ESelectNamesModel *source = E_SELECT_NAMES_TEXT_MODEL (model)->source; - ECard *card; + EContact *contact; gint i; i = nth_obj_index (source, n); g_return_if_fail (i >= 0); - card = e_select_names_model_get_card (source, i); - g_return_if_fail (card != NULL); + contact = e_select_names_model_get_contact (source, i); + g_return_if_fail (contact != NULL); /* present read-only contact editor when someone double clicks from here */ - if (e_card_evolution_list (card)) { + if (e_contact_get (contact, E_CONTACT_IS_LIST)) { EContactListEditor *ce; - ce = e_addressbook_show_contact_list_editor (e_card_get_book(card), card, FALSE, FALSE); + ce = e_addressbook_show_contact_list_editor (e_contact_get_book(contact), contact, FALSE, FALSE); e_contact_list_editor_raise (ce); } else { - EContactEditor *ce; - ce = e_addressbook_show_contact_editor (e_card_get_book(card), card, FALSE, FALSE); + EABContactEditor *ce; + ce = e_addressbook_show_contact_editor (e_contact_get_book(contact), contact, FALSE, FALSE); e_contact_editor_raise (ce); } +#endif } diff --git a/addressbook/gui/component/select-names/e-select-names.c b/addressbook/gui/component/select-names/e-select-names.c index f009fbbd63..b50a6d0ca0 100644 --- a/addressbook/gui/component/select-names/e-select-names.c +++ b/addressbook/gui/component/select-names/e-select-names.c @@ -30,9 +30,8 @@ #include #include -#include -#include -#include +#include +#include #include #include #include @@ -40,7 +39,7 @@ #include #include "e-select-names.h" -#include +#include #include "e-select-names-table-model.h" #include #include @@ -113,7 +112,7 @@ GtkWidget *e_addressbook_create_ebook_table(char *name, char *string1, char *str GtkWidget *e_addressbook_create_folder_selector(char *name, char *string1, char *string2, int num1, int num2); static void -search_result (EAddressbookModel *model, EBookViewStatus status, ESelectNames *esn) +search_result (EABModel *model, EBookViewStatus status, ESelectNames *esn) { sync_table_and_models (NULL, esn); } @@ -131,19 +130,15 @@ set_book(EBook *book, EBookStatus status, ESelectNames *esn) } static void -addressbook_model_set_uri(ESelectNames *e_select_names, EAddressbookModel *model, const char *uri) +addressbook_model_set_uri(ESelectNames *e_select_names, EABModel *model, const char *uri) { EBook *book; - char *book_uri; - - book_uri = e_book_expand_uri (uri); /* If uri == the current uri, then we don't have to do anything */ - book = e_addressbook_model_get_ebook (model); + book = eab_model_get_ebook (model); if (book) { const gchar *current_uri = e_book_get_uri (book); - if (current_uri && !strcmp (book_uri, current_uri)) { - g_free (book_uri); + if (current_uri && !strcmp (uri, current_uri)) { return; } } @@ -152,25 +147,28 @@ addressbook_model_set_uri(ESelectNames *e_select_names, EAddressbookModel *model g_object_ref(e_select_names); g_object_ref(model); - addressbook_load_uri(book, book_uri, (EBookCallback) set_book, e_select_names); - - g_free (book_uri); + addressbook_load_uri(book, uri, (EBookCallback) set_book, e_select_names); } static void * -card_key (ECard *card) +contact_key (const EContact *contact) { - EBook *book; + EBook *book = NULL; const gchar *book_uri; - if (card == NULL) + if (contact == NULL) return NULL; - g_assert (E_IS_CARD (card)); + g_assert (E_IS_CONTACT (contact)); - book = e_card_get_book (card); +#if notyet + /* XXX we need a way to reproduce this here somehow.. or at + least make sure we never collide between two contacts in + different books. */ + book = e_contact_get_book (contact); +#endif book_uri = book ? e_book_get_uri (book) : "NoBook"; - return g_strdup_printf ("%s|%s", book_uri ? book_uri : "NoURI", e_card_get_id (card)); + return g_strdup_printf ("%s|%s", book_uri ? book_uri : "NoURI", (char*)e_contact_get_const ((EContact*)contact, E_CONTACT_UID)); } static void @@ -180,14 +178,14 @@ sync_one_model (gpointer k, gpointer val, gpointer closure) ESelectNamesChild *child = val; ESelectNamesModel *model = child->source; gint i, count; - ECard *card; + EContact *contact; void *key; count = e_select_names_model_count (model); for (i = 0; i < count; ++i) { - card = e_select_names_model_get_card (model, i); - if (card) { - key = card_key (card); + contact = e_select_names_model_get_contact (model, i); + if (contact) { + key = contact_key (contact); e_table_without_hide (etw, key); g_free (key); } @@ -206,21 +204,19 @@ real_add_address_cb (int model_row, gpointer closure) { ESelectNamesChild *child = closure; ESelectNames *names = child->names; - ECard *card; - EDestination *dest = e_destination_new (); + const EContact *contact; + EABDestination *dest = eab_destination_new (); gint mapped_row; mapped_row = e_table_subset_view_to_model_row (E_TABLE_SUBSET (names->without), model_row); - card = e_addressbook_model_get_card (E_ADDRESSBOOK_MODEL(names->model), mapped_row); + contact = eab_model_contact_at (EAB_MODEL(names->model), mapped_row); - if (card != NULL) { - e_destination_set_card (dest, card, 0); + if (contact != NULL) { + eab_destination_set_contact (dest, (EContact*)contact, 0); e_select_names_model_append (child->source, dest); e_select_names_model_clean (child->source, FALSE); - - g_object_unref(card); } } @@ -266,10 +262,9 @@ selection_change (ETable *table, ESelectNames *names) static void * esn_get_key_fn (ETableModel *source, int row, void *closure) { - EAddressbookModel *model = E_ADDRESSBOOK_MODEL (closure); - ECard *card = e_addressbook_model_get_card (model, row); - void *key = card_key (card); - g_object_unref (card); + EABModel *model = EAB_MODEL (closure); + const EContact *contact = eab_model_contact_at (model, row); + void *key = contact_key (contact); return key; } @@ -297,11 +292,11 @@ e_addressbook_create_ebook_table(char *name, char *string1, char *string2, int n { ETableModel *adapter; ETableModel *without; - EAddressbookModel *model; + EABModel *model; GtkWidget *table; - model = e_addressbook_model_new (); - adapter = E_TABLE_MODEL (e_addressbook_table_adapter_new (model)); + model = eab_model_new (); + adapter = E_TABLE_MODEL (eab_table_adapter_new (model)); g_object_set(model, "editable", FALSE, @@ -340,7 +335,7 @@ folder_selected (EvolutionFolderSelectorButton *button, GNOME_Evolution_Folder * { addressbook_model_set_uri(e_select_names, e_select_names->model, folder->physicalUri); - e_config_listener_set_string (e_book_get_config_database(), + e_config_listener_set_string (eab_get_config_database(), "/apps/evolution/addressbook/select_names/last_used_uri", folder->physicalUri); } @@ -392,7 +387,7 @@ update_query (GtkWidget *widget, ESelectNames *e_select_names) } static void -status_message (EAddressbookModel *model, const gchar *message, ESelectNames *e_select_names) +status_message (EABModel *model, const gchar *message, ESelectNames *e_select_names) { if (message == NULL) gtk_label_set_text (GTK_LABEL (e_select_names->status_message), ""); @@ -424,7 +419,7 @@ select_entry_changed (GtkWidget *widget, ESelectNames *e_select_names) int model_row = e_table_view_to_model_row (table, i); char *row_strcoll_string = g_utf8_collate_key (e_table_model_value_at (e_select_names->without, - E_CARD_SIMPLE_FIELD_NAME_OR_ORG, + E_CONTACT_FULL_NAME, model_row), -1); if (g_utf8_collate (select_strcoll_string, row_strcoll_string) <= 0) { @@ -637,12 +632,14 @@ e_select_names_new (EvolutionShellClient *shell_client) e_select_names = g_object_new (E_TYPE_SELECT_NAMES, NULL); - db = e_book_get_config_database (); + db = eab_get_config_database (); contacts_uri = e_config_listener_get_string_with_default ( db, "/apps/evolution/addressbook/select_names/last_used_uri", NULL, NULL); +#if notyet if (!contacts_uri) contacts_uri = g_strdup (e_book_get_default_book_uri ()); +#endif button = glade_xml_get_widget (e_select_names->gui, "folder-selector"); evolution_folder_selector_button_construct (EVOLUTION_FOLDER_SELECTOR_BUTTON (button), diff --git a/addressbook/gui/component/select-names/e-select-names.h b/addressbook/gui/component/select-names/e-select-names.h index 8e672da92a..e67f64b70b 100644 --- a/addressbook/gui/component/select-names/e-select-names.h +++ b/addressbook/gui/component/select-names/e-select-names.h @@ -67,7 +67,7 @@ struct _ESelectNames ETableScrolled *table; ETableModel *adapter; ETableModel *without; - EAddressbookModel *model; + EABModel *model; GtkWidget *categories; GtkWidget *select_entry; GtkWidget *status_message; diff --git a/addressbook/gui/component/select-names/e-simple-card-bonobo.c b/addressbook/gui/component/select-names/e-simple-card-bonobo.c deleted file mode 100644 index 07203618b3..0000000000 --- a/addressbook/gui/component/select-names/e-simple-card-bonobo.c +++ /dev/null @@ -1,216 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-simple-card-bonobo.c - * - * Copyright (C) 2000 Ximian, Inc. - * - * 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., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Authors: - * Ettore Perazzoli - * Chris Lahey - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "e-simple-card-bonobo.h" - -#include - -#include "Evolution-Addressbook-SelectNames.h" - - -#define PARENT_TYPE BONOBO_TYPE_OBJECT -static BonoboObjectClass *parent_class = NULL; - -struct _ESimpleCardBonoboPrivate { - ECardSimple *card_simple; -}; - - - -static GNOME_Evolution_Addressbook_SimpleCard_Arbitrary * -impl_SimpleCard_get_arbitrary (PortableServer_Servant servant, - const CORBA_char *key, - CORBA_Environment *ev) -{ - ESimpleCardBonobo *simple_card; - ESimpleCardBonoboPrivate *priv; - GNOME_Evolution_Addressbook_SimpleCard_Arbitrary *ret_val = GNOME_Evolution_Addressbook_SimpleCard_Arbitrary__alloc (); - - simple_card = E_SIMPLE_CARD_BONOBO (bonobo_object (servant)); - priv = simple_card->priv; - - if (priv->card_simple) { - const ECardArbitrary *arbitrary = e_card_simple_get_arbitrary (priv->card_simple, key); - ret_val->key = CORBA_string_dup (arbitrary->key); - ret_val->value = CORBA_string_dup (arbitrary->value); - ret_val->type = CORBA_string_dup (arbitrary->type); - } else { - ret_val->key = CORBA_string_dup (""); - ret_val->value = CORBA_string_dup (""); - ret_val->type = CORBA_string_dup (""); - } - - return ret_val; -} - -static void -impl_SimpleCard_set_arbitrary (PortableServer_Servant servant, - const CORBA_char *key, - const CORBA_char *type, - const CORBA_char *value, - CORBA_Environment *ev) -{ - ESimpleCardBonobo *simple_card; - ESimpleCardBonoboPrivate *priv; - - simple_card = E_SIMPLE_CARD_BONOBO (bonobo_object (servant)); - priv = simple_card->priv; - - if (priv->card_simple) { - e_card_simple_set_arbitrary (priv->card_simple, key, type, value); - } -} - -static CORBA_char * -impl_SimpleCard_get (PortableServer_Servant servant, - GNOME_Evolution_Addressbook_SimpleCard_Field field, - CORBA_Environment *ev) -{ - ESimpleCardBonobo *simple_card; - ESimpleCardBonoboPrivate *priv; - - simple_card = E_SIMPLE_CARD_BONOBO (bonobo_object (servant)); - priv = simple_card->priv; - - if (priv->card_simple) { - char *value = e_card_simple_get (priv->card_simple, - field); - char *ret_val = CORBA_string_dup (value ? value : ""); - g_free (value); - return ret_val; - } else { - return CORBA_string_dup (""); - } -} - -static void -impl_SimpleCard_set (PortableServer_Servant servant, - GNOME_Evolution_Addressbook_SimpleCard_Field field, - const CORBA_char *value, - CORBA_Environment *ev) -{ - - ESimpleCardBonobo *simple_card; - ESimpleCardBonoboPrivate *priv; - - simple_card = E_SIMPLE_CARD_BONOBO (bonobo_object (servant)); - priv = simple_card->priv; - - if (priv->card_simple) { - e_card_simple_set (priv->card_simple, - field, - value); - } -} - - -/* GtkObject methods. */ - -static void -impl_dispose (GObject *object) -{ - ESimpleCardBonobo *simple_card; - ESimpleCardBonoboPrivate *priv; - - simple_card = E_SIMPLE_CARD_BONOBO (object); - priv = simple_card->priv; - - if (priv) { - if (priv->card_simple) { - g_object_unref (priv->card_simple); - } - - g_free (priv); - simple_card->priv = NULL; - } - - if (G_OBJECT_CLASS(parent_class)->dispose) - G_OBJECT_CLASS(parent_class)->dispose(object); -} - - -static void -e_simple_card_bonobo_class_init (ESimpleCardBonoboClass *klass) -{ - GObjectClass *object_class; - POA_GNOME_Evolution_Addressbook_SimpleCard__epv *epv; - - object_class = G_OBJECT_CLASS (klass); - parent_class = g_type_class_ref (BONOBO_TYPE_OBJECT); - - object_class->dispose = impl_dispose; - - epv = &klass->epv; - epv->getArbitrary = impl_SimpleCard_get_arbitrary; - epv->setArbitrary = impl_SimpleCard_set_arbitrary; - epv->get = impl_SimpleCard_get; - epv->set = impl_SimpleCard_set; -} - -static void -e_simple_card_bonobo_init (ESimpleCardBonobo *simple_card) -{ - ESimpleCardBonoboPrivate *priv; - - priv = g_new (ESimpleCardBonoboPrivate, 1); - - priv->card_simple = NULL; - - simple_card->priv = priv; -} - - -void -e_simple_card_bonobo_construct (ESimpleCardBonobo *simple_card, - ECardSimple *card_simple) -{ - g_return_if_fail (simple_card != NULL); - g_return_if_fail (E_IS_SIMPLE_CARD_BONOBO (simple_card)); - - simple_card->priv->card_simple = card_simple; - g_object_ref (card_simple); -} - -ESimpleCardBonobo * -e_simple_card_bonobo_new (ECardSimple *card_simple) -{ - ESimpleCardBonobo *simple_card; - - simple_card = g_object_new (E_TYPE_SIMPLE_CARD_BONOBO, NULL); - - e_simple_card_bonobo_construct (simple_card, card_simple); - - return simple_card; -} - - -BONOBO_TYPE_FUNC_FULL ( - ESimpleCardBonobo, - GNOME_Evolution_Addressbook_SimpleCard, - PARENT_TYPE, - e_simple_card_bonobo); diff --git a/addressbook/gui/component/select-names/e-simple-card-bonobo.h b/addressbook/gui/component/select-names/e-simple-card-bonobo.h deleted file mode 100644 index 7bc2d65830..0000000000 --- a/addressbook/gui/component/select-names/e-simple-card-bonobo.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-simple-card-bonobo.h - * - * Copyright (C) 2000 Ximian, Inc. - * - * 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., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Authors: - * Ettore Perazzoli - * Chris Lahey - */ - -#ifndef __E_SIMPLE_CARD_BONOBO_H__ -#define __E_SIMPLE_CARD_BONOBO_H__ - -#include - -#include "Evolution-Addressbook-SelectNames.h" -#include - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -#define E_TYPE_SIMPLE_CARD_BONOBO (e_simple_card_bonobo_get_type ()) -#define E_SIMPLE_CARD_BONOBO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_SIMPLE_CARD_BONOBO, ESimpleCardBonobo)) -#define E_SIMPLE_CARD_BONOBO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_SIMPLE_CARD_BONOBO, ESimpleCardBonoboClass)) -#define E_IS_SIMPLE_CARD_BONOBO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_SIMPLE_CARD_BONOBO)) -#define E_IS_SIMPLE_CARD_BONOBO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_SIMPLE_CARD_BONOBO)) - - -typedef struct _ESimpleCardBonobo ESimpleCardBonobo; -typedef struct _ESimpleCardBonoboPrivate ESimpleCardBonoboPrivate; -typedef struct _ESimpleCardBonoboClass ESimpleCardBonoboClass; - -struct _ESimpleCardBonobo { - BonoboObject parent; - - ESimpleCardBonoboPrivate *priv; -}; - -struct _ESimpleCardBonoboClass { - BonoboObjectClass parent_class; - - POA_GNOME_Evolution_Addressbook_SimpleCard__epv epv; -}; - - -GType e_simple_card_bonobo_get_type (void); -ESimpleCardBonobo *e_simple_card_bonobo_new (ECardSimple *card_simple); -void e_simple_card_bonobo_construct (ESimpleCardBonobo *simple_card, - ECardSimple *card_simple); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __E_SIMPLE_CARD_BONOBO_H__ */ -- cgit v1.2.3