aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui/widgets
diff options
context:
space:
mode:
authorEttore Perazzoli <ettore@src.gnome.org>2003-10-22 02:49:34 +0800
committerEttore Perazzoli <ettore@src.gnome.org>2003-10-22 02:49:34 +0800
commit653cfffc0e00dfb59b36813c1b45c53d3f773c65 (patch)
tree9b486d5e383ec1391d60973d9cc548be0ef6d9d5 /addressbook/gui/widgets
parent0fb08f3ff81575a4749d851404233f34252dd2f2 (diff)
downloadgsoc2013-evolution-653cfffc0e00dfb59b36813c1b45c53d3f773c65.tar.gz
gsoc2013-evolution-653cfffc0e00dfb59b36813c1b45c53d3f773c65.tar.zst
gsoc2013-evolution-653cfffc0e00dfb59b36813c1b45c53d3f773c65.zip
Merge new-ui-branch to the trunk.
svn path=/trunk/; revision=22965
Diffstat (limited to 'addressbook/gui/widgets')
-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.c1236
-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
34 files changed, 3414 insertions, 2839 deletions
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/widgets/eab-popup-control.c b/addressbook/gui/widgets/eab-popup-control.c
new file mode 100644
index 0000000000..e2d0299d6e
--- /dev/null
+++ b/addressbook/gui/widgets/eab-popup-control.c
@@ -0,0 +1,1236 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ * eab-popup-control.c
+ *
+ * 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.
+ */
+
+/*
+ * This file is too big and this widget is too complicated. Forgive me.
+ */
+
+#include <config.h>
+#include <string.h>
+#include "addressbook.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-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/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
+ * we really need it to be).
+ */
+
+typedef struct _MiniWizard MiniWizard;
+struct _MiniWizard {
+ GtkWidget *body;
+
+ GtkWidget *vbox;
+ GtkWidget *ok_button;
+ GtkWidget *cancel_button;
+
+ void (*ok_cb) (MiniWizard *, gpointer);
+ void (*cleanup_cb) (gpointer);
+ gpointer closure;
+
+ void (*destroy_cb) (MiniWizard *, gpointer);
+ gpointer destroy_closure;
+};
+
+static void
+mini_wizard_container_add (MiniWizard *wiz, GtkWidget *w)
+{
+ GList *iter = gtk_container_get_children (GTK_CONTAINER (wiz->vbox));
+ while (iter != NULL) {
+ GtkWidget *oldw = (GtkWidget *) iter->data;
+ iter = g_list_next (iter);
+ gtk_container_remove (GTK_CONTAINER (wiz->vbox), oldw);
+ }
+ gtk_container_add (GTK_CONTAINER (wiz->vbox), w);
+}
+
+static void
+mini_wizard_destroy (MiniWizard *wiz)
+{
+ if (wiz->cleanup_cb)
+ wiz->cleanup_cb (wiz->closure);
+ wiz->cleanup_cb = NULL;
+
+ if (wiz->destroy_cb)
+ wiz->destroy_cb (wiz, wiz->destroy_closure);
+}
+
+static void
+mini_wizard_ok_cb (GtkWidget *b, gpointer closure)
+{
+ MiniWizard *wiz = (MiniWizard *) closure;
+
+ gpointer old_closure = wiz->closure;
+ void (*old_cleanup) (gpointer) = wiz->cleanup_cb;
+
+ wiz->cleanup_cb = NULL;
+
+ if (wiz->ok_cb)
+ wiz->ok_cb (wiz, wiz->closure);
+
+ if (old_cleanup)
+ old_cleanup (old_closure);
+
+}
+
+static void
+mini_wizard_cancel_cb (GtkWidget *b, gpointer closure)
+{
+ mini_wizard_destroy ((MiniWizard *) closure);
+}
+
+static void
+mini_wizard_destroy_cb (gpointer closure, GObject *where_object_was)
+{
+ MiniWizard *wiz = (MiniWizard *) closure;
+ if (wiz->cleanup_cb)
+ wiz->cleanup_cb (wiz->closure);
+ g_free (wiz);
+}
+
+static MiniWizard *
+mini_wizard_new (void)
+{
+ MiniWizard *wiz = g_new (MiniWizard, 1);
+ GtkWidget *bbox;
+
+ wiz->body = gtk_vbox_new (FALSE, 2);
+ wiz->vbox = gtk_vbox_new (FALSE, 2);
+ wiz->ok_button = gtk_button_new_from_stock (GTK_STOCK_OK);
+ wiz->cancel_button = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
+
+ wiz->ok_cb = NULL;
+ wiz->cleanup_cb = NULL;
+ wiz->closure = NULL;
+
+ wiz->destroy_cb = NULL;
+ wiz->destroy_closure = NULL;
+
+ bbox = gtk_hbutton_box_new ();
+ gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox),
+ GTK_BUTTONBOX_END);
+
+ gtk_box_pack_start (GTK_BOX (bbox), wiz->cancel_button, FALSE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (bbox), wiz->ok_button, FALSE, TRUE, 0);
+
+ gtk_box_set_spacing (GTK_BOX (bbox),
+ 10 /* ugh */);
+
+ gtk_box_pack_start (GTK_BOX (wiz->body), wiz->vbox, TRUE, TRUE, 2);
+ gtk_box_pack_start (GTK_BOX (wiz->body), gtk_hseparator_new (), FALSE, TRUE, 2);
+ gtk_box_pack_start (GTK_BOX (wiz->body), bbox, FALSE, TRUE, 2);
+
+ gtk_widget_show_all (wiz->body);
+
+ g_signal_connect (wiz->ok_button,
+ "clicked",
+ G_CALLBACK (mini_wizard_ok_cb),
+ wiz);
+ g_signal_connect (wiz->cancel_button,
+ "clicked",
+ G_CALLBACK (mini_wizard_cancel_cb),
+ wiz);
+
+ g_object_weak_ref (G_OBJECT (wiz->body),
+ mini_wizard_destroy_cb,
+ wiz);
+
+ return wiz;
+
+}
+
+
+
+/*
+ * This is the code for the UI thingie that lets you manipulate the e-mail
+ * addresses (and *only* the e-mail addresses) associated with an existing
+ * contact.
+ */
+
+#define EMPTY_ENTRY N_("(none)")
+
+typedef struct _EMailMenu EMailMenu;
+struct _EMailMenu {
+ GtkWidget *option_menu;
+ GList *options;
+ gchar *current_selection;
+};
+
+static void
+email_menu_free (EMailMenu *menu)
+{
+ if (menu == NULL)
+ return;
+
+ g_list_foreach (menu->options, (GFunc) g_free, NULL);
+ g_list_free (menu->options);
+ g_free (menu);
+}
+
+static EMailMenu *
+email_menu_new (void)
+{
+ EMailMenu *menu = g_new (EMailMenu, 1);
+
+ menu->option_menu = gtk_option_menu_new ();
+ menu->options = NULL;
+ menu->current_selection = NULL;
+
+ gtk_option_menu_set_menu (GTK_OPTION_MENU (menu->option_menu), gtk_menu_new ());
+
+ return menu;
+}
+
+static void
+menu_activate_cb (GtkWidget *w, gpointer closure)
+{
+ EMailMenu *menu = (EMailMenu *) closure;
+ gchar *addr = (gchar *) g_object_get_data (G_OBJECT (w), "addr");
+
+ menu->current_selection = addr;
+}
+
+static void
+email_menu_add_option (EMailMenu *menu, char *addr)
+{
+ GtkWidget *menu_item;
+
+ g_return_if_fail (menu != NULL);
+ if (addr == NULL)
+ return;
+
+ 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);
+ gtk_widget_show_all (menu_item);
+ gtk_menu_shell_append (GTK_MENU_SHELL (gtk_option_menu_get_menu (GTK_OPTION_MENU (menu->option_menu))), menu_item);
+
+ g_signal_connect (menu_item,
+ "activate",
+ G_CALLBACK (menu_activate_cb),
+ menu);
+}
+
+static void
+email_menu_add_options_from_contact (EMailMenu *menu, EContact *contact, const gchar *extra_addr)
+{
+ 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_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);
+}
+
+static void
+email_menu_set_option (EMailMenu *menu, const gchar *addr)
+{
+ guint count = 0;
+ GList *iter;
+
+ g_return_if_fail (menu != NULL);
+
+ if (addr == NULL) {
+ email_menu_set_option (menu, EMPTY_ENTRY);
+ return;
+ }
+
+ iter = menu->options;
+ while (iter && strcmp (addr, (gchar *) iter->data)) {
+ ++count;
+ iter = g_list_next (iter);
+ }
+
+ if (iter) {
+ gtk_option_menu_set_history (GTK_OPTION_MENU (menu->option_menu), count);
+ menu->current_selection = (gchar *) iter->data;
+ }
+}
+
+#ifdef UNDEFINED_FUNCTIONS_SHOULD_PLEASE_BE_INCLUDED
+static void
+email_menu_unset_option (EMailMenu *menu, const gchar *addr)
+{
+ GList *iter;
+
+ g_return_if_fail (menu != NULL);
+ g_return_if_fail (addr != NULL);
+
+ if (menu->current_selection == NULL || strcmp (addr, menu->current_selection))
+ return;
+
+ iter = menu->options;
+ while (iter && strcmp (addr, (gchar *) iter->data)) {
+ iter = g_list_next (iter);
+ }
+ if (iter) {
+ iter = g_list_next (iter);
+ if (iter) {
+ email_menu_set_option (menu, (gchar *) iter->data);
+ } else {
+ email_menu_set_option (menu, EMPTY_ENTRY);
+ }
+ }
+}
+#endif
+
+
+
+typedef struct _EMailTable EMailTable;
+struct _EMailTable {
+ GtkWidget *table;
+ EContact *contact;
+ EMailMenu *primary;
+ EMailMenu *email2;
+ EMailMenu *email3;
+};
+
+static void
+email_table_cleanup_cb (gpointer closure)
+{
+ EMailTable *et = (EMailTable *) closure;
+
+ if (et == NULL)
+ return;
+
+ g_object_unref (et->contact);
+ email_menu_free (et->primary);
+ email_menu_free (et->email2);
+ email_menu_free (et->email3);
+
+ g_free (et);
+}
+
+static void
+email_table_from_contact (EMailTable *et)
+{
+ g_return_if_fail (et != NULL);
+
+ 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_contact (EMailTable *et)
+{
+ gchar *curr;
+
+ g_return_if_fail (et != NULL);
+
+ curr = et->primary->current_selection;
+ if (curr && !strcmp (curr, _(EMPTY_ENTRY)))
+ curr = NULL;
+ e_contact_set (et->contact, E_CONTACT_EMAIL_1, curr);
+
+ curr = et->email2->current_selection;
+ if (curr && !strcmp (curr, _(EMPTY_ENTRY)))
+ curr = NULL;
+ e_contact_set (et->contact, E_CONTACT_EMAIL_2, curr);
+
+ curr = et->email3->current_selection;
+ if (curr && !strcmp (curr, _(EMPTY_ENTRY)))
+ curr = NULL;
+ e_contact_set (et->contact, E_CONTACT_EMAIL_3, curr);
+}
+
+static void
+email_table_save_contact_cb (EBook *book, EBookStatus status, gpointer closure)
+{
+ EContact *contact = E_CONTACT (closure);
+
+ if (status == E_BOOK_ERROR_OK) {
+ e_book_async_commit_contact (book, contact, NULL, NULL);
+ }
+ if (book)
+ g_object_unref (book);
+ g_object_unref (contact);
+}
+
+static void
+email_table_ok_cb (MiniWizard *wiz, gpointer closure)
+{
+ EMailTable *et = (EMailTable *) closure;
+
+ email_table_to_contact (et);
+
+ g_object_ref (et->contact);
+
+ addressbook_load_default_book (email_table_save_contact_cb, et->contact);
+
+ mini_wizard_destroy (wiz);
+}
+
+static void
+email_table_init (MiniWizard *wiz, EContact *contact, const gchar *extra_address)
+{
+ EMailTable *et;
+
+ gchar *name_str;
+ gint xpad, ypad;
+ GtkAttachOptions label_x_opts, label_y_opts;
+ GtkAttachOptions menu_x_opts, menu_y_opts;
+
+ g_return_if_fail (contact && E_IS_CONTACT (contact));
+
+ et = g_new (EMailTable, 1);
+
+ et->contact = contact;
+ g_object_ref (et->contact);
+
+ et->table = gtk_table_new (4, 2, FALSE);
+
+ et->primary = email_menu_new ();
+ et->email2 = email_menu_new ();
+ et->email3 = email_menu_new ();
+
+ email_menu_add_options_from_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_contact (et);
+
+ label_x_opts = GTK_FILL;
+ label_y_opts = GTK_FILL;
+ menu_x_opts = GTK_EXPAND | GTK_FILL;
+ menu_y_opts = GTK_EXPAND | GTK_FILL;
+ xpad = 3;
+ ypad = 3;
+
+ name_str = e_contact_get (et->contact, E_CONTACT_FULL_NAME);
+ gtk_table_attach (GTK_TABLE (et->table),
+ gtk_label_new (name_str),
+ 0, 2, 0, 1,
+ label_x_opts, label_y_opts, xpad, ypad);
+ g_free (name_str);
+
+ gtk_table_attach (GTK_TABLE (et->table),
+ gtk_label_new (_("Primary Email")),
+ 0, 1, 1, 2,
+ label_x_opts, label_y_opts, xpad, ypad);
+
+ gtk_table_attach (GTK_TABLE (et->table),
+ et->primary->option_menu,
+ 1, 2, 1, 2,
+ menu_x_opts, menu_y_opts, xpad, ypad);
+
+ gtk_table_attach (GTK_TABLE (et->table),
+ gtk_label_new (_("Email 2")),
+ 0, 1, 2, 3,
+ label_x_opts, label_y_opts, xpad, ypad);
+
+ gtk_table_attach (GTK_TABLE (et->table),
+ et->email2->option_menu,
+ 1, 2, 2, 3,
+ menu_x_opts, menu_y_opts, xpad, ypad);
+
+ gtk_table_attach (GTK_TABLE (et->table),
+ gtk_label_new (_("Email 3")),
+ 0, 1, 3, 4,
+ label_x_opts, label_y_opts, xpad, ypad);
+
+ gtk_table_attach (GTK_TABLE (et->table),
+ et->email3->option_menu,
+ 1, 2, 3, 4,
+ menu_x_opts, menu_y_opts, xpad, ypad);
+
+ gtk_widget_show_all (et->primary->option_menu);
+ gtk_widget_show_all (et->email2->option_menu);
+ gtk_widget_show_all (et->email3->option_menu);
+
+ gtk_widget_show_all (et->table);
+ mini_wizard_container_add (wiz, et->table);
+ wiz->ok_cb = email_table_ok_cb;
+ wiz->cleanup_cb = email_table_cleanup_cb;
+ wiz->closure = et;
+}
+
+/*
+ * This code is for the little UI thing that lets you pick from a set of contacts
+ * and decide which one you want to add the e-mail address to.
+ */
+
+typedef struct _ContactPicker ContactPicker;
+struct _ContactPicker {
+ GtkWidget *body;
+ GtkWidget *list;
+ GtkListStore *model;
+ GList *contacts;
+ gchar *new_name;
+ gchar *new_email;
+
+ EContact *current_contact;
+};
+
+enum {
+ COLUMN_ACTION,
+ COLUMN_CONTACT
+};
+
+static void
+contact_picker_selection_changed (GtkTreeSelection *selection, gpointer closure)
+{
+ MiniWizard *wiz = (MiniWizard *) closure;
+ ContactPicker *pick = (ContactPicker *) wiz->closure;
+ gboolean selected;
+ GtkTreeIter iter;
+
+ selected = gtk_tree_selection_get_selected (selection, NULL, &iter);
+
+ gtk_widget_set_sensitive (wiz->ok_button, selected);
+
+ if (selected) {
+ gtk_tree_model_get (GTK_TREE_MODEL (pick->model), &iter,
+ COLUMN_CONTACT, &pick->current_contact,
+ -1);
+ }
+ else {
+ pick->current_contact = NULL;
+ }
+}
+
+static void
+contact_picker_ok_cb (MiniWizard *wiz, gpointer closure)
+{
+ ContactPicker *pick = (ContactPicker *) closure;
+
+ 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_contact, pick->new_email);
+ }
+}
+
+static void
+contact_picker_cleanup_cb (gpointer closure)
+{
+ ContactPicker *pick = (ContactPicker *) closure;
+
+ 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);
+}
+
+static void
+free_str (gpointer data,
+ GObject *where_the_object_was)
+{
+ g_free (data);
+}
+
+static void
+contact_picker_init (MiniWizard *wiz, const GList *contacts, const gchar *new_name, const gchar *new_email)
+{
+ ContactPicker *pick;
+ gchar *str;
+ GtkWidget *w;
+ GtkTreeIter iter;
+
+ pick = g_new (ContactPicker, 1);
+
+ pick->body = gtk_vbox_new (FALSE, 2);
+
+ pick->model = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_POINTER);
+
+ pick->list = gtk_tree_view_new_with_model (GTK_TREE_MODEL (pick->model));
+
+ gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (pick->list), TRUE);
+
+ gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (pick->list),
+ COLUMN_ACTION,
+ _("Select an Action"),
+ gtk_cell_renderer_text_new (),
+ "text", COLUMN_ACTION,
+ NULL);
+
+ gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (pick->list)),
+ GTK_SELECTION_SINGLE);
+
+ str = g_strdup_printf (_("Create a new contact \"%s\""), new_name);
+ gtk_list_store_append (pick->model, &iter);
+ gtk_list_store_set (pick->model, &iter,
+ COLUMN_ACTION, str,
+ COLUMN_CONTACT, NULL,
+ -1);
+ g_object_weak_ref (G_OBJECT (pick->model), free_str, str);
+
+ pick->contacts = NULL;
+ while (contacts) {
+ EContact *contact = (EContact *) contacts->data;
+ gchar *name_str = e_contact_get (contact, E_CONTACT_FULL_NAME);
+
+ 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_CONTACT, contact,
+ -1);
+ g_free (name_str);
+
+ g_object_weak_ref (G_OBJECT (pick->model), free_str, str);
+
+ contacts = g_list_next (contacts);
+ }
+
+ pick->new_name = g_strdup (new_name);
+ pick->new_email = g_strdup (new_email);
+
+ pick->current_contact = NULL;
+ gtk_widget_set_sensitive (wiz->ok_button, FALSE);
+
+ /* Connect some signals & callbacks */
+
+ 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 (contact_picker_selection_changed),
+ wiz);
+
+ /* Build our widget */
+
+ w = gtk_label_new (new_email);
+ gtk_box_pack_start (GTK_BOX (pick->body), w, FALSE, TRUE, 3);
+
+ gtk_box_pack_start (GTK_BOX (pick->body), pick->list, TRUE, TRUE, 2);
+ gtk_widget_show_all (pick->body);
+
+
+ /* Put it in our mini-wizard */
+
+ wiz->closure = pick;
+ mini_wizard_container_add (wiz, pick->body);
+}
+
+/* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** */
+
+/*
+ * The code for the actual EABPopupControl widget begins here.
+ */
+
+/* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** */
+
+
+static GtkObjectClass *parent_class;
+
+static void eab_popup_control_dispose (GObject *);
+static void eab_popup_control_query (EABPopupControl *);
+
+
+static void
+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 = eab_popup_control_dispose;
+}
+
+static void
+eab_popup_control_init (EABPopupControl *pop)
+{
+ pop->transitory = TRUE;
+}
+
+static void
+eab_popup_control_cleanup (EABPopupControl *pop)
+{
+ if (pop->contact) {
+ g_object_unref (pop->contact);
+ pop->contact = NULL;
+ }
+
+ if (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;
+ }
+
+ if (pop->book) {
+ g_object_unref (pop->book);
+ pop->book = NULL;
+ }
+
+ g_free (pop->name);
+ pop->name = NULL;
+
+ g_free (pop->email);
+ pop->email = NULL;
+}
+
+static void
+eab_popup_control_dispose (GObject *obj)
+{
+ EABPopupControl *pop = EAB_POPUP_CONTROL (obj);
+
+ eab_popup_control_cleanup (pop);
+
+ if (G_OBJECT_CLASS (parent_class)->dispose)
+ G_OBJECT_CLASS (parent_class)->dispose (obj);
+}
+
+GType
+eab_popup_control_get_type (void)
+{
+ static GType pop_type = 0;
+
+ if (!pop_type) {
+ static const GTypeInfo pop_info = {
+ sizeof (EABPopupControlClass),
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ (GClassInitFunc) eab_popup_control_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (EABPopupControl),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) eab_popup_control_init,
+ };
+
+ pop_type = g_type_register_static (gtk_event_box_get_type (), "EABPopupControl", &pop_info, 0);
+ }
+
+ return pop_type;
+}
+
+static void
+eab_popup_control_refresh_names (EABPopupControl *pop)
+{
+ if (pop->name_widget) {
+ if (pop->name && *pop->name) {
+ gtk_label_set_text (GTK_LABEL (pop->name_widget), pop->name);
+ gtk_widget_show (pop->name_widget);
+ } else {
+ gtk_widget_hide (pop->name_widget);
+ }
+ }
+
+ if (pop->email_widget) {
+ if (pop->email && *pop->email) {
+ gtk_label_set_text (GTK_LABEL (pop->email_widget), pop->email);
+ gtk_widget_show (pop->email_widget);
+ } else {
+ gtk_widget_hide (pop->email_widget);
+ }
+ }
+
+ eab_popup_control_query (pop);
+}
+
+static gint
+refresh_timeout_cb (gpointer ptr)
+{
+ EABPopupControl *pop = EAB_POPUP_CONTROL (ptr);
+ eab_popup_control_refresh_names (pop);
+ pop->scheduled_refresh = 0;
+ return 0;
+}
+
+static void
+eab_popup_control_schedule_refresh (EABPopupControl *pop)
+{
+ if (pop->scheduled_refresh == 0)
+ 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
+eab_popup_control_set_free_form (EABPopupControl *pop, const gchar *txt)
+{
+ gchar *lt, *gt = NULL;
+
+ g_return_val_if_fail (pop && EAB_IS_POPUP_CONTROL (pop), FALSE);
+
+ if (txt == NULL)
+ return FALSE;
+
+ lt = strchr (txt, '<');
+ if (lt)
+ gt = strchr (txt, '>');
+
+ if (lt && gt && lt+1 < gt) {
+ gchar *name = g_strndup (txt, lt-txt);
+ gchar *email = g_strndup (lt+1, gt-lt-1);
+ eab_popup_control_set_name (pop, name);
+ eab_popup_control_set_email (pop, email);
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static void
+eab_popup_control_set_name (EABPopupControl *pop, const gchar *name)
+{
+ g_return_if_fail (pop && EAB_IS_POPUP_CONTROL (pop));
+
+ /* We only allow the name to be set once. */
+ if (pop->name)
+ return;
+
+ if (!eab_popup_control_set_free_form (pop, name)) {
+ pop->name = g_strdup (name);
+ if (pop->name)
+ g_strstrip (pop->name);
+ }
+
+ eab_popup_control_schedule_refresh (pop);
+}
+
+static void
+eab_popup_control_set_email (EABPopupControl *pop, const gchar *email)
+{
+ 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 (!eab_popup_control_set_free_form (pop, email)) {
+ pop->email = g_strdup (email);
+ if (pop->email)
+ g_strstrip (pop->email);
+ }
+
+ eab_popup_control_schedule_refresh (pop);
+}
+
+void
+eab_popup_control_construct (EABPopupControl *pop)
+{
+ GtkWidget *vbox, *name_holder;
+ GdkColor color = { 0x0, 0xffff, 0xffff, 0xffff };
+
+ g_return_if_fail (pop && EAB_IS_POPUP_CONTROL (pop));
+
+ pop->main_vbox = gtk_vbox_new (FALSE, 0);
+
+ /* Build Generic View */
+
+ name_holder = gtk_event_box_new ();
+ vbox = gtk_vbox_new (FALSE, 2);
+ pop->name_widget = gtk_label_new ("");
+ pop->email_widget = gtk_label_new ("");
+
+ gtk_box_pack_start (GTK_BOX (vbox), pop->name_widget, TRUE, TRUE, 2);
+ gtk_box_pack_start (GTK_BOX (vbox), pop->email_widget, TRUE, TRUE, 2);
+ gtk_container_add (GTK_CONTAINER (name_holder), GTK_WIDGET (vbox));
+
+ if (gdk_colormap_alloc_color (gtk_widget_get_colormap (GTK_WIDGET (name_holder)), &color, FALSE, TRUE)) {
+ GtkStyle *style = gtk_style_copy (gtk_widget_get_style (GTK_WIDGET (name_holder)));
+ style->bg[0] = color;
+ gtk_widget_set_style (GTK_WIDGET (name_holder), style);
+ g_object_unref (style);
+ }
+
+ pop->generic_view = gtk_frame_new (NULL);
+ gtk_container_add (GTK_CONTAINER (pop->generic_view), name_holder);
+ gtk_box_pack_start (GTK_BOX (pop->main_vbox), pop->generic_view, TRUE, TRUE, 0);
+ gtk_widget_show_all (pop->generic_view);
+
+ pop->query_msg = gtk_label_new (_("Querying Addressbook..."));
+ gtk_box_pack_start (GTK_BOX (pop->main_vbox), pop->query_msg, TRUE, TRUE, 0);
+ gtk_widget_show (pop->query_msg);
+
+ /* Build 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 */
+
+ gtk_container_add (GTK_CONTAINER (pop), pop->main_vbox);
+ gtk_widget_show (pop->main_vbox);
+
+ gtk_container_set_border_width (GTK_CONTAINER (vbox), 3);
+ gtk_container_set_border_width (GTK_CONTAINER (pop), 2);
+}
+
+static GtkWidget *
+eab_popup_new (void)
+{
+ EABPopupControl *pop = g_object_new (EAB_TYPE_POPUP_CONTROL, NULL);
+ eab_popup_control_construct (pop);
+ return GTK_WIDGET (pop);
+}
+
+static void
+emit_event (EABPopupControl *pop, const char *event)
+{
+ if (pop->es) {
+ BonoboArg *arg;
+
+ arg = bonobo_arg_new (BONOBO_ARG_BOOLEAN);
+ BONOBO_ARG_SET_BOOLEAN (arg, TRUE);
+ bonobo_event_source_notify_listeners_full (pop->es,
+ "GNOME/Evolution/Addressbook/AddressPopup",
+ "Event",
+ event,
+ arg, NULL);
+ bonobo_arg_release (arg);
+ }
+}
+
+static void
+contact_editor_cb (EBook *book, EBookStatus status, gpointer closure)
+{
+ if (status == E_BOOK_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);
+ }
+
+ if (book)
+ g_object_unref (book);
+}
+
+static void
+edit_contact_info_cb (GtkWidget *button, EABPopupControl *pop)
+{
+ emit_event (pop, "Hide");
+
+ addressbook_load_default_book (contact_editor_cb, pop);
+}
+
+static void
+eab_popup_control_display_contact (EABPopupControl *pop, EContact *contact)
+{
+ GtkWidget *b;
+
+ 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->contact = contact;
+ g_object_ref (pop->contact);
+
+ 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"));
+ gtk_box_pack_start (GTK_BOX (pop->main_vbox), b, TRUE, TRUE, 0);
+ g_signal_connect (b,
+ "clicked",
+ G_CALLBACK (edit_contact_info_cb),
+ pop);
+ gtk_widget_show (b);
+}
+
+static void
+add_contacts_cb (GtkWidget *button, EABPopupControl *pop)
+{
+ if (pop->email && *pop->email) {
+ if (pop->name && *pop->name)
+ e_contact_quick_add (pop->name, pop->email, NULL, NULL);
+ else
+ e_contact_quick_add_free_form (pop->email, NULL, NULL);
+
+ }
+ eab_popup_control_cleanup (pop);
+ emit_event (pop, "Destroy");
+}
+
+static void
+eab_popup_control_no_matches (EABPopupControl *pop)
+{
+ GtkWidget *b;
+
+ g_return_if_fail (pop && EAB_IS_POPUP_CONTROL (pop));
+
+ b = e_button_new_with_stock_icon (_("Add to Contacts"), "gtk-add");
+
+ gtk_box_pack_start (GTK_BOX (pop->main_vbox), b, TRUE, TRUE, 0);
+ g_signal_connect (b,
+ "clicked",
+ G_CALLBACK (add_contacts_cb),
+ pop);
+ gtk_widget_show (b);
+}
+
+static void
+wizard_destroy_cb (MiniWizard *wiz, gpointer closure)
+{
+ gtk_widget_destroy (GTK_WIDGET (closure));
+}
+
+static void
+eab_popup_control_ambiguous_email_add (EABPopupControl *pop, const GList *contacts)
+{
+ MiniWizard *wiz = mini_wizard_new ();
+ GtkWidget *win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+
+ wiz->destroy_cb = wizard_destroy_cb;
+ wiz->destroy_closure = win;
+
+ gtk_window_set_title (GTK_WINDOW (win), _("Merge E-Mail Address"));
+ gtk_window_set_position (GTK_WINDOW (win), GTK_WIN_POS_MOUSE);
+
+ contact_picker_init (wiz, contacts, pop->name, pop->email);
+
+ eab_popup_control_cleanup (pop);
+ emit_event (pop, "Destroy");
+
+ gtk_container_add (GTK_CONTAINER (win), wiz->body);
+ gtk_widget_show_all (win);
+}
+
+static void
+eab_popup_control_multiple_matches (EABPopupControl *pop, const GList *contacts)
+{
+ pop->multiple_matches = TRUE;
+
+ eab_popup_control_ambiguous_email_add (pop, contacts);
+}
+
+/** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **/
+
+/*
+ * Addressbook Query Fun
+ */
+
+static void
+name_only_query_cb (EBook *book, EBookStatus status, GList *contacts, gpointer closure)
+{
+ EABPopupControl *pop;
+
+ if (status != E_BOOK_ERROR_OK)
+ return;
+
+ pop = EAB_POPUP_CONTROL (closure);
+
+ pop->query_tag = 0;
+
+ if (contacts == NULL) {
+ eab_popup_control_no_matches (pop);
+ } else {
+ 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, EBookStatus status, GList *contacts, gpointer closure)
+{
+ EABPopupControl *pop;
+
+ if (status != E_BOOK_ERROR_OK)
+ return;
+
+ pop = EAB_POPUP_CONTROL (closure);
+
+ pop->query_tag = 0;
+ gtk_widget_hide (pop->query_msg);
+
+ 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 = eab_name_and_email_query (book, pop->name, NULL, name_only_query_cb, pop);
+ } else {
+ eab_popup_control_no_matches (pop);
+ }
+
+ } else {
+ if (g_list_length ((GList *) contacts) == 1)
+ eab_popup_control_display_contact (pop, E_CONTACT (contacts->data));
+ else
+ 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)
+{
+ EABPopupControl *pop = EAB_POPUP_CONTROL (closure);
+
+ 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);
+ if (pop->book)
+ g_object_unref (pop->book);
+ pop->book = book;
+ }
+
+ pop->query_tag = eab_name_and_email_query (book, pop->name, pop->email, query_cb, pop);
+
+ g_object_unref (pop);
+}
+
+static void
+eab_popup_control_query (EABPopupControl *pop)
+{
+ g_return_if_fail (pop && EAB_IS_POPUP_CONTROL (pop));
+
+ g_object_ref (pop);
+
+ addressbook_load_default_book (start_query, pop);
+}
+
+/** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **/
+
+enum {
+ PROPERTY_NAME,
+ PROPERTY_EMAIL,
+ PROPERTY_TRANSITORY
+};
+
+static void
+set_prop (BonoboPropertyBag *bag, const BonoboArg *arg, guint arg_id, CORBA_Environment *ev, gpointer user_data)
+{
+ EABPopupControl *pop = EAB_POPUP_CONTROL (user_data);
+
+ switch (arg_id) {
+
+ case PROPERTY_NAME:
+ eab_popup_control_set_name (pop, BONOBO_ARG_GET_STRING (arg));
+ break;
+
+ case PROPERTY_EMAIL:
+ eab_popup_control_set_email (pop, BONOBO_ARG_GET_STRING (arg));
+ break;
+
+ default:
+ g_assert_not_reached ();
+ }
+}
+
+static void
+get_prop (BonoboPropertyBag *bag, BonoboArg *arg, guint arg_id, CORBA_Environment *ev, gpointer user_data)
+{
+ EABPopupControl *pop = EAB_POPUP_CONTROL (user_data);
+
+ switch (arg_id) {
+
+ case PROPERTY_NAME:
+ BONOBO_ARG_SET_STRING (arg, pop->name);
+ break;
+
+ case PROPERTY_EMAIL:
+ BONOBO_ARG_SET_STRING (arg, pop->email);
+ break;
+
+ case PROPERTY_TRANSITORY:
+ BONOBO_ARG_SET_BOOLEAN (arg, pop->transitory);
+ break;
+
+ default:
+ g_assert_not_reached ();
+ }
+}
+
+BonoboControl *
+eab_popup_control_new (void)
+{
+ BonoboControl *control;
+ BonoboPropertyBag *bag;
+ EABPopupControl *addy;
+ GtkWidget *w;
+
+ w = eab_popup_new ();
+ addy = EAB_POPUP_CONTROL (w);
+
+ control = bonobo_control_new (w);
+ gtk_widget_show (w);
+
+ bag = bonobo_property_bag_new (get_prop, set_prop, w);
+ bonobo_property_bag_add (bag, "name", PROPERTY_NAME,
+ BONOBO_ARG_STRING, NULL, NULL,
+ BONOBO_PROPERTY_WRITEABLE | BONOBO_PROPERTY_READABLE);
+
+ bonobo_property_bag_add (bag, "email", PROPERTY_EMAIL,
+ BONOBO_ARG_STRING, NULL, NULL,
+ BONOBO_PROPERTY_WRITEABLE | BONOBO_PROPERTY_READABLE);
+
+ bonobo_property_bag_add (bag, "transitory", PROPERTY_TRANSITORY,
+ BONOBO_ARG_BOOLEAN, NULL, NULL,
+ BONOBO_PROPERTY_READABLE);
+
+ bonobo_control_set_properties (control, bonobo_object_corba_objref (BONOBO_OBJECT (bag)), NULL);
+ bonobo_object_unref (BONOBO_OBJECT (bag));
+
+ addy->es = bonobo_event_source_new ();
+ bonobo_object_add_interface (BONOBO_OBJECT (control),
+ BONOBO_OBJECT (addy->es));
+
+ return control;
+}
diff --git a/addressbook/gui/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;
-}