aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/print.c
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@helixcode.com>2000-06-03 10:28:34 +0800
committerFederico Mena Quintero <federico@src.gnome.org>2000-06-03 10:28:34 +0800
commit6ec291cbc6660e1732543bcfc20885c7020cb8ed (patch)
treeae96a9e80e9f2f1e24ca0adaa55be3fc95c45c3f /calendar/gui/print.c
parent31642359471574aad4a8427a18692d2558c91c5c (diff)
downloadgsoc2013-evolution-6ec291cbc6660e1732543bcfc20885c7020cb8ed.tar
gsoc2013-evolution-6ec291cbc6660e1732543bcfc20885c7020cb8ed.tar.gz
gsoc2013-evolution-6ec291cbc6660e1732543bcfc20885c7020cb8ed.tar.bz2
gsoc2013-evolution-6ec291cbc6660e1732543bcfc20885c7020cb8ed.tar.lz
gsoc2013-evolution-6ec291cbc6660e1732543bcfc20885c7020cb8ed.tar.xz
gsoc2013-evolution-6ec291cbc6660e1732543bcfc20885c7020cb8ed.tar.zst
gsoc2013-evolution-6ec291cbc6660e1732543bcfc20885c7020cb8ed.zip
New function to call the print engine. (calendar_toolbar): Added the Print
2000-06-02 Federico Mena Quintero <federico@helixcode.com> * gui/calendar-commands.c (print): New function to call the print engine. (calendar_toolbar): Added the Print button. (calendar_control_activate): Added the File/Print item. * gui/e-day-view.c (e_day_view_get_selected_time_range): Allow start_time and end_time to be NULL. * gui/e-week-view.c (e_week_view_get_selected_time_range): Likewise. * gui/print.c (range_selector_new): Show the range selector widgets. Use the correct radio group for all of them! (print_calendar): Do the dialog box here. We may want to split this function later into smaller chunks. svn path=/trunk/; revision=3409
Diffstat (limited to 'calendar/gui/print.c')
-rw-r--r--calendar/gui/print.c194
1 files changed, 75 insertions, 119 deletions
diff --git a/calendar/gui/print.c b/calendar/gui/print.c
index d3cf5015cf..436221ebc6 100644
--- a/calendar/gui/print.c
+++ b/calendar/gui/print.c
@@ -27,6 +27,7 @@
#include <libgnomeprint/gnome-print.h>
#include <libgnomeprint/gnome-print-copies.h>
#include <libgnomeprint/gnome-print-master.h>
+#include <libgnomeprint/gnome-print-master-preview.h>
#include <libgnomeprint/gnome-print-preview.h>
#include <libgnomeprint/gnome-printer-profile.h>
#include <libgnomeprint/gnome-printer-dialog.h>
@@ -35,11 +36,10 @@
#include "calendar-commands.h"
#include "gnome-cal.h"
#include "layout.h"
+#include "print.h"
-static void show_print_dialogue(void);
-
/* copied from gnome-month-item.c this should be shared?? */
/* Number of days in a month, for normal and leap years */
@@ -1003,7 +1003,7 @@ static GtkWidget *
range_selector_new (GtkWidget *dialog, time_t at, int *view)
{
GtkWidget *box;
- GtkWidge *radio;
+ GtkWidget *radio;
GSList *group;
char text[1024];
struct tm tm;
@@ -1024,7 +1024,7 @@ range_selector_new (GtkWidget *dialog, time_t at, int *view)
/* Week */
week_begin = time_week_begin (at);
- week_end = time_add_day (time_time_week_end (at), -1);
+ week_end = time_add_day (time_week_end (at), -1);
week_begin_tm = *localtime (&week_begin);
week_end_tm = *localtime (&week_end);
@@ -1071,103 +1071,105 @@ range_selector_new (GtkWidget *dialog, time_t at, int *view)
}
radio = gtk_radio_button_new_with_label (group, text);
+ group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio));
gtk_box_pack_start (GTK_BOX (box), radio, FALSE, FALSE, 0);
/* Month */
strftime (text, sizeof (text), _("Current month (%a %Y)"), &tm);
radio = gtk_radio_button_new_with_label (group, text);
+ group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio));
gtk_box_pack_start (GTK_BOX (box), radio, FALSE, FALSE, 0);
/* Year */
strftime (text, sizeof (text), _("Current year (%Y)"), &tm);
radio = gtk_radio_button_new_with_label (group, text);
+ group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio));
gtk_box_pack_start (GTK_BOX (box), radio, FALSE, FALSE, 0);
/* Select default */
- e_dialog_widget_hook_value (dialog, radio, view, print_view_map);
+ e_dialog_widget_hook_value (dialog, radio, view, (gpointer) print_view_map);
+
+ gtk_widget_show_all (box);
+ return box;
}
-/* Shows the print dialog. The new values are returned in the at and view
- * variables.
- */
-static enum GnomePrintButtons
-print_dialog (GnomeCalendar *gcal, time_t *at, PrintView *view, GnomePrinter **printer)
+void
+print_calendar (GnomeCalendar *gcal, gboolean preview, time_t at, PrintView default_view)
{
- GnomePrintDialog *pd;
- GtkWidget *range;
- int int_view;
- enum GnomePrintButtons retval;
+ GnomePrinter *printer;
+ GnomePrintMaster *gpm;
+ GnomePrintContext *pc;
+ int copies, collate;
+ const GnomePaper *paper_info;
+ double l, r, t, b, todo, header;
+ char buf[100];
+ time_t when;
- pd = gnome_print_dialog_new (_("Print Calendar"),
- GNOME_PRINT_DIALOG_RANGE | GNOME_PRINT_DIALOG_COPIES);
+ g_return_if_fail (gcal != NULL);
+ g_return_if_fail (GNOME_IS_CALENDAR (gcal));
- int_view = *view;
+ printer = NULL;
+ copies = 1;
+ collate = FALSE;
- range = range_selector_new (GTK_WIDGET (pd), *at, &int_view);
- gnome_print_dialog_construct_range_custom (pd, range);
+ if (!preview) {
+ GtkWidget *gpd;
+ GtkWidget *range;
+ int view;
- gnome_dialog_set_default (GNOME_DIALOG (pd), GNOME_PRINT_PRINT);
+ gpd = gnome_print_dialog_new (_("Print Calendar"),
+ GNOME_PRINT_DIALOG_RANGE | GNOME_PRINT_DIALOG_COPIES);
- /* Run! */
+ view = (int) default_view;
+ range = range_selector_new (gpd, at, &view);
+ gnome_print_dialog_construct_range_custom (GNOME_PRINT_DIALOG (gpd), range);
- retval = gnome_dialog_run (GNOME_DIALOG (pd));
+ gnome_dialog_set_default (GNOME_DIALOG (gpd), GNOME_PRINT_PRINT);
- switch (retval) {
- case GNOME_PRINT_PRINT:
- case GNOME_PRINT_PREVIEW:
- e_dialog_get_values (GTK_WIDGET (pd));
- *view = int_view;
+ /* Run dialog */
- *printer = gnome_print_dialog_get_printer (pd);
- break;
+ switch (gnome_dialog_run (GNOME_DIALOG (gpd))) {
+ case GNOME_PRINT_PRINT:
+ break;
- default:
- retval = GNOME_PRINT_CANCEL;
- break;
- }
+ case GNOME_PRINT_PREVIEW:
+ preview = TRUE;
+ break;
- gnome_dialog_close (GNOME_DIALOG (pd));
- return retval;
-}
+ case -1:
+ return;
-void
-print_calendar (GnomeCalendar *gcal, time_t at, PrintView default_view)
-{
- GnomePrinter *printer;
- GnomePrintMaster *gpm;
- GnomePrintContext *pc;
+ default:
+ gnome_dialog_close (GNOME_DIALOG (gpd));
+ return;
+ }
- switch (print_dialog (gcal, &at, &default_view, &printer)) {
- case GNOME_PRINT_PRINT:
- break;
+ e_dialog_get_values (gpd);
+ default_view = (PrintView) view;
- case GNOME_PRINT_PREVIEW:
- /* FIXME */
- break;
+ gnome_print_dialog_get_copies (GNOME_PRINT_DIALOG (gpd), &copies, &collate);
+ printer = gnome_print_dialog_get_printer (GNOME_PRINT_DIALOG (gpd));
- default:
- return;
+ gnome_dialog_close (GNOME_DIALOG (gpd));
}
- g_assert (printer != NULL);
+ /* FIXME: allow configuration of paper size */
gpm = gnome_print_master_new ();
- gnome_print_master_set_printer (gpm, printer);
-
- const GnomePaper *paper_info;
- double l, r, t, b, todo, header;
- char buf[100];
- time_t when;
- char *paper = "A4";
- GnomePrintMaster *gpm = gnome_print_master_new ();
- pc = gnome_print_master_get_context (gpm);
- paper_info = gnome_paper_with_name (paper);
+ paper_info = gnome_paper_with_name (gnome_paper_name_default ());
gnome_print_master_set_paper (gpm, paper_info);
+ if (printer)
+ gnome_print_master_set_printer (gpm, printer);
+
+ gnome_print_master_set_copies (gpm, copies, collate);
+
+ pc = gnome_print_master_get_context (gpm);
+
l = gnome_paper_lmargin (paper_info);
r = gnome_paper_pswidth (paper_info) - gnome_paper_rmargin (paper_info);
t = gnome_paper_psheight (paper_info) - gnome_paper_tmargin (paper_info);
@@ -1175,7 +1177,7 @@ print_calendar (GnomeCalendar *gcal, time_t at, PrintView default_view)
/* depending on the view, do a different output */
switch (default_view) {
- case VIEW_DAY: {
+ case PRINT_VIEW_DAY: {
int i, days = 1;
for (i = 0; i < days; i++) {
@@ -1201,7 +1203,8 @@ print_calendar (GnomeCalendar *gcal, time_t at, PrintView default_view)
}
break;
}
- case VIEW_WEEK:
+
+ case PRINT_VIEW_WEEK:
header = t - 70;
print_week_summary (pc, gcal, at, l, r, header, b);
@@ -1230,7 +1233,7 @@ print_calendar (GnomeCalendar *gcal, time_t at, PrintView default_view)
gnome_print_showpage (pc);
break;
- case VIEW_MONTH:
+ case PRINT_VIEW_MONTH:
header = t - 70;
gnome_print_rotate (pc, 90);
gnome_print_translate (pc, 0, -gnome_paper_pswidth (paper_info));
@@ -1252,7 +1255,7 @@ print_calendar (GnomeCalendar *gcal, time_t at, PrintView default_view)
gnome_print_showpage (pc);
break;
- case VIEW_YEAR:
+ case PRINT_VIEW_YEAR:
#if 0
/* landscape */
gnome_print_rotate(pc, 90);
@@ -1278,61 +1281,14 @@ print_calendar (GnomeCalendar *gcal, time_t at, PrintView default_view)
}
gnome_print_master_close (gpm);
- gnome_print_master_print (gpm);
-}
-
-#if 0
-/*
- Load the printing dialogue box
-*/
-static void
-show_print_dialogue(void)
-{
- GtkWidget *print_dialogue;
- GtkWidget *printer_widget;
- GtkWidget *paper_widget;
- GtkWidget *print_copies;
- GtkWidget *table;
-
- print_dialogue =
- gnome_dialog_new(_("Print Calendar"),
- GNOME_STOCK_BUTTON_OK,
- _("Preview"),
- GNOME_STOCK_BUTTON_CANCEL,
- NULL);
-
- table = gtk_table_new(2, 2, FALSE);
- gtk_container_add(GTK_CONTAINER(GNOME_DIALOG (print_dialogue)->vbox), GTK_WIDGET (table));
- gtk_widget_show(table);
-
- printer_widget = gnome_printer_widget_new ();
- gtk_table_attach((GtkTable *)table, printer_widget, 1, 2, 0, 2, 0, 0, 4, 4);
- gtk_widget_show(printer_widget);
-
-#if 0
- frame = gtk_frame_new("Select Paper");
- paper_widget = gnome_paper_selector_new ();
- gtk_table_attach(table, frame, 0, 1, 0, 1, 0, 0, 4, 4);
- gtk_container_add(frame, GTK_WIDGET (paper_widget));
- gtk_widget_show(paper_widget);
- gtk_widget_show(frame);
-#else
- paper_widget = gnome_paper_selector_new ();
- gtk_table_attach((GtkTable *)table, paper_widget, 0, 1, 0, 1, GTK_SHRINK, GTK_SHRINK, 4, 4);
- gtk_widget_show(paper_widget);
-#endif
- print_copies = gnome_print_copies_new ();
- gtk_table_attach((GtkTable *)table, print_copies, 0, 1, 1, 2, 0, 0, 4, 4);
- gtk_widget_show(print_copies);
+ if (preview) {
+ GnomePrintMasterPreview *gpmp;
-#if 0
- frame = gtk_frame_new("Print Range");
- gtk_table_attach_defaults(table, frame, 0, 1, 1, 2);
- gtk_widget_show(frame);
-#endif
+ gpmp = gnome_print_master_preview_new (gpm, _("Print Preview"));
+ gtk_widget_show (GTK_WIDGET (gpmp));
+ } else
+ gnome_print_master_print (gpm);
- gnome_dialog_run_and_close (GNOME_DIALOG (print_dialogue));
+ gtk_object_unref (GTK_OBJECT (gpm));
}
-
-#endif