aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@helixcode.com>2000-07-08 07:18:12 +0800
committerChris Lahey <clahey@src.gnome.org>2000-07-08 07:18:12 +0800
commit5e793d76f46de7aa61a7e4d738c7753424041ec8 (patch)
tree269a91190cc4d9d3db3b9ad1017d16f45f10721f
parentfffc023e64825d6488fa3d1827fe50d924af3535 (diff)
downloadgsoc2013-evolution-5e793d76f46de7aa61a7e4d738c7753424041ec8.tar.gz
gsoc2013-evolution-5e793d76f46de7aa61a7e4d738c7753424041ec8.tar.zst
gsoc2013-evolution-5e793d76f46de7aa61a7e4d738c7753424041ec8.zip
Implemented the get_cards function.
2000-07-07 Christopher James Lahey <clahey@helixcode.com> * gui/component/select-names/e-select-names-manager.c, gui/component/select-names/e-select-names-model.c: Implemented the get_cards function. * gui/component/select-names/e-select-names.c: Implemented adding cards through the interface. svn path=/trunk/; revision=3966
-rw-r--r--addressbook/ChangeLog9
-rw-r--r--addressbook/gui/component/select-names/e-select-names-manager.c2
-rw-r--r--addressbook/gui/component/select-names/e-select-names-model.c44
-rw-r--r--addressbook/gui/component/select-names/e-select-names.c32
4 files changed, 84 insertions, 3 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index 322a3b8fcc..5492eca4ea 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,5 +1,14 @@
2000-07-07 Christopher James Lahey <clahey@helixcode.com>
+ * gui/component/select-names/e-select-names-manager.c,
+ gui/component/select-names/e-select-names-model.c: Implemented the
+ get_cards function.
+
+ * gui/component/select-names/e-select-names.c: Implemented adding
+ cards through the interface.
+
+2000-07-07 Christopher James Lahey <clahey@helixcode.com>
+
* gui/component/select-names/e-select-names-manager.c: Make the
entry widgets we create editable.
diff --git a/addressbook/gui/component/select-names/e-select-names-manager.c b/addressbook/gui/component/select-names/e-select-names-manager.c
index 4b0d65902e..51a4d889c1 100644
--- a/addressbook/gui/component/select-names/e-select-names-manager.c
+++ b/addressbook/gui/component/select-names/e-select-names-manager.c
@@ -239,7 +239,7 @@ EList *e_select_names_manager_get_cards (ESel
for (e_iterator_reset(iterator); e_iterator_is_valid(iterator); e_iterator_next(iterator)) {
const ESelectNamesManagerSection *section = e_iterator_get(iterator);
if (!strcmp(section->id, id)) {
-
+ return e_select_names_model_get_cards(section->model);
}
}
return NULL;
diff --git a/addressbook/gui/component/select-names/e-select-names-model.c b/addressbook/gui/component/select-names/e-select-names-model.c
index 98745523a1..c131c4d66f 100644
--- a/addressbook/gui/component/select-names/e-select-names-model.c
+++ b/addressbook/gui/component/select-names/e-select-names-model.c
@@ -14,6 +14,7 @@
#include "e-select-names-model.h"
#include "e-util/e-util.h"
+#include "addressbook/backend/ebook/e-card-simple.h"
enum {
E_SELECT_NAMES_MODEL_CHANGED,
@@ -189,10 +190,47 @@ e_select_names_model_init (ESelectNamesModel *model)
model->data = e_list_new(data_copy, data_free, model);
}
+static void *
+copy_func(const void *data, void *user_data)
+{
+ GtkObject *object = (void *) data;
+ if (object)
+ gtk_object_ref(object);
+ return object;
+}
+
+static void
+free_func(void *data, void *user_data)
+{
+ GtkObject *object = data;
+ if (object)
+ gtk_object_unref(object);
+}
+
/* Of type ECard */
EList *e_select_names_model_get_cards (ESelectNamesModel *model)
{
- return NULL;
+ EList *list = e_list_new(copy_func, free_func, NULL);
+ EIterator *iterator = e_list_get_iterator(model->data);
+ EIterator *new_iterator = e_list_get_iterator(list);
+
+ for (e_iterator_reset(iterator); e_iterator_is_valid(iterator); e_iterator_next(iterator)) {
+ ESelectNamesModelData *node = (void *) e_iterator_get(iterator);
+ ECard *card;
+ ECardSimple *simple;
+ if (node->card) {
+ card = node->card;
+ gtk_object_ref(GTK_OBJECT(card));
+ } else {
+ card = e_card_new("");
+ }
+ simple = e_card_simple_new(card);
+ e_card_simple_set_arbitrary(simple, "text_version", "string", node->string);
+ e_iterator_insert(new_iterator, card, FALSE);
+ gtk_object_unref(GTK_OBJECT(card));
+ gtk_object_unref(GTK_OBJECT(simple));
+ }
+ return list;
}
EList *e_select_names_model_get_data (ESelectNamesModel *model)
@@ -351,12 +389,16 @@ e_select_names_model_add_item (ESelectNamesModel *model,
EIterator *iterator, /* NULL for at the beginning. */
ESelectNamesModelData *data)
{
+ e_iterator_insert(iterator, data, FALSE);
+ e_select_names_model_changed(model);
}
void
e_select_names_model_remove_item (ESelectNamesModel *model,
EIterator *iterator)
{
+ e_iterator_delete(iterator);
+ e_select_names_model_changed(model);
}
diff --git a/addressbook/gui/component/select-names/e-select-names.c b/addressbook/gui/component/select-names/e-select-names.c
index 646321694f..8814fe06eb 100644
--- a/addressbook/gui/component/select-names/e-select-names.c
+++ b/addressbook/gui/component/select-names/e-select-names.c
@@ -49,6 +49,7 @@ enum {
typedef struct {
char *title;
ETableModel *model;
+ ESelectNamesModel *source;
ESelectNames *names;
} ESelectNamesChild;
@@ -198,6 +199,7 @@ static void e_select_names_child_free(char *key, ESelectNamesChild *child, ESele
{
g_free(child->title);
gtk_object_unref(GTK_OBJECT(child->model));
+ gtk_object_unref(GTK_OBJECT(child->source));
g_free(key);
}
@@ -251,8 +253,34 @@ button_clicked(GtkWidget *button, ESelectNamesChild *child)
int row = names->currently_selected;
if (row != -1) {
ECard *card = e_addressbook_model_get_card(E_ADDRESSBOOK_MODEL(names->model), row);
- e_cardlist_model_add(E_CARDLIST_MODEL(child->model), &card, 1);
+ ESelectNamesModelData new = {E_SELECT_NAMES_MODEL_DATA_TYPE_CARD,
+ card,
+ NULL};
+ char *name, *email;
+ ECardSimple *simple = e_card_simple_new(card);
+ EIterator *iterator;
+
+ name = e_card_simple_get(simple, E_CARD_SIMPLE_FIELD_FULL_NAME);
+ email = e_card_simple_get(simple, E_CARD_SIMPLE_FIELD_EMAIL);
+ if (name && *name && email && *email) {
+ new.string = g_strdup_printf("%s <%s>", name, email);
+ } else if (email && *email) {
+ new.string = g_strdup_printf("%s", email);
+ } else if (name && *name) {
+ new.string = g_strdup_printf("%s <>", name);
+ } else {
+ new.string = g_strdup("");
+ }
+
+ iterator = e_list_get_iterator(e_select_names_model_get_data(child->source));
+ e_iterator_last(iterator);
+ e_select_names_model_add_item(child->source, iterator, &new);
+
+ gtk_object_unref(GTK_OBJECT(simple));
gtk_object_unref(GTK_OBJECT(card));
+ g_free(email);
+ g_free(name);
+ g_free(new.string);
}
}
@@ -305,7 +333,9 @@ e_select_names_add_section(ESelectNames *e_select_names, char *name, char *id, E
etable = e_table_new (header, model, SPEC2);
child->model = model;
+ child->source = source;
gtk_object_ref(GTK_OBJECT(child->model));
+ gtk_object_ref(GTK_OBJECT(child->source));
gtk_widget_show(etable);