diff options
Diffstat (limited to 'addressbook/printing')
-rw-r--r-- | addressbook/printing/Makefile.am | 6 | ||||
-rw-r--r-- | addressbook/printing/e-contact-print-envelope.c | 31 | ||||
-rw-r--r-- | addressbook/printing/e-contact-print-envelope.h | 4 | ||||
-rw-r--r-- | addressbook/printing/e-contact-print.c | 327 | ||||
-rw-r--r-- | addressbook/printing/e-contact-print.h | 6 |
5 files changed, 108 insertions, 266 deletions
diff --git a/addressbook/printing/Makefile.am b/addressbook/printing/Makefile.am index b28d841ec2..f9e9661890 100644 --- a/addressbook/printing/Makefile.am +++ b/addressbook/printing/Makefile.am @@ -38,16 +38,18 @@ contact_print_test_SOURCES = \ test-print.c contact_print_test_LDADD = \ - $(top_builddir)/addressbook/backend/ebook/libebook.la \ libecontactprint.la \ + $(top_builddir)/addressbook/util/libeabutil.la \ + $(top_builddir)/addressbook/backend/ebook/libebook.la \ $(EVOLUTION_ADDRESSBOOK_LIBS) contact_print_style_editor_test_SOURCES = \ test-contact-print-style-editor.c contact_print_style_editor_test_LDADD = \ - $(top_builddir)/addressbook/backend/ebook/libebook.la \ libecontactprint.la \ + $(top_builddir)/addressbook/util/libeabutil.la \ + $(top_builddir)/addressbook/backend/ebook/libebook.la \ $(EVOLUTION_ADDRESSBOOK_LIBS) diff --git a/addressbook/printing/e-contact-print-envelope.c b/addressbook/printing/e-contact-print-envelope.c index 93916744da..c7bd68163f 100644 --- a/addressbook/printing/e-contact-print-envelope.c +++ b/addressbook/printing/e-contact-print-envelope.c @@ -29,8 +29,6 @@ #include <libgnomeprint/gnome-print.h> #include <libgnomeprint/gnome-print-job.h> #include <libgnomeprintui/gnome-print-job-preview.h> -#include "addressbook/backend/ebook/e-card.h" -#include "addressbook/backend/ebook/e-card-simple.h" #define ENVELOPE_HEIGHT (72.0 * 4.0) #define ENVELOPE_WIDTH (72.0 * 9.5) @@ -131,9 +129,8 @@ e_contact_print_envelope_close(GnomeDialog *dialog, gpointer data) } static void -ecpe_print(GnomePrintContext *pc, ECard *ecard, gboolean as_return) +ecpe_print(GnomePrintContext *pc, EContact *contact, gboolean as_return) { - ECardSimple *card = e_card_simple_new(ecard); char *address; EcpeLine *linelist; double x; @@ -144,7 +141,7 @@ ecpe_print(GnomePrintContext *pc, ECard *ecard, gboolean as_return) gnome_print_rotate(pc, 90); gnome_print_translate(pc, 72.0 * 11.0 - ENVELOPE_WIDTH, -72.0 * 8.5 + (72.0 * 8.5 - ENVELOPE_HEIGHT) / 2); - address = e_card_simple_get(card, E_CARD_SIMPLE_FIELD_ADDRESS_BUSINESS); + address = e_contact_get(contact, E_CONTACT_ADDRESS_LABEL_WORK); linelist = ecpe_break(address); if (as_return) font = gnome_font_find ("Sans", 9); @@ -166,8 +163,6 @@ ecpe_print(GnomePrintContext *pc, ECard *ecard, gboolean as_return) gnome_print_showpage(pc); gnome_print_context_close(pc); - - g_object_unref(card); } static void @@ -176,10 +171,10 @@ e_contact_print_envelope_button(GnomeDialog *dialog, gint button, gpointer data) GnomePrintJob *master; GnomePrintContext *pc; GnomePrintConfig *config; - ECard *card = NULL; + EContact *contact = NULL; GtkWidget *preview; - card = g_object_get_data(G_OBJECT(dialog), "card"); + contact = g_object_get_data(G_OBJECT(dialog), "contact"); switch( button ) { case GNOME_PRINT_DIALOG_RESPONSE_PRINT: @@ -187,7 +182,7 @@ e_contact_print_envelope_button(GnomeDialog *dialog, gint button, gpointer data) master = gnome_print_job_new (config); pc = gnome_print_job_get_context( master ); - ecpe_print(pc, card, FALSE); + ecpe_print(pc, contact, FALSE); gnome_print_job_print(master); gnome_dialog_close(dialog); @@ -197,27 +192,27 @@ e_contact_print_envelope_button(GnomeDialog *dialog, gint button, gpointer data) master = gnome_print_job_new (config); pc = gnome_print_job_get_context( master ); - ecpe_print(pc, card, FALSE); + ecpe_print(pc, contact, FALSE); preview = GTK_WIDGET(gnome_print_job_preview_new(master, "Print Preview")); gtk_widget_show_all(preview); break; case GNOME_PRINT_DIALOG_RESPONSE_CANCEL: - g_object_unref(card); + g_object_unref(contact); gnome_dialog_close(dialog); break; } } GtkWidget * -e_contact_print_envelope_dialog_new(ECard *card) +e_contact_print_envelope_dialog_new(EContact *contact) { GtkWidget *dialog; dialog = gnome_print_dialog_new(NULL, _("Print envelope"), GNOME_PRINT_DIALOG_COPIES); - card = e_card_duplicate(card); - g_object_set_data(G_OBJECT(dialog), "card", card); + contact = e_contact_duplicate(contact); + g_object_set_data(G_OBJECT(dialog), "contact", contact); g_signal_connect(dialog, "clicked", G_CALLBACK(e_contact_print_envelope_button), NULL); g_signal_connect(dialog, @@ -230,15 +225,15 @@ GtkWidget * e_contact_print_envelope_list_dialog_new(GList *list) { GtkWidget *dialog; - ECard *card; + EContact *contact; if (list == NULL) return NULL; dialog = gnome_print_dialog_new(NULL, _("Print envelope"), GNOME_PRINT_DIALOG_COPIES); - card = e_card_duplicate(list->data); - g_object_set_data(G_OBJECT(dialog), "card", card); + contact = e_contact_duplicate(list->data); + g_object_set_data(G_OBJECT(dialog), "contact", contact); g_signal_connect(dialog, "clicked", G_CALLBACK(e_contact_print_envelope_button), NULL); g_signal_connect(dialog, diff --git a/addressbook/printing/e-contact-print-envelope.h b/addressbook/printing/e-contact-print-envelope.h index 4302c4c5d7..d9e24b1794 100644 --- a/addressbook/printing/e-contact-print-envelope.h +++ b/addressbook/printing/e-contact-print-envelope.h @@ -22,11 +22,11 @@ #ifndef E_CONTACT_PRINT_ENVELOPE_H #define E_CONTACT_PRINT_ENVELOPE_H -#include <addressbook/backend/ebook/e-card.h> +#include <addressbook/backend/ebook/e-contact.h> #include <gtk/gtkwidget.h> #include "e-contact-print-types.h" -GtkWidget *e_contact_print_envelope_dialog_new(ECard *card); +GtkWidget *e_contact_print_envelope_dialog_new(EContact *contact); GtkWidget *e_contact_print_envelope_list_dialog_new(GList *list); #endif /* E_CONTACT_PRINT_ENVELOPE_H */ diff --git a/addressbook/printing/e-contact-print.c b/addressbook/printing/e-contact-print.c index 81698ddb10..0aa2e67900 100644 --- a/addressbook/printing/e-contact-print.c +++ b/addressbook/printing/e-contact-print.c @@ -38,10 +38,9 @@ #include <libgnomeprint/gnome-print-job.h> #include <libgnomeprintui/gnome-print-dialog.h> #include <libgnomeprintui/gnome-print-job-preview.h> -#include <addressbook/backend/ebook/e-book.h> -#include <addressbook/backend/ebook/e-card.h> -#include <addressbook/backend/ebook/e-card-simple.h> -#include <addressbook/backend/ebook/e-destination.h> +#include <addressbook/backend/ebook/e-book-async.h> +#include <addressbook/backend/ebook/e-contact.h> +#include <addressbook/util/eab-destination.h> #define SCALE 5 #define HYPHEN_PIXELS 20 @@ -70,7 +69,7 @@ struct _EContactPrintContext EBook *book; gchar *query; - GList *cards; + GList *contacts; }; static gint @@ -274,7 +273,7 @@ e_contact_output(GnomePrintContext *pc, GnomeFont *font, double x, double y, dou } static gdouble -e_contact_text_height(GnomePrintContext *pc, GnomeFont *font, double width, gchar *text) +e_contact_text_height(GnomePrintContext *pc, GnomeFont *font, double width, const gchar *text) { int line_count = e_contact_divide_text(pc, font, width, text, NULL); return line_count * (gnome_font_get_ascender(font) + gnome_font_get_descender(font)) + @@ -402,12 +401,12 @@ e_contact_start_new_page(EContactPrintContext *ctxt) } static double -e_contact_get_card_size(ECardSimple *simple, EContactPrintContext *ctxt) +e_contact_get_contact_size(EContact *contact, 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; + const char *file_as; gint field; if ( ctxt->style->letter_tabs ) page_width -= e_contact_get_letter_tab_width(ctxt); @@ -417,22 +416,20 @@ e_contact_get_card_size(ECardSimple *simple, EContactPrintContext *ctxt) height += gnome_font_get_size (ctxt->style->headings_font) * .2; - g_object_get(simple->card, - "file_as", &file_as, - NULL); + file_as = e_contact_get_const (contact, E_CONTACT_FILE_AS); + height += e_contact_text_height(ctxt->pc, ctxt->style->headings_font, column_width - 4, file_as); - g_free (file_as); height += gnome_font_get_size (ctxt->style->headings_font) * .2; height += gnome_font_get_size (ctxt->style->headings_font) * .2; - for(field = E_CARD_SIMPLE_FIELD_FULL_NAME; field != E_CARD_SIMPLE_FIELD_LAST_SIMPLE_STRING; field++) { + for(field = E_CONTACT_FILE_AS; field != E_CONTACT_LAST_SIMPLE_STRING; field++) { char *string; - string = e_card_simple_get(simple, field); + string = e_contact_get(contact, field); if (string && *string) { double xoff = 0; - xoff += gnome_font_get_width_utf8(ctxt->style->body_font, e_card_simple_get_name(simple, field)); + xoff += gnome_font_get_width_utf8(ctxt->style->body_font, e_contact_pretty_name (field)); xoff += gnome_font_get_width_utf8(ctxt->style->body_font, ": "); height += e_contact_text_height(ctxt->pc, ctxt->style->body_font, column_width - xoff, string); height += .2 * gnome_font_get_size (ctxt->style->body_font); @@ -447,7 +444,7 @@ e_contact_get_card_size(ECardSimple *simple, EContactPrintContext *ctxt) static void -e_contact_print_card (ECardSimple *simple, EContactPrintContext *ctxt) +e_contact_print_contact (EContact *contact, EContactPrintContext *ctxt) { gdouble page_width = 72 * (ctxt->style->page_width - ctxt->style->left_margin - ctxt->style->right_margin); gdouble column_width; @@ -463,9 +460,7 @@ e_contact_print_card (ECardSimple *simple, EContactPrintContext *ctxt) ctxt->y -= gnome_font_get_size (ctxt->style->headings_font) * .2; ctxt->y -= gnome_font_get_size (ctxt->style->headings_font) * .2; - g_object_get(simple->card, - "file_as", &file_as, - NULL); + file_as = e_contact_get (contact, E_CONTACT_FILE_AS); if (ctxt->style->print_using_grey) e_contact_rectangle(ctxt->pc, ctxt->x, ctxt->y + gnome_font_get_size (ctxt->style->headings_font) * .3, ctxt->x + column_width, ctxt->y - e_contact_text_height(ctxt->pc, ctxt->style->headings_font, column_width - 4, file_as) - gnome_font_get_size (ctxt->style->headings_font) * .3, .85, .85, .85); e_contact_output(ctxt->pc, ctxt->style->headings_font, ctxt->x + 2, ctxt->y, column_width - 4, file_as); @@ -475,14 +470,14 @@ e_contact_print_card (ECardSimple *simple, EContactPrintContext *ctxt) ctxt->y -= gnome_font_get_size (ctxt->style->headings_font) * .2; ctxt->y -= gnome_font_get_size (ctxt->style->headings_font) * .2; - for(field = E_CARD_SIMPLE_FIELD_FULL_NAME; field != E_CARD_SIMPLE_FIELD_LAST_SIMPLE_STRING; field++) { + for(field = E_CONTACT_FILE_AS; field != E_CONTACT_LAST_SIMPLE_STRING; field++) { char *string; - string = e_card_simple_get(simple, field); + string = e_contact_get(contact, field); if (string && !strncmp (string, "<?xml", 4)) { - EDestination *dest = e_destination_import (string); + EABDestination *dest = eab_destination_import (string); if (dest != NULL) { - gchar *new_string = g_strdup (e_destination_get_address (dest)); + gchar *new_string = g_strdup (eab_destination_get_address (dest)); g_free (string); string = new_string; g_object_unref (dest); @@ -491,8 +486,8 @@ e_contact_print_card (ECardSimple *simple, EContactPrintContext *ctxt) 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_utf8(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, e_contact_pretty_name (field)); + xoff += gnome_font_get_width_utf8(ctxt->style->body_font, e_contact_pretty_name (field)); e_contact_output(ctxt->pc, ctxt->style->body_font, ctxt->x + xoff, ctxt->y, -1, ": "); xoff += gnome_font_get_width_utf8(ctxt->style->body_font, ": "); e_contact_output(ctxt->pc, ctxt->style->body_font, ctxt->x + xoff, ctxt->y, column_width - xoff, string); @@ -526,7 +521,7 @@ e_contact_start_new_column (EContactPrintContext *ctxt) static void complete_sequence(EBookView *book_view, EBookViewStatus status, EContactPrintContext *ctxt) { - GList *cards = ctxt->cards; + GList *contacts = ctxt->contacts; gdouble page_width = 72 * (ctxt->style->page_width - ctxt->style->left_margin - ctxt->style->right_margin); @@ -541,15 +536,13 @@ complete_sequence(EBookView *book_view, EBookViewStatus status, EContactPrintCon gnome_print_beginpage (ctxt->pc, NULL); - for(; cards; cards = cards->next) { - ECard *card = cards->data; - ECardSimple *simple = e_card_simple_new(card); + for(; contacts; contacts = contacts->next) { + EContact *contact = contacts->data; guchar *file_as; gchar *letter_str = NULL; - g_object_get(card, - "file_as", &file_as, - NULL); + file_as = e_contact_get (contact, E_CONTACT_FILE_AS); + if (file_as != NULL) { letter_str = g_strndup (file_as, g_utf8_next_char (file_as) - (gchar *) file_as); } @@ -559,13 +552,13 @@ complete_sequence(EBookView *book_view, EBookViewStatus status, EContactPrintCon if (ctxt->style->sections_start_new_page && ! ctxt->first_contact) { e_contact_start_new_page(ctxt); } - 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)) + else if ((!ctxt->first_contact) && (ctxt->y - e_contact_get_letter_heading_height(ctxt) - e_contact_get_contact_size(contact, ctxt) < ctxt->style->bottom_margin * 72)) e_contact_start_new_column(ctxt); if ( ctxt->style->letter_headings ) e_contact_print_letter_heading(ctxt, ctxt->character); ctxt->first_section = FALSE; } - else if ( (!ctxt->first_contact) && (ctxt->y - e_contact_get_card_size(simple, ctxt) < ctxt->style->bottom_margin * 72)) { + else if ( (!ctxt->first_contact) && (ctxt->y - e_contact_get_contact_size(contact, ctxt) < ctxt->style->bottom_margin * 72)) { e_contact_start_new_column(ctxt); if ( ctxt->style->letter_headings ) e_contact_print_letter_heading(ctxt, ctxt->character); @@ -574,9 +567,8 @@ complete_sequence(EBookView *book_view, EBookViewStatus status, EContactPrintCon 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(simple, ctxt); + e_contact_print_contact(contact, ctxt); ctxt->first_contact = FALSE; - g_object_unref(simple); } ctxt->last_char_on_page = 'Z'; if ( ctxt->style->letter_tabs ) @@ -598,8 +590,8 @@ complete_sequence(EBookView *book_view, EBookViewStatus status, EContactPrintCon if (ctxt->book) g_object_unref(ctxt->book); g_free(ctxt->query); - g_list_foreach(ctxt->cards, (GFunc) g_object_unref, NULL); - g_list_free(ctxt->cards); + g_list_foreach(ctxt->contacts, (GFunc) g_object_unref, NULL); + g_list_free(ctxt->contacts); g_object_unref(ctxt->style->headings_font); g_object_unref(ctxt->style->body_font); g_object_unref(ctxt->style->header_font); @@ -611,41 +603,32 @@ complete_sequence(EBookView *book_view, EBookViewStatus status, EContactPrintCon } static int -card_compare (ECard *card1, ECard *card2) { - int cmp = 0; - - if (card1 && card2) { - char *file_as1, *file_as2; - - g_object_get(card1, - "file_as", &file_as1, - NULL); - g_object_get(card2, - "file_as", &file_as2, - NULL); - if (file_as1 && file_as2) - cmp = g_utf8_collate(file_as1, file_as2); - else if (file_as1) - cmp = -1; - else if (file_as2) - cmp = 1; - else - cmp = strcmp(e_card_get_id(card1), e_card_get_id(card2)); - - g_free (file_as2); - g_free (file_as1); +contact_compare (EContact *contact1, EContact *contact2) +{ + if (contact1 && contact2) { + const char *file_as1, *file_as2; + file_as1 = e_contact_get_const (contact1, E_CONTACT_FILE_AS); + file_as2 = e_contact_get_const (contact2, E_CONTACT_FILE_AS); + if (file_as1 && file_as2) + return g_utf8_collate(file_as1, file_as2); + if (file_as1) + return -1; + if (file_as2) + return 1; + return strcmp(e_contact_get_const(contact1, E_CONTACT_UID), e_contact_get_const(contact2, E_CONTACT_UID)); + } else { + return 0; } - return cmp; } static void -create_card(EBookView *book_view, const GList *cards, EContactPrintContext *ctxt) +create_contact(EBookView *book_view, const GList *contacts, EContactPrintContext *ctxt) { - for(; cards; cards = cards->next) { - ECard *card = cards->data; - g_object_ref(card); - ctxt->cards = g_list_insert_sorted(ctxt->cards, card, (GCompareFunc) card_compare); + for(; contacts; contacts = contacts->next) { + EContact *contact = contacts->data; + g_object_ref(contact); + ctxt->contacts = g_list_insert_sorted(ctxt->contacts, contact, (GCompareFunc) contact_compare); } } @@ -655,169 +638,31 @@ book_view_loaded (EBook *book, EBookStatus status, EBookView *book_view, EContac g_object_ref(book_view); g_signal_connect(book_view, - "card_added", - G_CALLBACK(create_card), + "contacts_added", + G_CALLBACK(create_contact), ctxt); g_signal_connect(book_view, "sequence_complete", G_CALLBACK(complete_sequence), ctxt); -} - -static void -e_contact_do_print_cards (EBook *book, char *query, EContactPrintContext *ctxt) -{ - e_book_get_book_view(book, query, (EBookBookViewCallback) book_view_loaded, ctxt); -} - -#if 0 -static double -e_contact_get_phone_list_size(ECardSimple *simple, EContactPrintContext *ctxt) -{ - double height = 0; - int field; - - height += gnome_font_get_size (ctxt->style->headings_font) * .2; - - height += gnome_font_get_size (ctxt->style->headings_font) * .2; - - for(field = E_CARD_SIMPLE_FIELD_FULL_NAME; field != E_CARD_SIMPLE_FIELD_LAST_SIMPLE_STRING; 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 * gnome_font_get_size (ctxt->style->body_font); - } - } - g_free(string); - } - height += gnome_font_get_size (ctxt->style->headings_font) * .4; - return height; -} - - -static void -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; - double xoff, dotwidth; - 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; - - gnome_print_gsave(ctxt->pc); - - ctxt->y -= gnome_font_get_size (ctxt->style->headings_font) * .2; - ctxt->y -= gnome_font_get_size (ctxt->style->headings_font) * .2; - e_contact_output(ctxt->pc, ctxt->style->body_font, ctxt->x, ctxt->y, -1, e_card_get_string_fileas(card)); - - xoff = column_width - 9 * gnome_font_get_size (ctxt->style->body_font); - dotwidth = xoff - - gnome_font_get_width_utf8(ctxt->style->body_font, e_card_get_string_fileas(card)) - - gnome_font_get_width_utf8(ctxt->style->body_font, " "); - dotcount = dotwidth / gnome_font_get_width(ctxt->style->body_font, '.'); - dots = g_new(gchar, dotcount + 1); - for (i = 0; i < dotcount; i++) - dots[i] = '.'; - dots[dotcount] = 0; - e_contact_output(ctxt->pc, ctxt->style->body_font, ctxt->x + xoff - dotcount * gnome_font_get_width(ctxt->style->body_font, '.'), ctxt->y, -1, dots); - g_free(dots); - - 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); - e_contact_output(ctxt->pc, ctxt->style->body_font, ctxt->x + xoff, ctxt->y, -1, shown_fields->data); - e_contact_output(ctxt->pc, ctxt->style->body_font, - ctxt->x + column_width - gnome_font_get_width_utf8(ctxt->style->body_font, - field), - ctxt->y, - -1, - field); - ctxt->y -= e_contact_text_height(ctxt->pc, ctxt->style->body_font, 100, field); - ctxt->y -= .2 * gnome_font_get_size (ctxt->style->body_font); - } - } - ctxt->y -= gnome_font_get_size (ctxt->style->headings_font) * .4; - gnome_print_grestore(ctxt->pc); + e_book_view_start (book_view); } static void -e_contact_do_print_phone_list (EBook *book, char *query, EContactPrintContext *ctxt) +e_contact_do_print_contacts (EBook *book, char *query, EContactPrintContext *ctxt) { - ECard *card = NULL; - int i; - 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 ) - 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 (i=0; i < 30; i++) { - guchar *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) { - e_contact_start_new_page(ctxt); - } - else if ((!first_contact) && (ctxt->y - e_contact_get_letter_heading_height(ctxt) - e_contact_get_phone_list_size(card, ctxt, shown_fields) < ctxt->style->bottom_margin * 72)) - e_contact_start_new_column(ctxt); - if (!character) - character = g_strdup(" "); - *character = tolower(*file_as); - if ( ctxt->style->letter_headings ) - e_contact_print_letter_heading(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)) { - e_contact_start_new_column(ctxt); - if ( ctxt->style->letter_headings ) - e_contact_print_letter_heading(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_phone_list(card, ctxt, shown_fields); - first_contact = FALSE; - g_free (file_as); - } - 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); + e_book_async_get_book_view(book, query, (EBookBookViewCallback) book_view_loaded, ctxt); } -#endif static void 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, query, ctxt); + e_contact_do_print_contacts( book, query, ctxt); break; -#if 0 - case E_CONTACT_PRINT_TYPE_PHONE_LIST: - e_contact_do_print_phone_list( book, query, ctxt ); - break; -#endif default: break; } @@ -1027,8 +872,8 @@ e_contact_print_response(GtkWidget *dialog, gint response_id, gpointer data) gboolean uses_list = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(dialog), "uses_list")); EBook *book = NULL; char *query = NULL; - ECard *card = NULL; - GList *card_list = NULL; + EContact *contact = NULL; + GList *contact_list = NULL; gdouble font_size; @@ -1037,10 +882,10 @@ e_contact_print_response(GtkWidget *dialog, gint response_id, gpointer data) query = g_object_get_data(G_OBJECT(dialog), "query"); } else if (uses_list) { - card_list = g_object_get_data(G_OBJECT(dialog), "card_list"); + contact_list = g_object_get_data(G_OBJECT(dialog), "contact_list"); } else { - card = g_object_get_data(G_OBJECT(dialog), "card"); + contact = g_object_get_data(G_OBJECT(dialog), "contact"); } switch( response_id ) { case GNOME_PRINT_DIALOG_RESPONSE_PRINT: @@ -1075,16 +920,16 @@ e_contact_print_response(GtkWidget *dialog, gint response_id, gpointer data) ctxt->book = book; ctxt->query = query; if (uses_book) { - ctxt->cards = NULL; + ctxt->contacts = NULL; e_contact_do_print(book, ctxt->query, ctxt); } else if (uses_list) { - ctxt->cards = card_list; - complete_sequence(NULL, E_BOOK_VIEW_STATUS_SUCCESS, ctxt); + ctxt->contacts = contact_list; + complete_sequence(NULL, E_BOOK_VIEW_STATUS_OK, ctxt); } else { - ctxt->cards = g_list_append(NULL, card); - complete_sequence(NULL, E_BOOK_VIEW_STATUS_SUCCESS, ctxt); + ctxt->contacts = g_list_append(NULL, contact); + complete_sequence(NULL, E_BOOK_VIEW_STATUS_OK, ctxt); } gtk_widget_destroy (dialog); break; @@ -1119,28 +964,28 @@ e_contact_print_response(GtkWidget *dialog, gint response_id, gpointer data) ctxt->book = book; ctxt->query = g_strdup(query); if (uses_book) { - ctxt->cards = NULL; + ctxt->contacts = NULL; g_object_ref(book); e_contact_do_print(book, ctxt->query, ctxt); } else if (uses_list) { - ctxt->cards = g_list_copy (card_list); - g_list_foreach (ctxt->cards, (GFunc)g_object_ref, NULL); - complete_sequence(NULL, E_BOOK_VIEW_STATUS_SUCCESS, ctxt); + ctxt->contacts = g_list_copy (contact_list); + g_list_foreach (ctxt->contacts, (GFunc)g_object_ref, NULL); + complete_sequence(NULL, E_BOOK_VIEW_STATUS_OK, ctxt); } else { - ctxt->cards = g_list_append(NULL, card); - g_object_ref(card); - complete_sequence(NULL, E_BOOK_VIEW_STATUS_SUCCESS, ctxt); + ctxt->contacts = g_list_append(NULL, contact); + g_object_ref(contact); + complete_sequence(NULL, E_BOOK_VIEW_STATUS_OK, ctxt); } break; case GNOME_PRINT_DIALOG_RESPONSE_CANCEL: if (uses_book) g_object_unref(book); else if (uses_list) - e_free_object_list (card_list); + e_free_object_list (contact_list); else - g_object_unref(card); + g_object_unref(contact); g_free(query); gtk_widget_destroy (dialog); g_free(style); @@ -1155,7 +1000,7 @@ e_contact_print_dialog_new(EBook *book, char *query) GtkWidget *dialog; - dialog = gnome_print_dialog_new(NULL, _("Print cards"), GNOME_PRINT_DIALOG_RANGE | GNOME_PRINT_DIALOG_COPIES); + dialog = gnome_print_dialog_new(NULL, _("Print contacts"), GNOME_PRINT_DIALOG_RANGE | GNOME_PRINT_DIALOG_COPIES); gnome_print_dialog_construct_range_any(GNOME_PRINT_DIALOG(dialog), GNOME_PRINT_RANGE_ALL | GNOME_PRINT_RANGE_SELECTION, NULL, NULL, NULL); @@ -1211,20 +1056,20 @@ e_contact_print_preview(EBook *book, char *query) #endif ctxt->book = book; ctxt->query = g_strdup(query); - ctxt->cards = NULL; + ctxt->contacts = NULL; g_object_ref(book); e_contact_do_print(book, ctxt->query, ctxt); } GtkWidget * -e_contact_print_card_dialog_new(ECard *card) +e_contact_print_contact_dialog_new(EContact *contact) { GtkWidget *dialog; - dialog = gnome_print_dialog_new(NULL, _("Print card"), GNOME_PRINT_DIALOG_COPIES); + dialog = gnome_print_dialog_new(NULL, _("Print contact"), GNOME_PRINT_DIALOG_COPIES); - card = e_card_duplicate(card); - g_object_set_data(G_OBJECT(dialog), "card", card); + contact = e_contact_duplicate(contact); + g_object_set_data(G_OBJECT(dialog), "contact", contact); g_object_set_data(G_OBJECT(dialog), "uses_list", GINT_TO_POINTER (FALSE)); g_object_set_data(G_OBJECT(dialog), "uses_book", GINT_TO_POINTER (FALSE)); g_signal_connect(dialog, @@ -1235,22 +1080,22 @@ e_contact_print_card_dialog_new(ECard *card) } GtkWidget * -e_contact_print_card_list_dialog_new(GList *list) +e_contact_print_contact_list_dialog_new(GList *list) { GtkWidget *dialog; - ECard *card; GList *copied_list; + GList *l; if (list == NULL) return NULL; copied_list = g_list_copy (list); - g_list_foreach (copied_list, (GFunc)g_object_ref, NULL); + for (l = copied_list; l; l = l->next) + l->data = e_contact_duplicate (E_CONTACT (l->data)); - dialog = gnome_print_dialog_new(NULL, _("Print card"), GNOME_PRINT_DIALOG_COPIES); + dialog = gnome_print_dialog_new(NULL, _("Print contact"), GNOME_PRINT_DIALOG_COPIES); - card = e_card_duplicate(list->data); - g_object_set_data(G_OBJECT(dialog), "card_list", copied_list); + g_object_set_data(G_OBJECT(dialog), "contact_list", copied_list); g_object_set_data(G_OBJECT(dialog), "uses_list", GINT_TO_POINTER (TRUE)); g_object_set_data(G_OBJECT(dialog), "uses_book", GINT_TO_POINTER (FALSE)); g_signal_connect(dialog, diff --git a/addressbook/printing/e-contact-print.h b/addressbook/printing/e-contact-print.h index 12f13f4573..8c2fbb6acb 100644 --- a/addressbook/printing/e-contact-print.h +++ b/addressbook/printing/e-contact-print.h @@ -25,12 +25,12 @@ #include <glib.h> #include <gtk/gtkwidget.h> #include <addressbook/backend/ebook/e-book.h> -#include <addressbook/backend/ebook/e-card.h> +#include <addressbook/backend/ebook/e-contact.h> #include "e-contact-print-types.h" GtkWidget *e_contact_print_dialog_new(EBook *book, char *query); void e_contact_print_preview(EBook *book, char *query); -GtkWidget *e_contact_print_card_dialog_new(ECard *card); -GtkWidget *e_contact_print_card_list_dialog_new(GList *list); +GtkWidget *e_contact_print_contact_dialog_new(EContact *card); +GtkWidget *e_contact_print_contact_list_dialog_new(GList *list); #endif /* E_CONTACT_PRINT_H */ |