[evolution-patches] Tasks printing (GAL, Calendar) #43585



A patch for the calendar, and one for GAL. Together, this should fix
#43585.

-- 
Hans Petter
? evolution-tasks-print.patch
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/calendar/ChangeLog,v
retrieving revision 1.1797
diff -u -p -r1.1797 ChangeLog
--- ChangeLog	20 Jun 2003 14:36:16 -0000	1.1797
+++ ChangeLog	23 Jun 2003 05:07:15 -0000
@@ -1,3 +1,10 @@
+2003-06-22  Hans Petter Jansson  <hpj ximian com>
+
+	* gui/print.c (get_font_for_size): Remove debug output.
+
+	* gui/tasks-control.c (print_tasks): Ref and sink the printable.
+	Use fixed (5%) margins instead of what gnome-print gives us.
+
 2003-06-19  Dan Winship  <danw ximian com>
 
 	* pcs/cal-backend.c (cal_backend_finalize): don't leak the
Index: gui/print.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/print.c,v
retrieving revision 1.49
diff -u -p -r1.49 print.c
--- gui/print.c	30 May 2003 17:35:10 -0000	1.49
+++ gui/print.c	23 Jun 2003 05:07:19 -0000
@@ -283,8 +283,6 @@ get_font_for_size (double h, GnomeFontWe
 	desc = abs (gnome_font_face_get_descender (face));
 	size = h * 1000 / (asc + desc);
 
-	g_print ("Print Info: %f, %f, %f\n", asc, desc, size);
-
 	/* This function is broken in gnome-print (it doesn't find a suitable font).
 	 * font = gnome_font_find_closest_from_weight_slant (DEFAULT_FONT, weight, italic, size); */
 	font = gnome_font_find_closest (font_name, size);
Index: gui/tasks-control.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/tasks-control.c,v
retrieving revision 1.57
diff -u -p -r1.57 tasks-control.c
--- gui/tasks-control.c	29 May 2003 09:06:00 -0000	1.57
+++ gui/tasks-control.c	23 Jun 2003 05:07:20 -0000
@@ -52,6 +52,7 @@
 
 #define TASKS_CONTROL_PROPERTY_URI		"folder_uri"
 #define TASKS_CONTROL_PROPERTY_URI_IDX		1
+#define FIXED_MARGIN                            .05
 
 
 static void tasks_control_properties_init	(BonoboControl		*control,
@@ -530,6 +531,8 @@ print_tasks (ETasks *tasks, gboolean pre
 	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);
+	g_object_ref (printable);
+	gtk_object_sink (GTK_OBJECT (printable));
 	e_printable_reset (printable);
 
 	gpm = gnome_print_job_new (print_config);
@@ -537,12 +540,19 @@ print_tasks (ETasks *tasks, gboolean pre
 
 	gnome_print_config_get_page_size (print_config, &r, &t);
 
+#if 0
 	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);
+#endif
+
+	b = t * FIXED_MARGIN;
+	l = r * FIXED_MARGIN;
+	t *= (1.0 - FIXED_MARGIN);
+	r *= (1.0 - FIXED_MARGIN);
 
 	page_width = r - l;
 	page_height = t - b;
? gal-cell-text-print.patch
? docs/gal-api.html
Index: gal/e-table/ChangeLog
===================================================================
RCS file: /cvs/gnome/gal/gal/e-table/ChangeLog,v
retrieving revision 1.905
diff -u -p -r1.905 ChangeLog
--- gal/e-table/ChangeLog	19 Jun 2003 15:31:31 -0000	1.905
+++ gal/e-table/ChangeLog	23 Jun 2003 05:10:24 -0000
@@ -1,3 +1,9 @@
+2003-06-22  Hans Petter Jansson  <hpj ximian com>
+
+	* e-cell-text.c (get_font_for_size): Implement.
+	(ect_print): Use same font heuristics as evo calendar, pick a font
+	that fits. Correct baseline calculation.
+
 2003-06-19  Larry Ewing  <lewing ximian com>
 
 	* e-table-specification.c (e_table_specification_load_from_node):
Index: gal/e-table/e-cell-text.c
===================================================================
RCS file: /cvs/gnome/gal/gal/e-table/e-cell-text.c,v
retrieving revision 1.129
diff -u -p -r1.129 e-cell-text.c
--- gal/e-table/e-cell-text.c	12 Jun 2003 13:35:46 -0000	1.129
+++ gal/e-table/e-cell-text.c	23 Jun 2003 05:10:27 -0000
@@ -1113,12 +1113,33 @@ ect_free_state (ECellView *ecell_view, i
 	g_free (save_state);
 }
 
+#define FONT_NAME "Sans Regular"
+
+static GnomeFont *
+get_font_for_size (double h)
+{
+	GnomeFontFace *face;
+	GnomeFont *font;
+	double asc, desc, size;
+
+	face = gnome_font_face_find (FONT_NAME);
+
+	asc = gnome_font_face_get_ascender (face);
+	desc = abs (gnome_font_face_get_descender (face));
+	size = h * 1000 / (asc + desc);
+
+	font = gnome_font_find_closest (FONT_NAME, size);
+
+	g_object_unref (face);
+	return font;
+}
+
 static void
 ect_print (ECellView *ecell_view, GnomePrintContext *context, 
 	   int model_col, int view_col, int row,
 	   double width, double height)
 {
-	GnomeFont *font = gnome_font_find ("Helvetica", 12);
+	GnomeFont *font = get_font_for_size (16);
 	char *string;
 	ECellText *ect = E_CELL_TEXT(ecell_view->ecell);
 	string = e_cell_text_get_text(ect, ecell_view->e_table_model, model_col, row);
@@ -1135,11 +1156,13 @@ ect_print (ECellView *ecell_view, GnomeP
 				/* FIXME */;
 	if (gnome_print_clip(context) == -1)
 				/* FIXME */;
-	gnome_print_moveto(context, 2, (height - gnome_font_get_ascender(font) + gnome_font_get_descender(font)) / 2);
+	gnome_print_moveto(context, 2, (height - gnome_font_get_ascender(font) - gnome_font_get_descender(font)) / 2);
+
 	gnome_print_setfont(context, font);
 	gnome_print_show(context, string);
 	gnome_print_grestore(context);
 	e_cell_text_free_text(ect, string);
+	g_object_unref (font);
 }
 
 static gdouble


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]