diff options
Diffstat (limited to 'addressbook')
-rw-r--r-- | addressbook/ChangeLog | 14 | ||||
-rw-r--r-- | addressbook/gui/component/addressbook-view.c | 4 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-addressbook-view.c | 24 | ||||
-rw-r--r-- | addressbook/printing/e-contact-print.c | 82 |
4 files changed, 84 insertions, 40 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog index 6fbd1dffc0..481a42f626 100644 --- a/addressbook/ChangeLog +++ b/addressbook/ChangeLog @@ -1,3 +1,17 @@ +2007-02-12 Srinivasa Ragavan <sragavan@novell.com> + + ** Print migration updates from Ebby Wiselyn. + + * gui/component/addressbook-view.c: (print_cb), (print_preview_cb): + * gui/widgets/e-addressbook-view.c: (print), + (e_contact_print_button), (eab_view_print), + (eab_view_print_preview): + * printing/e-contact-print.c: (e_contact_print_contact), + (complete_sequence), (book_view_loaded), (print_func), + (e_contact_print_response), (e_contact_print_dialog_new), + (e_contact_print_contact_dialog_new), + (e_contact_print_contact_list_dialog_new), (contact_draw_page): + 2007-02-08 Srinivasa Ragavan <sragavan@novell.com> ** Fix for bug #332908 diff --git a/addressbook/gui/component/addressbook-view.c b/addressbook/gui/component/addressbook-view.c index 21b7cbd2f7..79bf25183e 100644 --- a/addressbook/gui/component/addressbook-view.c +++ b/addressbook/gui/component/addressbook-view.c @@ -193,7 +193,7 @@ print_cb (BonoboUIComponent *uih, void *user_data, const char *path) AddressbookView *view = (AddressbookView *) user_data; EABView *v = get_current_view (view); if (v) - eab_view_print(v, 1); + eab_view_print (v, 0); } static void @@ -202,7 +202,7 @@ print_preview_cb (BonoboUIComponent *uih, void *user_data, const char *path) AddressbookView *view = (AddressbookView *) user_data; EABView *v = get_current_view (view); if (v) - eab_view_print_preview(v); + eab_view_print_preview (v); } static void diff --git a/addressbook/gui/widgets/e-addressbook-view.c b/addressbook/gui/widgets/e-addressbook-view.c index d52602ec62..471f5c3157 100644 --- a/addressbook/gui/widgets/e-addressbook-view.c +++ b/addressbook/gui/widgets/e-addressbook-view.c @@ -881,8 +881,8 @@ print (EPopup *ep, EPopupItem *pitem, void *data) e_contact_print_response (dialog, GTK_RESPONSE_OK, NULL); } else { GList *contacts = get_contact_list(t); - - gtk_widget_show(e_contact_print_contact_list_dialog_new(contacts)); + dialog = e_contact_print_contact_list_dialog_new (contacts); + e_contact_print_response (dialog, GTK_RESPONSE_OK, NULL); g_list_free(contacts); } } @@ -1748,9 +1748,6 @@ e_contact_print_button(GtkDialog *dialog, gint response, gpointer data) gtk_widget_destroy(dialog); g_object_unref (print); - g_object_unref (settings); - g_object_unref (page_setup); - g_object_unref (paper_size); } static void @@ -1867,7 +1864,7 @@ eab_view_print(EABView *view, int preview) EContactPrintDialogWeakData *weak_data; /* FIXME: Allow range selection in table views, as in minicard view */ - dialog = e_print_get_dialog (_("Print cards"), GNOME_PRINT_DIALOG_COPIES); + dialog = e_print_get_dialog (_("Print cards"), 0); g_object_get(view->widget, "table", &etable, NULL); printable = e_table_get_printable(etable); @@ -1901,14 +1898,21 @@ eab_view_print_preview(EABView *view) if (view->view_type == EAB_VIEW_MINICARD) { char *query; EBook *book; - GtkWidget *print; + GtkWidget *dialog; g_object_get (view->model, "query", &query, "book", &book, NULL); - GList *list = get_selected_contacts (view); + + GList *list = get_selected_contacts (view); + if (list != NULL) + dialog = e_contact_print_contact_list_dialog_new (list); + else + dialog = e_contact_print_dialog_new (book, query, list); + e_contact_print_response (dialog, GTK_RESPONSE_APPLY, NULL); e_free_object_list (list); + g_free (query); }else if (view->view_type == EAB_VIEW_TABLE) { GtkWidget *dialog; EPrintable *printable; @@ -1916,7 +1920,7 @@ eab_view_print_preview(EABView *view) EContactPrintDialogWeakData *weak_data; /* FIXME: Allow range selection in table views, as in minicard view */ - dialog = e_print_get_dialog (_("Print cards"), GNOME_PRINT_DIALOG_COPIES); + dialog = e_print_get_dialog (_("Print cards"), 0); g_object_get(view->widget, "table", &etable, NULL); printable = e_table_get_printable(etable); @@ -1932,7 +1936,7 @@ eab_view_print_preview(EABView *view) weak_data->table = view->widget; weak_data->printable = G_OBJECT (printable); g_object_weak_ref (G_OBJECT (dialog), e_contact_print_destroy, weak_data); - e_contact_print_button (dialog, GTK_RESPONSE_OK, NULL); + e_contact_print_button (dialog, GTK_RESPONSE_APPLY, NULL); } } diff --git a/addressbook/printing/e-contact-print.c b/addressbook/printing/e-contact-print.c index 16c219fe1e..51d2171f9f 100644 --- a/addressbook/printing/e-contact-print.c +++ b/addressbook/printing/e-contact-print.c @@ -64,6 +64,7 @@ typedef struct _ContactPrintItem ContactPrintItem; struct _EContactPrintContext { GtkPrintContext *pc; + GtkPrintOperation *print; GnomePrintJob *master; PangoLayout *pl; gdouble x; @@ -78,6 +79,7 @@ struct _EContactPrintContext gboolean uses_book; int type; + gint response_id; EBook *book; EBookQuery *query; @@ -98,6 +100,9 @@ struct _ContactPrintItem static void contact_draw_page (GtkPrintOperation *print, GtkPrintContext *context, gint page_nr, ContactPrintItem *cpi); +static void +print_func (EBookView *book_view, const GList *contacts, EContactPrintContext *ctxt); + static double get_font_height (PangoFontDescription *font) { @@ -360,7 +365,7 @@ e_contact_print_contact (EContact *contact, EContactPrintContext *ctxt) e_contact_pretty_name (field)); xoff += get_font_width(ctxt, ctxt->style->body_font, e_contact_pretty_name (field)); - e_contact_output(ctxt, ctxt->style->body_font, ctxt->x + xoff, ctxt->y, -1, ": "); + e_contact_output(ctxt, ctxt->style->body_font, ctxt->x + xoff, ctxt->y + 5, -1, ": "); xoff += get_font_width(ctxt, ctxt->style->body_font, ": "); e_contact_output(ctxt, @@ -448,13 +453,13 @@ complete_sequence (EBookView *book_view, EBookViewStatus status, EContactPrintCo g_object_unref(ctxt->pc); g_object_unref(ctxt->pl); - if (ctxt->book) + if (ctxt->book) g_object_unref(ctxt->book); - + g_free(ctxt->character); if (ctxt->query) e_book_query_unref (ctxt->query); - g_list_foreach(ctxt->contacts, (GFunc) g_object_unref, NULL); + g_list_foreach(ctxt->contacts, (GFunc) g_object_unref, NULL); g_list_free(ctxt->contacts); pango_font_description_free(ctxt->style->headings_font); pango_font_description_free(ctxt->style->body_font); @@ -462,7 +467,6 @@ complete_sequence (EBookView *book_view, EBookViewStatus status, EContactPrintCo pango_font_description_free(ctxt->style->footer_font); pango_font_description_free(ctxt->letter_heading_font); g_free(ctxt->style); - g_free(ctxt); } static int @@ -504,10 +508,27 @@ book_view_loaded (EBook *book, EBookStatus status, EBookView *book_view, EContac "contacts_added", G_CALLBACK(create_contact), ctxt); - + g_signal_connect(book_view, + "sequence_complete", + G_CALLBACK(print_func), + ctxt); e_book_view_start (book_view); } +static void +print_func (EBookView *book_view, const GList *contacts, EContactPrintContext *ctxt) +{ + GtkPrintSettings *settings; + settings = gtk_print_settings_new (); + /* runs a print dialog, emittings signals */ + if(ctxt->response_id == GTK_RESPONSE_APPLY) + gtk_print_operation_run (ctxt->print, GTK_PRINT_OPERATION_ACTION_PREVIEW, NULL, NULL); + else + gtk_print_operation_run (ctxt->print, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, NULL, NULL); + settings = gtk_print_operation_get_print_settings (ctxt->print); + e_print_save_settings (settings); +} + static void e_contact_do_print_contacts (EBook *book, EBookQuery *query, EContactPrintContext *ctxt) { @@ -725,7 +746,6 @@ void e_contact_print_response(GtkWidget *dialog, gint response_id, gpointer data) { GtkPrintSettings *settings; - GtkPrintOperation *print; GtkPrintOperationResult res; GtkPaperSize *paper_size; GtkPageSetup *page_setup; @@ -770,10 +790,10 @@ e_contact_print_response(GtkWidget *dialog, gint response_id, gpointer data) page_setup = gtk_page_setup_new (); paper_size = gtk_paper_size_new ("iso_a4"); /* FIXME paper size hardcoded */ gtk_page_setup_set_paper_size (page_setup, paper_size); - print = gtk_print_operation_new (); - gtk_print_operation_set_default_page_setup (print, page_setup); - gtk_print_operation_set_n_pages (print, 1); - gtk_print_settings_set_print_pages (settings, GTK_PRINT_PAGES_ALL); + ctxt->print = gtk_print_operation_new (); + gtk_print_operation_set_default_page_setup (ctxt->print, page_setup); + gtk_print_operation_set_n_pages (ctxt->print, 1); + gtk_print_settings_set_print_pages (settings, GTK_PRINT_PAGES_ALL); /* style information */ e_contact_build_style(style, settings); @@ -790,6 +810,7 @@ e_contact_print_response(GtkWidget *dialog, gint response_id, gpointer data) get_font_height (ctxt->style->headings_font)*1.5); ctxt->book = book; ctxt->query = query; + ctxt->response_id = response_id; cpi->uses_book = uses_book; cpi->uses_list = uses_list; cpi->settings = settings; @@ -798,20 +819,25 @@ e_contact_print_response(GtkWidget *dialog, gint response_id, gpointer data) cpi->ctxt->contacts = NULL; cpi->contact_list= contact_list; cpi->book = book; - e_contact_do_print_contacts (book, query, ctxt); - - /* runs the print dialog , emitting signals */ - g_signal_connect (print, "draw_page",G_CALLBACK (contact_draw_page), cpi); - if (response_id == GTK_RESPONSE_APPLY) { - res = gtk_print_operation_run (print, GTK_PRINT_OPERATION_ACTION_PREVIEW, NULL, NULL); + gtk_print_operation_set_print_settings (ctxt->print, settings); + g_signal_connect (ctxt->print, "draw_page",G_CALLBACK (contact_draw_page), cpi); + + if (!uses_book) { + if(ctxt->response_id == GTK_RESPONSE_APPLY) + gtk_print_operation_run (ctxt->print, GTK_PRINT_OPERATION_ACTION_PREVIEW, NULL, NULL); + else + gtk_print_operation_run (ctxt->print, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, NULL, NULL); + settings = gtk_print_operation_get_print_settings (ctxt->print); + e_print_save_settings (settings); } else - res = gtk_print_operation_run (print, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, NULL, NULL); - g_object_unref (settings); - g_object_unref (print); - g_object_unref (paper_size); - g_object_unref (page_setup); - g_object_unref (cpi); + e_contact_do_print_contacts (book, query, ctxt); + + g_object_unref (cpi); + if (!uses_book) { + g_object_unref (ctxt->print); + g_free (ctxt); + } gtk_widget_destroy (dialog); } @@ -823,7 +849,7 @@ e_contact_print_dialog_new(EBook *book, char *query, GList *list) GList *copied_list = NULL; GList *l; - dialog = e_print_get_dialog(_("Print contacts"), GNOME_PRINT_DIALOG_RANGE | GNOME_PRINT_DIALOG_COPIES); + dialog = e_print_get_dialog(_("Print contacts"), 0); if (list != NULL) { copied_list = g_list_copy (list); @@ -849,7 +875,7 @@ e_contact_print_contact_dialog_new(EContact *contact) { GtkWidget *dialog; - dialog = e_print_get_dialog(_("Print contact"), GNOME_PRINT_DIALOG_COPIES); + dialog = e_print_get_dialog(_("Print contact"), 0); 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)); @@ -870,13 +896,13 @@ e_contact_print_contact_list_dialog_new(GList *list) GList *l; if (list == NULL) - return NULL; + return NULL; copied_list = g_list_copy (list); for (l = copied_list; l; l = l->next) l->data = e_contact_duplicate (E_CONTACT (l->data)); - dialog = e_print_get_dialog(_("Print contact"), GNOME_PRINT_DIALOG_COPIES); + dialog = e_print_get_dialog(_("Print contact"), 0); g_object_set_data(G_OBJECT(dialog), "contact_list", copied_list); g_object_set_data(G_OBJECT(dialog), "uses_list", GINT_TO_POINTER (TRUE)); @@ -892,7 +918,6 @@ e_contact_print_contact_list_dialog_new(GList *list) static void contact_draw_page (GtkPrintOperation *print, GtkPrintContext *context, gint page_nr, ContactPrintItem *cpi) { - cairo_t *cr; EBookView *view; EBookViewStatus status; @@ -905,6 +930,7 @@ contact_draw_page (GtkPrintOperation *print, GtkPrintContext *context, gint page } else if (cpi->uses_list) { + cpi->ctxt->contacts = cpi->contact_list; complete_sequence(NULL, E_BOOK_VIEW_STATUS_OK, cpi->ctxt); } else { |