aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@helixcode.com>2000-07-14 03:22:42 +0800
committerChris Lahey <clahey@src.gnome.org>2000-07-14 03:22:42 +0800
commita5fc85f2f49c04d8b0344c8e967c2bf18856a46a (patch)
tree6fc8f6893ebefb2fbc5433bac058356860363d38 /addressbook
parent906c46112c18cab409eeb06aaaf4616c24e026b5 (diff)
downloadgsoc2013-evolution-a5fc85f2f49c04d8b0344c8e967c2bf18856a46a.tar
gsoc2013-evolution-a5fc85f2f49c04d8b0344c8e967c2bf18856a46a.tar.gz
gsoc2013-evolution-a5fc85f2f49c04d8b0344c8e967c2bf18856a46a.tar.bz2
gsoc2013-evolution-a5fc85f2f49c04d8b0344c8e967c2bf18856a46a.tar.lz
gsoc2013-evolution-a5fc85f2f49c04d8b0344c8e967c2bf18856a46a.tar.xz
gsoc2013-evolution-a5fc85f2f49c04d8b0344c8e967c2bf18856a46a.tar.zst
gsoc2013-evolution-a5fc85f2f49c04d8b0344c8e967c2bf18856a46a.zip
Switched the order of compilation of printing and contact-editor.
2000-07-13 Christopher James Lahey <clahey@helixcode.com> * 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
Diffstat (limited to 'addressbook')
-rw-r--r--addressbook/ChangeLog25
-rw-r--r--addressbook/Makefile.am2
-rw-r--r--addressbook/contact-editor/Makefile.am7
-rw-r--r--addressbook/contact-editor/e-contact-editor.c76
-rw-r--r--addressbook/contact-editor/e-contact-editor.h4
-rw-r--r--addressbook/gui/component/addressbook.c12
-rw-r--r--addressbook/gui/contact-editor/Makefile.am7
-rw-r--r--addressbook/gui/contact-editor/e-contact-editor.c76
-rw-r--r--addressbook/gui/contact-editor/e-contact-editor.h4
-rw-r--r--addressbook/gui/minicard/Makefile.am3
-rw-r--r--addressbook/gui/minicard/e-minicard.c46
-rw-r--r--addressbook/gui/widgets/Makefile.am3
-rw-r--r--addressbook/gui/widgets/e-minicard.c46
-rw-r--r--addressbook/printing/e-contact-print.c85
-rw-r--r--addressbook/printing/e-contact-print.h1
15 files changed, 358 insertions, 39 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index 291cbed7b4..a58ed435ca 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,3 +1,28 @@
+2000-07-13 Christopher James Lahey <clahey@helixcode.com>
+
+ * 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.
+
2000-07-12 Chris Toshok <toshok@helixcode.com>
* gui/component/e-ldap-storage.c (ldap_server_foreach): oops. fix
diff --git a/addressbook/Makefile.am b/addressbook/Makefile.am
index 4ff2b4a114..044eb9fa12 100644
--- a/addressbook/Makefile.am
+++ b/addressbook/Makefile.am
@@ -1,2 +1,2 @@
SUBDIRS = \
- ename backend contact-editor printing gui
+ ename backend printing contact-editor gui
diff --git a/addressbook/contact-editor/Makefile.am b/addressbook/contact-editor/Makefile.am
index b487f96fe2..f51a0109ac 100644
--- a/addressbook/contact-editor/Makefile.am
+++ b/addressbook/contact-editor/Makefile.am
@@ -33,6 +33,7 @@ contact_editor_test_SOURCES = \
contact_editor_test_LDADD = \
libecontacteditor.a \
$(top_builddir)/e-util/libeutil.la \
+ $(top_builddir)/addressbook/printing/libecontactprint.a \
$(top_builddir)/addressbook/backend/ebook/libebook.la \
$(top_builddir)/addressbook/ename/libename.la \
$(top_builddir)/libversit/libversit.la \
@@ -53,10 +54,12 @@ gladedir = $(datadir)/evolution/glade
glade_DATA = \
contact-editor.glade \
fullname.glade \
- categories.glade
+ categories.glade \
+ e-contact-editor-confirm-delete.glade
EXTRA_DIST = $(evolution_DATA) \
$(glade_DATA) \
e-contact-editor-strings.h \
fullname-strings.h \
- categories-strings.h
+ categories-strings.h \
+ e-contact-editor-confirm-delete.glade.h
diff --git a/addressbook/contact-editor/e-contact-editor.c b/addressbook/contact-editor/e-contact-editor.c
index c318dc7605..6793713f65 100644
--- a/addressbook/contact-editor/e-contact-editor.c
+++ b/addressbook/contact-editor/e-contact-editor.c
@@ -29,11 +29,13 @@
#include <gdk-pixbuf/gnome-canvas-pixbuf.h>
#include <e-util/e-gui-utils.h>
#include <e-contact-save-as.h>
+#include "addressbook/printing/e-contact-print.h"
/* Signal IDs */
enum {
ADD_CARD,
COMMIT_CARD,
+ DELETE_CARD,
EDITOR_CLOSED,
LAST_SIGNAL
};
@@ -130,6 +132,15 @@ e_contact_editor_class_init (EContactEditorClass *klass)
GTK_TYPE_NONE, 1,
GTK_TYPE_OBJECT);
+ contact_editor_signals[DELETE_CARD] =
+ gtk_signal_new ("delete_card",
+ GTK_RUN_FIRST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (EContactEditorClass, delete_card),
+ gtk_marshal_NONE__OBJECT,
+ GTK_TYPE_NONE, 1,
+ GTK_TYPE_OBJECT);
+
contact_editor_signals[EDITOR_CLOSED] =
gtk_signal_new ("editor_closed",
GTK_RUN_FIRST,
@@ -573,6 +584,59 @@ file_save_as_cb (GtkWidget *widget, gpointer data)
e_contact_save_as("Save as VCard", card);
}
+gboolean
+e_contact_editor_confirm_delete(void)
+{
+ GnomeDialog *dialog;
+ GladeXML *gui;
+ int result;
+
+ gui = glade_xml_new (EVOLUTION_GLADEDIR "/e-contact-editor-confirm-delete.glade", NULL);
+
+ dialog = GNOME_DIALOG(glade_xml_get_widget(gui, "confirm-dialog"));
+
+ result = gnome_dialog_run_and_close(dialog);
+
+ gtk_object_unref(GTK_OBJECT(gui));
+
+ return !result;
+}
+
+static void
+delete_cb (GtkWidget *widget, gpointer data)
+{
+ EContactEditor *ce;
+
+ if (e_contact_editor_confirm_delete()) {
+
+ ce = E_CONTACT_EDITOR (data);
+
+ extract_info (ce);
+ e_card_simple_sync_card (ce->simple);
+
+ if (!ce->is_new_card)
+ gtk_signal_emit (GTK_OBJECT (ce), contact_editor_signals[DELETE_CARD],
+ ce->card);
+
+ file_close_cb(widget, data);
+ }
+}
+
+/* Emits the signal to request printing a card */
+static void
+print_cb (GtkWidget *widget, gpointer data)
+{
+ EContactEditor *ce;
+
+ ce = E_CONTACT_EDITOR (data);
+
+ extract_info (ce);
+ e_card_simple_sync_card (ce->simple);
+
+ gtk_widget_show(e_contact_print_card_dialog_new(ce->card));
+}
+
+
/* Menu bar */
static GnomeUIInfo file_new_menu[] = {
@@ -606,13 +670,13 @@ static GnomeUIInfo file_menu[] = {
GNOMEUIINFO_MENU_SAVE_AS_ITEM (file_save_as_cb, NULL),
GNOMEUIINFO_ITEM_NONE (N_("FIXME: Save Attac_hments..."), NULL, NULL),
GNOMEUIINFO_SEPARATOR,
- GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Delete"), NULL, NULL),
+ GNOMEUIINFO_ITEM_NONE (N_("_Delete"), NULL, delete_cb),
GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Move to Folder..."), NULL, NULL),
GNOMEUIINFO_ITEM_NONE (N_("FIXME: Cop_y to Folder..."), NULL, NULL),
GNOMEUIINFO_SEPARATOR,
GNOMEUIINFO_SUBTREE (N_("Page Set_up"), file_page_setup_menu),
GNOMEUIINFO_ITEM_NONE (N_("FIXME: Print Pre_view"), NULL, NULL),
- GNOMEUIINFO_MENU_PRINT_ITEM (NULL, NULL),
+ GNOMEUIINFO_MENU_PRINT_ITEM (print_cb, NULL),
GNOMEUIINFO_SEPARATOR,
GNOMEUIINFO_MENU_PROPERTIES_ITEM (NULL, NULL),
GNOMEUIINFO_SEPARATOR,
@@ -777,16 +841,16 @@ static GnomeUIInfo toolbar[] = {
tb_save_and_close_cb,
GNOME_STOCK_PIXMAP_SAVE),
GNOMEUIINFO_SEPARATOR,
- GNOMEUIINFO_ITEM_STOCK (N_("FIXME: Print..."),
- N_("Print this item"), NULL,
+ GNOMEUIINFO_ITEM_STOCK (N_("Print..."),
+ N_("Print this item"), print_cb,
GNOME_STOCK_PIXMAP_PRINT),
#if 0
GNOMEUIINFO_ITEM_NONE (N_("FIXME: Insert File..."),
N_("Insert a file as an attachment"), NULL),
#endif
GNOMEUIINFO_SEPARATOR,
- GNOMEUIINFO_ITEM_STOCK (N_("FIXME: Delete"),
- N_("Delete this item"), NULL,
+ GNOMEUIINFO_ITEM_STOCK (N_("Delete"),
+ N_("Delete this item"), delete_cb,
GNOME_STOCK_PIXMAP_TRASH),
GNOMEUIINFO_SEPARATOR,
GNOMEUIINFO_ITEM_STOCK (N_("FIXME: Previous"),
diff --git a/addressbook/contact-editor/e-contact-editor.h b/addressbook/contact-editor/e-contact-editor.h
index 8eae2bf1b5..de14b84ca3 100644
--- a/addressbook/contact-editor/e-contact-editor.h
+++ b/addressbook/contact-editor/e-contact-editor.h
@@ -95,6 +95,7 @@ struct _EContactEditorClass
void (* add_card) (EContactEditor *ce, ECard *card);
void (* commit_card) (EContactEditor *ce, ECard *card);
+ void (* delete_card) (EContactEditor *ce, ECard *card);
void (* editor_closed) (EContactEditor *ce);
};
@@ -102,6 +103,9 @@ struct _EContactEditorClass
EContactEditor *e_contact_editor_new (ECard *card, gboolean is_new_card);
GtkType e_contact_editor_get_type (void);
+
+gboolean e_contact_editor_confirm_delete(void);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/addressbook/gui/component/addressbook.c b/addressbook/gui/component/addressbook.c
index 7295682bf7..477f4b6f40 100644
--- a/addressbook/gui/component/addressbook.c
+++ b/addressbook/gui/component/addressbook.c
@@ -125,6 +125,16 @@ commit_card_cb (EContactEditor *ce, ECard *card, gpointer data)
e_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_modified_cb, NULL);
+}
+
/* Callback used when the contact editor is closed */
static void
editor_closed_cb (EContactEditor *ce, gpointer data)
@@ -157,6 +167,8 @@ new_contact_cb (BonoboUIHandler *uih, void *user_data, const char *path)
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);
diff --git a/addressbook/gui/contact-editor/Makefile.am b/addressbook/gui/contact-editor/Makefile.am
index b487f96fe2..f51a0109ac 100644
--- a/addressbook/gui/contact-editor/Makefile.am
+++ b/addressbook/gui/contact-editor/Makefile.am
@@ -33,6 +33,7 @@ contact_editor_test_SOURCES = \
contact_editor_test_LDADD = \
libecontacteditor.a \
$(top_builddir)/e-util/libeutil.la \
+ $(top_builddir)/addressbook/printing/libecontactprint.a \
$(top_builddir)/addressbook/backend/ebook/libebook.la \
$(top_builddir)/addressbook/ename/libename.la \
$(top_builddir)/libversit/libversit.la \
@@ -53,10 +54,12 @@ gladedir = $(datadir)/evolution/glade
glade_DATA = \
contact-editor.glade \
fullname.glade \
- categories.glade
+ categories.glade \
+ e-contact-editor-confirm-delete.glade
EXTRA_DIST = $(evolution_DATA) \
$(glade_DATA) \
e-contact-editor-strings.h \
fullname-strings.h \
- categories-strings.h
+ categories-strings.h \
+ e-contact-editor-confirm-delete.glade.h
diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c
index c318dc7605..6793713f65 100644
--- a/addressbook/gui/contact-editor/e-contact-editor.c
+++ b/addressbook/gui/contact-editor/e-contact-editor.c
@@ -29,11 +29,13 @@
#include <gdk-pixbuf/gnome-canvas-pixbuf.h>
#include <e-util/e-gui-utils.h>
#include <e-contact-save-as.h>
+#include "addressbook/printing/e-contact-print.h"
/* Signal IDs */
enum {
ADD_CARD,
COMMIT_CARD,
+ DELETE_CARD,
EDITOR_CLOSED,
LAST_SIGNAL
};
@@ -130,6 +132,15 @@ e_contact_editor_class_init (EContactEditorClass *klass)
GTK_TYPE_NONE, 1,
GTK_TYPE_OBJECT);
+ contact_editor_signals[DELETE_CARD] =
+ gtk_signal_new ("delete_card",
+ GTK_RUN_FIRST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (EContactEditorClass, delete_card),
+ gtk_marshal_NONE__OBJECT,
+ GTK_TYPE_NONE, 1,
+ GTK_TYPE_OBJECT);
+
contact_editor_signals[EDITOR_CLOSED] =
gtk_signal_new ("editor_closed",
GTK_RUN_FIRST,
@@ -573,6 +584,59 @@ file_save_as_cb (GtkWidget *widget, gpointer data)
e_contact_save_as("Save as VCard", card);
}
+gboolean
+e_contact_editor_confirm_delete(void)
+{
+ GnomeDialog *dialog;
+ GladeXML *gui;
+ int result;
+
+ gui = glade_xml_new (EVOLUTION_GLADEDIR "/e-contact-editor-confirm-delete.glade", NULL);
+
+ dialog = GNOME_DIALOG(glade_xml_get_widget(gui, "confirm-dialog"));
+
+ result = gnome_dialog_run_and_close(dialog);
+
+ gtk_object_unref(GTK_OBJECT(gui));
+
+ return !result;
+}
+
+static void
+delete_cb (GtkWidget *widget, gpointer data)
+{
+ EContactEditor *ce;
+
+ if (e_contact_editor_confirm_delete()) {
+
+ ce = E_CONTACT_EDITOR (data);
+
+ extract_info (ce);
+ e_card_simple_sync_card (ce->simple);
+
+ if (!ce->is_new_card)
+ gtk_signal_emit (GTK_OBJECT (ce), contact_editor_signals[DELETE_CARD],
+ ce->card);
+
+ file_close_cb(widget, data);
+ }
+}
+
+/* Emits the signal to request printing a card */
+static void
+print_cb (GtkWidget *widget, gpointer data)
+{
+ EContactEditor *ce;
+
+ ce = E_CONTACT_EDITOR (data);
+
+ extract_info (ce);
+ e_card_simple_sync_card (ce->simple);
+
+ gtk_widget_show(e_contact_print_card_dialog_new(ce->card));
+}
+
+
/* Menu bar */
static GnomeUIInfo file_new_menu[] = {
@@ -606,13 +670,13 @@ static GnomeUIInfo file_menu[] = {
GNOMEUIINFO_MENU_SAVE_AS_ITEM (file_save_as_cb, NULL),
GNOMEUIINFO_ITEM_NONE (N_("FIXME: Save Attac_hments..."), NULL, NULL),
GNOMEUIINFO_SEPARATOR,
- GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Delete"), NULL, NULL),
+ GNOMEUIINFO_ITEM_NONE (N_("_Delete"), NULL, delete_cb),
GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Move to Folder..."), NULL, NULL),
GNOMEUIINFO_ITEM_NONE (N_("FIXME: Cop_y to Folder..."), NULL, NULL),
GNOMEUIINFO_SEPARATOR,
GNOMEUIINFO_SUBTREE (N_("Page Set_up"), file_page_setup_menu),
GNOMEUIINFO_ITEM_NONE (N_("FIXME: Print Pre_view"), NULL, NULL),
- GNOMEUIINFO_MENU_PRINT_ITEM (NULL, NULL),
+ GNOMEUIINFO_MENU_PRINT_ITEM (print_cb, NULL),
GNOMEUIINFO_SEPARATOR,
GNOMEUIINFO_MENU_PROPERTIES_ITEM (NULL, NULL),
GNOMEUIINFO_SEPARATOR,
@@ -777,16 +841,16 @@ static GnomeUIInfo toolbar[] = {
tb_save_and_close_cb,
GNOME_STOCK_PIXMAP_SAVE),
GNOMEUIINFO_SEPARATOR,
- GNOMEUIINFO_ITEM_STOCK (N_("FIXME: Print..."),
- N_("Print this item"), NULL,
+ GNOMEUIINFO_ITEM_STOCK (N_("Print..."),
+ N_("Print this item"), print_cb,
GNOME_STOCK_PIXMAP_PRINT),
#if 0
GNOMEUIINFO_ITEM_NONE (N_("FIXME: Insert File..."),
N_("Insert a file as an attachment"), NULL),
#endif
GNOMEUIINFO_SEPARATOR,
- GNOMEUIINFO_ITEM_STOCK (N_("FIXME: Delete"),
- N_("Delete this item"), NULL,
+ GNOMEUIINFO_ITEM_STOCK (N_("Delete"),
+ N_("Delete this item"), delete_cb,
GNOME_STOCK_PIXMAP_TRASH),
GNOMEUIINFO_SEPARATOR,
GNOMEUIINFO_ITEM_STOCK (N_("FIXME: Previous"),
diff --git a/addressbook/gui/contact-editor/e-contact-editor.h b/addressbook/gui/contact-editor/e-contact-editor.h
index 8eae2bf1b5..de14b84ca3 100644
--- a/addressbook/gui/contact-editor/e-contact-editor.h
+++ b/addressbook/gui/contact-editor/e-contact-editor.h
@@ -95,6 +95,7 @@ struct _EContactEditorClass
void (* add_card) (EContactEditor *ce, ECard *card);
void (* commit_card) (EContactEditor *ce, ECard *card);
+ void (* delete_card) (EContactEditor *ce, ECard *card);
void (* editor_closed) (EContactEditor *ce);
};
@@ -102,6 +103,9 @@ struct _EContactEditorClass
EContactEditor *e_contact_editor_new (ECard *card, gboolean is_new_card);
GtkType e_contact_editor_get_type (void);
+
+gboolean e_contact_editor_confirm_delete(void);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/addressbook/gui/minicard/Makefile.am b/addressbook/gui/minicard/Makefile.am
index a20edc1c08..d09d66fe31 100644
--- a/addressbook/gui/minicard/Makefile.am
+++ b/addressbook/gui/minicard/Makefile.am
@@ -53,6 +53,7 @@ minicard_test_LDADD = \
$(top_builddir)/libversit/libversit.la \
$(top_builddir)/addressbook/ename/libename.la \
$(top_builddir)/addressbook/contact-editor/libecontacteditor.a \
+ $(top_builddir)/addressbook/printing/libecontactprint.a \
$(top_builddir)/widgets/e-table/libetable.a \
$(top_builddir)/widgets/misc/libemiscwidgets.a \
$(top_builddir)/e-util/libeutil.la \
@@ -71,6 +72,7 @@ reflow_test_LDADD = \
$(top_builddir)/libversit/libversit.la \
$(top_builddir)/addressbook/ename/libename.la \
$(top_builddir)/addressbook/contact-editor/libecontacteditor.a \
+ $(top_builddir)/addressbook/printing/libecontactprint.a \
$(top_builddir)/widgets/e-table/libetable.a \
$(top_builddir)/widgets/misc/libemiscwidgets.a \
$(top_builddir)/e-util/libeutil.la \
@@ -89,6 +91,7 @@ minicard_view_test_LDADD = \
$(top_builddir)/libversit/libversit.la \
$(top_builddir)/addressbook/ename/libename.la \
$(top_builddir)/addressbook/contact-editor/libecontacteditor.a \
+ $(top_builddir)/addressbook/printing/libecontactprint.a \
$(top_builddir)/widgets/e-table/libetable.a \
$(top_builddir)/widgets/misc/libemiscwidgets.a \
$(top_builddir)/e-util/libeutil.la \
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 <e-util/e-util.h>
#include <e-util/e-canvas-utils.h>
#include <e-util/e-popup-menu.h>
+#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);
diff --git a/addressbook/gui/widgets/Makefile.am b/addressbook/gui/widgets/Makefile.am
index a20edc1c08..d09d66fe31 100644
--- a/addressbook/gui/widgets/Makefile.am
+++ b/addressbook/gui/widgets/Makefile.am
@@ -53,6 +53,7 @@ minicard_test_LDADD = \
$(top_builddir)/libversit/libversit.la \
$(top_builddir)/addressbook/ename/libename.la \
$(top_builddir)/addressbook/contact-editor/libecontacteditor.a \
+ $(top_builddir)/addressbook/printing/libecontactprint.a \
$(top_builddir)/widgets/e-table/libetable.a \
$(top_builddir)/widgets/misc/libemiscwidgets.a \
$(top_builddir)/e-util/libeutil.la \
@@ -71,6 +72,7 @@ reflow_test_LDADD = \
$(top_builddir)/libversit/libversit.la \
$(top_builddir)/addressbook/ename/libename.la \
$(top_builddir)/addressbook/contact-editor/libecontacteditor.a \
+ $(top_builddir)/addressbook/printing/libecontactprint.a \
$(top_builddir)/widgets/e-table/libetable.a \
$(top_builddir)/widgets/misc/libemiscwidgets.a \
$(top_builddir)/e-util/libeutil.la \
@@ -89,6 +91,7 @@ minicard_view_test_LDADD = \
$(top_builddir)/libversit/libversit.la \
$(top_builddir)/addressbook/ename/libename.la \
$(top_builddir)/addressbook/contact-editor/libecontacteditor.a \
+ $(top_builddir)/addressbook/printing/libecontactprint.a \
$(top_builddir)/widgets/e-table/libetable.a \
$(top_builddir)/widgets/misc/libemiscwidgets.a \
$(top_builddir)/e-util/libeutil.la \
diff --git a/addressbook/gui/widgets/e-minicard.c b/addressbook/gui/widgets/e-minicard.c
index cdc809f6e4..68f6ccfc05 100644
--- a/addressbook/gui/widgets/e-minicard.c
+++ b/addressbook/gui/widgets/e-minicard.c
@@ -30,6 +30,7 @@
#include <e-util/e-util.h>
#include <e-util/e-canvas-utils.h>
#include <e-util/e-popup-menu.h>
+#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);
diff --git a/addressbook/printing/e-contact-print.c b/addressbook/printing/e-contact-print.c
index aeb9cfee58..55a72e0e11 100644
--- a/addressbook/printing/e-contact-print.c
+++ b/addressbook/printing/e-contact-print.c
@@ -57,6 +57,7 @@ struct _EContactPrintContext
char *character;
gboolean first_contact;
+ gboolean uses_book;
int type;
EBook *book;
gchar *query;
@@ -501,6 +502,18 @@ static void
complete_sequence(EBookView *book_view, EContactPrintContext *ctxt)
{
GList *cards = ctxt->cards;
+
+ gdouble page_width = 72 * (ctxt->style->page_width - ctxt->style->left_margin - ctxt->style->right_margin);
+
+ ctxt->first_contact = TRUE;
+ ctxt->character = NULL;
+ ctxt->y = (ctxt->style->page_height - ctxt->style->top_margin) * 72;
+ ctxt->x = (ctxt->style->left_margin) * 72;
+ if ( ctxt->style->letter_tabs )
+ page_width -= e_contact_get_letter_tab_width(ctxt);
+
+ ctxt->first_char_on_page = 'A' - 1;
+
for(; cards; cards = cards->next) {
ECard *card = cards->data;
ECardSimple *simple = e_card_simple_new(card);
@@ -540,7 +553,8 @@ complete_sequence(EBookView *book_view, EContactPrintContext *ctxt)
gnome_print_showpage(ctxt->pc);
gnome_print_context_close(ctxt->pc);
g_free(ctxt->character);
- gtk_object_unref(GTK_OBJECT(book_view));
+ if (book_view)
+ gtk_object_unref(GTK_OBJECT(book_view));
if (ctxt->type == GNOME_PRINT_PREVIEW) {
GtkWidget *preview;
preview = GTK_WIDGET(gnome_print_master_preview_new(ctxt->master, "Print Preview"));
@@ -550,7 +564,8 @@ complete_sequence(EBookView *book_view, EContactPrintContext *ctxt)
}
gtk_object_unref(GTK_OBJECT(ctxt->pc));
gtk_object_unref(GTK_OBJECT(ctxt->master));
- gtk_object_unref(GTK_OBJECT(ctxt->book));
+ if (ctxt->book)
+ gtk_object_unref(GTK_OBJECT(ctxt->book));
g_free(ctxt->query);
g_list_foreach(ctxt->cards, (GFunc) gtk_object_unref, NULL);
g_list_free(ctxt->cards);
@@ -615,16 +630,6 @@ book_view_loaded (EBook *book, EBookStatus status, EBookView *book_view, EContac
static void
e_contact_do_print_cards (EBook *book, char *query, EContactPrintContext *ctxt)
{
- gdouble page_width = 72 * (ctxt->style->page_width - ctxt->style->left_margin - ctxt->style->right_margin);
- ctxt->first_contact = TRUE;
- ctxt->character = NULL;
- ctxt->y = (ctxt->style->page_height - ctxt->style->top_margin) * 72;
- ctxt->x = (ctxt->style->left_margin) * 72;
- if ( ctxt->style->letter_tabs )
- page_width -= e_contact_get_letter_tab_width(ctxt);
-
- ctxt->first_char_on_page = 'A' - 1;
-
e_book_get_book_view(book, query, (EBookBookViewCallback) book_view_loaded, ctxt);
}
@@ -972,9 +977,17 @@ e_contact_print_button(GnomeDialog *dialog, gint button, gpointer data)
EContactPrintStyle *style = g_new(EContactPrintStyle, 1);
GnomePrintMaster *master;
GnomePrintContext *pc;
- EBook *book = gtk_object_get_data(GTK_OBJECT(dialog), "book");
- char *query = gtk_object_get_data(GTK_OBJECT(dialog), "query");
+ gboolean uses_book = (gint) gtk_object_get_data(GTK_OBJECT(dialog), "uses_book");
+ EBook *book = NULL;
+ char *query = NULL;
+ ECard *card = NULL;
gdouble font_size;
+ if (uses_book) {
+ book = gtk_object_get_data(GTK_OBJECT(dialog), "book");
+ query = gtk_object_get_data(GTK_OBJECT(dialog), "query");
+ } else {
+ card = gtk_object_get_data(GTK_OBJECT(dialog), "card");
+ }
switch( button ) {
case GNOME_PRINT_PRINT:
master = gnome_print_master_new_from_dialog( GNOME_PRINT_DIALOG(dialog) );
@@ -1002,8 +1015,13 @@ e_contact_print_button(GnomeDialog *dialog, gint button, gpointer data)
ctxt->book = book;
ctxt->query = query;
- ctxt->cards = NULL;
- e_contact_do_print(book, ctxt->query, ctxt);
+ if (uses_book) {
+ ctxt->cards = NULL;
+ e_contact_do_print(book, ctxt->query, ctxt);
+ } else {
+ ctxt->cards = g_list_append(NULL, card);
+ complete_sequence(NULL, ctxt);
+ }
gnome_dialog_close(dialog);
break;
case GNOME_PRINT_PREVIEW:
@@ -1030,14 +1048,23 @@ e_contact_print_button(GnomeDialog *dialog, gint button, gpointer data)
72 * style->page_width,
72 * style->page_height));
- gtk_object_ref(GTK_OBJECT(book));
ctxt->book = book;
ctxt->query = g_strdup(query);
- ctxt->cards = NULL;
- e_contact_do_print(book, ctxt->query, ctxt);
+ if (uses_book) {
+ ctxt->cards = NULL;
+ gtk_object_ref(GTK_OBJECT(book));
+ e_contact_do_print(book, ctxt->query, ctxt);
+ } else {
+ ctxt->cards = g_list_append(NULL, card);
+ gtk_object_ref(GTK_OBJECT(card));
+ complete_sequence(NULL, ctxt);
+ }
break;
case GNOME_PRINT_CANCEL:
- gtk_object_unref(GTK_OBJECT(book));
+ if (uses_book)
+ gtk_object_unref(GTK_OBJECT(book));
+ else
+ gtk_object_unref(GTK_OBJECT(card));
g_free(query);
gnome_dialog_close(dialog);
g_free(style);
@@ -1057,6 +1084,7 @@ e_contact_print_dialog_new(EBook *book, char *query)
NULL, NULL, NULL);
gtk_object_ref(GTK_OBJECT(book));
+ gtk_object_set_data(GTK_OBJECT(dialog), "uses_book", (void *) 1);
gtk_object_set_data(GTK_OBJECT(dialog), "book", book);
gtk_object_set_data(GTK_OBJECT(dialog), "query", g_strdup(query));
gtk_signal_connect(GTK_OBJECT(dialog),
@@ -1065,3 +1093,20 @@ e_contact_print_dialog_new(EBook *book, char *query)
"close", GTK_SIGNAL_FUNC(e_contact_print_close), NULL);
return dialog;
}
+
+GtkWidget *
+e_contact_print_card_dialog_new(ECard *card)
+{
+ GtkWidget *dialog;
+
+ dialog = gnome_print_dialog_new("Print card", GNOME_PRINT_DIALOG_COPIES);
+
+ card = e_card_duplicate(card);
+ gtk_object_set_data(GTK_OBJECT(dialog), "card", card);
+ gtk_object_set_data(GTK_OBJECT(dialog), "uses_book", (void *) 0);
+ gtk_signal_connect(GTK_OBJECT(dialog),
+ "clicked", GTK_SIGNAL_FUNC(e_contact_print_button), NULL);
+ gtk_signal_connect(GTK_OBJECT(dialog),
+ "close", GTK_SIGNAL_FUNC(e_contact_print_close), NULL);
+ return dialog;
+}
diff --git a/addressbook/printing/e-contact-print.h b/addressbook/printing/e-contact-print.h
index 8649a2ff6a..fb17271f6b 100644
--- a/addressbook/printing/e-contact-print.h
+++ b/addressbook/printing/e-contact-print.h
@@ -28,5 +28,6 @@
#include "e-contact-print-types.h"
GtkWidget *e_contact_print_dialog_new(EBook *book, char *query);
+GtkWidget *e_contact_print_card_dialog_new(ECard *card);
#endif /* E_CONTACT_PRINT_H */