aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui/widgets/e-addressbook-table-adapter.c
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/e-addressbook-table-adapter.c
parent0fb08f3ff81575a4749d851404233f34252dd2f2 (diff)
downloadgsoc2013-evolution-653cfffc0e00dfb59b36813c1b45c53d3f773c65.tar
gsoc2013-evolution-653cfffc0e00dfb59b36813c1b45c53d3f773c65.tar.gz
gsoc2013-evolution-653cfffc0e00dfb59b36813c1b45c53d3f773c65.tar.bz2
gsoc2013-evolution-653cfffc0e00dfb59b36813c1b45c53d3f773c65.tar.lz
gsoc2013-evolution-653cfffc0e00dfb59b36813c1b45c53d3f773c65.tar.xz
gsoc2013-evolution-653cfffc0e00dfb59b36813c1b45c53d3f773c65.tar.zst
gsoc2013-evolution-653cfffc0e00dfb59b36813c1b45c53d3f773c65.zip
Merge new-ui-branch to the trunk.
svn path=/trunk/; revision=22965
Diffstat (limited to 'addressbook/gui/widgets/e-addressbook-table-adapter.c')
-rw-r--r--addressbook/gui/widgets/e-addressbook-table-adapter.c207
1 files changed, 78 insertions, 129 deletions
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);
}