aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui
diff options
context:
space:
mode:
Diffstat (limited to 'addressbook/gui')
-rw-r--r--addressbook/gui/component/GNOME_Evolution_Addressbook.server.in.in27
-rw-r--r--addressbook/gui/component/Makefile.am21
-rw-r--r--addressbook/gui/component/addressbook-component.c653
-rw-r--r--addressbook/gui/component/addressbook-component.h45
-rw-r--r--addressbook/gui/component/addressbook-config.c16
-rw-r--r--addressbook/gui/component/addressbook.c216
-rw-r--r--addressbook/gui/component/addressbook.h4
-rw-r--r--addressbook/gui/component/component-factory.c29
-rw-r--r--addressbook/gui/component/e-address-popup.h88
-rw-r--r--addressbook/gui/component/e-address-widget.c568
-rw-r--r--addressbook/gui/component/e-address-widget.h82
-rw-r--r--addressbook/gui/component/e-cardlist-model.c239
-rw-r--r--addressbook/gui/component/e-cardlist-model.h42
-rw-r--r--addressbook/gui/component/select-names/Evolution-Addressbook-SelectNames.idl72
-rw-r--r--addressbook/gui/component/select-names/GNOME_Evolution_Addressbook_SelectNames.server.in.in4
-rw-r--r--addressbook/gui/component/select-names/Makefile.am4
-rw-r--r--addressbook/gui/component/select-names/e-select-names-bonobo.c41
-rw-r--r--addressbook/gui/component/select-names/e-select-names-completion.c238
-rw-r--r--addressbook/gui/component/select-names/e-select-names-completion.h2
-rw-r--r--addressbook/gui/component/select-names/e-select-names-manager.c27
-rw-r--r--addressbook/gui/component/select-names/e-select-names-model.c181
-rw-r--r--addressbook/gui/component/select-names/e-select-names-model.h27
-rw-r--r--addressbook/gui/component/select-names/e-select-names-popup.c96
-rw-r--r--addressbook/gui/component/select-names/e-select-names-table-model.c18
-rw-r--r--addressbook/gui/component/select-names/e-select-names-text-model.c65
-rw-r--r--addressbook/gui/component/select-names/e-select-names.c83
-rw-r--r--addressbook/gui/component/select-names/e-select-names.h2
-rw-r--r--addressbook/gui/component/select-names/e-simple-card-bonobo.c216
-rw-r--r--addressbook/gui/component/select-names/e-simple-card-bonobo.h71
-rw-r--r--addressbook/gui/contact-editor/Makefile.am2
-rw-r--r--addressbook/gui/contact-editor/contact-editor.glade43
-rw-r--r--addressbook/gui/contact-editor/e-contact-editor-address.c16
-rw-r--r--addressbook/gui/contact-editor/e-contact-editor-address.h6
-rw-r--r--addressbook/gui/contact-editor/e-contact-editor-fullname.c34
-rw-r--r--addressbook/gui/contact-editor/e-contact-editor-fullname.h6
-rw-r--r--addressbook/gui/contact-editor/e-contact-editor.c765
-rw-r--r--addressbook/gui/contact-editor/e-contact-editor.h40
-rw-r--r--addressbook/gui/contact-editor/e-contact-quick-add.c60
-rw-r--r--addressbook/gui/contact-editor/e-contact-quick-add.h4
-rw-r--r--addressbook/gui/contact-editor/e-contact-save-as.c218
-rw-r--r--addressbook/gui/contact-editor/e-contact-save-as.h41
-rw-r--r--addressbook/gui/contact-list-editor/contact-list-editor.glade2
-rw-r--r--addressbook/gui/contact-list-editor/e-contact-list-editor.c460
-rw-r--r--addressbook/gui/contact-list-editor/e-contact-list-editor.h26
-rw-r--r--addressbook/gui/contact-list-editor/e-contact-list-model.c32
-rw-r--r--addressbook/gui/contact-list-editor/e-contact-list-model.h15
-rw-r--r--addressbook/gui/merging/.cvsignore1
-rw-r--r--addressbook/gui/merging/Makefile.am17
-rw-r--r--addressbook/gui/merging/e-card-merging.c198
-rw-r--r--addressbook/gui/merging/e-card-merging.h29
-rw-r--r--addressbook/gui/merging/eab-contact-commit-duplicate-detected.glade (renamed from addressbook/gui/merging/e-card-merging-book-commit-duplicate-detected.glade)12
-rw-r--r--addressbook/gui/merging/eab-contact-compare.c736
-rw-r--r--addressbook/gui/merging/eab-contact-compare.h73
-rw-r--r--addressbook/gui/merging/eab-contact-duplicate-detected.glade (renamed from addressbook/gui/merging/e-card-duplicate-detected.glade)12
-rw-r--r--addressbook/gui/merging/eab-contact-merging.c197
-rw-r--r--addressbook/gui/merging/eab-contact-merging.h30
-rw-r--r--addressbook/gui/search/e-addressbook-search-dialog.c38
-rw-r--r--addressbook/gui/search/e-addressbook-search-dialog.h31
-rw-r--r--addressbook/gui/widgets/.cvsignore4
-rw-r--r--addressbook/gui/widgets/Makefile.am115
-rw-r--r--addressbook/gui/widgets/e-addressbook-model.c382
-rw-r--r--addressbook/gui/widgets/e-addressbook-model.h83
-rw-r--r--addressbook/gui/widgets/e-addressbook-reflow-adapter.c152
-rw-r--r--addressbook/gui/widgets/e-addressbook-reflow-adapter.h11
-rw-r--r--addressbook/gui/widgets/e-addressbook-table-adapter.c207
-rw-r--r--addressbook/gui/widgets/e-addressbook-table-adapter.h32
-rw-r--r--addressbook/gui/widgets/e-addressbook-treeview-adapter.c6
-rw-r--r--addressbook/gui/widgets/e-addressbook-util.h65
-rw-r--r--addressbook/gui/widgets/e-addressbook-view.c1147
-rw-r--r--addressbook/gui/widgets/e-addressbook-view.etspec30
-rw-r--r--addressbook/gui/widgets/e-addressbook-view.h153
-rw-r--r--addressbook/gui/widgets/e-minicard-control.h8
-rw-r--r--addressbook/gui/widgets/e-minicard-label.c4
-rw-r--r--addressbook/gui/widgets/e-minicard-view-widget.c49
-rw-r--r--addressbook/gui/widgets/e-minicard-view.c48
-rw-r--r--addressbook/gui/widgets/e-minicard-widget-test.c117
-rw-r--r--addressbook/gui/widgets/e-minicard-widget.c264
-rw-r--r--addressbook/gui/widgets/e-minicard-widget.h76
-rw-r--r--addressbook/gui/widgets/e-minicard.c264
-rw-r--r--addressbook/gui/widgets/e-minicard.h6
-rw-r--r--addressbook/gui/widgets/eab-contact-display.c486
-rw-r--r--addressbook/gui/widgets/eab-contact-display.h61
-rw-r--r--addressbook/gui/widgets/eab-gui-util.c (renamed from addressbook/gui/widgets/e-addressbook-util.c)397
-rw-r--r--addressbook/gui/widgets/eab-gui-util.h70
-rw-r--r--addressbook/gui/widgets/eab-marshal.list (renamed from addressbook/gui/widgets/e-addressbook-marshal.list)0
-rw-r--r--addressbook/gui/widgets/eab-popup-control.c (renamed from addressbook/gui/component/e-address-popup.c)425
-rw-r--r--addressbook/gui/widgets/eab-popup-control.h85
-rw-r--r--addressbook/gui/widgets/eab-vcard-control.c (renamed from addressbook/gui/widgets/e-minicard-control.c)235
-rw-r--r--addressbook/gui/widgets/eab-vcard-control.h8
-rw-r--r--addressbook/gui/widgets/test-minicard-label.c129
-rw-r--r--addressbook/gui/widgets/test-minicard-view.c203
-rw-r--r--addressbook/gui/widgets/test-minicard.c120
92 files changed, 4915 insertions, 6848 deletions
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 @@
<oaf_info>
-<oaf_server iid="OAFIID:GNOME_Evolution_Addressbook_Factory"
+<oaf_server iid="OAFIID:GNOME_Evolution_Addressbook_Factory_2"
type="shlib"
location="@COMPONENTDIR@/libevolution-addressbook.so">
@@ -13,9 +13,9 @@
</oaf_server>
-<oaf_server iid="OAFIID:GNOME_Evolution_Addressbook_MiniCard_Control"
+<oaf_server iid="OAFIID:GNOME_Evolution_Addressbook_VCard_Control"
type="factory"
- location="OAFIID:GNOME_Evolution_Addressbook_Factory">
+ location="OAFIID:GNOME_Evolution_Addressbook_Factory_2">
<oaf_attribute name="repo_ids" type="stringv">
<item value="IDL:Bonobo/Control:1.0"/>
@@ -32,9 +32,9 @@
</oaf_server>
-<oaf_server iid="OAFIID:GNOME_Evolution_Addressbook_Control"
+<oaf_server iid="OAFIID:GNOME_Evolution_Addressbook_Control_2"
type="factory"
- location="OAFIID:GNOME_Evolution_Addressbook_Factory">
+ location="OAFIID:GNOME_Evolution_Addressbook_Factory_2">
<oaf_attribute name="repo_ids" type="stringv">
<item value="IDL:BonoboControl/addressbook-control:1.0"/>
@@ -46,27 +46,22 @@
</oaf_server>
-<oaf_server iid="OAFIID:GNOME_Evolution_Addressbook_ShellComponent"
+<oaf_server iid="OAFIID:GNOME_Evolution_Addressbook_Component"
type="factory"
- location="OAFIID:GNOME_Evolution_Addressbook_Factory">
+ location="OAFIID:GNOME_Evolution_Addressbook_Factory_2">
<oaf_attribute name="repo_ids" type="stringv">
- <item value="IDL:GNOME/Evolution/ShellComponent:1.0"/>
+ <item value="IDL:GNOME/Evolution/Component:1.0"/>
</oaf_attribute>
<oaf_attribute name="name" type="string"
_value="Evolution Addressbook component"/>
- <oaf_attribute name="evolution:shell_component_icon" type="string"
- value="evolution-contacts.png"/>
- <oaf_attribute name="evolution:shell_component_launch_order" type="number"
- value="2"/>
-
</oaf_server>
<oaf_server iid="OAFIID:GNOME_Evolution_Addressbook_AddressWidget"
type="factory"
- location="OAFIID:GNOME_Evolution_Addressbook_Factory">
+ location="OAFIID:GNOME_Evolution_Addressbook_Factory_2">
<oaf_attribute name="repo_ids" type="stringv">
<item value="IDL:BonoboControl/address-widget:1.0"/>
@@ -80,7 +75,7 @@
<oaf_server iid="OAFIID:GNOME_Evolution_Addressbook_AddressPopup"
type="factory"
- location="OAFIID:GNOME_Evolution_Addressbook_Factory">
+ location="OAFIID:GNOME_Evolution_Addressbook_Factory_2">
<oaf_attribute name="repo_ids" type="stringv">
<item value="IDL:BonoboControl/address-widget:1.0"/>
@@ -94,7 +89,7 @@
<oaf_server iid="OAFIID:GNOME_Evolution_LDAPStorage_ConfigControl"
type="factory"
- location="OAFIID:GNOME_Evolution_Addressbook_Factory">
+ location="OAFIID:GNOME_Evolution_Addressbook_Factory_2">
<oaf_attribute name="repo_ids" type="stringv">
<item value="IDL:GNOME/Evolution/ConfigControl:1.0"/>
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 <ettore@ximian.com>
*/
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <libgnomevfs/gnome-vfs-types.h>
-#include <libgnomevfs/gnome-vfs-uri.h>
-#include <libgnomevfs/gnome-vfs-ops.h>
-#include <libgnomevfs/gnome-vfs-directory.h>
-#include <libgnomevfs/gnome-vfs-file-info.h>
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <errno.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <bonobo/bonobo-generic-factory.h>
-#include <bonobo/bonobo-main.h>
-
-#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 <config.h>
-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 <gtk/gtkscrolledwindow.h>
+#include <gconf/gconf-client.h>
- *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 <ettore@ximian.com>
*/
-#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 <bonobo/bonobo-object.h>
-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 <string.h>
#include <glib.h>
-#include <gtk/gtkframe.h>
#include <gtk/gtkvbox.h>
#include <gtk/gtkwidget.h>
#include <gtk/gtkmessagedialog.h>
@@ -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 <ebook/e-book.h>
-#include <ebook/e-book-util.h>
+#include <ebook/e-book-async.h>
#include <widgets/misc/e-search-bar.h>
#include <widgets/misc/e-filter-bar.h>
@@ -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;
@@ -800,19 +786,6 @@ static ESearchBarItem addressbook_search_option_items[] = {
};
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)
{
ECategoriesMasterList *master_list;
@@ -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 <e-util/e-config-listener.h>
#include <bonobo/bonobo-object.h>
#include <bonobo/bonobo-moniker-util.h>
-#include <ebook/e-book.h>
+#include <ebook/e-book-async.h>
/* 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 <bonobo/bonobo-shlib-factory.h>
-#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.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 <trow@ximian.com>
- */
-
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA.
- */
-
-#ifndef __E_ADDRESS_POPUP_H__
-#define __E_ADDRESS_POPUP_H__
-
-#include <gtk/gtk.h>
-#include <addressbook/backend/ebook/e-book.h>
-#include <addressbook/backend/ebook/e-card.h>
-#include <bonobo/bonobo-event-source.h>
-
-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 <trow@ximian.com>
- */
-
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA.
- */
-
-#include <config.h>
-#include <ctype.h>
-#include <string.h>
-#include <gtk/gtklabel.h>
-#include <libgnomeui/gnome-popup-menu.h>
-#include <bonobo/bonobo-control.h>
-#include <bonobo/bonobo-property-bag.h>
-#include <bonobo/bonobo-generic-factory.h>
-#include <addressbook/gui/contact-editor/e-contact-quick-add.h>
-#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; i<N; ++i)
- pattern[i] = '_';
- pattern[i] = '\0';
- gtk_label_set_pattern (GTK_LABEL (addr->name_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 <trow@ximian.com>
- */
-
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA.
- */
-
-#ifndef __E_ADDRESS_WIDGET_H__
-#define __E_ADDRESS_WIDGET_H__
-
-#include <gtk/gtkeventbox.h>
-#include <gtk/gtkhbox.h>
-#include <gtk/gtkobject.h>
-#include <gtk/gtkwidget.h>
-#include <addressbook/backend/ebook/e-book-util.h>
-#include <addressbook/backend/ebook/e-card.h>
-
-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 <clahey@ximian.com>
- *
- * (C) 1999 Ximian, Inc.
- */
-
-#include <config.h>
-#include <libxml/tree.h>
-#include <libxml/parser.h>
-#include <libxml/xmlmemory.h>
-
-#include <string.h>
-
-#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 <gal/e-table/e-table-model.h>
-#include <ebook/e-book.h>
-#include <ebook/e-book-view.h>
-#include <ebook/e-card-simple.h>
-
-#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<SimpleCard> 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 @@
<oaf_server iid="OAFIID:GNOME_Evolution_Addressbook_SelectNames"
type="factory"
- location="OAFIID:GNOME_Evolution_Addressbook_Factory">
+ location="OAFIID:GNOME_Evolution_Addressbook_Factory_2">
<oaf_attribute name="repo_ids" type="stringv">
<item value="IDL:GNOME/Evolution/Addressbook/SelectNames"/>
@@ -28,4 +28,4 @@
</oaf_server>
-</oaf_info> \ No newline at end of file
+</oaf_info>
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 <bonobo-activation/bonobo-activation-activate.h>
@@ -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 <gtk/gtksignal.h>
-#include <addressbook/backend/ebook/e-book-util.h>
-#include <addressbook/backend/ebook/e-destination.h>
-#include <addressbook/backend/ebook/e-card-simple.h>
-#include <addressbook/backend/ebook/e-card-compare.h>
+#include <addressbook/util/eab-book-util.h>
+#include <addressbook/util/eab-destination.h>
+#include <addressbook/gui/merging/eab-contact-compare.h>
+#include <addressbook/backend/ebook/e-contact.h>
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; i<e_list_length (card->email); ++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 <gal/e-text/e-completion.h>
-#include <addressbook/backend/ebook/e-book.h>
+#include <addressbook/backend/ebook/e-book-async.h>
#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 <addressbook/backend/ebook/e-book-util.h>
-#include <addressbook/backend/ebook/e-destination.h>
+#include <addressbook/util/eab-book-util.h>
+#include <addressbook/util/eab-destination.h>
#include "addressbook/gui/component/addressbook.h"
#include <bonobo/bonobo-object.h>
@@ -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 <gtk/gtkobject.h>
#include <stdio.h>
#include <e-util/e-list.h>
-#include <addressbook/backend/ebook/e-card.h>
-#include <addressbook/backend/ebook/e-destination.h>
+#include <addressbook/backend/ebook/e-contact.h>
+#include <addressbook/util/eab-destination.h>
#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 <gtk/gtklabel.h>
#include <libgnome/gnome-i18n.h>
-#include <addressbook/backend/ebook/e-book-util.h>
+#include <addressbook/util/eab-book-util.h>
#include <addressbook/gui/contact-editor/e-contact-editor.h>
+#include <addressbook/gui/contact-list-editor/e-contact-list-editor.h>
#include <addressbook/gui/contact-editor/e-contact-quick-add.h>
-#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, "<?xml", 5)) {
- EDestination *dest = e_destination_import (email);
+ EABDestination *dest = eab_destination_import (email);
if (dest) {
- label = g_strdup (e_destination_get_textrep (dest, TRUE));
+ label = g_strdup (eab_destination_get_textrep (dest, TRUE));
g_object_unref (dest);
}
}
@@ -280,13 +283,14 @@ populate_popup_card (GtkWidget *pop, gboolean list, PopupInfo *info)
g_free (label);
}
-
- g_object_unref (iterator);
} else {
- menuitem = gtk_menu_item_new_with_label (e_destination_get_email (info->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 <libgnome/gnome-i18n.h>
#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 <addressbook/gui/contact-editor/e-contact-editor.h>
#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_count (model); ++i)
fprintf (out, "[%d] \"%s\" %s\n", i,
e_select_names_model_get_string (model, i),
- e_select_names_model_get_card (model, i) ? "<card>" : "");
+ e_select_names_model_get_contact (model, i) ? "<contact>" : "");
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 <addressbook/gui/widgets/e-addressbook-model.h>
#include <addressbook/gui/widgets/e-addressbook-table-adapter.h>
-#include <addressbook/gui/component/e-cardlist-model.h>
-#include <addressbook/backend/ebook/e-book.h>
-#include <addressbook/backend/ebook/e-book-util.h>
+#include <addressbook/backend/ebook/e-book-async.h>
+#include <addressbook/util/eab-book-util.h>
#include <addressbook/gui/component/addressbook-component.h>
#include <addressbook/gui/component/addressbook-storage.h>
#include <addressbook/gui/component/addressbook.h>
@@ -40,7 +39,7 @@
#include <shell/evolution-folder-selector-button.h>
#include "e-select-names.h"
-#include <addressbook/backend/ebook/e-card-simple.h>
+#include <addressbook/backend/ebook/e-contact.h>
#include "e-select-names-table-model.h"
#include <gal/widgets/e-categories-master-list-option-menu.h>
#include <gal/e-text/e-entry.h>
@@ -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 <ettore@ximian.com>
- * Chris Lahey <clahey@ximian.com>
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "e-simple-card-bonobo.h"
-
-#include <gal/util/e-util.h>
-
-#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 <ettore@ximian.com>
- * Chris Lahey <clahey@ximian.com>
- */
-
-#ifndef __E_SIMPLE_CARD_BONOBO_H__
-#define __E_SIMPLE_CARD_BONOBO_H__
-
-#include <bonobo/bonobo-object.h>
-
-#include "Evolution-Addressbook-SelectNames.h"
-#include <addressbook/backend/ebook/e-card-simple.h>
-
-#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__ */
diff --git a/addressbook/gui/contact-editor/Makefile.am b/addressbook/gui/contact-editor/Makefile.am
index fc3a0a71d0..ae9f99cd35 100644
--- a/addressbook/gui/contact-editor/Makefile.am
+++ b/addressbook/gui/contact-editor/Makefile.am
@@ -29,8 +29,6 @@ libecontacteditor_la_SOURCES = \
e-contact-editor-marshal.c \
e-contact-editor.c \
e-contact-editor.h \
- e-contact-save-as.c \
- e-contact-save-as.h \
e-contact-quick-add.c \
e-contact-quick-add.h
diff --git a/addressbook/gui/contact-editor/contact-editor.glade b/addressbook/gui/contact-editor/contact-editor.glade
index 2ef6954d10..10b05c27b4 100644
--- a/addressbook/gui/contact-editor/contact-editor.glade
+++ b/addressbook/gui/contact-editor/contact-editor.glade
@@ -1478,6 +1478,49 @@
<property name="y_options">fill</property>
</packing>
</child>
+
+ <child>
+ <widget class="GtkLabel" id="accellabel-blog">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Blog address:</property>
+ <property name="use_underline">True</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_CENTER</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">1</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="mnemonic_widget">entry-web</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">3</property>
+ <property name="top_attach">9</property>
+ <property name="bottom_attach">10</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="Custom" id="entry-blog">
+ <property name="visible">True</property>
+ <property name="creation_function">e_contact_editor_create_web</property>
+ <property name="int1">0</property>
+ <property name="int2">0</property>
+ <property name="last_modification_time">Sat, 08 Feb 2003 09:14:46 GMT</property>
+ </widget>
+ <packing>
+ <property name="left_attach">3</property>
+ <property name="right_attach">4</property>
+ <property name="top_attach">9</property>
+ <property name="bottom_attach">10</property>
+ <property name="x_options">fill</property>
+ <property name="y_options">fill</property>
+ </packing>
+ </child>
</widget>
<packing>
<property name="tab_expand">False</property>
diff --git a/addressbook/gui/contact-editor/e-contact-editor-address.c b/addressbook/gui/contact-editor/e-contact-editor-address.c
index da8bb5421f..34977e3fb7 100644
--- a/addressbook/gui/contact-editor/e-contact-editor-address.c
+++ b/addressbook/gui/contact-editor/e-contact-editor-address.c
@@ -420,7 +420,9 @@ e_contact_editor_address_init (EContactEditorAddress *e_contact_editor_address)
gtk_window_set_resizable(GTK_WINDOW(e_contact_editor_address), TRUE);
+#if notyet
e_contact_editor_address->address = NULL;
+#endif
gui = glade_xml_new (EVOLUTION_GLADEDIR "/fulladdr.glade", NULL, NULL);
e_contact_editor_address->gui = gui;
@@ -453,22 +455,26 @@ e_contact_editor_address_dispose (GObject *object)
e_contact_editor_address->gui = NULL;
}
+#if notyet
if (e_contact_editor_address->address) {
e_card_delivery_address_unref(e_contact_editor_address->address);
e_contact_editor_address->address = NULL;
}
+#endif
if (G_OBJECT_CLASS (parent_class)->dispose)
(* G_OBJECT_CLASS (parent_class)->dispose) (object);
}
GtkWidget*
-e_contact_editor_address_new (const ECardDeliveryAddress *address)
+e_contact_editor_address_new (/* XXX notyet const ECardDeliveryAddress *address*/)
{
GtkWidget *widget = g_object_new (E_TYPE_CONTACT_EDITOR_ADDRESS, NULL);
+#if notyet
g_object_set (widget,
"address", address,
NULL);
+#endif
return widget;
}
@@ -482,9 +488,11 @@ e_contact_editor_address_set_property (GObject *object, guint prop_id,
switch (prop_id){
case PROP_ADDRESS:
+#if notyet
e_card_delivery_address_unref(e_contact_editor_address->address);
e_contact_editor_address->address = e_card_delivery_address_copy(g_value_get_pointer (value));
fill_in_info(e_contact_editor_address);
+#endif
break;
case PROP_EDITABLE: {
int i;
@@ -540,7 +548,9 @@ e_contact_editor_address_get_property (GObject *object, guint prop_id,
switch (prop_id) {
case PROP_ADDRESS:
extract_info(e_contact_editor_address);
+#if notyet
g_value_set_pointer (value, e_card_delivery_address_ref(e_contact_editor_address->address));
+#endif
break;
case PROP_EDITABLE:
g_value_set_boolean (value, e_contact_editor_address->editable ? TRUE : FALSE);
@@ -566,6 +576,7 @@ fill_in_field(EContactEditorAddress *editor, char *field, char *string)
static void
fill_in_info(EContactEditorAddress *editor)
{
+#if notyet
ECardDeliveryAddress *address = editor->address;
if (address) {
fill_in_field(editor, "entry-street" , address->street );
@@ -576,6 +587,7 @@ fill_in_info(EContactEditorAddress *editor)
fill_in_field(editor, "entry-code" , address->code );
fill_in_field(editor, "entry-country", address->country);
}
+#endif
}
static char *
@@ -591,6 +603,7 @@ extract_field(EContactEditorAddress *editor, char *field)
static void
extract_info(EContactEditorAddress *editor)
{
+#if notyet
ECardDeliveryAddress *address = editor->address;
if (!address) {
address = e_card_delivery_address_new();
@@ -603,4 +616,5 @@ extract_info(EContactEditorAddress *editor)
address->region = extract_field(editor, "entry-region" );
address->code = extract_field(editor, "entry-code" );
address->country = extract_field(editor, "entry-country");
+#endif
}
diff --git a/addressbook/gui/contact-editor/e-contact-editor-address.h b/addressbook/gui/contact-editor/e-contact-editor-address.h
index 7faab47a4f..c20f020152 100644
--- a/addressbook/gui/contact-editor/e-contact-editor-address.h
+++ b/addressbook/gui/contact-editor/e-contact-editor-address.h
@@ -22,7 +22,7 @@
#include <gtk/gtkdialog.h>
#include <glade/glade.h>
-#include <ebook/e-card.h>
+#include <ebook/e-contact.h>
G_BEGIN_DECLS
@@ -49,8 +49,10 @@ struct _EContactEditorAddress
{
GtkDialog parent;
+#if notyet
/* item specific fields */
ECardDeliveryAddress *address;
+#endif
guint editable : 1;
@@ -63,7 +65,7 @@ struct _EContactEditorAddressClass
};
-GtkWidget *e_contact_editor_address_new(const ECardDeliveryAddress *name);
+GtkWidget *e_contact_editor_address_new(/* XXX not yet const ECardDeliveryAddress *name*/);
GType e_contact_editor_address_get_type (void);
G_END_DECLS
diff --git a/addressbook/gui/contact-editor/e-contact-editor-fullname.c b/addressbook/gui/contact-editor/e-contact-editor-fullname.c
index 4a7d6cec1b..c37f4cc8b7 100644
--- a/addressbook/gui/contact-editor/e-contact-editor-fullname.c
+++ b/addressbook/gui/contact-editor/e-contact-editor-fullname.c
@@ -1,8 +1,8 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
- * e-contact-editor-fullname.c
- * Copyright (C) 2000 Ximian, Inc.
- * Author: Chris Lahey <clahey@ximian.com>
+ * eab-contact-editor-phones.c
+ * Copyright (C) 2003 Ximian, Inc.
+ * Author: Chris Toshok <toshok@ximian.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public
@@ -142,7 +142,7 @@ e_contact_editor_fullname_dispose (GObject *object)
}
if (e_contact_editor_fullname->name) {
- e_card_name_unref(e_contact_editor_fullname->name);
+ e_contact_name_free(e_contact_editor_fullname->name);
e_contact_editor_fullname->name = NULL;
}
@@ -151,12 +151,12 @@ e_contact_editor_fullname_dispose (GObject *object)
}
GtkWidget*
-e_contact_editor_fullname_new (const ECardName *name)
+e_contact_editor_fullname_new (const EContactName *name)
{
GtkWidget *widget = g_object_new (E_TYPE_CONTACT_EDITOR_FULLNAME, NULL);
g_object_set (widget,
- "name", name,
- NULL);
+ "name", name,
+ NULL);
return widget;
}
@@ -170,8 +170,8 @@ e_contact_editor_fullname_set_property (GObject *object, guint prop_id,
switch (prop_id){
case PROP_NAME:
- e_card_name_unref(e_contact_editor_fullname->name);
- e_contact_editor_fullname->name = e_card_name_copy(g_value_get_pointer (value));
+ e_contact_name_free(e_contact_editor_fullname->name);
+ e_contact_editor_fullname->name = e_contact_name_copy(g_value_get_pointer (value));
fill_in_info(e_contact_editor_fullname);
break;
case PROP_EDITABLE: {
@@ -224,7 +224,7 @@ e_contact_editor_fullname_get_property (GObject *object, guint prop_id,
switch (prop_id) {
case PROP_NAME:
extract_info(e_contact_editor_fullname);
- g_value_set_pointer (value, e_card_name_ref(e_contact_editor_fullname->name));
+ g_value_set_pointer (value, e_contact_name_copy(e_contact_editor_fullname->name));
break;
case PROP_EDITABLE:
g_value_set_boolean (value, e_contact_editor_fullname->editable ? TRUE : FALSE);
@@ -250,13 +250,13 @@ fill_in_field(EContactEditorFullname *editor, char *field, char *string)
static void
fill_in_info(EContactEditorFullname *editor)
{
- ECardName *name = editor->name;
+ EContactName *name = editor->name;
if (name) {
- fill_in_field(editor, "entry-title", name->prefix);
+ fill_in_field(editor, "entry-title", name->prefixes);
fill_in_field(editor, "entry-first", name->given);
fill_in_field(editor, "entry-middle", name->additional);
fill_in_field(editor, "entry-last", name->family);
- fill_in_field(editor, "entry-suffix", name->suffix);
+ fill_in_field(editor, "entry-suffix", name->suffixes);
}
}
@@ -273,15 +273,15 @@ extract_field(EContactEditorFullname *editor, char *field)
static void
extract_info(EContactEditorFullname *editor)
{
- ECardName *name = editor->name;
+ EContactName *name = editor->name;
if (!name) {
- name = e_card_name_new();
+ name = e_contact_name_new();
editor->name = name;
}
- name->prefix = extract_field(editor, "entry-title" );
+ name->prefixes = extract_field(editor, "entry-title" );
name->given = extract_field(editor, "entry-first" );
name->additional = extract_field(editor, "entry-middle");
name->family = extract_field(editor, "entry-last" );
- name->suffix = extract_field(editor, "entry-suffix");
+ name->suffixes = extract_field(editor, "entry-suffix");
}
diff --git a/addressbook/gui/contact-editor/e-contact-editor-fullname.h b/addressbook/gui/contact-editor/e-contact-editor-fullname.h
index 3c8e055a96..408fcffdc3 100644
--- a/addressbook/gui/contact-editor/e-contact-editor-fullname.h
+++ b/addressbook/gui/contact-editor/e-contact-editor-fullname.h
@@ -22,7 +22,7 @@
#include <gtk/gtkdialog.h>
#include <glade/glade.h>
-#include <ebook/e-card.h>
+#include <ebook/e-contact.h>
G_BEGIN_DECLS
@@ -50,7 +50,7 @@ struct _EContactEditorFullname
GtkDialog parent;
/* item specific fields */
- ECardName *name;
+ EContactName *name;
GladeXML *gui;
/* Whether the dialog will accept modifications */
@@ -63,7 +63,7 @@ struct _EContactEditorFullnameClass
};
-GtkWidget *e_contact_editor_fullname_new(const ECardName *name);
+GtkWidget *e_contact_editor_fullname_new(const EContactName *name);
GType e_contact_editor_fullname_get_type (void);
G_END_DECLS
diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c
index 2330daf063..1391ccf1b0 100644
--- a/addressbook/gui/contact-editor/e-contact-editor.c
+++ b/addressbook/gui/contact-editor/e-contact-editor.c
@@ -49,29 +49,28 @@
#include "addressbook/printing/e-contact-print.h"
#include "addressbook/printing/e-contact-print-envelope.h"
-#include "addressbook/gui/widgets/e-addressbook-util.h"
+#include "addressbook/gui/widgets/eab-gui-util.h"
#include "e-util/e-gui-utils.h"
#include "widgets/misc/e-dateedit.h"
#include "widgets/misc/e-url-entry.h"
#include "shell/evolution-shell-component-utils.h"
-#include "e-card-merging.h"
+#include "eab-contact-merging.h"
#include "e-contact-editor-address.h"
#include "e-contact-editor-fullname.h"
#include "e-contact-editor-marshal.h"
-#include "e-contact-save-as.h"
/* Signal IDs */
enum {
- CARD_ADDED,
- CARD_MODIFIED,
- CARD_DELETED,
+ CONTACT_ADDED,
+ CONTACT_MODIFIED,
+ CONTACT_DELETED,
EDITOR_CLOSED,
LAST_SIGNAL
};
-static void e_contact_editor_init (EContactEditor *card);
+static void e_contact_editor_init (EContactEditor *editor);
static void e_contact_editor_class_init (EContactEditorClass *klass);
static void e_contact_editor_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
static void e_contact_editor_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
@@ -85,9 +84,10 @@ static void enable_writable_fields(EContactEditor *editor);
static void set_editable(EContactEditor *editor);
static void fill_in_info(EContactEditor *editor);
static void extract_info(EContactEditor *editor);
-static void set_fields(EContactEditor *editor);
+static void set_field(EContactEditor *editor, GtkEntry *entry, const char *string);
static void set_address_field(EContactEditor *editor, int result);
-static void add_field_callback(GtkWidget *widget, EContactEditor *editor);
+static void set_phone_field(EContactEditor *editor, GtkWidget *entry, const char *phone_number);
+static void set_fields(EContactEditor *editor);
static void command_state_changed (EContactEditor *ce);
static void widget_changed (GtkWidget *widget, EContactEditor *editor);
static void close_dialog (EContactEditor *ce);
@@ -101,8 +101,8 @@ static guint contact_editor_signals[LAST_SIGNAL];
enum {
PROP_0,
PROP_BOOK,
- PROP_CARD,
- PROP_IS_NEW_CARD,
+ PROP_CONTACT,
+ PROP_IS_NEW_CONTACT,
PROP_EDITABLE,
PROP_CHANGED,
PROP_WRITABLE_FIELDS
@@ -114,6 +114,34 @@ enum {
DYNAMIC_LIST_ADDRESS
};
+static EContactField phones[] = {
+ E_CONTACT_PHONE_ASSISTANT,
+ E_CONTACT_PHONE_BUSINESS,
+ E_CONTACT_PHONE_BUSINESS_2,
+ E_CONTACT_PHONE_BUSINESS_FAX,
+ E_CONTACT_PHONE_CALLBACK,
+ E_CONTACT_PHONE_CAR,
+ E_CONTACT_PHONE_COMPANY,
+ E_CONTACT_PHONE_HOME,
+ E_CONTACT_PHONE_HOME_2,
+ E_CONTACT_PHONE_HOME_FAX,
+ E_CONTACT_PHONE_ISDN,
+ E_CONTACT_PHONE_MOBILE,
+ E_CONTACT_PHONE_OTHER,
+ E_CONTACT_PHONE_OTHER_FAX,
+ E_CONTACT_PHONE_PAGER,
+ E_CONTACT_PHONE_PRIMARY,
+ E_CONTACT_PHONE_RADIO,
+ E_CONTACT_PHONE_TELEX,
+ E_CONTACT_PHONE_TTYTDD,
+};
+
+static EContactField emails[] = {
+ E_CONTACT_EMAIL_1,
+ E_CONTACT_EMAIL_2,
+ E_CONTACT_EMAIL_3
+};
+
static GSList *all_contact_editors = NULL;
GType
@@ -158,16 +186,16 @@ e_contact_editor_class_init (EContactEditorClass *klass)
E_TYPE_BOOK,
G_PARAM_READWRITE));
- g_object_class_install_property (object_class, PROP_CARD,
- g_param_spec_object ("card",
- _("Card"),
+ g_object_class_install_property (object_class, PROP_CONTACT,
+ g_param_spec_object ("contact",
+ _("Contact"),
/*_( */"XXX blurb" /*)*/,
- E_TYPE_CARD,
+ E_TYPE_CONTACT,
G_PARAM_READWRITE));
- g_object_class_install_property (object_class, PROP_IS_NEW_CARD,
- g_param_spec_boolean ("is_new_card",
- _("Is New Card"),
+ g_object_class_install_property (object_class, PROP_IS_NEW_CONTACT,
+ g_param_spec_boolean ("is_new_contact",
+ _("Is New Contact"),
/*_( */"XXX blurb" /*)*/,
FALSE,
G_PARAM_READWRITE));
@@ -193,31 +221,31 @@ e_contact_editor_class_init (EContactEditorClass *klass)
FALSE,
G_PARAM_READWRITE));
- contact_editor_signals[CARD_ADDED] =
- g_signal_new ("card_added",
+ contact_editor_signals[CONTACT_ADDED] =
+ g_signal_new ("contact_added",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (EContactEditorClass, card_added),
+ G_STRUCT_OFFSET (EContactEditorClass, contact_added),
NULL, NULL,
e_contact_editor_marshal_NONE__INT_OBJECT,
G_TYPE_NONE, 2,
G_TYPE_INT, G_TYPE_OBJECT);
- contact_editor_signals[CARD_MODIFIED] =
- g_signal_new ("card_modified",
+ contact_editor_signals[CONTACT_MODIFIED] =
+ g_signal_new ("contact_modified",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (EContactEditorClass, card_modified),
+ G_STRUCT_OFFSET (EContactEditorClass, contact_modified),
NULL, NULL,
e_contact_editor_marshal_NONE__INT_OBJECT,
G_TYPE_NONE, 2,
G_TYPE_INT, G_TYPE_OBJECT);
- contact_editor_signals[CARD_DELETED] =
- g_signal_new ("card_deleted",
+ contact_editor_signals[CONTACT_DELETED] =
+ g_signal_new ("contact_deleted",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (EContactEditorClass, card_deleted),
+ G_STRUCT_OFFSET (EContactEditorClass, contact_deleted),
NULL, NULL,
e_contact_editor_marshal_NONE__INT_OBJECT,
G_TYPE_NONE, 2,
@@ -259,11 +287,10 @@ wants_html_changed (GtkWidget *widget, EContactEditor *editor)
{
gboolean wants_html;
g_object_get (widget,
- "active", &wants_html,
- NULL);
- g_object_set (editor->card,
- "wants_html", wants_html,
- NULL);
+ "active", &wants_html,
+ NULL);
+
+ e_contact_set (editor->contact, E_CONTACT_WANTS_HTML, GINT_TO_POINTER (wants_html));
widget_changed (widget, editor);
}
@@ -273,23 +300,20 @@ phone_entry_changed (GtkWidget *widget, EContactEditor *editor)
{
int which;
GtkEntry *entry = GTK_ENTRY(widget);
- ECardPhone *phone;
- if ( widget == glade_xml_get_widget(editor->gui, "entry-phone1") ) {
+ if ( widget == glade_xml_get_widget(editor->gui, "entry-phone1") )
which = 1;
- } else if ( widget == glade_xml_get_widget(editor->gui, "entry-phone2") ) {
+ else if ( widget == glade_xml_get_widget(editor->gui, "entry-phone2") )
which = 2;
- } else if ( widget == glade_xml_get_widget(editor->gui, "entry-phone3") ) {
+ else if ( widget == glade_xml_get_widget(editor->gui, "entry-phone3") )
which = 3;
- } else if ( widget == glade_xml_get_widget(editor->gui, "entry-phone4") ) {
+ else if ( widget == glade_xml_get_widget(editor->gui, "entry-phone4") )
which = 4;
- } else
+ else
return;
- phone = e_card_phone_new();
- phone->number = g_strdup (gtk_entry_get_text(entry));
- e_card_simple_set_phone(editor->simple, editor->phone_choice[which - 1], phone);
- e_card_phone_unref(phone);
- set_fields(editor);
+
+ printf ("gtk_entry_get_text(entry) == %s\n", (char*)gtk_entry_get_text(entry));
+ e_contact_set(editor->contact, editor->phone_choice[which - 1], (char*)gtk_entry_get_text(entry));
widget_changed (widget, editor);
}
@@ -297,12 +321,9 @@ phone_entry_changed (GtkWidget *widget, EContactEditor *editor)
static void
email_entry_changed (GtkWidget *widget, EContactEditor *editor)
{
- const gchar *string;
GtkEntry *entry = GTK_ENTRY(widget);
- string = gtk_entry_get_text(entry);
-
- e_card_simple_set_email(editor->simple, editor->email_choice, string);
+ e_contact_set (editor->contact, editor->email_choice, (char*)gtk_entry_get_text(entry));
widget_changed (widget, editor);
}
@@ -310,6 +331,7 @@ email_entry_changed (GtkWidget *widget, EContactEditor *editor)
static void
address_text_changed (GtkTextBuffer *buffer, EContactEditor *editor)
{
+#if notyet
ECardAddrLabel *address;
GtkTextIter start_iter, end_iter;
@@ -346,12 +368,14 @@ address_text_changed (GtkTextBuffer *buffer, EContactEditor *editor)
e_card_address_label_unref(address);
widget_changed (NULL, editor);
+#endif
}
static void
address_mailing_changed (GtkWidget *widget, EContactEditor *editor)
{
+#if notyet
const ECardDeliveryAddress *curr;
ECardDeliveryAddress *address;
gboolean mailing_address;
@@ -399,12 +423,13 @@ address_mailing_changed (GtkWidget *widget, EContactEditor *editor)
editor->address_mailing = -1;
widget_changed (widget, editor);
+#endif
}
/* This function tells you whether name_to_style will make sense. */
static gboolean
-style_makes_sense(const ECardName *name, char *company, int style)
+style_makes_sense(const EContactName *name, char *company, int style)
{
switch (style) {
case 0: /* Fall Through */
@@ -427,7 +452,7 @@ style_makes_sense(const ECardName *name, char *company, int style)
}
static char *
-name_to_style(const ECardName *name, char *company, int style)
+name_to_style(const EContactName *name, char *company, int style)
{
char *string;
char *strings[4], **stringptr;
@@ -489,7 +514,7 @@ file_as_get_style (EContactEditor *editor)
GtkEntry *file_as = GTK_ENTRY(glade_xml_get_widget(editor->gui, "entry-file-as"));
char *filestring;
char *trystring;
- ECardName *name = editor->name;
+ EContactName *name = editor->name;
int i;
int style;
@@ -561,11 +586,12 @@ name_entry_changed (GtkWidget *widget, EContactEditor *editor)
const char *string;
style = file_as_get_style(editor);
-
- e_card_name_unref(editor->name);
+
+ e_contact_name_free (editor->name);
string = gtk_entry_get_text (GTK_ENTRY(widget));
- editor->name = e_card_name_from_string(string);
+
+ editor->name = e_contact_name_from_string(string);
file_as_set_style(editor, style);
@@ -680,6 +706,7 @@ set_entry_changed_signals(EContactEditor *editor)
}
set_urlentry_changed_signal_field (editor, "entry-web");
+ set_urlentry_changed_signal_field (editor, "entry-blog");
set_urlentry_changed_signal_field (editor, "entry-caluri");
set_urlentry_changed_signal_field (editor, "entry-fburl");
@@ -719,32 +746,32 @@ full_name_clicked(GtkWidget *button, EContactEditor *editor)
int result;
g_object_set (dialog,
- "editable", editor->fullname_editable,
- NULL);
+ "editable", editor->fullname_editable,
+ NULL);
gtk_widget_show(GTK_WIDGET(dialog));
result = gtk_dialog_run (dialog);
gtk_widget_hide (GTK_WIDGET (dialog));
if (editor->fullname_editable && result == GTK_RESPONSE_OK) {
- ECardName *name;
+ EContactName *name;
GtkWidget *fname_widget;
int style = 0;
g_object_get (dialog,
- "name", &name,
- NULL);
+ "name", &name,
+ NULL);
style = file_as_get_style(editor);
fname_widget = glade_xml_get_widget(editor->gui, "entry-fullname");
if (fname_widget && GTK_IS_ENTRY(fname_widget)) {
- char *full_name = e_card_name_to_string(name);
+ char *full_name = e_contact_name_to_string(name);
gtk_entry_set_text(GTK_ENTRY(fname_widget), full_name);
g_free(full_name);
}
- e_card_name_unref(editor->name);
- editor->name = e_card_name_ref(name);
+ e_contact_name_free(editor->name);
+ editor->name = name;
file_as_set_style(editor, style);
}
@@ -754,6 +781,7 @@ full_name_clicked(GtkWidget *button, EContactEditor *editor)
static void
full_addr_clicked(GtkWidget *button, EContactEditor *editor)
{
+#if notyet
GtkDialog *dialog;
int result;
const ECardDeliveryAddress *address;
@@ -802,6 +830,7 @@ full_addr_clicked(GtkWidget *button, EContactEditor *editor)
widget_changed (NULL, editor);
}
gtk_widget_destroy (GTK_WIDGET (dialog));
+#endif
}
static void
@@ -814,10 +843,9 @@ categories_clicked(GtkWidget *button, EContactEditor *editor)
ECategoriesMasterList *ecml;
if (entry && GTK_IS_ENTRY(entry))
categories = g_strdup (gtk_entry_get_text(GTK_ENTRY(entry)));
- else if (editor->card)
- g_object_get (editor->card,
- "categories", &categories,
- NULL);
+ else if (editor->contact)
+ categories = e_contact_get (editor->contact, E_CONTACT_CATEGORIES);
+
dialog = GTK_DIALOG(e_categories_new(categories));
if (dialog == NULL) {
@@ -841,14 +869,13 @@ categories_clicked(GtkWidget *button, EContactEditor *editor)
g_free (categories);
if (result == GTK_RESPONSE_OK) {
g_object_get (dialog,
- "categories", &categories,
- NULL);
+ "categories", &categories,
+ NULL);
if (entry && GTK_IS_ENTRY(entry))
gtk_entry_set_text(GTK_ENTRY(entry), categories);
else
- g_object_set (editor->card,
- "categories", categories,
- NULL);
+ e_contact_set (editor->contact, E_CONTACT_CATEGORIES, categories);
+
g_free(categories);
}
gtk_widget_destroy(GTK_WIDGET(dialog));
@@ -860,7 +887,7 @@ typedef struct {
} EditorCloseStruct;
static void
-card_added_cb (EBook *book, EBookStatus status, const char *id, EditorCloseStruct *ecs)
+contact_added_cb (EBook *book, EBookStatus status, const char *id, EditorCloseStruct *ecs)
{
EContactEditor *ce = ecs->ce;
gboolean should_close = ecs->should_close;
@@ -868,13 +895,13 @@ card_added_cb (EBook *book, EBookStatus status, const char *id, EditorCloseStruc
gtk_widget_set_sensitive (ce->app, TRUE);
ce->in_async_call = FALSE;
- e_card_set_id (ce->card, id);
+ e_contact_set (ce->contact, E_CONTACT_UID, (char*)id);
- g_signal_emit (ce, contact_editor_signals[CARD_ADDED], 0,
- status, ce->card);
+ g_signal_emit (ce, contact_editor_signals[CONTACT_ADDED], 0,
+ status, ce->contact);
- if (status == E_BOOK_STATUS_SUCCESS) {
- ce->is_new_card = FALSE;
+ if (status == E_BOOK_ERROR_OK) {
+ ce->is_new_contact = FALSE;
if (should_close) {
close_dialog (ce);
@@ -890,7 +917,7 @@ card_added_cb (EBook *book, EBookStatus status, const char *id, EditorCloseStruc
}
static void
-card_modified_cb (EBook *book, EBookStatus status, EditorCloseStruct *ecs)
+contact_modified_cb (EBook *book, EBookStatus status, EditorCloseStruct *ecs)
{
EContactEditor *ce = ecs->ce;
gboolean should_close = ecs->should_close;
@@ -898,10 +925,10 @@ card_modified_cb (EBook *book, EBookStatus status, EditorCloseStruct *ecs)
gtk_widget_set_sensitive (ce->app, TRUE);
ce->in_async_call = FALSE;
- g_signal_emit (ce, contact_editor_signals[CARD_MODIFIED], 0,
- status, ce->card);
+ g_signal_emit (ce, contact_editor_signals[CONTACT_MODIFIED], 0,
+ status, ce->contact);
- if (status == E_BOOK_STATUS_SUCCESS) {
+ if (status == E_BOOK_ERROR_OK) {
if (should_close) {
close_dialog (ce);
}
@@ -915,12 +942,11 @@ card_modified_cb (EBook *book, EBookStatus status, EditorCloseStruct *ecs)
g_free (ecs);
}
-/* Emits the signal to request saving a card */
+/* Emits the signal to request saving a contact */
static void
-save_card (EContactEditor *ce, gboolean should_close)
+save_contact (EContactEditor *ce, gboolean should_close)
{
extract_info (ce);
- e_card_simple_sync_card (ce->simple);
if (ce->book) {
EditorCloseStruct *ecs = g_new(EditorCloseStruct, 1);
@@ -933,10 +959,10 @@ save_card (EContactEditor *ce, gboolean should_close)
gtk_widget_set_sensitive (ce->app, FALSE);
ce->in_async_call = TRUE;
- if (ce->is_new_card)
- e_card_merging_book_add_card (ce->book, ce->card, (EBookIdCallback)card_added_cb, ecs);
+ if (ce->is_new_contact)
+ eab_merging_book_add_contact (ce->book, ce->contact, (EBookIdCallback)contact_added_cb, ecs);
else
- e_card_merging_book_commit_card (ce->book, ce->card, (EBookCallback)card_modified_cb, ecs);
+ eab_merging_book_commit_contact (ce->book, ce->contact, (EBookCallback)contact_modified_cb, ecs);
}
}
@@ -957,9 +983,9 @@ prompt_to_save_changes (EContactEditor *editor)
if (!editor->changed)
return TRUE;
- switch (e_addressbook_prompt_save_dialog (GTK_WINDOW(editor->app))) {
+ switch (eab_prompt_save_dialog (GTK_WINDOW(editor->app))) {
case GTK_RESPONSE_YES:
- save_card (editor, FALSE);
+ save_contact (editor, FALSE);
return TRUE;
case GTK_RESPONSE_NO:
return TRUE;
@@ -978,7 +1004,7 @@ file_save_cb (GtkWidget *widget, gpointer data)
EContactEditor *ce;
ce = E_CONTACT_EDITOR (data);
- save_card (ce, FALSE);
+ save_contact (ce, FALSE);
}
/* File/Close callback */
@@ -998,45 +1024,38 @@ static void
file_save_as_cb (GtkWidget *widget, gpointer data)
{
EContactEditor *ce;
- ECard *card;
+ EContact *contact;
ce = E_CONTACT_EDITOR (data);
extract_info (ce);
- e_card_simple_sync_card (ce->simple);
- card = ce->card;
- e_contact_save_as(_("Save Contact as VCard"), card, GTK_WINDOW (ce->app));
+ contact = ce->contact;
+ eab_contact_save(_("Save Contact as VCard"), contact, GTK_WINDOW (ce->app));
}
static void
file_send_as_cb (GtkWidget *widget, gpointer data)
{
EContactEditor *ce;
- ECard *card;
ce = E_CONTACT_EDITOR (data);
extract_info (ce);
- e_card_simple_sync_card (ce->simple);
- card = ce->card;
- e_addressbook_send_card(card, E_ADDRESSBOOK_DISPOSITION_AS_ATTACHMENT);
+ eab_send_contact(ce->contact, EAB_DISPOSITION_AS_ATTACHMENT);
}
static void
file_send_to_cb (GtkWidget *widget, gpointer data)
{
EContactEditor *ce;
- ECard *card;
ce = E_CONTACT_EDITOR (data);
extract_info (ce);
- e_card_simple_sync_card (ce->simple);
- card = ce->card;
- e_addressbook_send_card(card, E_ADDRESSBOOK_DISPOSITION_AS_TO);
+ eab_send_contact(ce->contact, EAB_DISPOSITION_AS_TO);
}
gboolean
@@ -1071,16 +1090,16 @@ e_contact_editor_confirm_delete (GtkWindow *parent)
}
static void
-card_deleted_cb (EBook *book, EBookStatus status, EContactEditor *ce)
+contact_deleted_cb (EBook *book, EBookStatus status, EContactEditor *ce)
{
gtk_widget_set_sensitive (ce->app, TRUE);
ce->in_async_call = FALSE;
- g_signal_emit (ce, contact_editor_signals[CARD_DELETED], 0,
- status, ce->card);
+ g_signal_emit (ce, contact_editor_signals[CONTACT_DELETED], 0,
+ status, ce->contact);
/* always close the dialog after we successfully delete a card */
- if (status == E_BOOK_STATUS_SUCCESS)
+ if (status == E_BOOK_ERROR_OK)
close_dialog (ce);
}
@@ -1088,27 +1107,23 @@ static void
delete_cb (GtkWidget *widget, gpointer data)
{
EContactEditor *ce = E_CONTACT_EDITOR (data);
- ECard *card = ce->card;
- ECardSimple *simple = ce->simple;
+ EContact *contact = ce->contact;
- g_object_ref(card);
- g_object_ref(simple);
+ g_object_ref(contact);
if (e_contact_editor_confirm_delete(GTK_WINDOW(ce->app))) {
extract_info (ce);
- e_card_simple_sync_card (simple);
- if (!ce->is_new_card && ce->book) {
+ if (!ce->is_new_contact && ce->book) {
gtk_widget_set_sensitive (ce->app, FALSE);
ce->in_async_call = TRUE;
- e_book_remove_card (ce->book, card, (EBookCallback)card_deleted_cb, ce);
+ e_book_async_remove_contact (ce->book, contact, (EBookCallback)contact_deleted_cb, ce);
}
}
- g_object_unref(card);
- g_object_unref(simple);
+ g_object_unref(contact);
}
/* Emits the signal to request printing a card */
@@ -1120,9 +1135,8 @@ print_cb (BonoboUIComponent *uih, void *data, const char *path)
ce = E_CONTACT_EDITOR (data);
extract_info (ce);
- e_card_simple_sync_card (ce->simple);
- gtk_widget_show(e_contact_print_card_dialog_new(ce->card));
+ gtk_widget_show(e_contact_print_contact_dialog_new(ce->contact));
}
#if 0 /* Envelope printing is disabled for Evolution 1.0. */
@@ -1148,7 +1162,7 @@ tb_save_and_close_cb (BonoboUIComponent *uih, void *data, const char *path)
EContactEditor *ce;
ce = E_CONTACT_EDITOR (data);
- save_card (ce, TRUE);
+ save_contact (ce, TRUE);
}
static
@@ -1244,6 +1258,7 @@ setup_tab_order(GladeXML *gui)
list = add_to_tab_order(list, gui, "entry-email1");
list = add_to_tab_order(list, gui, "alignment-htmlmail");
list = add_to_tab_order(list, gui, "entry-web");
+ list = add_to_tab_order(list, gui, "entry-blog");
list = add_to_tab_order(list, gui, "button-fulladdr");
list = add_to_tab_order(list, gui, "text-address");
list = g_list_reverse(list);
@@ -1271,22 +1286,20 @@ e_contact_editor_init (EContactEditor *e_contact_editor)
e_contact_editor->email_list = NULL;
e_contact_editor->phone_list = NULL;
e_contact_editor->address_list = NULL;
- e_contact_editor->name = e_card_name_new();
+ e_contact_editor->name = e_contact_name_new();
e_contact_editor->company = g_strdup("");
- e_contact_editor->email_choice = 0;
- e_contact_editor->phone_choice[0] = E_CARD_SIMPLE_PHONE_ID_BUSINESS;
- e_contact_editor->phone_choice[1] = E_CARD_SIMPLE_PHONE_ID_HOME;
- e_contact_editor->phone_choice[2] = E_CARD_SIMPLE_PHONE_ID_BUSINESS_FAX;
- e_contact_editor->phone_choice[3] = E_CARD_SIMPLE_PHONE_ID_MOBILE;
+ e_contact_editor->email_choice = E_CONTACT_EMAIL_1;
+ e_contact_editor->phone_choice[0] = E_CONTACT_PHONE_BUSINESS;
+ e_contact_editor->phone_choice[1] = E_CONTACT_PHONE_HOME;
+ e_contact_editor->phone_choice[2] = E_CONTACT_PHONE_BUSINESS_FAX;
+ e_contact_editor->phone_choice[3] = E_CONTACT_PHONE_MOBILE;
+#if 0
e_contact_editor->address_choice = 0;
e_contact_editor->address_mailing = -1;
+#endif
- e_contact_editor->arbitrary_fields = NULL;
-
- e_contact_editor->simple = e_card_simple_new(NULL);
-
- e_contact_editor->card = NULL;
+ e_contact_editor->contact = NULL;
e_contact_editor->changed = FALSE;
e_contact_editor->in_async_call = FALSE;
e_contact_editor->editable = TRUE;
@@ -1298,10 +1311,6 @@ e_contact_editor_init (EContactEditor *e_contact_editor)
e_contact_editor->app = glade_xml_get_widget (gui, "contact editor");
- e_container_foreach_leaf (GTK_CONTAINER (e_contact_editor->app),
- (GtkCallback) add_field_callback,
- e_contact_editor);
-
connect_arrow_button_signals(e_contact_editor);
set_entry_changed_signals(e_contact_editor);
@@ -1429,23 +1438,18 @@ e_contact_editor_dispose (GObject *object) {
e_contact_editor->address_popup = NULL;
}
- if (e_contact_editor->simple) {
- g_object_unref(e_contact_editor->simple);
- e_contact_editor->simple = NULL;
+ if (e_contact_editor->contact) {
+ g_object_unref(e_contact_editor->contact);
+ e_contact_editor->contact = NULL;
}
- if (e_contact_editor->card) {
- g_object_unref(e_contact_editor->card);
- e_contact_editor->card = NULL;
- }
-
if (e_contact_editor->book) {
g_object_unref(e_contact_editor->book);
e_contact_editor->book = NULL;
}
if (e_contact_editor->name) {
- e_card_name_unref(e_contact_editor->name);
+ e_contact_name_free(e_contact_editor->name);
e_contact_editor->name = NULL;
}
@@ -1474,7 +1478,7 @@ command_state_changed (EContactEditor *ce)
bonobo_ui_component_set_prop (ce->uic,
"/commands/ContactEditorDelete",
"sensitive",
- (ce->editable && !ce->is_new_card) ? "1" : "0", NULL);
+ (ce->editable && !ce->is_new_contact) ? "1" : "0", NULL);
}
static void
@@ -1506,14 +1510,14 @@ contact_editor_destroy_notify (void *data,
EContactEditor *
e_contact_editor_new (EBook *book,
- ECard *card,
- gboolean is_new_card,
+ EContact *contact,
+ gboolean is_new_contact,
gboolean editable)
{
EContactEditor *ce;
g_return_val_if_fail (E_IS_BOOK (book), NULL);
- g_return_val_if_fail (E_IS_CARD (card), NULL);
+ g_return_val_if_fail (E_IS_CONTACT (contact), NULL);
ce = g_object_new (E_TYPE_CONTACT_EDITOR, NULL);
@@ -1525,13 +1529,13 @@ e_contact_editor_new (EBook *book,
g_object_set (ce,
"book", book,
- "card", card,
- "is_new_card", is_new_card,
+ "contact", contact,
+ "is_new_contact", is_new_contact,
"editable", editable,
NULL);
if (book)
- e_book_get_supported_fields (book, (EBookFieldsCallback)supported_fields_cb, ce);
+ e_book_async_get_supported_fields (book, (EBookFieldsCallback)supported_fields_cb, ce);
return ce;
}
@@ -1551,19 +1555,16 @@ e_contact_editor_set_property (GObject *object, guint prop_id, const GValue *val
g_object_ref (editor->book);
/* XXX more here about editable/etc. */
break;
- case PROP_CARD:
- if (editor->card)
- g_object_unref(editor->card);
- editor->card = e_card_duplicate(E_CARD(g_value_get_object (value)));
- g_object_set(editor->simple,
- "card", editor->card,
- NULL);
+ case PROP_CONTACT:
+ if (editor->contact)
+ g_object_unref(editor->contact);
+ editor->contact = e_contact_duplicate(E_CONTACT(g_value_get_object (value)));
fill_in_info(editor);
editor->changed = FALSE;
break;
- case PROP_IS_NEW_CARD:
- editor->is_new_card = g_value_get_boolean (value) ? TRUE : FALSE;
+ case PROP_IS_NEW_CONTACT:
+ editor->is_new_contact = g_value_get_boolean (value) ? TRUE : FALSE;
break;
case PROP_EDITABLE: {
@@ -1617,14 +1618,13 @@ e_contact_editor_get_property (GObject *object, guint prop_id, GValue *value, GP
g_value_set_object (value, e_contact_editor->book);
break;
- case PROP_CARD:
- e_card_simple_sync_card(e_contact_editor->simple);
+ case PROP_CONTACT:
extract_info(e_contact_editor);
- g_value_set_object (value, e_contact_editor->card);
+ g_value_set_object (value, e_contact_editor->contact);
break;
- case PROP_IS_NEW_CARD:
- g_value_set_boolean (value, e_contact_editor->is_new_card ? TRUE : FALSE);
+ case PROP_IS_NEW_CONTACT:
+ g_value_set_boolean (value, e_contact_editor->is_new_contact ? TRUE : FALSE);
break;
case PROP_EDITABLE:
@@ -1730,33 +1730,11 @@ e_contact_editor_build_ui_info(GList *list, GnomeUIInfo **infop)
static void
e_contact_editor_build_phone_ui (EContactEditor *editor)
{
- int i;
-
if (editor->phone_list == NULL) {
- static char *info[] = {
- N_("Assistant"),
- N_("Business"),
- N_("Business 2"),
- N_("Business Fax"),
- N_("Callback"),
- N_("Car"),
- N_("Company"),
- N_("Home"),
- N_("Home 2"),
- N_("Home Fax"),
- N_("ISDN"),
- N_("Mobile"),
- N_("Other"),
- N_("Other Fax"),
- N_("Pager"),
- N_("Primary"),
- N_("Radio"),
- N_("Telex"),
- N_("TTY/TDD")
- };
-
- for (i = 0; i < sizeof(info) / sizeof(info[0]); i++) {
- editor->phone_list = g_list_append(editor->phone_list, g_strdup(info[i]));
+ int i;
+
+ for (i = 0; i < G_N_ELEMENTS (phones); i ++) {
+ editor->phone_list = g_list_append(editor->phone_list, g_strdup(e_contact_pretty_name (phones[i])));
}
}
if (editor->phone_info == NULL) {
@@ -1777,15 +1755,8 @@ e_contact_editor_build_email_ui (EContactEditor *editor)
int i;
if (editor->email_list == NULL) {
- static char *info[] = {
- N_("Primary Email"),
- N_("Email 2"),
- N_("Email 3")
- };
-
- for (i = 0; i < sizeof(info) / sizeof(info[0]); i++) {
- editor->email_list = g_list_append(editor->email_list, g_strdup(info[i]));
- }
+ for (i = 0; i < G_N_ELEMENTS (emails); i++)
+ editor->email_list = g_list_append(editor->email_list, g_strdup(e_contact_pretty_name (emails[i])));
}
if (editor->email_info == NULL) {
e_contact_editor_build_ui_info(editor->email_list, &editor->email_info);
@@ -1851,21 +1822,21 @@ _phone_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEditor
e_contact_editor_build_phone_ui (editor);
- for(i = 0; i < E_CARD_SIMPLE_PHONE_ID_LAST; i++) {
- const ECardPhone *phone = e_card_simple_get_phone(editor->simple, i);
- gboolean checked;
- checked = phone && phone->number && *phone->number;
+ for(i = 0; i < G_N_ELEMENTS (phones); i++) {
+ char *phone = e_contact_get (editor->contact, phones[i]);
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(editor->phone_info[i].widget),
- checked);
+ phone && *phone);
+ g_free (phone);
}
result = _arrow_pressed (widget, button, editor, editor->phone_popup, &editor->phone_list, &editor->phone_info, label);
if (result != -1) {
- editor->phone_choice[which - 1] = result;
- set_fields(editor);
+ GtkWidget *w = glade_xml_get_widget (editor->gui, entry);
+ editor->phone_choice[which - 1] = phones[result];
+ set_fields (editor);
enable_widget (glade_xml_get_widget (editor->gui, label), TRUE);
- enable_widget (glade_xml_get_widget (editor->gui, entry), editor->editable);
+ enable_widget (w, editor->editable);
}
g_free(label);
@@ -1880,23 +1851,26 @@ _email_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEditor
e_contact_editor_build_email_ui (editor);
- for(i = 0; i < E_CARD_SIMPLE_EMAIL_ID_LAST; i++) {
- const char *string = e_card_simple_get_email(editor->simple, i);
+ for(i = 0; i < G_N_ELEMENTS (emails); i++) {
+ char *string = e_contact_get (editor->contact, emails[i]);
gboolean checked;
checked = string && *string;
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(editor->email_info[i].widget),
checked);
+ g_free (string);
}
result = _arrow_pressed (widget, button, editor, editor->email_popup, &editor->email_list, &editor->email_info, "label-email1");
if (result != -1) {
+ GtkWidget *entry = glade_xml_get_widget (editor->gui, "entry-email1");
editor->email_choice = result;
- set_fields(editor);
+
+ set_fields (editor);
/* make sure the buttons/entry is/are sensitive */
enable_widget (glade_xml_get_widget (editor->gui, "label-email1"), TRUE);
- enable_widget (glade_xml_get_widget (editor->gui, "entry-email1"), editor->editable);
+ enable_widget (entry, editor->editable);
enable_widget (glade_xml_get_widget (editor->gui, "checkbutton-htmlmail"), editor->editable);
}
}
@@ -1904,6 +1878,7 @@ _email_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEditor
static void
_address_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEditor *editor)
{
+#if notyet
int i;
int result;
@@ -1927,11 +1902,13 @@ _address_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEdito
enable_widget (glade_xml_get_widget (editor->gui, "text-address"), editor->address_editable[result]);
enable_widget (glade_xml_get_widget (editor->gui, "checkbutton-mailingaddress"), editor->address_editable[result]);
}
+#endif
}
static void
find_address_mailing (EContactEditor *editor)
{
+#if notyet
const ECardDeliveryAddress *address;
int i;
@@ -1951,6 +1928,7 @@ find_address_mailing (EContactEditor *editor)
}
}
}
+#endif
}
static void
@@ -1971,9 +1949,9 @@ set_field(EContactEditor *editor, GtkEntry *entry, const char *string)
}
static void
-set_phone_field(EContactEditor *editor, GtkWidget *entry, const ECardPhone *phone)
+set_phone_field(EContactEditor *editor, GtkWidget *entry, const char *phone_number)
{
- set_field(editor, GTK_ENTRY(entry), phone ? phone->number : "");
+ set_field(editor, GTK_ENTRY(entry), phone_number ? phone_number : "");
}
static void
@@ -1985,28 +1963,28 @@ set_fields(EContactEditor *editor)
entry = glade_xml_get_widget(editor->gui, "entry-phone1");
if (entry && GTK_IS_ENTRY(entry))
- set_phone_field(editor, entry, e_card_simple_get_phone(editor->simple, editor->phone_choice[0]));
+ set_phone_field(editor, entry, e_contact_get_const(editor->contact, editor->phone_choice[0]));
entry = glade_xml_get_widget(editor->gui, "entry-phone2");
if (entry && GTK_IS_ENTRY(entry))
- set_phone_field(editor, entry, e_card_simple_get_phone(editor->simple, editor->phone_choice[1]));
+ set_phone_field(editor, entry, e_contact_get_const(editor->contact, editor->phone_choice[1]));
entry = glade_xml_get_widget(editor->gui, "entry-phone3");
if (entry && GTK_IS_ENTRY(entry))
- set_phone_field(editor, entry, e_card_simple_get_phone(editor->simple, editor->phone_choice[2]));
+ set_phone_field(editor, entry, e_contact_get_const(editor->contact, editor->phone_choice[2]));
entry = glade_xml_get_widget(editor->gui, "entry-phone4");
if (entry && GTK_IS_ENTRY(entry))
- set_phone_field(editor, entry, e_card_simple_get_phone(editor->simple, editor->phone_choice[3]));
+ set_phone_field(editor, entry, e_contact_get_const(editor->contact, editor->phone_choice[3]));
entry = glade_xml_get_widget(editor->gui, "entry-email1");
if (entry && GTK_IS_ENTRY(entry))
- set_field(editor, GTK_ENTRY(entry), e_card_simple_get_email(editor->simple, editor->email_choice));
-
+ set_field(editor, GTK_ENTRY(entry), e_contact_get_const(editor->contact, editor->email_choice));
e_contact_editor_build_address_ui (editor);
+#if notyet
for (i = 0; i < E_CARD_SIMPLE_ADDRESS_ID_LAST; i++) {
const ECardAddrLabel *address = e_card_simple_get_address(editor->simple, i);
@@ -2024,11 +2002,13 @@ set_fields(EContactEditor *editor)
}
set_address_field(editor, i);
+#endif
}
static void
set_address_field(EContactEditor *editor, int result)
{
+#if notyet
GtkWidget *text, *check;
text = glade_xml_get_widget(editor->gui, "text-address");
@@ -2064,73 +2044,29 @@ set_address_field(EContactEditor *editor, int result)
editor->address_choice = result;
}
-}
-
-static void
-add_field_callback(GtkWidget *widget, EContactEditor *editor)
-{
- const char *name;
- int i;
- static const char *builtins[] = {
- "entry-fullname",
- "entry-web",
- "entry-company",
- "entry-department",
- "entry-office",
- "entry-jobtitle",
- "entry-profession",
- "entry-manager",
- "entry-assistant",
- "entry-nickname",
- "entry-spouse",
- "text-comments",
- "entry-categories",
- "entry-file-as",
- "dateedit-anniversary",
- "dateedit-birthday",
- "entry-phone1",
- "entry-phone2",
- "entry-phone3",
- "entry-phone4",
- "entry-email1",
- "text-address",
- "checkbutton-mailingaddress",
- "checkbutton-htmlmail",
- "entry-caluri",
- "entry-fburl",
- NULL
- };
- name = glade_get_widget_name(widget);
- if (name) {
- for (i = 0; builtins[i]; i++) {
- if (!strcmp(name, builtins[i]))
- return;
- }
- if (GTK_IS_ENTRY(widget) || GTK_IS_TEXT_VIEW(widget)) {
- editor->arbitrary_fields = g_list_prepend(editor->arbitrary_fields, g_strdup(name));
- }
- }
+#endif
}
static struct {
char *id;
- char *key;
+ EContactField field;
} field_mapping [] = {
- { "entry-fullname", "full_name" },
- { "entry-web", "url" },
- { "entry-company", "org" },
- { "entry-department", "org_unit" },
- { "entry-office", "office" },
- { "entry-jobtitle", "title" },
- { "entry-profession", "role" },
- { "entry-manager", "manager" },
- { "entry-assistant", "assistant" },
- { "entry-nickname", "nickname" },
- { "entry-spouse", "spouse" },
- { "text-comments", "note" },
- { "entry-categories", "categories" },
- { "entry-caluri", "caluri" },
- { "entry-fburl", "fburl" },
+ { "entry-fullname", E_CONTACT_FULL_NAME },
+ { "entry-web", E_CONTACT_HOMEPAGE_URL },
+ { "entry-blog", E_CONTACT_BLOG_URL },
+ { "entry-company", E_CONTACT_ORG },
+ { "entry-department", E_CONTACT_ORG_UNIT },
+ { "entry-office", E_CONTACT_OFFICE },
+ { "entry-jobtitle", E_CONTACT_TITLE },
+ { "entry-profession", E_CONTACT_ROLE },
+ { "entry-manager", E_CONTACT_MANAGER },
+ { "entry-assistant", E_CONTACT_ASSISTANT },
+ { "entry-nickname", E_CONTACT_NICKNAME },
+ { "entry-spouse", E_CONTACT_SPOUSE },
+ { "text-comments", E_CONTACT_NOTE },
+ { "entry-categories", E_CONTACT_CATEGORIES },
+ { "entry-caluri", E_CONTACT_CALENDAR_URI },
+ { "entry-fburl", E_CONTACT_FREEBUSY_URL },
};
static void
@@ -2159,36 +2095,6 @@ fill_in_field(EContactEditor *editor, char *id, char *value)
}
static void
-fill_in_card_field(EContactEditor *editor, ECard *card, char *id, char *key)
-{
- char *string;
- g_object_get (card,
- key, &string,
- NULL);
- fill_in_field(editor, id, string);
- g_free (string);
-}
-
-static void
-fill_in_single_field(EContactEditor *editor, char *name)
-{
- ECardSimple *simple = editor->simple;
- GtkWidget *widget = glade_xml_get_widget(editor->gui, name);
-
- if (widget && GTK_IS_EDITABLE(widget)) {
- int position = 0;
- GtkEditable *editable = GTK_EDITABLE(widget);
- const ECardArbitrary *arbitrary;
-
- gtk_editable_delete_text(editable, 0, -1);
- arbitrary = e_card_simple_get_arbitrary(simple,
- name);
- if (arbitrary && arbitrary->value)
- gtk_editable_insert_text(editable, arbitrary->value, strlen(arbitrary->value), &position);
- }
-}
-
-static void
disable_widget_foreach (char *key, GtkWidget *widget, gpointer closure)
{
enable_widget (widget, FALSE);
@@ -2196,62 +2102,65 @@ disable_widget_foreach (char *key, GtkWidget *widget, gpointer closure)
static struct {
char *widget_name;
- ECardSimpleField field_id;
+ EContactField field_id;
gboolean desensitize_for_read_only;
} widget_field_mappings[] = {
- { "entry-web", E_CARD_SIMPLE_FIELD_URL, TRUE },
- { "accellabel-web", E_CARD_SIMPLE_FIELD_URL },
+ { "entry-web", E_CONTACT_HOMEPAGE_URL, TRUE },
+ { "accellabel-web", E_CONTACT_HOMEPAGE_URL },
- { "entry-jobtitle", E_CARD_SIMPLE_FIELD_TITLE, TRUE },
- { "label-jobtitle", E_CARD_SIMPLE_FIELD_TITLE },
+ { "entry-blog", E_CONTACT_BLOG_URL, TRUE },
+ { "accellabel-blog", E_CONTACT_BLOG_URL },
- { "entry-company", E_CARD_SIMPLE_FIELD_ORG, TRUE },
- { "label-company", E_CARD_SIMPLE_FIELD_ORG },
+ { "entry-jobtitle", E_CONTACT_TITLE, TRUE },
+ { "label-jobtitle", E_CONTACT_TITLE },
- { "combo-file-as", E_CARD_SIMPLE_FIELD_FILE_AS, TRUE },
- { "entry-file-as", E_CARD_SIMPLE_FIELD_FILE_AS, TRUE },
- { "accellabel-fileas", E_CARD_SIMPLE_FIELD_FILE_AS },
+ { "entry-company", E_CONTACT_ORG, TRUE },
+ { "label-company", E_CONTACT_ORG },
- { "label-department", E_CARD_SIMPLE_FIELD_ORG_UNIT },
- { "entry-department", E_CARD_SIMPLE_FIELD_ORG_UNIT, TRUE },
+ { "combo-file-as", E_CONTACT_FILE_AS, TRUE },
+ { "entry-file-as", E_CONTACT_FILE_AS, TRUE },
+ { "accellabel-fileas", E_CONTACT_FILE_AS },
- { "label-office", E_CARD_SIMPLE_FIELD_OFFICE },
- { "entry-office", E_CARD_SIMPLE_FIELD_OFFICE, TRUE },
+ { "label-department", E_CONTACT_ORG_UNIT },
+ { "entry-department", E_CONTACT_ORG_UNIT, TRUE },
- { "label-profession", E_CARD_SIMPLE_FIELD_ROLE },
- { "entry-profession", E_CARD_SIMPLE_FIELD_ROLE, TRUE },
+ { "label-office", E_CONTACT_OFFICE },
+ { "entry-office", E_CONTACT_OFFICE, TRUE },
- { "label-manager", E_CARD_SIMPLE_FIELD_MANAGER },
- { "entry-manager", E_CARD_SIMPLE_FIELD_MANAGER, TRUE },
+ { "label-profession", E_CONTACT_ROLE },
+ { "entry-profession", E_CONTACT_ROLE, TRUE },
- { "label-assistant", E_CARD_SIMPLE_FIELD_ASSISTANT },
- { "entry-assistant", E_CARD_SIMPLE_FIELD_ASSISTANT, TRUE },
+ { "label-manager", E_CONTACT_MANAGER },
+ { "entry-manager", E_CONTACT_MANAGER, TRUE },
- { "label-nickname", E_CARD_SIMPLE_FIELD_NICKNAME },
- { "entry-nickname", E_CARD_SIMPLE_FIELD_NICKNAME, TRUE },
+ { "label-assistant", E_CONTACT_ASSISTANT },
+ { "entry-assistant", E_CONTACT_ASSISTANT, TRUE },
- { "label-spouse", E_CARD_SIMPLE_FIELD_SPOUSE },
- { "entry-spouse", E_CARD_SIMPLE_FIELD_SPOUSE, TRUE },
+ { "label-nickname", E_CONTACT_NICKNAME },
+ { "entry-nickname", E_CONTACT_NICKNAME, TRUE },
- { "label-birthday", E_CARD_SIMPLE_FIELD_BIRTH_DATE },
- { "dateedit-birthday", E_CARD_SIMPLE_FIELD_BIRTH_DATE, TRUE },
+ { "label-spouse", E_CONTACT_SPOUSE },
+ { "entry-spouse", E_CONTACT_SPOUSE, TRUE },
- { "label-anniversary", E_CARD_SIMPLE_FIELD_ANNIVERSARY },
- { "dateedit-anniversary", E_CARD_SIMPLE_FIELD_ANNIVERSARY, TRUE },
+ { "label-birthday", E_CONTACT_BIRTH_DATE },
+ { "dateedit-birthday", E_CONTACT_BIRTH_DATE, TRUE },
- { "label-comments", E_CARD_SIMPLE_FIELD_NOTE },
- { "text-comments", E_CARD_SIMPLE_FIELD_NOTE, TRUE },
+ { "label-anniversary", E_CONTACT_ANNIVERSARY },
+ { "dateedit-anniversary", E_CONTACT_ANNIVERSARY, TRUE },
- { "entry-fullname", E_CARD_SIMPLE_FIELD_FULL_NAME, TRUE },
+ { "label-comments", E_CONTACT_NOTE },
+ { "text-comments", E_CONTACT_NOTE, TRUE },
- { "button-categories", E_CARD_SIMPLE_FIELD_CATEGORIES, TRUE },
- { "entry-categories", E_CARD_SIMPLE_FIELD_CATEGORIES, TRUE },
+ { "entry-fullname", E_CONTACT_FULL_NAME, TRUE },
- { "label-caluri", E_CARD_SIMPLE_FIELD_CALURI },
- { "entry-caluri", E_CARD_SIMPLE_FIELD_CALURI, TRUE },
+ { "button-categories", E_CONTACT_CATEGORIES, TRUE },
+ { "entry-categories", E_CONTACT_CATEGORIES, TRUE },
- { "label-fburl", E_CARD_SIMPLE_FIELD_FBURL },
- { "entry-fburl", E_CARD_SIMPLE_FIELD_FBURL, TRUE }
+ { "label-caluri", E_CONTACT_CALENDAR_URI },
+ { "entry-caluri", E_CONTACT_CALENDAR_URI, TRUE },
+
+ { "label-fburl", E_CONTACT_FREEBUSY_URL },
+ { "entry-fburl", E_CONTACT_FREEBUSY_URL, TRUE }
};
static int num_widget_field_mappings = sizeof(widget_field_mappings) / sizeof (widget_field_mappings[0]);
@@ -2262,35 +2171,32 @@ enable_writable_fields(EContactEditor *editor)
EIterator *iter;
GHashTable *dropdown_hash, *supported_hash;
int i;
- ECardSimple *simple;
- ECard *card;
char *widget_name;
if (!fields)
return;
- card = e_card_new ("");
- simple = e_card_simple_new (card);
-
dropdown_hash = g_hash_table_new (g_str_hash, g_str_equal);
supported_hash = g_hash_table_new (g_str_hash, g_str_equal);
/* build our hashtable of the drop down menu items */
e_contact_editor_build_phone_ui (editor);
- for (i = 0; i < E_CARD_SIMPLE_PHONE_ID_LAST; i ++)
+ for (i = 0; i < G_N_ELEMENTS (phones); i ++)
g_hash_table_insert (dropdown_hash,
- (char*)e_card_simple_get_ecard_field(simple, e_card_simple_map_phone_to_field (i)),
+ (char*)e_contact_field_name(phones[i]),
editor->phone_info[i].widget);
e_contact_editor_build_email_ui (editor);
- for (i = 0; i < E_CARD_SIMPLE_EMAIL_ID_LAST; i ++)
+ for (i = 0; i < G_N_ELEMENTS (emails); i ++)
g_hash_table_insert (dropdown_hash,
- (char*)e_card_simple_get_ecard_field(simple, e_card_simple_map_email_to_field (i)),
+ (char*)e_contact_field_name(phones[i]),
editor->email_info[i].widget);
+#if notyet
e_contact_editor_build_address_ui (editor);
for (i = 0; i < E_CARD_SIMPLE_ADDRESS_ID_LAST; i ++)
g_hash_table_insert (dropdown_hash,
(char*)e_card_simple_get_ecard_field(simple, e_card_simple_map_address_to_field (i)),
editor->address_info[i].widget);
+#endif
/* then disable them all */
g_hash_table_foreach (dropdown_hash, (GHFunc)disable_widget_foreach, NULL);
@@ -2332,28 +2238,30 @@ enable_writable_fields(EContactEditor *editor)
g_hash_table_insert (supported_hash, field, field);
}
+#if notyet
for (i = 0; i < E_CARD_SIMPLE_ADDRESS_ID_LAST; i ++) {
if (!strcmp (field, e_card_simple_get_ecard_field (simple, e_card_simple_map_address_to_field(i)))) {
editor->address_editable [i] = TRUE;
}
}
+#endif
/* ugh - this is needed to make sure we don't have a
disabled label next to a drop down when the item in
the menu (the one reflected in the label) is
enabled. */
- if (!strcmp (field, e_card_simple_get_ecard_field (simple, e_card_simple_map_email_to_field(editor->email_choice)))) {
+ if (!strcmp (field, e_contact_field_name (editor->email_choice))) {
enable_widget (glade_xml_get_widget (editor->gui, "label-email1"), TRUE);
enable_widget (glade_xml_get_widget (editor->gui, "entry-email1"), editor->editable);
enable_widget (glade_xml_get_widget (editor->gui, "checkbutton-htmlmail"), editor->editable);
}
- else if (!strcmp (field, e_card_simple_get_ecard_field (simple, e_card_simple_map_address_to_field(editor->address_choice)))) {
+ else if (!strcmp (field, e_contact_field_name (editor->address_choice))) {
enable_widget (glade_xml_get_widget (editor->gui, "label-address"), TRUE);
enable_widget (glade_xml_get_widget (editor->gui, "checkbutton-mailingaddress"), editor->editable);
enable_widget (glade_xml_get_widget (editor->gui, "text-address"), editor->editable);
}
else for (i = 0; i < 4; i ++) {
- if (!strcmp (field, e_card_simple_get_ecard_field (simple, e_card_simple_map_phone_to_field(editor->phone_choice[i])))) {
+ if (!strcmp (field, e_contact_field_name (editor->phone_choice[i]))) {
widget_name = g_strdup_printf ("label-phone%d", i+1);
enable_widget (glade_xml_get_widget (editor->gui, widget_name), TRUE);
g_free (widget_name);
@@ -2377,8 +2285,7 @@ enable_writable_fields(EContactEditor *editor)
widget_field_mappings[i].widget_name);
continue;
}
- field = e_card_simple_get_ecard_field (simple,
- widget_field_mappings[i].field_id);
+ field = e_contact_field_name (widget_field_mappings[i].field_id);
enabled = (g_hash_table_lookup (supported_hash, field) != NULL);
@@ -2393,8 +2300,6 @@ enable_writable_fields(EContactEditor *editor)
g_hash_table_destroy (dropdown_hash);
g_hash_table_destroy (supported_hash);
- g_object_unref (simple);
- g_object_unref (card);
}
static void
@@ -2436,51 +2341,46 @@ set_editable (EContactEditor *editor)
static void
fill_in_info(EContactEditor *editor)
{
- ECard *card = editor->card;
- if (card) {
+ EContact *contact = editor->contact;
+ if (contact) {
char *file_as;
- ECardName *name;
- const ECardDate *anniversary;
- const ECardDate *bday;
+ EContactName *name;
+ EContactDate *anniversary;
+ EContactDate *bday;
int i;
GtkWidget *widget;
- GList *list;
- gboolean wants_html, wants_html_set;
-
- g_object_get (card,
- "file_as", &file_as,
- "name", &name,
- "anniversary", &anniversary,
- "birth_date", &bday,
- "wants_html_set", &wants_html_set,
- "wants_html", &wants_html,
- NULL);
-
- for (i = 0; i < sizeof(field_mapping) / sizeof(field_mapping[0]); i++) {
- fill_in_card_field(editor, card, field_mapping[i].id, field_mapping[i].key);
- }
+ gboolean wants_html;
+
+ g_object_get (contact,
+ "file_as", &file_as,
+ "name", &name,
+ "anniversary", &anniversary,
+ "birth_date", &bday,
+ "wants_html", &wants_html,
+ NULL);
- for (list = editor->arbitrary_fields; list; list = list->next) {
- fill_in_single_field(editor, list->data);
+ for (i = 0; i < sizeof(field_mapping) / sizeof(field_mapping[0]); i++) {
+ char *string = e_contact_get (contact, field_mapping[i].field);
+ fill_in_field(editor, field_mapping[i].id, string);
+ g_free (string);
}
find_address_mailing (editor);
- if (wants_html_set) {
- GtkWidget *widget = glade_xml_get_widget(editor->gui, "checkbutton-htmlmail");
- if (widget && GTK_IS_CHECK_BUTTON(widget)) {
- g_object_set (widget,
- "active", wants_html,
- NULL);
- }
+ widget = glade_xml_get_widget(editor->gui, "checkbutton-htmlmail");
+ if (widget && GTK_IS_CHECK_BUTTON(widget)) {
+ g_object_set (widget,
+ "active", wants_html,
+ NULL);
}
/* File as has to come after company and name or else it'll get messed up when setting them. */
fill_in_field(editor, "entry-file-as", file_as);
- g_free (file_as);
- e_card_name_unref(editor->name);
- editor->name = e_card_name_ref(name);
+ g_free (file_as);
+ if (editor->name)
+ e_contact_name_free(editor->name);
+ editor->name = name;
widget = glade_xml_get_widget(editor->gui, "dateedit-anniversary");
if (widget && E_IS_DATE_EDIT(widget)) {
@@ -2508,12 +2408,15 @@ fill_in_info(EContactEditor *editor)
e_date_edit_set_time (dateedit, -1);
}
+ e_contact_date_free (anniversary);
+ e_contact_date_free (bday);
+
set_fields(editor);
}
}
static void
-extract_field(EContactEditor *editor, ECard *card, char *editable_id, char *key)
+extract_field(EContactEditor *editor, EContact *contact, char *editable_id, EContactField field)
{
GtkWidget *widget = glade_xml_get_widget(editor->gui, editable_id);
char *string = NULL;
@@ -2538,50 +2441,22 @@ extract_field(EContactEditor *editor, ECard *card, char *editable_id, char *key)
}
if (string && *string)
- g_object_set (card,
- key, string,
- NULL);
+ e_contact_set (contact, field, string);
else
- g_object_set (card,
- key, NULL,
- NULL);
+ e_contact_set (contact, field, NULL);
if (string) g_free(string);
}
static void
-extract_single_field(EContactEditor *editor, char *name)
-{
- GtkWidget *widget = glade_xml_get_widget(editor->gui, name);
- ECardSimple *simple = editor->simple;
- if (widget && GTK_IS_EDITABLE(widget)) {
- GtkEditable *editable = GTK_EDITABLE(widget);
- char *string = gtk_editable_get_chars(editable, 0, -1);
-
- if (string && *string)
- e_card_simple_set_arbitrary(simple,
- name,
- NULL,
- string);
- else
- e_card_simple_set_arbitrary(simple,
- name,
- NULL,
- NULL);
- if (string) g_free(string);
- }
-}
-
-static void
extract_info(EContactEditor *editor)
{
- ECard *card = editor->card;
- if (card) {
- ECardDate anniversary;
- ECardDate bday;
+ EContact *contact = editor->contact;
+ if (contact) {
+ EContactDate anniversary;
+ EContactDate bday;
int i;
GtkWidget *widget;
- GList *list;
widget = glade_xml_get_widget(editor->gui, "entry-file-as");
if (widget && GTK_IS_EDITABLE(widget)) {
@@ -2589,25 +2464,17 @@ extract_info(EContactEditor *editor)
char *string = gtk_editable_get_chars(editable, 0, -1);
if (string && *string)
- g_object_set (card,
- "file_as", string,
- NULL);
+ e_contact_set (contact, E_CONTACT_FILE_AS, string);
- if (string) g_free(string);
+ g_free(string);
}
for (i = 0; i < sizeof(field_mapping) / sizeof(field_mapping[0]); i++) {
- extract_field(editor, card, field_mapping[i].id, field_mapping[i].key);
- }
-
- for (list = editor->arbitrary_fields; list; list = list->next) {
- extract_single_field(editor, list->data);
+ extract_field(editor, contact, field_mapping[i].id, field_mapping[i].field);
}
if (editor->name)
- g_object_set (card,
- "name", editor->name,
- NULL);
+ e_contact_set (contact, E_CONTACT_NAME, editor->name);
widget = glade_xml_get_widget(editor->gui, "dateedit-anniversary");
if (widget && E_IS_DATE_EDIT(widget)) {
@@ -2616,13 +2483,9 @@ extract_info(EContactEditor *editor)
&anniversary.month,
&anniversary.day)) {
/* g_print ("%d %d %d\n", anniversary.year, anniversary.month, anniversary.day); */
- g_object_set (card,
- "anniversary", &anniversary,
- NULL);
+ e_contact_set (contact, E_CONTACT_ANNIVERSARY, &anniversary);
} else
- g_object_set (card,
- "anniversary", NULL,
- NULL);
+ e_contact_set (contact, E_CONTACT_ANNIVERSARY, NULL);
}
widget = glade_xml_get_widget(editor->gui, "dateedit-birthday");
@@ -2632,13 +2495,9 @@ extract_info(EContactEditor *editor)
&bday.month,
&bday.day)) {
/* g_print ("%d %d %d\n", bday.year, bday.month, bday.day); */
- g_object_set (card,
- "birth_date", &bday,
- NULL);
+ e_contact_set (contact, E_CONTACT_BIRTH_DATE, &bday);
} else
- g_object_set (card,
- "birth_date", NULL,
- NULL);
+ e_contact_set (contact, E_CONTACT_BIRTH_DATE, NULL);
}
}
}
diff --git a/addressbook/gui/contact-editor/e-contact-editor.h b/addressbook/gui/contact-editor/e-contact-editor.h
index 8642aecac1..efee496539 100644
--- a/addressbook/gui/contact-editor/e-contact-editor.h
+++ b/addressbook/gui/contact-editor/e-contact-editor.h
@@ -25,9 +25,8 @@
#include <bonobo/bonobo-ui-component.h>
#include <glade/glade.h>
-#include "addressbook/backend/ebook/e-book.h"
-#include "addressbook/backend/ebook/e-card.h"
-#include "addressbook/backend/ebook/e-card-simple.h"
+#include "addressbook/backend/ebook/e-book-async.h"
+#include "addressbook/backend/ebook/e-contact.h"
G_BEGIN_DECLS
@@ -56,8 +55,7 @@ struct _EContactEditor
/* item specific fields */
EBook *book;
- ECard *card;
- ECardSimple *simple;
+ EContact *contact;
/* UI handler */
BonoboUIComponent *uic;
@@ -74,20 +72,18 @@ struct _EContactEditor
GList *phone_list;
GList *address_list;
- ECardName *name;
+ EContactName *name;
char *company;
- ECardSimpleEmailId email_choice;
- ECardSimplePhoneId phone_choice[4];
- ECardSimpleAddressId address_choice;
- ECardSimpleAddressId address_mailing;
+ EContactField email_choice;
+ EContactField phone_choice[4];
+ EContactField address_choice;
+ EContactField address_mailing;
- GList *arbitrary_fields;
+ /* Whether we are editing a new contact or an existing one */
+ guint is_new_contact : 1;
- /* Whether we are editing a new card or an existing one */
- guint is_new_card : 1;
-
- /* Whether the card has been changed since bringing up the contact editor */
+ /* Whether the contact has been changed since bringing up the contact editor */
guint changed : 1;
/* Whether the contact editor will accept modifications */
@@ -96,8 +92,10 @@ struct _EContactEditor
/* Whether the fullname will accept modifications */
guint fullname_editable : 1;
+#if notyet
/* Whether each of the addresses are editable */
gboolean address_editable[E_CARD_SIMPLE_ADDRESS_ID_LAST];
+#endif
/* Whether an async wombat call is in progress */
guint in_async_call : 1;
@@ -111,15 +109,15 @@ struct _EContactEditorClass
/* Notification signals */
- void (* card_added) (EContactEditor *ce, EBookStatus status, ECard *card);
- void (* card_modified) (EContactEditor *ce, EBookStatus status, ECard *card);
- void (* card_deleted) (EContactEditor *ce, EBookStatus status, ECard *card);
- void (* editor_closed) (EContactEditor *ce);
+ void (* contact_added) (EContactEditor *ce, EBookStatus status, EContact *contact);
+ void (* contact_modified) (EContactEditor *ce, EBookStatus status, EContact *contact);
+ void (* contact_deleted) (EContactEditor *ce, EBookStatus status, EContact *contact);
+ void (* editor_closed) (EContactEditor *ce);
};
EContactEditor *e_contact_editor_new (EBook *book,
- ECard *card,
- gboolean is_new_card,
+ EContact *contact,
+ gboolean is_new_contact,
gboolean editable);
GType e_contact_editor_get_type (void);
diff --git a/addressbook/gui/contact-editor/e-contact-quick-add.c b/addressbook/gui/contact-editor/e-contact-quick-add.c
index 703996ee07..65b321c997 100644
--- a/addressbook/gui/contact-editor/e-contact-quick-add.c
+++ b/addressbook/gui/contact-editor/e-contact-quick-add.c
@@ -37,17 +37,17 @@
#include <libgnomeui/gnome-app.h>
#include <addressbook/gui/component/addressbook.h>
#include <addressbook/backend/ebook/e-book.h>
-#include <addressbook/backend/ebook/e-book-util.h>
-#include <addressbook/backend/ebook/e-card.h>
+#include <addressbook/util/eab-book-util.h>
+#include <addressbook/backend/ebook/e-contact.h>
#include "e-contact-editor.h"
#include "e-contact-quick-add.h"
-#include "e-card-merging.h"
+#include "eab-contact-merging.h"
typedef struct _QuickAdd QuickAdd;
struct _QuickAdd {
gchar *name;
gchar *email;
- ECard *card;
+ EContact *contact;
EContactQuickAddCallback cb;
gpointer closure;
@@ -63,7 +63,7 @@ static QuickAdd *
quick_add_new (void)
{
QuickAdd *qa = g_new0 (QuickAdd, 1);
- qa->card = e_card_new ("");
+ qa->contact = e_contact_new ();
qa->refs = 1;
return qa;
}
@@ -84,7 +84,7 @@ quick_add_unref (QuickAdd *qa)
if (qa->refs == 0) {
g_free (qa->name);
g_free (qa->email);
- g_object_unref (qa->card);
+ g_object_unref (qa->contact);
g_free (qa);
}
}
@@ -93,7 +93,8 @@ quick_add_unref (QuickAdd *qa)
static void
quick_add_set_name (QuickAdd *qa, const gchar *name)
{
- ECardName *card_name;
+#if notyet
+ EContactName *card_name;
if (name == qa->name)
return;
@@ -108,23 +109,19 @@ quick_add_set_name (QuickAdd *qa, const gchar *name)
NULL);
e_card_name_unref (card_name);
+#endif
}
static void
quick_add_set_email (QuickAdd *qa, const gchar *email)
{
- ECardSimple *simple;
-
if (email == qa->email)
return;
g_free (qa->email);
qa->email = g_strdup (email);
- simple = e_card_simple_new (qa->card);
- e_card_simple_set (simple, E_CARD_SIMPLE_FIELD_EMAIL, email);
- e_card_simple_sync_card (simple);
- g_object_unref (simple);
+ e_contact_set (qa->contact, E_CONTACT_EMAIL_1, (char*)email);
}
static void
@@ -132,10 +129,10 @@ merge_cb (EBook *book, EBookStatus status, gpointer closure)
{
QuickAdd *qa = (QuickAdd *) closure;
- if (status == E_BOOK_STATUS_SUCCESS) {
- e_card_merging_book_add_card (book, qa->card, NULL, NULL);
+ if (status == E_BOOK_ERROR_OK) {
+ eab_merging_book_add_contact (book, qa->contact, NULL, NULL);
if (qa->cb)
- qa->cb (qa->card, qa->closure);
+ qa->cb (qa->contact, qa->closure);
g_object_unref (book);
} else {
/* Something went wrong. */
@@ -149,14 +146,11 @@ merge_cb (EBook *book, EBookStatus status, gpointer closure)
}
static void
-quick_add_merge_card (QuickAdd *qa)
+quick_add_merge_contact (QuickAdd *qa)
{
- EBook *book;
-
quick_add_ref (qa);
- book = e_book_new ();
- addressbook_load_default_book (book, merge_cb, qa);
+ addressbook_load_default_book (merge_cb, qa);
}
@@ -165,14 +159,14 @@ quick_add_merge_card (QuickAdd *qa)
*/
static void
-card_added_cb (EContactEditor *ce, EBookStatus status, ECard *card, gpointer closure)
+contact_added_cb (EContactEditor *ce, EBookStatus status, EContact *contact, gpointer closure)
{
QuickAdd *qa = (QuickAdd *) g_object_get_data (G_OBJECT (ce), "quick_add");
if (qa) {
if (qa->cb)
- qa->cb (qa->card, qa->closure);
+ qa->cb (qa->contact, qa->closure);
/* We don't need to unref qa because we set_data_full below */
g_object_set_data (G_OBJECT (ce), "quick_add", NULL);
@@ -196,13 +190,13 @@ ce_have_book (EBook *book, EBookStatus status, gpointer closure)
{
QuickAdd *qa = (QuickAdd *) closure;
- if (status != E_BOOK_STATUS_SUCCESS) {
+ if (status != E_BOOK_ERROR_OK) {
if (book)
g_object_unref (book);
g_warning ("Couldn't open local address book.");
quick_add_unref (qa);
} else {
- EContactEditor *contact_editor = e_contact_editor_new (book, qa->card, TRUE, TRUE /* XXX */);
+ EContactEditor *contact_editor = e_contact_editor_new (book, qa->contact, TRUE, TRUE /* XXX */);
/* mark it as changed so the Save buttons are enabled when we bring up the dialog. */
g_object_set (contact_editor,
@@ -210,14 +204,14 @@ ce_have_book (EBook *book, EBookStatus status, gpointer closure)
NULL);
/* We pass this via object data, so that we don't get a dangling pointer referenced if both
- the "card_added" and "editor_closed" get emitted. (Which, based on a backtrace in bugzilla,
+ the "contact_added" and "editor_closed" get emitted. (Which, based on a backtrace in bugzilla,
I think can happen and cause a crash. */
g_object_set_data_full (G_OBJECT (contact_editor), "quick_add", qa,
(GDestroyNotify) quick_add_unref);
g_signal_connect (contact_editor,
- "card_added",
- G_CALLBACK (card_added_cb),
+ "contact_added",
+ G_CALLBACK (contact_added_cb),
NULL);
g_signal_connect (contact_editor,
"editor_closed",
@@ -229,11 +223,9 @@ ce_have_book (EBook *book, EBookStatus status, gpointer closure)
}
static void
-edit_card (QuickAdd *qa)
+edit_contact (QuickAdd *qa)
{
- EBook *book;
- book = e_book_new ();
- addressbook_load_default_book (book, ce_have_book, qa);
+ addressbook_load_default_book (ce_have_book, qa);
}
#define QUICK_ADD_RESPONSE_EDIT_FULL 2
@@ -272,12 +264,12 @@ clicked_cb (GtkWidget *w, gint button, gpointer closure)
if (button == GTK_RESPONSE_OK) {
/* OK */
- quick_add_merge_card (qa);
+ quick_add_merge_contact (qa);
} else if (button == QUICK_ADD_RESPONSE_EDIT_FULL) {
/* EDIT FULL */
- edit_card (qa);
+ edit_contact (qa);
} else {
/* CANCEL */
diff --git a/addressbook/gui/contact-editor/e-contact-quick-add.h b/addressbook/gui/contact-editor/e-contact-quick-add.h
index 1bf69ee114..ad98c73c23 100644
--- a/addressbook/gui/contact-editor/e-contact-quick-add.h
+++ b/addressbook/gui/contact-editor/e-contact-quick-add.h
@@ -27,9 +27,9 @@
#ifndef __E_CONTACT_QUICK_ADD_H__
#define __E_CONTACT_QUICK_ADD_H__
-#include <addressbook/backend/ebook/e-card.h>
+#include <addressbook/backend/ebook/e-contact.h>
-typedef void (*EContactQuickAddCallback) (ECard *new_card, gpointer closure);
+typedef void (*EContactQuickAddCallback) (EContact *new_contact, gpointer closure);
void e_contact_quick_add (const gchar *name, const gchar *email,
EContactQuickAddCallback cb, gpointer closure);
diff --git a/addressbook/gui/contact-editor/e-contact-save-as.c b/addressbook/gui/contact-editor/e-contact-save-as.c
deleted file mode 100644
index a141560763..0000000000
--- a/addressbook/gui/contact-editor/e-contact-save-as.c
+++ /dev/null
@@ -1,218 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* e-contact-editor.h
- * Copyright (C) 2000 Ximian, Inc.
- * Author: Chris Lahey <clahey@ximian.com>
- *
- * This library 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 library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include <config.h>
-
-#include "e-contact-save-as.h"
-
-#include <unistd.h>
-#include <fcntl.h>
-#include <gtk/gtkfilesel.h>
-#include <gtk/gtksignal.h>
-#include <gtk/gtkmessagedialog.h>
-#include <gal/util/e-util.h>
-#include <libgnome/gnome-i18n.h>
-#include <errno.h>
-#include <string.h>
-#include <libgnomeui/gnome-messagebox.h>
-
-static gint file_exists(GtkFileSelection *filesel, const char *filename);
-
-typedef struct {
- GtkFileSelection *filesel;
- char *vcard;
-} SaveAsInfo;
-
-static void
-save_it(GtkWidget *widget, SaveAsInfo *info)
-{
- gint error = 0;
- gint response = 0;
-
- const char *filename = gtk_file_selection_get_filename (info->filesel);
-
- error = e_write_file (filename, info->vcard, O_WRONLY | O_CREAT | O_EXCL | O_TRUNC);
-
- if (error == EEXIST) {
- response = file_exists(info->filesel, filename);
- switch (response) {
- case GTK_RESPONSE_ACCEPT : /* Overwrite */
- e_write_file(filename, info->vcard, O_WRONLY | O_CREAT | O_TRUNC);
- break;
- case GTK_RESPONSE_REJECT : /* cancel */
- return;
- }
- } else if (error != 0) {
- GtkWidget *dialog;
- char *str;
-
- str = g_strdup_printf (_("Error saving %s: %s"), filename, strerror(errno));
- dialog = gtk_message_dialog_new (GTK_WINDOW (info->filesel),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_OK,
- str);
- g_free (str);
-
- gtk_widget_show (dialog);
-
- return;
- }
-
- gtk_widget_destroy(GTK_WIDGET(info->filesel));
-}
-
-static void
-close_it(GtkWidget *widget, SaveAsInfo *info)
-{
- gtk_widget_destroy (GTK_WIDGET (info->filesel));
-}
-
-static void
-destroy_it(void *data, GObject *where_the_object_was)
-{
- SaveAsInfo *info = data;
- g_free (info->vcard);
- g_free (info);
-}
-
-static char *
-make_safe_filename (const char *prefix, char *name)
-{
- char *safe, *p;
-
- if (!name) {
- /* This is a filename. Translators take note. */
- name = _("card.vcf");
- }
-
- p = strrchr (name, '/');
- if (p)
- safe = g_strdup_printf ("%s%s%s", prefix, p, ".vcf");
- else
- safe = g_strdup_printf ("%s/%s%s", prefix, name, ".vcf");
-
- p = strrchr (safe, '/') + 1;
- if (p)
- e_filename_make_safe (p);
-
- return safe;
-}
-
-void
-e_contact_save_as(char *title, ECard *card, GtkWindow *parent_window)
-{
- GtkFileSelection *filesel;
- char *file;
- char *name;
- SaveAsInfo *info = g_new(SaveAsInfo, 1);
-
- filesel = GTK_FILE_SELECTION(gtk_file_selection_new(title));
-
- g_object_get (card,
- "file_as", &name,
- NULL);
- file = make_safe_filename (g_get_home_dir(), name);
- gtk_file_selection_set_filename (filesel, file);
- g_free (file);
- g_free (name);
-
- info->filesel = filesel;
- info->vcard = e_card_get_vcard(card);
-
- g_signal_connect(filesel->ok_button, "clicked",
- G_CALLBACK (save_it), info);
- g_signal_connect(filesel->cancel_button, "clicked",
- G_CALLBACK (close_it), info);
- g_object_weak_ref (G_OBJECT (filesel), destroy_it, info);
-
- if (parent_window) {
- gtk_window_set_transient_for (GTK_WINDOW (filesel),
- parent_window);
- gtk_window_set_modal (GTK_WINDOW (filesel), TRUE);
- }
-
- gtk_widget_show(GTK_WIDGET(filesel));
-}
-
-void
-e_contact_list_save_as(char *title, GList *list, GtkWindow *parent_window)
-{
- GtkFileSelection *filesel;
- SaveAsInfo *info = g_new(SaveAsInfo, 1);
-
- filesel = GTK_FILE_SELECTION(gtk_file_selection_new(title));
-
- /* This is a filename. Translators take note. */
- if (list && list->data && list->next == NULL) {
- char *name, *file;
- g_object_get (list->data,
- "file_as", &name,
- NULL);
- file = make_safe_filename (g_get_home_dir(), name);
- gtk_file_selection_set_filename (filesel, file);
- g_free (file);
- g_free (name);
- } else {
- char *file;
- file = make_safe_filename (g_get_home_dir(), _("list"));
- gtk_file_selection_set_filename (filesel, file);
- g_free (file);
- }
-
- info->filesel = filesel;
- info->vcard = e_card_list_get_vcard (list);
-
- g_signal_connect(filesel->ok_button, "clicked",
- G_CALLBACK (save_it), info);
- g_signal_connect(filesel->cancel_button, "clicked",
- G_CALLBACK (close_it), info);
- g_object_weak_ref (G_OBJECT (filesel), destroy_it, info);
-
- if (parent_window) {
- gtk_window_set_transient_for (GTK_WINDOW (filesel),
- parent_window);
- gtk_window_set_modal (GTK_WINDOW (filesel), TRUE);
- }
-
- gtk_widget_show(GTK_WIDGET(filesel));
-}
-
-static gint
-file_exists(GtkFileSelection *filesel, const char *filename)
-{
- GtkWidget *dialog;
- gint response;
-
- dialog = gtk_message_dialog_new (GTK_WINDOW (filesel),
- 0,
- GTK_MESSAGE_QUESTION,
- GTK_BUTTONS_NONE,
- _("%s already exists\nDo you want to overwrite it?"), filename);
-
- gtk_dialog_add_buttons (GTK_DIALOG (dialog),
- GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
- _("Overwrite"), GTK_RESPONSE_ACCEPT,
- NULL);
-
- response = gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
- return response;
-}
diff --git a/addressbook/gui/contact-editor/e-contact-save-as.h b/addressbook/gui/contact-editor/e-contact-save-as.h
deleted file mode 100644
index 2b01ad8435..0000000000
--- a/addressbook/gui/contact-editor/e-contact-save-as.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* e-contact-save-as.h
- * Copyright (C) 2000 Ximian, Inc.
- * Author: Chris Lahey <clahey@ximian.com>
- *
- * This library 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 library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-#ifndef __E_CONTACT_SAVE_AS_H__
-#define __E_CONTACT_SAVE_AS_H__
-
-#include <gtk/gtkwindow.h>
-#include <glade/glade.h>
-#include "addressbook/backend/ebook/e-card.h"
-#include "addressbook/backend/ebook/e-card-simple.h"
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus */
-
-void e_contact_save_as (gchar *title, ECard *card, GtkWindow *parent_window);
-void e_contact_list_save_as (gchar *title, GList *list, GtkWindow *parent_window);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-
-#endif /* __E_CONTACT_EDITOR_H__ */
diff --git a/addressbook/gui/contact-list-editor/contact-list-editor.glade b/addressbook/gui/contact-list-editor/contact-list-editor.glade
index c64eebd520..002e697105 100644
--- a/addressbook/gui/contact-list-editor/contact-list-editor.glade
+++ b/addressbook/gui/contact-list-editor/contact-list-editor.glade
@@ -78,7 +78,7 @@
</child>
<child>
- <widget class="Custom" id="custom7">
+ <widget class="Custom" id="list-image">
<property name="visible">True</property>
<property name="creation_function">e_create_image_widget</property>
<property name="string1">evolution-contacts-plain.png</property>
diff --git a/addressbook/gui/contact-list-editor/e-contact-list-editor.c b/addressbook/gui/contact-list-editor/e-contact-list-editor.c
index 39f251f5ee..a475d15cd6 100644
--- a/addressbook/gui/contact-list-editor/e-contact-list-editor.c
+++ b/addressbook/gui/contact-list-editor/e-contact-list-editor.c
@@ -30,12 +30,13 @@
#include <bonobo/bonobo-ui-util.h>
#include <bonobo/bonobo-window.h>
#include <gal/e-table/e-table-scrolled.h>
+#include <libgnomevfs/gnome-vfs-ops.h>
#include "shell/evolution-shell-component-utils.h"
-#include "addressbook/gui/widgets/e-addressbook-util.h"
+#include "addressbook/gui/widgets/eab-gui-util.h"
+#include "addressbook/util/eab-book-util.h"
#include "e-contact-editor.h"
-#include "e-contact-save-as.h"
#include "e-contact-list-model.h"
#include "e-contact-list-editor-marshal.h"
@@ -76,6 +77,17 @@ static void table_drag_data_received_cb (ETable *table, int row, int col,
gint x, gint y,
GtkSelectionData *selection_data, guint info, guint time,
EContactListEditor *editor);
+static gboolean image_drag_motion_cb (GtkWidget *widget,
+ GdkDragContext *context,
+ gint x, gint y, guint time, EContactListEditor *editor);
+static gboolean image_drag_drop_cb (GtkWidget *widget,
+ GdkDragContext *context,
+ gint x, gint y, guint time, EContactListEditor *editor);
+static void image_drag_data_received_cb (GtkWidget *widget,
+ GdkDragContext *context,
+ gint x, gint y,
+ GtkSelectionData *selection_data,
+ guint info, guint time, EContactListEditor *editor);
static GtkObjectClass *parent_class = NULL;
@@ -83,18 +95,26 @@ static guint contact_list_editor_signals[LAST_SIGNAL];
enum DndTargetType {
DND_TARGET_TYPE_VCARD,
+ DND_TARGET_TYPE_URI_LIST
};
#define VCARD_TYPE "text/x-vcard"
-static GtkTargetEntry drag_types[] = {
+#define URI_LIST_TYPE "text/uri-list"
+
+static GtkTargetEntry list_drag_types[] = {
{ VCARD_TYPE, 0, DND_TARGET_TYPE_VCARD },
};
-static const int num_drag_types = sizeof (drag_types) / sizeof (drag_types[0]);
+static const int num_list_drag_types = sizeof (list_drag_types) / sizeof (list_drag_types[0]);
+
+static GtkTargetEntry image_drag_types[] = {
+ { URI_LIST_TYPE, 0, DND_TARGET_TYPE_URI_LIST },
+};
+static const int num_image_drag_types = sizeof (image_drag_types) / sizeof (image_drag_types[0]);
/* The arguments we take */
enum {
PROP_0,
PROP_BOOK,
- PROP_CARD,
+ PROP_CONTACT,
PROP_IS_NEW_LIST,
PROP_EDITABLE
};
@@ -144,11 +164,11 @@ e_contact_list_editor_class_init (EContactListEditorClass *klass)
E_TYPE_BOOK,
G_PARAM_READWRITE));
- g_object_class_install_property (object_class, PROP_CARD,
- g_param_spec_object ("card",
- _("Card"),
+ g_object_class_install_property (object_class, PROP_CONTACT,
+ g_param_spec_object ("contact",
+ _("Contact"),
/*_( */"XXX blurb" /*)*/,
- E_TYPE_CARD,
+ E_TYPE_CONTACT,
G_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_IS_NEW_LIST,
@@ -212,8 +232,10 @@ e_contact_list_editor_init (EContactListEditor *editor)
GtkWidget *bonobo_win;
BonoboUIContainer *container;
char *icon_path;
+ GdkPixbuf *pixbuf;
- editor->card = NULL;
+ editor->image_buf = NULL;
+ editor->contact = NULL;
editor->changed = FALSE;
editor->editable = TRUE;
editor->in_async_call = FALSE;
@@ -235,9 +257,17 @@ e_contact_list_editor_init (EContactListEditor *editor)
editor->email_entry = glade_xml_get_widget (gui, "email-entry");
editor->list_name_entry = glade_xml_get_widget (gui, "list-name-entry");
-
+ editor->list_image = glade_xml_get_widget (gui, "list-image");
+ if (GTK_IS_ALIGNMENT (editor->list_image)) {
+ /* deal with the e_create_image_widget code, that wraps the image in an alignment */
+ editor->list_image = GTK_BIN (editor->list_image)->child;
+ }
editor->visible_addrs_checkbutton = glade_xml_get_widget (gui, "visible-addrs-checkbutton");
+ pixbuf = gtk_image_get_pixbuf (GTK_IMAGE (editor->list_image));
+ editor->list_image_width = gdk_pixbuf_get_width (pixbuf);
+ editor->list_image_height = gdk_pixbuf_get_height (pixbuf);
+
/* Construct the app */
bonobo_win = bonobo_window_new ("contact-list-editor", _("Contact List Editor"));
@@ -286,7 +316,7 @@ e_contact_list_editor_init (EContactListEditor *editor)
"toggled", G_CALLBACK(visible_addrs_toggled_cb), editor);
e_table_drag_dest_set (e_table_scrolled_get_table (E_TABLE_SCROLLED (editor->table)),
- 0, drag_types, num_drag_types, GDK_ACTION_LINK);
+ 0, list_drag_types, num_list_drag_types, GDK_ACTION_LINK);
g_signal_connect (e_table_scrolled_get_table (E_TABLE_SCROLLED (editor->table)),
"table_drag_motion", G_CALLBACK(table_drag_motion_cb), editor);
@@ -295,6 +325,14 @@ e_contact_list_editor_init (EContactListEditor *editor)
g_signal_connect (e_table_scrolled_get_table (E_TABLE_SCROLLED (editor->table)),
"table_drag_data_received", G_CALLBACK(table_drag_data_received_cb), editor);
+ gtk_drag_dest_set (editor->list_image, 0, image_drag_types, num_image_drag_types, GDK_ACTION_COPY);
+ g_signal_connect (editor->list_image,
+ "drag_motion", G_CALLBACK (image_drag_motion_cb), editor);
+ g_signal_connect (editor->list_image,
+ "drag_drop", G_CALLBACK (image_drag_drop_cb), editor);
+ g_signal_connect (editor->list_image,
+ "drag_data_received", G_CALLBACK (image_drag_data_received_cb), editor);
+
command_state_changed (editor);
/* Connect to the deletion of the dialog */
@@ -311,6 +349,13 @@ e_contact_list_editor_init (EContactListEditor *editor)
static void
e_contact_list_editor_dispose (GObject *object)
{
+ EContactListEditor *cle = E_CONTACT_LIST_EDITOR (object);
+
+ if (cle->image_buf) {
+ g_free (cle->image_buf);
+ cle->image_buf = NULL;
+ }
+
if (G_OBJECT_CLASS (parent_class)->dispose)
(* G_OBJECT_CLASS (parent_class)->dispose) (object);
}
@@ -330,12 +375,12 @@ list_added_cb (EBook *book, EBookStatus status, const char *id, EditorCloseStruc
gtk_widget_set_sensitive (cle->app, TRUE);
cle->in_async_call = FALSE;
- e_card_set_id (cle->card, id);
+ e_contact_set (cle->contact, E_CONTACT_UID, (char*)id);
g_signal_emit (cle, contact_list_editor_signals[LIST_ADDED], 0,
- status, cle->card);
+ status, cle->contact);
- if (status == E_BOOK_STATUS_SUCCESS) {
+ if (status == E_BOOK_ERROR_OK) {
cle->is_new_list = FALSE;
if (should_close)
@@ -359,9 +404,9 @@ list_modified_cb (EBook *book, EBookStatus status, EditorCloseStruct *ecs)
cle->in_async_call = FALSE;
g_signal_emit (cle, contact_list_editor_signals[LIST_MODIFIED], 0,
- status, cle->card);
+ status, cle->contact);
- if (status == E_BOOK_STATUS_SUCCESS) {
+ if (status == E_BOOK_ERROR_OK) {
if (should_close)
close_dialog (cle);
}
@@ -371,7 +416,7 @@ list_modified_cb (EBook *book, EBookStatus status, EditorCloseStruct *ecs)
}
static void
-save_card (EContactListEditor *cle, gboolean should_close)
+save_contact (EContactListEditor *cle, gboolean should_close)
{
extract_info (cle);
@@ -387,9 +432,9 @@ save_card (EContactListEditor *cle, gboolean should_close)
cle->in_async_call = TRUE;
if (cle->is_new_list)
- e_book_add_card (cle->book, cle->card, (EBookIdCallback)list_added_cb, ecs);
+ e_book_async_add_contact (cle->book, cle->contact, (EBookIdCallback)list_added_cb, ecs);
else
- e_book_commit_card (cle->book, cle->card, (EBookCallback)list_modified_cb, ecs);
+ e_book_async_commit_contact (cle->book, cle->contact, (EBookCallback)list_modified_cb, ecs);
cle->changed = FALSE;
}
@@ -416,9 +461,9 @@ prompt_to_save_changes (EContactListEditor *editor)
if (!editor->changed || !is_named (editor))
return TRUE;
- switch (e_addressbook_prompt_save_dialog (GTK_WINDOW(editor->app))) {
+ switch (eab_prompt_save_dialog (GTK_WINDOW(editor->app))) {
case GTK_RESPONSE_YES:
- save_card (editor, FALSE);
+ save_contact (editor, FALSE);
return TRUE;
case GTK_RESPONSE_NO:
return TRUE;
@@ -444,7 +489,7 @@ file_save_cb (GtkWidget *widget, gpointer data)
{
EContactListEditor *cle = E_CONTACT_LIST_EDITOR (data);
- save_card (cle, FALSE);
+ save_contact (cle, FALSE);
}
static void
@@ -454,7 +499,7 @@ file_save_as_cb (GtkWidget *widget, gpointer data)
extract_info (cle);
- e_contact_save_as(_("Save List as VCard"), cle->card, GTK_WINDOW (cle->app));
+ eab_contact_save(_("Save List as VCard"), cle->contact, GTK_WINDOW (cle->app));
}
static void
@@ -464,7 +509,7 @@ file_send_as_cb (GtkWidget *widget, gpointer data)
extract_info (cle);
- e_addressbook_send_card(cle->card, E_ADDRESSBOOK_DISPOSITION_AS_ATTACHMENT);
+ eab_send_contact(cle->contact, EAB_DISPOSITION_AS_ATTACHMENT);
}
static void
@@ -474,14 +519,14 @@ file_send_to_cb (GtkWidget *widget, gpointer data)
extract_info (cle);
- e_addressbook_send_card(cle->card, E_ADDRESSBOOK_DISPOSITION_AS_TO);
+ eab_send_contact(cle->contact, EAB_DISPOSITION_AS_TO);
}
static void
tb_save_and_close_cb (GtkWidget *widget, gpointer data)
{
EContactListEditor *cle = E_CONTACT_LIST_EDITOR (data);
- save_card (cle, TRUE);
+ save_contact (cle, TRUE);
}
static void
@@ -492,10 +537,10 @@ list_deleted_cb (EBook *book, EBookStatus status, EContactListEditor *cle)
cle->in_async_call = FALSE;
g_signal_emit (cle, contact_list_editor_signals[LIST_DELETED], 0,
- status, cle->card);
+ status, cle->contact);
/* always close the dialog after we successfully delete a list */
- if (status == E_BOOK_STATUS_SUCCESS)
+ if (status == E_BOOK_ERROR_OK)
close_dialog (cle);
g_object_unref (cle); /* release reference held for callback */
@@ -505,9 +550,9 @@ static void
delete_cb (GtkWidget *widget, gpointer data)
{
EContactListEditor *cle = E_CONTACT_LIST_EDITOR (data);
- ECard *card = cle->card;
+ EContact *contact = cle->contact;
- g_object_ref (card);
+ g_object_ref (contact);
if (e_contact_editor_confirm_delete(GTK_WINDOW(cle->app))) {
@@ -518,11 +563,11 @@ delete_cb (GtkWidget *widget, gpointer data)
cle->in_async_call = TRUE;
g_object_ref (cle); /* hold reference for callback */
- e_book_remove_card (cle->book, card, (EBookCallback)list_deleted_cb, cle);
+ e_book_async_remove_contact (cle->book, contact, (EBookCallback)list_deleted_cb, cle);
}
}
- g_object_unref (card);
+ g_object_unref (contact);
}
static
@@ -578,7 +623,7 @@ contact_list_editor_destroy_notify (gpointer data,
EContactListEditor *
e_contact_list_editor_new (EBook *book,
- ECard *list_card,
+ EContact *list_contact,
gboolean is_new_list,
gboolean editable)
{
@@ -592,7 +637,7 @@ e_contact_list_editor_new (EBook *book,
g_object_set (ce,
"book", book,
- "card", list_card,
+ "contact", list_contact,
"is_new_list", is_new_list,
"editable", editable,
NULL);
@@ -616,10 +661,10 @@ e_contact_list_editor_set_property (GObject *object, guint prop_id,
g_object_ref (editor->book);
/* XXX more here about editable/etc. */
break;
- case PROP_CARD:
- if (editor->card)
- g_object_unref (editor->card);
- editor->card = e_card_duplicate(E_CARD(g_value_get_object (value)));
+ case PROP_CONTACT:
+ if (editor->contact)
+ g_object_unref (editor->contact);
+ editor->contact = e_contact_duplicate(E_CONTACT(g_value_get_object (value)));
fill_in_info(editor);
editor->changed = FALSE;
command_state_changed (editor);
@@ -665,9 +710,9 @@ e_contact_list_editor_get_property (GObject *object, guint prop_id,
g_value_set_object (value, editor->book);
break;
- case PROP_CARD:
+ case PROP_CONTACT:
extract_info(editor);
- g_value_set_object (value, editor->card);
+ g_value_set_object (value, editor->contact);
break;
case PROP_IS_NEW_LIST:
@@ -822,7 +867,7 @@ table_drag_motion_cb (ETable *table, int row, int col,
for (p = context->targets; p != NULL; p = p->next) {
char *possible_type;
- possible_type = gdk_atom_name ((GdkAtom) p->data);
+ possible_type = gdk_atom_name (GDK_POINTER_TO_ATOM (p->data));
if (!strcmp (possible_type, VCARD_TYPE)) {
g_free (possible_type);
gdk_drag_status (context, GDK_ACTION_LINK, time);
@@ -866,28 +911,24 @@ table_drag_data_received_cb (ETable *table, int row, int col,
if (!strcmp (target_type, VCARD_TYPE)) {
- GList *card_list = e_card_load_cards_from_string_with_default_charset (selection_data->data, "ISO-8859-1");
+ GList *contact_list = eab_contact_list_from_string (selection_data->data);
GList *c;
- if (card_list)
+ if (contact_list)
handled = TRUE;
- for (c = card_list; c; c = c->next) {
- ECard *ecard = c->data;
-
- if (!e_card_evolution_list (ecard)) {
- ECardSimple *simple = e_card_simple_new (ecard);
+ for (c = contact_list; c; c = c->next) {
+ EContact *contact = c->data;
- e_contact_list_model_add_card (E_CONTACT_LIST_MODEL (editor->model),
- simple);
-
- g_object_unref (simple);
+ if (!e_contact_get (contact, E_CONTACT_IS_LIST)) {
+ e_contact_list_model_add_contact (E_CONTACT_LIST_MODEL (editor->model),
+ contact);
changed = TRUE;
}
}
- g_list_foreach (card_list, (GFunc)g_object_unref, NULL);
- g_list_free (card_list);
+ g_list_foreach (contact_list, (GFunc)g_object_unref, NULL);
+ g_list_free (contact_list);
/* Skip to the end of the list */
if (adj->upper - adj->lower > adj->page_size)
@@ -902,6 +943,219 @@ table_drag_data_received_cb (ETable *table, int row, int col,
gtk_drag_finish (context, handled, FALSE, time);
}
+static gboolean
+set_image_from_data (EContactListEditor *editor,
+ char *data, int length)
+{
+ gboolean rv = FALSE;
+ GdkPixbufLoader *loader = gdk_pixbuf_loader_new ();
+ GdkPixbuf *pixbuf;
+
+ gdk_pixbuf_loader_write (loader, data, length, NULL);
+
+ pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
+ if (pixbuf)
+ gdk_pixbuf_ref (pixbuf);
+ gdk_pixbuf_loader_close (loader, NULL);
+ g_object_unref (loader);
+
+ if (pixbuf) {
+ GdkPixbuf *scaled;
+ GdkPixbuf *composite;
+
+ float scale;
+ int new_height, new_width;
+
+ new_height = gdk_pixbuf_get_height (pixbuf);
+ new_width = gdk_pixbuf_get_width (pixbuf);
+
+ printf ("new dimensions = (%d,%d)\n", new_width, new_height);
+
+ if (editor->list_image_height < new_height
+ || editor->list_image_width < new_width) {
+ /* we need to scale down */
+ printf ("we need to scale down\n");
+ if (new_height > new_width)
+ scale = (float)editor->list_image_height / new_height;
+ else
+ scale = (float)editor->list_image_width / new_width;
+ }
+ else {
+ /* we need to scale up */
+ printf ("we need to scale up\n");
+ if (new_height > new_width)
+ scale = (float)new_height / editor->list_image_height;
+ else
+ scale = (float)new_width / editor->list_image_width;
+ }
+
+ printf ("scale = %g\n", scale);
+
+ new_width *= scale;
+ new_height *= scale;
+ new_width = MIN (new_width, editor->list_image_width);
+ new_height = MIN (new_height, editor->list_image_height);
+
+ printf ("new scaled dimensions = (%d,%d)\n", new_width, new_height);
+
+ scaled = gdk_pixbuf_scale_simple (pixbuf,
+ new_width, new_height,
+ GDK_INTERP_BILINEAR);
+
+ composite = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, gdk_pixbuf_get_bits_per_sample (pixbuf),
+ editor->list_image_width, editor->list_image_height);
+
+ gdk_pixbuf_fill (composite, 0x00000000);
+
+ gdk_pixbuf_copy_area (scaled, 0, 0, new_width, new_height,
+ composite,
+ editor->list_image_width / 2 - new_width / 2,
+ editor->list_image_height / 2 - new_height / 2);
+
+ gtk_image_set_from_pixbuf (GTK_IMAGE (editor->list_image), composite);
+ gdk_pixbuf_unref (pixbuf);
+ gdk_pixbuf_unref (scaled);
+ gdk_pixbuf_unref (composite);
+
+ rv = TRUE;
+ }
+
+ return rv;
+}
+
+static gboolean
+image_drag_motion_cb (GtkWidget *widget,
+ GdkDragContext *context,
+ gint x, gint y, guint time, EContactListEditor *editor)
+{
+ GList *p;
+
+ for (p = context->targets; p != NULL; p = p->next) {
+ char *possible_type;
+
+ possible_type = gdk_atom_name (GDK_POINTER_TO_ATOM (p->data));
+ if (!strcmp (possible_type, URI_LIST_TYPE)) {
+ g_free (possible_type);
+ gdk_drag_status (context, GDK_ACTION_COPY, time);
+ return TRUE;
+ }
+
+ g_free (possible_type);
+ }
+
+ return FALSE;
+}
+
+static gboolean
+image_drag_drop_cb (GtkWidget *widget,
+ GdkDragContext *context,
+ gint x, gint y, guint time, EContactListEditor *editor)
+{
+ GList *p;
+
+ if (context->targets == NULL)
+ return FALSE;
+
+
+ for (p = context->targets; p != NULL; p = p->next) {
+ char *possible_type;
+
+ possible_type = gdk_atom_name (GDK_POINTER_TO_ATOM (p->data));
+ if (!strcmp (possible_type, URI_LIST_TYPE)) {
+ g_free (possible_type);
+ gtk_drag_get_data (widget, context,
+ GDK_POINTER_TO_ATOM (p->data),
+ time);
+ return TRUE;
+ }
+
+ g_free (possible_type);
+ }
+
+ return FALSE;
+}
+
+static void
+image_drag_data_received_cb (GtkWidget *widget,
+ GdkDragContext *context,
+ gint x, gint y,
+ GtkSelectionData *selection_data,
+ guint info, guint time, EContactListEditor *editor)
+{
+ char *target_type;
+ gboolean changed = FALSE;
+ gboolean handled = FALSE;
+
+ target_type = gdk_atom_name (selection_data->target);
+
+ printf ("target_type == %s\n", target_type);
+
+ if (!strcmp (target_type, URI_LIST_TYPE)) {
+ GnomeVFSResult result;
+ GnomeVFSHandle *handle;
+ char *uri;
+ char *nl = strstr (selection_data->data, "\r\n");
+ char *buf = NULL;
+ GnomeVFSFileInfo info;
+
+ if (nl)
+ uri = g_strndup (selection_data->data, nl - (char*)selection_data->data);
+ else
+ uri = g_strdup (selection_data->data);
+
+ printf ("uri == %s\n", uri);
+
+ result = gnome_vfs_open (&handle, uri, GNOME_VFS_OPEN_READ);
+ if (result == GNOME_VFS_OK) {
+ result = gnome_vfs_get_file_info_from_handle (handle, &info, GNOME_VFS_FILE_INFO_DEFAULT);
+ if (result == GNOME_VFS_OK) {
+ GnomeVFSFileSize num_left;
+ GnomeVFSFileSize num_read;
+ GnomeVFSFileSize total_read;
+
+ printf ("file size = %d\n", (int)info.size);
+ buf = g_malloc (info.size);
+
+ num_left = info.size;
+ total_read = 0;
+
+ while ((result = gnome_vfs_read (handle, buf + total_read, num_left, &num_read)) == GNOME_VFS_OK) {
+ num_left -= num_read;
+ total_read += num_read;
+ }
+
+ printf ("read %d bytes\n", (int)total_read);
+ if (set_image_from_data (editor, buf, total_read)) {
+ changed = TRUE;
+ handled = TRUE;
+ g_free (editor->image_buf);
+ editor->image_buf = buf;
+ editor->image_buf_size = total_read;
+ }
+ else {
+ /* XXX we should pop up a
+ warning dialog here */
+ g_free (buf);
+ }
+ }
+
+ gnome_vfs_close (handle);
+ }
+ else {
+ printf ("gnome_vfs_open failed (%s)\n", gnome_vfs_result_to_string (result));
+ }
+
+ g_free (uri);
+
+ if (changed) {
+ editor->changed = TRUE;
+ command_state_changed (editor);
+ }
+ }
+
+ gtk_drag_finish (context, handled, FALSE, time);
+}
+
static void
command_state_changed (EContactListEditor *editor)
{
@@ -926,48 +1180,43 @@ command_state_changed (EContactListEditor *editor)
static void
extract_info(EContactListEditor *editor)
{
- ECard *card = editor->card;
- if (card) {
+ EContact *contact = editor->contact;
+ if (contact) {
int i;
- EList *email_list;
- EIterator *email_iter;
+ GList *email_list;
char *string = gtk_editable_get_chars(GTK_EDITABLE (editor->list_name_entry), 0, -1);
- if (string && *string)
- g_object_set (card,
- "file_as", string,
- "full_name", string,
- NULL);
+ if (string && *string) {
+ e_contact_set (contact, E_CONTACT_FILE_AS, string);
+ e_contact_set (contact, E_CONTACT_FULL_NAME, string);
+ }
g_free (string);
-
- g_object_set (card,
- "list", GINT_TO_POINTER (TRUE),
- "list_show_addresses",
- GINT_TO_POINTER (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(editor->visible_addrs_checkbutton))),
- NULL);
-
- g_object_get (card,
- "email", &email_list,
- NULL);
-
- /* clear the email list */
- email_iter = e_list_get_iterator (email_list);
- e_iterator_last (email_iter);
- while (e_iterator_is_valid (E_ITERATOR (email_iter))) {
- e_iterator_delete (E_ITERATOR (email_iter));
- }
- g_object_unref (email_iter);
+ e_contact_set (contact, E_CONTACT_IS_LIST, GINT_TO_POINTER (TRUE));
+ e_contact_set (contact, E_CONTACT_LIST_SHOW_ADDRESSES,
+ GINT_TO_POINTER (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(editor->visible_addrs_checkbutton))));
+ email_list = NULL;
/* then refill it from the contact list model */
for (i = 0; i < e_table_model_row_count (editor->model); i ++) {
- const EDestination *dest = e_contact_list_model_get_destination (E_CONTACT_LIST_MODEL (editor->model), i);
- gchar *dest_xml = e_destination_export (dest);
- if (dest_xml) {
- e_list_append (email_list, dest_xml);
- }
- g_free (dest_xml);
+ const EABDestination *dest = e_contact_list_model_get_destination (E_CONTACT_LIST_MODEL (editor->model), i);
+ gchar *dest_xml = eab_destination_export (dest);
+ if (dest_xml)
+ email_list = g_list_append (email_list, dest_xml);
+ }
+
+ e_contact_set (contact, E_CONTACT_EMAIL, email_list);
+
+ /* XXX free email_list? */
+
+ if (editor->image_buf) {
+ EContactPhoto photo;
+
+ photo.data = editor->image_buf;
+ photo.length = editor->image_buf_size;
+
+ e_contact_set (contact, E_CONTACT_LOGO, &photo);
}
g_object_unref (email_list);
}
@@ -976,19 +1225,18 @@ extract_info(EContactListEditor *editor)
static void
fill_in_info(EContactListEditor *editor)
{
- if (editor->card) {
+ if (editor->contact) {
+ EContactPhoto *photo;
char *file_as;
gboolean show_addresses = FALSE;
gboolean is_evolution_list = FALSE;
- EList *email_list;
- EIterator *email_iter;
+ GList *email_list;
+ GList *iter;
- g_object_get (editor->card,
- "file_as", &file_as,
- "email", &email_list,
- "list", &is_evolution_list,
- "list_show_addresses", &show_addresses,
- NULL);
+ file_as = e_contact_get_const (editor->contact, E_CONTACT_FILE_AS);
+ email_list = e_contact_get (editor->contact, E_CONTACT_EMAIL);
+ is_evolution_list = GPOINTER_TO_INT (e_contact_get (editor->contact, E_CONTACT_IS_LIST));
+ show_addresses = GPOINTER_TO_INT (e_contact_get (editor->contact, E_CONTACT_LIST_SHOW_ADDRESSES));
gtk_editable_delete_text (GTK_EDITABLE (editor->list_name_entry), 0, -1);
if (file_as) {
@@ -1001,20 +1249,24 @@ fill_in_info(EContactListEditor *editor)
e_contact_list_model_remove_all (E_CONTACT_LIST_MODEL (editor->model));
- email_iter = e_list_get_iterator (email_list);
-
- while (e_iterator_is_valid (email_iter)) {
- const char *dest_xml = e_iterator_get (email_iter);
- EDestination *dest;
+ for (iter = email_list; iter; iter = iter->next) {
+ char *dest_xml = iter->data;
+ EABDestination *dest;
/* g_message ("incoming xml: [%s]", dest_xml); */
- dest = e_destination_import (dest_xml);
+ dest = eab_destination_import (dest_xml);
if (dest != NULL) {
e_contact_list_model_add_destination (E_CONTACT_LIST_MODEL (editor->model), dest);
}
+ }
+
+ /* XXX free email_list */
- e_iterator_next (email_iter);
+ photo = e_contact_get (editor->contact, E_CONTACT_LOGO);
+ if (photo) {
+ set_image_from_data (editor, photo->data, photo->length);
+ e_contact_photo_free (photo);
}
g_object_unref (email_list);
}
diff --git a/addressbook/gui/contact-list-editor/e-contact-list-editor.h b/addressbook/gui/contact-list-editor/e-contact-list-editor.h
index 184145a0f7..62334c17bf 100644
--- a/addressbook/gui/contact-list-editor/e-contact-list-editor.h
+++ b/addressbook/gui/contact-list-editor/e-contact-list-editor.h
@@ -26,9 +26,8 @@
#include <glade/glade.h>
#include <gal/e-table/e-table-model.h>
-#include "addressbook/backend/ebook/e-book.h"
-#include "addressbook/backend/ebook/e-card.h"
-#include "addressbook/backend/ebook/e-card-simple.h"
+#include "addressbook/backend/ebook/e-book-async.h"
+#include "addressbook/backend/ebook/e-contact.h"
G_BEGIN_DECLS
@@ -48,7 +47,7 @@ struct _EContactListEditor
/* item specific fields */
EBook *book;
- ECard *card;
+ EContact *contact;
/* UI handler */
BonoboUIComponent *uic;
@@ -62,12 +61,19 @@ struct _EContactListEditor
GtkWidget *list_name_entry;
GtkWidget *add_button;
GtkWidget *remove_button;
+ GtkWidget *list_image_button;
GtkWidget *visible_addrs_checkbutton;
+ GtkWidget *list_image;
+ int list_image_width;
+ int list_image_height;
- /* Whether we are editing a new card or an existing one */
+ char *image_buf;
+ int image_buf_size;
+
+ /* Whether we are editing a new contact or an existing one */
guint is_new_list : 1;
- /* Whether the card has been changed since bringing up the contact editor */
+ /* Whether the contact has been changed since bringing up the contact editor */
guint changed : 1;
/* Whether the contact editor will accept modifications */
@@ -83,14 +89,14 @@ struct _EContactListEditorClass
/* Notification signals */
- void (* list_added) (EContactListEditor *cle, EBookStatus status, ECard *card);
- void (* list_modified) (EContactListEditor *cle, EBookStatus status, ECard *card);
- void (* list_deleted) (EContactListEditor *cle, EBookStatus status, ECard *card);
+ void (* list_added) (EContactListEditor *cle, EBookStatus status, EContact *contact);
+ void (* list_modified) (EContactListEditor *cle, EBookStatus status, EContact *contact);
+ void (* list_deleted) (EContactListEditor *cle, EBookStatus status, EContact *contact);
void (* editor_closed) (EContactListEditor *cle);
};
EContactListEditor *e_contact_list_editor_new (EBook *book,
- ECard *list_card,
+ EContact *list_contact,
gboolean is_new_list,
gboolean editable);
GType e_contact_list_editor_get_type (void);
diff --git a/addressbook/gui/contact-list-editor/e-contact-list-model.c b/addressbook/gui/contact-list-editor/e-contact-list-model.c
index 89354aaece..80bc29b7a9 100644
--- a/addressbook/gui/contact-list-editor/e-contact-list-model.c
+++ b/addressbook/gui/contact-list-editor/e-contact-list-model.c
@@ -30,7 +30,7 @@ contact_list_value_at (ETableModel *etc, int col, int row)
{
EContactListModel *model = E_CONTACT_LIST_MODEL (etc);
- return (void *) e_destination_get_textrep (model->data[row], TRUE);
+ return (void *) eab_destination_get_textrep (model->data[row], TRUE);
}
/* This function sets the value at a particular point in our ETableModel. */
@@ -127,7 +127,7 @@ e_contact_list_model_init (GtkObject *object)
model->data_alloc = 10;
model->data_count = 0;
- model->data = g_new (EDestination*, model->data_alloc);
+ model->data = g_new (EABDestination*, model->data_alloc);
}
GType
@@ -172,16 +172,16 @@ e_contact_list_model_new ()
}
void
-e_contact_list_model_add_destination (EContactListModel *model, EDestination *dest)
+e_contact_list_model_add_destination (EContactListModel *model, EABDestination *dest)
{
g_return_if_fail (E_IS_CONTACT_LIST_MODEL (model));
- g_return_if_fail (E_IS_DESTINATION (dest));
+ g_return_if_fail (EAB_IS_DESTINATION (dest));
e_table_model_pre_change (E_TABLE_MODEL (model));
if (model->data_count + 1 >= model->data_alloc) {
model->data_alloc *= 2;
- model->data = g_renew (EDestination*, model->data, model->data_alloc);
+ model->data = g_renew (EABDestination*, model->data, model->data_alloc);
}
model->data[model->data_count ++] = dest;
@@ -194,28 +194,28 @@ void
e_contact_list_model_add_email (EContactListModel *model,
const char *email)
{
- EDestination *new_dest;
+ EABDestination *new_dest;
g_return_if_fail (E_IS_CONTACT_LIST_MODEL (model));
g_return_if_fail (email != NULL);
- new_dest = e_destination_new ();
- e_destination_set_email (new_dest, email);
+ new_dest = eab_destination_new ();
+ eab_destination_set_email (new_dest, email);
e_contact_list_model_add_destination (model, new_dest);
}
void
-e_contact_list_model_add_card (EContactListModel *model,
- ECardSimple *simple)
+e_contact_list_model_add_contact (EContactListModel *model,
+ EContact *contact)
{
- EDestination *new_dest;
+ EABDestination *new_dest;
g_return_if_fail (E_IS_CONTACT_LIST_MODEL (model));
- g_return_if_fail (E_IS_CARD_SIMPLE (simple));
+ g_return_if_fail (E_IS_CONTACT (contact));
- new_dest = e_destination_new ();
- e_destination_set_card (new_dest, simple->card, 0); /* Hard-wired for default e-mail */
+ new_dest = eab_destination_new ();
+ eab_destination_set_contact (new_dest, contact, 0); /* Hard-wired for default e-mail */
e_contact_list_model_add_destination (model, new_dest);
}
@@ -229,7 +229,7 @@ e_contact_list_model_remove_row (EContactListModel *model, int row)
e_table_model_pre_change (E_TABLE_MODEL (model));
g_object_unref (model->data[row]);
- memmove (model->data + row, model->data + row + 1, sizeof (EDestination*) * (model->data_count - row - 1));
+ memmove (model->data + row, model->data + row + 1, sizeof (EABDestination*) * (model->data_count - row - 1));
model->data_count --;
e_table_model_row_deleted (E_TABLE_MODEL (model), row);
@@ -255,7 +255,7 @@ e_contact_list_model_remove_all (EContactListModel *model)
}
-const EDestination *
+const EABDestination *
e_contact_list_model_get_destination (EContactListModel *model, int row)
{
g_return_val_if_fail (E_IS_CONTACT_LIST_MODEL (model), NULL);
diff --git a/addressbook/gui/contact-list-editor/e-contact-list-model.h b/addressbook/gui/contact-list-editor/e-contact-list-model.h
index bb07d83544..92d3d9bc60 100644
--- a/addressbook/gui/contact-list-editor/e-contact-list-model.h
+++ b/addressbook/gui/contact-list-editor/e-contact-list-model.h
@@ -4,10 +4,9 @@
#include <gtk/gtk.h>
#include <gal/e-table/e-table-model.h>
-#include "addressbook/backend/ebook/e-book.h"
-#include "addressbook/backend/ebook/e-book-view.h"
-#include "addressbook/backend/ebook/e-card-simple.h"
-#include "addressbook/backend/ebook/e-destination.h"
+#include "addressbook/backend/ebook/e-book-async.h"
+#include "addressbook/backend/ebook/e-contact.h"
+#include "addressbook/util/eab-destination.h"
G_BEGIN_DECLS
@@ -23,7 +22,7 @@ typedef struct _EContactListModelClass EContactListModelClass;
struct _EContactListModel {
ETableModel parent;
- EDestination **data;
+ EABDestination **data;
int data_count;
int data_alloc;
};
@@ -38,14 +37,14 @@ GType e_contact_list_model_get_type (void);
void e_contact_list_model_construct (EContactListModel *model);
ETableModel *e_contact_list_model_new (void);
-void e_contact_list_model_add_destination (EContactListModel *model, EDestination *dest);
+void e_contact_list_model_add_destination (EContactListModel *model, EABDestination *dest);
void e_contact_list_model_add_email (EContactListModel *model, const char *email);
-void e_contact_list_model_add_card (EContactListModel *model, ECardSimple *simple);
+void e_contact_list_model_add_contact (EContactListModel *model, EContact *contact);
void e_contact_list_model_remove_row (EContactListModel *model, int row);
void e_contact_list_model_remove_all (EContactListModel *model);
-const EDestination *e_contact_list_model_get_destination (EContactListModel *model, int row);
+const EABDestination *e_contact_list_model_get_destination (EContactListModel *model, int row);
G_END_DECLS
diff --git a/addressbook/gui/merging/.cvsignore b/addressbook/gui/merging/.cvsignore
index d6c55c7345..b6fa83ca4c 100644
--- a/addressbook/gui/merging/.cvsignore
+++ b/addressbook/gui/merging/.cvsignore
@@ -5,3 +5,4 @@ Makefile
Makefile.in
*.lo
*.la
+*.gladep
diff --git a/addressbook/gui/merging/Makefile.am b/addressbook/gui/merging/Makefile.am
index f30edd5745..4627f30594 100644
--- a/addressbook/gui/merging/Makefile.am
+++ b/addressbook/gui/merging/Makefile.am
@@ -1,7 +1,8 @@
INCLUDES = \
- -DG_LOG_DOMAIN=\"e-card-gui\" \
+ -DG_LOG_DOMAIN=\"eab-contact-merging\" \
-DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \
-I$(top_srcdir) \
+ -I$(top_srcdir)/addressbook \
-I$(top_srcdir)/addressbook/backend \
-I$(top_builddir)/addressbook/backend \
-DG_DISABLE_DEPRECATED \
@@ -11,15 +12,17 @@ INCLUDES = \
$(EVOLUTION_ADDRESSBOOK_CFLAGS)
noinst_LTLIBRARIES = \
- libecardmerging.la
+ libeabbookmerging.la
-libecardmerging_la_SOURCES = \
- e-card-merging.c \
- e-card-merging.h
+libeabbookmerging_la_SOURCES = \
+ eab-contact-compare.c \
+ eab-contact-compare.h \
+ eab-contact-merging.c \
+ eab-contact-merging.h
-glade_DATA = e-card-duplicate-detected.glade \
- e-card-merging-book-commit-duplicate-detected.glade
+glade_DATA = eab-contact-duplicate-detected.glade \
+ eab-contact-commit-duplicate-detected.glade
EXTRA_DIST = \
$(glade_DATA)
diff --git a/addressbook/gui/merging/e-card-merging.c b/addressbook/gui/merging/e-card-merging.c
deleted file mode 100644
index f2322e772c..0000000000
--- a/addressbook/gui/merging/e-card-merging.c
+++ /dev/null
@@ -1,198 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Code for checking for duplicates when doing ECard work.
- *
- * Author:
- * Christopher James Lahey <clahey@ximian.com>
- *
- * Copyright 2001, Ximian, Inc.
- */
-
-#include <config.h>
-
-#include "e-card-merging.h"
-#include <ebook/e-card-compare.h>
-#include <glade/glade.h>
-#include <gtk/gtksignal.h>
-#include "addressbook/gui/widgets/e-minicard-widget.h"
-
-typedef enum {
- E_CARD_MERGING_ADD,
- E_CARD_MERGING_COMMIT
-} ECardMergingOpType;
-
-typedef struct {
- ECardMergingOpType op;
- EBook *book;
- ECard *card;
- EBookIdCallback id_cb;
- EBookCallback cb;
- gpointer closure;
-} ECardMergingLookup;
-
-static void
-free_lookup (ECardMergingLookup *lookup)
-{
- g_object_unref (lookup->book);
- g_object_unref (lookup->card);
-
- g_free (lookup);
-}
-
-static void
-final_id_cb (EBook *book, EBookStatus status, const char *id, gpointer closure)
-{
- ECardMergingLookup *lookup = closure;
-
- if (lookup->id_cb)
- lookup->id_cb (lookup->book, status, id, lookup->closure);
-
- free_lookup (lookup);
-}
-
-static void
-final_cb (EBook *book, EBookStatus status, gpointer closure)
-{
- ECardMergingLookup *lookup = closure;
-
- if (lookup->cb)
- lookup->cb (lookup->book, status, lookup->closure);
-
- free_lookup (lookup);
-}
-
-static void
-doit (ECardMergingLookup *lookup)
-{
- if (lookup->op == E_CARD_MERGING_ADD)
- e_book_add_card (lookup->book, lookup->card, final_id_cb, lookup);
- else if (lookup->op == E_CARD_MERGING_COMMIT)
- e_book_commit_card (lookup->book, lookup->card, final_cb, lookup);
-}
-
-static void
-cancelit (ECardMergingLookup *lookup)
-{
- if (lookup->op == E_CARD_MERGING_ADD) {
- if (lookup->id_cb)
- final_id_cb (lookup->book, E_BOOK_STATUS_CANCELLED, NULL, lookup);
- } else if (lookup->op == E_CARD_MERGING_COMMIT) {
- if (lookup->cb)
- final_cb (lookup->book, E_BOOK_STATUS_CANCELLED, lookup);
- }
-}
-
-static void
-response (GtkWidget *dialog, int response, ECardMergingLookup *lookup)
-{
- gtk_widget_destroy (dialog);
-
- switch (response) {
- case 0:
- doit (lookup);
- break;
- case 1:
- cancelit (lookup);
- break;
- }
-}
-
-static void
-match_query_callback (ECard *card, ECard *match, ECardMatchType type, gpointer closure)
-{
- ECardMergingLookup *lookup = closure;
-
- if ((gint) type <= (gint) E_CARD_MATCH_VAGUE) {
- doit (lookup);
- } else {
- GladeXML *ui;
-
- GtkWidget *widget;
-
- if (lookup->op == E_CARD_MERGING_ADD)
- ui = glade_xml_new (EVOLUTION_GLADEDIR "/e-card-duplicate-detected.glade", NULL, NULL);
- else if (lookup->op == E_CARD_MERGING_COMMIT)
- ui = glade_xml_new (EVOLUTION_GLADEDIR "/e-card-merging-book-commit-duplicate-detected.glade", NULL, NULL);
- else {
- doit (lookup);
- return;
- }
-
- widget = glade_xml_get_widget (ui, "custom-old-card");
- g_object_set (widget,
- "card", match,
- NULL);
-
- widget = glade_xml_get_widget (ui, "custom-new-card");
- g_object_set (widget,
- "card", card,
- NULL);
-
- widget = glade_xml_get_widget (ui, "dialog-duplicate-contact");
-
- g_signal_connect (widget, "response",
- G_CALLBACK (response), lookup);
-
- gtk_widget_show_all (widget);
- }
-}
-
-gboolean
-e_card_merging_book_add_card (EBook *book,
- ECard *card,
- EBookIdCallback cb,
- gpointer closure)
-{
- ECardMergingLookup *lookup;
-
- lookup = g_new (ECardMergingLookup, 1);
-
- lookup->op = E_CARD_MERGING_ADD;
- lookup->book = g_object_ref (book);
- lookup->card = g_object_ref (card);
- lookup->id_cb = cb;
- lookup->closure = closure;
-
- e_card_locate_match_full (book, card, NULL, match_query_callback, lookup);
-
- return TRUE;
-}
-
-gboolean
-e_card_merging_book_commit_card (EBook *book,
- ECard *card,
- EBookCallback cb,
- gpointer closure)
-{
- ECardMergingLookup *lookup;
- GList *avoid;
-
- lookup = g_new (ECardMergingLookup, 1);
-
- lookup->op = E_CARD_MERGING_COMMIT;
- lookup->book = g_object_ref (book);
- lookup->card = g_object_ref (card);
- lookup->cb = cb;
- lookup->closure = closure;
-
- avoid = g_list_append (NULL, card);
-
- e_card_locate_match_full (book, card, avoid, match_query_callback, lookup);
-
- g_list_free (avoid);
-
- return TRUE;
-}
-
-GtkWidget *
-e_card_merging_create_old_card(gchar *name,
- gchar *string1, gchar *string2,
- gint int1, gint int2);
-
-GtkWidget *
-e_card_merging_create_old_card(gchar *name,
- gchar *string1, gchar *string2,
- gint int1, gint int2)
-{
- return e_minicard_widget_new ();
-}
diff --git a/addressbook/gui/merging/e-card-merging.h b/addressbook/gui/merging/e-card-merging.h
deleted file mode 100644
index 8ea1f9f018..0000000000
--- a/addressbook/gui/merging/e-card-merging.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * The Evolution addressbook client object.
- *
- * Author:
- * Christopher James Lahey <clahey@ximian.com>
- *
- * Copyright 2001, Ximian, Inc.
- */
-
-#ifndef __E_CARD_MERGING_H__
-#define __E_CARD_MERGING_H__
-
-#include <addressbook/backend/ebook/e-book.h>
-
-G_BEGIN_DECLS
-
-gboolean e_card_merging_book_add_card (EBook *book,
- ECard *card,
- EBookIdCallback cb,
- gpointer closure);
-gboolean e_card_merging_book_commit_card (EBook *book,
- ECard *card,
- EBookCallback cb,
- gpointer closure);
-
-G_END_DECLS
-
-#endif /* ! __E_CARD_MERGING_H__ */
diff --git a/addressbook/gui/merging/e-card-merging-book-commit-duplicate-detected.glade b/addressbook/gui/merging/eab-contact-commit-duplicate-detected.glade
index f7cfd259e5..789c465d92 100644
--- a/addressbook/gui/merging/e-card-merging-book-commit-duplicate-detected.glade
+++ b/addressbook/gui/merging/eab-contact-commit-duplicate-detected.glade
@@ -68,12 +68,12 @@
<property name="column_spacing">6</property>
<child>
- <widget class="Custom" id="custom-old-card">
+ <widget class="Custom" id="custom-old-contact">
<property name="visible">True</property>
- <property name="creation_function">e_card_merging_create_old_card</property>
+ <property name="creation_function">_eab_contact_merging_create_contact_display</property>
<property name="int1">0</property>
<property name="int2">0</property>
- <property name="last_modification_time">Fri, 08 Jun 2001 01:33:22 GMT</property>
+ <property name="last_modification_time">Sun, 05 Oct 2003 03:54:20 GMT</property>
</widget>
<packing>
<property name="left_attach">1</property>
@@ -155,12 +155,12 @@ exists in this folder. Would you like to add it anyway?</property>
</child>
<child>
- <widget class="Custom" id="custom-new-card">
+ <widget class="Custom" id="custom-new-contact">
<property name="visible">True</property>
- <property name="creation_function">e_card_merging_create_old_card</property>
+ <property name="creation_function">_eab_contact_merging_create_contact_display</property>
<property name="int1">0</property>
<property name="int2">0</property>
- <property name="last_modification_time">Fri, 08 Jun 2001 01:33:22 GMT</property>
+ <property name="last_modification_time">Sun, 05 Oct 2003 03:53:42 GMT</property>
</widget>
<packing>
<property name="left_attach">1</property>
diff --git a/addressbook/gui/merging/eab-contact-compare.c b/addressbook/gui/merging/eab-contact-compare.c
new file mode 100644
index 0000000000..409b1bce81
--- /dev/null
+++ b/addressbook/gui/merging/eab-contact-compare.c
@@ -0,0 +1,736 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ * eab-contact-compare.c
+ *
+ * Copyright (C) 2001, 2002, 2003 Ximian, Inc.
+ *
+ * Authors: Jon Trowbridge <trow@ximian.com>
+ * Chris Toshok <toshok@ximian.com>
+ */
+
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA.
+ */
+
+#include <config.h>
+#include <ctype.h>
+#include <string.h>
+#include "util/eab-book-util.h"
+#include "eab-contact-compare.h"
+
+/* This is an "optimistic" combiner: the best of the two outcomes is
+ selected. */
+static EABContactMatchType
+combine_comparisons (EABContactMatchType prev,
+ EABContactMatchType new_info)
+{
+ if (new_info == EAB_CONTACT_MATCH_NOT_APPLICABLE)
+ return prev;
+ return (EABContactMatchType) MAX ((gint) prev, (gint) new_info);
+}
+
+
+/*** Name comparisons ***/
+
+/* This *so* doesn't belong here... at least not implemented in a
+ sucky way like this. But it can be fixed later. */
+
+/* This is very Anglocentric. */
+static gchar *name_synonyms[][2] = {
+ { "jon", "john" }, /* Ah, the hacker's perogative */
+ { "joseph", "joe" },
+ { "robert", "bob" },
+ { "gene", "jean" },
+ { "jesse", "jessie" },
+ { "ian", "iain" },
+ { "richard", "dick" },
+ { "william", "bill" },
+ { "william", "will" },
+ { "anthony", "tony" },
+ { "michael", "mike" },
+ { "eric", "erik" },
+ { "elizabeth", "liz" },
+ { "jeff", "geoff" },
+ { "jeff", "geoffrey" },
+ { "tom", "thomas" },
+ { "dave", "david" },
+ { "jim", "james" },
+ { "abigal", "abby" },
+ { "amanda", "amy" },
+ { "amanda", "manda" },
+ { "jennifer", "jenny" },
+ { "christopher", "chris" },
+ { "rebecca", "becca" },
+ { "rebecca", "becky" },
+ { "anderson", "andersen" },
+ { "johnson", "johnsen" },
+ /* We could go on and on... */
+ /* We should add soundex here. */
+ { NULL, NULL }
+};
+
+static gboolean
+name_fragment_match (const gchar *a, const gchar *b, gboolean strict)
+{
+ gint len;
+
+ if (!(a && b && *a && *b))
+ return FALSE;
+
+ /* If we are in 'strict' mode, b must match the beginning of a.
+ So "Robert", "Rob" would match, but "Robert", "Robbie" wouldn't.
+
+ If strict is FALSE, it is sufficient for the strings to share
+ some leading characters. In this case, "Robert" and "Robbie"
+ would match, as would "Dave" and "Dan". */
+
+ if (strict) {
+ len = g_utf8_strlen (b, -1);
+ } else {
+ len = MIN (g_utf8_strlen (a, -1), g_utf8_strlen (b, -1));
+ }
+
+ return !e_utf8_casefold_collate_len (a, b, len);
+}
+
+static gboolean
+name_fragment_match_with_synonyms (const gchar *a, const gchar *b, gboolean strict)
+{
+ gint i;
+
+ if (!(a && b && *a && *b))
+ return FALSE;
+
+ if (name_fragment_match (a, b, strict))
+ return TRUE;
+
+ /* Check for nicknames. Yes, the linear search blows. */
+ for (i=0; name_synonyms[i][0]; ++i) {
+
+ if (!e_utf8_casefold_collate (name_synonyms[i][0], a)
+ && !e_utf8_casefold_collate (name_synonyms[i][1], b))
+ return TRUE;
+
+ if (!e_utf8_casefold_collate (name_synonyms[i][0], b)
+ && !e_utf8_casefold_collate (name_synonyms[i][1], a))
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+EABContactMatchType
+eab_contact_compare_name_to_string (EContact *contact, const gchar *str)
+{
+ return eab_contact_compare_name_to_string_full (contact, str, FALSE, NULL, NULL, NULL);
+}
+
+EABContactMatchType
+eab_contact_compare_name_to_string_full (EContact *contact, const gchar *str, gboolean allow_partial_matches,
+ gint *matched_parts_out, EABContactMatchPart *first_matched_part_out, gint *matched_character_count_out)
+{
+ gchar **namev, **givenv = NULL, **addv = NULL, **familyv = NULL;
+
+ gint matched_parts = EAB_CONTACT_MATCH_PART_NONE;
+ EABContactMatchPart first_matched_part = EAB_CONTACT_MATCH_PART_NONE;
+ EABContactMatchPart this_part_match = EAB_CONTACT_MATCH_PART_NOT_APPLICABLE;
+ EABContactMatchType match_type;
+ EContactName *contact_name;
+
+ gint match_count = 0, matched_character_count = 0, fragment_count;
+ gint i, j;
+ gchar *str_cpy, *s;
+
+ g_return_val_if_fail (E_IS_CONTACT (contact), EAB_CONTACT_MATCH_NOT_APPLICABLE);
+
+ if (!e_contact_get_const (contact, E_CONTACT_FULL_NAME))
+ return EAB_CONTACT_MATCH_NOT_APPLICABLE;
+ if (str == NULL)
+ return EAB_CONTACT_MATCH_NOT_APPLICABLE;
+
+ str_cpy = s = g_strdup (str);
+ while (*s) {
+ if (*s == ',' || *s == '"')
+ *s = ' ';
+ ++s;
+ }
+ namev = g_strsplit (str_cpy, " ", 0);
+ g_free (str_cpy);
+
+ contact_name = e_contact_get (contact, E_CONTACT_NAME);
+
+ if (contact_name->given)
+ givenv = g_strsplit (contact_name->given, " ", 0);
+ if (contact_name->additional)
+ addv = g_strsplit (contact_name->additional, " ", 0);
+ if (contact_name->family)
+ familyv = g_strsplit (contact_name->family, " ", 0);
+
+ e_contact_name_free (contact_name);
+
+ fragment_count = 0;
+ for (i = 0; givenv && givenv[i]; ++i)
+ ++fragment_count;
+ for (i = 0; addv && addv[i]; ++i)
+ ++fragment_count;
+ for (i = 0; familyv && familyv[i]; ++i)
+ ++fragment_count;
+
+ for (i = 0; namev[i] && this_part_match != EAB_CONTACT_MATCH_PART_NONE; ++i) {
+
+ if (*namev[i]) {
+
+ this_part_match = EAB_CONTACT_MATCH_PART_NONE;
+
+ /* When we are allowing partials, we are strict about the matches we allow.
+ Does this make sense? Not really, but it does the right thing for the purposes
+ of completion. */
+
+ if (givenv && this_part_match == EAB_CONTACT_MATCH_PART_NONE) {
+ for (j = 0; givenv[j]; ++j) {
+ if (name_fragment_match_with_synonyms (givenv[j], namev[i], allow_partial_matches)) {
+
+ this_part_match = EAB_CONTACT_MATCH_PART_GIVEN_NAME;
+
+ /* We remove a piece of a name once it has been matched against, so
+ that "john john" won't match "john doe". */
+ g_free (givenv[j]);
+ givenv[j] = g_strdup ("");
+ break;
+ }
+ }
+ }
+
+ if (addv && this_part_match == EAB_CONTACT_MATCH_PART_NONE) {
+ for (j = 0; addv[j]; ++j) {
+ if (name_fragment_match_with_synonyms (addv[j], namev[i], allow_partial_matches)) {
+
+ this_part_match = EAB_CONTACT_MATCH_PART_ADDITIONAL_NAME;
+
+ g_free (addv[j]);
+ addv[j] = g_strdup ("");
+ break;
+ }
+ }
+ }
+
+ if (familyv && this_part_match == EAB_CONTACT_MATCH_PART_NONE) {
+ for (j = 0; familyv[j]; ++j) {
+ if (allow_partial_matches ? name_fragment_match_with_synonyms (familyv[j], namev[i], allow_partial_matches)
+ : !e_utf8_casefold_collate (familyv[j], namev[i])) {
+
+ this_part_match = EAB_CONTACT_MATCH_PART_FAMILY_NAME;
+
+ g_free (familyv[j]);
+ familyv[j] = g_strdup ("");
+ break;
+ }
+ }
+ }
+
+ if (this_part_match != EAB_CONTACT_MATCH_PART_NONE) {
+ ++match_count;
+ matched_character_count += g_utf8_strlen (namev[i], -1);
+ matched_parts |= this_part_match;
+ if (first_matched_part == EAB_CONTACT_MATCH_PART_NONE)
+ first_matched_part = this_part_match;
+ }
+ }
+ }
+
+ match_type = EAB_CONTACT_MATCH_NONE;
+
+ if (this_part_match != EAB_CONTACT_MATCH_PART_NONE) {
+
+ if (match_count > 0)
+ match_type = EAB_CONTACT_MATCH_VAGUE;
+
+ if (fragment_count == match_count) {
+
+ match_type = EAB_CONTACT_MATCH_EXACT;
+
+ } else if (fragment_count == match_count + 1) {
+
+ match_type = EAB_CONTACT_MATCH_PARTIAL;
+
+ }
+ }
+
+ if (matched_parts_out)
+ *matched_parts_out = matched_parts;
+ if (first_matched_part_out)
+ *first_matched_part_out = first_matched_part;
+ if (matched_character_count_out)
+ *matched_character_count_out = matched_character_count;
+
+ g_strfreev (namev);
+ g_strfreev (givenv);
+ g_strfreev (addv);
+ g_strfreev (familyv);
+
+ return match_type;
+}
+
+EABContactMatchType
+eab_contact_compare_name (EContact *contact1, EContact *contact2)
+{
+ EContactName *a, *b;
+ gint matches=0, possible=0;
+ gboolean given_match = FALSE, additional_match = FALSE, family_match = FALSE;
+
+ g_return_val_if_fail (E_IS_CONTACT (contact1), EAB_CONTACT_MATCH_NOT_APPLICABLE);
+ g_return_val_if_fail (E_IS_CONTACT (contact2), EAB_CONTACT_MATCH_NOT_APPLICABLE);
+
+ a = e_contact_get (contact1, E_CONTACT_NAME);
+ b = e_contact_get (contact2, E_CONTACT_NAME);
+
+ if (a == NULL || b == NULL)
+ return EAB_CONTACT_MATCH_NOT_APPLICABLE;
+
+ if (a->given && b->given) {
+ ++possible;
+ if (name_fragment_match_with_synonyms (a->given, b->given, FALSE /* both inputs are complete */)) {
+ ++matches;
+ given_match = TRUE;
+ }
+ }
+
+ if (a->additional && b->additional) {
+ ++possible;
+ if (name_fragment_match_with_synonyms (a->additional, b->additional, FALSE /* both inputs are complete */)) {
+ ++matches;
+ additional_match = TRUE;
+ }
+ }
+
+ if (a->family && b->family) {
+ ++possible;
+ /* We don't allow "loose matching" (i.e. John vs. Jon) on family names */
+ if (! e_utf8_casefold_collate (a->family, b->family)) {
+ ++matches;
+ family_match = TRUE;
+ }
+ }
+
+ e_contact_name_free (a);
+ e_contact_name_free (b);
+
+ /* Now look at the # of matches and try to intelligently map
+ an EAB_CONTACT_MATCH_* type to it. Special consideration is given
+ to family-name matches. */
+
+ if (possible == 0)
+ return EAB_CONTACT_MATCH_NOT_APPLICABLE;
+
+ if (possible == 1)
+ return family_match ? EAB_CONTACT_MATCH_VAGUE : EAB_CONTACT_MATCH_NONE;
+
+ if (possible == matches)
+ return family_match ? EAB_CONTACT_MATCH_EXACT : EAB_CONTACT_MATCH_PARTIAL;
+
+ if (possible == matches+1)
+ return family_match ? EAB_CONTACT_MATCH_VAGUE : EAB_CONTACT_MATCH_NONE;
+
+ return EAB_CONTACT_MATCH_NONE;
+}
+
+
+/*** Nickname Comparisons ***/
+
+EABContactMatchType
+eab_contact_compare_nickname (EContact *contact1, EContact *contact2)
+{
+ g_return_val_if_fail (contact1 && E_IS_CONTACT (contact1), EAB_CONTACT_MATCH_NOT_APPLICABLE);
+ g_return_val_if_fail (contact2 && E_IS_CONTACT (contact2), EAB_CONTACT_MATCH_NOT_APPLICABLE);
+
+ return EAB_CONTACT_MATCH_NOT_APPLICABLE;
+}
+
+
+
+/*** E-mail Comparisons ***/
+
+static gboolean
+match_email_username (const gchar *addr1, const gchar *addr2)
+{
+ gint c1, c2;
+ if (addr1 == NULL || addr2 == NULL)
+ return FALSE;
+
+ while (*addr1 && *addr2 && *addr1 != '@' && *addr2 != '@') {
+ c1 = isupper (*addr1) ? tolower (*addr1) : *addr1;
+ c2 = isupper (*addr2) ? tolower (*addr2) : *addr2;
+ if (c1 != c2)
+ return FALSE;
+ ++addr1;
+ ++addr2;
+ }
+
+ return *addr1 == *addr2;
+}
+
+static gboolean
+match_email_hostname (const gchar *addr1, const gchar *addr2)
+{
+ gint c1, c2;
+ gboolean seen_at1, seen_at2;
+ if (addr1 == NULL || addr2 == NULL)
+ return FALSE;
+
+ /* Walk to the end of each string. */
+ seen_at1 = FALSE;
+ if (*addr1) {
+ while (*addr1) {
+ if (*addr1 == '@')
+ seen_at1 = TRUE;
+ ++addr1;
+ }
+ --addr1;
+ }
+
+ seen_at2 = FALSE;
+ if (*addr2) {
+ while (*addr2) {
+ if (*addr2 == '@')
+ seen_at2 = TRUE;
+ ++addr2;
+ }
+ --addr2;
+ }
+
+ if (!seen_at1 && !seen_at2)
+ return TRUE;
+ if (!seen_at1 || !seen_at2)
+ return FALSE;
+
+ while (*addr1 != '@' && *addr2 != '@') {
+ c1 = isupper (*addr1) ? tolower (*addr1) : *addr1;
+ c2 = isupper (*addr2) ? tolower (*addr2) : *addr2;
+ if (c1 != c2)
+ return FALSE;
+ --addr1;
+ --addr2;
+ }
+
+ /* This will match bob@foo.ximian.com and bob@ximian.com */
+ return *addr1 == '.' || *addr2 == '.';
+}
+
+static EABContactMatchType
+compare_email_addresses (const gchar *addr1, const gchar *addr2)
+{
+ if (addr1 == NULL || *addr1 == 0 ||
+ addr2 == NULL || *addr2 == 0)
+ return EAB_CONTACT_MATCH_NOT_APPLICABLE;
+
+ if (match_email_username (addr1, addr2))
+ return match_email_hostname (addr1, addr2) ? EAB_CONTACT_MATCH_EXACT : EAB_CONTACT_MATCH_VAGUE;
+
+ return EAB_CONTACT_MATCH_NONE;
+}
+
+EABContactMatchType
+eab_contact_compare_email (EContact *contact1, EContact *contact2)
+{
+ EABContactMatchType match = EAB_CONTACT_MATCH_NOT_APPLICABLE;
+ GList *contact1_email, *contact2_email;
+ GList *i1, *i2;
+
+ g_return_val_if_fail (contact1 && E_IS_CONTACT (contact1), EAB_CONTACT_MATCH_NOT_APPLICABLE);
+ g_return_val_if_fail (contact2 && E_IS_CONTACT (contact2), EAB_CONTACT_MATCH_NOT_APPLICABLE);
+
+ contact1_email = e_contact_get (contact1, E_CONTACT_EMAIL);
+ contact2_email = e_contact_get (contact2, E_CONTACT_EMAIL);
+
+ if (contact1_email == NULL || contact2_email == NULL) {
+ g_list_foreach (contact1_email, (GFunc)g_free, NULL);
+ g_list_free (contact1_email);
+
+ g_list_foreach (contact2_email, (GFunc)g_free, NULL);
+ g_list_free (contact2_email);
+ return EAB_CONTACT_MATCH_NOT_APPLICABLE;
+ }
+
+ i1 = contact1_email;
+
+ /* Do pairwise-comparisons on all of the e-mail addresses. If
+ we find an exact match, there is no reason to keep
+ checking. */
+ while (i1 && match != EAB_CONTACT_MATCH_EXACT) {
+ char *addr1 = (char *) i1->data;
+
+ i2 = contact2_email;
+ while (i2 && match != EAB_CONTACT_MATCH_EXACT) {
+ char *addr2 = (char *) i2->data;
+
+ match = combine_comparisons (match, compare_email_addresses (addr1, addr2));
+
+ i2 = i2->next;
+ }
+
+ i1 = i1->next;
+ }
+
+ g_list_foreach (contact1_email, (GFunc)g_free, NULL);
+ g_list_free (contact1_email);
+
+ g_list_foreach (contact2_email, (GFunc)g_free, NULL);
+ g_list_free (contact2_email);
+
+ return match;
+}
+
+EABContactMatchType
+eab_contact_compare_address (EContact *contact1, EContact *contact2)
+{
+ g_return_val_if_fail (contact1 && E_IS_CONTACT (contact1), EAB_CONTACT_MATCH_NOT_APPLICABLE);
+ g_return_val_if_fail (contact2 && E_IS_CONTACT (contact2), EAB_CONTACT_MATCH_NOT_APPLICABLE);
+
+ /* Unimplemented */
+
+ return EAB_CONTACT_MATCH_NOT_APPLICABLE;
+}
+
+EABContactMatchType
+eab_contact_compare_telephone (EContact *contact1, EContact *contact2)
+{
+ g_return_val_if_fail (contact1 && E_IS_CONTACT (contact1), EAB_CONTACT_MATCH_NOT_APPLICABLE);
+ g_return_val_if_fail (contact2 && E_IS_CONTACT (contact2), EAB_CONTACT_MATCH_NOT_APPLICABLE);
+
+ /* Unimplemented */
+
+ return EAB_CONTACT_MATCH_NOT_APPLICABLE;
+}
+
+EABContactMatchType
+eab_contact_compare (EContact *contact1, EContact *contact2)
+{
+ EABContactMatchType result;
+
+ g_return_val_if_fail (contact1 && E_IS_CONTACT (contact1), EAB_CONTACT_MATCH_NOT_APPLICABLE);
+ g_return_val_if_fail (contact2 && E_IS_CONTACT (contact2), EAB_CONTACT_MATCH_NOT_APPLICABLE);
+
+ result = EAB_CONTACT_MATCH_NONE;
+ result = combine_comparisons (result, eab_contact_compare_name (contact1, contact2));
+ result = combine_comparisons (result, eab_contact_compare_nickname (contact1, contact2));
+ result = combine_comparisons (result, eab_contact_compare_email (contact1, contact2));
+ result = combine_comparisons (result, eab_contact_compare_address (contact1, contact2));
+ result = combine_comparisons (result, eab_contact_compare_telephone (contact1, contact2));
+
+ return result;
+}
+
+typedef struct _MatchSearchInfo MatchSearchInfo;
+struct _MatchSearchInfo {
+ EContact *contact;
+ GList *avoid;
+ EABContactMatchQueryCallback cb;
+ gpointer closure;
+};
+
+static void
+match_search_info_free (MatchSearchInfo *info)
+{
+ if (info) {
+ g_object_unref (info->contact);
+
+ /* This should already have been deallocated, but just in case... */
+ if (info->avoid) {
+ g_list_foreach (info->avoid, (GFunc) g_object_unref, NULL);
+ g_list_free (info->avoid);
+ info->avoid = NULL;
+ }
+
+ g_free (info);
+ }
+}
+
+static void
+query_cb (EBook *book, EBookStatus status, GList *contacts, gpointer closure)
+{
+ /* XXX we need to free contacts */
+ MatchSearchInfo *info = (MatchSearchInfo *) closure;
+ EABContactMatchType best_match = EAB_CONTACT_MATCH_NONE;
+ EContact *best_contact = NULL;
+ GList *remaining_contacts = NULL;
+ const GList *i;
+
+ if (status != E_BOOK_ERROR_OK) {
+ info->cb (info->contact, NULL, EAB_CONTACT_MATCH_NONE, info->closure);
+ match_search_info_free (info);
+ return;
+ }
+
+ /* remove the contacts we're to avoid from the list, if they're present */
+ for (i = contacts; i != NULL; i = g_list_next (i)) {
+ EContact *this_contact = E_CONTACT (i->data);
+ GList *iterator;
+ gboolean avoid = FALSE;
+ for (iterator = info->avoid; iterator; iterator = iterator->next) {
+ if (!strcmp (e_contact_get_const (iterator->data, E_CONTACT_UID),
+ e_contact_get_const (this_contact, E_CONTACT_UID))) {
+ avoid = TRUE;
+ break;
+ }
+ }
+ if (!avoid)
+ remaining_contacts = g_list_prepend (remaining_contacts, this_contact);
+ }
+
+ remaining_contacts = g_list_reverse (remaining_contacts);
+
+ for (i = remaining_contacts; i != NULL; i = g_list_next (i)) {
+ EContact *this_contact = E_CONTACT (i->data);
+ EABContactMatchType this_match = eab_contact_compare (info->contact, this_contact);
+ if ((gint)this_match > (gint)best_match) {
+ best_match = this_match;
+ best_contact = this_contact;
+ }
+ }
+
+ g_list_free (remaining_contacts);
+
+ info->cb (info->contact, best_contact, best_match, info->closure);
+ match_search_info_free (info);
+}
+
+#define MAX_QUERY_PARTS 10
+static void
+use_common_book_cb (EBook *book, gpointer closure)
+{
+ MatchSearchInfo *info = (MatchSearchInfo *) closure;
+ EContact *contact = info->contact;
+ EContactName *contact_name;
+ GList *contact_email;
+ gchar *query_parts[MAX_QUERY_PARTS];
+ gint p=0;
+ gchar *query, *qj;
+ int i;
+
+ if (book == NULL) {
+ info->cb (info->contact, NULL, EAB_CONTACT_MATCH_NONE, info->closure);
+ match_search_info_free (info);
+ return;
+ }
+
+ contact_name = e_contact_get (contact, E_CONTACT_NAME);
+ if (contact_name) {
+ if (contact_name->given && *contact_name->given)
+ query_parts[p++] = g_strdup_printf ("(contains \"full_name\" \"%s\")", contact_name->given);
+
+ if (contact_name->additional && *contact_name->additional)
+ query_parts[p++] = g_strdup_printf ("(contains \"full_name\" \"%s\")", contact_name->additional);
+
+ if (contact_name->family && *contact_name->family)
+ query_parts[p++] = g_strdup_printf ("(contains \"full_name\" \"%s\")", contact_name->family);
+
+ e_contact_name_free (contact_name);
+ }
+
+ contact_email = e_contact_get (contact, E_CONTACT_EMAIL);
+ if (contact_email) {
+ GList *iter;
+ for (iter = contact_email; iter && p < MAX_QUERY_PARTS; iter = iter->next) {
+ gchar *addr = g_strdup (iter->data);
+ if (addr && *addr) {
+ gchar *s = addr;
+ while (*s) {
+ if (*s == '@') {
+ *s = '\0';
+ break;
+ }
+ ++s;
+ }
+ query_parts[p++] = g_strdup_printf ("(beginswith \"email\" \"%s\")", addr);
+ g_free (addr);
+ }
+ }
+ }
+ g_list_foreach (contact_email, (GFunc)g_free, NULL);
+ g_list_free (contact_email);
+
+
+ /* Build up our full query from the parts. */
+ query_parts[p] = NULL;
+ qj = g_strjoinv (" ", query_parts);
+ for(i = 0; query_parts[i] != NULL; i++)
+ g_free(query_parts[i]);
+ if (p > 0) {
+ query = g_strdup_printf ("(or %s)", qj);
+ g_free (qj);
+ } else {
+ query = qj;
+ }
+
+ if (query && *query)
+ e_book_async_get_contacts (book, query, query_cb, info);
+ else
+ query_cb (book, E_BOOK_ERROR_OK, NULL, info);
+
+ g_free (query);
+}
+
+void
+eab_contact_locate_match (EContact *contact, EABContactMatchQueryCallback cb, gpointer closure)
+{
+ MatchSearchInfo *info;
+
+ g_return_if_fail (contact && E_IS_CONTACT (contact));
+ g_return_if_fail (cb != NULL);
+
+ info = g_new (MatchSearchInfo, 1);
+ info->contact = contact;
+ g_object_ref (contact);
+ info->cb = cb;
+ info->closure = closure;
+ info->avoid = NULL;
+
+ addressbook_load_default_book (use_common_book_cb, info);
+}
+
+/**
+ * e_contact_locate_match_full:
+ * @book: The book to look in. If this is NULL, use the default
+ * addressbook.
+ * @contact: The contact to compare to.
+ * @avoid: A list of contacts to not match. These will not show up in the search.
+ * @cb: The function to call.
+ * @closure: The closure to add to the call.
+ *
+ * Look for the best match and return it using the EABContactMatchQueryCallback.
+ **/
+void
+eab_contact_locate_match_full (EBook *book, EContact *contact, GList *avoid, EABContactMatchQueryCallback cb, gpointer closure)
+{
+ MatchSearchInfo *info;
+
+ g_return_if_fail (contact && E_IS_CONTACT (contact));
+ g_return_if_fail (cb != NULL);
+
+ info = g_new (MatchSearchInfo, 1);
+ info->contact = contact;
+ g_object_ref (contact);
+ info->cb = cb;
+ info->closure = closure;
+ info->avoid = g_list_copy (avoid);
+ g_list_foreach (info->avoid, (GFunc) g_object_ref, NULL);
+
+ if (book)
+ use_common_book_cb (book, info);
+ else
+ addressbook_load_default_book (use_common_book_cb, info);
+}
+
diff --git a/addressbook/gui/merging/eab-contact-compare.h b/addressbook/gui/merging/eab-contact-compare.h
new file mode 100644
index 0000000000..07a9cd7e35
--- /dev/null
+++ b/addressbook/gui/merging/eab-contact-compare.h
@@ -0,0 +1,73 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ * eab-contact-compare.h
+ *
+ * Copyright (C) 2001,2002,2003 Ximian, Inc.
+ *
+ * Authors: Jon Trowbridge <trow@ximian.com>
+ * Chris Toshok <toshok@ximian.com>
+ */
+
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA.
+ */
+
+#ifndef __EAB_CONTACT_COMPARE_H__
+#define __EAB_CONTACT_COMPARE_H__
+
+#include "ebook/e-book.h"
+#include "ebook/e-contact.h"
+
+typedef enum {
+ EAB_CONTACT_MATCH_NOT_APPLICABLE = 0,
+ EAB_CONTACT_MATCH_NONE = 1,
+ EAB_CONTACT_MATCH_VAGUE = 2,
+ EAB_CONTACT_MATCH_PARTIAL = 3,
+ EAB_CONTACT_MATCH_EXACT = 4
+} EABContactMatchType;
+
+typedef enum {
+ EAB_CONTACT_MATCH_PART_NOT_APPLICABLE = -1,
+ EAB_CONTACT_MATCH_PART_NONE = 0,
+ EAB_CONTACT_MATCH_PART_GIVEN_NAME = 1<<0,
+ EAB_CONTACT_MATCH_PART_ADDITIONAL_NAME = 1<<2,
+ EAB_CONTACT_MATCH_PART_FAMILY_NAME = 1<<3
+} EABContactMatchPart;
+
+typedef void (*EABContactMatchQueryCallback) (EContact *contact, EContact *match, EABContactMatchType type, gpointer closure);
+
+EABContactMatchType eab_contact_compare_name_to_string (EContact *contact, const gchar *str);
+
+EABContactMatchType eab_contact_compare_name_to_string_full (EContact *contact, const gchar *str,
+ gboolean allow_partial_matches,
+ gint *matched_parts, EABContactMatchPart *first_matched_part,
+ gint *matched_character_count);
+
+EABContactMatchType eab_contact_compare_name (EContact *contact1, EContact *contact2);
+EABContactMatchType eab_contact_compare_nickname (EContact *contact1, EContact *contact2);
+EABContactMatchType eab_contact_compare_email (EContact *contact1, EContact *contact2);
+EABContactMatchType eab_contact_compare_address (EContact *contact1, EContact *contact2);
+EABContactMatchType eab_contact_compare_telephone (EContact *contact1, EContact *contact2);
+
+EABContactMatchType eab_contact_compare (EContact *contact1, EContact *contact2);
+
+void eab_contact_locate_match (EContact *contact, EABContactMatchQueryCallback cb, gpointer closure);
+void eab_contact_locate_match_full (EBook *book, EContact *contact, GList *avoid, EABContactMatchQueryCallback cb, gpointer closure);
+
+
+
+#endif /* __E_CONTACT_COMPARE_H__ */
+
diff --git a/addressbook/gui/merging/e-card-duplicate-detected.glade b/addressbook/gui/merging/eab-contact-duplicate-detected.glade
index 5c287cd163..c44547fb92 100644
--- a/addressbook/gui/merging/e-card-duplicate-detected.glade
+++ b/addressbook/gui/merging/eab-contact-duplicate-detected.glade
@@ -68,12 +68,12 @@
<property name="column_spacing">6</property>
<child>
- <widget class="Custom" id="custom-old-card">
+ <widget class="Custom" id="custom-old-contact">
<property name="visible">True</property>
- <property name="creation_function">e_card_merging_create_old_card</property>
+ <property name="creation_function">_eab_contact_merging_create_contact_display</property>
<property name="int1">0</property>
<property name="int2">0</property>
- <property name="last_modification_time">Fri, 08 Jun 2001 01:33:22 GMT</property>
+ <property name="last_modification_time">Sun, 05 Oct 2003 03:55:10 GMT</property>
</widget>
<packing>
<property name="left_attach">1</property>
@@ -155,12 +155,12 @@ in this folder. Would you like to add it anyway?</property>
</child>
<child>
- <widget class="Custom" id="custom-new-card">
+ <widget class="Custom" id="custom-new-contact">
<property name="visible">True</property>
- <property name="creation_function">e_card_merging_create_old_card</property>
+ <property name="creation_function">_eab_contact_merging_create_contact_display</property>
<property name="int1">0</property>
<property name="int2">0</property>
- <property name="last_modification_time">Fri, 08 Jun 2001 01:33:22 GMT</property>
+ <property name="last_modification_time">Sun, 05 Oct 2003 03:54:50 GMT</property>
</widget>
<packing>
<property name="left_attach">1</property>
diff --git a/addressbook/gui/merging/eab-contact-merging.c b/addressbook/gui/merging/eab-contact-merging.c
new file mode 100644
index 0000000000..38a3c188b2
--- /dev/null
+++ b/addressbook/gui/merging/eab-contact-merging.c
@@ -0,0 +1,197 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Code for checking for duplicates when doing EContact work.
+ *
+ * Authors:
+ * Christopher James Lahey <clahey@ximian.com>
+ * Chris Toshok <toshok@ximian.com>
+ *
+ * Copyright (C) 2001, 2002, 2003, Ximian, Inc.
+ */
+
+#include <config.h>
+
+#include "eab-contact-merging.h"
+#include "eab-contact-compare.h"
+#include <glade/glade.h>
+#include <gtk/gtksignal.h>
+#include "addressbook/gui/widgets/eab-contact-display.h"
+
+typedef enum {
+ E_CONTACT_MERGING_ADD,
+ E_CONTACT_MERGING_COMMIT
+} EContactMergingOpType;
+
+typedef struct {
+ EContactMergingOpType op;
+ EBook *book;
+ EContact *contact;
+ EBookIdCallback id_cb;
+ EBookCallback cb;
+ gpointer closure;
+} EContactMergingLookup;
+
+static void
+free_lookup (EContactMergingLookup *lookup)
+{
+ g_object_unref (lookup->book);
+ g_object_unref (lookup->contact);
+
+ g_free (lookup);
+}
+
+static void
+final_id_cb (EBook *book, EBookStatus status, const char *id, gpointer closure)
+{
+ EContactMergingLookup *lookup = closure;
+
+ if (lookup->id_cb)
+ lookup->id_cb (lookup->book, status, id, lookup->closure);
+
+ free_lookup (lookup);
+}
+
+static void
+final_cb (EBook *book, EBookStatus status, gpointer closure)
+{
+ EContactMergingLookup *lookup = closure;
+
+ if (lookup->cb)
+ lookup->cb (lookup->book, status, lookup->closure);
+
+ free_lookup (lookup);
+}
+
+static void
+doit (EContactMergingLookup *lookup)
+{
+ if (lookup->op == E_CONTACT_MERGING_ADD)
+ e_book_async_add_contact (lookup->book, lookup->contact, final_id_cb, lookup);
+ else if (lookup->op == E_CONTACT_MERGING_COMMIT)
+ e_book_async_commit_contact (lookup->book, lookup->contact, final_cb, lookup);
+}
+
+static void
+cancelit (EContactMergingLookup *lookup)
+{
+ if (lookup->op == E_CONTACT_MERGING_ADD) {
+ if (lookup->id_cb)
+ final_id_cb (lookup->book, E_BOOK_ERROR_CANCELLED, NULL, lookup);
+ } else if (lookup->op == E_CONTACT_MERGING_COMMIT) {
+ if (lookup->cb)
+ final_cb (lookup->book, E_BOOK_ERROR_CANCELLED, lookup);
+ }
+}
+
+static void
+response (GtkWidget *dialog, int response, EContactMergingLookup *lookup)
+{
+ gtk_widget_destroy (dialog);
+
+ switch (response) {
+ case 0:
+ doit (lookup);
+ break;
+ case 1:
+ cancelit (lookup);
+ break;
+ }
+}
+
+static void
+match_query_callback (EContact *contact, EContact *match, EABContactMatchType type, gpointer closure)
+{
+ EContactMergingLookup *lookup = closure;
+
+ if ((gint) type <= (gint) EAB_CONTACT_MATCH_VAGUE) {
+ doit (lookup);
+ } else {
+ GladeXML *ui;
+
+ GtkWidget *widget;
+
+ if (lookup->op == E_CONTACT_MERGING_ADD)
+ ui = glade_xml_new (EVOLUTION_GLADEDIR "/eab-contact-duplicate-detected.glade", NULL, NULL);
+ else if (lookup->op == E_CONTACT_MERGING_COMMIT)
+ ui = glade_xml_new (EVOLUTION_GLADEDIR "/eab-contact-merging-commit-duplicate-detected.glade", NULL, NULL);
+ else {
+ doit (lookup);
+ return;
+ }
+
+ widget = glade_xml_get_widget (ui, "custom-old-contact");
+ eab_contact_display_render (EAB_CONTACT_DISPLAY (widget),
+ match, EAB_CONTACT_DISPLAY_RENDER_COMPACT);
+
+ widget = glade_xml_get_widget (ui, "custom-new-contact");
+ eab_contact_display_render (EAB_CONTACT_DISPLAY (widget),
+ contact, EAB_CONTACT_DISPLAY_RENDER_COMPACT);
+
+ widget = glade_xml_get_widget (ui, "dialog-duplicate-contact");
+
+ g_signal_connect (widget, "response",
+ G_CALLBACK (response), lookup);
+
+ gtk_widget_show_all (widget);
+ }
+}
+
+gboolean
+eab_merging_book_add_contact (EBook *book,
+ EContact *contact,
+ EBookIdCallback cb,
+ gpointer closure)
+{
+ EContactMergingLookup *lookup;
+
+ lookup = g_new (EContactMergingLookup, 1);
+
+ lookup->op = E_CONTACT_MERGING_ADD;
+ lookup->book = g_object_ref (book);
+ lookup->contact = g_object_ref (contact);
+ lookup->id_cb = cb;
+ lookup->closure = closure;
+
+ eab_contact_locate_match_full (book, contact, NULL, match_query_callback, lookup);
+
+ return TRUE;
+}
+
+gboolean
+eab_merging_book_commit_contact (EBook *book,
+ EContact *contact,
+ EBookCallback cb,
+ gpointer closure)
+{
+ EContactMergingLookup *lookup;
+ GList *avoid;
+
+ lookup = g_new (EContactMergingLookup, 1);
+
+ lookup->op = E_CONTACT_MERGING_COMMIT;
+ lookup->book = g_object_ref (book);
+ lookup->contact = g_object_ref (contact);
+ lookup->cb = cb;
+ lookup->closure = closure;
+
+ avoid = g_list_append (NULL, contact);
+
+ eab_contact_locate_match_full (book, contact, avoid, match_query_callback, lookup);
+
+ g_list_free (avoid);
+
+ return TRUE;
+}
+
+GtkWidget *
+_eab_contact_merging_create_contact_display(gchar *name,
+ gchar *string1, gchar *string2,
+ gint int1, gint int2);
+
+GtkWidget *
+_eab_contact_merging_create_contact_display(gchar *name,
+ gchar *string1, gchar *string2,
+ gint int1, gint int2)
+{
+ return eab_contact_display_new();
+}
diff --git a/addressbook/gui/merging/eab-contact-merging.h b/addressbook/gui/merging/eab-contact-merging.h
new file mode 100644
index 0000000000..6011263f31
--- /dev/null
+++ b/addressbook/gui/merging/eab-contact-merging.h
@@ -0,0 +1,30 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * The Evolution addressbook client object.
+ *
+ * Authors:
+ * Christopher James Lahey <clahey@ximian.com>
+ * Chris Toshok <toshok@ximian.com>
+ *
+ * Copyright (C) 2001, 2002, 2003 Ximian, Inc.
+ */
+
+#ifndef __E_CONTACT_MERGING_H__
+#define __E_CONTACT_MERGING_H__
+
+#include <addressbook/backend/ebook/e-book-async.h>
+
+G_BEGIN_DECLS
+
+gboolean eab_merging_book_add_contact (EBook *book,
+ EContact *contact,
+ EBookIdCallback cb,
+ gpointer closure);
+gboolean eab_merging_book_commit_contact (EBook *book,
+ EContact *contact,
+ EBookCallback cb,
+ gpointer closure);
+
+G_END_DECLS
+
+#endif /* ! __EAB_CONTACT_MERGING_H__ */
diff --git a/addressbook/gui/search/e-addressbook-search-dialog.c b/addressbook/gui/search/e-addressbook-search-dialog.c
index eefd170a73..a8621bf5a7 100644
--- a/addressbook/gui/search/e-addressbook-search-dialog.c
+++ b/addressbook/gui/search/e-addressbook-search-dialog.c
@@ -30,23 +30,23 @@
#include "e-addressbook-search-dialog.h"
-static void e_addressbook_search_dialog_init (EAddressbookSearchDialog *widget);
-static void e_addressbook_search_dialog_class_init (EAddressbookSearchDialogClass *klass);
-static void e_addressbook_search_dialog_dispose (GObject *object);
+static void eab_search_dialog_init (EABSearchDialog *widget);
+static void eab_search_dialog_class_init (EABSearchDialogClass *klass);
+static void eab_search_dialog_dispose (GObject *object);
static GtkDialog *parent_class = NULL;
#define PARENT_TYPE GTK_TYPE_DIALOG
-E_MAKE_TYPE (e_addressbook_search_dialog,
- "EAddressbookSearchDialog",
- EAddressbookSearchDialog,
- e_addressbook_search_dialog_class_init,
- e_addressbook_search_dialog_init,
+E_MAKE_TYPE (eab_search_dialog,
+ "EABSearchDialog",
+ EABSearchDialog,
+ eab_search_dialog_class_init,
+ eab_search_dialog_init,
PARENT_TYPE)
static void
-e_addressbook_search_dialog_class_init (EAddressbookSearchDialogClass *klass)
+eab_search_dialog_class_init (EABSearchDialogClass *klass)
{
GObjectClass *object_class;
@@ -54,11 +54,11 @@ e_addressbook_search_dialog_class_init (EAddressbookSearchDialogClass *klass)
parent_class = g_type_class_ref (PARENT_TYPE);
- object_class->dispose = e_addressbook_search_dialog_dispose;
+ object_class->dispose = eab_search_dialog_dispose;
}
static GtkWidget *
-get_widget (EAddressbookSearchDialog *view)
+get_widget (EABSearchDialog *view)
{
FilterPart *part;
@@ -79,7 +79,7 @@ get_widget (EAddressbookSearchDialog *view)
}
static char *
-get_query (EAddressbookSearchDialog *view)
+get_query (EABSearchDialog *view)
{
GString *out = g_string_new("");
char *ret;
@@ -92,7 +92,7 @@ get_query (EAddressbookSearchDialog *view)
}
static void
-dialog_response (GtkWidget *widget, int response_id, EAddressbookSearchDialog *dialog)
+dialog_response (GtkWidget *widget, int response_id, EABSearchDialog *dialog)
{
char *query;
@@ -108,7 +108,7 @@ dialog_response (GtkWidget *widget, int response_id, EAddressbookSearchDialog *d
}
static void
-e_addressbook_search_dialog_init (EAddressbookSearchDialog *view)
+eab_search_dialog_init (EABSearchDialog *view)
{
GtkDialog *dialog = GTK_DIALOG (view);
@@ -131,19 +131,19 @@ e_addressbook_search_dialog_init (EAddressbookSearchDialog *view)
}
GtkWidget *
-e_addressbook_search_dialog_new (EAddressbookView *addr_view)
+eab_search_dialog_new (EABView *addr_view)
{
- EAddressbookSearchDialog *view = g_object_new (E_ADDRESSBOOK_SEARCH_DIALOG_TYPE, NULL);
+ EABSearchDialog *view = g_object_new (EAB_SEARCH_DIALOG_TYPE, NULL);
view->view = addr_view;
return GTK_WIDGET(view);
}
static void
-e_addressbook_search_dialog_dispose (GObject *object)
+eab_search_dialog_dispose (GObject *object)
{
- EAddressbookSearchDialog *view;
+ EABSearchDialog *view;
- view = E_ADDRESSBOOK_SEARCH_DIALOG (object);
+ view = EAB_SEARCH_DIALOG (object);
if (view->context) {
g_object_unref(view->context);
diff --git a/addressbook/gui/search/e-addressbook-search-dialog.h b/addressbook/gui/search/e-addressbook-search-dialog.h
index 4be0050ca0..ef501766ea 100644
--- a/addressbook/gui/search/e-addressbook-search-dialog.h
+++ b/addressbook/gui/search/e-addressbook-search-dialog.h
@@ -17,8 +17,9 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
-#ifndef __E_ADDRESSBOOK_SEARCH_DIALOG_H__
-#define __E_ADDRESSBOOK_SEARCH_DIALOG_H__
+
+#ifndef __EAB_SEARCH_DIALOG_H__
+#define __EAB_SEARCH_DIALOG_H__
#include <ebook/e-book.h>
@@ -29,37 +30,37 @@
G_BEGIN_DECLS
-#define E_ADDRESSBOOK_SEARCH_DIALOG_TYPE (e_addressbook_search_dialog_get_type ())
-#define E_ADDRESSBOOK_SEARCH_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_ADDRESSBOOK_SEARCH_DIALOG_TYPE, EAddressbookSearchDialog))
-#define E_ADDRESSBOOK_SEARCH_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_ADDRESSBOOK_SEARCH_DIALOG_TYPE, EAddressbookSearchDialogClass))
-#define E_IS_ADDRESSBOOK_SEARCH_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_ADDRESSBOOK_SEARCH_DIALOG_TYPE))
-#define E_IS_ADDRESSBOOK_SEARCH_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_ADDRESSBOOK_SEARCH_DIALOG_TYPE))
+#define EAB_SEARCH_DIALOG_TYPE (eab_search_dialog_get_type ())
+#define EAB_SEARCH_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EAB_SEARCH_DIALOG_TYPE, EABSearchDialog))
+#define EAB_SEARCH_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EAB_SEARCH_DIALOG_TYPE, EABSearchDialogClass))
+#define E_IS_ADDRESSBOOK_SEARCH_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EAB_SEARCH_DIALOG_TYPE))
+#define E_IS_ADDRESSBOOK_SEARCH_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), EAB_SEARCH_DIALOG_TYPE))
-typedef struct _EAddressbookSearchDialog EAddressbookSearchDialog;
-typedef struct _EAddressbookSearchDialogClass EAddressbookSearchDialogClass;
+typedef struct _EABSearchDialog EABSearchDialog;
+typedef struct _EABSearchDialogClass EABSearchDialogClass;
-struct _EAddressbookSearchDialog
+struct _EABSearchDialog
{
GtkDialog parent;
GtkWidget *search;
- EAddressbookView *view;
+ EABView *view;
RuleContext *context;
FilterRule *rule;
};
-struct _EAddressbookSearchDialogClass
+struct _EABSearchDialogClass
{
GtkDialogClass parent_class;
};
-GType e_addressbook_search_dialog_get_type (void);
+GType eab_search_dialog_get_type (void);
-GtkWidget *e_addressbook_search_dialog_new (EAddressbookView *view);
+GtkWidget *eab_search_dialog_new (EABView *view);
G_END_DECLS
-#endif /* __E_ADDRESSBOOK_SEARCH_DIALOG_H__ */
+#endif /* __EAB_SEARCH_DIALOG_H__ */
diff --git a/addressbook/gui/widgets/.cvsignore b/addressbook/gui/widgets/.cvsignore
index d3b9ac4305..b67f65e6c3 100644
--- a/addressbook/gui/widgets/.cvsignore
+++ b/addressbook/gui/widgets/.cvsignore
@@ -10,8 +10,8 @@ minicard-test
minicard-view-test
minicard-widget-test
reflow-test
-e-addressbook-marshal.c
-e-addressbook-marshal.h
+eab-marshal.c
+eab-marshal.h
Evolution-Composer-stubs.c
Evolution-Composer-skels.c
Evolution-Composer-common.c
diff --git a/addressbook/gui/widgets/Makefile.am b/addressbook/gui/widgets/Makefile.am
index 2185d10764..ce441cbafb 100644
--- a/addressbook/gui/widgets/Makefile.am
+++ b/addressbook/gui/widgets/Makefile.am
@@ -1,9 +1,10 @@
INCLUDES = \
- -DG_LOG_DOMAIN=\"e-minicard\" \
+ -DG_LOG_DOMAIN=\"eab-widgets\" \
-DEVOLUTION_ETSPECDIR=\""$(etspecdir)"\" \
-DEVOLUTION_IMAGESDIR=\""$(imagesdir)"\" \
-DEVOLUTION_GALVIEWSDIR=\""$(viewsdir)"\" \
-I$(top_srcdir) \
+ -I$(top_srcdir)/addressbook \
-I$(top_srcdir)/addressbook/backend \
-I$(top_builddir)/addressbook/backend \
-I$(top_srcdir)/addressbook/gui/contact-editor \
@@ -35,37 +36,39 @@ CORBA_SOURCE_C = $(CORBA_COMPOSER_SOURCE_C)
CORBA_SOURCE = $(CORBA_SOURCE_H) $(CORBA_SOURCE_C)
noinst_LTLIBRARIES = \
- libeminicard.la
+ libeabwidgets.la
-libeminicard_la_SOURCES = \
+libeabwidgets_la_SOURCES = \
$(CORBA_SOURCE) \
- e-addressbook-marshal.c \
+ eab-contact-display.c \
+ eab-contact-display.h \
+ eab-gui-util.c \
+ eab-gui-util.h \
+ eab-popup-control.c \
+ eab-popup-control.h \
+ eab-vcard-control.c \
+ eab-vcard-control.h \
+ eab-marshal.c \
+ e-minicard.c \
+ e-minicard.h \
+ e-minicard-label.c \
+ e-minicard-label.h \
+ e-minicard-view.c \
+ e-minicard-view.h \
+ e-minicard-view-widget.c \
+ e-minicard-view-widget.h \
e-addressbook-reflow-adapter.c \
e-addressbook-reflow-adapter.h \
e-addressbook-table-adapter.c \
e-addressbook-table-adapter.h \
e-addressbook-model.c \
e-addressbook-model.h \
- e-addressbook-util.c \
- e-addressbook-util.h \
e-addressbook-view.c \
e-addressbook-view.h \
- e-minicard-control.c \
- e-minicard-control.h \
- e-minicard-label.c \
- e-minicard-label.h \
- e-minicard-view-widget.c \
- e-minicard-view-widget.h \
- e-minicard-view.c \
- e-minicard-view.h \
- e-minicard-widget.c \
- e-minicard-widget.h \
- e-minicard.c \
- e-minicard.h \
- gal-view-factory-minicard.c \
- gal-view-factory-minicard.h \
gal-view-minicard.c \
- gal-view-minicard.h
+ gal-view-minicard.h \
+ gal-view-factory-minicard.c \
+ gal-view-factory-minicard.h
#TREEVIEW_SOURCES= e-addressbook-treeview-adapter.c \
# e-addressbook-treeview-adapter.h \
@@ -74,7 +77,7 @@ libeminicard_la_SOURCES = \
# gal-view-treeview.c \
# gal-view-treeview.h
-MARSHAL_GENERATED = e-addressbook-marshal.c e-addressbook-marshal.h
+MARSHAL_GENERATED = eab-marshal.c eab-marshal.h
@EVO_MARSHAL_RULE@
BUILT_SOURCES = $(CORBA_SOURCE) $(MARSHAL_GENERATED)
@@ -83,74 +86,8 @@ CLEANFILES = $(BUILT_SOURCES)
dist-hook:
cd $(distdir); rm -f $(BUILT_SOURCES)
-#noinst_PROGRAMS = \
-# minicard-widget-test \
-# minicard-label-test \
-# minicard-test
-## reflow-test
-## minicard-view-test
-#
-#minicard_label_test_SOURCES = \
-# test-minicard-label.c
-#
-#minicard_label_test_LDADD = \
-# libeminicard.a \
-# $(EVOLUTION_ADDRESSBOOK_LIBS) \
-# $(top_builddir)/e-util/libeutil.la
-#
-#minicard_test_SOURCES = \
-# test-minicard.c
-#
-#minicard_test_LDADD = \
-# libeminicard.a \
-# $(top_builddir)/addressbook/backend/ebook/libebook.la \
-# $(top_builddir)/addressbook/gui/contact-editor/libecontacteditor.a \
-# $(top_builddir)/addressbook/gui/contact-list-editor/libecontactlisteditor.a \
-# $(top_builddir)/addressbook/printing/libecontactprint.a \
-# $(top_builddir)/addressbook/gui/merging/libecardmerging.a \
-# $(top_builddir)/widgets/misc/libemiscwidgets.la \
-# $(top_builddir)/addressbook/gui/component/select-names/libeselectnames.la \
-# $(EVOLUTION_ADDRESSBOOK_LIBS) \
-# libeminicard.a
-#
-#reflow_test_SOURCES = \
-# test-reflow.c
-#
-#reflow_test_LDADD = \
-# libeminicard.a \
-# $(top_builddir)/addressbook/backend/ebook/libebook.la \
-# $(top_builddir)/addressbook/contact-editor/libecontacteditor.a \
-# $(top_builddir)/addressbook/printing/libecontactprint.a \
-# $(top_builddir)/widgets/misc/libemiscwidgets.la \
-# $(EVOLUTION_ADDRESSBOOK_LIBS)
-
-#minicard_view_test_SOURCES = \
-# test-minicard-view.c
-
-#minicard_view_test_LDADD = \
-# $(EVOLUTION_ADDRESSBOOK_LIBS)
-# libeminicard.a \
-# $(top_builddir)/addressbook/backend/ebook/libebook.la \
-# $(top_builddir)/addressbook/contact-editor/libecontacteditor.a \
-# $(top_builddir)/addressbook/printing/libecontactprint.a \
-# $(top_builddir)/widgets/misc/libemiscwidgets.la
-#
-#minicard_widget_test_SOURCES = \
-# e-minicard-widget-test.c
-#
-#minicard_widget_test_LDADD = \
-# libeminicard.a \
-# $(top_builddir)/addressbook/backend/ebook/libebook.la \
-# $(top_builddir)/addressbook/gui/contact-editor/libecontacteditor.a \
-# $(top_builddir)/addressbook/gui/contact-list-editor/libecontactlisteditor.a \
-# $(top_builddir)/addressbook/gui/component/select-names/libeselectnames.la \
-# $(top_builddir)/addressbook/printing/libecontactprint.a \
-# $(top_builddir)/widgets/misc/libemiscwidgets.la \
-# $(top_builddir)/addressbook/gui/merging/libecardmerging.a \
-# $(EVOLUTION_ADDRESSBOOK_LIBS)
-
etspec_DATA= e-addressbook-view.etspec
EXTRA_DIST = \
$(etspec_DATA) \
- e-addressbook-marshal.list
+ eab-marshal.list
diff --git a/addressbook/gui/widgets/e-addressbook-model.c b/addressbook/gui/widgets/e-addressbook-model.c
index 10af915ecf..e8a1e76a38 100644
--- a/addressbook/gui/widgets/e-addressbook-model.c
+++ b/addressbook/gui/widgets/e-addressbook-model.c
@@ -8,25 +8,24 @@
*/
#include <config.h>
-#include "e-addressbook-marshal.h"
+#include "eab-marshal.h"
#include "e-addressbook-model.h"
#include <libxml/tree.h>
#include <libxml/parser.h>
#include <libxml/xmlmemory.h>
#include <gnome.h>
#include <gal/widgets/e-gui-utils.h>
-#include "e-addressbook-util.h"
-#include "e-addressbook-marshal.h"
+#include "eab-gui-util.h"
#define PARENT_TYPE G_TYPE_OBJECT
static GObjectClass *parent_class;
/*
- * EAddressbookModel callbacks
+ * EABModel callbacks
* These are the callbacks that define the behavior of our custom model.
*/
-static void e_addressbook_model_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void e_addressbook_model_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
+static void eab_model_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
+static void eab_model_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
enum {
@@ -42,21 +41,19 @@ enum {
SEARCH_STARTED,
SEARCH_RESULT,
FOLDER_BAR_MESSAGE,
- CARD_ADDED,
- CARD_REMOVED,
- CARD_CHANGED,
+ CONTACT_ADDED,
+ CONTACT_REMOVED,
+ CONTACT_CHANGED,
MODEL_CHANGED,
STOP_STATE_CHANGED,
BACKEND_DIED,
LAST_SIGNAL
};
-#define COLS (E_CARD_SIMPLE_FIELD_LAST)
-
-static guint e_addressbook_model_signals [LAST_SIGNAL] = {0, };
+static guint eab_model_signals [LAST_SIGNAL] = {0, };
static void
-free_data (EAddressbookModel *model)
+free_data (EABModel *model)
{
if (model->data) {
int i;
@@ -73,17 +70,17 @@ free_data (EAddressbookModel *model)
}
static void
-remove_book_view(EAddressbookModel *model)
+remove_book_view(EABModel *model)
{
- if (model->book_view && model->create_card_id)
+ if (model->book_view && model->create_contact_id)
g_signal_handler_disconnect (model->book_view,
- model->create_card_id);
- if (model->book_view && model->remove_card_id)
+ model->create_contact_id);
+ if (model->book_view && model->remove_contact_id)
g_signal_handler_disconnect (model->book_view,
- model->remove_card_id);
- if (model->book_view && model->modify_card_id)
+ model->remove_contact_id);
+ if (model->book_view && model->modify_contact_id)
g_signal_handler_disconnect (model->book_view,
- model->modify_card_id);
+ model->modify_contact_id);
if (model->book_view && model->status_message_id)
g_signal_handler_disconnect (model->book_view,
model->status_message_id);
@@ -91,9 +88,9 @@ remove_book_view(EAddressbookModel *model)
g_signal_handler_disconnect (model->book_view,
model->sequence_complete_id);
- model->create_card_id = 0;
- model->remove_card_id = 0;
- model->modify_card_id = 0;
+ model->create_contact_id = 0;
+ model->remove_contact_id = 0;
+ model->modify_contact_id = 0;
model->status_message_id = 0;
model->sequence_complete_id = 0;
@@ -109,12 +106,7 @@ remove_book_view(EAddressbookModel *model)
static void
addressbook_dispose(GObject *object)
{
- EAddressbookModel *model = E_ADDRESSBOOK_MODEL(object);
-
- if (model->get_view_idle) {
- g_source_remove(model->get_view_idle);
- model->get_view_idle = 0;
- }
+ EABModel *model = EAB_MODEL(object);
remove_book_view(model);
free_data (model);
@@ -135,7 +127,7 @@ addressbook_dispose(GObject *object)
}
if (model->query) {
- g_free (model->query);
+ e_book_query_unref (model->query);
model->query = NULL;
}
@@ -144,7 +136,7 @@ addressbook_dispose(GObject *object)
}
static void
-update_folder_bar_message (EAddressbookModel *model)
+update_folder_bar_message (EABModel *model)
{
int count;
char *message;
@@ -153,67 +145,68 @@ update_folder_bar_message (EAddressbookModel *model)
switch (count) {
case 0:
- message = g_strdup (_("No cards"));
+ message = g_strdup (_("No contacts"));
break;
case 1:
- message = g_strdup (_("1 card"));
+ message = g_strdup (_("1 contact"));
break;
default:
- message = g_strdup_printf (_("%d cards"), count);
+ message = g_strdup_printf (_("%d contacts"), count);
break;
}
g_signal_emit (model,
- e_addressbook_model_signals [FOLDER_BAR_MESSAGE], 0,
+ eab_model_signals [FOLDER_BAR_MESSAGE], 0,
message);
g_free (message);
}
static void
-create_card(EBookView *book_view,
- const GList *cards,
- EAddressbookModel *model)
+create_contact(EBookView *book_view,
+ const GList *contacts,
+ EABModel *model)
{
int old_count = model->data_count;
- int length = g_list_length ((GList *)cards);
+ int length = g_list_length ((GList *)contacts);
if (model->data_count + length > model->allocated_count) {
while (model->data_count + length > model->allocated_count)
model->allocated_count = model->allocated_count * 2 + 1;
- model->data = g_renew(ECard *, model->data, model->allocated_count);
+ model->data = g_renew(EContact *, model->data, model->allocated_count);
}
- for ( ; cards; cards = cards->next) {
- model->data[model->data_count++] = cards->data;
- g_object_ref (cards->data);
+ for ( ; contacts; contacts = contacts->next) {
+ model->data[model->data_count++] = contacts->data;
+ g_object_ref (contacts->data);
}
g_signal_emit (model,
- e_addressbook_model_signals [CARD_ADDED], 0,
+ eab_model_signals [CONTACT_ADDED], 0,
old_count, model->data_count - old_count);
update_folder_bar_message (model);
}
static void
-remove_card(EBookView *book_view,
- GList *ids,
- EAddressbookModel *model)
+remove_contact(EBookView *book_view,
+ GList *ids,
+ EABModel *model)
{
+ /* XXX we should keep a hash around instead of this O(n*m) loop */
int i = 0;
GList *l;
for (l = ids; l; l = l->next) {
char *id = l->data;
for ( i = 0; i < model->data_count; i++) {
- if ( !strcmp(e_card_get_id(model->data[i]), id) ) {
+ if ( !strcmp(e_contact_get_const (model->data[i], E_CONTACT_UID), id) ) {
g_object_unref (model->data[i]);
- memmove(model->data + i, model->data + i + 1, (model->data_count - i - 1) * sizeof (ECard *));
+ memmove(model->data + i, model->data + i + 1, (model->data_count - i - 1) * sizeof (EContact *));
model->data_count--;
g_signal_emit (model,
- e_addressbook_model_signals [CARD_REMOVED], 0,
+ eab_model_signals [CONTACT_REMOVED], 0,
i);
break;
@@ -225,18 +218,19 @@ remove_card(EBookView *book_view,
}
static void
-modify_card(EBookView *book_view,
- const GList *cards,
- EAddressbookModel *model)
+modify_contact(EBookView *book_view,
+ const GList *contacts,
+ EABModel *model)
{
- for ( ; cards; cards = cards->next) {
+ for ( ; contacts; contacts = contacts->next) {
int i;
for ( i = 0; i < model->data_count; i++) {
- if ( !strcmp(e_card_get_id(model->data[i]), e_card_get_id(E_CARD(cards->data))) ) {
+ if ( !strcmp(e_contact_get_const(model->data[i], E_CONTACT_UID),
+ e_contact_get_const(E_CONTACT(contacts->data), E_CONTACT_UID)) ) {
g_object_unref (model->data[i]);
- model->data[i] = e_card_duplicate(E_CARD(cards->data));
+ model->data[i] = e_contact_duplicate(E_CONTACT(contacts->data));
g_signal_emit (model,
- e_addressbook_model_signals [CARD_CHANGED], 0,
+ eab_model_signals [CONTACT_CHANGED], 0,
i);
break;
}
@@ -247,57 +241,57 @@ modify_card(EBookView *book_view,
static void
status_message (EBookView *book_view,
char* status,
- EAddressbookModel *model)
+ EABModel *model)
{
g_signal_emit (model,
- e_addressbook_model_signals [STATUS_MESSAGE], 0,
+ eab_model_signals [STATUS_MESSAGE], 0,
status);
}
static void
sequence_complete (EBookView *book_view,
EBookViewStatus status,
- EAddressbookModel *model)
+ EABModel *model)
{
model->search_in_progress = FALSE;
status_message (book_view, NULL, model);
g_signal_emit (model,
- e_addressbook_model_signals [SEARCH_RESULT], 0,
+ eab_model_signals [SEARCH_RESULT], 0,
status);
g_signal_emit (model,
- e_addressbook_model_signals [STOP_STATE_CHANGED], 0);
+ eab_model_signals [STOP_STATE_CHANGED], 0);
}
static void
writable_status (EBook *book,
gboolean writable,
- EAddressbookModel *model)
+ EABModel *model)
{
if (!model->editable_set) {
model->editable = writable;
g_signal_emit (model,
- e_addressbook_model_signals [WRITABLE_STATUS], 0,
+ eab_model_signals [WRITABLE_STATUS], 0,
writable);
}
}
static void
backend_died (EBook *book,
- EAddressbookModel *model)
+ EABModel *model)
{
g_signal_emit (model,
- e_addressbook_model_signals [BACKEND_DIED], 0);
+ eab_model_signals [BACKEND_DIED], 0);
}
static void
-e_addressbook_model_class_init (GObjectClass *object_class)
+eab_model_class_init (GObjectClass *object_class)
{
parent_class = g_type_class_ref (PARENT_TYPE);
object_class->dispose = addressbook_dispose;
- object_class->set_property = e_addressbook_model_set_property;
- object_class->get_property = e_addressbook_model_get_property;
+ object_class->set_property = eab_model_set_property;
+ object_class->get_property = eab_model_get_property;
g_object_class_install_property (object_class, PROP_BOOK,
g_param_spec_object ("book",
@@ -320,119 +314,118 @@ e_addressbook_model_class_init (GObjectClass *object_class)
FALSE,
G_PARAM_READWRITE));
- e_addressbook_model_signals [WRITABLE_STATUS] =
+ eab_model_signals [WRITABLE_STATUS] =
g_signal_new ("writable_status",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EAddressbookModelClass, writable_status),
+ G_STRUCT_OFFSET (EABModelClass, writable_status),
NULL, NULL,
- e_addressbook_marshal_NONE__BOOL,
+ eab_marshal_NONE__BOOL,
G_TYPE_NONE,
1, G_TYPE_BOOLEAN);
- e_addressbook_model_signals [STATUS_MESSAGE] =
+ eab_model_signals [STATUS_MESSAGE] =
g_signal_new ("status_message",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EAddressbookModelClass, status_message),
+ G_STRUCT_OFFSET (EABModelClass, status_message),
NULL, NULL,
- e_addressbook_marshal_NONE__POINTER,
+ eab_marshal_NONE__POINTER,
G_TYPE_NONE,
1, G_TYPE_POINTER);
- e_addressbook_model_signals [SEARCH_STARTED] =
+ eab_model_signals [SEARCH_STARTED] =
g_signal_new ("search_started",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EAddressbookModelClass, search_started),
+ G_STRUCT_OFFSET (EABModelClass, search_started),
NULL, NULL,
- e_addressbook_marshal_NONE__NONE,
+ eab_marshal_NONE__NONE,
G_TYPE_NONE, 0);
- e_addressbook_model_signals [SEARCH_RESULT] =
+ eab_model_signals [SEARCH_RESULT] =
g_signal_new ("search_result",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EAddressbookModelClass, search_result),
+ G_STRUCT_OFFSET (EABModelClass, search_result),
NULL, NULL,
- e_addressbook_marshal_NONE__INT,
+ eab_marshal_NONE__INT,
G_TYPE_NONE, 1, G_TYPE_INT);
- e_addressbook_model_signals [FOLDER_BAR_MESSAGE] =
+ eab_model_signals [FOLDER_BAR_MESSAGE] =
g_signal_new ("folder_bar_message",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EAddressbookModelClass, folder_bar_message),
+ G_STRUCT_OFFSET (EABModelClass, folder_bar_message),
NULL, NULL,
- e_addressbook_marshal_NONE__POINTER,
+ eab_marshal_NONE__POINTER,
G_TYPE_NONE, 1, G_TYPE_POINTER);
- e_addressbook_model_signals [CARD_ADDED] =
- g_signal_new ("card_added",
+ eab_model_signals [CONTACT_ADDED] =
+ g_signal_new ("contact_added",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EAddressbookModelClass, card_added),
+ G_STRUCT_OFFSET (EABModelClass, contact_added),
NULL, NULL,
- e_addressbook_marshal_NONE__INT_INT,
+ eab_marshal_NONE__INT_INT,
G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT);
- e_addressbook_model_signals [CARD_REMOVED] =
- g_signal_new ("card_removed",
+ eab_model_signals [CONTACT_REMOVED] =
+ g_signal_new ("contact_removed",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EAddressbookModelClass, card_removed),
+ G_STRUCT_OFFSET (EABModelClass, contact_removed),
NULL, NULL,
- e_addressbook_marshal_NONE__INT,
+ eab_marshal_NONE__INT,
G_TYPE_NONE, 1, G_TYPE_INT);
- e_addressbook_model_signals [CARD_CHANGED] =
- g_signal_new ("card_changed",
+ eab_model_signals [CONTACT_CHANGED] =
+ g_signal_new ("contact_changed",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EAddressbookModelClass, card_changed),
+ G_STRUCT_OFFSET (EABModelClass, contact_changed),
NULL, NULL,
- e_addressbook_marshal_NONE__INT,
+ eab_marshal_NONE__INT,
G_TYPE_NONE, 1, G_TYPE_INT);
- e_addressbook_model_signals [MODEL_CHANGED] =
+ eab_model_signals [MODEL_CHANGED] =
g_signal_new ("model_changed",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EAddressbookModelClass, model_changed),
+ G_STRUCT_OFFSET (EABModelClass, model_changed),
NULL, NULL,
- e_addressbook_marshal_NONE__NONE,
+ eab_marshal_NONE__NONE,
G_TYPE_NONE, 0);
- e_addressbook_model_signals [STOP_STATE_CHANGED] =
+ eab_model_signals [STOP_STATE_CHANGED] =
g_signal_new ("stop_state_changed",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EAddressbookModelClass, stop_state_changed),
+ G_STRUCT_OFFSET (EABModelClass, stop_state_changed),
NULL, NULL,
- e_addressbook_marshal_NONE__NONE,
+ eab_marshal_NONE__NONE,
G_TYPE_NONE, 0);
- e_addressbook_model_signals [BACKEND_DIED] =
+ eab_model_signals [BACKEND_DIED] =
g_signal_new ("backend_died",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EAddressbookModelClass, backend_died),
+ G_STRUCT_OFFSET (EABModelClass, backend_died),
NULL, NULL,
- e_addressbook_marshal_NONE__NONE,
+ eab_marshal_NONE__NONE,
G_TYPE_NONE, 0);
}
static void
-e_addressbook_model_init (GObject *object)
+eab_model_init (GObject *object)
{
- EAddressbookModel *model = E_ADDRESSBOOK_MODEL(object);
+ EABModel *model = EAB_MODEL(object);
model->book = NULL;
- model->query = g_strdup("(contains \"x-evolution-any-field\" \"\")");
+ model->query = e_book_query_any_field_contains ("");
model->book_view = NULL;
- model->get_view_idle = 0;
- model->create_card_id = 0;
- model->remove_card_id = 0;
- model->modify_card_id = 0;
+ model->create_contact_id = 0;
+ model->remove_contact_id = 0;
+ model->modify_contact_id = 0;
model->status_message_id = 0;
model->writable_status_id = 0;
model->backend_died_id = 0;
@@ -449,30 +442,28 @@ e_addressbook_model_init (GObject *object)
static void
book_view_loaded (EBook *book, EBookStatus status, EBookView *book_view, gpointer closure)
{
- EAddressbookModel *model = closure;
+ EABModel *model = closure;
- remove_book_view(model);
-
- if (status != E_BOOK_STATUS_SUCCESS) {
- e_addressbook_error_dialog (_("Error getting book view"), status);
+ if (status != E_BOOK_ERROR_OK) {
+ eab_error_dialog (_("Error getting book view"), status);
return;
}
model->book_view = book_view;
if (model->book_view)
g_object_ref (model->book_view);
- model->create_card_id = g_signal_connect(model->book_view,
- "card_added",
- G_CALLBACK (create_card),
- model);
- model->remove_card_id = g_signal_connect(model->book_view,
- "card_removed",
- G_CALLBACK (remove_card),
- model);
- model->modify_card_id = g_signal_connect(model->book_view,
- "card_changed",
- G_CALLBACK(modify_card),
- model);
+ model->create_contact_id = g_signal_connect(model->book_view,
+ "contacts_added",
+ G_CALLBACK (create_contact),
+ model);
+ model->remove_contact_id = g_signal_connect(model->book_view,
+ "contacts_removed",
+ G_CALLBACK (remove_contact),
+ model);
+ model->modify_contact_id = g_signal_connect(model->book_view,
+ "contacts_changed",
+ G_CALLBACK(modify_contact),
+ model);
model->status_message_id = g_signal_connect(model->book_view,
"status_message",
G_CALLBACK(status_message),
@@ -482,70 +473,65 @@ book_view_loaded (EBook *book, EBookStatus status, EBookView *book_view, gpointe
G_CALLBACK(sequence_complete),
model);
- free_data (model);
-
model->search_in_progress = TRUE;
g_signal_emit (model,
- e_addressbook_model_signals [MODEL_CHANGED], 0);
+ eab_model_signals [MODEL_CHANGED], 0);
g_signal_emit (model,
- e_addressbook_model_signals [SEARCH_STARTED], 0);
+ eab_model_signals [SEARCH_STARTED], 0);
g_signal_emit (model,
- e_addressbook_model_signals [STOP_STATE_CHANGED], 0);
+ eab_model_signals [STOP_STATE_CHANGED], 0);
+
+ e_book_view_start (model->book_view);
}
-static gboolean
-get_view (EAddressbookModel *model)
+static void
+get_view (EABModel *model)
{
+ gboolean success;
+
if (model->book && model->query) {
+ char *query_string = e_book_query_to_string (model->query);
+
+ remove_book_view(model);
+ free_data (model);
+
if (model->first_get_view) {
+ model->first_get_view = FALSE;
+
if (e_book_check_static_capability (model->book, "do-initial-query")) {
- e_book_get_book_view (model->book, model->query, book_view_loaded, model);
+ success = e_book_async_get_book_view (model->book, query_string, book_view_loaded, model);
} else {
- remove_book_view(model);
- free_data (model);
g_signal_emit (model,
- e_addressbook_model_signals [MODEL_CHANGED], 0);
+ eab_model_signals [MODEL_CHANGED], 0);
g_signal_emit (model,
- e_addressbook_model_signals [STOP_STATE_CHANGED], 0);
+ eab_model_signals [STOP_STATE_CHANGED], 0);
+ g_free (query_string);
+ return;
}
- model->first_get_view = FALSE;
}
else
- e_book_get_book_view (model->book, model->query, book_view_loaded, model);
- }
+ success = e_book_async_get_book_view (model->book, query_string, book_view_loaded, model);
- model->get_view_idle = 0;
- return FALSE;
-}
-
-ECard *
-e_addressbook_model_get_card(EAddressbookModel *model,
- int row)
-{
- if (model->data && 0 <= row && row < model->data_count) {
- ECard *card;
- card = e_card_duplicate (model->data[row]);
- return card;
+ g_free (query_string);
}
- return NULL;
}
-const ECard *
-e_addressbook_model_peek_card(EAddressbookModel *model,
- int row)
+EContact *
+eab_model_get_contact(EABModel *model,
+ int row)
{
if (model->data && 0 <= row && row < model->data_count) {
- return model->data[row];
+ return e_contact_duplicate (model->data[row]);
}
return NULL;
}
static void
-e_addressbook_model_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+eab_model_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
{
- EAddressbookModel *model;
+ EABModel *model;
- model = E_ADDRESSBOOK_MODEL (object);
+ model = EAB_MODEL (object);
switch (prop_id){
case PROP_BOOK:
@@ -564,10 +550,11 @@ e_addressbook_model_set_property (GObject *object, guint prop_id, const GValue *
}
model->book = E_BOOK(g_value_get_object (value));
if (model->book) {
+ if (!model->editable_set)
+ model->editable = e_book_is_writable (model->book);
model->first_get_view = TRUE;
g_object_ref (model->book);
- if (model->get_view_idle == 0)
- model->get_view_idle = g_idle_add((GSourceFunc)get_view, model);
+ get_view (model);
g_signal_connect (model->book,
"writable_status",
G_CALLBACK (writable_status), model);
@@ -578,10 +565,9 @@ e_addressbook_model_set_property (GObject *object, guint prop_id, const GValue *
break;
case PROP_QUERY:
if (model->query)
- g_free(model->query);
- model->query = g_strdup(g_value_get_string (value));
- if (model->get_view_idle == 0)
- model->get_view_idle = g_idle_add((GSourceFunc)get_view, model);
+ e_book_query_unref (model->query);
+ model->query = e_book_query_from_string (g_value_get_string (value));
+ get_view (model);
break;
case PROP_EDITABLE:
model->editable = g_value_get_boolean (value);
@@ -594,21 +580,23 @@ e_addressbook_model_set_property (GObject *object, guint prop_id, const GValue *
}
static void
-e_addressbook_model_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+eab_model_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
{
- EAddressbookModel *e_addressbook_model;
+ EABModel *eab_model;
- e_addressbook_model = E_ADDRESSBOOK_MODEL (object);
+ eab_model = EAB_MODEL (object);
switch (prop_id) {
case PROP_BOOK:
- g_value_set_object (value, e_addressbook_model->book);
+ g_value_set_object (value, eab_model->book);
break;
- case PROP_QUERY:
- g_value_set_string (value, g_strdup(e_addressbook_model->query));
+ case PROP_QUERY: {
+ char *query_string = e_book_query_to_string (eab_model->query);
+ g_value_set_string (value, query_string);
break;
+ }
case PROP_EDITABLE:
- g_value_set_boolean (value, e_addressbook_model->editable);
+ g_value_set_boolean (value, eab_model->editable);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -617,81 +605,81 @@ e_addressbook_model_get_property (GObject *object, guint prop_id, GValue *value,
}
GType
-e_addressbook_model_get_type (void)
+eab_model_get_type (void)
{
static GType type = 0;
if (!type) {
static const GTypeInfo info = {
- sizeof (EAddressbookModelClass),
+ sizeof (EABModelClass),
NULL, /* base_init */
NULL, /* base_finalize */
- (GClassInitFunc) e_addressbook_model_class_init,
+ (GClassInitFunc) eab_model_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
- sizeof (EAddressbookModel),
+ sizeof (EABModel),
0, /* n_preallocs */
- (GInstanceInitFunc) e_addressbook_model_init,
+ (GInstanceInitFunc) eab_model_init,
};
- type = g_type_register_static (PARENT_TYPE, "EAddressbookModel", &info, 0);
+ type = g_type_register_static (PARENT_TYPE, "EABModel", &info, 0);
}
return type;
}
-EAddressbookModel*
-e_addressbook_model_new (void)
+EABModel*
+eab_model_new (void)
{
- EAddressbookModel *et;
+ EABModel *et;
- et = g_object_new (E_TYPE_ADDRESSBOOK_MODEL, NULL);
+ et = g_object_new (EAB_TYPE_MODEL, NULL);
return et;
}
-void e_addressbook_model_stop (EAddressbookModel *model)
+void eab_model_stop (EABModel *model)
{
remove_book_view(model);
g_signal_emit (model,
- e_addressbook_model_signals [STOP_STATE_CHANGED], 0);
+ eab_model_signals [STOP_STATE_CHANGED], 0);
g_signal_emit (model,
- e_addressbook_model_signals [STATUS_MESSAGE], 0,
+ eab_model_signals [STATUS_MESSAGE], 0,
"Search Interrupted.");
}
gboolean
-e_addressbook_model_can_stop (EAddressbookModel *model)
+eab_model_can_stop (EABModel *model)
{
return model->search_in_progress;
}
void
-e_addressbook_model_force_folder_bar_message (EAddressbookModel *model)
+eab_model_force_folder_bar_message (EABModel *model)
{
update_folder_bar_message (model);
}
int
-e_addressbook_model_card_count (EAddressbookModel *model)
+eab_model_contact_count (EABModel *model)
{
return model->data_count;
}
-ECard *
-e_addressbook_model_card_at (EAddressbookModel *model, int index)
+const EContact *
+eab_model_contact_at (EABModel *model, int index)
{
return model->data[index];
}
gboolean
-e_addressbook_model_editable (EAddressbookModel *model)
+eab_model_editable (EABModel *model)
{
return model->editable;
}
EBook *
-e_addressbook_model_get_ebook (EAddressbookModel *model)
+eab_model_get_ebook (EABModel *model)
{
return model->book;
}
diff --git a/addressbook/gui/widgets/e-addressbook-model.h b/addressbook/gui/widgets/e-addressbook-model.h
index 57cfe6f729..35f9d0e87f 100644
--- a/addressbook/gui/widgets/e-addressbook-model.h
+++ b/addressbook/gui/widgets/e-addressbook-model.h
@@ -1,37 +1,34 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-#ifndef _E_ADDRESSBOOK_MODEL_H_
-#define _E_ADDRESSBOOK_MODEL_H_
+#ifndef _EAB_MODEL_H_
+#define _EAB_MODEL_H_
#include <glib.h>
#include <glib-object.h>
-#include "addressbook/backend/ebook/e-book.h"
+#include "addressbook/backend/ebook/e-book-async.h"
#include "addressbook/backend/ebook/e-book-view.h"
-#include "addressbook/backend/ebook/e-card-simple.h"
-#define E_TYPE_ADDRESSBOOK_MODEL (e_addressbook_model_get_type ())
-#define E_ADDRESSBOOK_MODEL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), E_TYPE_ADDRESSBOOK_MODEL, EAddressbookModel))
-#define E_ADDRESSBOOK_MODEL_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), E_TYPE_ADDRESSBOOK_MODEL, EAddressbookModelClass))
-#define E_IS_ADDRESSBOOK_MODEL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_TYPE_ADDRESSBOOK_MODEL))
-#define E_IS_ADDRESSBOOK_MODEL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), E_TYPE_ADDRESSBOOK_MODEL))
+#define EAB_TYPE_MODEL (eab_model_get_type ())
+#define EAB_MODEL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EAB_TYPE_MODEL, EABModel))
+#define EAB_MODEL_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EAB_TYPE_MODEL, EABModelClass))
+#define E_IS_ADDRESSBOOK_MODEL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EAB_TYPE_MODEL))
+#define E_IS_ADDRESSBOOK_MODEL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EAB_TYPE_MODEL))
-typedef struct _EAddressbookModel EAddressbookModel;
-typedef struct _EAddressbookModelClass EAddressbookModelClass;
+typedef struct _EABModel EABModel;
+typedef struct _EABModelClass EABModelClass;
-struct _EAddressbookModel {
+struct _EABModel {
GObject parent;
/* item specific fields */
EBook *book;
- char *query;
+ EBookQuery *query;
EBookView *book_view;
- int get_view_idle;
-
- ECard **data;
+ EContact **data;
int data_count;
int allocated_count;
- int create_card_id, remove_card_id, modify_card_id;
+ int create_contact_id, remove_contact_id, modify_contact_id;
int status_message_id, writable_status_id, sequence_complete_id;
int backend_died_id;
@@ -42,44 +39,42 @@ struct _EAddressbookModel {
};
-struct _EAddressbookModelClass {
+struct _EABModelClass {
GObjectClass parent_class;
/*
* Signals
*/
- void (*writable_status) (EAddressbookModel *model, gboolean writable);
- void (*search_started) (EAddressbookModel *model);
- void (*search_result) (EAddressbookModel *model, EBookViewStatus status);
- void (*status_message) (EAddressbookModel *model, const gchar *message);
- void (*folder_bar_message) (EAddressbookModel *model, const gchar *message);
- void (*card_added) (EAddressbookModel *model, gint index, gint count);
- void (*card_removed) (EAddressbookModel *model, gint index);
- void (*card_changed) (EAddressbookModel *model, gint index);
- void (*model_changed) (EAddressbookModel *model);
- void (*stop_state_changed) (EAddressbookModel *model);
- void (*backend_died) (EAddressbookModel *model);
+ void (*writable_status) (EABModel *model, gboolean writable);
+ void (*search_started) (EABModel *model);
+ void (*search_result) (EABModel *model, EBookViewStatus status);
+ void (*status_message) (EABModel *model, const gchar *message);
+ void (*folder_bar_message) (EABModel *model, const gchar *message);
+ void (*contact_added) (EABModel *model, gint index, gint count);
+ void (*contact_removed) (EABModel *model, gint index);
+ void (*contact_changed) (EABModel *model, gint index);
+ void (*model_changed) (EABModel *model);
+ void (*stop_state_changed) (EABModel *model);
+ void (*backend_died) (EABModel *model);
};
-GType e_addressbook_model_get_type (void);
-EAddressbookModel *e_addressbook_model_new (void);
+GType eab_model_get_type (void);
+EABModel *eab_model_new (void);
/* Returns object with ref count of 1. */
-ECard *e_addressbook_model_get_card (EAddressbookModel *model,
- int row);
-const ECard *e_addressbook_model_peek_card (EAddressbookModel *model,
- int row);
-EBook *e_addressbook_model_get_ebook (EAddressbookModel *model);
+EContact *eab_model_get_contact (EABModel *model,
+ int row);
+EBook *eab_model_get_ebook (EABModel *model);
-void e_addressbook_model_stop (EAddressbookModel *model);
-gboolean e_addressbook_model_can_stop (EAddressbookModel *model);
+void eab_model_stop (EABModel *model);
+gboolean eab_model_can_stop (EABModel *model);
-void e_addressbook_model_force_folder_bar_message (EAddressbookModel *model);
+void eab_model_force_folder_bar_message (EABModel *model);
-int e_addressbook_model_card_count (EAddressbookModel *model);
-ECard *e_addressbook_model_card_at (EAddressbookModel *model,
- int index);
-gboolean e_addressbook_model_editable (EAddressbookModel *model);
+int eab_model_contact_count (EABModel *model);
+const EContact *eab_model_contact_at (EABModel *model,
+ int index);
+gboolean eab_model_editable (EABModel *model);
-#endif /* _E_ADDRESSBOOK_MODEL_H_ */
+#endif /* _EAB_MODEL_H_ */
diff --git a/addressbook/gui/widgets/e-addressbook-reflow-adapter.c b/addressbook/gui/widgets/e-addressbook-reflow-adapter.c
index a4cb9364b5..cf1667fec5 100644
--- a/addressbook/gui/widgets/e-addressbook-reflow-adapter.c
+++ b/addressbook/gui/widgets/e-addressbook-reflow-adapter.c
@@ -5,26 +5,25 @@
#include <string.h>
#include <libgnome/gnome-i18n.h>
-#include "e-addressbook-marshal.h"
+#include "eab-marshal.h"
#include "e-addressbook-reflow-adapter.h"
#include "e-addressbook-model.h"
#include "e-addressbook-view.h"
-#include "e-addressbook-util.h"
+#include "eab-gui-util.h"
#include "e-minicard.h"
#include <gal/widgets/e-popup-menu.h>
#include <gal/widgets/e-gui-utils.h>
-#include "e-contact-save-as.h"
#include "addressbook/printing/e-contact-print.h"
#include "addressbook/printing/e-contact-print-envelope.h"
struct _EAddressbookReflowAdapterPrivate {
- EAddressbookModel *model;
+ EABModel *model;
gboolean loading;
- int create_card_id, remove_card_id, modify_card_id, model_changed_id;
+ int create_contact_id, remove_contact_id, modify_contact_id, model_changed_id;
int search_started_id, search_result_id;
};
@@ -53,15 +52,15 @@ unlink_model(EAddressbookReflowAdapter *adapter)
{
EAddressbookReflowAdapterPrivate *priv = adapter->priv;
- if (priv->model && priv->create_card_id)
+ if (priv->model && priv->create_contact_id)
g_signal_handler_disconnect (priv->model,
- priv->create_card_id);
- if (priv->model && priv->remove_card_id)
+ priv->create_contact_id);
+ if (priv->model && priv->remove_contact_id)
g_signal_handler_disconnect (priv->model,
- priv->remove_card_id);
- if (priv->model && priv->modify_card_id)
+ priv->remove_contact_id);
+ if (priv->model && priv->modify_contact_id)
g_signal_handler_disconnect (priv->model,
- priv->modify_card_id);
+ priv->modify_contact_id);
if (priv->model && priv->model_changed_id)
g_signal_handler_disconnect (priv->model,
priv->model_changed_id);
@@ -72,9 +71,9 @@ unlink_model(EAddressbookReflowAdapter *adapter)
g_signal_handler_disconnect (priv->model,
priv->search_result_id);
- priv->create_card_id = 0;
- priv->remove_card_id = 0;
- priv->modify_card_id = 0;
+ priv->create_contact_id = 0;
+ priv->remove_contact_id = 0;
+ priv->modify_contact_id = 0;
priv->model_changed_id = 0;
priv->search_started_id = 0;
priv->search_result_id = 0;
@@ -104,20 +103,6 @@ addressbook_dispose(GObject *object)
EAddressbookReflowAdapter *adapter = E_ADDRESSBOOK_REFLOW_ADAPTER(object);
unlink_model (adapter);
-
- if (G_OBJECT_CLASS (parent_class)->dispose)
- (* G_OBJECT_CLASS (parent_class)->dispose) (object);
-}
-
-static void
-addressbook_finalize(GObject *object)
-{
- EAddressbookReflowAdapter *adapter = E_ADDRESSBOOK_REFLOW_ADAPTER(object);
-
- g_free (adapter->priv);
-
- if (G_OBJECT_CLASS (parent_class)->finalize)
- (* G_OBJECT_CLASS (parent_class)->finalize) (object);
}
static void
@@ -132,37 +117,37 @@ addressbook_count (EReflowModel *erm)
EAddressbookReflowAdapter *adapter = E_ADDRESSBOOK_REFLOW_ADAPTER(erm);
EAddressbookReflowAdapterPrivate *priv = adapter->priv;
- return e_addressbook_model_card_count (priv->model);
+ return eab_model_contact_count (priv->model);
}
-/* This function returns the height of the minicard in question */
+/* This function returns the height of the minicontact in question */
static int
addressbook_height (EReflowModel *erm, int i, GnomeCanvasGroup *parent)
{
EAddressbookReflowAdapter *adapter = E_ADDRESSBOOK_REFLOW_ADAPTER(erm);
EAddressbookReflowAdapterPrivate *priv = adapter->priv;
- ECardSimpleField field;
+ EContactField field;
int count = 0;
char *string;
- ECardSimple *simple = e_card_simple_new (e_addressbook_model_card_at (priv->model, i));
+ EContact *contact = (EContact*)eab_model_contact_at (priv->model, i);
PangoLayout *layout = gtk_widget_create_pango_layout (GTK_WIDGET (GNOME_CANVAS_ITEM (parent)->canvas), "");
int height;
- string = e_card_simple_get(simple, E_CARD_SIMPLE_FIELD_FILE_AS);
+ string = e_contact_get(contact, E_CONTACT_FILE_AS);
height = text_height (layout, string ? string : "") + 10.0;
g_free(string);
- for(field = E_CARD_SIMPLE_FIELD_FULL_NAME; field != E_CARD_SIMPLE_FIELD_LAST_SIMPLE_STRING && count < 5; field++) {
+ for(field = E_CONTACT_FULL_NAME; field != E_CONTACT_LAST_SIMPLE_STRING && count < 5; field++) {
- if (field == E_CARD_SIMPLE_FIELD_FAMILY_NAME)
+ if (field == E_CONTACT_FAMILY_NAME || field == E_CONTACT_GIVEN_NAME)
continue;
- string = e_card_simple_get(simple, field);
+ string = e_contact_get(contact, field);
if (string && *string) {
int this_height;
int field_text_height;
- this_height = text_height (layout, e_card_simple_get_name(simple, field));
+ this_height = text_height (layout, e_contact_pretty_name(field));
field_text_height = text_height (layout, string);
if (this_height < field_text_height)
@@ -177,7 +162,6 @@ addressbook_height (EReflowModel *erm, int i, GnomeCanvasGroup *parent)
}
height += 2;
- g_object_unref (simple);
g_object_unref (layout);
return height;
@@ -188,30 +172,31 @@ addressbook_compare (EReflowModel *erm, int n1, int n2)
{
EAddressbookReflowAdapter *adapter = E_ADDRESSBOOK_REFLOW_ADAPTER(erm);
EAddressbookReflowAdapterPrivate *priv = adapter->priv;
- ECard *card1, *card2;
+ EContact *contact1, *contact2;
if (priv->loading) {
return n1-n2;
}
else {
- card1 = e_addressbook_model_card_at (priv->model, n1);
- card2 = e_addressbook_model_card_at (priv->model, n2);
+ contact1 = (EContact*)eab_model_contact_at (priv->model, n1);
+ contact2 = (EContact*)eab_model_contact_at (priv->model, n2);
- if (card1 && card2) {
- char *file_as1, *file_as2;
- file_as1 = card1->file_as;
- file_as2 = card2->file_as;
+ if (contact1 && contact2) {
+ const char *file_as1, *file_as2;
+ file_as1 = e_contact_get_const (contact1, E_CONTACT_FILE_AS);
+ file_as2 = e_contact_get_const (contact2, E_CONTACT_FILE_AS);
if (file_as1 && file_as2)
return g_utf8_collate(file_as1, file_as2);
if (file_as1)
return -1;
if (file_as2)
return 1;
- return strcmp(e_card_get_id(card1), e_card_get_id(card2));
+ return strcmp(e_contact_get_const (contact1, E_CONTACT_UID),
+ e_contact_get_const (contact2, E_CONTACT_UID));
}
- if (card1)
+ if (contact1)
return -1;
- if (card2)
+ if (contact2)
return 1;
return 0;
}
@@ -238,8 +223,8 @@ addressbook_incarnate (EReflowModel *erm, int i, GnomeCanvasGroup *parent)
item = gnome_canvas_item_new(parent,
e_minicard_get_type(),
- "card", e_addressbook_model_card_at (priv->model, i),
- "editable", e_addressbook_model_editable (priv->model),
+ "contact", eab_model_contact_at (priv->model, i),
+ "editable", eab_model_editable (priv->model),
NULL);
#if 0
@@ -260,14 +245,14 @@ addressbook_reincarnate (EReflowModel *erm, int i, GnomeCanvasItem *item)
EAddressbookReflowAdapterPrivate *priv = adapter->priv;
gnome_canvas_item_set(item,
- "card", e_addressbook_model_card_at (priv->model, i),
+ "contact", eab_model_contact_at (priv->model, i),
NULL);
}
static void
-create_card (EAddressbookModel *model,
- gint index, gint count,
- EAddressbookReflowAdapter *adapter)
+create_contact (EABModel *model,
+ gint index, gint count,
+ EAddressbookReflowAdapter *adapter)
{
e_reflow_model_items_inserted (E_REFLOW_MODEL (adapter),
index,
@@ -275,30 +260,30 @@ create_card (EAddressbookModel *model,
}
static void
-remove_card (EAddressbookModel *model,
- gint index,
- EAddressbookReflowAdapter *adapter)
+remove_contact (EABModel *model,
+ gint index,
+ EAddressbookReflowAdapter *adapter)
{
e_reflow_model_item_removed (E_REFLOW_MODEL (adapter), index);
}
static void
-modify_card (EAddressbookModel *model,
- gint index,
- EAddressbookReflowAdapter *adapter)
+modify_contact (EABModel *model,
+ gint index,
+ EAddressbookReflowAdapter *adapter)
{
e_reflow_model_item_changed (E_REFLOW_MODEL (adapter), index);
}
static void
-model_changed (EAddressbookModel *model,
+model_changed (EABModel *model,
EAddressbookReflowAdapter *adapter)
{
e_reflow_model_changed (E_REFLOW_MODEL (adapter));
}
static void
-search_started (EAddressbookModel *model,
+search_started (EABModel *model,
EAddressbookReflowAdapter *adapter)
{
EAddressbookReflowAdapterPrivate *priv = adapter->priv;
@@ -307,7 +292,7 @@ search_started (EAddressbookModel *model,
}
static void
-search_result (EAddressbookModel *model,
+search_result (EABModel *model,
EBookViewStatus status,
EAddressbookReflowAdapter *adapter)
{
@@ -387,7 +372,6 @@ e_addressbook_reflow_adapter_class_init (GObjectClass *object_class)
object_class->set_property = addressbook_set_property;
object_class->get_property = addressbook_get_property;
object_class->dispose = addressbook_dispose;
- object_class->finalize = addressbook_finalize;
g_object_class_install_property (object_class, PROP_BOOK,
g_param_spec_object ("book",
@@ -414,7 +398,7 @@ e_addressbook_reflow_adapter_class_init (GObjectClass *object_class)
g_param_spec_object ("model",
_("Model"),
/*_( */"XXX blurb" /*)*/,
- E_TYPE_ADDRESSBOOK_MODEL,
+ EAB_TYPE_MODEL,
G_PARAM_READABLE));
e_addressbook_reflow_adapter_signals [DRAG_BEGIN] =
@@ -423,7 +407,7 @@ e_addressbook_reflow_adapter_class_init (GObjectClass *object_class)
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (EAddressbookReflowAdapterClass, drag_begin),
NULL, NULL,
- e_addressbook_marshal_INT__POINTER,
+ eab_marshal_INT__POINTER,
G_TYPE_INT, 1, G_TYPE_POINTER);
model_class->set_width = addressbook_set_width;
@@ -443,9 +427,9 @@ e_addressbook_reflow_adapter_init (GtkObject *object)
priv = adapter->priv = g_new0 (EAddressbookReflowAdapterPrivate, 1);
priv->loading = FALSE;
- priv->create_card_id = 0;
- priv->remove_card_id = 0;
- priv->modify_card_id = 0;
+ priv->create_contact_id = 0;
+ priv->remove_contact_id = 0;
+ priv->modify_contact_id = 0;
priv->model_changed_id = 0;
priv->search_started_id = 0;
priv->search_result_id = 0;
@@ -477,24 +461,24 @@ e_addressbook_reflow_adapter_get_type (void)
void
e_addressbook_reflow_adapter_construct (EAddressbookReflowAdapter *adapter,
- EAddressbookModel *model)
+ EABModel *model)
{
EAddressbookReflowAdapterPrivate *priv = adapter->priv;
priv->model = model;
g_object_ref (priv->model);
- priv->create_card_id = g_signal_connect(priv->model,
- "card_added",
- G_CALLBACK(create_card),
+ priv->create_contact_id = g_signal_connect(priv->model,
+ "contact_added",
+ G_CALLBACK(create_contact),
adapter);
- priv->remove_card_id = g_signal_connect(priv->model,
- "card_removed",
- G_CALLBACK(remove_card),
+ priv->remove_contact_id = g_signal_connect(priv->model,
+ "contact_removed",
+ G_CALLBACK(remove_contact),
adapter);
- priv->modify_card_id = g_signal_connect(priv->model,
- "card_changed",
- G_CALLBACK(modify_card),
+ priv->modify_contact_id = g_signal_connect(priv->model,
+ "contact_changed",
+ G_CALLBACK(modify_contact),
adapter);
priv->model_changed_id = g_signal_connect(priv->model,
"model_changed",
@@ -511,7 +495,7 @@ e_addressbook_reflow_adapter_construct (EAddressbookReflowAdapter *adapter,
}
EReflowModel *
-e_addressbook_reflow_adapter_new (EAddressbookModel *model)
+e_addressbook_reflow_adapter_new (EABModel *model)
{
EAddressbookReflowAdapter *et;
@@ -523,11 +507,11 @@ e_addressbook_reflow_adapter_new (EAddressbookModel *model)
}
-ECard *
-e_addressbook_reflow_adapter_get_card (EAddressbookReflowAdapter *adapter,
- int index)
+EContact *
+e_addressbook_reflow_adapter_get_contact (EAddressbookReflowAdapter *adapter,
+ int index)
{
EAddressbookReflowAdapterPrivate *priv = adapter->priv;
- return e_addressbook_model_get_card (priv->model, index);
+ return eab_model_get_contact (priv->model, index);
}
diff --git a/addressbook/gui/widgets/e-addressbook-reflow-adapter.h b/addressbook/gui/widgets/e-addressbook-reflow-adapter.h
index 4bf131bc5c..9ba7d2cf2d 100644
--- a/addressbook/gui/widgets/e-addressbook-reflow-adapter.h
+++ b/addressbook/gui/widgets/e-addressbook-reflow-adapter.h
@@ -3,11 +3,8 @@
#define _E_ADDRESSBOOK_REFLOW_ADAPTER_H_
#include <gal/widgets/e-reflow-model.h>
-#include <gal/widgets/e-selection-model.h>
#include "e-addressbook-model.h"
-#include "addressbook/backend/ebook/e-book.h"
-#include "addressbook/backend/ebook/e-book-view.h"
-#include "addressbook/backend/ebook/e-card.h"
+#include "addressbook/backend/ebook/e-contact.h"
#define E_TYPE_ADDRESSBOOK_REFLOW_ADAPTER (e_addressbook_reflow_adapter_get_type ())
#define E_ADDRESSBOOK_REFLOW_ADAPTER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), E_TYPE_ADDRESSBOOK_REFLOW_ADAPTER, EAddressbookReflowAdapter))
@@ -38,10 +35,10 @@ struct _EAddressbookReflowAdapterClass {
GType e_addressbook_reflow_adapter_get_type (void);
void e_addressbook_reflow_adapter_construct (EAddressbookReflowAdapter *adapter,
- EAddressbookModel *model);
-EReflowModel *e_addressbook_reflow_adapter_new (EAddressbookModel *model);
+ EABModel *model);
+EReflowModel *e_addressbook_reflow_adapter_new (EABModel *model);
/* Returns object with ref count of 1. */
-ECard *e_addressbook_reflow_adapter_get_card (EAddressbookReflowAdapter *adapter,
+EContact *e_addressbook_reflow_adapter_get_contact (EAddressbookReflowAdapter *adapter,
int index);
#endif /* _E_ADDRESSBOOK_REFLOW_ADAPTER_H_ */
diff --git a/addressbook/gui/widgets/e-addressbook-table-adapter.c b/addressbook/gui/widgets/e-addressbook-table-adapter.c
index 6a9e06da54..eb01b9b079 100644
--- a/addressbook/gui/widgets/e-addressbook-table-adapter.c
+++ b/addressbook/gui/widgets/e-addressbook-table-adapter.c
@@ -3,87 +3,52 @@
#include <config.h>
#include "e-addressbook-model.h"
#include "e-addressbook-table-adapter.h"
-#include "e-card-merging.h"
-#include "e-addressbook-util.h"
-#include "ebook/e-destination.h"
+#include "eab-gui-util.h"
+#include "util/eab-destination.h"
#include <libxml/tree.h>
#include <libxml/parser.h>
#include <libxml/xmlmemory.h>
#include <gnome.h>
struct _EAddressbookTableAdapterPrivate {
- EAddressbookModel *model;
+ EABModel *model;
- ECardSimple **simples;
- int count;
-
- int create_card_id, remove_card_id, modify_card_id, model_changed_id;
+ int create_contact_id, remove_contact_id, modify_contact_id, model_changed_id;
};
#define PARENT_TYPE e_table_model_get_type()
static ETableModelClass *parent_class;
-#define COLS (E_CARD_SIMPLE_FIELD_LAST)
+#define COLS (E_CONTACT_FIELD_LAST)
static void
unlink_model(EAddressbookTableAdapter *adapter)
{
EAddressbookTableAdapterPrivate *priv = adapter->priv;
- int i;
g_signal_handler_disconnect (priv->model,
- priv->create_card_id);
+ priv->create_contact_id);
g_signal_handler_disconnect (priv->model,
- priv->remove_card_id);
+ priv->remove_contact_id);
g_signal_handler_disconnect (priv->model,
- priv->modify_card_id);
+ priv->modify_contact_id);
g_signal_handler_disconnect (priv->model,
priv->model_changed_id);
- priv->create_card_id = 0;
- priv->remove_card_id = 0;
- priv->modify_card_id = 0;
+ priv->create_contact_id = 0;
+ priv->remove_contact_id = 0;
+ priv->modify_contact_id = 0;
priv->model_changed_id = 0;
- /* free up the existing mapping if there is one */
- if (priv->simples) {
- for (i = 0; i < priv->count; i ++)
- g_object_unref (priv->simples[i]);
- g_free (priv->simples);
- priv->simples = NULL;
- }
-
g_object_unref (priv->model);
priv->model = NULL;
}
static void
-build_simple_mapping(EAddressbookTableAdapter *adapter)
-{
- EAddressbookTableAdapterPrivate *priv = adapter->priv;
- int i;
-
- /* free up the existing mapping if there is one */
- if (priv->simples) {
- for (i = 0; i < priv->count; i ++)
- g_object_unref (priv->simples[i]);
- g_free (priv->simples);
- }
-
- /* build up our mapping to ECardSimple*'s */
- priv->count = e_addressbook_model_card_count (priv->model);
- priv->simples = g_new (ECardSimple*, priv->count);
- for (i = 0; i < priv->count; i ++) {
- priv->simples[i] = e_card_simple_new (e_addressbook_model_card_at (priv->model, i));
- g_object_ref (priv->simples[i]);
- }
-}
-
-static void
addressbook_dispose(GObject *object)
{
- EAddressbookTableAdapter *adapter = E_ADDRESSBOOK_TABLE_ADAPTER(object);
+ EAddressbookTableAdapter *adapter = EAB_TABLE_ADAPTER(object);
if (adapter->priv) {
unlink_model(adapter);
@@ -107,30 +72,30 @@ addressbook_col_count (ETableModel *etc)
static int
addressbook_row_count (ETableModel *etc)
{
- EAddressbookTableAdapter *adapter = E_ADDRESSBOOK_TABLE_ADAPTER(etc);
+ EAddressbookTableAdapter *adapter = EAB_TABLE_ADAPTER(etc);
EAddressbookTableAdapterPrivate *priv = adapter->priv;
- return e_addressbook_model_card_count (priv->model);
+ return eab_model_contact_count (priv->model);
}
/* This function returns the value at a particular point in our ETableModel. */
static void *
addressbook_value_at (ETableModel *etc, int col, int row)
{
- EAddressbookTableAdapter *adapter = E_ADDRESSBOOK_TABLE_ADAPTER(etc);
+ EAddressbookTableAdapter *adapter = EAB_TABLE_ADAPTER(etc);
EAddressbookTableAdapterPrivate *priv = adapter->priv;
const char *value;
- if ( col >= COLS || row >= e_addressbook_model_card_count (priv->model) )
+ if ( col >= COLS || row >= eab_model_contact_count (priv->model) )
return NULL;
- value = e_card_simple_get_const(priv->simples[row], col);
+ value = e_contact_get_const((EContact*)eab_model_contact_at (priv->model, row), col);
if (value && !strncmp (value, "<?xml", 5)) {
- EDestination *dest = e_destination_import (value);
+ EABDestination *dest = eab_destination_import (value);
if (dest) {
/* XXX blech, we leak this */
- value = g_strdup (e_destination_get_textrep (dest, TRUE));
+ value = g_strdup (eab_destination_get_textrep (dest, TRUE));
g_object_unref (dest);
}
}
@@ -140,22 +105,26 @@ addressbook_value_at (ETableModel *etc, int col, int row)
}
/* This function sets the value at a particular point in our ETableModel. */
+#if 0
static void
card_modified_cb (EBook* book, EBookStatus status,
gpointer user_data)
{
- if (status != E_BOOK_STATUS_SUCCESS)
- e_addressbook_error_dialog (_("Error modifying card"), status);
+ if (status != E_BOOK_ERROR_OK)
+ eab_error_dialog (_("Error modifying card"), status);
}
+#endif
+
static void
addressbook_set_value_at (ETableModel *etc, int col, int row, const void *val)
{
- EAddressbookTableAdapter *adapter = E_ADDRESSBOOK_TABLE_ADAPTER(etc);
+#if 0
+ EAddressbookTableAdapter *adapter = EAB_TABLE_ADAPTER(etc);
EAddressbookTableAdapterPrivate *priv = adapter->priv;
- if (e_addressbook_model_editable (priv->model)) {
+ if (eab_model_editable (priv->model)) {
ECard *card;
- if ( col >= COLS|| row >= e_addressbook_model_card_count (priv->model) )
+ if ( col >= COLS|| row >= eab_model_card_count (priv->model) )
return;
e_table_model_pre_change(etc);
@@ -167,29 +136,31 @@ addressbook_set_value_at (ETableModel *etc, int col, int row, const void *val)
"card", &card,
NULL);
- e_card_merging_book_commit_card(e_addressbook_model_get_ebook(priv->model),
+ e_card_merging_book_commit_card(eab_model_get_ebook(priv->model),
card, card_modified_cb, NULL);
g_object_unref (card);
/* XXX do we need this? shouldn't the commit_card generate a changed signal? */
e_table_model_cell_changed(etc, col, row);
}
+#endif
}
/* This function returns whether a particular cell is editable. */
static gboolean
addressbook_is_cell_editable (ETableModel *etc, int col, int row)
{
- EAddressbookTableAdapter *adapter = E_ADDRESSBOOK_TABLE_ADAPTER(etc);
+#if 0
+ EAddressbookTableAdapter *adapter = EAB_TABLE_ADAPTER(etc);
EAddressbookTableAdapterPrivate *priv = adapter->priv;
ECard *card;
- if (row >= 0 && row < e_addressbook_model_card_count (priv->model))
- card = e_addressbook_model_card_at (priv->model, row);
+ if (row >= 0 && row < eab_model_card_count (priv->model))
+ card = eab_model_card_at (priv->model, row);
else
card = NULL;
- if (!e_addressbook_model_editable(priv->model))
+ if (!eab_model_editable(priv->model))
return FALSE;
else if (card && e_card_evolution_list (card))
/* we only allow editing of the name and file as for
@@ -197,12 +168,16 @@ addressbook_is_cell_editable (ETableModel *etc, int col, int row)
return col == E_CARD_SIMPLE_FIELD_FULL_NAME || col == E_CARD_SIMPLE_FIELD_FILE_AS;
else
return col < E_CARD_SIMPLE_FIELD_LAST_SIMPLE_STRING;
+#else
+ return FALSE;
+#endif
}
static void
addressbook_append_row (ETableModel *etm, ETableModel *source, gint row)
{
- EAddressbookTableAdapter *adapter = E_ADDRESSBOOK_TABLE_ADAPTER(etm);
+#if 0
+ EAddressbookTableAdapter *adapter = EAB_TABLE_ADAPTER(etm);
EAddressbookTableAdapterPrivate *priv = adapter->priv;
ECard *card;
ECardSimple *simple;
@@ -216,9 +191,10 @@ addressbook_append_row (ETableModel *etm, ETableModel *source, gint row)
e_card_simple_set(simple, col, val);
}
e_card_simple_sync_card(simple);
- e_card_merging_book_add_card (e_addressbook_model_get_ebook (priv->model), card, NULL, NULL);
+ e_card_merging_book_add_card (eab_model_get_ebook (priv->model), card, NULL, NULL);
g_object_unref (simple);
g_object_unref (card);
+#endif
}
/* This function duplicates the value passed to it. */
@@ -254,7 +230,7 @@ addressbook_value_to_string (ETableModel *etc, int col, const void *value)
}
static void
-e_addressbook_table_adapter_class_init (GObjectClass *object_class)
+eab_table_adapter_class_init (GObjectClass *object_class)
{
ETableModelClass *model_class = (ETableModelClass *) object_class;
@@ -276,82 +252,57 @@ e_addressbook_table_adapter_class_init (GObjectClass *object_class)
}
static void
-e_addressbook_table_adapter_init (GObject *object)
+eab_table_adapter_init (GObject *object)
{
- EAddressbookTableAdapter *adapter = E_ADDRESSBOOK_TABLE_ADAPTER(object);
+ EAddressbookTableAdapter *adapter = EAB_TABLE_ADAPTER(object);
EAddressbookTableAdapterPrivate *priv;
priv = adapter->priv = g_new0 (EAddressbookTableAdapterPrivate, 1);
- priv->create_card_id = 0;
- priv->remove_card_id = 0;
- priv->modify_card_id = 0;
+ priv->create_contact_id = 0;
+ priv->remove_contact_id = 0;
+ priv->modify_contact_id = 0;
priv->model_changed_id = 0;
- priv->simples = NULL;
- priv->count = 0;
}
static void
-create_card (EAddressbookModel *model,
- gint index, gint count,
- EAddressbookTableAdapter *adapter)
+create_contact (EABModel *model,
+ gint index, gint count,
+ EAddressbookTableAdapter *adapter)
{
- EAddressbookTableAdapterPrivate *priv = adapter->priv;
- int i;
-
- priv->count += count;
- priv->simples = g_renew(ECardSimple *, priv->simples, priv->count);
- memmove (priv->simples + index + count, priv->simples + index, (priv->count - index - count) * sizeof (ECardSimple *));
-
e_table_model_pre_change (E_TABLE_MODEL (adapter));
- for (i = 0; i < count; i ++) {
- priv->simples[index + i] = e_card_simple_new (e_addressbook_model_card_at (priv->model, index + i));
- }
e_table_model_rows_inserted (E_TABLE_MODEL (adapter), index, count);
}
static void
-remove_card (EAddressbookModel *model,
- gint index,
- EAddressbookTableAdapter *adapter)
+remove_contact (EABModel *model,
+ gint index,
+ EAddressbookTableAdapter *adapter)
{
- EAddressbookTableAdapterPrivate *priv = adapter->priv;
-
e_table_model_pre_change (E_TABLE_MODEL (adapter));
-
- g_object_unref (priv->simples[index]);
- memmove (priv->simples + index, priv->simples + index + 1, (priv->count - index - 1) * sizeof (ECardSimple *));
- priv->count --;
e_table_model_rows_deleted (E_TABLE_MODEL (adapter), index, 1);
}
static void
-modify_card (EAddressbookModel *model,
- gint index,
- EAddressbookTableAdapter *adapter)
+modify_contact (EABModel *model,
+ gint index,
+ EAddressbookTableAdapter *adapter)
{
- EAddressbookTableAdapterPrivate *priv = adapter->priv;
-
e_table_model_pre_change (E_TABLE_MODEL (adapter));
-
- g_object_unref (priv->simples[index]);
- priv->simples[index] = e_card_simple_new (e_addressbook_model_card_at (priv->model, index));
- g_object_ref (priv->simples[index]);
e_table_model_row_changed (E_TABLE_MODEL (adapter), index);
}
static void
-model_changed (EAddressbookModel *model,
+model_changed (EABModel *model,
EAddressbookTableAdapter *adapter)
{
e_table_model_pre_change (E_TABLE_MODEL (adapter));
- build_simple_mapping (adapter);
e_table_model_changed (E_TABLE_MODEL (adapter));
}
GType
-e_addressbook_table_adapter_get_type (void)
+eab_table_adapter_get_type (void)
{
static GType type = 0;
@@ -360,12 +311,12 @@ e_addressbook_table_adapter_get_type (void)
sizeof (EAddressbookTableAdapterClass),
NULL, /* base_init */
NULL, /* base_finalize */
- (GClassInitFunc) e_addressbook_table_adapter_class_init,
+ (GClassInitFunc) eab_table_adapter_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (EAddressbookTableAdapter),
0, /* n_preallocs */
- (GInstanceInitFunc) e_addressbook_table_adapter_init,
+ (GInstanceInitFunc) eab_table_adapter_init,
};
type = g_type_register_static (PARENT_TYPE, "EAddressbookTableAdapter", &info, 0);
@@ -375,42 +326,40 @@ e_addressbook_table_adapter_get_type (void)
}
void
-e_addressbook_table_adapter_construct (EAddressbookTableAdapter *adapter,
- EAddressbookModel *model)
+eab_table_adapter_construct (EAddressbookTableAdapter *adapter,
+ EABModel *model)
{
EAddressbookTableAdapterPrivate *priv = adapter->priv;
priv->model = model;
g_object_ref (priv->model);
- priv->create_card_id = g_signal_connect(priv->model,
- "card_added",
- G_CALLBACK(create_card),
- adapter);
- priv->remove_card_id = g_signal_connect(priv->model,
- "card_removed",
- G_CALLBACK(remove_card),
- adapter);
- priv->modify_card_id = g_signal_connect(priv->model,
- "card_changed",
- G_CALLBACK(modify_card),
- adapter);
+ priv->create_contact_id = g_signal_connect(priv->model,
+ "contact_added",
+ G_CALLBACK(create_contact),
+ adapter);
+ priv->remove_contact_id = g_signal_connect(priv->model,
+ "contact_removed",
+ G_CALLBACK(remove_contact),
+ adapter);
+ priv->modify_contact_id = g_signal_connect(priv->model,
+ "contact_changed",
+ G_CALLBACK(modify_contact),
+ adapter);
priv->model_changed_id = g_signal_connect(priv->model,
"model_changed",
G_CALLBACK(model_changed),
adapter);
-
- build_simple_mapping (adapter);
}
ETableModel *
-e_addressbook_table_adapter_new (EAddressbookModel *model)
+eab_table_adapter_new (EABModel *model)
{
EAddressbookTableAdapter *et;
- et = g_object_new(E_TYPE_ADDRESSBOOK_TABLE_ADAPTER, NULL);
+ et = g_object_new(E_TYPE_AB_TABLE_ADAPTER, NULL);
- e_addressbook_table_adapter_construct (et, model);
+ eab_table_adapter_construct (et, model);
return E_TABLE_MODEL(et);
}
diff --git a/addressbook/gui/widgets/e-addressbook-table-adapter.h b/addressbook/gui/widgets/e-addressbook-table-adapter.h
index df66e1dce9..6f4bfd2960 100644
--- a/addressbook/gui/widgets/e-addressbook-table-adapter.h
+++ b/addressbook/gui/widgets/e-addressbook-table-adapter.h
@@ -1,24 +1,16 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-#ifndef _E_ADDRESSBOOK_TABLE_ADAPTER_H_
-#define _E_ADDRESSBOOK_TABLE_ADAPTER_H_
+#ifndef _EAB_TABLE_ADAPTER_H_
+#define _EAB_TABLE_ADAPTER_H_
#include <gal/e-table/e-table-model.h>
#include "addressbook/backend/ebook/e-book.h"
#include "addressbook/backend/ebook/e-book-view.h"
-#include "addressbook/backend/ebook/e-card-simple.h"
-#define E_TYPE_ADDRESSBOOK_TABLE_ADAPTER (e_addressbook_table_adapter_get_type ())
-#define E_ADDRESSBOOK_TABLE_ADAPTER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), E_TYPE_ADDRESSBOOK_TABLE_ADAPTER, EAddressbookTableAdapter))
-#define E_ADDRESSBOOK_TABLE_ADAPTER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), E_TYPE_ADDRESSBOOK_TABLE_ADAPTER, EAddressbookTableAdapterClass))
-#define E_IS_ADDRESSBOOK_TABLE_ADAPTER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_TYPE_ADDRESSBOOK_TABLE_ADAPTER))
-#define E_IS_ADDRESSBOOK_TABLE_ADAPTER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), E_TYPE_ADDRESSBOOK_TABLE_ADAPTER))
-
-/* Virtual Column list:
- 0 Email
- 1 Full Name
- 2 Street
- 3 Phone
-*/
+#define E_TYPE_AB_TABLE_ADAPTER (eab_table_adapter_get_type ())
+#define EAB_TABLE_ADAPTER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), E_TYPE_AB_TABLE_ADAPTER, EAddressbookTableAdapter))
+#define EAB_TABLE_ADAPTER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), E_TYPE_AB_TABLE_ADAPTER, EAddressbookTableAdapterClass))
+#define E_IS_ADDRESSBOOK_TABLE_ADAPTER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_TYPE_AB_TABLE_ADAPTER))
+#define E_IS_ADDRESSBOOK_TABLE_ADAPTER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), E_TYPE_AB_TABLE_ADAPTER))
typedef struct _EAddressbookTableAdapter EAddressbookTableAdapter;
typedef struct _EAddressbookTableAdapterPrivate EAddressbookTableAdapterPrivate;
@@ -36,9 +28,9 @@ struct _EAddressbookTableAdapterClass {
};
-GType e_addressbook_table_adapter_get_type (void);
-void e_addressbook_table_adapter_construct (EAddressbookTableAdapter *adapter,
- EAddressbookModel *model);
-ETableModel *e_addressbook_table_adapter_new (EAddressbookModel *model);
+GType eab_table_adapter_get_type (void);
+void eab_table_adapter_construct (EAddressbookTableAdapter *adapter,
+ EABModel *model);
+ETableModel *eab_table_adapter_new (EABModel *model);
-#endif /* _E_ADDRESSBOOK_TABLE_ADAPTER_H_ */
+#endif /* _EAB_TABLE_ADAPTER_H_ */
diff --git a/addressbook/gui/widgets/e-addressbook-treeview-adapter.c b/addressbook/gui/widgets/e-addressbook-treeview-adapter.c
index ab1a559f0c..592f9d2b03 100644
--- a/addressbook/gui/widgets/e-addressbook-treeview-adapter.c
+++ b/addressbook/gui/widgets/e-addressbook-treeview-adapter.c
@@ -4,7 +4,7 @@
#include "e-addressbook-model.h"
#include "e-addressbook-treeview-adapter.h"
#include "e-card-merging.h"
-#include "e-addressbook-util.h"
+#include "eab-gui-util.h"
#include <gtk/gtktreednd.h>
#include <libxml/tree.h>
#include <libxml/parser.h>
@@ -380,10 +380,10 @@ adapter_get_value (GtkTreeModel *tree_model,
v = e_card_simple_get_const(simple, column);
if (v && !strncmp (v, "<?xml", 5)) {
- EDestination *dest = e_destination_import (v);
+ EABDestination *dest = eab_destination_import (v);
if (dest) {
/* XXX blech, we leak this */
- v = g_strdup (e_destination_get_textrep (dest, TRUE));
+ v = g_strdup (eab_destination_get_textrep (dest, TRUE));
g_object_unref (dest);
}
}
diff --git a/addressbook/gui/widgets/e-addressbook-util.h b/addressbook/gui/widgets/e-addressbook-util.h
deleted file mode 100644
index e6ea3ab73b..0000000000
--- a/addressbook/gui/widgets/e-addressbook-util.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* e-addressbook-util.h
- * Copyright (C) 2001 Ximian, Inc.
- * Author: Chris Toshok <toshok@ximian.com>
- *
- * This library 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 library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-#ifndef __E_ADDRESSBOOK_UTIL_H__
-#define __E_ADDRESSBOOK_UTIL_H__
-
-#include "addressbook/backend/ebook/e-book.h"
-#include "addressbook/gui/contact-editor/e-contact-editor.h"
-#include "addressbook/gui/contact-list-editor/e-contact-list-editor.h"
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus */
-
-void e_addressbook_error_dialog (const gchar *msg,
- EBookStatus status);
-gint e_addressbook_prompt_save_dialog (GtkWindow *parent);
-EContactEditor *e_addressbook_show_contact_editor (EBook *book,
- ECard *card,
- gboolean is_new_card,
- gboolean editable);
-EContactListEditor *e_addressbook_show_contact_list_editor (EBook *book,
- ECard *card,
- gboolean is_new_card,
- gboolean editable);
-void e_addressbook_show_multiple_cards (EBook *book,
- GList *list,
- gboolean editable);
-void e_addressbook_transfer_cards (EBook *source,
- GList *cards, /* adopted */
- gboolean delete_from_source,
- GtkWindow *parent_window);
-
-typedef enum {
- E_ADDRESSBOOK_DISPOSITION_AS_ATTACHMENT,
- E_ADDRESSBOOK_DISPOSITION_AS_TO,
-} EAddressbookDisposition;
-
-void e_addressbook_send_card (ECard *card,
- EAddressbookDisposition disposition);
-void e_addressbook_send_card_list (GList *cards,
- EAddressbookDisposition disposition);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* __E_ADDRESSBOOK_UTIL_H__ */
diff --git a/addressbook/gui/widgets/e-addressbook-view.c b/addressbook/gui/widgets/e-addressbook-view.c
index 08710c71b5..4c5976717f 100644
--- a/addressbook/gui/widgets/e-addressbook-view.c
+++ b/addressbook/gui/widgets/e-addressbook-view.c
@@ -43,26 +43,24 @@
#include "addressbook/printing/e-contact-print.h"
#include "addressbook/printing/e-contact-print-envelope.h"
-#include "gal-view-factory-minicard.h"
-#include "gal-view-minicard.h"
#ifdef WITH_ADDRESSBOOK_VIEW_TREEVIEW
#include <gal/widgets/e-treeview-selection-model.h>
#include "gal-view-factory-treeview.h"
#include "gal-view-treeview.h"
#endif
+#include "gal-view-minicard.h"
+#include "gal-view-factory-minicard.h"
-#include "e-addressbook-marshal.h"
+#include "eab-marshal.h"
#include "e-addressbook-view.h"
#include "e-addressbook-model.h"
-#include "e-addressbook-util.h"
+#include "eab-gui-util.h"
+#include "util/eab-book-util.h"
#include "e-addressbook-table-adapter.h"
#ifdef WITH_ADDRESSBOOK_VIEW_TREEVIEW
#include "e-addressbook-treeview-adapter.h"
#endif
-#include "e-addressbook-reflow-adapter.h"
-#include "e-minicard-view-widget.h"
-#include "e-contact-save-as.h"
-#include "e-card-merging.h"
+#include "eab-contact-merging.h"
#include "e-contact-editor.h"
#include <gdk/gdkkeysyms.h>
@@ -76,33 +74,33 @@
#define d(x)
-static void e_addressbook_view_init (EAddressbookView *card);
-static void e_addressbook_view_class_init (EAddressbookViewClass *klass);
+static void eab_view_init (EABView *card);
+static void eab_view_class_init (EABViewClass *klass);
-static void e_addressbook_view_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void e_addressbook_view_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
+static void eab_view_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
+static void eab_view_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
-static void e_addressbook_view_dispose (GObject *object);
-static void change_view_type (EAddressbookView *view, EAddressbookViewType view_type);
+static void eab_view_dispose (GObject *object);
+static void change_view_type (EABView *view, EABViewType view_type);
-static void status_message (GtkObject *object, const gchar *status, EAddressbookView *eav);
-static void search_result (GtkObject *object, EBookViewStatus status, EAddressbookView *eav);
-static void folder_bar_message (GtkObject *object, const gchar *status, EAddressbookView *eav);
-static void stop_state_changed (GtkObject *object, EAddressbookView *eav);
-static void writable_status (GtkObject *object, gboolean writable, EAddressbookView *eav);
-static void backend_died (GtkObject *object, EAddressbookView *eav);
-static void command_state_change (EAddressbookView *eav);
-static void alphabet_state_change (EAddressbookView *eav, gunichar letter);
+static void status_message (GtkObject *object, const gchar *status, EABView *eav);
+static void search_result (GtkObject *object, EBookViewStatus status, EABView *eav);
+static void folder_bar_message (GtkObject *object, const gchar *status, EABView *eav);
+static void stop_state_changed (GtkObject *object, EABView *eav);
+static void writable_status (GtkObject *object, gboolean writable, EABView *eav);
+static void backend_died (GtkObject *object, EABView *eav);
+static void command_state_change (EABView *eav);
static void selection_clear_event (GtkWidget *invisible, GdkEventSelection *event,
- EAddressbookView *view);
+ EABView *view);
static void selection_received (GtkWidget *invisible, GtkSelectionData *selection_data,
- guint time, EAddressbookView *view);
+ guint time, EABView *view);
static void selection_get (GtkWidget *invisible, GtkSelectionData *selection_data,
- guint info, guint time_stamp, EAddressbookView *view);
+ guint info, guint time_stamp, EABView *view);
static void invisible_destroyed (gpointer data, GObject *where_object_was);
-static GtkTableClass *parent_class = NULL;
+#define PARENT_TYPE GTK_TYPE_EVENT_BOX
+static GtkEventBoxClass *parent_class = NULL;
/* The arguments we take */
enum {
@@ -117,7 +115,6 @@ enum {
SEARCH_RESULT,
FOLDER_BAR_MESSAGE,
COMMAND_STATE_CHANGE,
- ALPHABET_STATE_CHANGE,
LAST_SIGNAL
};
@@ -130,38 +127,38 @@ static GtkTargetEntry drag_types[] = {
};
static const int num_drag_types = sizeof (drag_types) / sizeof (drag_types[0]);
-static guint e_addressbook_view_signals [LAST_SIGNAL] = {0, };
+static guint eab_view_signals [LAST_SIGNAL] = {0, };
static GdkAtom clipboard_atom = GDK_NONE;
static GalViewCollection *collection = NULL;
GType
-e_addressbook_view_get_type (void)
+eab_view_get_type (void)
{
static GType type = 0;
if (!type) {
static const GTypeInfo info = {
- sizeof (EAddressbookViewClass),
+ sizeof (EABViewClass),
NULL, /* base_init */
NULL, /* base_finalize */
- (GClassInitFunc) e_addressbook_view_class_init,
+ (GClassInitFunc) eab_view_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
- sizeof (EAddressbookView),
+ sizeof (EABView),
0, /* n_preallocs */
- (GInstanceInitFunc) e_addressbook_view_init,
+ (GInstanceInitFunc) eab_view_init,
};
- type = g_type_register_static (GTK_TYPE_TABLE, "EAddressbookView", &info, 0);
+ type = g_type_register_static (PARENT_TYPE, "EABView", &info, 0);
}
return type;
}
static void
-e_addressbook_view_class_init (EAddressbookViewClass *klass)
+eab_view_class_init (EABViewClass *klass)
{
GObjectClass *object_class;
GtkWidgetClass *widget_class;
@@ -169,11 +166,11 @@ e_addressbook_view_class_init (EAddressbookViewClass *klass)
object_class = G_OBJECT_CLASS(klass);
widget_class = GTK_WIDGET_CLASS(klass);
- parent_class = gtk_type_class (gtk_table_get_type ());
+ parent_class = gtk_type_class (PARENT_TYPE);
- object_class->set_property = e_addressbook_view_set_property;
- object_class->get_property = e_addressbook_view_get_property;
- object_class->dispose = e_addressbook_view_dispose;
+ object_class->set_property = eab_view_set_property;
+ object_class->get_property = eab_view_get_property;
+ object_class->dispose = eab_view_dispose;
g_object_class_install_property (object_class, PROP_BOOK,
g_param_spec_object ("book",
@@ -193,137 +190,78 @@ e_addressbook_view_class_init (EAddressbookViewClass *klass)
g_param_spec_int ("type",
_("Type"),
/*_( */"XXX blurb" /*)*/,
- E_ADDRESSBOOK_VIEW_NONE,
-#ifdef WITH_ADDRESSBOOK_VIEW_TREEVIEW
- E_ADDRESSBOOK_VIEW_TREEVIEW,
-#else
- E_ADDRESSBOOK_VIEW_MINICARD,
-#endif
- E_ADDRESSBOOK_VIEW_NONE,
+ EAB_VIEW_NONE,
+ EAB_VIEW_TABLE,
+ EAB_VIEW_NONE,
G_PARAM_READWRITE));
- e_addressbook_view_signals [STATUS_MESSAGE] =
+ eab_view_signals [STATUS_MESSAGE] =
g_signal_new ("status_message",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EAddressbookViewClass, status_message),
+ G_STRUCT_OFFSET (EABViewClass, status_message),
NULL, NULL,
- e_addressbook_marshal_NONE__POINTER,
+ eab_marshal_NONE__POINTER,
G_TYPE_NONE, 1, G_TYPE_POINTER);
- e_addressbook_view_signals [SEARCH_RESULT] =
+ eab_view_signals [SEARCH_RESULT] =
g_signal_new ("search_result",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EAddressbookViewClass, search_result),
+ G_STRUCT_OFFSET (EABViewClass, search_result),
NULL, NULL,
- e_addressbook_marshal_NONE__INT,
+ eab_marshal_NONE__INT,
G_TYPE_NONE, 1, G_TYPE_INT);
- e_addressbook_view_signals [FOLDER_BAR_MESSAGE] =
+ eab_view_signals [FOLDER_BAR_MESSAGE] =
g_signal_new ("folder_bar_message",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EAddressbookViewClass, folder_bar_message),
+ G_STRUCT_OFFSET (EABViewClass, folder_bar_message),
NULL, NULL,
- e_addressbook_marshal_NONE__POINTER,
+ eab_marshal_NONE__POINTER,
G_TYPE_NONE, 1, G_TYPE_POINTER);
- e_addressbook_view_signals [COMMAND_STATE_CHANGE] =
+ eab_view_signals [COMMAND_STATE_CHANGE] =
g_signal_new ("command_state_change",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EAddressbookViewClass, command_state_change),
+ G_STRUCT_OFFSET (EABViewClass, command_state_change),
NULL, NULL,
- e_addressbook_marshal_NONE__NONE,
+ eab_marshal_NONE__NONE,
G_TYPE_NONE, 0);
- e_addressbook_view_signals [ALPHABET_STATE_CHANGE] =
- g_signal_new ("alphabet_state_change",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EAddressbookViewClass, alphabet_state_change),
- NULL, NULL,
- e_addressbook_marshal_NONE__UINT,
- G_TYPE_NONE, 1, G_TYPE_UINT);
-
-
if (!clipboard_atom)
clipboard_atom = gdk_atom_intern ("CLIPBOARD", FALSE);
}
static void
-e_addressbook_view_init (EAddressbookView *eav)
+eab_view_init (EABView *eav)
{
- eav->view_type = E_ADDRESSBOOK_VIEW_NONE;
-
- eav->model = e_addressbook_model_new ();
-
- g_signal_connect (eav->model,
- "status_message",
- G_CALLBACK (status_message),
- eav);
-
- g_signal_connect (eav->model,
- "search_result",
- G_CALLBACK (search_result),
- eav);
-
- g_signal_connect (eav->model,
- "folder_bar_message",
- G_CALLBACK (folder_bar_message),
- eav);
-
- g_signal_connect (eav->model,
- "stop_state_changed",
- G_CALLBACK (stop_state_changed),
- eav);
-
- g_signal_connect (eav->model,
- "writable_status",
- G_CALLBACK (writable_status),
- eav);
-
- g_signal_connect (eav->model,
- "backend_died",
- G_CALLBACK (backend_died),
- eav);
-
- eav->editable = FALSE;
- eav->book = NULL;
- eav->query = g_strdup (SHOW_ALL_SEARCH);
+ eav->view_type = EAB_VIEW_NONE;
+ eav->model = NULL;
eav->object = NULL;
eav->widget = NULL;
+ eav->scrolled = NULL;
+ eav->contact_display = NULL;
eav->view_instance = NULL;
eav->view_menus = NULL;
+ eav->current_view = NULL;
eav->uic = NULL;
- eav->current_alphabet_widget = NULL;
- eav->invisible = gtk_invisible_new ();
+ eav->book = NULL;
+ eav->query = NULL;
- gtk_selection_add_target (eav->invisible,
- clipboard_atom,
- GDK_SELECTION_TYPE_STRING,
- 0);
-
- g_signal_connect (eav->invisible, "selection_get",
- G_CALLBACK (selection_get),
- eav);
- g_signal_connect (eav->invisible, "selection_clear_event",
- G_CALLBACK (selection_clear_event),
- eav);
- g_signal_connect (eav->invisible, "selection_received",
- G_CALLBACK (selection_received),
- eav);
- g_object_weak_ref (G_OBJECT (eav->invisible), invisible_destroyed, eav);
+ eav->invisible = NULL;
+ eav->clipboard_contacts = NULL;
}
static void
-e_addressbook_view_dispose (GObject *object)
+eab_view_dispose (GObject *object)
{
- EAddressbookView *eav = E_ADDRESSBOOK_VIEW(object);
+ EABView *eav = EAB_VIEW(object);
if (eav->model) {
g_signal_handlers_disconnect_matched (eav->model,
@@ -356,10 +294,10 @@ e_addressbook_view_dispose (GObject *object)
eav->view_menus = NULL;
}
- if (eav->clipboard_cards) {
- g_list_foreach (eav->clipboard_cards, (GFunc)g_object_unref, NULL);
- g_list_free (eav->clipboard_cards);
- eav->clipboard_cards = NULL;
+ if (eav->clipboard_contacts) {
+ g_list_foreach (eav->clipboard_contacts, (GFunc)g_object_unref, NULL);
+ g_list_free (eav->clipboard_contacts);
+ eav->clipboard_contacts = NULL;
}
if (eav->invisible) {
@@ -372,14 +310,77 @@ e_addressbook_view_dispose (GObject *object)
}
GtkWidget*
-e_addressbook_view_new (void)
-{
- GtkWidget *widget = GTK_WIDGET (g_object_new (E_TYPE_ADDRESSBOOK_VIEW, NULL));
+eab_view_new (void)
+{
+ GtkWidget *widget = GTK_WIDGET (g_object_new (E_TYPE_AB_VIEW, NULL));
+ EABView *eav = EAB_VIEW (widget);
+
+ /* create our model */
+ eav->model = eab_model_new ();
+
+ g_signal_connect (eav->model, "status_message",
+ G_CALLBACK (status_message), eav);
+ g_signal_connect (eav->model, "search_result",
+ G_CALLBACK (search_result), eav);
+ g_signal_connect (eav->model, "folder_bar_message",
+ G_CALLBACK (folder_bar_message), eav);
+ g_signal_connect (eav->model, "stop_state_changed",
+ G_CALLBACK (stop_state_changed), eav);
+ g_signal_connect (eav->model, "writable_status",
+ G_CALLBACK (writable_status), eav);
+ g_signal_connect (eav->model, "backend_died",
+ G_CALLBACK (backend_died), eav);
+
+ eav->editable = FALSE;
+ eav->query = g_strdup (SHOW_ALL_SEARCH);
+
+ /* create the paned window and contact display */
+ eav->paned = gtk_vpaned_new ();
+ gtk_container_add (GTK_CONTAINER (eav), eav->paned);
+
+ eav->widget = gtk_label_new ("empty label here");
+ gtk_container_add (GTK_CONTAINER (eav->paned), eav->widget);
+ gtk_widget_show (eav->widget);
+
+ eav->scrolled = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (eav->scrolled), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (eav->scrolled), GTK_SHADOW_IN);
+ eav->contact_display = eab_contact_display_new ();
+
+ gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (eav->scrolled), eav->contact_display);
+ gtk_widget_show (eav->contact_display);
+
+ gtk_container_add (GTK_CONTAINER (eav->paned), eav->scrolled);
+ gtk_widget_show (eav->scrolled);
+ gtk_widget_show (eav->paned);
+
+ /* XXX hack */
+ gtk_paned_set_position (GTK_PANED (eav->paned), 144);
+
+ /* gtk selection crap */
+ eav->invisible = gtk_invisible_new ();
+
+ gtk_selection_add_target (eav->invisible,
+ clipboard_atom,
+ GDK_SELECTION_TYPE_STRING,
+ 0);
+
+ g_signal_connect (eav->invisible, "selection_get",
+ G_CALLBACK (selection_get),
+ eav);
+ g_signal_connect (eav->invisible, "selection_clear_event",
+ G_CALLBACK (selection_clear_event),
+ eav);
+ g_signal_connect (eav->invisible, "selection_received",
+ G_CALLBACK (selection_received),
+ eav);
+ g_object_weak_ref (G_OBJECT (eav->invisible), invisible_destroyed, eav);
+
return widget;
}
static void
-writable_status (GtkObject *object, gboolean writable, EAddressbookView *eav)
+writable_status (GtkObject *object, gboolean writable, EABView *eav)
{
eav->editable = writable;
command_state_change (eav);
@@ -412,7 +413,7 @@ init_collection (void)
gal_view_collection_add_factory (collection, factory);
g_object_unref (factory);
- factory = gal_view_factory_minicard_new ();
+ factory = gal_view_factory_minicard_new();
gal_view_collection_add_factory (collection, factory);
g_object_unref (factory);
@@ -431,17 +432,18 @@ display_view(GalViewInstance *instance,
GalView *view,
gpointer data)
{
- EAddressbookView *address_view = data;
+ EABView *address_view = data;
if (GAL_IS_VIEW_ETABLE(view)) {
- change_view_type (address_view, E_ADDRESSBOOK_VIEW_TABLE);
+ change_view_type (address_view, EAB_VIEW_TABLE);
gal_view_etable_attach_table (GAL_VIEW_ETABLE(view), e_table_scrolled_get_table(E_TABLE_SCROLLED(address_view->widget)));
- } else if (GAL_IS_VIEW_MINICARD(view)) {
- change_view_type (address_view, E_ADDRESSBOOK_VIEW_MINICARD);
- gal_view_minicard_attach (GAL_VIEW_MINICARD(view), E_MINICARD_VIEW_WIDGET (address_view->object));
+ }
+ else if (GAL_IS_VIEW_MINICARD(view)) {
+ change_view_type (address_view, EAB_VIEW_MINICARD);
+ gal_view_minicard_attach (GAL_VIEW_MINICARD (view), E_MINICARD_VIEW_WIDGET (address_view->object));
}
#ifdef WITH_ADDRESSBOOK_VIEW_TREEVIEW
else if (GAL_IS_VIEW_TREEVIEW (view)) {
- change_view_type (address_view, E_ADDRESSBOOK_VIEW_TREEVIEW);
+ change_view_type (address_view, EAB_VIEW_TREEVIEW);
gal_view_treeview_attach (GAL_VIEW_TREEVIEW(view), GTK_TREE_VIEW (address_view->object));
}
#endif
@@ -449,7 +451,7 @@ display_view(GalViewInstance *instance,
}
static void
-setup_menus (EAddressbookView *view)
+setup_menus (EABView *view)
{
if (view->book && view->view_instance == NULL) {
init_collection ();
@@ -468,9 +470,9 @@ setup_menus (EAddressbookView *view)
}
static void
-e_addressbook_view_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+eab_view_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
{
- EAddressbookView *eav = E_ADDRESSBOOK_VIEW(object);
+ EABView *eav = EAB_VIEW(object);
switch (prop_id){
case PROP_BOOK:
@@ -509,12 +511,6 @@ e_addressbook_view_set_property (GObject *object, guint prop_id, const GValue *v
g_object_set(eav->model,
"query", eav->query,
NULL);
- if (eav->current_alphabet_widget != NULL) {
- GtkWidget *current = eav->current_alphabet_widget;
-
- eav->current_alphabet_widget = NULL;
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (current), FALSE);
- }
break;
case PROP_TYPE:
change_view_type(eav, g_value_get_int (value));
@@ -526,9 +522,9 @@ e_addressbook_view_set_property (GObject *object, guint prop_id, const GValue *v
}
static void
-e_addressbook_view_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+eab_view_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
{
- EAddressbookView *eav = E_ADDRESSBOOK_VIEW(object);
+ EABView *eav = EAB_VIEW(object);
switch (prop_id) {
case PROP_BOOK:
@@ -550,44 +546,43 @@ e_addressbook_view_get_property (GObject *object, guint prop_id, GValue *value,
}
static ESelectionModel*
-get_selection_model (EAddressbookView *view)
+get_selection_model (EABView *view)
{
- if (view->view_type == E_ADDRESSBOOK_VIEW_MINICARD)
- return e_minicard_view_widget_get_selection_model (E_MINICARD_VIEW_WIDGET(view->object));
- else if (view->view_type == E_ADDRESSBOOK_VIEW_TABLE)
+ if (view->view_type == EAB_VIEW_TABLE)
return e_table_get_selection_model (e_table_scrolled_get_table (E_TABLE_SCROLLED(view->widget)));
+ else if (view->view_type == EAB_VIEW_MINICARD)
+ return e_minicard_view_widget_get_selection_model (E_MINICARD_VIEW_WIDGET(view->object));
#ifdef WITH_ADDRESSBOOK_VIEW_TREEVIEW
- else if (view->view_type == E_ADDRESSBOOK_VIEW_TREEVIEW) {
+ else if (view->view_type == EAB_VIEW_TREEVIEW)
return e_treeview_get_selection_model (GTK_TREE_VIEW (view->object));
- }
#endif
g_return_val_if_reached (NULL);
}
/* Popup menu stuff */
typedef struct {
- EAddressbookView *view;
+ EABView *view;
EPopupMenu *submenu;
gpointer closure;
-} CardAndBook;
+} ContactAndBook;
static ESelectionModel*
-card_and_book_get_selection_model (CardAndBook *card_and_book)
+contact_and_book_get_selection_model (ContactAndBook *contact_and_book)
{
- return get_selection_model (card_and_book->view);
+ return get_selection_model (contact_and_book->view);
}
static void
-card_and_book_free (CardAndBook *card_and_book)
+contact_and_book_free (ContactAndBook *contact_and_book)
{
- EAddressbookView *view = card_and_book->view;
+ EABView *view = contact_and_book->view;
ESelectionModel *selection;
- if (card_and_book->submenu)
+ if (contact_and_book->submenu)
gal_view_instance_free_popup_menu (view->view_instance,
- card_and_book->submenu);
+ contact_and_book->submenu);
- selection = card_and_book_get_selection_model (card_and_book);
+ selection = contact_and_book_get_selection_model (contact_and_book);
if (selection)
e_selection_model_right_click_up(selection);
@@ -595,33 +590,33 @@ card_and_book_free (CardAndBook *card_and_book)
}
static void
-get_card_list_1(gint model_row,
- gpointer closure)
+get_contact_list_1(gint model_row,
+ gpointer closure)
{
- CardAndBook *card_and_book;
+ ContactAndBook *contact_and_book;
GList **list;
- EAddressbookView *view;
- ECard *card;
+ EABView *view;
+ EContact *contact;
- card_and_book = closure;
- list = card_and_book->closure;
- view = card_and_book->view;
+ contact_and_book = closure;
+ list = contact_and_book->closure;
+ view = contact_and_book->view;
- card = e_addressbook_model_get_card(view->model, model_row);
- *list = g_list_prepend(*list, card);
+ contact = eab_model_get_contact(view->model, model_row);
+ *list = g_list_prepend(*list, contact);
}
static GList *
-get_card_list (CardAndBook *card_and_book)
+get_contact_list (ContactAndBook *contact_and_book)
{
GList *list = NULL;
ESelectionModel *selection;
- selection = card_and_book_get_selection_model (card_and_book);
+ selection = contact_and_book_get_selection_model (contact_and_book);
if (selection) {
- card_and_book->closure = &list;
- e_selection_model_foreach (selection, get_card_list_1, card_and_book);
+ contact_and_book->closure = &list;
+ e_selection_model_foreach (selection, get_contact_list_1, contact_and_book);
}
return list;
@@ -631,135 +626,134 @@ static void
has_email_address_1(gint model_row,
gpointer closure)
{
- CardAndBook *card_and_book;
+ ContactAndBook *contact_and_book;
gboolean *has_email;
- EAddressbookView *view;
- const ECard *card;
- EList *email;
+ EABView *view;
+ const EContact *contact;
+ GList *email;
- card_and_book = closure;
- has_email = card_and_book->closure;
- view = card_and_book->view;
+ contact_and_book = closure;
+ has_email = contact_and_book->closure;
+ view = contact_and_book->view;
if (*has_email)
return;
- card = e_addressbook_model_peek_card(view->model, model_row);
+ contact = eab_model_contact_at(view->model, model_row);
- g_object_get (G_OBJECT (card),
- "email", &email,
- NULL);
+ email = e_contact_get (E_CONTACT (contact), E_CONTACT_EMAIL);
- if (e_list_length (email) > 0)
+ if (g_list_length (email) > 0)
*has_email = TRUE;
- g_object_unref (email);
+ g_list_foreach (email, (GFunc)g_free, NULL);
+ g_list_free (email);
}
static gboolean
-get_has_email_address (CardAndBook *card_and_book)
+get_has_email_address (ContactAndBook *contact_and_book)
{
ESelectionModel *selection;
gboolean has_email = FALSE;
- selection = card_and_book_get_selection_model (card_and_book);
+ selection = contact_and_book_get_selection_model (contact_and_book);
if (selection) {
- card_and_book->closure = &has_email;
- e_selection_model_foreach (selection, has_email_address_1, card_and_book);
+ contact_and_book->closure = &has_email;
+ e_selection_model_foreach (selection, has_email_address_1, contact_and_book);
}
return has_email;
}
static void
-save_as (GtkWidget *widget, CardAndBook *card_and_book)
+save_as (GtkWidget *widget, ContactAndBook *contact_and_book)
{
- GList *cards = get_card_list (card_and_book);
- if (cards) {
- e_contact_list_save_as(_("Save as VCard"), cards, NULL);
- e_free_object_list(cards);
+ GList *contacts = get_contact_list (contact_and_book);
+ if (contacts) {
+ eab_contact_list_save(_("Save as VCard"), contacts, NULL);
+ e_free_object_list(contacts);
}
}
static void
-send_as (GtkWidget *widget, CardAndBook *card_and_book)
+send_as (GtkWidget *widget, ContactAndBook *contact_and_book)
{
- GList *cards = get_card_list (card_and_book);
- if (cards) {
- e_addressbook_send_card_list(cards, E_ADDRESSBOOK_DISPOSITION_AS_ATTACHMENT);
- e_free_object_list(cards);
+ GList *contacts = get_contact_list (contact_and_book);
+ if (contacts) {
+ eab_send_contact_list(contacts, EAB_DISPOSITION_AS_ATTACHMENT);
+ e_free_object_list(contacts);
}
}
static void
-send_to (GtkWidget *widget, CardAndBook *card_and_book)
+send_to (GtkWidget *widget, ContactAndBook *contact_and_book)
{
- GList *cards = get_card_list (card_and_book);
+ GList *contacts = get_contact_list (contact_and_book);
- if (cards) {
- e_addressbook_send_card_list(cards, E_ADDRESSBOOK_DISPOSITION_AS_TO);
- e_free_object_list(cards);
+ if (contacts) {
+ eab_send_contact_list(contacts, EAB_DISPOSITION_AS_TO);
+ e_free_object_list(contacts);
}
}
static void
-print (GtkWidget *widget, CardAndBook *card_and_book)
+print (GtkWidget *widget, ContactAndBook *contact_and_book)
{
- GList *cards = get_card_list (card_and_book);
- if (cards) {
- if (cards->next)
- gtk_widget_show(e_contact_print_card_list_dialog_new(cards));
+ GList *contacts = get_contact_list (contact_and_book);
+ if (contacts) {
+ if (contacts->next)
+ gtk_widget_show(e_contact_print_contact_list_dialog_new(contacts));
else
- gtk_widget_show(e_contact_print_card_dialog_new(cards->data));
- e_free_object_list(cards);
+ gtk_widget_show(e_contact_print_contact_dialog_new(contacts->data));
+ e_free_object_list(contacts);
}
}
#if 0 /* Envelope printing is disabled for Evolution 1.0. */
static void
-print_envelope (GtkWidget *widget, CardAndBook *card_and_book)
+print_envelope (GtkWidget *widget, ContactAndBook *contact_and_book)
{
- GList *cards = get_card_list (card_and_book);
+ GList *cards = get_card_list (contact_and_book);
if (cards) {
- gtk_widget_show(e_contact_list_print_envelope_dialog_new(card_and_book->card));
+ gtk_widget_show(e_contact_list_print_envelope_dialog_new(contact_and_book->card));
e_free_object_list(cards);
}
}
#endif
static void
-copy (GtkWidget *widget, CardAndBook *card_and_book)
+copy (GtkWidget *widget, ContactAndBook *contact_and_book)
{
- e_addressbook_view_copy (card_and_book->view);
+ eab_view_copy (contact_and_book->view);
}
static void
-paste (GtkWidget *widget, CardAndBook *card_and_book)
+paste (GtkWidget *widget, ContactAndBook *contact_and_book)
{
- e_addressbook_view_paste (card_and_book->view);
+ eab_view_paste (contact_and_book->view);
}
static void
-cut (GtkWidget *widget, CardAndBook *card_and_book)
+cut (GtkWidget *widget, ContactAndBook *contact_and_book)
{
- e_addressbook_view_cut (card_and_book->view);
+ eab_view_cut (contact_and_book->view);
}
static void
-delete (GtkWidget *widget, CardAndBook *card_and_book)
+delete (GtkWidget *widget, ContactAndBook *contact_and_book)
{
- if (e_contact_editor_confirm_delete(GTK_WINDOW(gtk_widget_get_toplevel(card_and_book->view->widget)))) {
+ if (e_contact_editor_confirm_delete(GTK_WINDOW(gtk_widget_get_toplevel(contact_and_book->view->widget)))) {
EBook *book;
- GList *list = get_card_list(card_and_book);
+ GList *list = get_contact_list(contact_and_book);
GList *iterator;
gboolean bulk_remove = FALSE;
- bulk_remove = e_book_check_static_capability (card_and_book->view->model->book,
+ bulk_remove = e_book_check_static_capability (contact_and_book->view->model->book,
"bulk-remove");
- g_object_get(card_and_book->view->model,
+ g_object_get(contact_and_book->view->model,
"book", &book,
NULL);
@@ -767,26 +761,28 @@ delete (GtkWidget *widget, CardAndBook *card_and_book)
GList *ids = NULL;
for (iterator = list; iterator; iterator = iterator->next) {
- ECard *card = iterator->data;
- ids = g_list_prepend (ids, (char*)e_card_get_id (card));
+ EContact *contact = iterator->data;
+ ids = g_list_prepend (ids, (char*)e_contact_get_const (contact, E_CONTACT_UID));
}
/* Remove the cards all at once. */
- e_book_remove_cards (book,
- ids,
- NULL,
- NULL);
+ /* XXX no callback specified... ugh */
+ e_book_async_remove_contacts (book,
+ ids,
+ NULL,
+ NULL);
g_list_free (ids);
}
else {
for (iterator = list; iterator; iterator = iterator->next) {
- ECard *card = iterator->data;
+ EContact *contact = iterator->data;
/* Remove the card. */
- e_book_remove_card (book,
- card,
- NULL,
- NULL);
+ /* XXX no callback specified... ugh */
+ e_book_async_remove_contact (book,
+ e_contact_get_const (contact, E_CONTACT_UID),
+ NULL,
+ NULL);
}
}
e_free_object_list(list);
@@ -795,56 +791,55 @@ delete (GtkWidget *widget, CardAndBook *card_and_book)
}
static void
-copy_to_folder (GtkWidget *widget, CardAndBook *card_and_book)
+copy_to_folder (GtkWidget *widget, ContactAndBook *contact_and_book)
{
- e_addressbook_view_copy_to_folder (card_and_book->view);
+ eab_view_copy_to_folder (contact_and_book->view);
}
static void
-move_to_folder (GtkWidget *widget, CardAndBook *card_and_book)
+move_to_folder (GtkWidget *widget, ContactAndBook *contact_and_book)
{
- e_addressbook_view_move_to_folder (card_and_book->view);
+ eab_view_move_to_folder (contact_and_book->view);
}
static void
-free_popup_info (GtkWidget *w, CardAndBook *card_and_book)
+free_popup_info (GtkWidget *w, ContactAndBook *contact_and_book)
{
- card_and_book_free (card_and_book);
+ contact_and_book_free (contact_and_book);
}
static void
-new_card (GtkWidget *widget, CardAndBook *card_and_book)
+new_card (GtkWidget *widget, ContactAndBook *contact_and_book)
{
EBook *book;
- ECard *card;
+ EContact *contact = e_contact_new();
- g_object_get(card_and_book->view->model,
+ g_object_get(contact_and_book->view->model,
"book", &book,
NULL);
- e_addressbook_show_contact_editor (book, card = e_card_new(""), TRUE, TRUE);
- g_object_unref(book);
- g_object_unref(card);
+ eab_show_contact_editor (book, contact, TRUE, TRUE);
+ g_object_unref (book);
+ g_object_unref (contact);
}
static void
-new_list (GtkWidget *widget, CardAndBook *card_and_book)
+new_list (GtkWidget *widget, ContactAndBook *contact_and_book)
{
EBook *book;
- ECard *card;
+ EContact *contact = e_contact_new ();
- g_object_get(card_and_book->view->model,
+ g_object_get(contact_and_book->view->model,
"book", &book,
NULL);
-
- e_addressbook_show_contact_list_editor (book, card = e_card_new(""), TRUE, TRUE);
+ eab_show_contact_list_editor (book, contact, TRUE, TRUE);
g_object_unref(book);
- g_object_unref(card);
+ g_object_unref(contact);
}
#if 0
static void
-sources (GtkWidget *widget, CardAndBook *card_and_book)
+sources (GtkWidget *widget, ContactAndBook *contact_and_book)
{
BonoboControl *control;
GNOME_Evolution_ShellView shell_view;
@@ -874,9 +869,9 @@ sources (GtkWidget *widget, CardAndBook *card_and_book)
#define POPUP_NOEMAIL_MASK 0x4
static void
-do_popup_menu(EAddressbookView *view, GdkEvent *event)
+do_popup_menu(EABView *view, GdkEvent *event)
{
- CardAndBook *card_and_book;
+ ContactAndBook *contact_and_book;
GtkMenu *popup;
EPopupMenu *submenu = NULL;
ESelectionModel *selection_model;
@@ -921,308 +916,62 @@ do_popup_menu(EAddressbookView *view, GdkEvent *event)
E_POPUP_TERMINATOR
};
- card_and_book = g_new(CardAndBook, 1);
- card_and_book->view = view;
- card_and_book->submenu = submenu;
+ contact_and_book = g_new(ContactAndBook, 1);
+ contact_and_book->view = view;
+ contact_and_book->submenu = submenu;
- g_object_ref (card_and_book->view);
+ g_object_ref (contact_and_book->view);
- selection_model = card_and_book_get_selection_model (card_and_book);
+ selection_model = contact_and_book_get_selection_model (contact_and_book);
if (selection_model)
selection = e_selection_model_selected_count (selection_model) > 0;
popup = e_popup_menu_create (menu,
0,
- (e_addressbook_model_editable (view->model) ? 0 : POPUP_READONLY_MASK) +
+ (eab_model_editable (view->model) ? 0 : POPUP_READONLY_MASK) +
(selection ? 0 : POPUP_NOSELECTION_MASK) +
- (get_has_email_address (card_and_book) ? 0 : POPUP_NOEMAIL_MASK),
- card_and_book);
+ (get_has_email_address (contact_and_book) ? 0 : POPUP_NOEMAIL_MASK),
+ contact_and_book);
g_signal_connect (popup, "selection-done",
- G_CALLBACK (free_popup_info), card_and_book);
+ G_CALLBACK (free_popup_info), contact_and_book);
e_popup_menu (popup, event);
}
-
-/* Minicard view stuff */
-
-/* Translators: put here a list of labels you want to see on buttons in
- addressbook. You may use any character to separate labels but it must
- also be placed at the begining ot the string */
-const char *button_labels = N_(",123,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z");
-/* Translators: put here a list of characters that correspond to buttons
- in addressbook. You may use any character to separate labels but it
- must also be placed at the begining ot the string.
- Use lower case letters if possible. */
-const char *button_letters = N_(",0,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z");
-
-typedef struct {
- EAddressbookView *view;
- GtkWidget *button;
- GtkWidget *vbox;
- gchar *letters;
-} LetterClosure;
-
-static char **
-e_utf8_split (const char *utf8_str, gunichar delim)
-{
- GSList *str_list = NULL, *sl;
- int n = 0;
- const char *str, *s;
- char **str_array;
-
- g_return_val_if_fail (utf8_str != NULL, NULL);
-
- str = utf8_str;
- while (*str != '\0') {
- int len;
- char *new_str;
-
- for (s = str; *s != '\0' && g_utf8_get_char (s) != delim; s = g_utf8_next_char (s))
- ;
- len = s - str;
- new_str = g_new (char, len + 1);
- if (len > 0) {
- memcpy (new_str, str, len);
- }
- new_str[len] = '\0';
- str_list = g_slist_prepend (str_list, new_str);
- n++;
- if (*s != '\0') {
- str = g_utf8_next_char (s);
- } else {
- str = s;
- }
- }
-
- str_array = g_new (char *, n + 1);
- str_array[n--] = NULL;
- for (sl = str_list; sl != NULL; sl = sl->next) {
- str_array[n--] = sl->data;
- }
- g_slist_free (str_list);
-
- return str_array;
-}
-
static void
-jump_to_letters (EAddressbookView *view, gchar* l)
-{
- char *query;
- char *s;
- char buf[6 + 1];
-
- if (g_unichar_isdigit (g_utf8_get_char(l))) {
- const char *letters = _(button_letters);
- char **letter_v;
- GString *gstr;
- char **p;
-
- letter_v = e_utf8_split (g_utf8_next_char (letters),
- g_utf8_get_char (letters));
- g_assert (letter_v != NULL && letter_v[0] != NULL);
- gstr = g_string_new ("(not (or ");
- for (p = letter_v + 1; *p != NULL; p++) {
- for (s = *p; *s != '\0'; s = g_utf8_next_char (s)) {
- buf [g_unichar_to_utf8 (g_utf8_get_char(s), buf)] = '\0';
- g_string_append_printf (gstr, "(beginswith \"file_as\" \"%s\")", buf);
- }
- }
- g_string_append (gstr, "))");
- query = gstr->str;
- g_strfreev (letter_v);
- g_string_free (gstr, FALSE);
- } else {
- GString *gstr;
-
- gstr = g_string_new ("(or ");
-
- for (s = l; *s != '\0'; s = g_utf8_next_char (s)) {
- buf [g_unichar_to_utf8 (g_utf8_get_char(s), buf)] = '\0';
- g_string_append_printf (gstr, "(beginswith \"file_as\" \"%s\")", buf);
- }
-
- g_string_append (gstr, ")");
- query = gstr->str;
- g_string_free (gstr, FALSE);
- }
- g_object_set (view,
- "query", query,
- NULL);
- g_free (query);
-}
-
-static void
-button_toggled(GtkWidget *button, LetterClosure *closure)
+render_contact (int row, EABView *view)
{
- EAddressbookView *view = closure->view;
-
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button))) {
- GtkWidget *current = view->current_alphabet_widget;
+ EContact *contact = eab_model_get_contact (view->model, row);
- view->current_alphabet_widget = NULL;
- if (current && current != button)
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (current), FALSE);
- jump_to_letters (view, closure->letters);
- view->current_alphabet_widget = button;
- alphabet_state_change (view, g_utf8_get_char(closure->letters));
- } else {
- if (view->current_alphabet_widget != NULL &&
- view->current_alphabet_widget == button) {
- view->current_alphabet_widget = NULL;
- g_object_set (view,
- "query", NULL,
- NULL);
- alphabet_state_change (view, 0);
- }
- }
+ eab_contact_display_render (EAB_CONTACT_DISPLAY (view->contact_display), contact,
+ EAB_CONTACT_DISPLAY_RENDER_NORMAL);
}
static void
-free_closure(gpointer data, GObject *where_object_was)
+selection_changed (GObject *o, EABView *view)
{
- GtkWidget *button = GTK_WIDGET (where_object_was);
- LetterClosure *closure = data;
- if (button != NULL &&
- button == closure->view->current_alphabet_widget) {
- closure->view->current_alphabet_widget = NULL;
- }
- g_free (closure->letters);
- g_free (closure);
-}
-
-static GtkWidget *
-create_alphabet (EAddressbookView *view)
-{
- GtkWidget *widget, *viewport, *vbox;
- const char *labels, *letters;
- char **label_v, **letter_v;
- char **pl, **pc;
- gunichar sep;
-
- widget = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (widget),
- GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
-
- viewport = gtk_viewport_new (NULL, NULL);
- gtk_container_add (GTK_CONTAINER (widget), viewport);
- gtk_container_set_border_width (GTK_CONTAINER (viewport), 4);
- gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport), GTK_SHADOW_NONE);
-
- vbox = gtk_vbox_new (FALSE, 4);
- gtk_container_add (GTK_CONTAINER (viewport), vbox);
-
- labels = _(button_labels);
- sep = g_utf8_get_char (labels);
- label_v = e_utf8_split (g_utf8_next_char (labels), sep);
- letters = _(button_letters);
- sep = g_utf8_get_char (letters);
- letter_v = e_utf8_split (g_utf8_next_char (letters), sep);
- g_assert (label_v != NULL && letter_v != NULL);
- for (pl = label_v, pc = letter_v; *pl != NULL && *pc != NULL; pl++, pc++) {
- GtkWidget *button;
- LetterClosure *closure;
- char *label;
-
- label = *pl;
- button = gtk_toggle_button_new_with_label (label);
- gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
-
- closure = g_new (LetterClosure, 1);
- closure->view = view;
- closure->letters = g_strdup (*pc);
- closure->button = button;
- closure->vbox = vbox;
- g_signal_connect(button, "toggled",
- G_CALLBACK (button_toggled), closure);
- g_object_weak_ref (G_OBJECT (button), free_closure, closure);
-
- }
- g_strfreev (label_v);
- g_strfreev (letter_v);
-
- gtk_widget_show_all (widget);
-
- return widget;
-}
+ ESelectionModel *selection_model;
-static void
-selection_changed (GObject *o, EAddressbookView *view)
-{
command_state_change (view);
-}
-
-static void
-minicard_right_click (EMinicardView *minicard_view_item, GdkEvent *event, EAddressbookView *view)
-{
- do_popup_menu(view, event);
-}
-
-static void
-create_minicard_view (EAddressbookView *view)
-{
- GtkWidget *scrolled_window;
- GtkWidget *alphabet;
- GtkWidget *minicard_view;
- GtkWidget *minicard_hbox;
- EAddressbookReflowAdapter *adapter;
-
- gtk_widget_push_colormap (gdk_rgb_get_cmap ());
-
- minicard_hbox = gtk_hbox_new(FALSE, 0);
-
- adapter = E_ADDRESSBOOK_REFLOW_ADAPTER(e_addressbook_reflow_adapter_new (view->model));
- minicard_view = e_minicard_view_widget_new(adapter);
-
- /* A hack */
- g_object_set_data (G_OBJECT (adapter), "view", view);
-
- g_signal_connect(minicard_view, "selection_change",
- G_CALLBACK(selection_changed), view);
-
- g_signal_connect(minicard_view, "right_click",
- G_CALLBACK(minicard_right_click), view);
-
-
- view->object = G_OBJECT(minicard_view);
- view->widget = minicard_hbox;
-
- scrolled_window = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
- GTK_POLICY_AUTOMATIC,
- GTK_POLICY_AUTOMATIC);
-
- gtk_container_add (GTK_CONTAINER (scrolled_window), minicard_view);
-
- gtk_box_pack_start(GTK_BOX(minicard_hbox), scrolled_window, TRUE, TRUE, 0);
-
- alphabet = create_alphabet(view);
- if (alphabet)
- gtk_box_pack_start(GTK_BOX(minicard_hbox), alphabet, FALSE, FALSE, 0);
-
- gtk_table_attach(GTK_TABLE(view), minicard_hbox,
- 0, 1,
- 0, 1,
- GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND,
- 0, 0);
-
- gtk_widget_show_all( GTK_WIDGET(minicard_hbox) );
-
- gtk_widget_pop_colormap ();
-
- e_reflow_model_changed (E_REFLOW_MODEL (adapter));
+ selection_model = get_selection_model (view);
- g_object_unref (adapter);
+ if (e_selection_model_selected_count (selection_model) == 1)
+ e_selection_model_foreach (selection_model,
+ (EForeachFunc)render_contact, view);
+ else
+ eab_contact_display_render (EAB_CONTACT_DISPLAY (view->contact_display), NULL,
+ EAB_CONTACT_DISPLAY_RENDER_NORMAL);
+
}
static void
-table_double_click(ETableScrolled *table, gint row, gint col, GdkEvent *event, EAddressbookView *view)
+table_double_click(ETableScrolled *table, gint row, gint col, GdkEvent *event, EABView *view)
{
if (E_IS_ADDRESSBOOK_TABLE_ADAPTER(view->object)) {
- EAddressbookModel *model = view->model;
- ECard *card = e_addressbook_model_get_card(model, row);
+ EABModel *model = view->model;
+ EContact *contact = eab_model_get_contact (model, row);
EBook *book;
g_object_get(model,
@@ -1231,25 +980,25 @@ table_double_click(ETableScrolled *table, gint row, gint col, GdkEvent *event, E
g_assert (E_IS_BOOK (book));
- if (e_card_evolution_list (card))
- e_addressbook_show_contact_list_editor (book, card, FALSE, view->editable);
+ if (e_contact_get (contact, E_CONTACT_IS_LIST))
+ eab_show_contact_list_editor (book, contact, FALSE, view->editable);
else
- e_addressbook_show_contact_editor (book, card, FALSE, view->editable);
+ eab_show_contact_editor (book, contact, FALSE, view->editable);
g_object_unref (book);
- g_object_unref (card);
+ g_object_unref (contact);
}
}
static gint
-table_right_click(ETableScrolled *table, gint row, gint col, GdkEvent *event, EAddressbookView *view)
+table_right_click(ETableScrolled *table, gint row, gint col, GdkEvent *event, EABView *view)
{
do_popup_menu(view, event);
return TRUE;
}
static gint
-table_white_space_event(ETableScrolled *table, GdkEvent *event, EAddressbookView *view)
+table_white_space_event(ETableScrolled *table, GdkEvent *event, EABView *view)
{
if (event->type == GDK_BUTTON_PRESS && ((GdkEventButton *)event)->button == 3) {
do_popup_menu(view, event);
@@ -1269,7 +1018,7 @@ table_drag_data_get (ETable *table,
guint time,
gpointer user_data)
{
- EAddressbookView *view = user_data;
+ EABView *view = user_data;
if (!E_IS_ADDRESSBOOK_TABLE_ADAPTER(view->object))
return;
@@ -1278,7 +1027,7 @@ table_drag_data_get (ETable *table,
case DND_TARGET_TYPE_VCARD: {
char *value;
- value = e_card_get_vcard(view->model->data[row]);
+ value = e_vcard_to_string (E_VCARD (view->model->data[row]), EVC_FORMAT_VCARD_30);
gtk_selection_data_set (selection_data,
selection_data->target,
@@ -1290,68 +1039,62 @@ table_drag_data_get (ETable *table,
}
static void
-emit_status_message (EAddressbookView *eav, const gchar *status)
+emit_status_message (EABView *eav, const gchar *status)
{
g_signal_emit (eav,
- e_addressbook_view_signals [STATUS_MESSAGE], 0,
+ eab_view_signals [STATUS_MESSAGE], 0,
status);
}
static void
-emit_search_result (EAddressbookView *eav, EBookViewStatus status)
+emit_search_result (EABView *eav, EBookViewStatus status)
{
g_signal_emit (eav,
- e_addressbook_view_signals [SEARCH_RESULT], 0,
+ eab_view_signals [SEARCH_RESULT], 0,
status);
}
static void
-emit_folder_bar_message (EAddressbookView *eav, const gchar *message)
+emit_folder_bar_message (EABView *eav, const gchar *message)
{
g_signal_emit (eav,
- e_addressbook_view_signals [FOLDER_BAR_MESSAGE], 0,
+ eab_view_signals [FOLDER_BAR_MESSAGE], 0,
message);
}
static void
-status_message (GtkObject *object, const gchar *status, EAddressbookView *eav)
+status_message (GtkObject *object, const gchar *status, EABView *eav)
{
emit_status_message (eav, status);
}
static void
-search_result (GtkObject *object, EBookViewStatus status, EAddressbookView *eav)
+search_result (GtkObject *object, EBookViewStatus status, EABView *eav)
{
emit_search_result (eav, status);
}
static void
-folder_bar_message (GtkObject *object, const gchar *status, EAddressbookView *eav)
+folder_bar_message (GtkObject *object, const gchar *status, EABView *eav)
{
emit_folder_bar_message (eav, status);
}
static void
-stop_state_changed (GtkObject *object, EAddressbookView *eav)
+stop_state_changed (GtkObject *object, EABView *eav)
{
command_state_change (eav);
}
static void
-command_state_change (EAddressbookView *eav)
+command_state_change (EABView *eav)
{
/* Reffing during emission is unnecessary. Gtk automatically refs during an emission. */
- g_signal_emit (eav, e_addressbook_view_signals [COMMAND_STATE_CHANGE], 0);
+ g_signal_emit (eav, eab_view_signals [COMMAND_STATE_CHANGE], 0);
}
static void
-alphabet_state_change (EAddressbookView *eav, gunichar letter)
-{
- g_signal_emit (eav, e_addressbook_view_signals [ALPHABET_STATE_CHANGE], 0, letter);
-}
-
-static void
-backend_died (GtkObject *object, EAddressbookView *eav)
+backend_died (GtkObject *object, EABView *eav)
{
char *message = g_strdup_printf (_("The addressbook backend for\n%s\nhas crashed. "
"You will have to restart Evolution in order "
@@ -1362,12 +1105,52 @@ backend_died (GtkObject *object, EAddressbookView *eav)
}
static void
-create_table_view (EAddressbookView *view)
+minicard_right_click (EMinicardView *minicard_view_item, GdkEvent *event, EABView *view)
+{
+ do_popup_menu(view, event);
+}
+
+static void
+create_minicard_view (EABView *view)
+{
+ GtkWidget *scrolled_window;
+ GtkWidget *minicard_view;
+ EAddressbookReflowAdapter *adapter;
+
+ adapter = E_ADDRESSBOOK_REFLOW_ADAPTER(e_addressbook_reflow_adapter_new (view->model));
+ minicard_view = e_minicard_view_widget_new(adapter);
+
+ g_signal_connect(minicard_view, "selection_change",
+ G_CALLBACK(selection_changed), view);
+
+ g_signal_connect(minicard_view, "right_click",
+ G_CALLBACK(minicard_right_click), view);
+
+ scrolled_window = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
+ GTK_POLICY_AUTOMATIC,
+ GTK_POLICY_AUTOMATIC);
+
+ view->object = G_OBJECT(minicard_view);
+ view->widget = scrolled_window;
+
+ gtk_container_add (GTK_CONTAINER (scrolled_window), minicard_view);
+ gtk_widget_show (minicard_view);
+
+ gtk_widget_show_all( GTK_WIDGET(scrolled_window) );
+
+ gtk_paned_add1 (GTK_PANED (view->paned), scrolled_window);
+
+ e_reflow_model_changed (E_REFLOW_MODEL (adapter));
+}
+
+static void
+create_table_view (EABView *view)
{
ETableModel *adapter;
GtkWidget *table;
- adapter = e_addressbook_table_adapter_new(view->model);
+ adapter = eab_table_adapter_new(view->model);
/* Here we create the table. We give it the three pieces of
the table we've created, the header, the model, and the
@@ -1395,11 +1178,7 @@ create_table_view (EAddressbookView *view)
G_CALLBACK (table_drag_data_get),
view);
- gtk_table_attach(GTK_TABLE(view), table,
- 0, 1,
- 0, 1,
- GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND,
- 0, 0);
+ gtk_paned_add1 (GTK_PANED (view->paned), table);
gtk_widget_show( GTK_WIDGET(table) );
}
@@ -1408,11 +1187,11 @@ create_table_view (EAddressbookView *view)
static void
treeview_row_activated(GtkTreeView *treeview,
GtkTreePath *path, GtkTreeViewColumn *column,
- EAddressbookView *view)
+ EABView *view)
{
- EAddressbookModel *model = view->model;
+ EABModel *model = view->model;
int row = gtk_tree_path_get_indices (path)[0];
- ECard *card = e_addressbook_model_get_card(model, row);
+ ECard *card = eab_model_get_card(model, row);
EBook *book;
g_object_get(model,
@@ -1422,16 +1201,16 @@ treeview_row_activated(GtkTreeView *treeview,
g_assert (E_IS_BOOK (book));
if (e_card_evolution_list (card))
- e_addressbook_show_contact_list_editor (book, card, FALSE, view->editable);
+ eab_show_contact_list_editor (book, card, FALSE, view->editable);
else
- e_addressbook_show_contact_editor (book, card, FALSE, view->editable);
+ eab_show_contact_editor (book, card, FALSE, view->editable);
g_object_unref (book);
g_object_unref (card);
}
static void
-create_treeview_view (EAddressbookView *view)
+create_treeview_view (EABView *view)
{
GtkTreeModel *adapter;
ECardSimple *simple;
@@ -1441,7 +1220,7 @@ create_treeview_view (EAddressbookView *view)
simple = e_card_simple_new(NULL);
- adapter = e_addressbook_treeview_adapter_new(view->model);
+ adapter = eab_treeview_adapter_new(view->model);
scrolled = gtk_scrolled_window_new (NULL, NULL);
treeview = gtk_tree_view_new_with_model (adapter);
@@ -1490,11 +1269,7 @@ create_treeview_view (EAddressbookView *view)
g_signal_connect(e_treeview_get_selection_model (GTK_TREE_VIEW (treeview)), "selection_changed",
G_CALLBACK(selection_changed), view);
- gtk_table_attach(GTK_TABLE(view), scrolled,
- 0, 1,
- 0, 1,
- GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND,
- 0, 0);
+ gtk_paned_add1 (GTK_PANED (view->paned), scrolled);
gtk_widget_show( GTK_WIDGET(scrolled) );
@@ -1503,26 +1278,27 @@ create_treeview_view (EAddressbookView *view)
#endif
static void
-change_view_type (EAddressbookView *view, EAddressbookViewType view_type)
+change_view_type (EABView *view, EABViewType view_type)
{
if (view_type == view->view_type)
return;
if (view->widget) {
+ gtk_container_remove (GTK_CONTAINER (view->paned), view->widget);
gtk_widget_destroy (view->widget);
view->widget = NULL;
}
view->object = NULL;
switch (view_type) {
- case E_ADDRESSBOOK_VIEW_MINICARD:
- create_minicard_view (view);
- break;
- case E_ADDRESSBOOK_VIEW_TABLE:
+ case EAB_VIEW_TABLE:
create_table_view (view);
break;
+ case EAB_VIEW_MINICARD:
+ create_minicard_view (view);
+ break;
#ifdef WITH_ADDRESSBOOK_VIEW_TREEVIEW
- case E_ADDRESSBOOK_VIEW_TREEVIEW:
+ case EAB_VIEW_TREEVIEW:
create_treeview_view (view);
break;
#endif
@@ -1614,7 +1390,7 @@ e_contact_print_button(GtkDialog *dialog, gint response, gpointer data)
}
void
-e_addressbook_view_setup_menus (EAddressbookView *view,
+eab_view_setup_menus (EABView *view,
BonoboUIComponent *uic)
{
@@ -1631,7 +1407,7 @@ e_addressbook_view_setup_menus (EAddressbookView *view,
}
/**
- * e_addressbook_view_discard_menus:
+ * eab_view_discard_menus:
* @view: An addressbook view.
*
* Makes an addressbook view discard its GAL view menus and its views instance
@@ -1639,7 +1415,7 @@ e_addressbook_view_setup_menus (EAddressbookView *view,
* deactivated.
**/
void
-e_addressbook_view_discard_menus (EAddressbookView *view)
+eab_view_discard_menus (EABView *view)
{
g_return_if_fail (view != NULL);
g_return_if_fail (E_IS_ADDRESSBOOK_VIEW (view));
@@ -1661,9 +1437,9 @@ e_addressbook_view_discard_menus (EAddressbookView *view)
}
void
-e_addressbook_view_print(EAddressbookView *view)
+eab_view_print(EABView *view)
{
- if (view->view_type == E_ADDRESSBOOK_VIEW_MINICARD) {
+ if (view->view_type == EAB_VIEW_MINICARD) {
char *query;
EBook *book;
GtkWidget *print;
@@ -1673,12 +1449,10 @@ e_addressbook_view_print(EAddressbookView *view)
"book", &book,
NULL);
print = e_contact_print_dialog_new(book, query);
-
- g_object_unref(book);
g_free(query);
gtk_widget_show_all(print);
}
- else if (view->view_type == E_ADDRESSBOOK_VIEW_TABLE) {
+ else if (view->view_type == EAB_VIEW_TABLE) {
GtkWidget *dialog;
EPrintable *printable;
ETable *etable;
@@ -1709,16 +1483,16 @@ e_addressbook_view_print(EAddressbookView *view)
gtk_widget_show(dialog);
}
#ifdef WITH_ADDRESSBOOK_VIEW_TREEVIEW
- else if (view->view_type == E_ADDRESSBOOK_VIEW_TREEVIEW) {
+ else if (view->view_type == EAB_VIEW_TREEVIEW) {
/* XXX */
}
#endif
}
void
-e_addressbook_view_print_preview(EAddressbookView *view)
+eab_view_print_preview(EABView *view)
{
- if (view->view_type == E_ADDRESSBOOK_VIEW_MINICARD) {
+ if (view->view_type == EAB_VIEW_MINICARD) {
char *query;
EBook *book;
@@ -1727,10 +1501,9 @@ e_addressbook_view_print_preview(EAddressbookView *view)
"book", &book,
NULL);
e_contact_print_preview(book, query);
- g_object_unref(book);
g_free(query);
}
- else if (view->view_type == E_ADDRESSBOOK_VIEW_TABLE) {
+ else if (view->view_type == EAB_VIEW_TABLE) {
EPrintable *printable;
ETable *etable;
GnomePrintJob *master;
@@ -1769,27 +1542,27 @@ e_addressbook_view_print_preview(EAddressbookView *view)
g_object_unref (printable);
}
#ifdef WITH_ADDRESSBOOK_VIEW_TREEVIEW
- else if (view->view_type == E_ADDRESSBOOK_VIEW_TREEVIEW) {
+ else if (view->view_type == EAB_VIEW_TREEVIEW) {
/* XXX */
}
#endif
}
void
-e_addressbook_view_delete_selection(EAddressbookView *view)
+eab_view_delete_selection(EABView *view)
{
- CardAndBook card_and_book;
+ ContactAndBook contact_and_book;
- memset (&card_and_book, 0, sizeof (card_and_book));
- card_and_book.view = view;
+ memset (&contact_and_book, 0, sizeof (contact_and_book));
+ contact_and_book.view = view;
- delete (GTK_WIDGET (view), &card_and_book);
+ delete (GTK_WIDGET (view), &contact_and_book);
}
static void
invisible_destroyed (gpointer data, GObject *where_object_was)
{
- EAddressbookView *view = data;
+ EABView *view = data;
view->invisible = NULL;
}
@@ -1798,11 +1571,11 @@ selection_get (GtkWidget *invisible,
GtkSelectionData *selection_data,
guint info,
guint time_stamp,
- EAddressbookView *view)
+ EABView *view)
{
char *value;
- value = e_card_list_get_vcard(view->clipboard_cards);
+ value = eab_contact_list_to_string (view->clipboard_contacts);
gtk_selection_data_set (selection_data, GDK_SELECTION_TYPE_STRING,
8, value, strlen (value));
@@ -1812,12 +1585,12 @@ selection_get (GtkWidget *invisible,
static void
selection_clear_event (GtkWidget *invisible,
GdkEventSelection *event,
- EAddressbookView *view)
+ EABView *view)
{
- if (view->clipboard_cards) {
- g_list_foreach (view->clipboard_cards, (GFunc)g_object_unref, NULL);
- g_list_free (view->clipboard_cards);
- view->clipboard_cards = NULL;
+ if (view->clipboard_contacts) {
+ g_list_foreach (view->clipboard_contacts, (GFunc)g_object_unref, NULL);
+ g_list_free (view->clipboard_contacts);
+ view->clipboard_contacts = NULL;
}
}
@@ -1825,27 +1598,25 @@ static void
selection_received (GtkWidget *invisible,
GtkSelectionData *selection_data,
guint time,
- EAddressbookView *view)
+ EABView *view)
{
if (selection_data->length < 0 || selection_data->type != GDK_SELECTION_TYPE_STRING) {
return;
}
else {
/* XXX make sure selection_data->data = \0 terminated */
- GList *card_list = e_card_load_cards_from_string_with_default_charset (selection_data->data, "ISO-8859-1");
+ GList *contact_list = eab_contact_list_from_string (selection_data->data);
GList *l;
- if (!card_list /* it wasn't a vcard list */)
- return;
-
- for (l = card_list; l; l = l->next) {
- ECard *card = l->data;
+ for (l = contact_list; l; l = l->next) {
+ EContact *contact = l->data;
- e_card_merging_book_add_card (view->book, card, NULL /* XXX */, NULL);
+ /* XXX NULL for a callback /sigh */
+ eab_merging_book_add_contact (view->book, contact, NULL /* XXX */, NULL);
}
- g_list_foreach (card_list, (GFunc)g_object_unref, NULL);
- g_list_free (card_list);
+ g_list_foreach (contact_list, (GFunc)g_object_unref, NULL);
+ g_list_free (contact_list);
}
}
@@ -1857,7 +1628,7 @@ add_to_list (int model_row, gpointer closure)
}
static GList *
-get_selected_cards (EAddressbookView *view)
+get_selected_contacts (EABView *view)
{
GList *list;
GList *iterator;
@@ -1867,66 +1638,64 @@ get_selected_cards (EAddressbookView *view)
e_selection_model_foreach (selection, add_to_list, &list);
for (iterator = list; iterator; iterator = iterator->next) {
- iterator->data = e_addressbook_model_card_at (view->model, GPOINTER_TO_INT (iterator->data));
- if (iterator->data)
- g_object_ref (iterator->data);
+ iterator->data = eab_model_get_contact (view->model, GPOINTER_TO_INT (iterator->data));
}
list = g_list_reverse (list);
return list;
}
void
-e_addressbook_view_save_as (EAddressbookView *view)
+eab_view_save_as (EABView *view)
{
- GList *list = get_selected_cards (view);
+ GList *list = get_selected_contacts (view);
if (list)
- e_contact_list_save_as (_("Save as VCard"), list, NULL);
+ eab_contact_list_save (_("Save as VCard"), list, NULL);
e_free_object_list(list);
}
void
-e_addressbook_view_view (EAddressbookView *view)
+eab_view_view (EABView *view)
{
- GList *list = get_selected_cards (view);
- e_addressbook_show_multiple_cards (view->book, list, view->editable);
+ GList *list = get_selected_contacts (view);
+ eab_show_multiple_contacts (view->book, list, view->editable);
e_free_object_list(list);
}
void
-e_addressbook_view_send (EAddressbookView *view)
+eab_view_send (EABView *view)
{
- GList *list = get_selected_cards (view);
+ GList *list = get_selected_contacts (view);
if (list)
- e_addressbook_send_card_list (list, E_ADDRESSBOOK_DISPOSITION_AS_ATTACHMENT);
+ eab_send_contact_list (list, EAB_DISPOSITION_AS_ATTACHMENT);
e_free_object_list(list);
}
void
-e_addressbook_view_send_to (EAddressbookView *view)
+eab_view_send_to (EABView *view)
{
- GList *list = get_selected_cards (view);
+ GList *list = get_selected_contacts (view);
if (list)
- e_addressbook_send_card_list (list, E_ADDRESSBOOK_DISPOSITION_AS_TO);
+ eab_send_contact_list (list, EAB_DISPOSITION_AS_TO);
e_free_object_list(list);
}
void
-e_addressbook_view_cut (EAddressbookView *view)
+eab_view_cut (EABView *view)
{
- e_addressbook_view_copy (view);
- e_addressbook_view_delete_selection (view);
+ eab_view_copy (view);
+ eab_view_delete_selection (view);
}
void
-e_addressbook_view_copy (EAddressbookView *view)
+eab_view_copy (EABView *view)
{
- view->clipboard_cards = get_selected_cards (view);
+ view->clipboard_contacts = get_selected_contacts (view);
gtk_selection_owner_set (view->invisible, clipboard_atom, GDK_CURRENT_TIME);
}
void
-e_addressbook_view_paste (EAddressbookView *view)
+eab_view_paste (EABView *view)
{
gtk_selection_convert (view->invisible, clipboard_atom,
GDK_SELECTION_TYPE_STRING,
@@ -1934,7 +1703,7 @@ e_addressbook_view_paste (EAddressbookView *view)
}
void
-e_addressbook_view_select_all (EAddressbookView *view)
+eab_view_select_all (EABView *view)
{
ESelectionModel *model = get_selection_model (view);
@@ -1944,7 +1713,7 @@ e_addressbook_view_select_all (EAddressbookView *view)
}
void
-e_addressbook_view_show_all(EAddressbookView *view)
+eab_view_show_all(EABView *view)
{
g_object_set(view,
"query", NULL,
@@ -1952,44 +1721,44 @@ e_addressbook_view_show_all(EAddressbookView *view)
}
void
-e_addressbook_view_stop(EAddressbookView *view)
+eab_view_stop(EABView *view)
{
if (view)
- e_addressbook_model_stop (view->model);
+ eab_model_stop (view->model);
}
static void
-view_transfer_cards (EAddressbookView *view, gboolean delete_from_source)
+view_transfer_contacts (EABView *view, gboolean delete_from_source)
{
EBook *book;
- GList *cards;
+ GList *contacts;
GtkWindow *parent_window;
g_object_get(view->model,
"book", &book,
NULL);
- cards = get_selected_cards (view);
+ contacts = get_selected_contacts (view);
parent_window = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (view)));
- e_addressbook_transfer_cards (book, cards, delete_from_source, parent_window);
+ eab_transfer_contacts (book, contacts, delete_from_source, parent_window);
g_object_unref(book);
}
void
-e_addressbook_view_copy_to_folder (EAddressbookView *view)
+eab_view_copy_to_folder (EABView *view)
{
- view_transfer_cards (view, FALSE);
+ view_transfer_contacts (view, FALSE);
}
void
-e_addressbook_view_move_to_folder (EAddressbookView *view)
+eab_view_move_to_folder (EABView *view)
{
- view_transfer_cards (view, TRUE);
+ view_transfer_contacts (view, TRUE);
}
static gboolean
-e_addressbook_view_selection_nonempty (EAddressbookView *view)
+eab_view_selection_nonempty (EABView *view)
{
ESelectionModel *selection_model;
@@ -2001,85 +1770,85 @@ e_addressbook_view_selection_nonempty (EAddressbookView *view)
}
gboolean
-e_addressbook_view_can_create (EAddressbookView *view)
+eab_view_can_create (EABView *view)
{
- return view ? e_addressbook_model_editable (view->model) : FALSE;
+ return view ? eab_model_editable (view->model) : FALSE;
}
gboolean
-e_addressbook_view_can_print (EAddressbookView *view)
+eab_view_can_print (EABView *view)
{
- return view && view->model ? e_addressbook_model_card_count (view->model) : FALSE;
+ return view && view->model ? eab_model_contact_count (view->model) : FALSE;
}
gboolean
-e_addressbook_view_can_save_as (EAddressbookView *view)
+eab_view_can_save_as (EABView *view)
{
- return view ? e_addressbook_view_selection_nonempty (view) : FALSE;
+ return view ? eab_view_selection_nonempty (view) : FALSE;
}
gboolean
-e_addressbook_view_can_view (EAddressbookView *view)
+eab_view_can_view (EABView *view)
{
- return view ? e_addressbook_view_selection_nonempty (view) : FALSE;
+ return view ? eab_view_selection_nonempty (view) : FALSE;
}
gboolean
-e_addressbook_view_can_send (EAddressbookView *view)
+eab_view_can_send (EABView *view)
{
- return view ? e_addressbook_view_selection_nonempty (view) : FALSE;
+ return view ? eab_view_selection_nonempty (view) : FALSE;
}
gboolean
-e_addressbook_view_can_send_to (EAddressbookView *view)
+eab_view_can_send_to (EABView *view)
{
- return view ? e_addressbook_view_selection_nonempty (view) : FALSE;
+ return view ? eab_view_selection_nonempty (view) : FALSE;
}
gboolean
-e_addressbook_view_can_delete (EAddressbookView *view)
+eab_view_can_delete (EABView *view)
{
- return view ? e_addressbook_view_selection_nonempty (view) && e_addressbook_model_editable (view->model) : FALSE;
+ return view ? eab_view_selection_nonempty (view) && eab_model_editable (view->model) : FALSE;
}
gboolean
-e_addressbook_view_can_cut (EAddressbookView *view)
+eab_view_can_cut (EABView *view)
{
- return view ? e_addressbook_view_selection_nonempty (view) && e_addressbook_model_editable (view->model) : FALSE;
+ return view ? eab_view_selection_nonempty (view) && eab_model_editable (view->model) : FALSE;
}
gboolean
-e_addressbook_view_can_copy (EAddressbookView *view)
+eab_view_can_copy (EABView *view)
{
- return view ? e_addressbook_view_selection_nonempty (view) : FALSE;
+ return view ? eab_view_selection_nonempty (view) : FALSE;
}
gboolean
-e_addressbook_view_can_paste (EAddressbookView *view)
+eab_view_can_paste (EABView *view)
{
- return view ? e_addressbook_model_editable (view->model) : FALSE;
+ return view ? eab_model_editable (view->model) : FALSE;
}
gboolean
-e_addressbook_view_can_select_all (EAddressbookView *view)
+eab_view_can_select_all (EABView *view)
{
- return view ? e_addressbook_model_card_count (view->model) != 0 : FALSE;
+ return view ? eab_model_contact_count (view->model) != 0 : FALSE;
}
gboolean
-e_addressbook_view_can_stop (EAddressbookView *view)
+eab_view_can_stop (EABView *view)
{
- return view ? e_addressbook_model_can_stop (view->model) : FALSE;
+ return view ? eab_model_can_stop (view->model) : FALSE;
}
gboolean
-e_addressbook_view_can_copy_to_folder (EAddressbookView *view)
+eab_view_can_copy_to_folder (EABView *view)
{
- return view ? e_addressbook_view_selection_nonempty (view) : FALSE;
+ return view ? eab_view_selection_nonempty (view) : FALSE;
}
gboolean
-e_addressbook_view_can_move_to_folder (EAddressbookView *view)
+eab_view_can_move_to_folder (EABView *view)
{
- return view ? e_addressbook_view_selection_nonempty (view) && e_addressbook_model_editable (view->model) : FALSE;
+ return view ? eab_view_selection_nonempty (view) && eab_model_editable (view->model) : FALSE;
}
diff --git a/addressbook/gui/widgets/e-addressbook-view.etspec b/addressbook/gui/widgets/e-addressbook-view.etspec
index a0a0015d75..812a88b060 100644
--- a/addressbook/gui/widgets/e-addressbook-view.etspec
+++ b/addressbook/gui/widgets/e-addressbook-view.etspec
@@ -1,14 +1,17 @@
<ETableSpecification click-to-add="true" draw-grid="true" _click-to-add-message="* Click here to add a contact *">
- <ETableColumn model_col= "0" _title="File As" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/>
- <ETableColumn model_col= "1" _title="Full Name" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/>
- <ETableColumn model_col= "2" _title="Email" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/>
+ <ETableColumn model_col= "2" _title="File As" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/>
+ <ETableColumn model_col= "3" _title="Full Name" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/>
+ <ETableColumn model_col= "7" _title="Email" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/>
+<!--
<ETableColumn model_col= "3" _title="Primary Phone" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/>
<ETableColumn model_col= "4" _title="Assistant Phone" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/>
<ETableColumn model_col= "5" _title="Business Phone" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/>
<ETableColumn model_col= "6" _title="Callback Phone" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/>
<ETableColumn model_col= "7" _title="Company Phone" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/>
<ETableColumn model_col= "8" _title="Home Phone" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/>
- <ETableColumn model_col= "9" _title="Organization" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/>
+-->
+ <ETableColumn model_col="21" _title="Organization" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/>
+<!--
<ETableColumn model_col="10" _title="Business Address" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/>
<ETableColumn model_col="11" _title="Home Address" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/>
<ETableColumn model_col="12" _title="Mobile Phone" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/>
@@ -25,19 +28,22 @@
<ETableColumn model_col="23" _title="Telex" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/>
<ETableColumn model_col="24" _title="TTY" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/>
<ETableColumn model_col="25" _title="Other Address" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/>
- <ETableColumn model_col="26" _title="Email 2" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/>
- <ETableColumn model_col="27" _title="Email 3" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/>
+-->
+ <ETableColumn model_col="8" _title="Email 2" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/>
+ <ETableColumn model_col="9" _title="Email 3" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/>
<ETableColumn model_col="28" _title="Web Site" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/>
- <ETableColumn model_col="29" _title="Department" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/>
- <ETableColumn model_col="30" _title="Office" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/>
- <ETableColumn model_col="31" _title="Title" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/>
- <ETableColumn model_col="32" _title="Profession" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/>
- <ETableColumn model_col="33" _title="Manager" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/>
- <ETableColumn model_col="34" _title="Assistant" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/>
+ <ETableColumn model_col="22" _title="Department" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/>
+ <ETableColumn model_col="23" _title="Office" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/>
+ <ETableColumn model_col="24" _title="Title" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/>
+ <ETableColumn model_col="25" _title="Profession" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/>
+ <ETableColumn model_col="26" _title="Manager" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/>
+ <ETableColumn model_col="27" _title="Assistant" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/>
<ETableColumn model_col="35" _title="Nickname" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/>
+<!--
<ETableColumn model_col="36" _title="Spouse" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/>
<ETableColumn model_col="37" _title="Note" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/>
<ETableColumn model_col="38" _title="Free-busy URL" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/>
+-->
<ETableState>
<column source="0"/>
<column source="1"/>
diff --git a/addressbook/gui/widgets/e-addressbook-view.h b/addressbook/gui/widgets/e-addressbook-view.h
index dbf32811d8..1573f682ed 100644
--- a/addressbook/gui/widgets/e-addressbook-view.h
+++ b/addressbook/gui/widgets/e-addressbook-view.h
@@ -17,22 +17,20 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
-#ifndef __E_ADDRESSBOOK_VIEW_H__
-#define __E_ADDRESSBOOK_VIEW_H__
+#ifndef __EAB_VIEW_H__
+#define __EAB_VIEW_H__
-#include <gtk/gtktable.h>
+#include <gtk/gtkeventbox.h>
#include <bonobo/bonobo-ui-component.h>
#include <gal/menus/gal-view-instance.h>
#include "e-addressbook-model.h"
+#include "eab-contact-display.h"
#include "widgets/menus/gal-view-menus.h"
#include "addressbook/backend/ebook/e-book.h"
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus */
+G_BEGIN_DECLS
-/* EAddressbookView - A card displaying information about a contact.
+/* EABView - A card displaying information about a contact.
*
* The following arguments are available:
*
@@ -40,36 +38,36 @@ extern "C" {
* --------------------------------------------------------------------------------
*/
-#define E_TYPE_ADDRESSBOOK_VIEW (e_addressbook_view_get_type ())
-#define E_ADDRESSBOOK_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_ADDRESSBOOK_VIEW, EAddressbookView))
-#define E_ADDRESSBOOK_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_ADDRESSBOOK_VIEW, EAddressbookViewClass))
-#define E_IS_ADDRESSBOOK_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_ADDRESSBOOK_VIEW))
-#define E_IS_ADDRESSBOOK_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_ADDRESSBOOK_VIEW))
+#define E_TYPE_AB_VIEW (eab_view_get_type ())
+#define EAB_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_AB_VIEW, EABView))
+#define EAB_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_AB_VIEW, EABViewClass))
+#define E_IS_ADDRESSBOOK_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_AB_VIEW))
+#define E_IS_ADDRESSBOOK_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_AB_VIEW))
typedef enum {
- E_ADDRESSBOOK_VIEW_NONE, /* initialized to this */
- E_ADDRESSBOOK_VIEW_TABLE,
- E_ADDRESSBOOK_VIEW_MINICARD
+ EAB_VIEW_NONE, /* initialized to this */
+ EAB_VIEW_MINICARD,
+ EAB_VIEW_TABLE,
#ifdef WITH_ADDRESSBOOK_VIEW_TREEVIEW
- ,E_ADDRESSBOOK_VIEW_TREEVIEW
+ ,EAB_VIEW_TREEVIEW
#endif
-} EAddressbookViewType;
+} EABViewType;
-typedef struct _EAddressbookView EAddressbookView;
-typedef struct _EAddressbookViewClass EAddressbookViewClass;
+typedef struct _EABView EABView;
+typedef struct _EABViewClass EABViewClass;
-struct _EAddressbookView
+struct _EABView
{
- GtkTable parent;
+ GtkEventBox parent;
/* item specific fields */
- EAddressbookViewType view_type;
+ EABViewType view_type;
- EAddressbookModel *model;
+ EABModel *model;
GtkWidget *invisible;
- GList *clipboard_cards;
+ GList *clipboard_contacts;
EBook *book;
char *query;
@@ -77,9 +75,10 @@ struct _EAddressbookView
GObject *object;
GtkWidget *widget;
- GtkWidget *current_alphabet_widget;
- GtkWidget *vbox;
+ GtkWidget *scrolled;
+ GtkWidget *contact_display;
+ GtkWidget *paned;
/* Menus handler and the view instance */
GalViewInstance *view_instance;
@@ -88,62 +87,58 @@ struct _EAddressbookView
BonoboUIComponent *uic;
};
-struct _EAddressbookViewClass
+struct _EABViewClass
{
- GtkTableClass parent_class;
+ GtkEventBoxClass parent_class;
/*
* Signals
*/
- void (*status_message) (EAddressbookView *view, const gchar *message);
- void (*search_result) (EAddressbookView *view, EBookViewStatus status);
- void (*folder_bar_message) (EAddressbookView *view, const gchar *message);
- void (*command_state_change) (EAddressbookView *view);
- void (*alphabet_state_change) (EAddressbookView *view, gunichar letter);
+ void (*status_message) (EABView *view, const gchar *message);
+ void (*search_result) (EABView *view, EBookViewStatus status);
+ void (*folder_bar_message) (EABView *view, const gchar *message);
+ void (*command_state_change) (EABView *view);
};
-GtkWidget *e_addressbook_view_new (void);
-GType e_addressbook_view_get_type (void);
-
-void e_addressbook_view_setup_menus (EAddressbookView *view,
- BonoboUIComponent *uic);
-
-void e_addressbook_view_discard_menus (EAddressbookView *view);
-
-void e_addressbook_view_save_as (EAddressbookView *view);
-void e_addressbook_view_view (EAddressbookView *view);
-void e_addressbook_view_send (EAddressbookView *view);
-void e_addressbook_view_send_to (EAddressbookView *view);
-void e_addressbook_view_print (EAddressbookView *view);
-void e_addressbook_view_print_preview (EAddressbookView *view);
-void e_addressbook_view_delete_selection (EAddressbookView *view);
-void e_addressbook_view_cut (EAddressbookView *view);
-void e_addressbook_view_copy (EAddressbookView *view);
-void e_addressbook_view_paste (EAddressbookView *view);
-void e_addressbook_view_select_all (EAddressbookView *view);
-void e_addressbook_view_show_all (EAddressbookView *view);
-void e_addressbook_view_stop (EAddressbookView *view);
-void e_addressbook_view_copy_to_folder (EAddressbookView *view);
-void e_addressbook_view_move_to_folder (EAddressbookView *view);
-
-gboolean e_addressbook_view_can_create (EAddressbookView *view);
-gboolean e_addressbook_view_can_print (EAddressbookView *view);
-gboolean e_addressbook_view_can_save_as (EAddressbookView *view);
-gboolean e_addressbook_view_can_view (EAddressbookView *view);
-gboolean e_addressbook_view_can_send (EAddressbookView *view);
-gboolean e_addressbook_view_can_send_to (EAddressbookView *view);
-gboolean e_addressbook_view_can_delete (EAddressbookView *view);
-gboolean e_addressbook_view_can_cut (EAddressbookView *view);
-gboolean e_addressbook_view_can_copy (EAddressbookView *view);
-gboolean e_addressbook_view_can_paste (EAddressbookView *view);
-gboolean e_addressbook_view_can_select_all (EAddressbookView *view);
-gboolean e_addressbook_view_can_stop (EAddressbookView *view);
-gboolean e_addressbook_view_can_copy_to_folder (EAddressbookView *view);
-gboolean e_addressbook_view_can_move_to_folder (EAddressbookView *view);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-
-#endif /* __E_ADDRESSBOOK_VIEW_H__ */
+GtkWidget *eab_view_new (void);
+GType eab_view_get_type (void);
+
+void eab_view_setup_menus (EABView *view,
+ BonoboUIComponent *uic);
+
+void eab_view_discard_menus (EABView *view);
+
+void eab_view_save_as (EABView *view);
+void eab_view_view (EABView *view);
+void eab_view_send (EABView *view);
+void eab_view_send_to (EABView *view);
+void eab_view_print (EABView *view);
+void eab_view_print_preview (EABView *view);
+void eab_view_delete_selection (EABView *view);
+void eab_view_cut (EABView *view);
+void eab_view_copy (EABView *view);
+void eab_view_paste (EABView *view);
+void eab_view_select_all (EABView *view);
+void eab_view_show_all (EABView *view);
+void eab_view_stop (EABView *view);
+void eab_view_copy_to_folder (EABView *view);
+void eab_view_move_to_folder (EABView *view);
+
+gboolean eab_view_can_create (EABView *view);
+gboolean eab_view_can_print (EABView *view);
+gboolean eab_view_can_save_as (EABView *view);
+gboolean eab_view_can_view (EABView *view);
+gboolean eab_view_can_send (EABView *view);
+gboolean eab_view_can_send_to (EABView *view);
+gboolean eab_view_can_delete (EABView *view);
+gboolean eab_view_can_cut (EABView *view);
+gboolean eab_view_can_copy (EABView *view);
+gboolean eab_view_can_paste (EABView *view);
+gboolean eab_view_can_select_all (EABView *view);
+gboolean eab_view_can_stop (EABView *view);
+gboolean eab_view_can_copy_to_folder (EABView *view);
+gboolean eab_view_can_move_to_folder (EABView *view);
+
+G_END_DECLS;
+
+#endif /* __EAB_VIEW_H__ */
diff --git a/addressbook/gui/widgets/e-minicard-control.h b/addressbook/gui/widgets/e-minicard-control.h
deleted file mode 100644
index bc0d934384..0000000000
--- a/addressbook/gui/widgets/e-minicard-control.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef __E_MINICARD_CONTROL_H__
-#define __E_MINICARD_CONTROL_H__
-
-#include <bonobo/bonobo-control.h>
-
-BonoboControl *e_minicard_control_new (void);
-
-#endif /* __E_MINICARD_CONTROL_H__ */
diff --git a/addressbook/gui/widgets/e-minicard-label.c b/addressbook/gui/widgets/e-minicard-label.c
index 607170aea4..31935164d7 100644
--- a/addressbook/gui/widgets/e-minicard-label.c
+++ b/addressbook/gui/widgets/e-minicard-label.c
@@ -22,7 +22,7 @@
#include <config.h>
#include "e-minicard-label.h"
-#include "e-addressbook-marshal.h"
+#include "eab-marshal.h"
#include <gtk/gtksignal.h>
#include <libgnomecanvas/gnome-canvas-rect-ellipse.h>
@@ -172,7 +172,7 @@ e_minicard_label_class_init (EMinicardLabelClass *klass)
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (EMinicardLabelClass, style_set),
NULL, NULL,
- e_addressbook_marshal_VOID__OBJECT,
+ eab_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
GTK_TYPE_STYLE);
diff --git a/addressbook/gui/widgets/e-minicard-view-widget.c b/addressbook/gui/widgets/e-minicard-view-widget.c
index c90a581975..ff1bdc1f06 100644
--- a/addressbook/gui/widgets/e-minicard-view-widget.c
+++ b/addressbook/gui/widgets/e-minicard-view-widget.c
@@ -26,7 +26,7 @@
#include <gal/widgets/e-canvas.h>
#include <libgnome/gnome-i18n.h>
-#include "e-addressbook-marshal.h"
+#include "eab-marshal.h"
#include "e-minicard-view-widget.h"
static void e_minicard_view_widget_init (EMinicardViewWidget *widget);
@@ -38,7 +38,6 @@ static void e_minicard_view_widget_reflow (ECanvas *canvas);
static void e_minicard_view_widget_size_allocate (GtkWidget *widget, GtkAllocation *allocation);
static void e_minicard_view_widget_style_set (GtkWidget *widget, GtkStyle *previous_style);
static void e_minicard_view_widget_realize (GtkWidget *widget);
-static gboolean e_minicard_view_widget_real_focus_in_event (GtkWidget *widget, GdkEventFocus *event);
static ECanvasClass *parent_class = NULL;
@@ -135,7 +134,7 @@ e_minicard_view_widget_class_init (EMinicardViewWidgetClass *klass)
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (EMinicardViewWidgetClass, selection_change),
NULL, NULL,
- e_addressbook_marshal_NONE__NONE,
+ eab_marshal_NONE__NONE,
G_TYPE_NONE, 0);
signals [COLUMN_WIDTH_CHANGED] =
@@ -144,7 +143,7 @@ e_minicard_view_widget_class_init (EMinicardViewWidgetClass *klass)
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (EMinicardViewWidgetClass, column_width_changed),
NULL, NULL,
- e_addressbook_marshal_NONE__DOUBLE,
+ eab_marshal_NONE__DOUBLE,
G_TYPE_NONE, 1, G_TYPE_DOUBLE);
signals [RIGHT_CLICK] =
@@ -153,42 +152,18 @@ e_minicard_view_widget_class_init (EMinicardViewWidgetClass *klass)
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (EMinicardViewWidgetClass, right_click),
NULL, NULL,
- e_addressbook_marshal_INT__POINTER,
+ eab_marshal_INT__POINTER,
G_TYPE_INT, 1, G_TYPE_POINTER);
widget_class->style_set = e_minicard_view_widget_style_set;
widget_class->realize = e_minicard_view_widget_realize;
widget_class->size_allocate = e_minicard_view_widget_size_allocate;
- widget_class->focus_in_event = e_minicard_view_widget_real_focus_in_event;
canvas_class->reflow = e_minicard_view_widget_reflow;
klass->selection_change = NULL;
klass->column_width_changed = NULL;
klass->right_click = NULL;
-
-}
-
-static gboolean
-e_minicard_view_widget_real_focus_in_event(GtkWidget *widget, GdkEventFocus *event)
-{
- GnomeCanvas *canvas;
- EMinicardViewWidget *view;
-
- canvas = GNOME_CANVAS (widget);
- view = E_MINICARD_VIEW_WIDGET(widget);
-
- if (!canvas->focused_item) {
- EReflow *reflow = E_REFLOW (view->emv);
- if (reflow->count) {
- int unsorted = e_sorter_sorted_to_model (E_SORTER (reflow->sorter), 0);
-
- if (unsorted != -1)
- canvas->focused_item = reflow->items [unsorted];
- }
- }
-
- return GTK_WIDGET_CLASS(parent_class)->focus_in_event (widget, event);
}
static void
@@ -326,6 +301,18 @@ selection_change (ESelectionModel *esm, EMinicardViewWidget *widget)
}
static void
+selection_row_change (ESelectionModel *esm, int row, EMinicardViewWidget *widget)
+{
+ gboolean selected = e_selection_model_is_row_selected (esm, row);
+
+ /* we only handle the selected case here */
+ if (!selected)
+ return;
+
+ selection_change (esm, widget);
+}
+
+static void
column_width_changed (ESelectionModel *esm, double width, EMinicardViewWidget *widget)
{
g_signal_emit (widget,
@@ -356,6 +343,7 @@ e_minicard_view_widget_style_set (GtkWidget *widget, GtkStyle *previous_style)
GTK_WIDGET_CLASS(parent_class)->style_set (widget, previous_style);
}
+
static void
e_minicard_view_widget_realize (GtkWidget *widget)
{
@@ -379,6 +367,9 @@ e_minicard_view_widget_realize (GtkWidget *widget)
g_signal_connect (E_REFLOW(view->emv)->selection,
"selection_changed",
G_CALLBACK (selection_change), view);
+ g_signal_connect (E_REFLOW(view->emv)->selection,
+ "selection_row_changed",
+ G_CALLBACK (selection_row_change), view);
g_signal_connect (view->emv,
"column_width_changed",
G_CALLBACK (column_width_changed), view);
diff --git a/addressbook/gui/widgets/e-minicard-view.c b/addressbook/gui/widgets/e-minicard-view.c
index 18c4049e65..3c588c9ef2 100644
--- a/addressbook/gui/widgets/e-minicard-view.c
+++ b/addressbook/gui/widgets/e-minicard-view.c
@@ -23,9 +23,10 @@
#include "e-minicard-view.h"
-#include "e-addressbook-util.h"
+#include "eab-gui-util.h"
+#include "eab-marshal.h"
+#include "util/eab-book-util.h"
-#include "e-addressbook-marshal.h"
#include <gtk/gtkselection.h>
#include <gtk/gtkdnd.h>
#include <gal/widgets/e-canvas.h>
@@ -83,7 +84,7 @@ e_minicard_view_drag_data_get(GtkWidget *widget,
case DND_TARGET_TYPE_VCARD_LIST: {
char *value;
- value = e_card_list_get_vcard(view->drag_list);
+ value = eab_contact_list_to_string (view->drag_list);
gtk_selection_data_set (selection_data,
selection_data->target,
@@ -149,7 +150,7 @@ set_empty_message (EMinicardView *view)
}
static void
-writable_status_change (EAddressbookModel *model, gboolean writable, EMinicardView *view)
+writable_status_change (EABModel *model, gboolean writable, EMinicardView *view)
{
set_empty_message (view);
}
@@ -177,13 +178,12 @@ e_minicard_view_set_property (GObject *object,
case PROP_ADAPTER:
if (view->adapter) {
if (view->writable_status_id) {
- EAddressbookModel *model;
+ EABModel *model;
g_object_get (view->adapter,
"model", &model,
NULL);
if (model) {
g_signal_handler_disconnect (model, view->writable_status_id);
- g_object_unref (model);
}
}
@@ -197,7 +197,7 @@ e_minicard_view_set_property (GObject *object,
"model", view->adapter,
NULL);
if (view->adapter) {
- EAddressbookModel *model;
+ EABModel *model;
g_object_get (view->adapter,
"model", &model,
NULL);
@@ -277,13 +277,12 @@ e_minicard_view_dispose (GObject *object)
if (view->adapter) {
if (view->writable_status_id) {
- EAddressbookModel *model;
+ EABModel *model;
g_object_get (view->adapter,
"model", &model,
NULL);
if (model) {
g_signal_handler_disconnect (model, view->writable_status_id);
- g_object_unref (model);
}
}
@@ -323,10 +322,8 @@ e_minicard_view_event (GnomeCanvasItem *item, GdkEvent *event)
EBook *book;
g_object_get(view, "book", &book, NULL);
- if (book && E_IS_BOOK (book)) {
- e_addressbook_show_contact_editor (book, e_card_new(""), TRUE, editable);
- g_object_unref (book);
- }
+ if (book && E_IS_BOOK (book))
+ eab_show_contact_editor (book, e_contact_new(), TRUE, editable);
}
return TRUE;
}
@@ -391,7 +388,7 @@ static void
do_remove (int i, gpointer user_data)
{
EBook *book;
- ECard *card;
+ EContact *contact;
ViewCbClosure *viewcbclosure = user_data;
EMinicardView *view = viewcbclosure->view;
EBookCallback cb = viewcbclosure->cb;
@@ -401,12 +398,11 @@ do_remove (int i, gpointer user_data)
"book", &book,
NULL);
- card = e_addressbook_reflow_adapter_get_card (view->adapter, i);
+ contact = e_addressbook_reflow_adapter_get_contact (view->adapter, i);
- e_book_remove_card(book, card, cb, closure);
+ e_book_async_remove_contact(book, contact, cb, closure);
- g_object_unref (card);
- g_object_unref (book);
+ g_object_unref (contact);
}
#if 0
@@ -425,13 +421,13 @@ compare_to_utf_str (EMinicard *card, const char *utf_str)
g_object_get(card->card,
"file_as", &file_as,
NULL);
- if (file_as) {
- int cmp = g_utf8_strcasecmp (file_as, utf_str);
- g_free (file_as);
- return cmp;
- }
+ if (file_as)
+ return g_utf8_strcasecmp (file_as, utf_str);
+ else
+ return 0;
+ } else {
+ return 0;
}
- return 0;
}
#endif
@@ -486,7 +482,7 @@ e_minicard_view_class_init (EMinicardViewClass *klass)
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (EMinicardViewClass, right_click),
NULL, NULL,
- e_addressbook_marshal_INT__POINTER,
+ eab_marshal_INT__POINTER,
G_TYPE_INT, 1, G_TYPE_POINTER);
item_class->event = e_minicard_view_event;
@@ -567,7 +563,7 @@ static void
add_to_list (int index, gpointer closure)
{
ModelAndList *mal = closure;
- mal->list = g_list_prepend (mal->list, e_addressbook_reflow_adapter_get_card (mal->adapter, index));
+ mal->list = g_list_prepend (mal->list, e_addressbook_reflow_adapter_get_contact (mal->adapter, index));
}
GList *
diff --git a/addressbook/gui/widgets/e-minicard-widget-test.c b/addressbook/gui/widgets/e-minicard-widget-test.c
deleted file mode 100644
index 9a8d27d21c..0000000000
--- a/addressbook/gui/widgets/e-minicard-widget-test.c
+++ /dev/null
@@ -1,117 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* test-minicard.c
- *
- * Copyright (C) 2000 Ximian, Inc.
- * Author: Chris Lahey <clahey@ximian.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- */
-
-#define TEST_VCARD \
-"BEGIN:VCARD
-" \
-"FN:Nat
-" \
-"N:Friedman;Nat;D;Mr.
-" \
-"ORG:Ximian, Inc.
-" \
-"TITLE:Head Geek
-" \
-"ROLE:Programmer/Executive
-" \
-"BDAY:1977-08-06
-" \
-"TEL;WORK:617 679 1984
-" \
-"TEL;CELL:123 456 7890
-" \
-"EMAIL;INTERNET:nat@nat.org
-" \
-"EMAIL;INTERNET:nat@ximian.com
-" \
-"ADR;WORK;POSTAL:P.O. Box 101;;;Any Town;CA;91921-1234;
-" \
-"ADR;HOME;POSTAL;INTL:P.O. Box 202;;;Any Town 2;MI;12344-4321;USA
-" \
-"END:VCARD
-" \
-"
-"
-
-#include "config.h"
-#include <gtk/gtkmain.h>
-#include <libgnomeui/gnome-app.h>
-#include <libgnomeui/gnome-init.h>
-#include "e-minicard-widget.h"
-
-/* This is a horrible thing to do, but it is just a test. */
-
-static void destroy_callback(gpointer data, GObject *where_object_was)
-{
- exit(0);
-}
-
-#if 0
-static void about_callback( GtkWidget *widget, gpointer data )
-{
-
- const gchar *authors[] =
- {
- "Christopher James Lahey <clahey@umich.edu>",
- NULL
- };
-
- GtkWidget *about =
- gnome_about_new ( _( "Minicard Widget Test" ), VERSION,
- _( "Copyright (C) 2000, Ximian, Inc." ),
- authors,
- _( "This should test the minicard widget" ),
- NULL);
- gtk_widget_show (about);
-}
-#endif
-
-int main( int argc, char *argv[] )
-{
- GtkWidget *app;
- GtkWidget *minicard;
- ECard *card;
-
- /* bindtextdomain (PACKAGE, GNOMELOCALEDIR);
- textdomain (PACKAGE);*/
-
- gnome_init( "Minicard Widget Test", VERSION, argc, argv);
- app = gnome_app_new("Minicard Widget Test", NULL);
-
- minicard = e_minicard_widget_new();
- card = e_card_new(TEST_VCARD);
- g_object_set(minicard,
- "card", card,
- NULL);
-
- gnome_app_set_contents( GNOME_APP( app ), minicard );
-
- /* Connect the signals */
- g_object_weak_ref (app, destroy_callback, app);
-
- gtk_widget_show_all( app );
-
- gtk_main();
-
- /* Not reached. */
- return 0;
-}
diff --git a/addressbook/gui/widgets/e-minicard-widget.c b/addressbook/gui/widgets/e-minicard-widget.c
deleted file mode 100644
index e8f33673c3..0000000000
--- a/addressbook/gui/widgets/e-minicard-widget.c
+++ /dev/null
@@ -1,264 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * e-table-field-chooser.c
- * Copyright (C) 2000 Ximian, Inc.
- * Author: Chris Lahey <clahey@ximian.com>
- *
- * This library 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 library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include <config.h>
-#include <libgnome/gnome-i18n.h>
-#include <libgnomecanvas/gnome-canvas-rect-ellipse.h>
-#include "e-minicard-widget.h"
-#include "e-minicard.h"
-
-static void e_minicard_widget_init (EMinicardWidget *card);
-static void e_minicard_widget_class_init (EMinicardWidgetClass *klass);
-static void e_minicard_widget_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void e_minicard_widget_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
-static void e_minicard_widget_dispose (GObject *object);
-static void e_minicard_widget_size_request (GtkWidget *widget, GtkRequisition *requisition);
-static void e_minicard_widget_size_allocate (GtkWidget *widget, GtkAllocation *allocation);
-static void e_minicard_widget_reflow (ECanvas *canvas);
-
-static ECanvasClass *parent_class = NULL;
-
-/* The arguments we take */
-enum {
- PROP_0,
- PROP_CARD,
-};
-
-GType
-e_minicard_widget_get_type (void)
-{
- static GType type = 0;
-
- if (!type) {
- static const GTypeInfo info = {
- sizeof (EMinicardWidgetClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc) e_minicard_widget_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (EMinicardWidget),
- 0, /* n_preallocs */
- (GInstanceInitFunc) e_minicard_widget_init,
- };
-
- type = g_type_register_static (e_canvas_get_type (), "EMinicardWidget", &info, 0);
- }
-
- return type;
-}
-
-static void
-e_minicard_widget_class_init (EMinicardWidgetClass *klass)
-{
- GObjectClass *object_class;
- GtkWidgetClass *widget_class;
- ECanvasClass *ecanvas_class;
-
- object_class = G_OBJECT_CLASS(klass);
- widget_class = GTK_WIDGET_CLASS(klass);
- ecanvas_class = E_CANVAS_CLASS(klass);
-
- parent_class = g_type_class_peek_parent (klass);
-
- object_class->set_property = e_minicard_widget_set_property;
- object_class->get_property = e_minicard_widget_get_property;
- object_class->dispose = e_minicard_widget_dispose;
-
- widget_class->size_request = e_minicard_widget_size_request;
- widget_class->size_allocate = e_minicard_widget_size_allocate;
-
- ecanvas_class->reflow = e_minicard_widget_reflow;
-
- g_object_class_install_property (object_class, PROP_CARD,
- g_param_spec_object ("card",
- _("Card"),
- /*_( */"XXX blurb" /*)*/,
- E_TYPE_CARD,
- G_PARAM_READWRITE));
-}
-
-static void
-e_minicard_widget_size_request(GtkWidget *widget, GtkRequisition *requisition)
-{
- double height;
- EMinicardWidget *emw = E_MINICARD_WIDGET(widget);
- g_object_get(emw->item,
- "height", &height,
- NULL);
- if (height <= 0)
- height = 1;
- widget->requisition.height = height;
- widget->requisition.width = 200;
- requisition->height = height;
- requisition->width = 200;
-}
-
-static void
-e_minicard_widget_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
-{
- double height;
- EMinicardWidget *emw = E_MINICARD_WIDGET(widget);
- gnome_canvas_item_set( emw->item,
- "width", (double) allocation->width,
- NULL );
- g_object_get(emw->item,
- "height", &height,
- NULL);
- height = MAX(height, allocation->height);
- gnome_canvas_set_scroll_region(GNOME_CANVAS( emw ), 0, 0, allocation->width - 1, height - 1);
- gnome_canvas_item_set( emw->rect,
- "x2", (double) allocation->width,
- "y2", (double) height,
- NULL );
- if (GTK_WIDGET_CLASS(parent_class)->size_allocate)
- GTK_WIDGET_CLASS(parent_class)->size_allocate(widget, allocation);
-}
-
-static void e_minicard_widget_reflow(ECanvas *canvas)
-{
- double height;
- EMinicardWidget *emw = E_MINICARD_WIDGET(canvas);
- g_object_get(emw->item,
- "height", &height,
- NULL);
-
- height = MAX(height, GTK_WIDGET(emw)->allocation.height);
-
- gnome_canvas_set_scroll_region (GNOME_CANVAS(emw), 0, 0, GTK_WIDGET(emw)->allocation.width - 1, height - 1);
- gnome_canvas_item_set( emw->rect,
- "x2", (double) GTK_WIDGET(emw)->allocation.width,
- "y2", (double) height,
- NULL );
-
- gtk_widget_queue_resize(GTK_WIDGET(canvas));
-}
-
-static void
-e_minicard_widget_init (EMinicardWidget *emw)
-{
- emw->rect = gnome_canvas_item_new(gnome_canvas_root(GNOME_CANVAS(emw)),
- gnome_canvas_rect_get_type(),
- "x1", (double) 0,
- "y1", (double) 0,
- "x2", (double) 100,
- "y2", (double) 100,
- "fill_color", "white",
- NULL );
-
- emw->item = gnome_canvas_item_new(gnome_canvas_root(GNOME_CANVAS(emw)),
- e_minicard_get_type(),
- "width", (double) 100,
- NULL );
-
-#if PENDING_PORT_WORK
- /* XXX this crashes since the canvas has no h/v adjustments. */
- gnome_canvas_set_scroll_region ( GNOME_CANVAS( emw ),
- 0, 0,
- 100, 100 );
-#endif
- emw->card = NULL;
-}
-
-static void
-e_minicard_widget_dispose (GObject *object)
-{
- EMinicardWidget *emw = E_MINICARD_WIDGET(object);
-
- if (emw->card) {
- g_object_unref (emw->card);
- emw->card = NULL;
- }
-
- if (G_OBJECT_CLASS(parent_class)->dispose)
- G_OBJECT_CLASS(parent_class)->dispose(object);
-}
-
-GtkWidget*
-e_minicard_widget_new (void)
-{
- GtkWidget *widget = GTK_WIDGET (g_object_new (E_TYPE_MINICARD_WIDGET, NULL));
- return widget;
-}
-
-static void
-e_minicard_widget_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- EMinicardWidget *emw = E_MINICARD_WIDGET(object);
- gpointer ptr;
-
- switch (prop_id){
- case PROP_CARD:
- ptr = g_value_get_object (value);
- e_minicard_widget_set_card (emw, ptr ? E_CARD (ptr) : NULL);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-e_minicard_widget_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- EMinicardWidget *emw = E_MINICARD_WIDGET(object);
-
- switch (prop_id) {
- case PROP_CARD:
- if (emw->card)
- g_value_set_object (value, emw->card);
- else
- g_value_set_object (value, NULL);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-void
-e_minicard_widget_set_card (EMinicardWidget *emw, ECard *card)
-{
- g_return_if_fail (emw && E_IS_MINICARD_WIDGET (emw));
- g_return_if_fail (card == NULL || E_IS_CARD (card));
-
- if (card != emw->card) {
-
- if (emw->card)
- g_object_unref (emw->card);
-
- emw->card = card;
-
- if (emw->card)
- g_object_ref (emw->card);
-
- if (emw->item)
- g_object_set (emw->item,
- "card", emw->card,
- NULL);
- }
-}
diff --git a/addressbook/gui/widgets/e-minicard-widget.h b/addressbook/gui/widgets/e-minicard-widget.h
deleted file mode 100644
index 829ad8f77d..0000000000
--- a/addressbook/gui/widgets/e-minicard-widget.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* e-minicard-widget.h
- * Copyright (C) 2000 Ximian, Inc.
- * Author: Chris Lahey <clahey@ximian.com>
- *
- * This library 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 library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-#ifndef __E_MINICARD_WIDGET_H__
-#define __E_MINICARD_WIDGET_H__
-
-#include <gal/widgets/e-canvas.h>
-#include "addressbook/backend/ebook/e-card.h"
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus */
-
-/* EMinicardWidget - A card displaying information about a contact.
- *
- * The following arguments are available:
- *
- * name type read/write description
- * --------------------------------------------------------------------------------
- */
-
-#define E_TYPE_MINICARD_WIDGET (e_minicard_widget_get_type ())
-#define E_MINICARD_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_MINICARD_WIDGET, EMinicardWidget))
-#define E_MINICARD_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_MINICARD_WIDGET, EMinicardWidgetClass))
-#define E_IS_MINICARD_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_MINICARD_WIDGET))
-#define E_IS_MINICARD_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_MINICARD_WIDGET))
-
-
-typedef struct _EMinicardWidget EMinicardWidget;
-typedef struct _EMinicardWidgetClass EMinicardWidgetClass;
-
-struct _EMinicardWidget
-{
- ECanvas parent;
-
- /* item specific fields */
- GnomeCanvasItem *item;
-
- GnomeCanvasItem *rect;
- ECard *card;
-};
-
-struct _EMinicardWidgetClass
-{
- ECanvasClass parent_class;
-};
-
-
-GtkWidget *e_minicard_widget_new(void);
-GType e_minicard_widget_get_type (void);
-
-void e_minicard_widget_set_card (EMinicardWidget *, ECard *);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-
-#endif /* __E_MINICARD_WIDGET_H__ */
diff --git a/addressbook/gui/widgets/e-minicard.c b/addressbook/gui/widgets/e-minicard.c
index 7ce6d2f518..f9aa893dc3 100644
--- a/addressbook/gui/widgets/e-minicard.c
+++ b/addressbook/gui/widgets/e-minicard.c
@@ -33,14 +33,13 @@
#include <gal/widgets/e-canvas-utils.h>
#include <gal/widgets/e-canvas.h>
#include "addressbook/backend/ebook/e-book.h"
-#include "e-addressbook-marshal.h"
-#include "e-addressbook-util.h"
+#include "eab-marshal.h"
+#include "eab-gui-util.h"
#include "e-minicard.h"
#include "e-minicard-label.h"
#include "e-minicard-view.h"
#include "e-contact-editor.h"
-#include "e-card-merging.h"
-#include "ebook/e-destination.h"
+#include "util/eab-destination.h"
static void e_minicard_init (EMinicard *card);
static void e_minicard_class_init (EMinicardClass *klass);
@@ -64,7 +63,7 @@ static GnomeCanvasGroupClass *parent_class = NULL;
typedef struct _EMinicardField EMinicardField;
struct _EMinicardField {
- ECardSimpleField field;
+ EContactField field;
GnomeCanvasItem *label;
};
@@ -90,7 +89,7 @@ enum {
PROP_SELECTED,
PROP_HAS_CURSOR,
PROP_EDITABLE,
- PROP_CARD
+ PROP_CONTACT
};
enum {
@@ -185,11 +184,11 @@ e_minicard_class_init (EMinicardClass *klass)
FALSE,
G_PARAM_READWRITE));
- g_object_class_install_property (object_class, PROP_CARD,
- g_param_spec_object ("card",
- _("Card"),
+ g_object_class_install_property (object_class, PROP_CONTACT,
+ g_param_spec_object ("contact",
+ _("Contact"),
/*_( */"XXX blurb" /*)*/,
- E_TYPE_CARD,
+ E_TYPE_CONTACT,
G_PARAM_READWRITE));
e_minicard_signals [SELECTED] =
@@ -198,7 +197,7 @@ e_minicard_class_init (EMinicardClass *klass)
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (EMinicardClass, selected),
NULL, NULL,
- e_addressbook_marshal_INT__POINTER,
+ eab_marshal_INT__POINTER,
G_TYPE_INT, 1, G_TYPE_POINTER);
e_minicard_signals [DRAG_BEGIN] =
@@ -207,7 +206,7 @@ e_minicard_class_init (EMinicardClass *klass)
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (EMinicardClass, drag_begin),
NULL, NULL,
- e_addressbook_marshal_INT__POINTER,
+ eab_marshal_INT__POINTER,
G_TYPE_INT, 1, G_TYPE_POINTER);
e_minicard_signals [STYLE_SET] =
@@ -216,7 +215,7 @@ e_minicard_class_init (EMinicardClass *klass)
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (EMinicardClass, style_set),
NULL, NULL,
- e_addressbook_marshal_VOID__OBJECT,
+ eab_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
GTK_TYPE_STYLE);
@@ -231,7 +230,6 @@ e_minicard_class_init (EMinicardClass *klass)
static void
e_minicard_init (EMinicard *minicard)
{
- /* minicard->card = NULL;*/
minicard->rect = NULL;
minicard->fields = NULL;
minicard->width = 10;
@@ -241,8 +239,7 @@ e_minicard_init (EMinicard *minicard)
minicard->editable = FALSE;
minicard->has_cursor = FALSE;
- minicard->card = NULL;
- minicard->simple = e_card_simple_new(NULL);
+ minicard->contact = NULL;
minicard->list_icon_pixbuf = gdk_pixbuf_new_from_file (EVOLUTION_IMAGESDIR "/" LIST_ICON_FILENAME, NULL);
minicard->list_icon_size = gdk_pixbuf_get_height (minicard->list_icon_pixbuf);
@@ -344,15 +341,12 @@ e_minicard_set_property (GObject *object, guint prop_id, const GValue *value, G
if (e_minicard->has_cursor != g_value_get_boolean (value))
set_has_cursor (e_minicard, g_value_get_boolean (value));
break;
- case PROP_CARD:
- if (e_minicard->card)
- g_object_unref (e_minicard->card);
- e_minicard->card = E_CARD(g_value_get_object (value));
- if (e_minicard->card)
- g_object_ref (e_minicard->card);
- g_object_set(e_minicard->simple,
- "card", e_minicard->card,
- NULL);
+ case PROP_CONTACT:
+ if (e_minicard->contact)
+ g_object_unref (e_minicard->contact);
+ e_minicard->contact = E_CONTACT(g_value_get_object (value));
+ if (e_minicard->contact)
+ g_object_ref (e_minicard->contact);
remodel(e_minicard);
e_canvas_item_request_reflow(item);
e_minicard->changed = FALSE;
@@ -389,9 +383,8 @@ e_minicard_get_property (GObject *object, guint prop_id, GValue *value, GParamS
case PROP_EDITABLE:
g_value_set_boolean (value, e_minicard->editable);
break;
- case PROP_CARD:
- e_card_simple_sync_card(e_minicard->simple);
- g_value_set_object (value, e_minicard->card);
+ case PROP_CONTACT:
+ g_value_set_object (value, e_minicard->contact);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -436,10 +429,8 @@ e_minicard_finalize (GObject *object)
e_minicard = E_MINICARD (object);
- if (e_minicard->card)
- g_object_unref (e_minicard->card);
- if (e_minicard->simple)
- g_object_unref (e_minicard->simple);
+ if (e_minicard->contact)
+ g_object_unref (e_minicard->contact);
if (G_OBJECT_CLASS (parent_class)->finalize)
(* G_OBJECT_CLASS (parent_class)->finalize) (object);
@@ -523,14 +514,6 @@ e_minicard_unrealize (GnomeCanvasItem *item)
(* GNOME_CANVAS_ITEM_CLASS(parent_class)->unrealize) (item);
}
-static void
-card_modified_cb (EBook* book, EBookStatus status, gpointer user_data)
-{
- d(g_print ("%s: %s(): a card was modified\n", __FILE__, G_GNUC_FUNCTION));
- if (status != E_BOOK_STATUS_SUCCESS)
- e_addressbook_error_dialog (_("Error modifying card"), status);
-}
-
/* Callback used when the contact editor is closed */
static void
editor_closed_cb (GtkObject *editor, gpointer data)
@@ -560,35 +543,8 @@ e_minicard_event (GnomeCanvasItem *item, GdkEvent *event)
if (!e_minicard->selected) {
e_minicard_selected(e_minicard, event);
}
- } else {
- EBook *book = NULL;
-
- if (e_minicard->changed) {
-
- e_card_simple_sync_card(e_minicard->simple);
-
- if (E_IS_MINICARD_VIEW(GNOME_CANVAS_ITEM(e_minicard)->parent)) {
-
- g_object_get(GNOME_CANVAS_ITEM(e_minicard)->parent,
- "book", &book,
- NULL);
-
- }
-
- if (book) {
-
- /* Add the card in the contact editor to our ebook */
- e_card_merging_book_commit_card (book,
- e_minicard->card,
- card_modified_cb,
- NULL);
- g_object_unref(book);
- } else {
- remodel(e_minicard);
- e_canvas_item_request_reflow(GNOME_CANVAS_ITEM(e_minicard));
- }
- e_minicard->changed = FALSE;
- }
+ }
+ else {
e_minicard->has_focus = FALSE;
}
}
@@ -651,7 +607,7 @@ e_minicard_event (GnomeCanvasItem *item, GdkEvent *event)
case GDK_2BUTTON_PRESS:
if (event->button.button == 1 && E_IS_MINICARD_VIEW(item->parent)) {
if (e_minicard->editor) {
- if (e_card_evolution_list (e_minicard->card))
+ if (GPOINTER_TO_INT (e_contact_get (e_minicard->contact, E_CONTACT_IS_LIST)))
e_contact_list_editor_raise (E_CONTACT_LIST_EDITOR(e_minicard->editor));
else
e_contact_editor_raise(E_CONTACT_EDITOR(e_minicard->editor));
@@ -664,14 +620,14 @@ e_minicard_event (GnomeCanvasItem *item, GdkEvent *event)
}
if (book != NULL) {
- if (e_card_evolution_list (e_minicard->card)) {
- EContactListEditor *editor = e_addressbook_show_contact_list_editor (book, e_minicard->card,
- FALSE, e_minicard->editable);
+ if (e_contact_get (e_minicard->contact, E_CONTACT_IS_LIST)) {
+ EContactListEditor *editor = eab_show_contact_list_editor (book, e_minicard->contact,
+ FALSE, e_minicard->editable);
e_minicard->editor = G_OBJECT (editor);
}
else {
- EContactEditor *editor = e_addressbook_show_contact_editor (book, e_minicard->card,
- FALSE, e_minicard->editable);
+ EContactEditor *editor = eab_show_contact_editor (book, e_minicard->contact,
+ FALSE, e_minicard->editable);
e_minicard->editor = G_OBJECT (editor);
}
g_object_ref (e_minicard->editor);
@@ -685,36 +641,6 @@ e_minicard_event (GnomeCanvasItem *item, GdkEvent *event)
return TRUE;
}
break;
- case GDK_KEY_PRESS:
- if (event->key.keyval == GDK_Tab ||
- event->key.keyval == GDK_KP_Tab ||
- event->key.keyval == GDK_ISO_Left_Tab) {
- GList *list;
- for (list = e_minicard->fields; list; list = list->next) {
- EMinicardField *field = E_MINICARD_FIELD(list->data);
- GnomeCanvasItem *item = field->label;
- EFocus has_focus;
- g_object_get(item,
- "has_focus", &has_focus,
- NULL);
- if (has_focus != E_FOCUS_NONE) {
- if (event->key.state & GDK_SHIFT_MASK)
- list = list->prev;
- else
- list = list->next;
- if (list) {
- EMinicardField *field = E_MINICARD_FIELD(list->data);
- GnomeCanvasItem *item = field->label;
- gnome_canvas_item_set(item,
- "has_focus", (event->key.state & GDK_SHIFT_MASK) ? E_FOCUS_END : E_FOCUS_START,
- NULL);
- return 1;
- } else {
- return 0;
- }
- }
- }
- }
default:
break;
}
@@ -729,11 +655,12 @@ static void
e_minicard_resize_children( EMinicard *e_minicard )
{
GList *list;
-
+ gboolean is_list = GPOINTER_TO_INT (e_contact_get (e_minicard->contact, E_CONTACT_IS_LIST));
+
if (e_minicard->header_text) {
gnome_canvas_item_set( e_minicard->header_text,
"width", ((double) e_minicard->width - 12
- - (e_card_evolution_list (e_minicard->card) ? e_minicard->list_icon_size : 0.0)),
+ - (is_list ? e_minicard->list_icon_size : 0.0)),
NULL );
}
if (e_minicard->list_icon) {
@@ -749,79 +676,24 @@ e_minicard_resize_children( EMinicard *e_minicard )
}
static void
-field_changed (EText *text, EMinicard *e_minicard)
-{
- ECardSimpleType type;
- char *string;
- char *new_string;
- gboolean is_list = FALSE;
-
- type = GPOINTER_TO_INT
- (g_object_get_data(G_OBJECT(text),
- "EMinicard:field"));
- g_object_get(text,
- "text", &string,
- NULL);
-
- /*
- * If the card is coresponding with a contact list and the field be
- * changed is e-mail address, should wrap it before write it back.
- */
- new_string = (char*)e_card_simple_get_const (e_minicard->simple,
- E_CARD_SIMPLE_FIELD_IS_LIST);
-
- is_list = (NULL != new_string);
-
- if (is_list && (E_CARD_SIMPLE_FIELD_EMAIL == type ||
- E_CARD_SIMPLE_FIELD_EMAIL_2 == type ||
- E_CARD_SIMPLE_FIELD_EMAIL_3 == type)) {
- if (string && *string) {
- EDestination *dest = e_destination_new ();
- if (dest != NULL){
- e_destination_set_email (dest, string);
- new_string = e_destination_export(dest);
- g_free(string);
- string=new_string;
- g_object_unref (dest);
- }
- }
- }
-
- e_card_simple_set(e_minicard->simple,
- type,
- string);
- g_free(string);
- e_minicard->changed = TRUE;
-}
-
-static void
-field_activated (EText *text, EMinicard *e_minicard)
-{
- e_text_stop_editing (text);
- e_canvas_item_grab_focus (GNOME_CANVAS_ITEM (e_minicard), FALSE);
-}
-
-static void
-add_field (EMinicard *e_minicard, ECardSimpleField field, gdouble left_width)
+add_field (EMinicard *e_minicard, EContactField field, gdouble left_width)
{
GnomeCanvasItem *new_item;
GnomeCanvasGroup *group;
- ECardSimpleType type;
EMinicardField *minicard_field;
char *name;
char *string;
group = GNOME_CANVAS_GROUP( e_minicard );
- type = e_card_simple_type(e_minicard->simple, field);
- name = g_strdup_printf("%s:", e_card_simple_get_name(e_minicard->simple, field));
- string = e_card_simple_get(e_minicard->simple, field);
+ name = g_strdup_printf("%s:", e_contact_pretty_name (field));
+ string = e_contact_get (e_minicard->contact, field);
/* Magically convert embedded XML into an address. */
if (!strncmp (string, "<?xml", 5)) {
- EDestination *dest = e_destination_import (string);
+ EABDestination *dest = eab_destination_import (string);
if (dest != NULL) {
- gchar *new_string = g_strdup (e_destination_get_textrep (dest, TRUE));
+ gchar *new_string = g_strdup (eab_destination_get_textrep (dest, TRUE));
g_free (string);
string = new_string;
g_object_unref (dest);
@@ -834,15 +706,13 @@ add_field (EMinicard *e_minicard, ECardSimpleField field, gdouble left_width)
"fieldname", name,
"field", string,
"max_field_name_length", left_width,
- "editable", e_minicard->editable,
+ "editable", FALSE,
NULL );
- g_signal_connect(E_MINICARD_LABEL(new_item)->field,
- "changed", G_CALLBACK (field_changed), e_minicard);
- g_signal_connect(E_MINICARD_LABEL(new_item)->field,
- "activate", G_CALLBACK (field_activated), e_minicard);
+#if notyet
g_object_set(E_MINICARD_LABEL(new_item)->field,
- "allow_newlines", e_card_simple_get_allow_newlines (e_minicard->simple, field),
+ "allow_newlines", e_card_simple_get_allow_newlines (e_minicard->contact, field),
NULL);
+#endif
g_object_set_data(G_OBJECT (E_MINICARD_LABEL(new_item)->field),
"EMinicard:field",
GINT_TO_POINTER(field));
@@ -861,14 +731,18 @@ static int
get_left_width(EMinicard *e_minicard)
{
gchar *name;
- ECardSimpleField field;
+ EContactField field;
int width = -1;
PangoLayout *layout;
layout = gtk_widget_create_pango_layout (GTK_WIDGET (GNOME_CANVAS_ITEM (e_minicard)->canvas), "");
- for(field = E_CARD_SIMPLE_FIELD_FULL_NAME; field != E_CARD_SIMPLE_FIELD_LAST; field++) {
+ for(field = E_CONTACT_FULL_NAME; field != E_CONTACT_LAST_SIMPLE_STRING; field++) {
int this_width;
- name = g_strdup_printf("%s:", e_card_simple_get_name(e_minicard->simple, field));
+
+ if (field == E_CONTACT_FAMILY_NAME || field == E_CONTACT_GIVEN_NAME)
+ continue;
+
+ name = g_strdup_printf("%s:", e_contact_pretty_name (field));
pango_layout_set_text (layout, name, -1);
pango_layout_get_pixel_size (layout, &this_width, NULL);
if (width < this_width)
@@ -885,46 +759,47 @@ remodel( EMinicard *e_minicard )
int count = 0;
if ( !(GTK_OBJECT_FLAGS( e_minicard ) & GNOME_CANVAS_ITEM_REALIZED) )
return;
- if (e_minicard->simple) {
- ECardSimpleField field;
+ if (e_minicard->contact) {
+ EContactField field;
GList *list;
char *file_as;
int left_width = -1;
if (e_minicard->header_text) {
- file_as = e_card_simple_get(e_minicard->simple, E_CARD_SIMPLE_FIELD_FILE_AS);
- gnome_canvas_item_set( e_minicard->header_text,
+ file_as = e_contact_get (e_minicard->contact, E_CONTACT_FILE_AS);
+ gnome_canvas_item_set (e_minicard->header_text,
"text", file_as ? file_as : "",
NULL );
g_free(file_as);
}
- if (e_minicard->card && e_card_evolution_list (e_minicard->card) ) {
+ if (e_minicard->contact && e_contact_get (e_minicard->contact, E_CONTACT_IS_LIST))
gnome_canvas_item_show (e_minicard->list_icon);
- }
- else {
+ else
gnome_canvas_item_hide (e_minicard->list_icon);
- }
list = e_minicard->fields;
e_minicard->fields = NULL;
- for(field = E_CARD_SIMPLE_FIELD_FULL_NAME; field != E_CARD_SIMPLE_FIELD_LAST_SIMPLE_STRING && count < 5; field++) {
+ for(field = E_CONTACT_FULL_NAME; field != E_CONTACT_LAST_SIMPLE_STRING && count < 5; field++) {
EMinicardField *minicard_field = NULL;
+ if (field == E_CONTACT_FAMILY_NAME || field == E_CONTACT_GIVEN_NAME)
+ continue;
+
if (list)
minicard_field = list->data;
if (minicard_field && minicard_field->field == field) {
GList *this_list = list;
char *string;
- string = e_card_simple_get(e_minicard->simple, field);
+ string = e_contact_get(e_minicard->contact, field);
if (string && *string) {
/* Magically convert embedded XML into an address. */
if (!strncmp (string, "<?xml", 4)) {
- EDestination *dest = e_destination_import (string);
+ EABDestination *dest = eab_destination_import (string);
if (dest != NULL) {
- gchar *new_string = g_strdup (e_destination_get_textrep (dest, TRUE));
+ gchar *new_string = g_strdup (eab_destination_get_textrep (dest, TRUE));
g_free (string);
string = new_string;
g_object_unref (dest);
@@ -948,7 +823,7 @@ remodel( EMinicard *e_minicard )
left_width = get_left_width(e_minicard);
}
- string = e_card_simple_get(e_minicard->simple, field);
+ string = e_contact_get(e_minicard->contact, field);
if (string && *string) {
add_field(e_minicard, field, left_width);
count++;
@@ -1013,8 +888,8 @@ e_minicard_get_card_id (EMinicard *minicard)
g_return_val_if_fail(minicard != NULL, NULL);
g_return_val_if_fail(E_IS_MINICARD(minicard), NULL);
- if (minicard->card) {
- return e_card_get_id(minicard->card);
+ if (minicard->contact) {
+ return e_contact_get_const (minicard->contact, E_CONTACT_UID);
} else {
return "";
}
@@ -1030,13 +905,12 @@ e_minicard_compare (EMinicard *minicard1, EMinicard *minicard2)
g_return_val_if_fail(minicard2 != NULL, 0);
g_return_val_if_fail(E_IS_MINICARD(minicard2), 0);
- if (minicard1->card && minicard2->card) {
+ if (minicard1->contact && minicard2->contact) {
char *file_as1, *file_as2;
-
- g_object_get(minicard1->card,
+ g_object_get(minicard1->contact,
"file_as", &file_as1,
NULL);
- g_object_get(minicard2->card,
+ g_object_get(minicard2->contact,
"file_as", &file_as2,
NULL);
diff --git a/addressbook/gui/widgets/e-minicard.h b/addressbook/gui/widgets/e-minicard.h
index ac0f82e46c..e4673fe4d9 100644
--- a/addressbook/gui/widgets/e-minicard.h
+++ b/addressbook/gui/widgets/e-minicard.h
@@ -23,8 +23,7 @@
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "addressbook/gui/contact-editor/e-contact-editor.h"
#include <libgnomecanvas/gnome-canvas.h>
-#include "addressbook/backend/ebook/e-card.h"
-#include "addressbook/backend/ebook/e-card-simple.h"
+#include "addressbook/backend/ebook/e-contact.h"
#ifdef __cplusplus
extern "C" {
@@ -63,8 +62,7 @@ struct _EMinicard
GnomeCanvasGroup parent;
/* item specific fields */
- ECard *card;
- ECardSimple *simple;
+ EContact *contact;
GnomeCanvasItem *rect;
GnomeCanvasItem *header_rect;
diff --git a/addressbook/gui/widgets/eab-contact-display.c b/addressbook/gui/widgets/eab-contact-display.c
new file mode 100644
index 0000000000..3de6eac380
--- /dev/null
+++ b/addressbook/gui/widgets/eab-contact-display.c
@@ -0,0 +1,486 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Authors: Chris Toshok <toshok@ximian.com>
+ *
+ * Copyright (C) 2003 Ximian, Inc. (www.ximian.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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 Street #330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include "eab-contact-display.h"
+
+#include "e-util/e-html-utils.h"
+#include "util/eab-destination.h"
+
+#include <string.h>
+#include <libgnome/gnome-i18n.h>
+#include <libgnome/gnome-url.h>
+#include <gtkhtml/gtkhtml.h>
+#include <gtkhtml/gtkhtml-stream.h>
+
+#define PARENT_TYPE (gtk_vbox_get_type ())
+
+struct _EABContactDisplayPrivate {
+ GtkHTML *html;
+ EContact *contact;
+};
+
+
+#define HTML_HEADER "<!doctype html public \"-//W3C//DTD HTML 4.0 TRANSITIONAL//EN\">\n<html>\n" \
+ "<head>\n<meta name=\"generator\" content=\"Evolution Addressbook Component\">\n</head>\n"
+
+#define MAX_COMPACT_IMAGE_DIMENSION 48
+
+static void
+on_url_requested (GtkHTML *html, const char *url, GtkHTMLStream *handle,
+ EABContactDisplay *display)
+{
+ printf ("on_url_requested (%s)\n", url);
+ if (!strcmp (url, "internal-contact-photo:")) {
+ EContactPhoto *photo;
+
+ photo = e_contact_get (display->priv->contact, E_CONTACT_PHOTO);
+ if (!photo)
+ photo = e_contact_get (display->priv->contact, E_CONTACT_LOGO);
+
+ printf ("writing a photo of length %d\n", photo->length);
+
+ gtk_html_stream_write (handle, photo->data, photo->length);
+
+ gtk_html_end (html, handle, GTK_HTML_STREAM_OK);
+ }
+}
+
+static void
+on_link_clicked (GtkHTML *html, const char *url, EABContactDisplay *display)
+{
+ GError *err = NULL;
+
+ gnome_url_show (url, &err);
+
+ if (err) {
+ g_warning ("gnome_url_show: %s", err->message);
+ g_error_free (err);
+ }
+}
+
+static void
+render_address (GtkHTMLStream *html_stream, EContact *contact, const char *html_label, EContactField adr_field, EContactField label_field)
+{
+ EContactAddress *adr;
+ const char *label;
+
+ label = e_contact_get_const (contact, label_field);
+ if (label) {
+ char *html = e_text_to_html (label, E_TEXT_TO_HTML_CONVERT_NL);
+
+ gtk_html_stream_printf (html_stream, "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr valign=\"top\"><td>");
+ gtk_html_stream_printf (html_stream, "<b>%s:</b>&nbsp;<td>%s<br>", html_label, html);
+
+ gtk_html_stream_printf (html_stream, "<a href=\"http://www.mapquest.com/\">%s</a>", _("Map It"));
+ gtk_html_stream_printf (html_stream, "</td></tr></table>");
+ g_free (html);
+ return;
+ }
+
+ adr = e_contact_get (contact, adr_field);
+ if (adr &&
+ (adr->po || adr->ext || adr->street || adr->locality || adr->region || adr->code || adr->country)) {
+
+ gtk_html_stream_printf (html_stream, "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr valign=\"top\"><td>");
+ gtk_html_stream_printf (html_stream, "<b>%s:</b>&nbsp;<td>", html_label);
+
+ if (adr->po && *adr->po) gtk_html_stream_printf (html_stream, "%s<br>", adr->po);
+ if (adr->ext && *adr->ext) gtk_html_stream_printf (html_stream, "%s<br>", adr->ext);
+ if (adr->street && *adr->street) gtk_html_stream_printf (html_stream, "%s<br>", adr->street);
+ if (adr->locality && *adr->locality) gtk_html_stream_printf (html_stream, "%s<br>", adr->locality);
+ if (adr->region && *adr->region) gtk_html_stream_printf (html_stream, "%s<br>", adr->region);
+ if (adr->code && *adr->code) gtk_html_stream_printf (html_stream, "%s<br>", adr->code);
+ if (adr->country && *adr->country) gtk_html_stream_printf (html_stream, "%s<br>", adr->country);
+
+ gtk_html_stream_printf (html_stream, "<a href=\"http://www.mapquest.com/\">%s</a>", _("Map It"));
+ gtk_html_stream_printf (html_stream, "</td></tr></table>");
+ }
+ if (adr)
+ e_contact_address_free (adr);
+}
+
+static void
+render_string (GtkHTMLStream *html_stream, EContact *contact, const char *html_label, EContactField field)
+{
+ const char *str;
+
+ str = e_contact_get_const (contact, field);
+
+ if (str && *str) {
+ char *html = e_text_to_html (str, 0);
+ gtk_html_stream_printf (html_stream, "<b>%s:</b> %s<br>", html_label, str);
+ g_free (html);
+ }
+}
+
+static void
+render_url (GtkHTMLStream *html_stream, EContact *contact, const char *html_label, EContactField field)
+{
+ const char *str;
+ str = e_contact_get_const (contact, field);
+ if (str && *str) {
+ char *html = e_text_to_html (str, E_TEXT_TO_HTML_CONVERT_URLS);
+ gtk_html_stream_printf (html_stream, "<b>%s:</b> %s<br>",
+ html_label, html);
+ g_free (html);
+ }
+}
+
+static void
+eab_contact_display_render_normal (EABContactDisplay *display, EContact *contact)
+{
+ GtkHTMLStream *html_stream;
+
+ if (display->priv->contact)
+ g_object_unref (display->priv->contact);
+ display->priv->contact = contact;
+ if (display->priv->contact)
+ g_object_ref (display->priv->contact);
+
+ html_stream = gtk_html_begin (display->priv->html);
+ gtk_html_stream_write (html_stream, HTML_HEADER, sizeof (HTML_HEADER) - 1);
+ gtk_html_stream_write (html_stream, "<body>\n", 7);
+
+ if (contact) {
+ char *str, *html;
+ EContactPhoto *photo;
+
+ gtk_html_stream_printf (html_stream, "<table border=\"0\" valign=\"top\"><tr valign=\"top\"><td>");
+ photo = e_contact_get (contact, E_CONTACT_PHOTO);
+ if (!photo)
+ photo = e_contact_get (contact, E_CONTACT_LOGO);
+ if (photo) {
+ gtk_html_stream_printf (html_stream, "<img src=\"internal-contact-photo:\">");
+ e_contact_photo_free (photo);
+ }
+
+ gtk_html_stream_printf (html_stream, "</td><td>\n");
+
+ str = e_contact_get_const (contact, E_CONTACT_FILE_AS);
+ if (str) {
+ html = e_text_to_html (str, 0);
+ gtk_html_stream_printf (html_stream, "<h2>%s</h2>", html);
+ g_free (html);
+ }
+ else {
+ str = e_contact_get_const (contact, E_CONTACT_FULL_NAME);
+ if (str) {
+ html = e_text_to_html (str, 0);
+ gtk_html_stream_printf (html_stream, "<h2>%s</h2>", html);
+ g_free (html);
+ }
+ }
+
+ if (e_contact_get (contact, E_CONTACT_IS_LIST)) {
+ GList *email_list;
+ GList *l;
+
+ gtk_html_stream_printf (html_stream, "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr valign=\"top\"><td>");
+ gtk_html_stream_printf (html_stream, "<b>%s:</b>&nbsp;<td>", _("List Members"));
+
+ email_list = e_contact_get (contact, E_CONTACT_EMAIL);
+ for (l = email_list; l; l = l->next) {
+ EABDestination *dest = eab_destination_import (l->data);
+ if (dest) {
+ const char *textrep = eab_destination_get_textrep (dest, TRUE);
+ char *html = e_text_to_html (textrep, 0);
+ gtk_html_stream_printf (html_stream, "%s<br>", html);
+ g_free (html);
+ g_object_unref (dest);
+ }
+ }
+ gtk_html_stream_printf (html_stream, "</td></tr></table>");
+ }
+ else {
+ render_string (html_stream, contact, _("Job Title"), E_CONTACT_TITLE);
+
+ render_string (html_stream, contact, _("Email"), E_CONTACT_EMAIL_1);
+ render_string (html_stream, contact, _("Email"), E_CONTACT_EMAIL_2);
+ render_string (html_stream, contact, _("Email"), E_CONTACT_EMAIL_3);
+
+
+ render_address (html_stream, contact, _("Home Address"), E_CONTACT_ADDRESS_HOME, E_CONTACT_ADDRESS_LABEL_HOME);
+ render_address (html_stream, contact, _("Work Address"), E_CONTACT_ADDRESS_WORK, E_CONTACT_ADDRESS_LABEL_WORK);
+ render_address (html_stream, contact, _("Other Address"), E_CONTACT_ADDRESS_OTHER, E_CONTACT_ADDRESS_LABEL_OTHER);
+
+ gtk_html_stream_printf (html_stream, "<hr>");
+
+ render_url (html_stream, contact, _("Home page"), E_CONTACT_HOMEPAGE_URL);
+ render_url (html_stream, contact, _("Blog"), E_CONTACT_BLOG_URL);
+
+ }
+
+ gtk_html_stream_printf (html_stream, "</td></tr></table>\n");
+ }
+
+ gtk_html_stream_write (html_stream, "</body></html>\n", 15);
+ gtk_html_end (display->priv->html, html_stream, GTK_HTML_STREAM_OK);
+}
+
+static void
+eab_contact_display_render_compact (EABContactDisplay *display, EContact *contact)
+{
+ GtkHTMLStream *html_stream;
+
+ if (display->priv->contact)
+ g_object_unref (display->priv->contact);
+ display->priv->contact = contact;
+ if (display->priv->contact)
+ g_object_ref (display->priv->contact);
+
+ html_stream = gtk_html_begin (display->priv->html);
+ gtk_html_stream_write (html_stream, HTML_HEADER, sizeof (HTML_HEADER) - 1);
+ gtk_html_stream_write (html_stream, "<body>\n", 7);
+
+ if (contact) {
+ char *str, *html;
+ EContactPhoto *photo;
+
+ gtk_html_stream_printf (html_stream,
+ "<table width=\"100%%\" cellpadding=1 cellspacing=0 bgcolor=\"#000000\">"
+ "<tr><td>"
+ "<table width=\"100%%\" cellpadding=0 cellspacing=0 bgcolor=\"#eeeeee\">"
+ "<tr><td>"
+ "<table>"
+ "<tr valign=\"top\"><td>");
+
+ photo = e_contact_get (contact, E_CONTACT_PHOTO);
+ if (!photo)
+ photo = e_contact_get (contact, E_CONTACT_LOGO);
+ if (photo) {
+ int calced_width = MAX_COMPACT_IMAGE_DIMENSION, calced_height = MAX_COMPACT_IMAGE_DIMENSION;
+ GdkPixbufLoader *loader = gdk_pixbuf_loader_new ();
+ GdkPixbuf *pixbuf;
+
+ /* figure out if we need to downscale the
+ image here. we don't scale the pixbuf
+ itself, just insert width/height tags in
+ the html */
+ gdk_pixbuf_loader_write (loader, photo->data, photo->length, NULL);
+ pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
+ gdk_pixbuf_loader_close (loader, NULL);
+ g_object_unref (loader);
+ if (pixbuf) {
+ int max_dimension = gdk_pixbuf_get_height (pixbuf);
+ if (max_dimension < gdk_pixbuf_get_width (pixbuf))
+ max_dimension = gdk_pixbuf_get_width (pixbuf);
+
+ calced_width = (float)gdk_pixbuf_get_width (pixbuf) / max_dimension * MAX_COMPACT_IMAGE_DIMENSION;
+ calced_height = (float)gdk_pixbuf_get_height (pixbuf) / max_dimension * MAX_COMPACT_IMAGE_DIMENSION;
+
+ calced_width = MIN (calced_width, MAX_COMPACT_IMAGE_DIMENSION);
+ calced_height = MIN (calced_height, MAX_COMPACT_IMAGE_DIMENSION);
+ }
+
+ gdk_pixbuf_unref (pixbuf);
+ gtk_html_stream_printf (html_stream, "<img width=\"%d\" height=\"%d\" src=\"internal-contact-photo:\">",
+ calced_width, calced_height);
+ e_contact_photo_free (photo);
+ }
+
+ gtk_html_stream_printf (html_stream, "</td><td>\n");
+
+ str = e_contact_get_const (contact, E_CONTACT_FILE_AS);
+ if (str) {
+ html = e_text_to_html (str, 0);
+ gtk_html_stream_printf (html_stream, "<b>%s</b>", html);
+ g_free (html);
+ }
+ else {
+ str = e_contact_get_const (contact, E_CONTACT_FULL_NAME);
+ if (str) {
+ html = e_text_to_html (str, 0);
+ gtk_html_stream_printf (html_stream, "<b>%s</b>", html);
+ g_free (html);
+ }
+ }
+
+ gtk_html_stream_write (html_stream, "<hr>", 4);
+
+ if (e_contact_get (contact, E_CONTACT_IS_LIST)) {
+ GList *email_list;
+ GList *l;
+
+ gtk_html_stream_printf (html_stream, "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr valign=\"top\"><td>");
+ gtk_html_stream_printf (html_stream, "<b>%s:</b>&nbsp;<td>", _("List Members"));
+
+ email_list = e_contact_get (contact, E_CONTACT_EMAIL);
+ for (l = email_list; l; l = l->next) {
+ EABDestination *dest = eab_destination_import (l->data);
+ if (dest) {
+ const char *textrep = eab_destination_get_textrep (dest, TRUE);
+ char *html = e_text_to_html (textrep, 0);
+ gtk_html_stream_printf (html_stream, "%s, ", html);
+ g_free (html);
+ g_object_unref (dest);
+ }
+ }
+ gtk_html_stream_printf (html_stream, "</td></tr></table>");
+ }
+ else {
+ gboolean comma = FALSE;
+ str = e_contact_get_const (contact, E_CONTACT_TITLE);
+ if (str) {
+ html = e_text_to_html (str, 0);
+ gtk_html_stream_printf (html_stream, "<b>%s:</b> %s<br>", _("Job Title"), str);
+ g_free (html);
+ }
+
+ gtk_html_stream_printf (html_stream, "<b>%s:</b> ", _("Email"));
+ str = e_contact_get_const (contact, E_CONTACT_EMAIL_1);
+ if (str) {
+ html = e_text_to_html (str, 0);
+ gtk_html_stream_printf (html_stream, "%s", str);
+ g_free (html);
+ comma = TRUE;
+ }
+ str = e_contact_get_const (contact, E_CONTACT_EMAIL_2);
+ if (str) {
+ html = e_text_to_html (str, 0);
+ gtk_html_stream_printf (html_stream, "%s%s", comma ? ", " : "", str);
+ g_free (html);
+ comma = TRUE;
+ }
+ str = e_contact_get_const (contact, E_CONTACT_EMAIL_3);
+ if (str) {
+ html = e_text_to_html (str, 0);
+ gtk_html_stream_printf (html_stream, "%s%s", comma ? ", " : "", str);
+ g_free (html);
+ }
+ gtk_html_stream_write (html_stream, "<br>", 4);
+
+ str = e_contact_get_const (contact, E_CONTACT_HOMEPAGE_URL);
+ if (str) {
+ html = e_text_to_html (str, E_TEXT_TO_HTML_CONVERT_URLS);
+ gtk_html_stream_printf (html_stream, "<b>%s:</b> %s<br>",
+ _("Home page"), html);
+ g_free (html);
+ }
+
+ str = e_contact_get_const (contact, E_CONTACT_BLOG_URL);
+ if (str) {
+ html = e_text_to_html (str, E_TEXT_TO_HTML_CONVERT_URLS);
+ gtk_html_stream_printf (html_stream, "<b>%s:</b> %s<br>",
+ _("Blog"), html);
+ }
+ }
+
+ gtk_html_stream_printf (html_stream, "</td></tr></table></td></tr></table></td></tr></table>\n");
+ }
+
+ gtk_html_stream_write (html_stream, "</body></html>\n", 15);
+ gtk_html_end (display->priv->html, html_stream, GTK_HTML_STREAM_OK);
+}
+
+void
+eab_contact_display_render (EABContactDisplay *display, EContact *contact,
+ EABContactDisplayRenderMode mode)
+{
+ switch (mode) {
+ case EAB_CONTACT_DISPLAY_RENDER_NORMAL:
+ eab_contact_display_render_normal (display, contact);
+ break;
+ case EAB_CONTACT_DISPLAY_RENDER_COMPACT:
+ eab_contact_display_render_compact (display, contact);
+ break;
+ }
+}
+
+GtkWidget*
+eab_contact_display_new (void)
+{
+ EABContactDisplay *display;
+
+ display = g_object_new (EAB_TYPE_CONTACT_DISPLAY, NULL);
+
+ display->priv = g_new0 (EABContactDisplayPrivate, 1);
+
+ display->priv->html = GTK_HTML (gtk_html_new ());
+
+ gtk_html_set_default_content_type (display->priv->html, "text/html; charset=utf-8");
+
+ gtk_html_set_editable (display->priv->html, FALSE);
+
+
+ g_signal_connect (display->priv->html, "url_requested",
+ G_CALLBACK (on_url_requested),
+ display);
+ g_signal_connect (display->priv->html, "link_clicked",
+ G_CALLBACK (on_link_clicked),
+ display);
+#if 0
+ g_signal_connect (display->priv->html, "object_requested",
+ G_CALLBACK (on_object_requested),
+ mail_display);
+ g_signal_connect (display->priv->html, "button_press_event",
+ G_CALLBACK (html_button_press_event), mail_display);
+ g_signal_connect (display->priv->html, "motion_notify_event",
+ G_CALLBACK (html_motion_notify_event), mail_display);
+ g_signal_connect (display->priv->html, "enter_notify_event",
+ G_CALLBACK (html_enter_notify_event), mail_display);
+ g_signal_connect (display->priv->html, "iframe_created",
+ G_CALLBACK (html_iframe_created), mail_display);
+ g_signal_connect (display->priv->html, "on_url",
+ G_CALLBACK (html_on_url), mail_display);
+#endif
+
+ gtk_box_pack_start_defaults (GTK_BOX (display), GTK_WIDGET (display->priv->html));
+ gtk_widget_show (GTK_WIDGET (display->priv->html));
+
+ return GTK_WIDGET (display);
+}
+
+
+static void
+eab_contact_display_init (GObject *object)
+{
+}
+
+static void
+eab_contact_display_class_init (GtkObjectClass *object_class)
+{
+ // object_class->destroy = mail_display_destroy;
+}
+
+GType
+eab_contact_display_get_type (void)
+{
+ static GType type = 0;
+
+ if (!type) {
+ static const GTypeInfo info = {
+ sizeof (EABContactDisplayClass),
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ (GClassInitFunc) eab_contact_display_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (EABContactDisplay),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) eab_contact_display_init,
+ };
+
+ type = g_type_register_static (PARENT_TYPE, "EABContactDisplay", &info, 0);
+ }
+
+ return type;
+}
diff --git a/addressbook/gui/widgets/eab-contact-display.h b/addressbook/gui/widgets/eab-contact-display.h
new file mode 100644
index 0000000000..83bad9ae64
--- /dev/null
+++ b/addressbook/gui/widgets/eab-contact-display.h
@@ -0,0 +1,61 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Authors: Chris Toshok <toshok@ximian.com>
+ *
+ * Copyright 2003 Ximian, Inc. (www.ximian.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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 Street #330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef _EAB_CONTACT_DISPLAY_H_
+#define _EAB_CONTACT_DISPLAY_H_
+
+#include <gtk/gtkvbox.h>
+#include <gtkhtml/gtkhtml.h>
+#include <ebook/e-contact.h>
+
+#define EAB_TYPE_CONTACT_DISPLAY (eab_contact_display_get_type ())
+#define EAB_CONTACT_DISPLAY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EAB_TYPE_CONTACT_DISPLAY, EABContactDisplay))
+#define EAB_CONTACT_DISPLAY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), EAB_TYPE_CONTACT_DISPLAY, EABContactDisplayClass))
+#define IS_EAB_CONTACT_DISPLAY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EAB_TYPE_CONTACT_DISPLAY))
+#define IS_EAB_CONTACT_DISPLAY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EAB_TYPE_CONTACT_DISPLAY))
+
+typedef struct _EABContactDisplay EABContactDisplay;
+typedef struct _EABContactDisplayPrivate EABContactDisplayPrivate;
+typedef struct _EABContactDisplayClass EABContactDisplayClass;
+
+typedef enum {
+ EAB_CONTACT_DISPLAY_RENDER_NORMAL, /* for use in the preview pane */
+ EAB_CONTACT_DISPLAY_RENDER_COMPACT /* for use with embedded vcards (e.g, the EABVCardControl) */
+} EABContactDisplayRenderMode;
+
+struct _EABContactDisplay {
+ GtkVBox parent;
+
+ EABContactDisplayPrivate *priv;
+};
+
+struct _EABContactDisplayClass {
+ GtkVBoxClass parent_class;
+};
+
+GtkType eab_contact_display_get_type (void);
+GtkWidget * eab_contact_display_new (void);
+
+void eab_contact_display_render (EABContactDisplay *display, EContact *contact,
+ EABContactDisplayRenderMode render_mode);
+
+#endif /* _EAB_CONTACT_DISPLAY_H_ */
diff --git a/addressbook/gui/widgets/e-addressbook-util.c b/addressbook/gui/widgets/eab-gui-util.c
index 1ddb6812a2..666bc976f2 100644
--- a/addressbook/gui/widgets/e-addressbook-util.c
+++ b/addressbook/gui/widgets/eab-gui-util.c
@@ -20,26 +20,34 @@
*/
#include <config.h>
-#include "e-addressbook-util.h"
-#include "ebook/e-destination.h"
-#include <gnome.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <string.h>
+
#include <gal/util/e-util.h>
+#include "eab-gui-util.h"
+#include "util/eab-book-util.h"
+#include "util/eab-destination.h"
+
+#include <gnome.h>
-#include "e-card-merging.h"
#include <shell/evolution-shell-client.h>
-#include <addressbook/backend/ebook/e-book-util.h>
+
+#include "addressbook/gui/contact-editor/e-contact-editor.h"
+#include "addressbook/gui/contact-list-editor/e-contact-list-editor.h"
void
-e_addressbook_error_dialog (const gchar *msg, EBookStatus status)
+eab_error_dialog (const gchar *msg, EBookStatus status)
{
static char *status_to_string[] = {
N_("Success"),
N_("Unknown error"),
N_("Repository offline"),
N_("Permission denied"),
- N_("Card not found"),
- N_("Card ID already exists"),
+ N_("Contact not found"),
+ N_("Contact ID already exists"),
N_("Protocol not supported"),
N_("Cancelled"),
N_("Authentication Failed"),
@@ -64,7 +72,7 @@ e_addressbook_error_dialog (const gchar *msg, EBookStatus status)
}
gint
-e_addressbook_prompt_save_dialog (GtkWindow *parent)
+eab_prompt_save_dialog (GtkWindow *parent)
{
GtkWidget *dialog;
gint response;
@@ -93,8 +101,8 @@ static void
added_cb (EBook* book, EBookStatus status, const char *id,
gboolean is_list)
{
- if (status != E_BOOK_STATUS_SUCCESS) {
- e_addressbook_error_dialog (is_list ? _("Error adding list") : _("Error adding card"), status);
+ if (status != E_BOOK_ERROR_OK) {
+ eab_error_dialog (is_list ? _("Error adding list") : _("Error adding contact"), status);
}
}
@@ -102,9 +110,9 @@ static void
modified_cb (EBook* book, EBookStatus status,
gboolean is_list)
{
- if (status != E_BOOK_STATUS_SUCCESS) {
- e_addressbook_error_dialog (is_list ? _("Error modifying list") : _("Error modifying card"),
- status);
+ if (status != E_BOOK_ERROR_OK) {
+ eab_error_dialog (is_list ? _("Error modifying list") : _("Error modifying contact"),
+ status);
}
}
@@ -112,9 +120,9 @@ static void
deleted_cb (EBook* book, EBookStatus status,
gboolean is_list)
{
- if (status != E_BOOK_STATUS_SUCCESS) {
- e_addressbook_error_dialog (is_list ? _("Error removing list") : _("Error removing card"),
- status);
+ if (status != E_BOOK_ERROR_OK) {
+ eab_error_dialog (is_list ? _("Error removing list") : _("Error removing contact"),
+ status);
}
}
@@ -125,19 +133,19 @@ editor_closed_cb (GtkObject *editor, gpointer data)
}
EContactEditor *
-e_addressbook_show_contact_editor (EBook *book, ECard *card,
- gboolean is_new_card,
- gboolean editable)
+eab_show_contact_editor (EBook *book, EContact *contact,
+ gboolean is_new_contact,
+ gboolean editable)
{
EContactEditor *ce;
- ce = e_contact_editor_new (book, card, is_new_card, editable);
+ ce = e_contact_editor_new (book, contact, is_new_contact, editable);
- g_signal_connect (ce, "card_added",
+ g_signal_connect (ce, "contact_added",
G_CALLBACK (added_cb), GINT_TO_POINTER (FALSE));
- g_signal_connect (ce, "card_modified",
+ g_signal_connect (ce, "contact_modified",
G_CALLBACK (modified_cb), GINT_TO_POINTER (FALSE));
- g_signal_connect (ce, "card_deleted",
+ g_signal_connect (ce, "contact_deleted",
G_CALLBACK (deleted_cb), GINT_TO_POINTER (FALSE));
g_signal_connect (ce, "editor_closed",
G_CALLBACK (editor_closed_cb), NULL);
@@ -146,13 +154,13 @@ e_addressbook_show_contact_editor (EBook *book, ECard *card,
}
EContactListEditor *
-e_addressbook_show_contact_list_editor (EBook *book, ECard *card,
- gboolean is_new_card,
- gboolean editable)
+eab_show_contact_list_editor (EBook *book, EContact *contact,
+ gboolean is_new_contact,
+ gboolean editable)
{
EContactListEditor *ce;
- ce = e_contact_list_editor_new (book, card, is_new_card, editable);
+ ce = e_contact_list_editor_new (book, contact, is_new_contact, editable);
g_signal_connect (ce, "list_added",
G_CALLBACK (added_cb), GINT_TO_POINTER (TRUE));
@@ -169,21 +177,21 @@ e_addressbook_show_contact_list_editor (EBook *book, ECard *card,
}
static void
-view_cards (EBook *book, GList *list, gboolean editable)
+view_contacts (EBook *book, GList *list, gboolean editable)
{
for (; list; list = list->next) {
- ECard *card = list->data;
- if (e_card_evolution_list (card))
- e_addressbook_show_contact_list_editor (book, card, FALSE, editable);
+ EContact *contact = list->data;
+ if (e_contact_get (contact, E_CONTACT_IS_LIST))
+ eab_show_contact_list_editor (book, contact, FALSE, editable);
else
- e_addressbook_show_contact_editor (book, card, FALSE, editable);
+ eab_show_contact_editor (book, contact, FALSE, editable);
}
}
void
-e_addressbook_show_multiple_cards (EBook *book,
- GList *list,
- gboolean editable)
+eab_show_multiple_contacts (EBook *book,
+ GList *list,
+ gboolean editable)
{
if (list) {
int length = g_list_length (list);
@@ -195,40 +203,218 @@ e_addressbook_show_multiple_cards (EBook *book,
0,
GTK_MESSAGE_QUESTION,
GTK_BUTTONS_YES_NO,
- _("Opening %d cards will open %d new windows as well.\n"
- "Do you really want to display all of these cards?"),
+ _("Opening %d contacts will open %d new windows as well.\n"
+ "Do you really want to display all of these contacts?"),
length,
length);
response = gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
if (response == GTK_RESPONSE_YES)
- view_cards (book, list, editable);
+ view_contacts (book, list, editable);
} else {
- view_cards (book, list, editable);
+ view_contacts (book, list, editable);
}
}
}
+static gint
+file_exists(GtkFileSelection *filesel, const char *filename)
+{
+ GtkWidget *dialog;
+ gint response;
+
+ dialog = gtk_message_dialog_new (GTK_WINDOW (filesel),
+ 0,
+ GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_NONE,
+ _("%s already exists\nDo you want to overwrite it?"), filename);
+
+ gtk_dialog_add_buttons (GTK_DIALOG (dialog),
+ GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
+ _("Overwrite"), GTK_RESPONSE_ACCEPT,
+ NULL);
+
+ response = gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ return response;
+}
+
+typedef struct {
+ GtkFileSelection *filesel;
+ char *vcard;
+} SaveAsInfo;
+
+static void
+save_it(GtkWidget *widget, SaveAsInfo *info)
+{
+ gint error = 0;
+ gint response = 0;
+
+ const char *filename = gtk_file_selection_get_filename (info->filesel);
+
+ error = e_write_file (filename, info->vcard, O_WRONLY | O_CREAT | O_EXCL | O_TRUNC);
+
+ if (error == EEXIST) {
+ response = file_exists(info->filesel, filename);
+ switch (response) {
+ case GTK_RESPONSE_ACCEPT : /* Overwrite */
+ e_write_file(filename, info->vcard, O_WRONLY | O_CREAT | O_TRUNC);
+ break;
+ case GTK_RESPONSE_REJECT : /* cancel */
+ return;
+ }
+ } else if (error != 0) {
+ GtkWidget *dialog;
+ char *str;
+
+ str = g_strdup_printf (_("Error saving %s: %s"), filename, strerror(errno));
+ dialog = gtk_message_dialog_new (GTK_WINDOW (info->filesel),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK,
+ str);
+ g_free (str);
+
+ gtk_widget_show (dialog);
+
+ return;
+ }
+
+ gtk_widget_destroy(GTK_WIDGET(info->filesel));
+}
+
+static void
+close_it(GtkWidget *widget, SaveAsInfo *info)
+{
+ gtk_widget_destroy (GTK_WIDGET (info->filesel));
+}
-typedef struct CardCopyProcess_ CardCopyProcess;
+static void
+destroy_it(void *data, GObject *where_the_object_was)
+{
+ SaveAsInfo *info = data;
+ g_free (info->vcard);
+ g_free (info);
+}
-typedef void (*CardCopyDone) (CardCopyProcess *process);
+static char *
+make_safe_filename (const char *prefix, char *name)
+{
+ char *safe, *p;
-struct CardCopyProcess_ {
+ if (!name) {
+ /* This is a filename. Translators take note. */
+ name = _("card.vcf");
+ }
+
+ p = strrchr (name, '/');
+ if (p)
+ safe = g_strdup_printf ("%s%s%s", prefix, p, ".vcf");
+ else
+ safe = g_strdup_printf ("%s/%s%s", prefix, name, ".vcf");
+
+ p = strrchr (safe, '/') + 1;
+ if (p)
+ e_filename_make_safe (p);
+
+ return safe;
+}
+
+void
+eab_contact_save (char *title, EContact *contact, GtkWindow *parent_window)
+{
+ GtkFileSelection *filesel;
+ char *file;
+ char *name;
+ SaveAsInfo *info = g_new(SaveAsInfo, 1);
+
+ filesel = GTK_FILE_SELECTION(gtk_file_selection_new(title));
+
+ name = e_contact_get (contact, E_CONTACT_FILE_AS);
+ file = make_safe_filename (g_get_home_dir(), name);
+ gtk_file_selection_set_filename (filesel, file);
+ g_free (file);
+
+ info->filesel = filesel;
+ info->vcard = e_vcard_to_string (E_VCARD (contact), EVC_FORMAT_VCARD_30);
+
+ g_signal_connect(filesel->ok_button, "clicked",
+ G_CALLBACK (save_it), info);
+ g_signal_connect(filesel->cancel_button, "clicked",
+ G_CALLBACK (close_it), info);
+ g_object_weak_ref (G_OBJECT (filesel), destroy_it, info);
+
+ if (parent_window) {
+ gtk_window_set_transient_for (GTK_WINDOW (filesel),
+ parent_window);
+ gtk_window_set_modal (GTK_WINDOW (filesel), TRUE);
+ }
+
+ gtk_widget_show(GTK_WIDGET(filesel));
+}
+
+void
+eab_contact_list_save (char *title, GList *list, GtkWindow *parent_window)
+{
+ GtkFileSelection *filesel;
+ SaveAsInfo *info = g_new(SaveAsInfo, 1);
+
+ filesel = GTK_FILE_SELECTION(gtk_file_selection_new(title));
+
+ /* This is a filename. Translators take note. */
+ if (list && list->data && list->next == NULL) {
+ char *name, *file;
+ name = e_contact_get (E_CONTACT (list->data), E_CONTACT_FILE_AS);
+ if (!name)
+ name = e_contact_get (E_CONTACT (list->data), E_CONTACT_FULL_NAME);
+
+ file = make_safe_filename (g_get_home_dir(), name);
+ gtk_file_selection_set_filename (filesel, file);
+ g_free (file);
+ } else {
+ char *file;
+ file = make_safe_filename (g_get_home_dir(), _("list"));
+ gtk_file_selection_set_filename (filesel, file);
+ g_free (file);
+ }
+
+ info->filesel = filesel;
+ info->vcard = eab_contact_list_to_string (list);
+
+ g_signal_connect(filesel->ok_button, "clicked",
+ G_CALLBACK (save_it), info);
+ g_signal_connect(filesel->cancel_button, "clicked",
+ G_CALLBACK (close_it), info);
+ g_object_weak_ref (G_OBJECT (filesel), destroy_it, info);
+
+ if (parent_window) {
+ gtk_window_set_transient_for (GTK_WINDOW (filesel),
+ parent_window);
+ gtk_window_set_modal (GTK_WINDOW (filesel), TRUE);
+ }
+
+ gtk_widget_show(GTK_WIDGET(filesel));
+}
+
+typedef struct ContactCopyProcess_ ContactCopyProcess;
+
+typedef void (*ContactCopyDone) (ContactCopyProcess *process);
+
+struct ContactCopyProcess_ {
int count;
- GList *cards;
+ GList *contacts;
EBook *source;
EBook *destination;
- CardCopyDone done_cb;
+ ContactCopyDone done_cb;
};
static void
-card_deleted_cb (EBook* book, EBookStatus status, gpointer user_data)
+contact_deleted_cb (EBook* book, EBookStatus status, gpointer user_data)
{
- if (status != E_BOOK_STATUS_SUCCESS) {
- e_addressbook_error_dialog (_("Error removing card"), status);
+ if (status != E_BOOK_ERROR_OK) {
+ eab_error_dialog (_("Error removing contact"), status);
}
}
@@ -236,28 +422,28 @@ static void
do_delete (gpointer data, gpointer user_data)
{
EBook *book = user_data;
- ECard *card = data;
+ EContact *contact = data;
- e_book_remove_card(book, card, card_deleted_cb, NULL);
+ e_book_async_remove_contact(book, contact, contact_deleted_cb, NULL);
}
static void
-delete_cards (CardCopyProcess *process)
+delete_contacts (ContactCopyProcess *process)
{
- g_list_foreach (process->cards,
+ g_list_foreach (process->contacts,
do_delete,
process->source);
}
static void
-process_unref (CardCopyProcess *process)
+process_unref (ContactCopyProcess *process)
{
process->count --;
if (process->count == 0) {
if (process->done_cb) {
process->done_cb (process);
}
- e_free_object_list(process->cards);
+ e_free_object_list(process->contacts);
g_object_unref (process->source);
g_object_unref (process->destination);
g_free (process);
@@ -265,12 +451,12 @@ process_unref (CardCopyProcess *process)
}
static void
-card_added_cb (EBook* book, EBookStatus status, const char *id, gpointer user_data)
+contact_added_cb (EBook* book, EBookStatus status, const char *id, gpointer user_data)
{
- CardCopyProcess *process = user_data;
+ ContactCopyProcess *process = user_data;
- if (status != E_BOOK_STATUS_SUCCESS) {
- e_addressbook_error_dialog (_("Error adding card"), status);
+ if (status != E_BOOK_ERROR_OK) {
+ eab_error_dialog (_("Error adding contact"), status);
} else {
process_unref (process);
}
@@ -280,66 +466,70 @@ static void
do_copy (gpointer data, gpointer user_data)
{
EBook *book;
- ECard *card;
- CardCopyProcess *process;
+ EContact *contact;
+ ContactCopyProcess *process;
process = user_data;
- card = data;
+ contact = data;
book = process->destination;
process->count ++;
- e_book_add_card(book, card, card_added_cb, process);
+ e_book_async_add_contact(book, contact, contact_added_cb, process);
}
static void
-got_book_cb (EBook *book, gpointer closure)
+got_book_cb (EBook *book, EBookStatus status, gpointer closure)
{
- CardCopyProcess *process;
+ ContactCopyProcess *process;
process = closure;
- if (book) {
+ if (status == E_BOOK_ERROR_OK) {
process->destination = book;
g_object_ref (book);
- g_list_foreach (process->cards,
+ g_list_foreach (process->contacts,
do_copy,
process);
}
process_unref (process);
}
-extern EvolutionShellClient *global_shell_client;
-
void
-e_addressbook_transfer_cards (EBook *source, GList *cards /* adopted */, gboolean delete_from_source, GtkWindow *parent_window)
+eab_transfer_contacts (EBook *source, GList *contacts /* adopted */, gboolean delete_from_source, GtkWindow *parent_window)
{
+ EBook *dest;
const char *allowed_types[] = { "contacts/*", NULL };
GNOME_Evolution_Folder *folder;
static char *last_uri = NULL;
- CardCopyProcess *process;
+ ContactCopyProcess *process;
char *desc;
- if (cards == NULL)
+ if (contacts == NULL)
return;
if (last_uri == NULL)
last_uri = g_strdup ("");
- if (cards->next == NULL) {
+ if (contacts->next == NULL) {
if (delete_from_source)
- desc = _("Move card to");
+ desc = _("Move contact to");
else
- desc = _("Copy card to");
+ desc = _("Copy contact to");
} else {
if (delete_from_source)
- desc = _("Move cards to");
+ desc = _("Move contacts to");
else
- desc = _("Copy cards to");
+ desc = _("Copy contacts to");
}
+#if 0 /* EPFIXME */
evolution_shell_client_user_select_folder (global_shell_client,
parent_window,
desc, last_uri, allowed_types,
&folder);
+#else
+ folder = NULL;
+#endif
+
if (!folder)
return;
@@ -348,19 +538,20 @@ e_addressbook_transfer_cards (EBook *source, GList *cards /* adopted */, gboolea
last_uri = g_strdup (folder->evolutionUri);
}
- process = g_new (CardCopyProcess, 1);
+ process = g_new (ContactCopyProcess, 1);
process->count = 1;
process->source = source;
g_object_ref (source);
- process->cards = cards;
+ process->contacts = contacts;
process->destination = NULL;
if (delete_from_source)
- process->done_cb = delete_cards;
+ process->done_cb = delete_contacts;
else
process->done_cb = NULL;
- e_book_use_address_book_by_uri (folder->physicalUri, got_book_cb, process);
+ dest = e_book_new ();
+ e_book_async_load_uri (dest, folder->physicalUri, got_book_cb, process);
CORBA_free (folder);
}
@@ -370,19 +561,20 @@ e_addressbook_transfer_cards (EBook *source, GList *cards /* adopted */, gboolea
#define COMPOSER_OAFID "OAFIID:GNOME_Evolution_Mail_Composer"
void
-e_addressbook_send_card_list (GList *cards, EAddressbookDisposition disposition)
+eab_send_contact_list (GList *contacts, EABDisposition disposition)
{
+#if notyet
GNOME_Evolution_Composer composer_server;
CORBA_Environment ev;
- if (cards == NULL)
+ if (contacts == NULL)
return;
CORBA_exception_init (&ev);
composer_server = bonobo_activation_activate_from_id (COMPOSER_OAFID, 0, NULL, &ev);
- if (disposition == E_ADDRESSBOOK_DISPOSITION_AS_TO) {
+ if (disposition == EAB_DISPOSITION_AS_TO) {
GNOME_Evolution_Composer_RecipientList *to_list, *cc_list, *bcc_list;
CORBA_char *subject;
int to_i, bcc_i;
@@ -390,9 +582,9 @@ e_addressbook_send_card_list (GList *cards, EAddressbookDisposition disposition)
gint to_length = 0, bcc_length = 0;
/* Figure out how many addresses of each kind we have. */
- for (iter = cards; iter != NULL; iter = g_list_next (iter)) {
- ECard *card = E_CARD (iter->data);
- if (e_card_evolution_list (card)) {
+ for (iter = contacts; iter != NULL; iter = g_list_next (iter)) {
+ EContact *contact = E_CONTACT (iter->data);
+ if (e_contact_get (contact, E_CONTACT_IS_LIST)) {
gint len = card->email ? e_list_length (card->email) : 0;
if (e_card_evolution_list_show_addresses (card))
to_length += len;
@@ -453,11 +645,11 @@ e_addressbook_send_card_list (GList *cards, EAddressbookDisposition disposition)
if (e_iterator_is_valid (iterator)) {
if (is_list) {
- /* We need to decode the list entries, which are XMLified EDestinations. */
- EDestination *dest = e_destination_import (e_iterator_get (iterator));
+ /* We need to decode the list entries, which are XMLified EABDestinations. */
+ EABDestination *dest = eab_destination_import (e_iterator_get (iterator));
if (dest != NULL) {
- name = g_strdup (e_destination_get_name (dest));
- addr = g_strdup (e_destination_get_email (dest));
+ name = g_strdup (eab_destination_get_name (dest));
+ addr = g_strdup (eab_destination_get_email (dest));
free_name_addr = TRUE;
g_object_unref (dest);
}
@@ -502,7 +694,7 @@ e_addressbook_send_card_list (GList *cards, EAddressbookDisposition disposition)
CORBA_free (cc_list);
CORBA_free (bcc_list);
CORBA_free (subject);
- } else if (disposition == E_ADDRESSBOOK_DISPOSITION_AS_ATTACHMENT) {
+ } else if (disposition == EAB_DISPOSITION_AS_ATTACHMENT) {
CORBA_char *content_type, *filename, *description;
GNOME_Evolution_Composer_AttachmentData *attach_data;
CORBA_boolean show_inline;
@@ -526,16 +718,15 @@ e_addressbook_send_card_list (GList *cards, EAddressbookDisposition disposition)
tempstr = g_strdup_printf (_("VCard for %s"), file_as);
description = CORBA_string_dup (tempstr);
g_free (tempstr);
- g_free (file_as);
}
show_inline = FALSE;
- tempstr = e_card_list_get_vcard (cards);
+ tempstr = eab_contact_list_to_string (cards);
attach_data = GNOME_Evolution_Composer_AttachmentData__alloc();
attach_data->_maximum = attach_data->_length = strlen (tempstr);
attach_data->_buffer = CORBA_sequence_CORBA_char_allocbuf (attach_data->_length);
- memcpy(attach_data->_buffer, tempstr, attach_data->_length);
+ strcpy (attach_data->_buffer, tempstr);
g_free (tempstr);
GNOME_Evolution_Composer_attachData (composer_server,
@@ -573,17 +764,15 @@ e_addressbook_send_card_list (GList *cards, EAddressbookDisposition disposition)
g_object_get(card,
"file_as", &tempstr2,
NULL);
- if (!tempstr2 || !*tempstr2) {
- g_free (tempstr2);
+ if (!tempstr2 || !*tempstr2)
g_object_get(card,
"full_name", &tempstr2,
NULL);
- } if (!tempstr2 || !*tempstr2) {
- g_free (tempstr2);
+ if (!tempstr2 || !*tempstr2)
g_object_get(card,
"org", &tempstr2,
NULL);
- } if (!tempstr2 || !*tempstr2) {
+ if (!tempstr2 || !*tempstr2) {
EList *list;
EIterator *iterator;
g_object_get(card,
@@ -594,7 +783,6 @@ e_addressbook_send_card_list (GList *cards, EAddressbookDisposition disposition)
tempstr2 = e_iterator_get (iterator);
}
g_object_unref (iterator);
- g_object_unref (list);
}
if (!tempstr2 || !*tempstr2)
@@ -602,7 +790,6 @@ e_addressbook_send_card_list (GList *cards, EAddressbookDisposition disposition)
else
tempstr = g_strdup_printf ("Contact information for %s", tempstr2);
subject = CORBA_string_dup (tempstr);
- g_free (tempstr2);
g_free (tempstr);
}
@@ -623,14 +810,14 @@ e_addressbook_send_card_list (GList *cards, EAddressbookDisposition disposition)
}
CORBA_exception_free (&ev);
+#endif
}
void
-e_addressbook_send_card (ECard *card, EAddressbookDisposition disposition)
+eab_send_contact (EContact *contact, EABDisposition disposition)
{
GList *list;
- list = g_list_prepend (NULL, card);
- e_addressbook_send_card_list (list, disposition);
+ list = g_list_prepend (NULL, contact);
+ eab_send_contact_list (list, disposition);
g_list_free (list);
}
-
diff --git a/addressbook/gui/widgets/eab-gui-util.h b/addressbook/gui/widgets/eab-gui-util.h
new file mode 100644
index 0000000000..71a80bc7a6
--- /dev/null
+++ b/addressbook/gui/widgets/eab-gui-util.h
@@ -0,0 +1,70 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* eab-gui-util.h
+ * Copyright (C) 2001-2003 Ximian, Inc.
+ * Author: Chris Toshok <toshok@ximian.com>
+ *
+ * This library 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 library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+#ifndef __E_ADDRESSBOOK_UTIL_H__
+#define __E_ADDRESSBOOK_UTIL_H__
+
+#include <gtk/gtkwindow.h>
+#include "addressbook/backend/ebook/e-book.h"
+#include "addressbook/gui/contact-editor/e-contact-editor.h"
+#include "addressbook/gui/contact-list-editor/e-contact-list-editor.h"
+
+G_BEGIN_DECLS
+
+void eab_error_dialog (const gchar *msg,
+ EBookStatus status);
+gint eab_prompt_save_dialog (GtkWindow *parent);
+
+EContactEditor *eab_show_contact_editor (EBook *book,
+ EContact *contact,
+ gboolean is_new_contact,
+ gboolean editable);
+EContactListEditor *eab_show_contact_list_editor (EBook *book,
+ EContact *contact,
+ gboolean is_new_contact,
+ gboolean editable);
+void eab_show_multiple_contacts (EBook *book,
+ GList *list,
+ gboolean editable);
+void eab_transfer_contacts (EBook *source,
+ GList *contacts, /* adopted */
+ gboolean delete_from_source,
+ GtkWindow *parent_window);
+
+void eab_contact_save (char *title,
+ EContact *contact,
+ GtkWindow *parent_window);
+
+void eab_contact_list_save (char *title,
+ GList *list,
+ GtkWindow *parent_window);
+
+typedef enum {
+ EAB_DISPOSITION_AS_ATTACHMENT,
+ EAB_DISPOSITION_AS_TO,
+} EABDisposition;
+
+void eab_send_contact (EContact *contact,
+ EABDisposition disposition);
+void eab_send_contact_list (GList *contacts,
+ EABDisposition disposition);
+
+G_END_DECLS
+
+#endif /* __E_ADDRESSBOOK_UTIL_H__ */
diff --git a/addressbook/gui/widgets/e-addressbook-marshal.list b/addressbook/gui/widgets/eab-marshal.list
index 2b34707dbb..2b34707dbb 100644
--- a/addressbook/gui/widgets/e-addressbook-marshal.list
+++ b/addressbook/gui/widgets/eab-marshal.list
diff --git a/addressbook/gui/component/e-address-popup.c b/addressbook/gui/widgets/eab-popup-control.c
index 9d87fd0fb3..e2d0299d6e 100644
--- a/addressbook/gui/component/e-address-popup.c
+++ b/addressbook/gui/widgets/eab-popup-control.c
@@ -1,11 +1,12 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
- * e-address-popup.c
+ * eab-popup-control.c
*
- * Copyright (C) 2001 Ximian, Inc.
+ * Copyright (C) 2001-2003, Ximian, Inc.
*
- * Developed by Jon Trowbridge <trow@ximian.com>
+ * Authors: Jon Trowbridge <trow@ximian.com>
+ * Chris Toshok <toshok@ximian.com>
*/
/*
@@ -31,19 +32,22 @@
#include <config.h>
#include <string.h>
#include "addressbook.h"
-#include "e-address-popup.h"
+#include "eab-popup-control.h"
#include <bonobo/bonobo-control.h>
#include <bonobo/bonobo-property-bag.h>
#include <bonobo/bonobo-generic-factory.h>
#include <gal/widgets/e-popup-menu.h>
-#include <addressbook/backend/ebook/e-book.h>
-#include <addressbook/backend/ebook/e-book-util.h>
+#include <addressbook/backend/ebook/e-book-async.h>
+#include <addressbook/util/eab-book-util.h>
#include <addressbook/gui/contact-editor/e-contact-editor.h>
#include <addressbook/gui/contact-editor/e-contact-quick-add.h>
-#include <addressbook/gui/widgets/e-minicard-widget.h>
-#include <addressbook/gui/widgets/e-addressbook-util.h>
+#include <addressbook/gui/widgets/eab-contact-display.h>
+#include <addressbook/gui/widgets/eab-gui-util.h>
#include "e-util/e-gui-utils.h"
+static void eab_popup_control_set_name (EABPopupControl *pop, const gchar *name);
+static void eab_popup_control_set_email (EABPopupControl *pop, const gchar *email);
+
/*
* 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
@@ -178,7 +182,7 @@ mini_wizard_new (void)
/*
* 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.
+ * contact.
*/
#define EMPTY_ENTRY N_("(none)")
@@ -225,20 +229,18 @@ menu_activate_cb (GtkWidget *w, gpointer closure)
}
static void
-email_menu_add_option (EMailMenu *menu, const gchar *addr)
+email_menu_add_option (EMailMenu *menu, char *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->options = g_list_append (menu->options, addr);
menu_item = gtk_menu_item_new_with_label (addr);
- g_object_set_data (G_OBJECT (menu_item), "addr", addr_cpy);
+ g_object_set_data (G_OBJECT (menu_item), "addr", addr);
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);
@@ -249,23 +251,17 @@ email_menu_add_option (EMailMenu *menu, const gchar *addr)
}
static void
-email_menu_add_options_from_card (EMailMenu *menu, ECard *card, const gchar *extra_addr)
+email_menu_add_options_from_contact (EMailMenu *menu, EContact *contact, const gchar *extra_addr)
{
- ECardSimple *simple;
-
- g_return_if_fail (card && E_IS_CARD (card));
-
- simple = e_card_simple_new (card);
+ g_return_if_fail (contact && E_IS_CONTACT (contact));
/* 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, e_contact_get (contact, E_CONTACT_EMAIL_1));
+ email_menu_add_option (menu, e_contact_get (contact, E_CONTACT_EMAIL_2));
+ email_menu_add_option (menu, e_contact_get (contact, E_CONTACT_EMAIL_3));
+ email_menu_add_option (menu, g_strdup (extra_addr));
email_menu_add_option (menu, EMPTY_ENTRY);
-
- g_object_unref (simple);
}
static void
@@ -325,7 +321,7 @@ email_menu_unset_option (EMailMenu *menu, const gchar *addr)
typedef struct _EMailTable EMailTable;
struct _EMailTable {
GtkWidget *table;
- ECard *card;
+ EContact *contact;
EMailMenu *primary;
EMailMenu *email2;
EMailMenu *email3;
@@ -339,7 +335,7 @@ email_table_cleanup_cb (gpointer closure)
if (et == NULL)
return;
- g_object_unref (et->card);
+ g_object_unref (et->contact);
email_menu_free (et->primary);
email_menu_free (et->email2);
email_menu_free (et->email3);
@@ -348,74 +344,49 @@ email_table_cleanup_cb (gpointer closure)
}
static void
-email_table_from_card (EMailTable *et)
+email_table_from_contact (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);
+ email_menu_set_option (et->primary, e_contact_get_const (et->contact, E_CONTACT_EMAIL_1));
+ email_menu_set_option (et->email2, e_contact_get_const (et->contact, E_CONTACT_EMAIL_2));
+ email_menu_set_option (et->email3, e_contact_get_const (et->contact, E_CONTACT_EMAIL_3));
}
static void
-email_table_to_card (EMailTable *et)
+email_table_to_contact (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);
+ e_contact_set (et->contact, E_CONTACT_EMAIL_1, 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);
+ e_contact_set (et->contact, E_CONTACT_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);
+ e_contact_set (et->contact, E_CONTACT_EMAIL_3, curr);
}
static void
-email_table_save_card_cb (EBook *book, EBookStatus status, gpointer closure)
+email_table_save_contact_cb (EBook *book, EBookStatus status, gpointer closure)
{
- ECard *card = E_CARD (closure);
+ EContact *contact = E_CONTACT (closure);
- if (status == E_BOOK_STATUS_SUCCESS) {
- e_book_commit_card (book, card, NULL, NULL);
+ if (status == E_BOOK_ERROR_OK) {
+ e_book_async_commit_contact (book, contact, 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;
+ g_object_unref (contact);
}
static void
@@ -423,16 +394,17 @@ email_table_ok_cb (MiniWizard *wiz, gpointer closure)
{
EMailTable *et = (EMailTable *) closure;
- email_table_to_card (et);
+ email_table_to_contact (et);
+
+ g_object_ref (et->contact);
- g_object_ref (et->card);
- gtk_idle_add (add_card_idle_cb, et->card);
+ addressbook_load_default_book (email_table_save_contact_cb, et->contact);
mini_wizard_destroy (wiz);
}
static void
-email_table_init (MiniWizard *wiz, ECard *card, const gchar *extra_address)
+email_table_init (MiniWizard *wiz, EContact *contact, const gchar *extra_address)
{
EMailTable *et;
@@ -441,12 +413,12 @@ email_table_init (MiniWizard *wiz, ECard *card, const gchar *extra_address)
GtkAttachOptions label_x_opts, label_y_opts;
GtkAttachOptions menu_x_opts, menu_y_opts;
- g_return_if_fail (card && E_IS_CARD (card));
+ g_return_if_fail (contact && E_IS_CONTACT (contact));
et = g_new (EMailTable, 1);
- et->card = card;
- g_object_ref (et->card);
+ et->contact = contact;
+ g_object_ref (et->contact);
et->table = gtk_table_new (4, 2, FALSE);
@@ -454,11 +426,11 @@ email_table_init (MiniWizard *wiz, ECard *card, const gchar *extra_address)
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_menu_add_options_from_contact (et->primary, et->contact, extra_address);
+ email_menu_add_options_from_contact (et->email2, et->contact, extra_address);
+ email_menu_add_options_from_contact (et->email3, et->contact, extra_address);
- email_table_from_card (et);
+ email_table_from_contact (et);
label_x_opts = GTK_FILL;
label_y_opts = GTK_FILL;
@@ -467,7 +439,7 @@ email_table_init (MiniWizard *wiz, ECard *card, const gchar *extra_address)
xpad = 3;
ypad = 3;
- name_str = e_card_name_to_string (et->card->name);
+ name_str = e_contact_get (et->contact, E_CONTACT_FULL_NAME);
gtk_table_attach (GTK_TABLE (et->table),
gtk_label_new (name_str),
0, 2, 0, 1,
@@ -516,32 +488,32 @@ email_table_init (MiniWizard *wiz, ECard *card, const gchar *extra_address)
}
/*
- * This code is for the little UI thing that lets you pick from a set of cards
+ * This code is for the little UI thing that lets you pick from a set of contacts
* and decide which one you want to add the e-mail address to.
*/
-typedef struct _CardPicker CardPicker;
-struct _CardPicker {
+typedef struct _ContactPicker ContactPicker;
+struct _ContactPicker {
GtkWidget *body;
GtkWidget *list;
GtkListStore *model;
- GList *cards;
+ GList *contacts;
gchar *new_name;
gchar *new_email;
- ECard *current_card;
+ EContact *current_contact;
};
enum {
COLUMN_ACTION,
- COLUMN_CARD
+ COLUMN_CONTACT
};
static void
-card_picker_selection_changed (GtkTreeSelection *selection, gpointer closure)
+contact_picker_selection_changed (GtkTreeSelection *selection, gpointer closure)
{
MiniWizard *wiz = (MiniWizard *) closure;
- CardPicker *pick = (CardPicker *) wiz->closure;
+ ContactPicker *pick = (ContactPicker *) wiz->closure;
gboolean selected;
GtkTreeIter iter;
@@ -551,34 +523,34 @@ card_picker_selection_changed (GtkTreeSelection *selection, gpointer closure)
if (selected) {
gtk_tree_model_get (GTK_TREE_MODEL (pick->model), &iter,
- COLUMN_CARD, &pick->current_card,
+ COLUMN_CONTACT, &pick->current_contact,
-1);
}
else {
- pick->current_card = NULL;
+ pick->current_contact = NULL;
}
}
static void
-card_picker_ok_cb (MiniWizard *wiz, gpointer closure)
+contact_picker_ok_cb (MiniWizard *wiz, gpointer closure)
{
- CardPicker *pick = (CardPicker *) closure;
+ ContactPicker *pick = (ContactPicker *) closure;
- if (pick->current_card == NULL) {
+ if (pick->current_contact == 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);
+ email_table_init (wiz, pick->current_contact, pick->new_email);
}
}
static void
-card_picker_cleanup_cb (gpointer closure)
+contact_picker_cleanup_cb (gpointer closure)
{
- CardPicker *pick = (CardPicker *) closure;
+ ContactPicker *pick = (ContactPicker *) closure;
- g_list_foreach (pick->cards, (GFunc) g_object_unref, NULL);
- g_list_free (pick->cards);
+ g_list_foreach (pick->contacts, (GFunc) g_object_unref, NULL);
+ g_list_free (pick->contacts);
g_free (pick->new_name);
g_free (pick->new_email);
@@ -592,14 +564,14 @@ free_str (gpointer data,
}
static void
-card_picker_init (MiniWizard *wiz, const GList *cards, const gchar *new_name, const gchar *new_email)
+contact_picker_init (MiniWizard *wiz, const GList *contacts, const gchar *new_name, const gchar *new_email)
{
- CardPicker *pick;
+ ContactPicker *pick;
gchar *str;
GtkWidget *w;
GtkTreeIter iter;
- pick = g_new (CardPicker, 1);
+ pick = g_new (ContactPicker, 1);
pick->body = gtk_vbox_new (FALSE, 2);
@@ -623,44 +595,44 @@ card_picker_init (MiniWizard *wiz, const GList *cards, const gchar *new_name, co
gtk_list_store_append (pick->model, &iter);
gtk_list_store_set (pick->model, &iter,
COLUMN_ACTION, str,
- COLUMN_CARD, NULL,
+ COLUMN_CONTACT, 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->contacts = NULL;
+ while (contacts) {
+ EContact *contact = (EContact *) contacts->data;
+ gchar *name_str = e_contact_get (contact, E_CONTACT_FULL_NAME);
- pick->cards = g_list_append (pick->cards, card);
- g_object_ref (card);
+ pick->contacts = g_list_append (pick->contacts, contact);
+ g_object_ref (contact);
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,
+ COLUMN_CONTACT, contact,
-1);
g_free (name_str);
g_object_weak_ref (G_OBJECT (pick->model), free_str, str);
- cards = g_list_next (cards);
+ contacts = g_list_next (contacts);
}
pick->new_name = g_strdup (new_name);
pick->new_email = g_strdup (new_email);
- pick->current_card = NULL;
+ pick->current_contact = 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;
+ wiz->ok_cb = contact_picker_ok_cb;
+ wiz->cleanup_cb = contact_picker_cleanup_cb;
g_signal_connect (gtk_tree_view_get_selection (GTK_TREE_VIEW (pick->list)),
- "changed", G_CALLBACK (card_picker_selection_changed),
+ "changed", G_CALLBACK (contact_picker_selection_changed),
wiz);
/* Build our widget */
@@ -681,7 +653,7 @@ card_picker_init (MiniWizard *wiz, const GList *cards, const gchar *new_name, co
/* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** */
/*
- * The code for the actual EAddressPopup widget begins here.
+ * The code for the actual EABPopupControl widget begins here.
*/
/* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** */
@@ -689,41 +661,43 @@ card_picker_init (MiniWizard *wiz, const GList *cards, const gchar *new_name, co
static GtkObjectClass *parent_class;
-static void e_address_popup_dispose (GObject *);
-static void e_address_popup_query (EAddressPopup *);
+static void eab_popup_control_dispose (GObject *);
+static void eab_popup_control_query (EABPopupControl *);
static void
-e_address_popup_class_init (EAddressPopupClass *klass)
+eab_popup_control_class_init (EABPopupControlClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
- object_class->dispose = e_address_popup_dispose;
+ object_class->dispose = eab_popup_control_dispose;
}
static void
-e_address_popup_init (EAddressPopup *pop)
+eab_popup_control_init (EABPopupControl *pop)
{
pop->transitory = TRUE;
}
static void
-e_address_popup_cleanup (EAddressPopup *pop)
+eab_popup_control_cleanup (EABPopupControl *pop)
{
- if (pop->card) {
- g_object_unref (pop->card);
- pop->card = NULL;
+ if (pop->contact) {
+ g_object_unref (pop->contact);
+ pop->contact = NULL;
}
if (pop->scheduled_refresh) {
- gtk_timeout_remove (pop->scheduled_refresh);
+ g_source_remove (pop->scheduled_refresh);
pop->scheduled_refresh = 0;
}
if (pop->query_tag) {
+#if notyet
e_book_simple_query_cancel (pop->book, pop->query_tag);
+#endif
pop->query_tag = 0;
}
@@ -740,42 +714,42 @@ e_address_popup_cleanup (EAddressPopup *pop)
}
static void
-e_address_popup_dispose (GObject *obj)
+eab_popup_control_dispose (GObject *obj)
{
- EAddressPopup *pop = E_ADDRESS_POPUP (obj);
+ EABPopupControl *pop = EAB_POPUP_CONTROL (obj);
- e_address_popup_cleanup (pop);
+ eab_popup_control_cleanup (pop);
if (G_OBJECT_CLASS (parent_class)->dispose)
G_OBJECT_CLASS (parent_class)->dispose (obj);
}
GType
-e_address_popup_get_type (void)
+eab_popup_control_get_type (void)
{
static GType pop_type = 0;
if (!pop_type) {
static const GTypeInfo pop_info = {
- sizeof (EAddressPopupClass),
+ sizeof (EABPopupControlClass),
NULL, /* base_init */
NULL, /* base_finalize */
- (GClassInitFunc) e_address_popup_class_init,
+ (GClassInitFunc) eab_popup_control_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
- sizeof (EAddressPopup),
+ sizeof (EABPopupControl),
0, /* n_preallocs */
- (GInstanceInitFunc) e_address_popup_init,
+ (GInstanceInitFunc) eab_popup_control_init,
};
- pop_type = g_type_register_static (gtk_event_box_get_type (), "EAddressPopup", &pop_info, 0);
+ pop_type = g_type_register_static (gtk_event_box_get_type (), "EABPopupControl", &pop_info, 0);
}
return pop_type;
}
static void
-e_address_popup_refresh_names (EAddressPopup *pop)
+eab_popup_control_refresh_names (EABPopupControl *pop)
{
if (pop->name_widget) {
if (pop->name && *pop->name) {
@@ -795,33 +769,33 @@ e_address_popup_refresh_names (EAddressPopup *pop)
}
}
- e_address_popup_query (pop);
+ eab_popup_control_query (pop);
}
static gint
refresh_timeout_cb (gpointer ptr)
{
- EAddressPopup *pop = E_ADDRESS_POPUP (ptr);
- e_address_popup_refresh_names (pop);
+ EABPopupControl *pop = EAB_POPUP_CONTROL (ptr);
+ eab_popup_control_refresh_names (pop);
pop->scheduled_refresh = 0;
return 0;
}
static void
-e_address_popup_schedule_refresh (EAddressPopup *pop)
+eab_popup_control_schedule_refresh (EABPopupControl *pop)
{
if (pop->scheduled_refresh == 0)
- pop->scheduled_refresh = gtk_timeout_add (20, refresh_timeout_cb, pop);
+ pop->scheduled_refresh = g_timeout_add (20, refresh_timeout_cb, pop);
}
/* If we are handed something of the form "Foo <bar@bar.com>",
do the right thing. */
static gboolean
-e_address_popup_set_free_form (EAddressPopup *pop, const gchar *txt)
+eab_popup_control_set_free_form (EABPopupControl *pop, const gchar *txt)
{
gchar *lt, *gt = NULL;
- g_return_val_if_fail (pop && E_IS_ADDRESS_POPUP (pop), FALSE);
+ g_return_val_if_fail (pop && EAB_IS_POPUP_CONTROL (pop), FALSE);
if (txt == NULL)
return FALSE;
@@ -833,11 +807,8 @@ e_address_popup_set_free_form (EAddressPopup *pop, const gchar *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);
+ eab_popup_control_set_name (pop, name);
+ eab_popup_control_set_email (pop, email);
return TRUE;
}
@@ -845,49 +816,49 @@ e_address_popup_set_free_form (EAddressPopup *pop, const gchar *txt)
return FALSE;
}
-void
-e_address_popup_set_name (EAddressPopup *pop, const gchar *name)
+static void
+eab_popup_control_set_name (EABPopupControl *pop, const gchar *name)
{
- g_return_if_fail (pop && E_IS_ADDRESS_POPUP (pop));
+ g_return_if_fail (pop && EAB_IS_POPUP_CONTROL (pop));
/* We only allow the name to be set once. */
if (pop->name)
return;
- if (!e_address_popup_set_free_form (pop, name)) {
+ if (!eab_popup_control_set_free_form (pop, name)) {
pop->name = g_strdup (name);
if (pop->name)
g_strstrip (pop->name);
}
- e_address_popup_schedule_refresh (pop);
+ eab_popup_control_schedule_refresh (pop);
}
-void
-e_address_popup_set_email (EAddressPopup *pop, const gchar *email)
+static void
+eab_popup_control_set_email (EABPopupControl *pop, const gchar *email)
{
- g_return_if_fail (pop && E_IS_ADDRESS_POPUP (pop));
+ g_return_if_fail (pop && EAB_IS_POPUP_CONTROL (pop));
/* We only allow the e-mail to be set once. */
if (pop->email)
return;
- if (!e_address_popup_set_free_form (pop, email)) {
+ if (!eab_popup_control_set_free_form (pop, email)) {
pop->email = g_strdup (email);
if (pop->email)
g_strstrip (pop->email);
}
- e_address_popup_schedule_refresh (pop);
+ eab_popup_control_schedule_refresh (pop);
}
void
-e_address_popup_construct (EAddressPopup *pop)
+eab_popup_control_construct (EABPopupControl *pop)
{
GtkWidget *vbox, *name_holder;
GdkColor color = { 0x0, 0xffff, 0xffff, 0xffff };
- g_return_if_fail (pop && E_IS_ADDRESS_POPUP (pop));
+ g_return_if_fail (pop && EAB_IS_POPUP_CONTROL (pop));
pop->main_vbox = gtk_vbox_new (FALSE, 0);
@@ -918,9 +889,9 @@ e_address_popup_construct (EAddressPopup *pop)
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);
+ /* Build ContactDisplay */
+ pop->contact_display = eab_contact_display_new ();
+ gtk_box_pack_start (GTK_BOX (pop->main_vbox), pop->contact_display, TRUE, TRUE, 0);
/* Final assembly */
@@ -932,16 +903,16 @@ e_address_popup_construct (EAddressPopup *pop)
gtk_container_set_border_width (GTK_CONTAINER (pop), 2);
}
-GtkWidget *
-e_address_popup_new (void)
+static GtkWidget *
+eab_popup_new (void)
{
- EAddressPopup *pop = g_object_new (E_TYPE_ADDRESS_POPUP, NULL);
- e_address_popup_construct (pop);
+ EABPopupControl *pop = g_object_new (EAB_TYPE_POPUP_CONTROL, NULL);
+ eab_popup_control_construct (pop);
return GTK_WIDGET (pop);
}
static void
-emit_event (EAddressPopup *pop, const char *event)
+emit_event (EABPopupControl *pop, const char *event)
{
if (pop->es) {
BonoboArg *arg;
@@ -960,10 +931,10 @@ emit_event (EAddressPopup *pop, const char *event)
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);
+ if (status == E_BOOK_ERROR_OK) {
+ EABPopupControl *pop = EAB_POPUP_CONTROL (closure);
+ EContactEditor *ce = eab_show_contact_editor (book, pop->contact, FALSE, TRUE);
+ eab_popup_control_cleanup (pop);
emit_event (pop, "Destroy");
e_contact_editor_raise (ce);
}
@@ -973,29 +944,29 @@ contact_editor_cb (EBook *book, EBookStatus status, gpointer closure)
}
static void
-edit_contact_info_cb (GtkWidget *button, EAddressPopup *pop)
+edit_contact_info_cb (GtkWidget *button, EABPopupControl *pop)
{
- EBook *book;
emit_event (pop, "Hide");
- book = e_book_new ();
- addressbook_load_default_book (book, contact_editor_cb, pop);
+ addressbook_load_default_book (contact_editor_cb, pop);
}
static void
-e_address_popup_cardify (EAddressPopup *pop, ECard *card)
+eab_popup_control_display_contact (EABPopupControl *pop, EContact *contact)
{
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);
+ g_return_if_fail (pop && EAB_IS_POPUP_CONTROL (pop));
+ g_return_if_fail (contact && E_IS_CONTACT (contact));
+ g_return_if_fail (pop->contact == NULL);
- pop->card = card;
- g_object_ref (pop->card);
+ pop->contact = contact;
+ g_object_ref (pop->contact);
- e_minicard_widget_set_card (E_MINICARD_WIDGET (pop->minicard_view), card);
- gtk_widget_show (pop->minicard_view);
+ eab_contact_display_render (EAB_CONTACT_DISPLAY (pop->contact_display),
+ contact,
+ EAB_CONTACT_DISPLAY_RENDER_COMPACT);
+ gtk_widget_show (pop->contact_display);
gtk_widget_hide (pop->generic_view);
b = gtk_button_new_with_label (_("Edit Contact Info"));
@@ -1008,7 +979,7 @@ e_address_popup_cardify (EAddressPopup *pop, ECard *card)
}
static void
-add_contacts_cb (GtkWidget *button, EAddressPopup *pop)
+add_contacts_cb (GtkWidget *button, EABPopupControl *pop)
{
if (pop->email && *pop->email) {
if (pop->name && *pop->name)
@@ -1017,16 +988,16 @@ add_contacts_cb (GtkWidget *button, EAddressPopup *pop)
e_contact_quick_add_free_form (pop->email, NULL, NULL);
}
- e_address_popup_cleanup (pop);
+ eab_popup_control_cleanup (pop);
emit_event (pop, "Destroy");
}
static void
-e_address_popup_no_matches (EAddressPopup *pop)
+eab_popup_control_no_matches (EABPopupControl *pop)
{
GtkWidget *b;
- g_return_if_fail (pop && E_IS_ADDRESS_POPUP (pop));
+ g_return_if_fail (pop && EAB_IS_POPUP_CONTROL (pop));
b = e_button_new_with_stock_icon (_("Add to Contacts"), "gtk-add");
@@ -1045,7 +1016,7 @@ wizard_destroy_cb (MiniWizard *wiz, gpointer closure)
}
static void
-e_address_popup_ambiguous_email_add (EAddressPopup *pop, const GList *cards)
+eab_popup_control_ambiguous_email_add (EABPopupControl *pop, const GList *contacts)
{
MiniWizard *wiz = mini_wizard_new ();
GtkWidget *win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
@@ -1056,9 +1027,9 @@ e_address_popup_ambiguous_email_add (EAddressPopup *pop, const GList *cards)
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);
+ contact_picker_init (wiz, contacts, pop->name, pop->email);
- e_address_popup_cleanup (pop);
+ eab_popup_control_cleanup (pop);
emit_event (pop, "Destroy");
gtk_container_add (GTK_CONTAINER (win), wiz->body);
@@ -1066,11 +1037,11 @@ e_address_popup_ambiguous_email_add (EAddressPopup *pop, const GList *cards)
}
static void
-e_address_popup_multiple_matches (EAddressPopup *pop, const GList *cards)
+eab_popup_control_multiple_matches (EABPopupControl *pop, const GList *contacts)
{
pop->multiple_matches = TRUE;
- e_address_popup_ambiguous_email_add (pop, cards);
+ eab_popup_control_ambiguous_email_add (pop, contacts);
}
/** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **/
@@ -1080,71 +1051,78 @@ e_address_popup_multiple_matches (EAddressPopup *pop, const GList *cards)
*/
static void
-name_only_query_cb (EBook *book, EBookSimpleQueryStatus status, const GList *cards, gpointer closure)
+name_only_query_cb (EBook *book, EBookStatus status, GList *contacts, gpointer closure)
{
- EAddressPopup *pop;
+ EABPopupControl *pop;
- if (status != E_BOOK_SIMPLE_QUERY_STATUS_SUCCESS)
+ if (status != E_BOOK_ERROR_OK)
return;
- pop = E_ADDRESS_POPUP (closure);
+ pop = EAB_POPUP_CONTROL (closure);
pop->query_tag = 0;
- if (cards == NULL) {
- e_address_popup_no_matches (pop);
+ if (contacts == NULL) {
+ eab_popup_control_no_matches (pop);
} else {
- e_address_popup_ambiguous_email_add (pop, cards);
+ eab_popup_control_ambiguous_email_add (pop, contacts);
+ g_list_foreach (contacts, (GFunc)g_object_unref, NULL);
+ g_list_free (contacts);
}
}
static void
-query_cb (EBook *book, EBookSimpleQueryStatus status, const GList *cards, gpointer closure)
+query_cb (EBook *book, EBookStatus status, GList *contacts, gpointer closure)
{
- EAddressPopup *pop;
+ EABPopupControl *pop;
- if (status != E_BOOK_SIMPLE_QUERY_STATUS_SUCCESS)
+ if (status != E_BOOK_ERROR_OK)
return;
- pop = E_ADDRESS_POPUP (closure);
+ pop = EAB_POPUP_CONTROL (closure);
pop->query_tag = 0;
gtk_widget_hide (pop->query_msg);
- if (cards == NULL) {
+ if (contacts == 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);
+ pop->query_tag = eab_name_and_email_query (book, pop->name, NULL, name_only_query_cb, pop);
} else {
- e_address_popup_no_matches (pop);
+ eab_popup_control_no_matches (pop);
}
} else {
- if (g_list_length ((GList *) cards) == 1)
- e_address_popup_cardify (pop, E_CARD (cards->data));
+ if (g_list_length ((GList *) contacts) == 1)
+ eab_popup_control_display_contact (pop, E_CONTACT (contacts->data));
else
- e_address_popup_multiple_matches (pop, cards);
+ eab_popup_control_multiple_matches (pop, contacts);
+
+ g_list_foreach (contacts, (GFunc)g_object_unref, NULL);
+ g_list_free (contacts);
}
}
static void
start_query (EBook *book, EBookStatus status, gpointer closure)
{
- EAddressPopup *pop = E_ADDRESS_POPUP (closure);
+ EABPopupControl *pop = EAB_POPUP_CONTROL (closure);
- if (status != E_BOOK_STATUS_SUCCESS) {
- e_address_popup_no_matches (pop);
+ if (status != E_BOOK_ERROR_OK) {
+ eab_popup_control_no_matches (pop);
if (book)
g_object_unref (book);
return;
}
+#if notyet
if (pop->query_tag)
e_book_simple_query_cancel (book, pop->query_tag);
+#endif
if (pop->book != book) {
g_object_ref (book);
@@ -1153,22 +1131,19 @@ start_query (EBook *book, EBookStatus status, gpointer closure)
pop->book = book;
}
- pop->query_tag = e_book_name_and_email_query (book, pop->name, pop->email, query_cb, pop);
+ pop->query_tag = eab_name_and_email_query (book, pop->name, pop->email, query_cb, pop);
g_object_unref (pop);
}
static void
-e_address_popup_query (EAddressPopup *pop)
+eab_popup_control_query (EABPopupControl *pop)
{
- EBook *book;
-
- g_return_if_fail (pop && E_IS_ADDRESS_POPUP (pop));
+ g_return_if_fail (pop && EAB_IS_POPUP_CONTROL (pop));
- book = e_book_new ();
g_object_ref (pop);
- addressbook_load_default_book (book, start_query, pop);
+ addressbook_load_default_book (start_query, pop);
}
/** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **/
@@ -1182,16 +1157,16 @@ enum {
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);
+ EABPopupControl *pop = EAB_POPUP_CONTROL (user_data);
switch (arg_id) {
case PROPERTY_NAME:
- e_address_popup_set_name (pop, BONOBO_ARG_GET_STRING (arg));
+ eab_popup_control_set_name (pop, BONOBO_ARG_GET_STRING (arg));
break;
case PROPERTY_EMAIL:
- e_address_popup_set_email (pop, BONOBO_ARG_GET_STRING (arg));
+ eab_popup_control_set_email (pop, BONOBO_ARG_GET_STRING (arg));
break;
default:
@@ -1202,7 +1177,7 @@ set_prop (BonoboPropertyBag *bag, const BonoboArg *arg, guint arg_id, CORBA_Envi
static void
get_prop (BonoboPropertyBag *bag, BonoboArg *arg, guint arg_id, CORBA_Environment *ev, gpointer user_data)
{
- EAddressPopup *pop = E_ADDRESS_POPUP (user_data);
+ EABPopupControl *pop = EAB_POPUP_CONTROL (user_data);
switch (arg_id) {
@@ -1224,15 +1199,15 @@ get_prop (BonoboPropertyBag *bag, BonoboArg *arg, guint arg_id, CORBA_Environmen
}
BonoboControl *
-e_address_popup_new_control (void)
+eab_popup_control_new (void)
{
BonoboControl *control;
BonoboPropertyBag *bag;
- EAddressPopup *addy;
+ EABPopupControl *addy;
GtkWidget *w;
- w = e_address_popup_new ();
- addy = E_ADDRESS_POPUP (w);
+ w = eab_popup_new ();
+ addy = EAB_POPUP_CONTROL (w);
control = bonobo_control_new (w);
gtk_widget_show (w);
diff --git a/addressbook/gui/widgets/eab-popup-control.h b/addressbook/gui/widgets/eab-popup-control.h
new file mode 100644
index 0000000000..4d223f02cb
--- /dev/null
+++ b/addressbook/gui/widgets/eab-popup-control.h
@@ -0,0 +1,85 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ * eab-popup-control.h
+ *
+ * Copyright (C) 2001-2003, Ximian, Inc.
+ *
+ * Authors: Jon Trowbridge <trow@ximian.com>
+ * Chris Toshok <toshok@ximian.com>
+ */
+
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA.
+ */
+
+#ifndef __EAB_POPUP_CONTROL_H__
+#define __EAB_POPUP_CONTROL_H__
+
+#include <gtk/gtk.h>
+#include <addressbook/backend/ebook/e-book-async.h>
+#include <addressbook/backend/ebook/e-contact.h>
+#include <bonobo/bonobo-event-source.h>
+
+G_BEGIN_DECLS
+
+#define EAB_TYPE_POPUP_CONTROL (eab_popup_control_get_type ())
+#define EAB_POPUP_CONTROL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EAB_TYPE_POPUP_CONTROL, EABPopupControl))
+#define EAB_POPUP_CONTROL_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), EAB_TYPE_POPUP_CONTROL, EABPopupControlClass))
+#define EAB_IS_POPUP_CONTROL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EAB_TYPE_POPUP_CONTROL))
+#define EAB_IS_POPUP_CONTROL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EAB_TYPE_POPUP_CONTROL))
+
+typedef struct _EABPopupControl EABPopupControl;
+typedef struct _EABPopupControlClass EABPopupControlClass;
+
+struct _EABPopupControl {
+ GtkEventBox parent;
+
+ gchar *name;
+ gchar *email;
+
+ GtkWidget *name_widget;
+ GtkWidget *email_widget;
+ GtkWidget *query_msg;
+
+ GtkWidget *main_vbox;
+ GtkWidget *generic_view;
+ GtkWidget *contact_display;
+
+ gboolean transitory;
+
+ guint scheduled_refresh;
+ EBook *book;
+ guint query_tag;
+ gboolean multiple_matches;
+ EContact *contact;
+
+ BonoboEventSource *es;
+};
+
+struct _EABPopupControlClass {
+ GtkEventBoxClass parent_class;
+};
+
+GType eab_popup_control_get_type (void);
+
+void eab_popup_control_construct (EABPopupControl *);
+
+BonoboControl *eab_popup_control_new (void);
+
+G_END_DECLS
+
+#endif /* __EAB_POPUP_CONTROL_H__ */
+
diff --git a/addressbook/gui/widgets/e-minicard-control.c b/addressbook/gui/widgets/eab-vcard-control.c
index 7cbcfb028a..82c5fd6032 100644
--- a/addressbook/gui/widgets/e-minicard-control.c
+++ b/addressbook/gui/widgets/eab-vcard-control.c
@@ -1,8 +1,8 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
- * e-minicard-control.c
+ * eab-vcard-control.c
*
- * Copyright (C) 1999, 2000, 2001, 2002, Ximian, Inc.
+ * Copyright (C) 1999, 2000, 2001, 2002, 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
@@ -20,6 +20,7 @@
*
* Authors:
* Chris Lahey <clahey@ximian.com>
+ * Chris Toshok <toshok@ximian.com>
*/
#include <config.h>
@@ -33,87 +34,22 @@
#include <gal/util/e-util.h>
#include <addressbook/gui/component/addressbook.h>
-#include <addressbook/backend/ebook/e-book.h>
-#include <addressbook/backend/ebook/e-book-util.h>
-#include <addressbook/backend/ebook/e-card.h>
+#include <addressbook/gui/widgets/eab-contact-display.h>
+#include <addressbook/backend/ebook/e-book-async.h>
+#include <addressbook/backend/ebook/e-contact.h>
+#include <addressbook/util/eab-book-util.h>
-#include "e-minicard-control.h"
-#include "e-minicard-widget.h"
-#include "e-card-merging.h"
+#include "eab-vcard-control.h"
+#include "eab-contact-merging.h"
typedef struct {
- EMinicardWidget *minicard;
+ EABContactDisplay *display;
GList *card_list;
GtkWidget *label;
-} EMinicardControl;
+ EABContactDisplayRenderMode render_mode;
+} EABVCardControl;
-#define MINICARD_CONTROL_ID "OAFIID:GNOME_Evolution_Addressbook_MiniCard_Control"
-
-
-#if 0
-enum {
- PROP_RUNNING
-} MyArgs;
-
-#define RUNNING_KEY "Clock::Running"
-
-static void
-get_prop (BonoboPropertyBag *bag,
- BonoboArg *arg,
- guint arg_id,
- CORBA_Environment *ev,
- gpointer user_data)
-{
- GObject *clock = user_data;
-
- switch (arg_id) {
-
- case PROP_RUNNING:
- {
- gboolean b = GPOINTER_TO_UINT (g_object_get_data (clock, RUNNING_KEY));
- BONOBO_ARG_SET_BOOLEAN (arg, b);
- break;
- }
-
- default:
- g_warning ("Unhandled arg %d", arg_id);
- break;
- }
-}
-
-static void
-set_prop (BonoboPropertyBag *bag,
- const BonoboArg *arg,
- guint arg_id,
- CORBA_Environment *ev,
- gpointer user_data)
-{
- GtkClock *clock = user_data;
-
- switch (arg_id) {
-
- case PROP_RUNNING:
- {
- guint i;
-
- i = BONOBO_ARG_GET_BOOLEAN (arg);
-
- if (i)
- gtk_clock_start (clock);
- else
- gtk_clock_stop (clock);
-
- g_object_set_data (clock, RUNNING_KEY,
- GUINT_TO_POINTER (i));
- break;
- }
-
- default:
- g_warning ("Unhandled arg %d", arg_id);
- break;
- }
-}
-#endif
+#define VCARD_CONTROL_ID "OAFIID:GNOME_Evolution_Addressbook_VCard_Control"
/*
* Bonobo::PersistStream
@@ -174,7 +110,7 @@ pstream_load (BonoboPersistStream *ps, const Bonobo_Stream stream,
{
GList *list;
char *vcard;
- EMinicardControl *minicard_control = data;
+ EABVCardControl *vcard_control = data;
if (type && g_ascii_strcasecmp (type, "text/vCard") != 0 &&
g_ascii_strcasecmp (type, "text/x-vCard") != 0) {
@@ -189,27 +125,27 @@ pstream_load (BonoboPersistStream *ps, const Bonobo_Stream stream,
return;
}
- e_free_object_list (minicard_control->card_list);
- list = e_card_load_cards_from_string_with_default_charset(vcard, "ISO-8859-1");
+ e_free_object_list (vcard_control->card_list);
+ list = eab_contact_list_from_string (vcard);
g_free(vcard);
- minicard_control->card_list = list;
- if (list)
- g_object_set(minicard_control->minicard,
- "card", list->data,
- NULL);
+ vcard_control->card_list = list;
+ if (list) {
+ eab_contact_display_render (vcard_control->display, E_CONTACT (list->data),
+ vcard_control->render_mode);
+ }
if (list && list->next) {
char *message;
int length = g_list_length (list) - 1;
if (length > 1) {
- message = g_strdup_printf (_("and %d other cards."), length);
+ message = g_strdup_printf (_("and %d other contacts."), length);
} else {
- message = g_strdup_printf (_("and one other card."));
+ message = g_strdup_printf (_("and one other contact."));
}
- gtk_label_set_text (GTK_LABEL (minicard_control->label), message);
+ gtk_label_set_text (GTK_LABEL (vcard_control->label), message);
g_free (message);
- gtk_widget_show (minicard_control->label);
+ gtk_widget_show (vcard_control->label);
} else {
- gtk_widget_hide (minicard_control->label);
+ gtk_widget_hide (vcard_control->label);
}
} /* pstream_load */
@@ -221,7 +157,7 @@ pstream_save (BonoboPersistStream *ps, const Bonobo_Stream stream,
Bonobo_Persist_ContentType type, void *data,
CORBA_Environment *ev)
{
- EMinicardControl *minicard_control = data;
+ EABVCardControl *vcard_control = data;
char *vcard;
int length;
@@ -232,7 +168,7 @@ pstream_save (BonoboPersistStream *ps, const Bonobo_Stream stream,
return;
}
- vcard = e_card_list_get_vcard(minicard_control->card_list);
+ vcard = eab_contact_list_to_string (vcard_control->card_list);
length = strlen (vcard);
bonobo_stream_client_write (stream, vcard, length, ev);
g_free (vcard);
@@ -249,10 +185,11 @@ static void
book_open_cb (EBook *book, EBookStatus status, gpointer closure)
{
GList *list = closure;
- if (status == E_BOOK_STATUS_SUCCESS) {
+ if (status == E_BOOK_ERROR_OK) {
GList *p;
for (p = list; p; p = p->next) {
- e_card_merging_book_add_card(book, p->data, NULL, NULL);
+ /* XXX argh, more passing of NULL's for callbacks */
+ eab_merging_book_add_contact (book, E_CONTACT (p->data), NULL, NULL);
}
}
if (book)
@@ -263,87 +200,103 @@ book_open_cb (EBook *book, EBookStatus status, gpointer closure)
static void
save_in_addressbook(GtkWidget *button, gpointer data)
{
- EMinicardControl *minicard_control = data;
+ EABVCardControl *vcard_control = data;
GList *list, *p;
- EBook *book;
-
- book = e_book_new ();
- list = g_list_copy (minicard_control->card_list);
+ list = g_list_copy (vcard_control->card_list);
for (p = list; p; p = p->next)
g_object_ref (p->data);
- addressbook_load_default_book (book, book_open_cb, list);
+ addressbook_load_default_book (book_open_cb, list);
+}
+
+static void
+toggle_full_vcard(GtkWidget *button, gpointer data)
+{
+ EABVCardControl *vcard_control = data;
+ char *label;
+
+ if (!vcard_control->card_list)
+ return;
+
+ if (vcard_control->render_mode == EAB_CONTACT_DISPLAY_RENDER_NORMAL) {
+ vcard_control->render_mode = EAB_CONTACT_DISPLAY_RENDER_COMPACT;
+ label = _("Show Full VCard");
+ }
+ else {
+ vcard_control->render_mode = EAB_CONTACT_DISPLAY_RENDER_NORMAL;
+ label = _("Show Compact VCard");
+ }
+
+ gtk_button_set_label (GTK_BUTTON (button), label);
+ eab_contact_display_render (vcard_control->display, E_CONTACT (vcard_control->card_list->data),
+ vcard_control->render_mode);
}
static void
free_struct (gpointer data, GObject *where_object_was)
{
- EMinicardControl *minicard_control = data;
- e_free_object_list (minicard_control->card_list);
- g_free (minicard_control);
+ EABVCardControl *vcard_control = data;
+ e_free_object_list (vcard_control->card_list);
+ g_free (vcard_control);
}
BonoboControl *
-e_minicard_control_new (void)
+eab_vcard_control_new (void)
{
-#if 0
- BonoboPropertyBag *pb;
-#endif
BonoboControl *control;
BonoboPersistStream *stream;
- GtkWidget *minicard;
- GtkWidget *button;
+ GtkWidget *display;
+ GtkWidget *button1, *button2;
GtkWidget *label;
- GtkWidget *vbox;
+ GtkWidget *table;
- EMinicardControl *minicard_control = g_new (EMinicardControl, 1);
+ EABVCardControl *vcard_control = g_new (EABVCardControl, 1);
+ printf ("inside eab_vcard_control_new\n");
- minicard_control->card_list = NULL;
- minicard_control->minicard = NULL;
- minicard_control->label = NULL;
+ vcard_control->card_list = NULL;
+ vcard_control->display = NULL;
+ vcard_control->label = NULL;
+
+ vcard_control->render_mode = EAB_CONTACT_DISPLAY_RENDER_COMPACT;
/* Create the control. */
- minicard = e_minicard_widget_new ();
- gtk_widget_show (minicard);
- minicard_control->minicard = E_MINICARD_WIDGET (minicard);
+ display = eab_contact_display_new ();
+ gtk_widget_show (display);
+ vcard_control->display = EAB_CONTACT_DISPLAY (display);
/* This is intentionally not shown. */
label = gtk_label_new ("");
- minicard_control->label = label;
+ vcard_control->label = label;
+
+ button1 = gtk_button_new_with_label(_("Show Full VCard"));
+ g_signal_connect (button1, "clicked",
+ G_CALLBACK (toggle_full_vcard), vcard_control);
+ gtk_widget_show (button1);
- button = gtk_button_new_with_label(_("Save in addressbook"));
- g_signal_connect (button, "clicked",
- G_CALLBACK (save_in_addressbook), minicard_control);
- gtk_widget_show (button);
+ button2 = gtk_button_new_with_label(_("Save in addressbook"));
+ g_signal_connect (button2, "clicked",
+ G_CALLBACK (save_in_addressbook), vcard_control);
+ gtk_widget_show (button2);
- vbox = gtk_vbox_new(FALSE, 0);
- gtk_box_pack_start(GTK_BOX(vbox), minicard, TRUE, TRUE, 0);
- gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
- gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
- gtk_widget_show (vbox);
+ table = gtk_table_new (6, 6, FALSE);
+ gtk_table_attach (GTK_TABLE (table), display, 0, 6, 3, 6, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
+ gtk_table_attach (GTK_TABLE (table), label, 0, 3, 2, 3, GTK_FILL, 0, 0, 0);
+ gtk_table_attach (GTK_TABLE (table), button1, 0, 1, 1, 2, 0, 0, 0, 0);
+ gtk_table_attach (GTK_TABLE (table), button2, 1, 2, 1, 2, 0, 0, 0, 0);
+ gtk_widget_show (table);
- control = bonobo_control_new (vbox);
+ control = bonobo_control_new (table);
- g_object_weak_ref (G_OBJECT (control), free_struct, minicard_control);
+ g_object_weak_ref (G_OBJECT (control), free_struct, vcard_control);
stream = bonobo_persist_stream_new (pstream_load, pstream_save,
pstream_get_content_types,
- MINICARD_CONTROL_ID,
- minicard_control);
-
-#if 0
- /* Create the properties. */
- pb = bonobo_property_bag_new (get_prop, set_prop, clock);
- bonobo_control_set_properties (control, pb);
-
- bonobo_property_bag_add (pb, "running", PROP_RUNNING,
- BONOBO_ARG_BOOLEAN, NULL,
- "Whether or not the clock is running", 0);
-#endif
+ VCARD_CONTROL_ID,
+ vcard_control);
if (stream == NULL) {
bonobo_object_unref (BONOBO_OBJECT (control));
diff --git a/addressbook/gui/widgets/eab-vcard-control.h b/addressbook/gui/widgets/eab-vcard-control.h
new file mode 100644
index 0000000000..5f6643c1ca
--- /dev/null
+++ b/addressbook/gui/widgets/eab-vcard-control.h
@@ -0,0 +1,8 @@
+#ifndef __EAB_VCARD_CONTROL_H__
+#define __EAB_VCARD_CONTROL_H__
+
+#include <bonobo/bonobo-control.h>
+
+BonoboControl *eab_vcard_control_new (void);
+
+#endif /* __EAB_VCARD_CONTROL_H__ */
diff --git a/addressbook/gui/widgets/test-minicard-label.c b/addressbook/gui/widgets/test-minicard-label.c
deleted file mode 100644
index c109497628..0000000000
--- a/addressbook/gui/widgets/test-minicard-label.c
+++ /dev/null
@@ -1,129 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* test-minicard-label.c
- *
- * Copyright (C) 2000 Ximian, Inc.
- * Author: Chris Lahey <clahey@ximian.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include "config.h"
-
-#include <gtk/gtkmain.h>
-#include <libgnomeui/gnome-app.h>
-#include <libgnomeui/gnome-canvas-rect-ellipse.h>
-#include <libgnomeui/gnome-init.h>
-#include <gal/widgets/e-canvas.h>
-#include "e-minicard-label.h"
-
-/* This is a horrible thing to do, but it is just a test. */
-GnomeCanvasItem *label;
-GnomeCanvasItem *rect;
-
-static void destroy_callback(gpointer data, GObject *where_object_was)
-{
- exit(0);
-}
-
-static void allocate_callback(GtkWidget *canvas, GtkAllocation *allocation, gpointer data)
-{
- gnome_canvas_set_scroll_region(GNOME_CANVAS( canvas ), 0, 0, allocation->width, allocation->height );
- gnome_canvas_item_set( label,
- "width", (double) allocation->width,
- "height", (double) allocation->height,
- NULL );
- gnome_canvas_item_set( rect,
- "x2", (double) allocation->width,
- "y2", (double) allocation->height,
- NULL );
-}
-
-#if 0
-static void about_callback( GtkWidget *widget, gpointer data )
-{
-
- const gchar *authors[] =
- {
- "Christopher James Lahey <clahey@umich.edu>",
- NULL
- };
-
- GtkWidget *about =
- gnome_about_new ( _( "Minicard Label Test" ), VERSION,
- _( "Copyright (C) 2000, Ximian, Inc." ),
- authors,
- _( "This should test the minicard label canvas item" ),
- NULL);
- gtk_widget_show (about);
-}
-#endif
-
-static void button_press_callback( GtkWidget *widget, gpointer data )
-{
- gnome_canvas_item_grab_focus( label );
-}
-
-int main( int argc, char *argv[] )
-{
- GtkWidget *app;
- GtkWidget *canvas;
-
- /* bindtextdomain (PACKAGE, GNOMELOCALEDIR);
- textdomain (PACKAGE);*/
-
- gnome_init( "Minicard Label Test", VERSION, argc, argv);
- app = gnome_app_new("Minicard Label Test", NULL);
-
- canvas = e_canvas_new();
- rect = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( canvas ) ),
- gnome_canvas_rect_get_type(),
- "x1", (double) 0,
- "y1", (double) 0,
- "x2", (double) 100,
- "y2", (double) 100,
- "fill_color", "white",
- NULL );
- label = e_minicard_label_new(gnome_canvas_root( GNOME_CANVAS( canvas ) ));
- gnome_canvas_item_set( label,
- "width", (double) 100,
- "height", (double) 100,
- "fieldname", "Full Name:",
- "field", "Christopher James Lahey",
- NULL );
- gnome_canvas_set_scroll_region ( GNOME_CANVAS( canvas ),
- 0, 0,
- 100, 100 );
-
- gnome_app_set_contents( GNOME_APP( app ), canvas );
-
-
- /* Connect the signals */
- g_object_weak_ref (app, destroy_callback, app);
-
- g_signal_connect( canvas , "size_allocate",
- G_CALLBACK ( allocate_callback ),
- ( gpointer ) app );
-
- g_signal_connect( canvas , "button_press_event",
- G_CALLBACK ( button_press_callback ),
- ( gpointer ) app );
-
- gtk_widget_show_all( app );
-
- gtk_main();
-
- /* Not reached. */
- return 0;
-}
diff --git a/addressbook/gui/widgets/test-minicard-view.c b/addressbook/gui/widgets/test-minicard-view.c
deleted file mode 100644
index 14ede54208..0000000000
--- a/addressbook/gui/widgets/test-minicard-view.c
+++ /dev/null
@@ -1,203 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* test-reflow.c
- *
- * Copyright (C) 2000 Ximian, Inc.
- * Author: Chris Lahey <clahey@ximian.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include "config.h"
-
-#include <libgnorba/gnorba.h>
-#include <e-util/e-canvas.h>
-#include "e-minicard-view.h"
-
-/* This is a horrible thing to do, but it is just a test. */
-GnomeCanvasItem *reflow;
-GnomeCanvasItem *rect;
-GtkAllocation last_alloc;
-
-CORBA_Environment ev;
-CORBA_ORB orb;
-
-static void
-init_bonobo (int argc, char **argv)
-{
-
- gnome_CORBA_init_with_popt_table (
- "Reflow Test", VERSION,
- &argc, argv, NULL, 0, NULL, GNORBA_INIT_SERVER_FUNC, &ev);
-
- orb = gnome_CORBA_ORB ();
-
- if (bonobo_init (orb, NULL, NULL) == FALSE)
- g_error (_("Could not initialize Bonobo"));
-
-}
-
-static void destroy_callback(gpointer data, GObject *where_object_was)
-{
- exit(0);
-}
-
-static void allocate_callback(GtkWidget *canvas, GtkAllocation *allocation, gpointer data)
-{
- double width;
- last_alloc = *allocation;
- gnome_canvas_item_set( reflow,
- "height", (double) allocation->height,
- NULL );
- gnome_canvas_item_set( reflow,
- "minimum_width", (double) allocation->width,
- NULL );
- g_object_get(reflow,
- "width", &width,
- NULL);
- width = MAX(width, allocation->width);
- gnome_canvas_set_scroll_region(GNOME_CANVAS( canvas ), 0, 0, width, allocation->height );
- gnome_canvas_item_set( rect,
- "x2", (double) width,
- "y2", (double) allocation->height,
- NULL );
-}
-
-static void resize(GnomeCanvas *canvas, gpointer data)
-{
- double width;
- g_object_get(reflow,
- "width", &width,
- NULL);
- width = MAX(width, last_alloc.width);
- gnome_canvas_set_scroll_region(canvas , 0, 0, width, last_alloc.height );
- gnome_canvas_item_set( rect,
- "x2", (double) width,
- "y2", (double) last_alloc.height,
- NULL );
-}
-
-#if 0
-static void about_callback( GtkWidget *widget, gpointer data )
-{
-
- const gchar *authors[] =
- {
- "Christopher James Lahey <clahey@umich.edu>",
- NULL
- };
-
- GtkWidget *about =
- gnome_about_new ( _( "Reflow Test" ), VERSION,
- _( "Copyright (C) 2000, Ximian, Inc." ),
- authors,
- _( "This should test the reflow canvas item" ),
- NULL);
- gtk_widget_show (about);
-}
-#endif
-
-static void
-book_open_cb (EBook *book, EBookStatus status, gpointer closure)
-{
- if (status == E_BOOK_STATUS_SUCCESS)
- gnome_canvas_item_set(reflow,
- "book", book,
- NULL);
-}
-
-static gboolean
-ebook_create (gpointer data)
-{
- EBook *book;
-
- book = e_book_new ();
-
- if (!book) {
- printf ("%s: %s(): Couldn't create EBook, bailing.\n",
- __FILE__,
- G_GNUC_FUNCTION);
- return FALSE;
- }
-
-
- e_book_load_uri (book, "file:/tmp/test.db", book_open_cb, NULL);
-
- return FALSE;
-}
-
-int main( int argc, char *argv[] )
-{
- GtkWidget *app;
- GtkWidget *canvas;
- GtkWidget *vbox;
- GtkWidget *scrollbar;
-
- /* bindtextdomain (PACKAGE, GNOMELOCALEDIR);
- textdomain (PACKAGE);*/
-
- CORBA_exception_init (&ev);
- init_bonobo (argc, argv);
-
- app = gnome_app_new("Reflow Test", NULL);
-
- vbox = gtk_vbox_new(FALSE, 0);
-
- canvas = e_canvas_new();
- rect = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( canvas ) ),
- gnome_canvas_rect_get_type(),
- "x1", (double) 0,
- "y1", (double) 0,
- "x2", (double) 100,
- "y2", (double) 100,
- "fill_color", "white",
- NULL );
- reflow = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( canvas ) ),
- e_minicard_view_get_type(),
- "height", (double) 100,
- "minimum_width", (double) 100,
- NULL );
- g_signal_connect( canvas, "reflow",
- G_CALLBACK ( resize ),
- ( gpointer ) app);
-
- gnome_canvas_set_scroll_region ( GNOME_CANVAS( canvas ),
- 0, 0,
- 100, 100 );
-
- gtk_box_pack_start(GTK_BOX(vbox), canvas, TRUE, TRUE, 0);
-
- scrollbar = gtk_hscrollbar_new(gtk_layout_get_hadjustment(GTK_LAYOUT(canvas)));
-
- gtk_box_pack_start(GTK_BOX(vbox), scrollbar, FALSE, FALSE, 0);
-
- gnome_app_set_contents( GNOME_APP( app ), vbox );
-
- /* Connect the signals */
- g_object_weak_ref (app, destroy_callback, app);
-
- g_signal_connect( canvas, "size_allocate",
- G_CALLBACK ( allocate_callback ),
- ( gpointer ) app );
-
- gtk_widget_show_all( app );
- gdk_window_set_back_pixmap( GTK_LAYOUT(canvas)->bin_window, NULL, FALSE);
-
- g_idle_add (ebook_create, NULL);
-
- bonobo_main ();
-
- /* Not reached. */
- return 0;
-}
diff --git a/addressbook/gui/widgets/test-minicard.c b/addressbook/gui/widgets/test-minicard.c
deleted file mode 100644
index 822362d972..0000000000
--- a/addressbook/gui/widgets/test-minicard.c
+++ /dev/null
@@ -1,120 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* test-minicard.c
- *
- * Copyright (C) 2000 Ximian, Inc.
- * Author: Chris Lahey <clahey@ximian.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- */
-
-#include "config.h"
-
-#include <gtk/gtkmain.h>
-#include <libgnomeui/gnome-app.h>
-#include <libgnomeui/gnome-init.h>
-#include <libgnomeui/gnome-canvas-rect-ellipse.h>
-
-#include "e-minicard.h"
-
-/* This is a horrible thing to do, but it is just a test. */
-GnomeCanvasItem *card;
-GnomeCanvasItem *rect;
-
-static void destroy_callback(gpointer data, GObject *where_object_was)
-{
- exit(0);
-}
-
-static void allocate_callback(GtkWidget *canvas, GtkAllocation *allocation, gpointer data)
-{
- gnome_canvas_set_scroll_region(GNOME_CANVAS( canvas ), 0, 0, allocation->width, allocation->height );
- gnome_canvas_item_set( card,
- "width", (double) allocation->width,
- NULL );
- gnome_canvas_item_set( rect,
- "x2", (double) allocation->width,
- "y2", (double) allocation->height,
- NULL );
-}
-
-#if 0
-static void about_callback( GtkWidget *widget, gpointer data )
-{
-
- const gchar *authors[] =
- {
- "Christopher James Lahey <clahey@umich.edu>",
- NULL
- };
-
- GtkWidget *about =
- gnome_about_new ( _( "Minicard Test" ), VERSION,
- _( "Copyright (C) 2000, Ximian, Inc." ),
- authors,
- _( "This should test the minicard canvas item" ),
- NULL);
- gtk_widget_show (about);
-}
-#endif
-
-int main( int argc, char *argv[] )
-{
- GtkWidget *app;
- GtkWidget *canvas;
- int i;
-
- /* bindtextdomain (PACKAGE, GNOMELOCALEDIR);
- textdomain (PACKAGE);*/
-
- gnome_init( "Minicard Test", VERSION, argc, argv);
- app = gnome_app_new("Minicard Test", NULL);
-
- canvas = gnome_canvas_new();
- rect = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( canvas ) ),
- gnome_canvas_rect_get_type(),
- "x1", (double) 0,
- "y1", (double) 0,
- "x2", (double) 100,
- "y2", (double) 100,
- "fill_color", "white",
- NULL );
- for ( i = 0; i < 1; i++ )
- {
- card = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( canvas ) ),
- e_minicard_get_type(),
- "width", (double) 100,
- NULL );
- }
- gnome_canvas_set_scroll_region ( GNOME_CANVAS( canvas ),
- 0, 0,
- 100, 100 );
-
- gnome_app_set_contents( GNOME_APP( app ), canvas );
-
- /* Connect the signals */
- g_object_weak_ref (app, destroy_callback, app);
-
- g_signal_connect( canvas, "size_allocate",
- G_CALLBACK( allocate_callback ),
- ( gpointer ) app );
-
- gtk_widget_show_all( app );
-
- gtk_main();
-
- /* Not reached. */
- return 0;
-}