diff options
Diffstat (limited to 'addressbook/printing/e-contact-print.c')
-rw-r--r-- | addressbook/printing/e-contact-print.c | 205 |
1 files changed, 105 insertions, 100 deletions
diff --git a/addressbook/printing/e-contact-print.c b/addressbook/printing/e-contact-print.c index 55b5480c6f..9ef1d51bc8 100644 --- a/addressbook/printing/e-contact-print.c +++ b/addressbook/printing/e-contact-print.c @@ -26,20 +26,17 @@ #include <sys/types.h> #include <stdlib.h> #include <glib.h> -#include <gnome-xml/tree.h> -#include <gnome-xml/parser.h> -#include <gnome-xml/xmlmemory.h> +#include <libxml/tree.h> +#include <libxml/parser.h> +#include <libxml/xmlmemory.h> #include <libgnome/gnome-util.h> -#include <libgnome/gnome-defs.h> #include <libgnome/gnome-i18n.h> -#include <libgnome/gnome-paper.h> +#include <libgnomeui/gnome-dialog.h> #include <libgnomeprint/gnome-print.h> -#include <libgnomeprint/gnome-print-dialog.h> +#include <libgnomeprint/gnome-font.h> #include <libgnomeprint/gnome-print-master.h> -#include <libgnomeprint/gnome-print-master-preview.h> -#include <libgnomeprint/gnome-print-multipage.h> -#include <gal/widgets/e-unicode.h> -#include <gal/unicode/gunicode.h> +#include <libgnomeprintui/gnome-print-dialog.h> +#include <libgnomeprintui/gnome-print-master-preview.h> #include <addressbook/backend/ebook/e-book.h> #include <addressbook/backend/ebook/e-card.h> #include <addressbook/backend/ebook/e-card-simple.h> @@ -417,9 +414,9 @@ e_contact_get_card_size(ECardSimple *simple, EContactPrintContext *ctxt) height += gnome_font_get_size (ctxt->style->headings_font) * .2; - gtk_object_get(GTK_OBJECT(simple->card), - "file_as", &file_as, - NULL); + g_object_get(simple->card, + "file_as", &file_as, + NULL); height += e_contact_text_height(ctxt->pc, ctxt->style->headings_font, column_width - 4, file_as); height += gnome_font_get_size (ctxt->style->headings_font) * .2; @@ -462,9 +459,9 @@ e_contact_print_card (ECardSimple *simple, EContactPrintContext *ctxt) ctxt->y -= gnome_font_get_size (ctxt->style->headings_font) * .2; - gtk_object_get(GTK_OBJECT(simple->card), - "file_as", &file_as, - NULL); + g_object_get(simple->card, + "file_as", &file_as, + NULL); 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); @@ -483,7 +480,7 @@ e_contact_print_card (ECardSimple *simple, EContactPrintContext *ctxt) gchar *new_string = g_strdup (e_destination_get_address (dest)); g_free (string); string = new_string; - gtk_object_unref (GTK_OBJECT (dest)); + g_object_unref (dest); } } @@ -543,9 +540,9 @@ complete_sequence(EBookView *book_view, EBookViewStatus status, EContactPrintCon guchar *file_as; gchar *letter_str = NULL; - gtk_object_get(GTK_OBJECT(card), - "file_as", &file_as, - NULL); + g_object_get(card, + "file_as", &file_as, + NULL); if (file_as != NULL) { letter_str = g_strndup (file_as, g_utf8_next_char (file_as) - (gchar *) file_as); } @@ -572,7 +569,7 @@ complete_sequence(EBookView *book_view, EBookViewStatus status, EContactPrintCon ctxt->first_char_on_page = ctxt->last_char_on_page; e_contact_print_card(simple, ctxt); ctxt->first_contact = FALSE; - gtk_object_unref(GTK_OBJECT(simple)); + g_object_unref(simple); } ctxt->last_char_on_page = 'Z'; if ( ctxt->style->letter_tabs ) @@ -581,27 +578,27 @@ complete_sequence(EBookView *book_view, EBookViewStatus status, EContactPrintCon gnome_print_context_close(ctxt->pc); g_free(ctxt->character); if (book_view) - gtk_object_unref(GTK_OBJECT(book_view)); - if (ctxt->type == GNOME_PRINT_PREVIEW) { + g_object_unref(book_view); + if (ctxt->type == GNOME_PRINT_DIALOG_RESPONSE_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)); + g_object_unref(ctxt->pc); + g_object_unref(ctxt->master); if (ctxt->book) - gtk_object_unref(GTK_OBJECT(ctxt->book)); + g_object_unref(ctxt->book); g_free(ctxt->query); - g_list_foreach(ctxt->cards, (GFunc) gtk_object_unref, NULL); + g_list_foreach(ctxt->cards, (GFunc) g_object_unref, NULL); g_list_free(ctxt->cards); - 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_object_unref(ctxt->style->headings_font); + g_object_unref(ctxt->style->body_font); + g_object_unref(ctxt->style->header_font); + g_object_unref(ctxt->style->footer_font); + g_object_unref(ctxt->letter_heading_font); + g_object_unref(ctxt->letter_tab_font); g_free(ctxt->style); g_free(ctxt); } @@ -610,12 +607,12 @@ static int card_compare (ECard *card1, ECard *card2) { if (card1 && card2) { char *file_as1, *file_as2; - gtk_object_get(GTK_OBJECT(card1), - "file_as", &file_as1, - NULL); - gtk_object_get(GTK_OBJECT(card2), - "file_as", &file_as2, - NULL); + g_object_get(card1, + "file_as", &file_as1, + NULL); + g_object_get(card2, + "file_as", &file_as2, + NULL); if (file_as1 && file_as2) return g_utf8_collate(file_as1, file_as2); if (file_as1) @@ -633,7 +630,7 @@ create_card(EBookView *book_view, const GList *cards, EContactPrintContext *ctxt { for(; cards; cards = cards->next) { ECard *card = cards->data; - gtk_object_ref(GTK_OBJECT(card)); + g_object_ref(card); ctxt->cards = g_list_insert_sorted(ctxt->cards, card, (GCompareFunc) card_compare); } } @@ -641,17 +638,17 @@ create_card(EBookView *book_view, const GList *cards, EContactPrintContext *ctxt static void book_view_loaded (EBook *book, EBookStatus status, EBookView *book_view, EContactPrintContext *ctxt) { - gtk_object_ref(GTK_OBJECT(book_view)); + g_object_ref(book_view); - gtk_signal_connect(GTK_OBJECT(book_view), - "card_added", - GTK_SIGNAL_FUNC(create_card), - ctxt); + g_signal_connect(book_view, + "card_added", + G_CALLBACK(create_card), + ctxt); - gtk_signal_connect(GTK_OBJECT(book_view), - "sequence_complete", - GTK_SIGNAL_FUNC(complete_sequence), - ctxt); + g_signal_connect(book_view, + "sequence_complete", + G_CALLBACK(complete_sequence), + ctxt); } static void @@ -855,9 +852,9 @@ static double get_float( char *data ) static void get_font( char *data, GnomeFont **variable ) { if ( data ) { - GnomeFont *font = gnome_font_new_from_full_name( data ); + GnomeFont *font = gnome_font_find_from_full_name( data ); if ( font ) { - gtk_object_unref( GTK_OBJECT(*variable) ); + g_object_unref(*variable); *variable = font; } } @@ -869,6 +866,7 @@ 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; @@ -877,8 +875,8 @@ e_contact_build_style(EContactPrintStyle *style) style->letter_tabs = TRUE; style->letter_headings = FALSE; - style->headings_font = gnome_font_new_closest("Helvetica", GNOME_FONT_BOLD, FALSE, 8); - style->body_font = gnome_font_new_closest("Helvetica", GNOME_FONT_BOOK, FALSE, 6); + style->headings_font = gnome_font_find_closest_from_weight_slant ("Helvetica", GNOME_FONT_BOLD, FALSE, 8); + style->body_font = gnome_font_find_closest_from_weight_slant ("Helvetica", GNOME_FONT_BOOK, FALSE, 6); style->print_using_grey = TRUE; style->paper_type = 0; @@ -902,13 +900,13 @@ e_contact_build_style(EContactPrintStyle *style) #endif style->orientation_portrait = FALSE; - style->header_font = gnome_font_new_closest("Helvetica", GNOME_FONT_BOOK, FALSE, 6); + style->header_font = gnome_font_find_closest_from_weight_slant ("Helvetica", GNOME_FONT_BOOK, FALSE, 6); style->left_header = g_strdup(""); style->center_header = g_strdup(""); style->right_header = g_strdup(""); - style->footer_font = gnome_font_new_closest("Helvetica", GNOME_FONT_BOOK, FALSE, 6); + style->footer_font = gnome_font_find_closest_from_weight_slant ("Helvetica", GNOME_FONT_BOOK, FALSE, 6); style->left_footer = g_strdup(""); style->center_footer = g_strdup(""); @@ -920,7 +918,7 @@ e_contact_build_style(EContactPrintStyle *style) if (styledoc) { xmlNodePtr stylenode = xmlDocGetRootElement(styledoc); xmlNodePtr node; - for (node = stylenode->childs; node; node = node->next) { + for (node = stylenode->children; node; node = node->next) { char *data = xmlNodeGetContent ( node ); if ( !strcmp( node->name, "title" ) ) { get_string(data, &(style->title)); @@ -1009,21 +1007,25 @@ e_contact_print_button(GnomeDialog *dialog, gint button, gpointer data) EContactPrintContext *ctxt = g_new(EContactPrintContext, 1); EContactPrintStyle *style = g_new(EContactPrintStyle, 1); GnomePrintMaster *master; + GnomePrintConfig *config; GnomePrintContext *pc; - gboolean uses_book = (gint) gtk_object_get_data(GTK_OBJECT(dialog), "uses_book"); + gboolean uses_book = (gint) g_object_get_data(G_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"); + book = g_object_get_data(G_OBJECT(dialog), "book"); + query = g_object_get_data(G_OBJECT(dialog), "query"); } else { - card = gtk_object_get_data(GTK_OBJECT(dialog), "card"); + card = g_object_get_data(G_OBJECT(dialog), "card"); } switch( button ) { - case GNOME_PRINT_PRINT: - master = gnome_print_master_new_from_dialog( GNOME_PRINT_DIALOG(dialog) ); + case GNOME_PRINT_DIALOG_RESPONSE_PRINT: + config = gnome_print_dialog_get_config (GNOME_PRINT_DIALOG(dialog)); + master = gnome_print_master_new_from_config( config ); pc = gnome_print_master_get_context( master ); e_contact_build_style(style); @@ -1034,11 +1036,11 @@ e_contact_print_button(GnomeDialog *dialog, gint button, gpointer data) ctxt->master = master; ctxt->first_section = TRUE; ctxt->first_char_on_page = 'A' - 1; - ctxt->type = GNOME_PRINT_PRINT; + ctxt->type = GNOME_PRINT_DIALOG_RESPONSE_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), gnome_font_get_size (ctxt->style->headings_font) * 1.5); - ctxt->letter_tab_font = gnome_font_new(gnome_font_get_name(ctxt->style->headings_font), font_size); + ctxt->letter_heading_font = gnome_font_find (gnome_font_get_name(ctxt->style->headings_font), gnome_font_get_size (ctxt->style->headings_font) * 1.5); + ctxt->letter_tab_font = gnome_font_find (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, @@ -1057,8 +1059,9 @@ e_contact_print_button(GnomeDialog *dialog, gint button, gpointer data) } gnome_dialog_close(dialog); break; - case GNOME_PRINT_PREVIEW: - master = gnome_print_master_new_from_dialog( GNOME_PRINT_DIALOG(dialog) ); + case GNOME_PRINT_DIALOG_RESPONSE_PREVIEW: + config = gnome_print_dialog_get_config (GNOME_PRINT_DIALOG(dialog)); + master = gnome_print_master_new_from_config( config ); pc = gnome_print_master_get_context( master ); e_contact_build_style(style); @@ -1069,11 +1072,11 @@ e_contact_print_button(GnomeDialog *dialog, gint button, gpointer data) ctxt->master = master; ctxt->first_section = TRUE; ctxt->first_char_on_page = 'A' - 1; - ctxt->type = GNOME_PRINT_PREVIEW; + ctxt->type = GNOME_PRINT_DIALOG_RESPONSE_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), gnome_font_get_size (ctxt->style->headings_font) * 1.5); - ctxt->letter_tab_font = gnome_font_new(gnome_font_get_name(ctxt->style->headings_font), font_size); + ctxt->letter_heading_font = gnome_font_find (gnome_font_get_name(ctxt->style->headings_font), gnome_font_get_size (ctxt->style->headings_font) * 1.5); + ctxt->letter_tab_font = gnome_font_find (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, @@ -1085,19 +1088,19 @@ e_contact_print_button(GnomeDialog *dialog, gint button, gpointer data) ctxt->query = g_strdup(query); if (uses_book) { ctxt->cards = NULL; - gtk_object_ref(GTK_OBJECT(book)); + g_object_ref(book); e_contact_do_print(book, ctxt->query, ctxt); } else { ctxt->cards = g_list_append(NULL, card); - gtk_object_ref(GTK_OBJECT(card)); + g_object_ref(card); complete_sequence(NULL, E_BOOK_VIEW_STATUS_SUCCESS, ctxt); } break; - case GNOME_PRINT_CANCEL: + case GNOME_PRINT_DIALOG_RESPONSE_CANCEL: if (uses_book) - gtk_object_unref(GTK_OBJECT(book)); + g_object_unref(book); else - gtk_object_unref(GTK_OBJECT(card)); + g_object_unref(card); g_free(query); gnome_dialog_close(dialog); g_free(style); @@ -1116,14 +1119,14 @@ e_contact_print_dialog_new(EBook *book, char *query) 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), "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), - "clicked", GTK_SIGNAL_FUNC(e_contact_print_button), NULL); - gtk_signal_connect(GTK_OBJECT(dialog), - "close", GTK_SIGNAL_FUNC(e_contact_print_close), NULL); + g_object_ref(book); + g_object_set_data(G_OBJECT(dialog), "uses_book", (void *) 1); + g_object_set_data(G_OBJECT(dialog), "book", book); + g_object_set_data(G_OBJECT(dialog), "query", g_strdup(query)); + g_signal_connect(dialog, + "clicked", G_CALLBACK(e_contact_print_button), NULL); + g_signal_connect(dialog, + "close", G_CALLBACK(e_contact_print_close), NULL); return dialog; } @@ -1134,10 +1137,12 @@ e_contact_print_preview(EBook *book, char *query) EContactPrintStyle *style = g_new(EContactPrintStyle, 1); GnomePrintMaster *master; GnomePrintContext *pc; + GnomePrintConfig *config; gdouble font_size; master = gnome_print_master_new(); - gnome_print_master_set_copies (master, 1, FALSE); + config = gnome_print_master_get_config (master); + gnome_print_config_set_int (config, GNOME_PRINT_KEY_NUM_COPIES, 1); pc = gnome_print_master_get_context (master); e_contact_build_style (style); @@ -1148,11 +1153,11 @@ e_contact_print_preview(EBook *book, char *query) ctxt->master = master; ctxt->first_section = TRUE; ctxt->first_char_on_page = 'A' - 1; - ctxt->type = GNOME_PRINT_PREVIEW; + ctxt->type = GNOME_PRINT_DIALOG_RESPONSE_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), gnome_font_get_size (ctxt->style->headings_font) * 1.5); - ctxt->letter_tab_font = gnome_font_new(gnome_font_get_name(ctxt->style->headings_font), font_size); + ctxt->letter_heading_font = gnome_font_find (gnome_font_get_name(ctxt->style->headings_font), gnome_font_get_size (ctxt->style->headings_font) * 1.5); + ctxt->letter_tab_font = gnome_font_find (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, @@ -1163,7 +1168,7 @@ e_contact_print_preview(EBook *book, char *query) ctxt->book = book; ctxt->query = g_strdup(query); ctxt->cards = NULL; - gtk_object_ref(GTK_OBJECT(book)); + g_object_ref(book); e_contact_do_print(book, ctxt->query, ctxt); } @@ -1175,12 +1180,12 @@ e_contact_print_card_dialog_new(ECard *card) 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); + g_object_set_data(G_OBJECT(dialog), "card", card); + g_object_set_data(G_OBJECT(dialog), "uses_book", (void *) 0); + g_signal_connect(dialog, + "clicked", G_CALLBACK(e_contact_print_button), NULL); + g_signal_connect(dialog, + "close", G_CALLBACK(e_contact_print_close), NULL); return dialog; } @@ -1197,11 +1202,11 @@ e_contact_print_card_list_dialog_new(GList *list) dialog = gnome_print_dialog_new(_("Print card"), GNOME_PRINT_DIALOG_COPIES); card = e_card_duplicate(list->data); - 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); + g_object_set_data(G_OBJECT(dialog), "card", card); + g_object_set_data(G_OBJECT(dialog), "uses_book", (void *) 0); + g_signal_connect(dialog, + "clicked", G_CALLBACK(e_contact_print_button), NULL); + g_signal_connect(dialog, + "close", G_CALLBACK(e_contact_print_close), NULL); return dialog; } |