aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui
diff options
context:
space:
mode:
authorChris Toshok <toshok@ximian.com>2001-06-20 08:45:48 +0800
committerChris Toshok <toshok@src.gnome.org>2001-06-20 08:45:48 +0800
commit649bc025dbf8807ab001c874a3f53de1d1826e5b (patch)
tree10c54b2bd7d29345b72feb13543368003cd404ab /addressbook/gui
parent68a1984433b5b8597ea7cf99fc2417a30dc2d89d (diff)
downloadgsoc2013-evolution-649bc025dbf8807ab001c874a3f53de1d1826e5b.tar
gsoc2013-evolution-649bc025dbf8807ab001c874a3f53de1d1826e5b.tar.gz
gsoc2013-evolution-649bc025dbf8807ab001c874a3f53de1d1826e5b.tar.bz2
gsoc2013-evolution-649bc025dbf8807ab001c874a3f53de1d1826e5b.tar.lz
gsoc2013-evolution-649bc025dbf8807ab001c874a3f53de1d1826e5b.tar.xz
gsoc2013-evolution-649bc025dbf8807ab001c874a3f53de1d1826e5b.tar.zst
gsoc2013-evolution-649bc025dbf8807ab001c874a3f53de1d1826e5b.zip
track change to e_addressbook_show_contact_editor signature.
2001-06-19 Chris Toshok <toshok@ximian.com> * gui/widgets/e-addressbook-view.c (table_double_click): track change to e_addressbook_show_contact_editor signature. * gui/widgets/e-minicard-view.c (e_minicard_view_event): same. * gui/widgets/e-minicard.c (e_minicard_event): same. * gui/widgets/e-addressbook-util.c (e_addressbook_error_dialog): add an entry for "Card ID already exists". (e_addressbook_show_contact_editor): track the change to signal names and e_contact_editor_new signature here. * gui/widgets/e-addressbook-util.h: change e_addressbook_show_contact_editor's signature to match e_contact_editor_new more closely. * gui/widgets/e-addressbook-table-adapter.c (unlink_model): free up the simple mapping to plug a potentially sizeable memory leak. * gui/component/select-names/e-select-names-text-model.c (e_select_names_text_model_activate_obj): call e_addressbook_show_contact_editor here. * gui/component/select-names/e-select-names-popup.c (edit_contact_info_have_book_cb): remove the get_supported_fields stuff, since the contact editor handles it for us now, and call e_addressbook_show_contact_editor. * gui/component/e-address-popup.c (edit_contact_info_cb): same. * gui/component/addressbook.c (new_contact_cb): track change to e_addressbook_show_contact_editor. svn path=/trunk/; revision=10318
Diffstat (limited to 'addressbook/gui')
-rw-r--r--addressbook/gui/component/addressbook.c2
-rw-r--r--addressbook/gui/component/e-address-popup.c11
-rw-r--r--addressbook/gui/component/select-names/e-select-names-popup.c23
-rw-r--r--addressbook/gui/component/select-names/e-select-names-text-model.c3
-rw-r--r--addressbook/gui/widgets/e-addressbook-table-adapter.c9
-rw-r--r--addressbook/gui/widgets/e-addressbook-util.c89
-rw-r--r--addressbook/gui/widgets/e-addressbook-util.h1
-rw-r--r--addressbook/gui/widgets/e-addressbook-view.c2
-rw-r--r--addressbook/gui/widgets/e-minicard-view.c2
-rw-r--r--addressbook/gui/widgets/e-minicard.c3
10 files changed, 47 insertions, 98 deletions
diff --git a/addressbook/gui/component/addressbook.c b/addressbook/gui/component/addressbook.c
index 1ae42755ca..e8a14c10e2 100644
--- a/addressbook/gui/component/addressbook.c
+++ b/addressbook/gui/component/addressbook.c
@@ -64,7 +64,7 @@ new_contact_cb (BonoboUIComponent *uih, void *user_data, const char *path)
g_assert (E_IS_BOOK (book));
- e_addressbook_show_contact_editor (book, NULL, e_addressbook_view_can_create (view->view));
+ e_addressbook_show_contact_editor (book, e_card_new(""), TRUE, e_addressbook_view_can_create(view->view));
}
static void
diff --git a/addressbook/gui/component/e-address-popup.c b/addressbook/gui/component/e-address-popup.c
index 134ce1241b..81add0e243 100644
--- a/addressbook/gui/component/e-address-popup.c
+++ b/addressbook/gui/component/e-address-popup.c
@@ -214,21 +214,14 @@ e_address_popup_new (void)
}
static void
-found_fields_cb (EBook *book, EBookStatus status, EList *writable_fields, gpointer closure)
+edit_contact_info_cb (EAddressPopup *pop)
{
- EAddressPopup *pop = E_ADDRESS_POPUP (closure);
- EContactEditor *ce = e_contact_editor_new (pop->card, FALSE, writable_fields, FALSE);
+ EContactEditor *ce = e_addressbook_show_contact_editor (common_book, pop->card, FALSE, TRUE);
e_contact_editor_raise (ce);
gtk_widget_destroy (GTK_WIDGET (pop));
}
static void
-edit_contact_info_cb (EAddressPopup *pop)
-{
- e_book_get_supported_fields (common_book, found_fields_cb, pop);
-}
-
-static void
e_address_popup_cardify (EAddressPopup *pop, ECard *card)
{
GtkWidget *b;
diff --git a/addressbook/gui/component/select-names/e-select-names-popup.c b/addressbook/gui/component/select-names/e-select-names-popup.c
index e31fa8506f..4cea4dfb86 100644
--- a/addressbook/gui/component/select-names/e-select-names-popup.c
+++ b/addressbook/gui/component/select-names/e-select-names-popup.c
@@ -41,6 +41,7 @@
#include <addressbook/backend/ebook/e-book-util.h>
#include <addressbook/contact-editor/e-contact-editor.h>
#include <addressbook/contact-editor/e-contact-quick-add.h>
+#include "e-addressbook-util.h"
#include "e-select-names-popup.h"
typedef struct _PopupInfo PopupInfo;
@@ -93,23 +94,17 @@ popup_info_cleanup (GtkWidget *w, gpointer info)
/* You are in a maze of twisty little callbacks, all alike... */
static void
-found_fields_cb (EBook *book, EBookStatus status, EList *writable_fields, gpointer user_data)
-{
- EDestination *dest = E_DESTINATION (user_data);
- EContactEditor *ce;
- ECard *card;
-
- card = (ECard *) e_destination_get_card (dest);
- ce = e_contact_editor_new (card, FALSE, writable_fields, FALSE);
- e_contact_editor_raise (ce);
- gtk_object_unref (GTK_OBJECT (dest));
-}
-
-static void
edit_contact_info_have_book_cb (EBook *book, gpointer user_data)
{
if (book) {
- e_book_get_supported_fields (book, found_fields_cb, user_data);
+ EDestination *dest = E_DESTINATION (user_data);
+ EContactEditor *ce;
+ ECard *card;
+
+ card = (ECard *) e_destination_get_card (dest);
+ ce = e_addressbook_show_contact_editor (book, card, FALSE, TRUE);
+ e_contact_editor_raise (ce);
+ gtk_object_unref (GTK_OBJECT (dest));
}
}
diff --git a/addressbook/gui/component/select-names/e-select-names-text-model.c b/addressbook/gui/component/select-names/e-select-names-text-model.c
index 6aa6a75a9a..c9d1d1177f 100644
--- a/addressbook/gui/component/select-names/e-select-names-text-model.c
+++ b/addressbook/gui/component/select-names/e-select-names-text-model.c
@@ -18,6 +18,7 @@
#include <addressbook/contact-editor/e-contact-editor.h>
#include "e-select-names-text-model.h"
+#include "e-addressbook-util.h"
static FILE *out = NULL; /* stream for debugging spew */
@@ -714,7 +715,7 @@ e_select_names_text_model_activate_obj (ETextModel *model, gint n)
g_return_if_fail (card);
/* present read-only contact editor when someone double clicks from here */
- contact_editor = e_contact_editor_new ((ECard *) card, FALSE, NULL, TRUE);
+ contact_editor = e_addressbook_show_contact_editor (NULL, card, FALSE, FALSE);
e_contact_editor_raise (contact_editor);
}
diff --git a/addressbook/gui/widgets/e-addressbook-table-adapter.c b/addressbook/gui/widgets/e-addressbook-table-adapter.c
index 38596fd0f0..b54b2bcea8 100644
--- a/addressbook/gui/widgets/e-addressbook-table-adapter.c
+++ b/addressbook/gui/widgets/e-addressbook-table-adapter.c
@@ -28,6 +28,7 @@ static void
unlink_model(EAddressbookTableAdapter *adapter)
{
EAddressbookTableAdapterPrivate *priv = adapter->priv;
+ int i;
gtk_signal_disconnect(GTK_OBJECT (priv->model),
priv->create_card_id);
@@ -43,6 +44,14 @@ unlink_model(EAddressbookTableAdapter *adapter)
priv->modify_card_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 ++)
+ gtk_object_unref (GTK_OBJECT (priv->simples[i]));
+ g_free (priv->simples);
+ priv->simples = NULL;
+ }
+
gtk_object_unref(GTK_OBJECT(priv->model));
priv->model = NULL;
diff --git a/addressbook/gui/widgets/e-addressbook-util.c b/addressbook/gui/widgets/e-addressbook-util.c
index c8ef417116..7ec044adf8 100644
--- a/addressbook/gui/widgets/e-addressbook-util.c
+++ b/addressbook/gui/widgets/e-addressbook-util.c
@@ -37,6 +37,7 @@ e_addressbook_error_dialog (const gchar *msg, EBookStatus status)
N_("Repository offline"),
N_("Permission denied"),
N_("Card not found"),
+ N_("Card ID already exists"),
N_("Protocol not supported"),
N_("Canceled"),
N_("Other error")
@@ -53,11 +54,12 @@ e_addressbook_error_dialog (const gchar *msg, EBookStatus status)
static void
card_added_cb (EBook* book, EBookStatus status, const char *id,
- gpointer user_data)
+ gpointer user_data)
{
g_print ("%s: %s(): a card was added\n", __FILE__, __FUNCTION__);
- if (status != E_BOOK_STATUS_SUCCESS)
+ if (status != E_BOOK_STATUS_SUCCESS) {
e_addressbook_error_dialog (_("Error adding card"), status);
+ }
}
static void
@@ -65,97 +67,44 @@ card_modified_cb (EBook* book, EBookStatus status,
gpointer user_data)
{
g_print ("%s: %s(): a card was modified\n", __FILE__, __FUNCTION__);
- if (status != E_BOOK_STATUS_SUCCESS)
+ if (status != E_BOOK_STATUS_SUCCESS) {
e_addressbook_error_dialog (_("Error modifying card"), status);
+ }
}
static void
-card_removed_cb (EBook* book, EBookStatus status,
+card_deleted_cb (EBook* book, EBookStatus status,
gpointer user_data)
{
g_print ("%s: %s(): a card was removed\n", __FILE__, __FUNCTION__);
- if (status != E_BOOK_STATUS_SUCCESS)
+ if (status != E_BOOK_STATUS_SUCCESS) {
e_addressbook_error_dialog (_("Error removing card"), status);
+ }
}
-/* Callback for the add_card signal from the contact editor */
-static void
-add_card_cb (EContactEditor *ce, ECard *card, gpointer data)
-{
- EBook *book;
-
- book = E_BOOK (data);
- e_card_merging_book_add_card (book, card, card_added_cb, NULL);
-}
-
-/* Callback for the commit_card signal from the contact editor */
-static void
-commit_card_cb (EContactEditor *ce, ECard *card, gpointer data)
-{
- EBook *book;
-
- book = E_BOOK (data);
- e_card_merging_book_commit_card (book, card, card_modified_cb, NULL);
-}
-
-/* Callback for the delete_card signal from the contact editor */
-static void
-delete_card_cb (EContactEditor *ce, ECard *card, gpointer data)
-{
- EBook *book;
-
- book = E_BOOK (data);
- e_book_remove_card (book, card, card_removed_cb, NULL);
-}
-
-/* Callback used when the contact editor is closed */
static void
editor_closed_cb (EContactEditor *ce, gpointer data)
{
gtk_object_unref (GTK_OBJECT (ce));
}
-typedef struct {
- ECard *card;
- gboolean editable;
-} SupportedFieldsClosure;
-
-static void
-supported_fields_cb (EBook *book, EBookStatus status,
- EList *fields, EContactEditor *ce)
-{
- gtk_object_set (GTK_OBJECT (ce),
- "writable_fields", fields,
- NULL);
-
- gtk_signal_connect (GTK_OBJECT (ce), "add_card",
- GTK_SIGNAL_FUNC (add_card_cb), book);
- gtk_signal_connect (GTK_OBJECT (ce), "commit_card",
- GTK_SIGNAL_FUNC (commit_card_cb), book);
- gtk_signal_connect (GTK_OBJECT (ce), "delete_card",
- GTK_SIGNAL_FUNC (delete_card_cb), book);
- gtk_signal_connect (GTK_OBJECT (ce), "editor_closed",
- GTK_SIGNAL_FUNC (editor_closed_cb), NULL);
-
- e_contact_editor_show (ce);
-}
-
EContactEditor *
e_addressbook_show_contact_editor (EBook *book, ECard *card,
+ gboolean is_new_card,
gboolean editable)
{
EContactEditor *ce;
- gboolean new_card = FALSE;
- if (card == NULL) {
- new_card = TRUE;
- card = e_card_new ("");
- }
+ ce = e_contact_editor_new (book, card, is_new_card, editable);
- ce = e_contact_editor_new (card, new_card, NULL,
- !editable);
-
- e_book_get_supported_fields (book, (EBookFieldsCallback)supported_fields_cb, ce);
+ gtk_signal_connect (GTK_OBJECT (ce), "card_added",
+ GTK_SIGNAL_FUNC (card_added_cb), NULL);
+ gtk_signal_connect (GTK_OBJECT (ce), "card_modified",
+ GTK_SIGNAL_FUNC (card_modified_cb), NULL);
+ gtk_signal_connect (GTK_OBJECT (ce), "card_deleted",
+ GTK_SIGNAL_FUNC (card_deleted_cb), NULL);
+ gtk_signal_connect (GTK_OBJECT (ce), "editor_closed",
+ GTK_SIGNAL_FUNC (editor_closed_cb), NULL);
return ce;
}
diff --git a/addressbook/gui/widgets/e-addressbook-util.h b/addressbook/gui/widgets/e-addressbook-util.h
index f40a1b825a..3e222f7154 100644
--- a/addressbook/gui/widgets/e-addressbook-util.h
+++ b/addressbook/gui/widgets/e-addressbook-util.h
@@ -32,6 +32,7 @@ extern "C" {
void e_addressbook_error_dialog (const gchar *msg,
EBookStatus status);
EContactEditor* e_addressbook_show_contact_editor (EBook *book, ECard *card,
+ gboolean is_new_card,
gboolean editable);
#ifdef __cplusplus
diff --git a/addressbook/gui/widgets/e-addressbook-view.c b/addressbook/gui/widgets/e-addressbook-view.c
index 99672f2ede..8f33fe7349 100644
--- a/addressbook/gui/widgets/e-addressbook-view.c
+++ b/addressbook/gui/widgets/e-addressbook-view.c
@@ -481,7 +481,7 @@ table_double_click(ETableScrolled *table, gint row, gint col, GdkEvent *event, E
g_assert (E_IS_BOOK (book));
- e_addressbook_show_contact_editor (book, card, view->editable);
+ e_addressbook_show_contact_editor (book, card, FALSE, view->editable);
}
}
diff --git a/addressbook/gui/widgets/e-minicard-view.c b/addressbook/gui/widgets/e-minicard-view.c
index a85656a743..325f714341 100644
--- a/addressbook/gui/widgets/e-minicard-view.c
+++ b/addressbook/gui/widgets/e-minicard-view.c
@@ -263,7 +263,7 @@ e_minicard_view_event (GnomeCanvasItem *item, GdkEvent *event)
g_assert (E_IS_BOOK (book));
- e_addressbook_show_contact_editor (book, NULL, editable);
+ e_addressbook_show_contact_editor (book, e_card_new(""), TRUE, editable);
}
return TRUE;
default:
diff --git a/addressbook/gui/widgets/e-minicard.c b/addressbook/gui/widgets/e-minicard.c
index d6cb8f0e1a..7683de2357 100644
--- a/addressbook/gui/widgets/e-minicard.c
+++ b/addressbook/gui/widgets/e-minicard.c
@@ -538,7 +538,8 @@ e_minicard_event (GnomeCanvasItem *item, GdkEvent *event)
}
if (book != NULL) {
- e_minicard->editor = e_addressbook_show_contact_editor (book, e_minicard->card, e_minicard->editable);
+ e_minicard->editor = e_addressbook_show_contact_editor (book, e_minicard->card,
+ FALSE, e_minicard->editable);
gtk_object_ref (GTK_OBJECT (e_minicard->editor));
gtk_signal_connect (GTK_OBJECT (e_minicard->editor), "editor_closed",