aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui/widgets/e-addressbook-reflow-adapter.c
diff options
context:
space:
mode:
Diffstat (limited to 'addressbook/gui/widgets/e-addressbook-reflow-adapter.c')
-rw-r--r--addressbook/gui/widgets/e-addressbook-reflow-adapter.c152
1 files changed, 68 insertions, 84 deletions
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);
}