From 1bc1b31cc0bb9cd102da768b3d6a32f7fbe02fc2 Mon Sep 17 00:00:00 2001 From: Hans Petter Jansson Date: Wed, 26 Feb 2003 00:07:41 +0000 Subject: Use fixed margins of 5% of page width/height. This is the same cheat as 2003-02-25 Hans Petter Jansson * gui/print.c (print_calendar): Use fixed margins of 5% of page width/height. This is the same cheat as gtkhtml employs to get around the fact that GNOME_PRINT_KEY_PAGE_MARGIN_* don't return useful values (I think). It sort of sucks, but is better than no margins at all. (print_comp): Ditto. svn path=/trunk/; revision=20066 --- calendar/ChangeLog | 9 +++++++++ calendar/gui/print.c | 46 ++++++++++++++++++++++++++++++++++------------ 2 files changed, 43 insertions(+), 12 deletions(-) diff --git a/calendar/ChangeLog b/calendar/ChangeLog index a0f464fe50..1037b89039 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,12 @@ +2003-02-25 Hans Petter Jansson + + * gui/print.c (print_calendar): Use fixed margins of 5% of page + width/height. This is the same cheat as gtkhtml employs to get + around the fact that GNOME_PRINT_KEY_PAGE_MARGIN_* don't return + useful values (I think). It sort of sucks, but is better than + no margins at all. + (print_comp): Ditto. + 2003-02-25 Hans Petter Jansson * gui/calendar-config.c (calendar_config_get_default_view): Get diff --git a/calendar/gui/print.c b/calendar/gui/print.c index 1b83073766..dff86a02a2 100644 --- a/calendar/gui/print.c +++ b/calendar/gui/print.c @@ -61,6 +61,12 @@ * what gnome-print uses. */ +/* GtkHTML prints using a fixed margin. It has code to get the margins from + * gnome-print keys, but it's commented out. The corresponding code here + * doesn't seem to work either (getting zero margins), so we adopt + * gtkhtml's cheat. */ +#define TEMP_MARGIN .05 + /* The fonts to use */ #define REGULAR_FONT "Sans Regular" #define BOLD_FONT "Sans Bold" @@ -2486,12 +2492,20 @@ print_calendar (GnomeCalendar *gcal, gboolean preview, time_t date, pc = gnome_print_job_get_context (gpm); gnome_print_config_get_page_size (print_config, &r, &t); - 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); + /* See top of source for an explanation of this */ + + /* 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); + * b = l = TEMP_MARGIN; */ + + b = t * TEMP_MARGIN; + l = r * TEMP_MARGIN; + t *= (1.0 - TEMP_MARGIN); + r *= (1.0 - TEMP_MARGIN); /* depending on the view, do a different output */ switch (default_view) { @@ -2581,12 +2595,20 @@ print_comp (CalComponent *comp, CalClient *client, gboolean preview) pc = gnome_print_job_get_context (gpm); gnome_print_config_get_page_size (print_config, &r, &t); - 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); + /* See top of source for an explanation of this */ + + /* 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); + * b = l = TEMP_MARGIN; */ + + b = t * TEMP_MARGIN; + l = r * TEMP_MARGIN; + t *= (1.0 - TEMP_MARGIN); + r *= (1.0 - TEMP_MARGIN); print_comp_item (pc, comp, client, l, r, t, b); gnome_print_job_close (gpm); -- cgit v1.2.3