From 8b080c2358ad689f8a2d3fc2b0e98f966c4cccfb Mon Sep 17 00:00:00 2001 From: Christopher James Lahey Date: Mon, 11 Jun 2001 10:13:04 +0000 Subject: Added e-card-merging-book-commit-duplicate-detected.glade here. 2001-06-11 Christopher James Lahey * gui/merging/Makefile.am (glade_DATA): Added e-card-merging-book-commit-duplicate-detected.glade here. * gui/merging/e-card-merging-book-commit-duplicate-detected.glade: Added this file. The GUI for asking whether to commit a modified card. * gui/merging/e-card-merging.c, gui/merging/e-card-merging.h (e_card_merging_book_commit_card): Added this function. * gui/widgets/e-addressbook-table-adapter.c (addressbook_set_value_at), gui/widgets/e-addressbook-util.c (commit_card_cb), gui/widgets/e-minicard.c (e_minicard_event): Use e_card_merging_book_commit_card instead of e_book_commit_card here. svn path=/trunk/; revision=10184 --- addressbook/ChangeLog | 17 ++ addressbook/gui/merging/Makefile.am | 3 +- ...rd-merging-book-commit-duplicate-detected.glade | 255 +++++++++++++++++++++ addressbook/gui/merging/e-card-merging.c | 78 ++++++- addressbook/gui/merging/e-card-merging.h | 12 +- .../gui/widgets/e-addressbook-table-adapter.c | 4 +- addressbook/gui/widgets/e-addressbook-util.c | 2 +- addressbook/gui/widgets/e-minicard.c | 9 +- 8 files changed, 361 insertions(+), 19 deletions(-) create mode 100644 addressbook/gui/merging/e-card-merging-book-commit-duplicate-detected.glade (limited to 'addressbook') diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog index 5ee4ba0c17..7c6f0b5b18 100644 --- a/addressbook/ChangeLog +++ b/addressbook/ChangeLog @@ -1,3 +1,20 @@ +2001-06-11 Christopher James Lahey + + * gui/merging/Makefile.am (glade_DATA): Added + e-card-merging-book-commit-duplicate-detected.glade here. + + * gui/merging/e-card-merging-book-commit-duplicate-detected.glade: + Added this file. The GUI for asking whether to commit a modified + card. + + * gui/merging/e-card-merging.c, gui/merging/e-card-merging.h + (e_card_merging_book_commit_card): Added this function. + + * gui/widgets/e-addressbook-table-adapter.c + (addressbook_set_value_at), gui/widgets/e-addressbook-util.c + (commit_card_cb), gui/widgets/e-minicard.c (e_minicard_event): Use + e_card_merging_book_commit_card instead of e_book_commit_card here. + 2001-06-11 Christopher James Lahey * backend/ebook/e-card-simple.c, backend/ebook/e-card-simple.h: diff --git a/addressbook/gui/merging/Makefile.am b/addressbook/gui/merging/Makefile.am index 493edc0002..5a00726f26 100644 --- a/addressbook/gui/merging/Makefile.am +++ b/addressbook/gui/merging/Makefile.am @@ -16,7 +16,8 @@ libecardmerging_a_SOURCES = \ gladedir = $(datadir)/evolution/glade -glade_DATA = e-card-duplicate-detected.glade +glade_DATA = e-card-duplicate-detected.glade \ + e-card-merging-book-commit-duplicate-detected.glade EXTRA_DIST = \ $(glade_DATA) diff --git a/addressbook/gui/merging/e-card-merging-book-commit-duplicate-detected.glade b/addressbook/gui/merging/e-card-merging-book-commit-duplicate-detected.glade new file mode 100644 index 0000000000..0bc60ba13a --- /dev/null +++ b/addressbook/gui/merging/e-card-merging-book-commit-duplicate-detected.glade @@ -0,0 +1,255 @@ + + + + + e-card-merging-book-commit-duplicate-detected + e-card-merging-book-commit-duplicate-detected + + src + pixmaps + C + True + True + True + False + False + False + True + + + + GnomeDialog + dialog-duplicate-contact + Duplicate Contact Detected + GTK_WINDOW_POPUP + GTK_WIN_POS_NONE + False + False + True + False + False + False + + + GtkVBox + GnomeDialog:vbox + dialog-vbox1 + False + 8 + + 4 + True + True + + + + GtkHButtonBox + GnomeDialog:action_area + dialog-action_area1 + GTK_BUTTONBOX_END + 8 + 85 + 27 + 7 + 0 + + 0 + False + True + GTK_PACK_END + + + + GtkButton + button3 + True + True + + GNOME_STOCK_PIXMAP_ADD + + + + GtkButton + button4 + True + True + GNOME_STOCK_BUTTON_CANCEL + + + + + GtkTable + table1 + 5 + 2 + False + 6 + 6 + + 0 + True + True + + + + Custom + custom-old-card + e_card_merging_create_old_card + 0 + 0 + Fri, 08 Jun 2001 01:33:22 GMT + + 1 + 2 + 4 + 5 + 0 + 0 + True + True + False + False + True + True + + + + + GtkLabel + label1 + + GTK_JUSTIFY_LEFT + False + 0 + 0.5 + 0 + 0 + + 1 + 2 + 0 + 1 + 0 + 0 + True + False + False + False + True + True + + + + + GtkLabel + label3 + + GTK_JUSTIFY_CENTER + False + 0 + 0.5 + 0 + 0 + + 1 + 2 + 3 + 4 + 0 + 0 + True + False + False + False + True + True + + + + + GtkLabel + label4 + + GTK_JUSTIFY_CENTER + False + 0 + 0.5 + 0 + 0 + + 1 + 2 + 1 + 2 + 0 + 0 + False + False + False + False + True + False + + + + + Custom + custom-new-card + e_card_merging_create_old_card + 0 + 0 + Fri, 08 Jun 2001 01:33:22 GMT + + 1 + 2 + 2 + 3 + 0 + 0 + True + True + False + False + True + True + + + + + GtkAlignment + alignment1 + 0.5 + 0 + 1 + 0 + + 0 + 1 + 0 + 5 + 0 + 0 + False + False + False + False + True + True + + + + Custom + custom2 + e_create_image_widget + malehead.png + 0 + 0 + Fri, 08 Jun 2001 00:18:39 GMT + + + + + + + diff --git a/addressbook/gui/merging/e-card-merging.c b/addressbook/gui/merging/e-card-merging.c index c367a60271..dd8c317990 100644 --- a/addressbook/gui/merging/e-card-merging.c +++ b/addressbook/gui/merging/e-card-merging.c @@ -17,23 +17,50 @@ #include #include "addressbook/gui/widgets/e-minicard-widget.h" +typedef enum { + E_CARD_MERGING_ADD, + E_CARD_MERGING_COMMIT +} ECardMergingOpType; + typedef struct { + ECardMergingOpType op; EBook *book; ECard *card; - EBookIdCallback cb; + EBookIdCallback id_cb; + EBookCallback cb; gpointer closure; } ECardMergingLookup; +static void +doit (ECardMergingLookup *lookup) +{ + if (lookup->op == E_CARD_MERGING_ADD) + e_book_add_card (lookup->book, lookup->card, lookup->id_cb, lookup->closure); + else if (lookup->op == E_CARD_MERGING_COMMIT) + e_book_commit_card (lookup->book, lookup->card, lookup->cb, lookup->closure); +} + +static void +cancelit (ECardMergingLookup *lookup) +{ + if (lookup->op == E_CARD_MERGING_ADD) { + if (lookup->id_cb) + lookup->id_cb (lookup->book, E_BOOK_STATUS_CANCELLED, NULL, lookup->closure); + } else if (lookup->op == E_CARD_MERGING_COMMIT) { + if (lookup->cb) + lookup->cb (lookup->book, E_BOOK_STATUS_CANCELLED, lookup->closure); + } +} + static void clicked (GnomeDialog *dialog, int button, ECardMergingLookup *lookup) { switch (button) { case 0: - e_book_add_card (lookup->book, lookup->card, lookup->cb, lookup->closure); + doit (lookup); break; case 1: - if (lookup->cb) - lookup->cb (lookup->book, E_BOOK_STATUS_CANCELLED, NULL, lookup->closure); + cancelit (lookup); break; } g_free (lookup); @@ -45,12 +72,23 @@ match_query_callback (ECard *card, ECard *match, ECardMatchType type, gpointer c { ECardMergingLookup *lookup = closure; if (type == E_CARD_MATCH_NONE) { - e_book_add_card (lookup->book, card, lookup->cb, lookup->closure); + doit (lookup); g_free (lookup); } else { - GladeXML *ui = glade_xml_new (EVOLUTION_GLADEDIR "/e-card-duplicate-detected.glade", NULL); + GladeXML *ui; + GtkWidget *widget; + if (lookup->op == E_CARD_MERGING_ADD) + ui = glade_xml_new (EVOLUTION_GLADEDIR "/e-card-duplicate-detected.glade", NULL); + else if (lookup->op == E_CARD_MERGING_COMMIT) + ui = glade_xml_new (EVOLUTION_GLADEDIR "/e-card-merging-book-commit-duplicate-detected.glade", NULL); + else { + doit (lookup); + g_free (lookup); + return; + } + widget = glade_xml_get_widget (ui, "custom-old-card"); gtk_object_set (GTK_OBJECT (widget), "card", match, @@ -77,15 +115,41 @@ e_card_merging_book_add_card (EBook *book, ECardMergingLookup *lookup; lookup = g_new (ECardMergingLookup, 1); + lookup->op = E_CARD_MERGING_ADD; lookup->book = book; lookup->card = card; - lookup->cb = cb; + lookup->id_cb = cb; lookup->closure = closure; e_card_locate_match_full (book, card, NULL, match_query_callback, lookup); return TRUE; } +gboolean +e_card_merging_book_commit_card (EBook *book, + ECard *card, + EBookCallback cb, + gpointer closure) +{ + ECardMergingLookup *lookup; + GList *avoid; + lookup = g_new (ECardMergingLookup, 1); + + lookup->op = E_CARD_MERGING_COMMIT; + lookup->book = book; + lookup->card = card; + lookup->cb = cb; + lookup->closure = closure; + + avoid = g_list_append (NULL, card); + + e_card_locate_match_full (book, card, avoid, match_query_callback, lookup); + + g_list_free (avoid); + + return TRUE; +} + GtkWidget * e_card_merging_create_old_card(gchar *name, gchar *string1, gchar *string2, diff --git a/addressbook/gui/merging/e-card-merging.h b/addressbook/gui/merging/e-card-merging.h index 022cad0099..c4d9483beb 100644 --- a/addressbook/gui/merging/e-card-merging.h +++ b/addressbook/gui/merging/e-card-merging.h @@ -17,10 +17,14 @@ BEGIN_GNOME_DECLS -gboolean e_card_merging_book_add_card (EBook *book, - ECard *card, - EBookIdCallback cb, - gpointer closure); +gboolean e_card_merging_book_add_card (EBook *book, + ECard *card, + EBookIdCallback cb, + gpointer closure); +gboolean e_card_merging_book_commit_card (EBook *book, + ECard *card, + EBookCallback cb, + gpointer closure); END_GNOME_DECLS diff --git a/addressbook/gui/widgets/e-addressbook-table-adapter.c b/addressbook/gui/widgets/e-addressbook-table-adapter.c index 9557046afe..38596fd0f0 100644 --- a/addressbook/gui/widgets/e-addressbook-table-adapter.c +++ b/addressbook/gui/widgets/e-addressbook-table-adapter.c @@ -136,8 +136,8 @@ addressbook_set_value_at (ETableModel *etc, int col, int row, const void *val) "card", &card, NULL); - e_book_commit_card(e_addressbook_model_get_ebook(priv->model), - card, card_modified_cb, NULL); + e_card_merging_book_commit_card(e_addressbook_model_get_ebook(priv->model), + card, card_modified_cb, NULL); /* XXX do we need this? shouldn't the commit_card generate a changed signal? */ e_table_model_cell_changed(etc, col, row); diff --git a/addressbook/gui/widgets/e-addressbook-util.c b/addressbook/gui/widgets/e-addressbook-util.c index 6db628c412..c8ef417116 100644 --- a/addressbook/gui/widgets/e-addressbook-util.c +++ b/addressbook/gui/widgets/e-addressbook-util.c @@ -95,7 +95,7 @@ commit_card_cb (EContactEditor *ce, ECard *card, gpointer data) EBook *book; book = E_BOOK (data); - e_book_commit_card (book, card, card_modified_cb, NULL); + e_card_merging_book_commit_card (book, card, card_modified_cb, NULL); } /* Callback for the delete_card signal from the contact editor */ diff --git a/addressbook/gui/widgets/e-minicard.c b/addressbook/gui/widgets/e-minicard.c index 1627dd722a..d6cb8f0e1a 100644 --- a/addressbook/gui/widgets/e-minicard.c +++ b/addressbook/gui/widgets/e-minicard.c @@ -37,6 +37,7 @@ #include "e-minicard-label.h" #include "e-minicard-view.h" #include "e-contact-editor.h" +#include "e-card-merging.h" static void e_minicard_init (EMinicard *card); static void e_minicard_class_init (EMinicardClass *klass); @@ -479,10 +480,10 @@ e_minicard_event (GnomeCanvasItem *item, GdkEvent *event) if (book) { /* Add the card in the contact editor to our ebook */ - e_book_commit_card (book, - e_minicard->card, - card_modified_cb, - NULL); + e_card_merging_book_commit_card (book, + e_minicard->card, + card_modified_cb, + NULL); } else { remodel(e_minicard); e_canvas_item_request_reflow(GNOME_CANVAS_ITEM(e_minicard)); -- cgit v1.2.3