aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--addressbook/ChangeLog28
-rw-r--r--addressbook/Makefile.am2
-rw-r--r--addressbook/backend/ebook/e-book-view-listener.h2
-rw-r--r--addressbook/backend/ebook/e-book-view.h4
-rw-r--r--addressbook/backend/ebook/e-book.h8
-rw-r--r--addressbook/backend/ebook/e-card-cursor.h4
-rw-r--r--addressbook/backend/ebook/e-card-list.h2
-rw-r--r--addressbook/backend/ebook/e-card-simple.h6
-rw-r--r--addressbook/backend/ebook/e-card.h4
-rw-r--r--addressbook/gui/component/Makefile.am5
-rw-r--r--addressbook/gui/component/addressbook.c20
-rw-r--r--addressbook/printing/Makefile.am34
-rw-r--r--addressbook/printing/e-contact-print.c346
-rw-r--r--addressbook/printing/e-contact-print.h3
-rw-r--r--addressbook/printing/test-print.c2
15 files changed, 301 insertions, 169 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index f5a3ccca68..15ffffafd3 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,5 +1,33 @@
2000-05-23 Christopher James Lahey <clahey@helixcode.com>
+ * Makefile.am: Switched printing and gui.
+
+ * backend/ebook/e-book-view-listener.h,
+ backend/ebook/e-book-view.h, backend/ebook/e-book.h,
+ backend/ebook/e-card-cursor.h, backend/ebook/e-card-list.h,
+ backend/ebook/e-card-simple.h, backend/ebook/e-card.h: Fixed the
+ #defines to work elsewhere in evolution.
+
+ * gui/component/Makefile.am: Added linking to libecontactprint.
+
+ * gui/component/addressbook.c: Added a menu item to print the
+ current query.
+
+ * printing/Makefile.am: Add linking to libebook and requirements.
+ Add installation of ecps files.
+
+ * printing/e-contact-print.c, printing/e-contact-print.h: Changed
+ this to use real data from an EBook.
+
+ * printing/test-print.c: Made this pass NULL, NULL to
+ e_contact_print_dialog_new so that it will compile.
+
+2000-05-23 Christopher James Lahey <clahey@helixcode.com>
+
+ * contact-editor/e-contact-save-as.c: Fixed some memory leaks.
+
+2000-05-23 Christopher James Lahey <clahey@helixcode.com>
+
* contact-editor/Makefile.am: Added e-contact-editor-save-as.c and
e-contact-editor-save-as.h.
diff --git a/addressbook/Makefile.am b/addressbook/Makefile.am
index 5ddbe71bc5..4ff2b4a114 100644
--- a/addressbook/Makefile.am
+++ b/addressbook/Makefile.am
@@ -1,2 +1,2 @@
SUBDIRS = \
- ename backend contact-editor gui printing
+ ename backend contact-editor printing gui
diff --git a/addressbook/backend/ebook/e-book-view-listener.h b/addressbook/backend/ebook/e-book-view-listener.h
index 85542217df..e479ffd99b 100644
--- a/addressbook/backend/ebook/e-book-view-listener.h
+++ b/addressbook/backend/ebook/e-book-view-listener.h
@@ -14,7 +14,7 @@
#include <libgnome/gnome-defs.h>
#include <bonobo/bonobo-object.h>
-#include <ebook/addressbook.h>
+#include <addressbook/backend/ebook/addressbook.h>
BEGIN_GNOME_DECLS
diff --git a/addressbook/backend/ebook/e-book-view.h b/addressbook/backend/ebook/e-book-view.h
index 5ae20e1521..92fde1e37f 100644
--- a/addressbook/backend/ebook/e-book-view.h
+++ b/addressbook/backend/ebook/e-book-view.h
@@ -13,8 +13,8 @@
#include <libgnome/gnome-defs.h>
-#include <ebook/e-card.h>
-#include <ebook/e-book-view-listener.h>
+#include <addressbook/backend/ebook/e-card.h>
+#include <addressbook/backend/ebook/e-book-view-listener.h>
BEGIN_GNOME_DECLS
diff --git a/addressbook/backend/ebook/e-book.h b/addressbook/backend/ebook/e-book.h
index 4cab606239..a57c7263b3 100644
--- a/addressbook/backend/ebook/e-book.h
+++ b/addressbook/backend/ebook/e-book.h
@@ -13,10 +13,10 @@
#include <libgnome/gnome-defs.h>
-#include <ebook/e-card.h>
-#include <ebook/e-card-cursor.h>
-#include <ebook/e-book-view.h>
-#include <ebook/e-book-types.h>
+#include <addressbook/backend/ebook/e-card.h>
+#include <addressbook/backend/ebook/e-card-cursor.h>
+#include <addressbook/backend/ebook/e-book-view.h>
+#include <addressbook/backend/ebook/e-book-types.h>
BEGIN_GNOME_DECLS
diff --git a/addressbook/backend/ebook/e-card-cursor.h b/addressbook/backend/ebook/e-card-cursor.h
index 67020071d1..b318e646c4 100644
--- a/addressbook/backend/ebook/e-card-cursor.h
+++ b/addressbook/backend/ebook/e-card-cursor.h
@@ -12,8 +12,8 @@
#include <libgnome/gnome-defs.h>
#include <gtk/gtk.h>
-#include <ebook/addressbook.h>
-#include <ebook/e-card.h>
+#include <addressbook/backend/ebook/addressbook.h>
+#include <addressbook/backend/ebook/e-card.h>
BEGIN_GNOME_DECLS
diff --git a/addressbook/backend/ebook/e-card-list.h b/addressbook/backend/ebook/e-card-list.h
index 0a4a5bf105..af791a81a0 100644
--- a/addressbook/backend/ebook/e-card-list.h
+++ b/addressbook/backend/ebook/e-card-list.h
@@ -13,7 +13,7 @@
#include <time.h>
#include <gtk/gtk.h>
#include <stdio.h>
-#include <ebook/e-card-iterator.h>
+#include <addressbook/backend/ebook/e-card-iterator.h>
#define E_TYPE_CARD_LIST (e_card_list_get_type ())
#define E_CARD_LIST(obj) (GTK_CHECK_CAST ((obj), E_TYPE_CARD_LIST, ECardList))
diff --git a/addressbook/backend/ebook/e-card-simple.h b/addressbook/backend/ebook/e-card-simple.h
index 9566248387..72351c571a 100644
--- a/addressbook/backend/ebook/e-card-simple.h
+++ b/addressbook/backend/ebook/e-card-simple.h
@@ -15,9 +15,9 @@
#include <time.h>
#include <gtk/gtk.h>
#include <stdio.h>
-#include <ebook/e-card.h>
-#include <ebook/e-card-types.h>
-#include <ebook/e-card-list.h>
+#include <addressbook/backend/ebook/e-card.h>
+#include <addressbook/backend/ebook/e-card-types.h>
+#include <addressbook/backend/ebook/e-card-list.h>
#define E_TYPE_CARD_SIMPLE (e_card_simple_get_type ())
#define E_CARD_SIMPLE(obj) (GTK_CHECK_CAST ((obj), E_TYPE_CARD_SIMPLE, ECardSimple))
diff --git a/addressbook/backend/ebook/e-card.h b/addressbook/backend/ebook/e-card.h
index 9f10a984ed..3def0654cd 100644
--- a/addressbook/backend/ebook/e-card.h
+++ b/addressbook/backend/ebook/e-card.h
@@ -15,8 +15,8 @@
#include <time.h>
#include <gtk/gtk.h>
#include <stdio.h>
-#include <ebook/e-card-types.h>
-#include <ebook/e-card-list.h>
+#include <addressbook/backend/ebook/e-card-types.h>
+#include <addressbook/backend/ebook/e-card-list.h>
#define E_TYPE_CARD (e_card_get_type ())
#define E_CARD(obj) (GTK_CHECK_CAST ((obj), E_TYPE_CARD, ECard))
diff --git a/addressbook/gui/component/Makefile.am b/addressbook/gui/component/Makefile.am
index 9df1ad065d..1a1752ea07 100644
--- a/addressbook/gui/component/Makefile.am
+++ b/addressbook/gui/component/Makefile.am
@@ -41,7 +41,8 @@ evolution_addressbook_LDADD = \
$(top_builddir)/libversit/libversit.la \
$(top_builddir)/widgets/e-text/libetext.a \
$(top_builddir)/widgets/e-table/libetable.a \
- $(top_builddir)/e-util/libeutil.la
+ $(top_builddir)/e-util/libeutil.la \
+ $(top_builddir)/addressbook/printing/libecontactprint.a
evolution_addressbook_LDFLAGS = `gnome-config --libs gdk_pixbuf`
@@ -71,5 +72,3 @@ evolution-addressbook.pure: evolution-addressbook
$(PLINK) $(evolution_addressbook_LDFLAGS) $(evolution_addressbook_OBJECTS) $(evolution_addressbook_LDADD) $(LIBS)
endif
-
-
diff --git a/addressbook/gui/component/addressbook.c b/addressbook/gui/component/addressbook.c
index f54738fcb9..af57378d5b 100644
--- a/addressbook/gui/component/addressbook.c
+++ b/addressbook/gui/component/addressbook.c
@@ -28,6 +28,8 @@
#include "e-contact-editor.h"
#include "e-ldap-server-dialog.h"
+#include <addressbook/printing/e-contact-print.h>
+
#ifdef USING_OAF
#define CONTROL_FACTORY_ID "OAFIID:control-factory:addressbook:3e10597b-0591-4d45-b082-d781b7aa6e17"
#else
@@ -67,6 +69,7 @@ static void
control_deactivate (BonoboControl *control, BonoboUIHandler *uih)
{
/* how to remove a menu item */
+ bonobo_ui_handler_menu_remove (uih, "/File/Print");
bonobo_ui_handler_menu_remove (uih, "/View/<sep>");
bonobo_ui_handler_menu_remove (uih, "/View/Toggle View");
bonobo_ui_handler_menu_remove (uih, "/Actions/New Contact");
@@ -283,6 +286,16 @@ delete_contact_cb (BonoboUIHandler *uih, void *user_data, const char *path)
e_minicard_view_remove_selection (E_MINICARD_VIEW(view->view), card_deleted_cb, NULL);
}
+static void
+print_cb (BonoboUIHandler *uih, void *user_data, const char *path)
+{
+ AddressbookView *view = (AddressbookView *) user_data;
+ char *query = get_query(view);
+ GtkWidget *print = e_contact_print_dialog_new(view->book, query);
+ g_free(query);
+ gtk_widget_show_all(print);
+}
+
static GnomeUIInfo gnome_toolbar [] = {
GNOMEUIINFO_ITEM_STOCK (N_("New"), N_("Create a new contact"), new_contact_cb, GNOME_STOCK_PIXMAP_NEW),
@@ -355,6 +368,13 @@ control_activate (BonoboControl *control, BonoboUIHandler *uih,
bonobo_ui_handler_menu_new_separator (uih, "/View/<sep>", -1);
+ bonobo_ui_handler_menu_new_item (uih, "/File/Print",
+ N_("Print"),
+ NULL, -1,
+ BONOBO_UI_HANDLER_PIXMAP_NONE, NULL,
+ 0, 0, print_cb,
+ (gpointer) view);
+
bonobo_ui_handler_menu_new_item (uih, "/View/Toggle View",
N_("As _Table"),
NULL, -1,
diff --git a/addressbook/printing/Makefile.am b/addressbook/printing/Makefile.am
index 0aa9dbef9d..d0268d7dbc 100644
--- a/addressbook/printing/Makefile.am
+++ b/addressbook/printing/Makefile.am
@@ -1,12 +1,26 @@
+ecpsdir = $(datadir)/evolution/ecps
+
+ecps_DATA = \
+ smallbook.ecps \
+ medbook.ecps \
+ phonelist.ecps
+
+gladedir = $(datadir)/evolution/glade
+
+glade_DATA = \
+ e-contact-print.glade
CPPFLAGS = \
-DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \
+ -DEVOLUTION_ECPSDIR=\""$(ecpsdir)"\" \
-DDATADIR=\""$(datadir)"\" \
$(GNOME_PRINT_CFLAGS)
INCLUDES = \
$(GNOME_INCLUDEDIR) \
- -DG_LOG_DOMAIN=\"addressbook-printing\"
+ -DG_LOG_DOMAIN=\"addressbook-printing\" \
+ -I$(top_srcdir)/addressbook \
+ -I$(top_srcdir)
noinst_LIBRARIES = \
libecontactprint.a
@@ -27,6 +41,11 @@ contact_print_test_SOURCES = \
contact_print_test_LDADD = \
$(EXTRA_GNOME_LIBS) \
+ -lbonobo \
+ $(top_builddir)/addressbook/backend/ebook/libebook.la \
+ $(top_builddir)/e-util/libeutil.la \
+ $(top_builddir)/libversit/libversit.la \
+ $(top_builddir)/addressbook/ename/libename.la \
libecontactprint.a \
$(GNOME_PRINT_LIBS)
@@ -35,13 +54,12 @@ contact_print_style_editor_test_SOURCES = \
contact_print_style_editor_test_LDADD = \
$(EXTRA_GNOME_LIBS) \
+ -lbonobo \
+ $(top_builddir)/addressbook/backend/ebook/libebook.la \
+ $(top_builddir)/e-util/libeutil.la \
+ $(top_builddir)/libversit/libversit.la \
+ $(top_builddir)/addressbook/ename/libename.la \
libecontactprint.a \
$(GNOME_PRINT_LIBS)
-gladedir = $(datadir)/evolution/glade
-
-glade_DATA = \
- e-contact-print.glade
-
-EXTRA_DIST = $(glade_DATA)
-
+EXTRA_DIST = $(glade_DATA) $(ecps_DATA)
diff --git a/addressbook/printing/e-contact-print.c b/addressbook/printing/e-contact-print.c
index f86d2613b1..98c4d96a47 100644
--- a/addressbook/printing/e-contact-print.c
+++ b/addressbook/printing/e-contact-print.c
@@ -31,6 +31,9 @@
#include <gnome-xml/parser.h>
#include <gnome-xml/xmlmemory.h>
#include <ctype.h>
+#include <addressbook/backend/ebook/e-book.h>
+#include <addressbook/backend/ebook/e-card.h>
+#include <addressbook/backend/ebook/e-card-simple.h>
#define SCALE 5
#define HYPHEN_PIXELS 20
@@ -38,8 +41,6 @@
typedef struct _EContactPrintContext EContactPrintContext;
-static int cardcount;
-
struct _EContactPrintContext
{
GnomePrintContext *pc;
@@ -53,10 +54,16 @@ struct _EContactPrintContext
gchar last_char_on_page;
GnomeFont *letter_heading_font;
GnomeFont *letter_tab_font;
+ char *character;
+ gboolean first_contact;
+
+ int type;
+ EBook *book;
+ gchar *query;
};
static gint
-e_contact_divide_text(GnomePrintContext *pc, GnomeFont *font, double width, gchar *text, GList **return_val /* Of type char[] */)
+e_contact_divide_text(GnomePrintContext *pc, GnomeFont *font, double width, const gchar *text, GList **return_val /* Of type char[] */)
{
if ( width == -1 || gnome_font_get_width_string(font, text) <= width ) {
if ( return_val ) {
@@ -232,7 +239,7 @@ e_contact_divide_text(GnomePrintContext *pc, GnomeFont *font, double width, gcha
}
static void
-e_contact_output(GnomePrintContext *pc, GnomeFont *font, double x, double y, double width, gchar *text)
+e_contact_output(GnomePrintContext *pc, GnomeFont *font, double x, double y, double width, const gchar *text)
{
GList *list = NULL, *list_start;
int first_line = 1;
@@ -295,23 +302,6 @@ e_contact_rectangle(GnomePrintContext *pc,
gnome_print_grestore(pc);
}
-static gchar *e_card_get_string(void *card, gchar *key)
-{
- return key;
-}
-
-static gchar *e_card_get_string_fileas(void *card)
-{
- if (cardcount < 4)
- return "Lahey, Chris";
- else if (cardcount < 20)
- return "Rasputin";
- else if (cardcount < 24)
- return "Wow, this guy has a really long name. Can you believe it?";
- else
- return "Zamboni";
-}
-
static double
e_contact_get_letter_tab_width (EContactPrintContext *ctxt)
{
@@ -399,11 +389,13 @@ e_contact_start_new_page(EContactPrintContext *ctxt)
}
static double
-e_contact_get_card_size(void *card, EContactPrintContext *ctxt, GList *shown_fields)
+e_contact_get_card_size(ECardSimple *simple, EContactPrintContext *ctxt)
{
gdouble height = 0;
gdouble page_width = 72 * (ctxt->style->page_width - ctxt->style->left_margin - ctxt->style->right_margin);
gdouble column_width;
+ char *file_as;
+ gint field;
if ( ctxt->style->letter_tabs )
page_width -= e_contact_get_letter_tab_width(ctxt);
column_width = (page_width + 18) / ctxt->style->num_columns - 18;
@@ -412,18 +404,25 @@ e_contact_get_card_size(void *card, EContactPrintContext *ctxt, GList *shown_fie
height += ctxt->style->headings_font->size * .2;
- height += e_contact_text_height(ctxt->pc, ctxt->style->headings_font, column_width - 4, e_card_get_string_fileas(card));
+ gtk_object_get(GTK_OBJECT(simple->card),
+ "file_as", &file_as,
+ NULL);
+ height += e_contact_text_height(ctxt->pc, ctxt->style->headings_font, column_width - 4, file_as);
height += ctxt->style->headings_font->size * .2;
height += ctxt->style->headings_font->size * .2;
- for(; shown_fields; shown_fields = g_list_next(shown_fields)) {
- double xoff = 0;
- gchar *field = e_card_get_string(card, shown_fields->data);
- xoff += gnome_font_get_width_string(ctxt->style->body_font, shown_fields->data);
- xoff += gnome_font_get_width_string(ctxt->style->body_font, ": ");
- height += e_contact_text_height(ctxt->pc, ctxt->style->body_font, column_width - xoff, field);
- height += .2 * ctxt->style->body_font->size;
+ for(field = E_CARD_SIMPLE_FIELD_FULL_NAME; field != E_CARD_SIMPLE_FIELD_LAST; field++) {
+ char *string;
+ string = e_card_simple_get(simple, field);
+ if (string && *string) {
+ double xoff = 0;
+ xoff += gnome_font_get_width_string(ctxt->style->body_font, e_card_simple_get_name(simple, field));
+ xoff += gnome_font_get_width_string(ctxt->style->body_font, ": ");
+ height += e_contact_text_height(ctxt->pc, ctxt->style->body_font, column_width - xoff, string);
+ height += .2 * ctxt->style->body_font->size;
+ }
+ g_free(string);
}
height += ctxt->style->headings_font->size * .4;
return height;
@@ -431,10 +430,13 @@ e_contact_get_card_size(void *card, EContactPrintContext *ctxt, GList *shown_fie
static void
-e_contact_print_card (void *card, EContactPrintContext *ctxt, GList *shown_fields)
+e_contact_print_card (ECardSimple *simple, EContactPrintContext *ctxt)
{
gdouble page_width = 72 * (ctxt->style->page_width - ctxt->style->left_margin - ctxt->style->right_margin);
gdouble column_width;
+ char *file_as;
+ int field;
+
if ( ctxt->style->letter_tabs )
page_width -= e_contact_get_letter_tab_width(ctxt);
column_width = (page_width + 18) / ctxt->style->num_columns - 18;
@@ -445,25 +447,33 @@ e_contact_print_card (void *card, EContactPrintContext *ctxt, GList *shown_field
ctxt->y -= ctxt->style->headings_font->size * .2;
+ gtk_object_get(GTK_OBJECT(simple->card),
+ "file_as", &file_as,
+ NULL);
if (ctxt->style->print_using_grey)
- e_contact_rectangle(ctxt->pc, ctxt->x, ctxt->y + ctxt->style->headings_font->size * .2, ctxt->x + column_width, ctxt->y - e_contact_text_height(ctxt->pc, ctxt->style->headings_font, column_width - 4, e_card_get_string_fileas(card)) - ctxt->style->headings_font->size * .2, .85, .85, .85);
- e_contact_output(ctxt->pc, ctxt->style->headings_font, ctxt->x + 2, ctxt->y, column_width - 4, e_card_get_string_fileas(card));
- ctxt->y -= e_contact_text_height(ctxt->pc, ctxt->style->headings_font, column_width - 4, e_card_get_string_fileas(card));
+ e_contact_rectangle(ctxt->pc, ctxt->x, ctxt->y + ctxt->style->headings_font->size * .2, ctxt->x + column_width, ctxt->y - e_contact_text_height(ctxt->pc, ctxt->style->headings_font, column_width - 4, file_as) - ctxt->style->headings_font->size * .2, .85, .85, .85);
+ e_contact_output(ctxt->pc, ctxt->style->headings_font, ctxt->x + 2, ctxt->y, column_width - 4, file_as);
+ ctxt->y -= e_contact_text_height(ctxt->pc, ctxt->style->headings_font, column_width - 4, file_as);
ctxt->y -= ctxt->style->headings_font->size * .2;
ctxt->y -= ctxt->style->headings_font->size * .2;
- for(; shown_fields; shown_fields = g_list_next(shown_fields)) {
- double xoff = 0;
- gchar *field = e_card_get_string(card, shown_fields->data);
- e_contact_output(ctxt->pc, ctxt->style->body_font, ctxt->x + xoff, ctxt->y, -1, shown_fields->data);
- xoff += gnome_font_get_width_string(ctxt->style->body_font, shown_fields->data);
- e_contact_output(ctxt->pc, ctxt->style->body_font, ctxt->x + xoff, ctxt->y, -1, ": ");
- xoff += gnome_font_get_width_string(ctxt->style->body_font, ": ");
- e_contact_output(ctxt->pc, ctxt->style->body_font, ctxt->x + xoff, ctxt->y, column_width - xoff, field);
- ctxt->y -= e_contact_text_height(ctxt->pc, ctxt->style->body_font, column_width - xoff, field);
- ctxt->y -= .2 * ctxt->style->body_font->size;
+ for(field = E_CARD_SIMPLE_FIELD_FULL_NAME; field != E_CARD_SIMPLE_FIELD_LAST; field++) {
+ char *string;
+ string = e_card_simple_get(simple, field);
+ if (string && *string) {
+ double xoff = 0;
+ e_contact_output(ctxt->pc, ctxt->style->body_font, ctxt->x + xoff, ctxt->y, -1, e_card_simple_get_name(simple, field));
+ xoff += gnome_font_get_width_string(ctxt->style->body_font, e_card_simple_get_name(simple, field));
+ e_contact_output(ctxt->pc, ctxt->style->body_font, ctxt->x + xoff, ctxt->y, -1, ": ");
+ xoff += gnome_font_get_width_string(ctxt->style->body_font, ": ");
+ e_contact_output(ctxt->pc, ctxt->style->body_font, ctxt->x + xoff, ctxt->y, column_width - xoff, string);
+ ctxt->y -= e_contact_text_height(ctxt->pc, ctxt->style->body_font, column_width - xoff, string);
+ ctxt->y -= .2 * ctxt->style->body_font->size;
+ }
+ g_free(string);
}
+
ctxt->y -= ctxt->style->headings_font->size * .4;
gnome_print_grestore(ctxt->pc);
}
@@ -486,73 +496,118 @@ e_contact_start_new_column (EContactPrintContext *ctxt)
}
static void
-e_contact_do_print_cards (void *book, EContactPrintContext *ctxt, GList *shown_fields)
+create_card(EBookView *book_view, const GList *cards, EContactPrintContext *ctxt)
{
- gchar *character = NULL;
- void *card = NULL;
- gboolean first_contact = TRUE;
- gdouble page_width = 72 * (ctxt->style->page_width - ctxt->style->left_margin - ctxt->style->right_margin);
- gdouble column_width;
- 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;
-
- column_width = (page_width + 18) / ctxt->style->num_columns - 18;
- /*
- for(card = e_book_get_first(book); card; card = e_book_get_next(book)) {
- */
- for (cardcount=0; cardcount < 30; cardcount++) {
- gchar *file_as = e_card_get_string_fileas(card);
- if ( file_as && (!character || *character != tolower(*file_as)) ) {
- if (ctxt->style->sections_start_new_page && ! first_contact) {
+ for(; cards; cards = cards->next) {
+ ECard *card = cards->data;
+ ECardSimple *simple = e_card_simple_new(card);
+ gchar *file_as;
+
+ gtk_object_get(GTK_OBJECT(card),
+ "file_as", &file_as,
+ NULL);
+ if ( file_as && (!ctxt->character || *ctxt->character != tolower(*file_as)) ) {
+ if (ctxt->style->sections_start_new_page && ! ctxt->first_contact) {
e_contact_start_new_page(ctxt);
}
- else if ((!first_contact) && (ctxt->y - e_contact_get_letter_heading_height(ctxt) - e_contact_get_card_size(card, ctxt, shown_fields) < ctxt->style->bottom_margin * 72))
+ else if ((!ctxt->first_contact) && (ctxt->y - e_contact_get_letter_heading_height(ctxt) - e_contact_get_card_size(simple, ctxt) < ctxt->style->bottom_margin * 72))
e_contact_start_new_column(ctxt);
- if (!character)
- character = g_strdup(" ");
- *character = tolower(*file_as);
+ if (!ctxt->character)
+ ctxt->character = g_strdup(" ");
+ *ctxt->character = tolower(*file_as);
if ( ctxt->style->letter_headings )
- e_contact_print_letter_heading(ctxt, character);
+ e_contact_print_letter_heading(ctxt, ctxt->character);
ctxt->first_section = FALSE;
}
- else if ( (!first_contact) && (ctxt->y - e_contact_get_card_size(card, ctxt, shown_fields) < ctxt->style->bottom_margin * 72)) {
+ else if ( (!ctxt->first_contact) && (ctxt->y - e_contact_get_card_size(simple, ctxt) < ctxt->style->bottom_margin * 72)) {
e_contact_start_new_column(ctxt);
if ( ctxt->style->letter_headings )
- e_contact_print_letter_heading(ctxt, character);
+ e_contact_print_letter_heading(ctxt, ctxt->character);
}
ctxt->last_char_on_page = toupper(*file_as);
if ( ctxt->last_char_on_page < ctxt->first_char_on_page )
ctxt->first_char_on_page = ctxt->last_char_on_page;
- e_contact_print_card(card, ctxt, shown_fields);
- first_contact = FALSE;
+ e_contact_print_card(simple, ctxt);
+ ctxt->first_contact = FALSE;
+ gtk_object_unref(GTK_OBJECT(simple));
}
ctxt->last_char_on_page = 'Z';
if ( ctxt->style->letter_tabs )
e_contact_print_letter_tab(ctxt);
gnome_print_showpage(ctxt->pc);
gnome_print_context_close(ctxt->pc);
- g_free(character);
+ g_free(ctxt->character);
+ 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"));
+ gtk_widget_show_all(preview);
+ } else {
+ gnome_print_master_print(ctxt->master);
+ }
+ gtk_object_unref(GTK_OBJECT(ctxt->pc));
+ gtk_object_unref(GTK_OBJECT(ctxt->master));
+ gtk_object_unref(GTK_OBJECT(ctxt->book));
+ g_free(ctxt->query);
+ gtk_object_unref(GTK_OBJECT(ctxt->style->headings_font));
+ gtk_object_unref(GTK_OBJECT(ctxt->style->body_font));
+ gtk_object_unref(GTK_OBJECT(ctxt->style->header_font));
+ gtk_object_unref(GTK_OBJECT(ctxt->style->footer_font));
+ gtk_object_unref(GTK_OBJECT(ctxt->letter_heading_font));
+ gtk_object_unref(GTK_OBJECT(ctxt->letter_tab_font));
+ g_free(ctxt->style);
+ g_free(ctxt);
+}
+
+static void
+book_view_loaded (EBook *book, EBookStatus status, EBookView *book_view, EContactPrintContext *ctxt)
+{
+ gtk_object_ref(GTK_OBJECT(book_view));
+
+ gtk_signal_connect(GTK_OBJECT(book_view),
+ "card_added",
+ GTK_SIGNAL_FUNC(create_card),
+ ctxt);
+}
+
+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);
}
+#if 0
static double
-e_contact_get_phone_list_size(void *card, EContactPrintContext *ctxt, GList *shown_fields)
+e_contact_get_phone_list_size(ECardSimple *simple, EContactPrintContext *ctxt)
{
double height = 0;
+ int field;
height += ctxt->style->headings_font->size * .2;
height += ctxt->style->headings_font->size * .2;
- for(; shown_fields; shown_fields = g_list_next(shown_fields)) {
- if ( 1 ) /* field is a phone field. */ {
- gchar *field = e_card_get_string(card, shown_fields->data);
- height += e_contact_text_height(ctxt->pc, ctxt->style->body_font, 100, field);
- height += .2 * ctxt->style->body_font->size;
+ for(field = E_CARD_SIMPLE_FIELD_FULL_NAME; field != E_CARD_SIMPLE_FIELD_LAST; field++) {
+ char *string;
+ string = e_card_simple_get(simple, field);
+ if (string && *string) {
+ if ( 1 ) /* field is a phone field. */ {
+ gchar *field = string;
+ height += e_contact_text_height(ctxt->pc, ctxt->style->body_font, 100, field);
+ height += .2 * ctxt->style->body_font->size;
+ }
}
+ g_free(string);
}
height += ctxt->style->headings_font->size * .4;
return height;
@@ -560,7 +615,7 @@ e_contact_get_phone_list_size(void *card, EContactPrintContext *ctxt, GList *sho
static void
-e_contact_print_phone_list (void *card, EContactPrintContext *ctxt, GList *shown_fields)
+e_contact_print_phone_list (ECard *card, EContactPrintContext *ctxt)
{
gdouble page_width = 72 * (ctxt->style->page_width - ctxt->style->left_margin - ctxt->style->right_margin);
gdouble column_width;
@@ -568,6 +623,7 @@ e_contact_print_phone_list (void *card, EContactPrintContext *ctxt, GList *shown
int dotcount;
char *dots;
int i;
+ char *file_as;
if ( ctxt->style->letter_tabs )
page_width -= e_contact_get_letter_tab_width(ctxt);
column_width = (page_width + 18) / ctxt->style->num_columns - 18;
@@ -611,14 +667,14 @@ e_contact_print_phone_list (void *card, EContactPrintContext *ctxt, GList *shown
}
static void
-e_contact_do_print_phone_list (void *book, EContactPrintContext *ctxt, GList *shown_fields)
+e_contact_do_print_phone_list (EBook *book, char *query, EContactPrintContext *ctxt)
{
- gchar *character = NULL;
- void *card = NULL;
+ ECard *card = NULL;
int i;
- gboolean first_contact = TRUE;
gdouble page_width = 72 * (ctxt->style->page_width - ctxt->style->left_margin - ctxt->style->right_margin);
gdouble column_width;
+ 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 )
@@ -663,17 +719,20 @@ e_contact_do_print_phone_list (void *book, EContactPrintContext *ctxt, GList *sh
gnome_print_context_close(ctxt->pc);
g_free(character);
}
+#endif
static void
-e_contact_do_print (void *book, EContactPrintContext *ctxt, GList *shown_fields)
+e_contact_do_print (EBook *book, char *query, EContactPrintContext *ctxt)
{
switch ( ctxt->style->type ) {
case E_CONTACT_PRINT_TYPE_CARDS:
- e_contact_do_print_cards( book, ctxt, shown_fields );
+ e_contact_do_print_cards( book, query, ctxt);
break;
+#if 0
case E_CONTACT_PRINT_TYPE_PHONE_LIST:
- e_contact_do_print_phone_list( book, ctxt, shown_fields );
+ e_contact_do_print_phone_list( book, query, ctxt );
break;
+#endif
default:
break;
}
@@ -735,6 +794,7 @@ static void
e_contact_build_style(EContactPrintStyle *style)
{
xmlDocPtr styledoc;
+ gchar *filename;
style->title = g_strdup("");
style->type = E_CONTACT_PRINT_TYPE_CARDS;
style->sections_start_new_page = TRUE;
@@ -774,7 +834,9 @@ e_contact_build_style(EContactPrintStyle *style)
style->center_footer = g_strdup("");
style->right_footer = g_strdup("");
style->reverse_on_even_pages = FALSE;
- styledoc = xmlParseFile("smallbook.ecps");
+ filename = g_concat_dir_and_file(EVOLUTION_ECPSDIR, "smallbook.ecps");
+ styledoc = xmlParseFile(filename);
+ g_free(filename);
if (styledoc) {
xmlNodePtr stylenode = xmlDocGetRootElement(styledoc);
xmlNodePtr node;
@@ -864,81 +926,84 @@ e_contact_print_close(GnomeDialog *dialog, gpointer data)
static void
e_contact_print_button(GnomeDialog *dialog, gint button, gpointer data)
{
- EContactPrintContext ctxt;
- EContactPrintStyle style;
+ EContactPrintContext *ctxt = g_new(EContactPrintContext, 1);
+ EContactPrintStyle *style = g_new(EContactPrintStyle, 1);
GnomePrintMaster *master;
- GtkWidget *preview;
GnomePrintContext *pc;
- void *book = gtk_object_get_data(GTK_OBJECT(dialog), "book");
- GList *shown_fields = gtk_object_get_data(GTK_OBJECT(dialog), "shown_fields");
+ EBook *book = gtk_object_get_data(GTK_OBJECT(dialog), "book");
+ char *query = gtk_object_get_data(GTK_OBJECT(dialog), "query");
gdouble font_size;
switch( button ) {
case GNOME_PRINT_PRINT:
master = gnome_print_master_new_from_dialog( GNOME_PRINT_DIALOG(dialog) );
pc = gnome_print_master_get_context( master );
- e_contact_build_style(&style);
+ e_contact_build_style(style);
- ctxt.x = 0;
- ctxt.y = 0;
- ctxt.column = 0;
- ctxt.style = &style;
- ctxt.master = master;
- ctxt.first_section = TRUE;
- ctxt.first_char_on_page = 'A' - 1;
-
- font_size = 72 * ctxt.style->page_height / 27.0 / 2.0;
- ctxt.letter_heading_font = gnome_font_new(gnome_font_get_name(ctxt.style->headings_font), ctxt.style->headings_font->size * 1.5);
- ctxt.letter_tab_font = gnome_font_new(gnome_font_get_name(ctxt.style->headings_font), font_size);
+ ctxt->x = 0;
+ ctxt->y = 0;
+ ctxt->column = 0;
+ ctxt->style = style;
+ ctxt->master = master;
+ ctxt->first_section = TRUE;
+ ctxt->first_char_on_page = 'A' - 1;
+ ctxt->type = GNOME_PRINT_PRINT;
+
+ font_size = 72 * ctxt->style->page_height / 27.0 / 2.0;
+ ctxt->letter_heading_font = gnome_font_new(gnome_font_get_name(ctxt->style->headings_font), ctxt->style->headings_font->size * 1.5);
+ ctxt->letter_tab_font = gnome_font_new(gnome_font_get_name(ctxt->style->headings_font), font_size);
- ctxt.pc = GNOME_PRINT_CONTEXT(gnome_print_multipage_new_from_sizes(pc,
- 72 * style.paper_width,
- 72 * style.paper_height,
- 72 * style.page_width,
- 72 * style.page_height));
+ ctxt->pc = GNOME_PRINT_CONTEXT(gnome_print_multipage_new_from_sizes(pc,
+ 72 * style->paper_width,
+ 72 * style->paper_height,
+ 72 * style->page_width,
+ 72 * style->page_height));
- e_contact_do_print(book, &ctxt, shown_fields);
- gnome_print_master_print(master);
- gtk_object_unref(GTK_OBJECT(ctxt.pc));
- gtk_object_unref(GTK_OBJECT(master));
+ ctxt->book = book;
+ ctxt->query = query;
+ e_contact_do_print(book, ctxt->query, ctxt);
gnome_dialog_close(dialog);
break;
case GNOME_PRINT_PREVIEW:
master = gnome_print_master_new_from_dialog( GNOME_PRINT_DIALOG(dialog) );
pc = gnome_print_master_get_context( master );
- e_contact_build_style(&style);
+ e_contact_build_style(style);
- ctxt.x = 0;
- ctxt.y = 0;
- ctxt.column = 0;
- ctxt.style = &style;
- ctxt.master = master;
- ctxt.first_section = TRUE;
- ctxt.first_char_on_page = 'A' - 1;
-
- font_size = 72 * ctxt.style->page_height / 27.0 / 2.0;
- ctxt.letter_heading_font = gnome_font_new(gnome_font_get_name(ctxt.style->headings_font), ctxt.style->headings_font->size * 1.5);
- ctxt.letter_tab_font = gnome_font_new(gnome_font_get_name(ctxt.style->headings_font), font_size);
+ ctxt->x = 0;
+ ctxt->y = 0;
+ ctxt->column = 0;
+ ctxt->style = style;
+ ctxt->master = master;
+ ctxt->first_section = TRUE;
+ ctxt->first_char_on_page = 'A' - 1;
+ ctxt->type = GNOME_PRINT_PREVIEW;
+
+ font_size = 72 * ctxt->style->page_height / 27.0 / 2.0;
+ ctxt->letter_heading_font = gnome_font_new(gnome_font_get_name(ctxt->style->headings_font), ctxt->style->headings_font->size * 1.5);
+ ctxt->letter_tab_font = gnome_font_new(gnome_font_get_name(ctxt->style->headings_font), font_size);
- ctxt.pc = GNOME_PRINT_CONTEXT(gnome_print_multipage_new_from_sizes(pc,
- 72 * style.paper_width,
- 72 * style.paper_height,
- 72 * style.page_width,
- 72 * style.page_height));
+ ctxt->pc = GNOME_PRINT_CONTEXT(gnome_print_multipage_new_from_sizes(pc,
+ 72 * style->paper_width,
+ 72 * style->paper_height,
+ 72 * style->page_width,
+ 72 * style->page_height));
- e_contact_do_print(book, &ctxt, shown_fields);
- preview = GTK_WIDGET(gnome_print_master_preview_new(master, "Print Preview"));
- gtk_widget_show_all(preview);
- gtk_object_unref(GTK_OBJECT(ctxt.pc));
- gtk_object_unref(GTK_OBJECT(master));
+ gtk_object_ref(GTK_OBJECT(book));
+ ctxt->book = book;
+ ctxt->query = g_strdup(query);
+ e_contact_do_print(book, ctxt->query, ctxt);
break;
case GNOME_PRINT_CANCEL:
+ gtk_object_unref(GTK_OBJECT(book));
+ g_free(query);
gnome_dialog_close(dialog);
+ g_free(style);
+ g_free(ctxt);
break;
}
}
GtkWidget *
-e_contact_print_dialog_new(void *book, GList *shown_fields)
+e_contact_print_dialog_new(EBook *book, char *query)
{
GtkWidget *dialog;
@@ -947,8 +1012,9 @@ e_contact_print_dialog_new(void *book, GList *shown_fields)
gnome_print_dialog_construct_range_any(GNOME_PRINT_DIALOG(dialog), GNOME_PRINT_RANGE_ALL | GNOME_PRINT_RANGE_SELECTION,
NULL, NULL, NULL);
+ gtk_object_ref(GTK_OBJECT(book));
gtk_object_set_data(GTK_OBJECT(dialog), "book", book);
- gtk_object_set_data(GTK_OBJECT(dialog), "shown_fields", shown_fields);
+ gtk_object_set_data(GTK_OBJECT(dialog), "query", g_strdup(query));
gtk_signal_connect(GTK_OBJECT(dialog),
"clicked", GTK_SIGNAL_FUNC(e_contact_print_button), NULL);
gtk_signal_connect(GTK_OBJECT(dialog),
diff --git a/addressbook/printing/e-contact-print.h b/addressbook/printing/e-contact-print.h
index 28a0d14441..8649a2ff6a 100644
--- a/addressbook/printing/e-contact-print.h
+++ b/addressbook/printing/e-contact-print.h
@@ -24,8 +24,9 @@
#define E_CONTACT_PRINT_H
#include <gnome.h>
+#include <addressbook/backend/ebook/e-book.h>
#include "e-contact-print-types.h"
-GtkWidget *e_contact_print_dialog_new(void *book, GList *shown_fields);
+GtkWidget *e_contact_print_dialog_new(EBook *book, char *query);
#endif /* E_CONTACT_PRINT_H */
diff --git a/addressbook/printing/test-print.c b/addressbook/printing/test-print.c
index 7b438eed31..1b73fda3da 100644
--- a/addressbook/printing/test-print.c
+++ b/addressbook/printing/test-print.c
@@ -71,7 +71,7 @@ int main( int argc, char *argv[] )
shown_fields = g_list_append(shown_fields, "Third field");
shown_fields = g_list_append(shown_fields, "Fourth field");
- print = e_contact_print_dialog_new(NULL, shown_fields);
+ print = e_contact_print_dialog_new(NULL, NULL);
gtk_widget_show_all(print);
gtk_signal_connect(GTK_OBJECT(print), "close", GTK_SIGNAL_FUNC(test_close), NULL);