aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/tasks-control.c
diff options
context:
space:
mode:
authorHans Petter Jansson <hpj@ximian.com>2003-02-12 10:41:05 +0800
committerHans Petter <hansp@src.gnome.org>2003-02-12 10:41:05 +0800
commit7b01b20f70bacd7d9fca0d65a3ca88b8cb88934f (patch)
tree842e8df2fa4ed84a894a72bf5862493324392d96 /calendar/gui/tasks-control.c
parent2b010a5021938a9962653dfe541e43e54c4b5c8c (diff)
downloadgsoc2013-evolution-7b01b20f70bacd7d9fca0d65a3ca88b8cb88934f.tar
gsoc2013-evolution-7b01b20f70bacd7d9fca0d65a3ca88b8cb88934f.tar.gz
gsoc2013-evolution-7b01b20f70bacd7d9fca0d65a3ca88b8cb88934f.tar.bz2
gsoc2013-evolution-7b01b20f70bacd7d9fca0d65a3ca88b8cb88934f.tar.lz
gsoc2013-evolution-7b01b20f70bacd7d9fca0d65a3ca88b8cb88934f.tar.xz
gsoc2013-evolution-7b01b20f70bacd7d9fca0d65a3ca88b8cb88934f.tar.zst
gsoc2013-evolution-7b01b20f70bacd7d9fca0d65a3ca88b8cb88934f.zip
Enable printing for calendar and tasks.
2003-02-11 Hans Petter Jansson <hpj@ximian.com> Enable printing for calendar and tasks. * gui/print.c: Set default font to be "Sans". Store the PrintConfig globally instead of PaperInfo (which doesn't exist anymore). (get_font_for_size): Don't use gnome_font_face_find_closest_from_weight_slant() anymore, since it's broken. Instead, use gnome_font_face_find() and put bold- and italicness in the name to look for. Descenders can now be negative, so have to take the absolute value to get font height. (print_comp): Use global, persistent print configuration. GnomePrintDialog is now a GtkDialog. Remove manual configuration parameter shuffling. Set up page using new methods. (print_calendar): Like print_comp(). For month view, force landscape mode by temporarily setting it in the config, and remove the old hack. (print_setup): Port. I'm not sure this works, but at least it compiles now. How do I test this code path? (print_day_view): Pass NULL for page denominator. (print_week_view): Ditto. (print_month_view): Ditto. (print_year_view): Ditto. (print_comp_item): Add missing gnome_print_beginpage(). How did this work before? * gui/tasks-control.c: Store the PrintConfig globally instead of passing individual parameters every time. Persistent too. (print_title): Look for "Sans Bold" instead of "Times" with GNOME_FONT_BOLD property. Don't use find_closest_from_weight_slant(). (print_tasks): Set up page using new methods. GnomePrintMaster -> GnomePrintJob. Get params from global config instead of args. (tasks_control_print_cmd): Use global, persistent print configuration. Remove manual portrait/landscape hack. GnomePrintDialog is now a GtkDialog. Set params in global config instead of passing them to print_tasks(). (tasks_control_print_preview_cmd): print_tasks() now takes fewer args. svn path=/trunk/; revision=19889
Diffstat (limited to 'calendar/gui/tasks-control.c')
-rw-r--r--calendar/gui/tasks-control.c144
1 files changed, 46 insertions, 98 deletions
diff --git a/calendar/gui/tasks-control.c b/calendar/gui/tasks-control.c
index 2cb45c180c..31d1e2b984 100644
--- a/calendar/gui/tasks-control.c
+++ b/calendar/gui/tasks-control.c
@@ -102,6 +102,9 @@ static void tasks_control_print_preview_cmd (BonoboUIComponent *uic,
const char *path);
+static GnomePrintConfig *print_config = NULL;
+
+
BonoboControl *
tasks_control_new (void)
{
@@ -503,7 +506,7 @@ print_title (GnomePrintContext *pc,
char *text;
double w, x, y;
- font = gnome_font_find_closest_from_weight_slant ("Times", GNOME_FONT_BOLD, 0, 18);
+ font = gnome_font_find_closest ("Sans Bold", 18);
text = _("Tasks");
w = gnome_font_get_width_utf8 (font, text);
@@ -519,60 +522,44 @@ print_title (GnomePrintContext *pc,
g_object_unref (font);
}
-
static void
-print_tasks (ETasks *tasks, gboolean preview, gboolean landscape,
- int copies, gboolean collate)
+print_tasks (ETasks *tasks, gboolean preview)
{
-#warning "Re-implement printing."
-#if 0
ECalendarTable *cal_table;
EPrintable *printable;
ETable *etable;
- GnomePrintMaster *master;
GnomePrintContext *pc;
- const GnomePrintPaper *paper_info;
- double l, r, t, b, page_width, page_height, left_margin, bottom_margin;
+ GnomePrintJob *gpm;
+ double l, r, t, b, page_width, page_height, left_margin, bottom_margin, temp_d;
+
+ if (!print_config)
+ print_config = gnome_print_config_default ();
cal_table = e_tasks_get_calendar_table (tasks);
etable = e_calendar_table_get_table (E_CALENDAR_TABLE (cal_table));
printable = e_table_get_printable (etable);
+ e_printable_reset (printable);
- master = gnome_print_master_new ();
+ gpm = gnome_print_job_new (print_config);
+ pc = gnome_print_job_get_context (gpm);
- paper_info = gnome_print_paper_with_name (gnome_paper_name_default ());
- gnome_print_master_set_paper (master, paper_info);
+ gnome_print_config_get_page_size (print_config, &r, &t);
- gnome_print_master_set_copies (master, copies, collate);
- pc = gnome_print_master_get_context (master);
- e_printable_reset (printable);
+ gnome_print_config_get_double (print_config, GNOME_PRINT_KEY_PAGE_MARGIN_TOP, &temp_d);
+ t -= temp_d;
+ gnome_print_config_get_double (print_config, GNOME_PRINT_KEY_PAGE_MARGIN_RIGHT, &temp_d);
+ r -= temp_d;
+ gnome_print_config_get_double (print_config, GNOME_PRINT_KEY_PAGE_MARGIN_BOTTOM, &b);
+ gnome_print_config_get_double (print_config, GNOME_PRINT_KEY_PAGE_MARGIN_LEFT, &l);
- 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);
- b = gnome_paper_bmargin (paper_info);
-
- if (landscape) {
- page_width = t - b;
- page_height = r - l;
- left_margin = b;
- bottom_margin = gnome_paper_rmargin (paper_info);
- } else {
- page_width = r - l;
- page_height = t - b;
- left_margin = l;
- bottom_margin = b;
- }
+ page_width = r - l;
+ page_height = t - b;
+ left_margin = l;
+ bottom_margin = b;
while (e_printable_data_left (printable)) {
gnome_print_beginpage (pc, "Tasks");
gnome_print_gsave (pc);
- if (landscape) {
- gnome_print_rotate (pc, 90);
- gnome_print_translate (pc, 0, -gnome_paper_pswidth (paper_info));
- }
gnome_print_translate (pc, left_margin, bottom_margin);
@@ -584,19 +571,19 @@ print_tasks (ETasks *tasks, gboolean preview, gboolean landscape,
gnome_print_grestore (pc);
gnome_print_showpage (pc);
}
- gnome_print_master_close (master);
+
+ gnome_print_job_close (gpm);
if (preview) {
- GnomePrintMasterPreview *gpmp;
- gpmp = gnome_print_master_preview_new_with_orientation (master, _("Print Preview"), landscape);
- gtk_widget_show (GTK_WIDGET (gpmp));
+ GtkWidget *gpmp;
+ gpmp = gnome_print_job_preview_new (gpm, _("Print Preview"));
+ gtk_widget_show (gpmp);
} else {
- gnome_print_master_print (master);
+ gnome_print_job_print (gpm);
}
- g_object_unref (master);
+ g_object_unref (gpm);
g_object_unref (printable);
-#endif
}
@@ -606,57 +593,27 @@ tasks_control_print_cmd (BonoboUIComponent *uic,
gpointer data,
const char *path)
{
-#if 0
ETasks *tasks;
- GtkWidget *gpd, *mode_box, *portrait_radio, *landscape_radio;
- GtkWidget *dialog_vbox, *dialog_hbox, *mode_frame;
- GList *children;
- GSList *group;
- gboolean preview = FALSE, landscape = FALSE;
- GnomePrinter *printer;
- int copies;
- gboolean collate;
+ GtkWidget *gpd;
+ gboolean preview = FALSE;
+ GnomePrintJob *gpm;
tasks = E_TASKS (data);
- gpd = gnome_print_dialog_new (_("Print Tasks"),
- GNOME_PRINT_DIALOG_COPIES);
-
- mode_frame = gtk_frame_new (_("Orientation"));
-
- mode_box = gtk_vbox_new (FALSE, 4);
- gtk_container_add (GTK_CONTAINER (mode_frame), mode_box);
-
- /* Portrait */
- portrait_radio = gtk_radio_button_new_with_label (NULL, _("Portrait"));
- group = gtk_radio_button_group (GTK_RADIO_BUTTON (portrait_radio));
- gtk_box_pack_start (GTK_BOX (mode_box), portrait_radio,
- FALSE, FALSE, 0);
-
- /* Landscape */
- landscape_radio = gtk_radio_button_new_with_label (group,
- _("Landscape"));
- gtk_box_pack_start (GTK_BOX (mode_box), landscape_radio,
- FALSE, FALSE, 0);
+ if (!print_config)
+ print_config = gnome_print_config_default ();
- gtk_widget_show_all (mode_frame);
+ gpm = gnome_print_job_new (print_config);
- /* A bit of a hack to insert our own Orientation option. */
- dialog_vbox = GNOME_DIALOG (gpd)->vbox;
- children = gtk_container_children (GTK_CONTAINER (dialog_vbox));
- dialog_hbox = children->next->data;
- g_list_free (children);
- gtk_box_pack_start (GTK_BOX (dialog_hbox), mode_frame,
- FALSE, FALSE, 3);
-
- gnome_dialog_set_default (GNOME_DIALOG (gpd), GNOME_PRINT_PRINT);
+ gpd = gnome_print_dialog_new (gpm, _("Print Tasks"), GNOME_PRINT_DIALOG_COPIES);
+ gtk_dialog_set_default_response (GTK_DIALOG (gpd), GNOME_PRINT_DIALOG_RESPONSE_PRINT);
/* Run dialog */
- switch (gnome_dialog_run (GNOME_DIALOG (gpd))) {
- case GNOME_PRINT_PRINT:
+ switch (gtk_dialog_run (GTK_DIALOG (gpd))) {
+ case GNOME_PRINT_DIALOG_RESPONSE_PRINT:
break;
- case GNOME_PRINT_PREVIEW:
+ case GNOME_PRINT_DIALOG_RESPONSE_PREVIEW:
preview = TRUE;
break;
@@ -664,21 +621,12 @@ tasks_control_print_cmd (BonoboUIComponent *uic,
return;
default:
- gnome_dialog_close (GNOME_DIALOG (gpd));
+ gtk_widget_destroy (gpd);
return;
}
- gnome_print_dialog_get_copies (GNOME_PRINT_DIALOG (gpd),
- &copies, &collate);
- if (GTK_TOGGLE_BUTTON (landscape_radio)->active)
- landscape = TRUE;
-
- printer = gnome_print_dialog_get_printer (GNOME_PRINT_DIALOG (gpd));
-
- gnome_dialog_close (GNOME_DIALOG (gpd));
-
- print_tasks (tasks, preview, landscape, copies, collate);
-#endif
+ gtk_widget_destroy (gpd);
+ print_tasks (tasks, preview);
}
static void
@@ -690,6 +638,6 @@ tasks_control_print_preview_cmd (BonoboUIComponent *uic,
tasks = E_TASKS (data);
- print_tasks (tasks, TRUE, FALSE, 1, FALSE);
+ print_tasks (tasks, TRUE);
}