From 9d775d14ebcd879002ad80ed43fc88d66c01ab01 Mon Sep 17 00:00:00 2001 From: Christopher James Lahey Date: Sat, 10 Jun 2000 21:17:12 +0000 Subject: Do e_card_simple_sync and extract_info more often. 2000-06-10 Christopher James Lahey * contact-editor/e-contact-editor.c: Do e_card_simple_sync and extract_info more often. * gui/component/addressbook.c: Added table printing code. svn path=/trunk/; revision=3512 --- addressbook/gui/component/addressbook.c | 107 ++++++++++++++++++++++++++++++-- 1 file changed, 102 insertions(+), 5 deletions(-) (limited to 'addressbook/gui/component') diff --git a/addressbook/gui/component/addressbook.c b/addressbook/gui/component/addressbook.c index 3026aa4811..805a11f574 100644 --- a/addressbook/gui/component/addressbook.c +++ b/addressbook/gui/component/addressbook.c @@ -29,6 +29,10 @@ #include "e-contact-editor.h" #include "e-contact-save-as.h" #include "e-ldap-server-dialog.h" +#include +#include +#include +#include #include @@ -85,7 +89,7 @@ control_deactivate (BonoboControl *control, BonoboUIHandler *uih) static void do_nothing_cb (BonoboUIHandler *uih, void *user_data, const char *path) { - printf ("Yow! I am called back!\n"); + g_print ("Yow! I am called back!\n"); } static void @@ -300,14 +304,107 @@ 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 +e_contact_print_destroy(GnomeDialog *dialog, gpointer data) +{ + ETable *table = gtk_object_get_data(GTK_OBJECT(dialog), "table"); + EPrintable *printable = gtk_object_get_data(GTK_OBJECT(dialog), "printable"); + gtk_object_unref(GTK_OBJECT(printable)); + gtk_object_unref(GTK_OBJECT(table)); +} + +static void +e_contact_print_button(GnomeDialog *dialog, gint button, gpointer data) +{ + GnomePrintMaster *master; + GnomePrintContext *pc; + EPrintable *printable = gtk_object_get_data(GTK_OBJECT(dialog), "printable"); + GtkWidget *preview; + 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_printable_reset(printable); + while (e_printable_data_left(printable)) { + if (gnome_print_gsave(pc) == -1) + /* FIXME */; + if (gnome_print_translate(pc, .5 * 72, .5 * 72) == -1) + /* FIXME */; + e_printable_print_page(printable, + pc, + 7.5 * 72, + 10.5 * 72, + TRUE); + if (gnome_print_grestore(pc) == -1) + /* FIXME */; + if (gnome_print_showpage(pc) == -1) + /* FIXME */; + } + gnome_print_master_close(master); + gnome_print_master_print(master); + gtk_object_unref(GTK_OBJECT(master)); + 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_printable_reset(printable); + while (e_printable_data_left(printable)) { + if (gnome_print_gsave(pc) == -1) + /* FIXME */; + if (gnome_print_translate(pc, .5 * 72, .5 * 72) == -1) + /* FIXME */; + e_printable_print_page(printable, + pc, + 7.5 * 72, + 10.5 * 72, + TRUE); + if (gnome_print_grestore(pc) == -1) + /* FIXME */; + if (gnome_print_showpage(pc) == -1) + /* FIXME */; + } + gnome_print_master_close(master); + preview = GTK_WIDGET(gnome_print_master_preview_new(master, "Print Preview")); + gtk_widget_show_all(preview); + gtk_object_unref(GTK_OBJECT(master)); + break; + case GNOME_PRINT_CANCEL: + gnome_dialog_close(dialog); + break; + } +} + 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); + if (view->view) { + char *query = get_query(view); + GtkWidget *print = e_contact_print_dialog_new(view->book, query); + g_free(query); + gtk_widget_show_all(print); + } else { + GtkWidget *dialog; + EPrintable *printable; + + dialog = gnome_print_dialog_new("Print cards", 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); + + printable = e_table_get_printable(E_TABLE(view->table)); + + gtk_object_ref(GTK_OBJECT(view->table)); + + gtk_object_set_data(GTK_OBJECT(dialog), "table", view->table); + gtk_object_set_data(GTK_OBJECT(dialog), "printable", printable); + + gtk_signal_connect(GTK_OBJECT(dialog), + "clicked", GTK_SIGNAL_FUNC(e_contact_print_button), NULL); + gtk_signal_connect(GTK_OBJECT(dialog), + "destroy", GTK_SIGNAL_FUNC(e_contact_print_destroy), NULL); + gtk_widget_show(dialog); + } } static GnomeUIInfo gnome_toolbar [] = { -- cgit v1.2.3