From a5fc85f2f49c04d8b0344c8e967c2bf18856a46a Mon Sep 17 00:00:00 2001 From: Christopher James Lahey Date: Thu, 13 Jul 2000 19:22:42 +0000 Subject: Switched the order of compilation of printing and contact-editor. 2000-07-13 Christopher James Lahey * Makefile.am: Switched the order of compilation of printing and contact-editor. * contact-editor/Makefile.am: Added printing libraries and a confirm delete dialog glade file. * contact-editor/e-contact-editor.c, contact-editor/e-contact-editor.h: Enabled the delete and print functions as well as providing a confirm delete dialog to the outside world. * gui/component/addressbook.c: Made the delete button on new cards active. * gui/minicard/Makefile.am: Added printing libraries to a number of test programs. * gui/minicard/e-minicard.c: Added print and delete to the right click menu. Made the delete button on the card editor active. * printing/e-contact-print.c, printing/e-contact-print.h: Added a function to print a single card. svn path=/trunk/; revision=4151 --- addressbook/gui/minicard/e-minicard.c | 46 ++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) (limited to 'addressbook/gui/minicard/e-minicard.c') diff --git a/addressbook/gui/minicard/e-minicard.c b/addressbook/gui/minicard/e-minicard.c index cdc809f6e4..68f6ccfc05 100644 --- a/addressbook/gui/minicard/e-minicard.c +++ b/addressbook/gui/minicard/e-minicard.c @@ -30,6 +30,7 @@ #include #include #include +#include "addressbook/printing/e-contact-print.h" #include "e-contact-editor.h" #include "e-contact-save-as.h" #include "e-minicard-view.h" @@ -329,6 +330,34 @@ save_as (GtkWidget *widget, EMinicard *minicard) e_contact_save_as(_("Save as VCard"), minicard->card); } +static void +delete (GtkWidget *widget, EMinicard *minicard) +{ + EBook *book; + + if (e_contact_editor_confirm_delete()) { + e_card_simple_sync_card(minicard->simple); + + gtk_object_get(GTK_OBJECT(GNOME_CANVAS_ITEM(minicard)->parent), + "book", &book, + NULL); + + /* Add the card in the contact editor to our ebook */ + e_book_remove_card (book, + minicard->card, + card_changed_cb, + NULL); + } +} + +static void +print (GtkWidget *widget, EMinicard *minicard) +{ + e_card_simple_sync_card(minicard->simple); + + gtk_widget_show(e_contact_print_card_dialog_new(minicard->card)); +} + /* Callback for the add_card signal from the contact editor */ static void add_card_cb (EContactEditor *ce, ECard *card, gpointer data) @@ -349,6 +378,16 @@ commit_card_cb (EContactEditor *ce, ECard *card, gpointer data) e_book_commit_card (book, card, card_changed_cb, NULL); } +/* Callback for the commit_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_changed_cb, NULL); +} + /* Callback used when the contact editor is closed */ static void editor_closed_cb (EContactEditor *ce, gpointer data) @@ -410,7 +449,10 @@ e_minicard_event (GnomeCanvasItem *item, GdkEvent *event) if (event->button.button == 1) { e_canvas_item_grab_focus(item); } else if (event->button.button == 3) { - EPopupMenu menu[] = { {"Save as VCard", NULL, GTK_SIGNAL_FUNC(save_as), 0}, {NULL, NULL, NULL, 0} }; + EPopupMenu menu[] = { {"Save as VCard", NULL, GTK_SIGNAL_FUNC(save_as), 0}, + {"Print", NULL, GTK_SIGNAL_FUNC(print), 0}, + {"Delete", NULL, GTK_SIGNAL_FUNC(delete), 0}, + {NULL, NULL, NULL, 0}}; e_popup_menu_run (menu, (GdkEventButton *)event, 0, e_minicard); } break; @@ -431,6 +473,8 @@ e_minicard_event (GnomeCanvasItem *item, GdkEvent *event) 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); -- cgit v1.2.3