aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Toshok <toshok@ximian.com>2001-06-26 05:51:17 +0800
committerChris Toshok <toshok@src.gnome.org>2001-06-26 05:51:17 +0800
commit9a1c55ede5e6aad25d0053b097dab47a66b479d1 (patch)
tree019f1b0c0b08dd5c8ae5240fe77559fdd47040c7
parent0296d70c6e207fa4c6acc14f6a0541b14028b64e (diff)
downloadgsoc2013-evolution-9a1c55ede5e6aad25d0053b097dab47a66b479d1.tar
gsoc2013-evolution-9a1c55ede5e6aad25d0053b097dab47a66b479d1.tar.gz
gsoc2013-evolution-9a1c55ede5e6aad25d0053b097dab47a66b479d1.tar.bz2
gsoc2013-evolution-9a1c55ede5e6aad25d0053b097dab47a66b479d1.tar.lz
gsoc2013-evolution-9a1c55ede5e6aad25d0053b097dab47a66b479d1.tar.xz
gsoc2013-evolution-9a1c55ede5e6aad25d0053b097dab47a66b479d1.tar.zst
gsoc2013-evolution-9a1c55ede5e6aad25d0053b097dab47a66b479d1.zip
change layout slightly, the icon no longer pushes everything to the left,
2001-06-25 Chris Toshok <toshok@ximian.com> * gui/contact-list-editor/contact-list-editor.glade: change layout slightly, the icon no longer pushes everything to the left, and make the buttons on the right smaller and more in line with the other widgets. * gui/contact-list-editor/e-contact-list-model.c (contact_list_value_at): return the SimpleAndString->string instead of querying the ecardsimple. (e_contact_list_model_init): initially allocate 10 of each type (email and simple). (e_contact_list_model_add_email): realloc if need be. (e_contact_list_model_add_card): same, and initialize the string displayed to be "[Name] [<email>]". (e_contact_list_model_remove_row): change for SimpleAndString. (contact_list_model_destroy): free our 2 arrays. * gui/contact-list-editor/e-contact-list-model.h: add alloc counts and the SimpleAndString struct. * gui/contact-list-editor/e-contact-list-editor.c: Helix Code => Ximian. (e_contact_list_editor_init): hook up d&d destination signals, and un-#if 0 the delete_event signal. (table_drag_motion_cb): new function. (table_drag_drop_cb): new function. (table_drag_data_received_cb): new function. (file_close_cb): new function. (verbs) uncomment the close verb. (close_dialog): new function. (app_delete_event_cb): new function. * gui/contact-list-editor/e-contact-list-editor.h: Helix Code => Ximian. svn path=/trunk/; revision=10494
-rw-r--r--addressbook/ChangeLog36
-rw-r--r--addressbook/gui/contact-list-editor/contact-list-editor.glade182
-rw-r--r--addressbook/gui/contact-list-editor/e-contact-list-editor.c144
-rw-r--r--addressbook/gui/contact-list-editor/e-contact-list-editor.h4
-rw-r--r--addressbook/gui/contact-list-editor/e-contact-list-model.c64
-rw-r--r--addressbook/gui/contact-list-editor/e-contact-list-model.h9
6 files changed, 327 insertions, 112 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index 83e1317287..e98d406b16 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,3 +1,39 @@
+2001-06-25 Chris Toshok <toshok@ximian.com>
+
+ * gui/contact-list-editor/contact-list-editor.glade: change layout
+ slightly, the icon no longer pushes everything to the left, and
+ make the buttons on the right smaller and more in line with the
+ other widgets.
+
+ * gui/contact-list-editor/e-contact-list-model.c
+ (contact_list_value_at): return the SimpleAndString->string
+ instead of querying the ecardsimple.
+ (e_contact_list_model_init): initially allocate 10 of each type
+ (email and simple).
+ (e_contact_list_model_add_email): realloc if need be.
+ (e_contact_list_model_add_card): same, and initialize the string
+ displayed to be "[Name] [<email>]".
+ (e_contact_list_model_remove_row): change for SimpleAndString.
+ (contact_list_model_destroy): free our 2 arrays.
+
+ * gui/contact-list-editor/e-contact-list-model.h: add alloc counts
+ and the SimpleAndString struct.
+
+ * gui/contact-list-editor/e-contact-list-editor.c: Helix Code =>
+ Ximian.
+ (e_contact_list_editor_init): hook up d&d destination signals, and
+ un-#if 0 the delete_event signal.
+ (table_drag_motion_cb): new function.
+ (table_drag_drop_cb): new function.
+ (table_drag_data_received_cb): new function.
+ (file_close_cb): new function.
+ (verbs) uncomment the close verb.
+ (close_dialog): new function.
+ (app_delete_event_cb): new function.
+
+ * gui/contact-list-editor/e-contact-list-editor.h: Helix Code =>
+ Ximian.
+
2001-06-25 Jon Trowbridge <trow@ximian.com>
* gui/component/e-address-popup.c: Add a huge steaming pile of
diff --git a/addressbook/gui/contact-list-editor/contact-list-editor.glade b/addressbook/gui/contact-list-editor/contact-list-editor.glade
index 56317384f3..51b7c1a877 100644
--- a/addressbook/gui/contact-list-editor/contact-list-editor.glade
+++ b/addressbook/gui/contact-list-editor/contact-list-editor.glade
@@ -41,7 +41,7 @@
<name>table1</name>
<border_width>13</border_width>
<rows>6</rows>
- <columns>4</columns>
+ <columns>3</columns>
<homogeneous>False</homogeneous>
<row_spacing>5</row_spacing>
<column_spacing>5</column_spacing>
@@ -55,8 +55,8 @@
<int2>0</int2>
<last_modification_time>Sat, 23 Jun 2001 06:00:16 GMT</last_modification_time>
<child>
- <left_attach>1</left_attach>
- <right_attach>3</right_attach>
+ <left_attach>0</left_attach>
+ <right_attach>2</right_attach>
<top_attach>4</top_attach>
<bottom_attach>6</bottom_attach>
<xpad>0</xpad>
@@ -79,8 +79,8 @@
<text_max_length>0</text_max_length>
<text></text>
<child>
- <left_attach>1</left_attach>
- <right_attach>3</right_attach>
+ <left_attach>0</left_attach>
+ <right_attach>2</right_attach>
<top_attach>3</top_attach>
<bottom_attach>4</bottom_attach>
<xpad>0</xpad>
@@ -105,8 +105,8 @@
<xpad>0</xpad>
<ypad>0</ypad>
<child>
- <left_attach>1</left_attach>
- <right_attach>3</right_attach>
+ <left_attach>0</left_attach>
+ <right_attach>2</right_attach>
<top_attach>2</top_attach>
<bottom_attach>3</bottom_attach>
<xpad>0</xpad>
@@ -121,20 +121,13 @@
</widget>
<widget>
- <class>GtkLabel</class>
- <name>label2</name>
- <label>List Name:</label>
- <justify>GTK_JUSTIFY_LEFT</justify>
- <wrap>False</wrap>
- <xalign>0</xalign>
- <yalign>0.5</yalign>
- <xpad>0</xpad>
- <ypad>0</ypad>
+ <class>GtkHSeparator</class>
+ <name>hseparator1</name>
<child>
- <left_attach>1</left_attach>
- <right_attach>2</right_attach>
- <top_attach>0</top_attach>
- <bottom_attach>1</bottom_attach>
+ <left_attach>0</left_attach>
+ <right_attach>3</right_attach>
+ <top_attach>1</top_attach>
+ <bottom_attach>2</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
@@ -142,48 +135,20 @@
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
- <yfill>False</yfill>
+ <yfill>True</yfill>
</child>
</widget>
<widget>
- <class>GtkEntry</class>
- <name>list-name-entry</name>
- <can_focus>True</can_focus>
- <editable>True</editable>
- <text_visible>True</text_visible>
- <text_max_length>0</text_max_length>
- <text></text>
+ <class>GtkVBox</class>
+ <name>vbox1</name>
+ <homogeneous>False</homogeneous>
+ <spacing>0</spacing>
<child>
<left_attach>2</left_attach>
<right_attach>3</right_attach>
- <top_attach>0</top_attach>
- <bottom_attach>1</bottom_attach>
- <xpad>0</xpad>
- <ypad>0</ypad>
- <xexpand>True</xexpand>
- <yexpand>False</yexpand>
- <xshrink>False</xshrink>
- <yshrink>False</yshrink>
- <xfill>True</xfill>
- <yfill>False</yfill>
- </child>
- </widget>
-
- <widget>
- <class>GtkVButtonBox</class>
- <name>vbuttonbox2</name>
- <layout_style>GTK_BUTTONBOX_START</layout_style>
- <spacing>10</spacing>
- <child_min_width>85</child_min_width>
- <child_min_height>27</child_min_height>
- <child_ipad_x>7</child_ipad_x>
- <child_ipad_y>0</child_ipad_y>
- <child>
- <left_attach>3</left_attach>
- <right_attach>4</right_attach>
<top_attach>4</top_attach>
- <bottom_attach>6</bottom_attach>
+ <bottom_attach>5</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
@@ -197,44 +162,25 @@
<widget>
<class>GtkButton</class>
<name>remove-button</name>
- <can_default>True</can_default>
<can_focus>True</can_focus>
<label>Remove</label>
<relief>GTK_RELIEF_NORMAL</relief>
+ <child>
+ <padding>0</padding>
+ <expand>False</expand>
+ <fill>False</fill>
+ </child>
</widget>
</widget>
<widget>
- <class>GtkHSeparator</class>
- <name>hseparator1</name>
- <child>
- <left_attach>1</left_attach>
- <right_attach>4</right_attach>
- <top_attach>1</top_attach>
- <bottom_attach>2</bottom_attach>
- <xpad>0</xpad>
- <ypad>0</ypad>
- <xexpand>False</xexpand>
- <yexpand>False</yexpand>
- <xshrink>False</xshrink>
- <yshrink>False</yshrink>
- <xfill>True</xfill>
- <yfill>True</yfill>
- </child>
- </widget>
-
- <widget>
- <class>GtkVButtonBox</class>
- <name>vbuttonbox3</name>
- <layout_style>GTK_BUTTONBOX_DEFAULT_STYLE</layout_style>
- <spacing>10</spacing>
- <child_min_width>85</child_min_width>
- <child_min_height>27</child_min_height>
- <child_ipad_x>0</child_ipad_x>
- <child_ipad_y>0</child_ipad_y>
+ <class>GtkVBox</class>
+ <name>vbox2</name>
+ <homogeneous>False</homogeneous>
+ <spacing>0</spacing>
<child>
- <left_attach>3</left_attach>
- <right_attach>4</right_attach>
+ <left_attach>2</left_attach>
+ <right_attach>3</right_attach>
<top_attach>3</top_attach>
<bottom_attach>4</bottom_attach>
<xpad>0</xpad>
@@ -250,26 +196,27 @@
<widget>
<class>GtkButton</class>
<name>add-email-button</name>
- <can_default>True</can_default>
<can_focus>True</can_focus>
<label>Add</label>
<relief>GTK_RELIEF_NORMAL</relief>
+ <child>
+ <padding>0</padding>
+ <expand>False</expand>
+ <fill>False</fill>
+ </child>
</widget>
</widget>
<widget>
- <class>Custom</class>
- <name>custom2</name>
- <creation_function>e_create_image_widget</creation_function>
- <string1>evolution-contacts-plain.png</string1>
- <int1>0</int1>
- <int2>0</int2>
- <last_modification_time>Sat, 23 Jun 2001 05:59:21 GMT</last_modification_time>
+ <class>GtkHBox</class>
+ <name>hbox1</name>
+ <homogeneous>False</homogeneous>
+ <spacing>0</spacing>
<child>
<left_attach>0</left_attach>
- <right_attach>1</right_attach>
+ <right_attach>2</right_attach>
<top_attach>0</top_attach>
- <bottom_attach>6</bottom_attach>
+ <bottom_attach>1</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
@@ -279,6 +226,53 @@
<xfill>True</xfill>
<yfill>True</yfill>
</child>
+
+ <widget>
+ <class>Custom</class>
+ <name>custom3</name>
+ <creation_function>e_create_image_widget</creation_function>
+ <string1>evolution-contacts-plain.png</string1>
+ <int1>0</int1>
+ <int2>0</int2>
+ <last_modification_time>Sat, 23 Jun 2001 05:59:21 GMT</last_modification_time>
+ <child>
+ <padding>0</padding>
+ <expand>False</expand>
+ <fill>True</fill>
+ </child>
+ </widget>
+
+ <widget>
+ <class>GtkLabel</class>
+ <name>label3</name>
+ <label>List Name:</label>
+ <justify>GTK_JUSTIFY_LEFT</justify>
+ <wrap>False</wrap>
+ <xalign>0</xalign>
+ <yalign>0.5</yalign>
+ <xpad>0</xpad>
+ <ypad>0</ypad>
+ <child>
+ <padding>0</padding>
+ <expand>False</expand>
+ <fill>False</fill>
+ </child>
+ </widget>
+
+ <widget>
+ <class>GtkEntry</class>
+ <name>list-name-entry</name>
+ <can_focus>True</can_focus>
+ <editable>True</editable>
+ <text_visible>True</text_visible>
+ <text_max_length>0</text_max_length>
+ <text></text>
+ <child>
+ <padding>0</padding>
+ <expand>True</expand>
+ <fill>True</fill>
+ </child>
+ </widget>
</widget>
</widget>
</widget>
diff --git a/addressbook/gui/contact-list-editor/e-contact-list-editor.c b/addressbook/gui/contact-list-editor/e-contact-list-editor.c
index f95cb936af..06a3473baa 100644
--- a/addressbook/gui/contact-list-editor/e-contact-list-editor.c
+++ b/addressbook/gui/contact-list-editor/e-contact-list-editor.c
@@ -1,7 +1,7 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* e-contact-list-editor.c
- * Copyright (C) 2000 Helix Code, Inc.
- * Author: Chris Toshok <toshok@helixcode.com>
+ * 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 the GNU General Public License as
@@ -45,15 +45,35 @@ static void e_contact_list_editor_destroy (GtkObject *object);
static void create_ui (EContactListEditor *ce);
static void set_editable (EContactListEditor *editor);
static void command_state_changed (EContactListEditor *editor);
+static void close_dialog (EContactListEditor *cle);
static void add_email_cb (GtkWidget *w, EContactListEditor *editor);
static void remove_entry_cb (GtkWidget *w, EContactListEditor *editor);
static void list_name_changed_cb (GtkWidget *w, EContactListEditor *editor);
+static gint app_delete_event_cb (GtkWidget *widget, GdkEvent *event, gpointer data);
+static gboolean table_drag_drop_cb (ETable *table, int row, int col, GdkDragContext *context,
+ gint x, gint y, guint time, EContactListEditor *editor);
+static gboolean table_drag_motion_cb (ETable *table, int row, int col, GdkDragContext *context,
+ gint x, gint y, guint time, EContactListEditor *editor);
+static void table_drag_data_received_cb (ETable *table, int row, int col,
+ GdkDragContext *context,
+ gint x, gint y,
+ GtkSelectionData *selection_data, guint info, guint time,
+ EContactListEditor *editor);
static GtkObjectClass *parent_class = NULL;
static guint contact_list_editor_signals[LAST_SIGNAL];
+enum DndTargetType {
+ DND_TARGET_TYPE_VCARD,
+};
+#define VCARD_TYPE "text/x-vcard"
+static GtkTargetEntry drag_types[] = {
+ { VCARD_TYPE, 0, DND_TARGET_TYPE_VCARD },
+};
+static const int num_drag_types = sizeof (drag_types) / sizeof (drag_types[0]);
+
/* The arguments we take */
enum {
ARG_0,
@@ -236,14 +256,22 @@ e_contact_list_editor_init (EContactListEditor *editor)
gtk_signal_connect (GTK_OBJECT(editor->list_name_entry),
"changed", GTK_SIGNAL_FUNC(list_name_changed_cb), editor);
+ e_table_drag_dest_set (e_table_scrolled_get_table (E_TABLE_SCROLLED (editor->table)),
+ 0, drag_types, num_drag_types, GDK_ACTION_LINK);
+
+ gtk_signal_connect (GTK_OBJECT(e_table_scrolled_get_table (E_TABLE_SCROLLED (editor->table))),
+ "table_drag_motion", GTK_SIGNAL_FUNC(table_drag_motion_cb), editor);
+ gtk_signal_connect (GTK_OBJECT(e_table_scrolled_get_table (E_TABLE_SCROLLED (editor->table))),
+ "table_drag_drop", GTK_SIGNAL_FUNC(table_drag_drop_cb), editor);
+ gtk_signal_connect (GTK_OBJECT(e_table_scrolled_get_table (E_TABLE_SCROLLED (editor->table))),
+ "table_drag_data_received", GTK_SIGNAL_FUNC(table_drag_data_received_cb), editor);
+
command_state_changed (editor);
/* Connect to the deletion of the dialog */
-#if 0
gtk_signal_connect (GTK_OBJECT (editor->app), "delete_event",
GTK_SIGNAL_FUNC (app_delete_event_cb), editor);
-#endif
}
static void
@@ -251,6 +279,16 @@ e_contact_list_editor_destroy (GtkObject *object)
{
}
+/* File/Close callback */
+static void
+file_close_cb (GtkWidget *widget, gpointer data)
+{
+ EContactListEditor *cle;
+
+ cle = E_CONTACT_LIST_EDITOR (data);
+ close_dialog (cle);
+}
+
static
BonoboUIVerb verbs [] = {
#if 0
@@ -260,11 +298,8 @@ BonoboUIVerb verbs [] = {
BONOBO_UI_UNSAFE_VERB ("ContactEditorSendAs", file_send_as_cb),
BONOBO_UI_UNSAFE_VERB ("ContactEditorSendTo", file_send_to_cb),
BONOBO_UI_UNSAFE_VERB ("ContactEditorDelete", delete_cb),
- BONOBO_UI_UNSAFE_VERB ("ContactEditorPrint", print_cb),
- BONOBO_UI_UNSAFE_VERB ("ContactEditorPrintEnvelope", print_envelope_cb),
- /* BONOBO_UI_UNSAFE_VERB ("ContactEditorPageSetup", file_page_setup_menu), */
- BONOBO_UI_UNSAFE_VERB ("ContactEditorClose", file_close_cb),
-#endif
+#endif
+ BONOBO_UI_UNSAFE_VERB ("ContactListEditorClose", file_close_cb),
BONOBO_UI_VERB_END
};
@@ -479,6 +514,97 @@ set_editable (EContactListEditor *editor)
gtk_widget_set_sensitive (editor->table, editor->editable);
}
+/* Closes the dialog box and emits the appropriate signals */
+static void
+close_dialog (EContactListEditor *cle)
+{
+ g_assert (cle->app != NULL);
+
+ gtk_widget_destroy (cle->app);
+ cle->app = NULL;
+
+ gtk_signal_emit (GTK_OBJECT (cle), contact_list_editor_signals[EDITOR_CLOSED]);
+}
+
+/* Callback used when the editor is destroyed */
+static gint
+app_delete_event_cb (GtkWidget *widget, GdkEvent *event, gpointer data)
+{
+ EContactListEditor *ce;
+
+ ce = E_CONTACT_LIST_EDITOR (data);
+
+ close_dialog (ce);
+ return TRUE;
+}
+
+static gboolean
+table_drag_motion_cb (ETable *table, int row, int col,
+ GdkDragContext *context,
+ gint x, gint y, guint time, EContactListEditor *editor)
+{
+ GList *p;
+
+ for (p = context->targets; p != NULL; p = p->next) {
+ char *possible_type;
+
+ possible_type = gdk_atom_name ((GdkAtom) p->data);
+ if (!strcmp (possible_type, VCARD_TYPE)) {
+ g_free (possible_type);
+ gdk_drag_status (context, GDK_ACTION_LINK, time);
+ return TRUE;
+ }
+
+ g_free (possible_type);
+ }
+
+ return FALSE;
+}
+
+static gboolean
+table_drag_drop_cb (ETable *table, int row, int col,
+ GdkDragContext *context,
+ gint x, gint y, guint time, EContactListEditor *editor)
+{
+ if (context->targets != NULL) {
+ gtk_drag_get_data (GTK_WIDGET (table), context,
+ GPOINTER_TO_INT (context->targets->data),
+ time);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static void
+table_drag_data_received_cb (ETable *table, int row, int col,
+ GdkDragContext *context,
+ gint x, gint y,
+ GtkSelectionData *selection_data,
+ guint info, guint time, EContactListEditor *editor)
+{
+ char *target_type;
+
+ target_type = gdk_atom_name (selection_data->target);
+
+ if (!strcmp (target_type, VCARD_TYPE)) {
+ GList *card_list = e_card_load_cards_from_string (selection_data->data);
+ GList *c;
+
+ for (c = card_list; c; c = c->next) {
+ ECard *ecard = c->data;
+ ECardSimple *simple = e_card_simple_new (ecard);
+
+ e_contact_list_model_add_card (E_CONTACT_LIST_MODEL (editor->model),
+ simple);
+
+ gtk_object_unref (GTK_OBJECT (simple));
+ }
+ g_list_foreach (card_list, (GFunc)gtk_object_unref, NULL);
+ g_list_free (card_list);
+ }
+}
+
static void
command_state_changed (EContactListEditor *editor)
{
diff --git a/addressbook/gui/contact-list-editor/e-contact-list-editor.h b/addressbook/gui/contact-list-editor/e-contact-list-editor.h
index 55badc3016..c697275f43 100644
--- a/addressbook/gui/contact-list-editor/e-contact-list-editor.h
+++ b/addressbook/gui/contact-list-editor/e-contact-list-editor.h
@@ -1,7 +1,7 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* e-contact-list-editor.h
- * Copyright (C) 2000 Helix Code, Inc.
- * Author: Chris Toshok <toshok@helixcode.com>
+ * 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 the GNU General Public License as
diff --git a/addressbook/gui/contact-list-editor/e-contact-list-model.c b/addressbook/gui/contact-list-editor/e-contact-list-model.c
index 8d8831a6ab..abc963b198 100644
--- a/addressbook/gui/contact-list-editor/e-contact-list-model.c
+++ b/addressbook/gui/contact-list-editor/e-contact-list-model.c
@@ -30,7 +30,7 @@ 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);
+ return model->simples[row]->string;
else
return model->emails [row - model->simple_count];
}
@@ -84,6 +84,21 @@ contact_list_value_to_string (ETableModel *etc, int col, const void *value)
static void
contact_list_model_destroy (GtkObject *o)
{
+ EContactListModel *model = E_CONTACT_LIST_MODEL (o);
+ int i;
+
+ for (i = 0; i < model->simple_count; i ++) {
+ g_free (model->simples[i]->string);
+ gtk_object_unref (GTK_OBJECT(model->simples[i]->simple));
+ g_free (model->simples[i]);
+ }
+ g_free (model->simples);
+ model->simple_count = 0;
+
+ for (i = 0; i < model->email_count; i ++)
+ g_free (model->emails[i]);
+ g_free (model->emails);
+ model->email_count = 0;
}
static void
@@ -112,9 +127,12 @@ e_contact_list_model_init (GtkObject *object)
{
EContactListModel *model = E_CONTACT_LIST_MODEL(object);
- model->simples = NULL;
+ model->simple_alloc = 10;
+ model->simples = g_new (SimpleAndString*, model->simple_alloc);
model->simple_count = 0;
- model->emails = NULL;
+
+ model->email_alloc = 10;
+ model->emails = g_new (char*, model->email_alloc);
model->email_count = 0;
}
@@ -162,9 +180,12 @@ 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);
+ if (model->email_count + 1 >= model->email_alloc) {
+ model->email_alloc *= 2;
+ model->emails = g_renew (char*, model->emails, model->email_alloc);
+ }
+
+ model->emails[model->email_count ++] = g_strdup (email);
e_table_model_changed (E_TABLE_MODEL (model));
}
@@ -172,12 +193,43 @@ void
e_contact_list_model_add_card (EContactListModel *model,
ECardSimple *simple)
{
+ char *email, *name;
+
+ name = e_card_simple_get (simple, E_CARD_SIMPLE_FIELD_NAME_OR_ORG);
+ email = e_card_simple_get (simple, E_CARD_SIMPLE_FIELD_EMAIL);
+
+ if (! name && ! email) {
+ /* what to do here? */
+ return;
+ }
+
+
+ if (model->simple_count + 1 >= model->simple_alloc) {
+ model->simple_alloc *= 2;
+ model->simples = g_renew (SimpleAndString*, model->simples, model->simple_alloc);
+ }
+
+ model->simples[model->simple_count] = g_new (SimpleAndString, 1);
+
+ model->simples[model->simple_count]->simple = simple;
+ model->simples[model->simple_count]->string = g_strconcat (name ? name : "",
+ email ? " <" : "", email ? email : "", email ? ">" : "",
+ NULL);
+
+ model->simple_count++;
+
+ gtk_object_ref (GTK_OBJECT (simple));
+
+ e_table_model_changed (E_TABLE_MODEL (model));
}
void
e_contact_list_model_remove_row (EContactListModel *model, int row)
{
if (row < model->simple_count) {
+ g_free (model->simples[row]->string);
+ gtk_object_unref (GTK_OBJECT(model->simples[row]->simple));
+ g_free (model->simples[row]);
memcpy (model->simples + row, model->simples + row + 1, model->simple_count - row);
model->simple_count --;
}
diff --git a/addressbook/gui/contact-list-editor/e-contact-list-model.h b/addressbook/gui/contact-list-editor/e-contact-list-model.h
index da9be77b49..8665245501 100644
--- a/addressbook/gui/contact-list-editor/e-contact-list-model.h
+++ b/addressbook/gui/contact-list-editor/e-contact-list-model.h
@@ -16,13 +16,20 @@
typedef struct _EContactListModel EContactListModel;
typedef struct _EContactListModelClass EContactListModelClass;
+typedef struct {
+ ECardSimple *simple;
+ char *string;
+} SimpleAndString;
+
struct _EContactListModel {
ETableModel parent;
- ECardSimple **simples;
+ SimpleAndString **simples;
int simple_count;
+ int simple_alloc;
char **emails;
int email_count;
+ int email_alloc;
};