aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui/contact-list-editor/e-contact-list-model.c
diff options
context:
space:
mode:
authorChris Toshok <toshok@ximian.com>2001-06-25 09:09:43 +0800
committerChris Toshok <toshok@src.gnome.org>2001-06-25 09:09:43 +0800
commit8cb68557aebb62334f68beeea60cf3bbf5930f9e (patch)
treebc27d2cd32645cddfd8631f6d6cc602ab29eea4e /addressbook/gui/contact-list-editor/e-contact-list-model.c
parentdcf2e1a4acef258ff7473425cbd8d119294e41c0 (diff)
downloadgsoc2013-evolution-8cb68557aebb62334f68beeea60cf3bbf5930f9e.tar
gsoc2013-evolution-8cb68557aebb62334f68beeea60cf3bbf5930f9e.tar.gz
gsoc2013-evolution-8cb68557aebb62334f68beeea60cf3bbf5930f9e.tar.bz2
gsoc2013-evolution-8cb68557aebb62334f68beeea60cf3bbf5930f9e.tar.lz
gsoc2013-evolution-8cb68557aebb62334f68beeea60cf3bbf5930f9e.tar.xz
gsoc2013-evolution-8cb68557aebb62334f68beeea60cf3bbf5930f9e.tar.zst
gsoc2013-evolution-8cb68557aebb62334f68beeea60cf3bbf5930f9e.zip
correct path to libecontacteditor.a. (minicard_widget_test_LDADD): same.
2001-06-24 Chris Toshok <toshok@ximian.com> * gui/widgets/Makefile.am (minicard_test_LDADD): correct path to libecontacteditor.a. (minicard_widget_test_LDADD): same. (INCLUDES): same, for the includes. * gui/widgets/e-minicard.h: correct e-contact-editor.h path. * gui/widgets/e-addressbook-util.h: correct path to e-contact-editor.h, and add e-contact-list-editor.h. Add prototype for e_addressbook_show_contact_list_editor. * gui/widgets/e-addressbook-util.c: remove #include "e-contact-editor.h" (our header includes it.) (added_cb): rename card_added_cb to this, and make it so it can be reused in both the list and card cases. remove the g_print too. (modified_cb): same for modified case. (deleted_cb): same for deleted case. (editor_closed_cb): change first arg to GtkObject* so we can reuse this for both list and card. (e_addressbook_show_contact_editor): use added_cb, modified_cb, deleted_cb, and pass FALSE as user_data. (e_addressbook_show_contact_list_editor): new function, same as above but creating a contact-list-editor, and pass TRUE as user_data. * gui/component/e-address-popup.c: correct path to contact-editor. * gui/component/e-address-widget.c: same. * gui/component/select-names/e-select-names-popup.c: same. * gui/component/select-names/e-select-names-text-model.c: same. * gui/component/addressbook.c (new_contact_list_cb): new function. (update_command_state): update ContactNewList command. (verbs): remove ViewAll from the toolbar from the verb list. Add ContactNewList. (pixmaps): same for pixmaps. * gui/component/Makefile.am (evolution_addressbook_LDADD): new path for contact-editor. (INCLUDES): same. * gui/contact-list-editor/e-contact-list-model.h: * gui/contact-list-editor/e-contact-list-model.c: * gui/contact-list-editor/e-contact-list-editor.h: * gui/contact-list-editor/e-contact-list-editor.c: * gui/contact-list-editor/Makefile.am: Initial contact-list editor commit. * gui/Makefile.am (SUBDIRS): add contact-editor. * Makefile.am: (SUBDIRS): remove contact-editor. svn path=/trunk/; revision=10463
Diffstat (limited to 'addressbook/gui/contact-list-editor/e-contact-list-model.c')
-rw-r--r--addressbook/gui/contact-list-editor/e-contact-list-model.c190
1 files changed, 190 insertions, 0 deletions
diff --git a/addressbook/gui/contact-list-editor/e-contact-list-model.c b/addressbook/gui/contact-list-editor/e-contact-list-model.c
new file mode 100644
index 0000000000..8d8831a6ab
--- /dev/null
+++ b/addressbook/gui/contact-list-editor/e-contact-list-model.c
@@ -0,0 +1,190 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+#include <config.h>
+#include "e-contact-list-model.h"
+
+#define PARENT_TYPE e_table_model_get_type()
+ETableModelClass *parent_class;
+
+#define COLS 1
+
+/* This function returns the number of columns in our ETableModel. */
+static int
+contact_list_col_count (ETableModel *etc)
+{
+ return COLS;
+}
+
+/* This function returns the number of rows in our ETableModel. */
+static int
+contact_list_row_count (ETableModel *etc)
+{
+ EContactListModel *model = E_CONTACT_LIST_MODEL (etc);
+ return model->simple_count + model->email_count;
+}
+
+/* This function returns the value at a particular point in our ETableModel. */
+static void *
+contact_list_value_at (ETableModel *etc, int col, int row)
+{
+ EContactListModel *model = E_CONTACT_LIST_MODEL (etc);
+
+ if (row < model->simple_count)
+ return (char*)e_card_simple_get_const (model->simples[row], E_CARD_SIMPLE_FIELD_EMAIL);
+ else
+ return model->emails [row - model->simple_count];
+}
+
+/* This function sets the value at a particular point in our ETableModel. */
+static void
+contact_list_set_value_at (ETableModel *etc, int col, int row, const void *val)
+{
+ /* nothing */
+}
+
+/* This function returns whether a particular cell is editable. */
+static gboolean
+contact_list_is_cell_editable (ETableModel *etc, int col, int row)
+{
+ return FALSE;
+}
+
+/* This function duplicates the value passed to it. */
+static void *
+contact_list_duplicate_value (ETableModel *etc, int col, const void *value)
+{
+ return g_strdup(value);
+}
+
+/* This function frees the value passed to it. */
+static void
+contact_list_free_value (ETableModel *etc, int col, void *value)
+{
+ g_free(value);
+}
+
+static void *
+contact_list_initialize_value (ETableModel *etc, int col)
+{
+ return g_strdup("");
+}
+
+static gboolean
+contact_list_value_is_empty (ETableModel *etc, int col, const void *value)
+{
+ return !(value && *(char *)value);
+}
+
+static char *
+contact_list_value_to_string (ETableModel *etc, int col, const void *value)
+{
+ return g_strdup(value);
+}
+
+static void
+contact_list_model_destroy (GtkObject *o)
+{
+}
+
+static void
+e_contact_list_model_class_init (GtkObjectClass *object_class)
+{
+ ETableModelClass *model_class = (ETableModelClass *) object_class;
+
+ parent_class = gtk_type_class (PARENT_TYPE);
+
+ object_class->destroy = contact_list_model_destroy;
+
+ model_class->column_count = contact_list_col_count;
+ model_class->row_count = contact_list_row_count;
+ model_class->value_at = contact_list_value_at;
+ model_class->set_value_at = contact_list_set_value_at;
+ model_class->is_cell_editable = contact_list_is_cell_editable;
+ model_class->duplicate_value = contact_list_duplicate_value;
+ model_class->free_value = contact_list_free_value;
+ model_class->initialize_value = contact_list_initialize_value;
+ model_class->value_is_empty = contact_list_value_is_empty;
+ model_class->value_to_string = contact_list_value_to_string;
+}
+
+static void
+e_contact_list_model_init (GtkObject *object)
+{
+ EContactListModel *model = E_CONTACT_LIST_MODEL(object);
+
+ model->simples = NULL;
+ model->simple_count = 0;
+ model->emails = NULL;
+ model->email_count = 0;
+}
+
+GtkType
+e_contact_list_model_get_type (void)
+{
+ static GtkType type = 0;
+
+ if (!type){
+ GtkTypeInfo info = {
+ "EContactListModel",
+ sizeof (EContactListModel),
+ sizeof (EContactListModelClass),
+ (GtkClassInitFunc) e_contact_list_model_class_init,
+ (GtkObjectInitFunc) e_contact_list_model_init,
+ NULL, /* reserved 1 */
+ NULL, /* reserved 2 */
+ (GtkClassInitFunc) NULL
+ };
+
+ type = gtk_type_unique (PARENT_TYPE, &info);
+ }
+
+ return type;
+}
+
+void
+e_contact_list_model_construct (EContactListModel *model)
+{
+}
+
+ETableModel *
+e_contact_list_model_new ()
+{
+ EContactListModel *model;
+
+ model = gtk_type_new (e_contact_list_model_get_type ());
+
+ e_contact_list_model_construct (model);
+
+ return E_TABLE_MODEL(model);
+}
+
+void
+e_contact_list_model_add_email (EContactListModel *model,
+ const char *email)
+{
+ model->email_count ++;
+ model->emails = g_renew (char*, model->emails, model->email_count);
+ model->emails[model->email_count - 1] = g_strdup (email);
+ e_table_model_changed (E_TABLE_MODEL (model));
+}
+
+void
+e_contact_list_model_add_card (EContactListModel *model,
+ ECardSimple *simple)
+{
+}
+
+void
+e_contact_list_model_remove_row (EContactListModel *model, int row)
+{
+ if (row < model->simple_count) {
+ memcpy (model->simples + row, model->simples + row + 1, model->simple_count - row);
+ model->simple_count --;
+ }
+ else {
+ int email_row = row - model->simple_count;
+ memcpy (model->emails + email_row, model->emails + email_row + 1, model->email_count - email_row);
+ model->email_count --;
+ }
+ e_table_model_row_deleted (E_TABLE_MODEL (model), row);
+}