aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui/widgets/e-minicard.c
diff options
context:
space:
mode:
Diffstat (limited to 'addressbook/gui/widgets/e-minicard.c')
-rw-r--r--addressbook/gui/widgets/e-minicard.c81
1 files changed, 46 insertions, 35 deletions
diff --git a/addressbook/gui/widgets/e-minicard.c b/addressbook/gui/widgets/e-minicard.c
index 3aabdab5ef..4b7942a9f4 100644
--- a/addressbook/gui/widgets/e-minicard.c
+++ b/addressbook/gui/widgets/e-minicard.c
@@ -311,6 +311,12 @@ e_minicard_unrealize (GnomeCanvasItem *item)
}
static void
+card_added_cb (EBook* book, EBookStatus status, const char *id, gpointer user_data)
+{
+ g_print ("%s: %s(): a card was added\n", __FILE__, __FUNCTION__);
+}
+
+static void
card_changed_cb (EBook* book, EBookStatus status, gpointer user_data)
{
g_print ("%s: %s(): a card was changed with status %d\n", __FILE__, __FUNCTION__, status);
@@ -323,6 +329,33 @@ save_as (GtkWidget *widget, EMinicard *minicard)
e_contact_save_as(_("Save as VCard"), minicard->card);
}
+/* 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_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_book_commit_card (book, card, card_changed_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));
+}
+
static gboolean
e_minicard_event (GnomeCanvasItem *item, GdkEvent *event)
{
@@ -381,48 +414,26 @@ e_minicard_event (GnomeCanvasItem *item, GdkEvent *event)
e_popup_menu_run (menu, (GdkEventButton *)event, 0, e_minicard);
}
break;
+
case GDK_2BUTTON_PRESS:
if (event->button.button == 1 && E_IS_MINICARD_VIEW(item->parent)) {
- gint result;
- GtkWidget* contact_editor =
- e_contact_editor_new(e_minicard->card);
+ EContactEditor *ce;
EBook *book;
- GtkWidget *dlg;
+
gtk_object_get(GTK_OBJECT(item->parent),
"book", &book,
NULL);
-
- dlg = gnome_dialog_new ("Contact Editor", "Save", "Cancel", NULL);
-
- gtk_window_set_policy(GTK_WINDOW(dlg), FALSE, TRUE, FALSE);
-
g_assert (E_IS_BOOK (book));
-
- gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dlg)->vbox),
- contact_editor, TRUE, TRUE, 0);
-
- gtk_widget_show(contact_editor);
- gtk_widget_show (dlg);
-
- gnome_dialog_close_hides (GNOME_DIALOG (dlg), TRUE);
- result = gnome_dialog_run_and_close (GNOME_DIALOG (dlg));
-
-
- /* If the user clicks "okay"...*/
- if (result == 0) {
- ECard *card;
- g_assert (contact_editor);
- g_assert (GTK_IS_OBJECT (contact_editor));
- gtk_object_get(GTK_OBJECT(contact_editor),
- "card", &card,
- NULL);
-
- /* Add the card in the contact editor to our ebook */
- e_book_commit_card (book,
- card,
- card_changed_cb,
- NULL);
- }
+
+ ce = e_contact_editor_new (e_minicard->card, FALSE);
+
+ 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), "editor_closed",
+ GTK_SIGNAL_FUNC (editor_closed_cb), NULL);
+
return TRUE;
}
break;