[evolution-patches] Re: [gene-pool] Printing font problem



On Mon, 2003-06-23 at 20:38, Larry Ewing wrote:
> I think the problem is slightly more complex than this, the current code
> is creating a new and packing the print html widget inside it so it
> cannot pick up the style settings properly, I have a patch that should
> address that but I haven't had time to test it because other things have
> been breaking.

Yeah, I didn't realize it at first, but I had to set widget name and add
one more line to gtkrc to get style applied.

> I'm trying to clear out my match que now, I'll look at the printing
> again as soon as I'm done if rodo hasn't gotten there first.

Okie, I am attaching both parts - evo part takes care about style
application, gtkhtml part takes care of reducing of font properties to
one set.

Radek

> 
> --Larry
> 
> On Mon, 2003-06-23 at 12:13, Ettore Perazzoli wrote:
> > On Fri, 2003-06-20 at 16:26, Radek Doulík wrote:
> > > > I assume it's not going to cause trouble in case the user selects a
> > > > fancy font for on-screen display?
> > > 
> > > it will just use the same fancy font for printing
> > 
> > OK.  What's the status of the patch?
> > 
> > -- Ettore
-- 
Radek Doulík <rodo ximian com>
Ximian, Inc.
Index: gtkhtml-private.h
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/gtkhtml-private.h,v
retrieving revision 1.39
diff -u -p -r1.39 gtkhtml-private.h
--- gtkhtml-private.h	20 May 2003 18:25:14 -0000	1.39
+++ gtkhtml-private.h	23 Jun 2003 22:33:36 -0000
@@ -67,16 +67,18 @@ struct _GtkHTMLPrivate {
 	gboolean    inline_spelling;
 };
 
-void  gtk_html_private_calc_scrollbars  (GtkHTML                 *html,
-					 gboolean                *changed_x,
-					 gboolean                *changed_y);
-void  gtk_html_editor_event_command     (GtkHTML                 *html,
-					 GtkHTMLCommandType       com_type,
-					 gboolean                 before);
-void  gtk_html_editor_event             (GtkHTML                 *html,
-					 GtkHTMLEditorEventType   event,
-					 GValue                  *args);
-void  gtk_html_api_set_language         (GtkHTML                 *html);
-void  gtk_html_im_reset                 (GtkHTML                 *html);
+void  gtk_html_private_calc_scrollbars  (GtkHTML                *html,
+					 gboolean               *changed_x,
+					 gboolean               *changed_y);
+void  gtk_html_editor_event_command     (GtkHTML                *html,
+					 GtkHTMLCommandType      com_type,
+					 gboolean                before);
+void  gtk_html_editor_event             (GtkHTML                *html,
+					 GtkHTMLEditorEventType  event,
+					 GValue                 *args);
+void  gtk_html_api_set_language         (GtkHTML                *html);
+void  gtk_html_im_reset                 (GtkHTML                *html);
+void  gtk_html_set_fonts                (GtkHTML                *html,
+					 HTMLPainter            *painter);
 
 #endif /* _GTKHTML_PRIVATE_H */
Index: gtkhtml-properties.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/gtkhtml-properties.c,v
retrieving revision 1.93
diff -u -p -r1.93 gtkhtml-properties.c
--- gtkhtml-properties.c	20 May 2003 18:25:14 -0000	1.93
+++ gtkhtml-properties.c	23 Jun 2003 22:33:36 -0000
@@ -68,22 +68,12 @@ gtk_html_class_properties_new (GtkWidget
 	/* editing */
 	p->language                = g_strdup (e_iconv_locale_language ());
 
-	/* printf ("Variable Printing Font: \"%s\"\n", p->font_var_print); */
-	p->font_var_print          = g_strdup (pango_font_description_get_family (var_desc));
-	p->font_fix_print          = fixed_name;
-	p->font_var_size_print     = DEFAULT_FONT_SIZE_PRINT;
-	p->font_fix_size_print     = DEFAULT_FONT_SIZE_PRINT;
-	p->font_var_print_points   = FALSE;
-	p->font_fix_print_points   = FALSE;
-
 	return p;
 }
 
 void
 gtk_html_class_properties_destroy (GtkHTMLClassProperties *p)
 {
-	g_free (p->font_fix_print);
-	g_free (p->font_var_print);
 	g_free (p->language);
 	g_free (p);
 }
@@ -118,22 +108,6 @@ gtk_html_class_properties_load (GtkHTMLC
 void
 gtk_html_class_properties_update (GtkHTMLClassProperties *p, GConfClient *client, GtkHTMLClassProperties *old)
 {
-	gchar *key;
-
-	if (strcmp (p->font_var_print, old->font_var_print))
-		SET (string, "/font_variable_print", font_var_print);
-	if (strcmp (p->font_fix_print, old->font_fix_print))
-		SET (string, "/font_fixed_print", font_fix_print);
-	if (p->font_var_print_points != old->font_var_print_points)
-		SET (bool, "/font_variable_print_points", font_var_print_points);
-	if (p->font_fix_print_points != old->font_fix_print_points)
-		SET (bool, "/font_fixed_print_points", font_fix_print_points);
-	if (p->font_var_size_print != old->font_var_size_print || p->font_var_print_points != old->font_var_print_points)
-		SET (int, "/font_variable_size_print", font_var_size_print);
-	if (p->font_fix_size_print != old->font_fix_size_print || p->font_fix_print_points != old->font_fix_print_points)
-		SET (int, "/font_fixed_size_print", font_fix_size_print);
-	
-	gconf_client_suggest_sync (client, NULL);
 }
 
 /* enums */
Index: gtkhtml-properties.h
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/gtkhtml-properties.h,v
retrieving revision 1.25
diff -u -p -r1.25 gtkhtml-properties.h
--- gtkhtml-properties.h	20 May 2003 18:25:14 -0000	1.25
+++ gtkhtml-properties.h	23 Jun 2003 22:33:36 -0000
@@ -38,14 +38,6 @@
 #define GTK_HTML_PROPERTY(w,p)         (GTK_HTML_CLASS (GTK_WIDGET_GET_CLASS (w))->properties-> p)
 
 struct _GtkHTMLClassProperties {
-	/* viewer */
-	gchar    *font_var_print;
-	guint     font_var_size_print;
-	gboolean  font_var_print_points;
-	gchar    *font_fix_print;
-	guint     font_fix_size_print;
-	gboolean  font_fix_print_points;
-
 	/* editor */
 	gchar    *language;
 };
Index: gtkhtml.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/gtkhtml.c,v
retrieving revision 1.516
diff -u -p -r1.516 gtkhtml.c
--- gtkhtml.c	13 Jun 2003 21:42:59 -0000	1.516
+++ gtkhtml.c	23 Jun 2003 22:33:37 -0000
@@ -720,55 +720,63 @@ destroy (GtkObject *object)
 		(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
 }
 
-/* GtkWidget methods.  */
-static void
-style_set (GtkWidget *widget, GtkStyle  *previous_style)
+void
+gtk_html_set_fonts (GtkHTML *html, HTMLPainter *painter)
 {
-	HTMLEngine *engine = GTK_HTML (widget)->engine;
 	PangoFontDescription *fixed_desc = NULL;
 	char *fixed_name = NULL;
+	char *fixed_family = NULL;
 	gint  fixed_size = 0;
 	char *font_var = NULL;
 	gint  font_var_size = 0;
 
-	/* we don't need to set font's in idle time so call idle callback directly to avoid
-	   recalculating whole document
-	*/
-	if (engine) {
-		font_var = pango_font_description_to_string (widget->style->font_desc);
-		font_var_size = PANGO_PIXELS (pango_font_description_get_size (widget->style->font_desc));
+	(const gchar *) font_var = pango_font_description_get_family (GTK_WIDGET (html)->style->font_desc);
+	font_var_size = PANGO_PIXELS (pango_font_description_get_size (GTK_WIDGET (html)->style->font_desc));
 		
-		gtk_widget_style_get (widget, "fixed_font_name", &fixed_name, NULL);
-		if (fixed_name) {
-			fixed_desc = pango_font_description_from_string (fixed_name);
-			if (pango_font_description_get_family (fixed_desc)) {
-				fixed_size = PANGO_PIXELS (pango_font_description_get_size (fixed_desc));
-			} else {
-				g_free (fixed_name);
-				fixed_name = NULL;
-			}
-			pango_font_description_free (fixed_desc);
+	gtk_widget_style_get (GTK_WIDGET (html), "fixed_font_name", &fixed_name, NULL);
+	if (fixed_name) {
+		fixed_desc = pango_font_description_from_string (fixed_name);
+		if (pango_font_description_get_family (fixed_desc)) {
+			fixed_size = PANGO_PIXELS (pango_font_description_get_size (fixed_desc));
+			(const gchar *) fixed_family = pango_font_description_get_family (fixed_desc);
+		} else {
+			g_free (fixed_name);
+			fixed_name = NULL;
 		}
+	}
 		
-		if (!fixed_name) {
-			fixed_name = g_strdup ("Monospace");
-			fixed_size = font_var_size;
-		}
+	if (!fixed_name) {
+		fixed_family = g_strdup ("Monospace");
+		fixed_size = font_var_size;
+	}
 
-		html_font_manager_set_default (&engine->painter->font_manager,
-					       font_var, fixed_name,
-					       font_var_size, FALSE,
-					       fixed_size, FALSE);
+	html_font_manager_set_default (&painter->font_manager,
+				       font_var, fixed_family,
+				       font_var_size, FALSE,
+				       fixed_size, FALSE);
+	if (fixed_desc)
+		pango_font_description_free (fixed_desc);
 
+	g_free (fixed_name);
+}
+
+/* GtkWidget methods.  */
+static void
+style_set (GtkWidget *widget, GtkStyle  *previous_style)
+{
+	HTMLEngine *engine = GTK_HTML (widget)->engine;
+
+	/* we don't need to set font's in idle time so call idle callback directly to avoid
+	   recalculating whole document
+	*/
+	if (engine) {
+		gtk_html_set_fonts (GTK_HTML (widget), engine->painter);
 		if (engine->clue) {
 			html_object_reset (engine->clue);
 			html_object_change_set_down (engine->clue, HTML_CHANGE_ALL);
 			html_engine_calc_size (engine, FALSE);
 			html_engine_schedule_update (engine);
 		}
-		
-		g_free (fixed_name);
-		g_free (font_var);
 	}
 
 
Index: htmlengine-print.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlengine-print.c,v
retrieving revision 1.37
diff -u -p -r1.37 htmlengine-print.c
--- htmlengine-print.c	19 May 2003 12:32:26 -0000	1.37
+++ htmlengine-print.c	23 Jun 2003 22:33:37 -0000
@@ -159,10 +159,7 @@ print_with_header_footer (HTMLEngine *en
 	g_return_val_if_fail (engine->clue != NULL, 0);
 
 	printer = html_printer_new (print_context, GTK_HTML (engine->widget)->priv->print_master);
-	html_font_manager_set_default (&printer->font_manager,
-				       prop->font_var_print,      prop->font_fix_print,
-				       prop->font_var_size_print, prop->font_var_print_points,
-				       prop->font_fix_size_print, prop->font_fix_print_points);
+	gtk_html_set_fonts (engine->widget, printer);
 
 	if (do_we_have_default_font (printer)) {
 		gint min_width, page_width;
Index: htmlgdkpainter.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlgdkpainter.c,v
retrieving revision 1.120
diff -u -p -r1.120 htmlgdkpainter.c
--- htmlgdkpainter.c	9 Apr 2003 04:03:51 -0000	1.120
+++ htmlgdkpainter.c	23 Jun 2003 22:33:40 -0000
@@ -211,7 +211,11 @@ alloc_font (HTMLPainter *painter, gchar 
 	PangoFontDescription *desc = NULL;
 
 	if (face) {
-		desc = pango_font_description_from_string (face);
+		gchar *str;
+
+		str = g_strdup_printf ("%s %d", face, (gint) size * PANGO_SCALE);
+		desc = pango_font_description_from_string (str);
+		g_free (str);
 	}
 
 	if (!desc || !pango_font_description_get_family (desc)) {
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/mail/ChangeLog,v
retrieving revision 1.2753
diff -u -p -r1.2753 ChangeLog
--- ChangeLog	20 Jun 2003 04:57:49 -0000	1.2753
+++ ChangeLog	23 Jun 2003 22:33:43 -0000
@@ -1,3 +1,10 @@
+2003-06-23  Radek Doulik  <rodo ximian com>
+
+	* mail-config.c (config_write_style): add
+	EvolutionMailPrintHTMLWidget style assignment
+
+	* mail-callbacks.c (do_mail_print): set printing widget name
+
 2003-06-19  Not Zed  <NotZed Ximian com>
 
 	** See bug #45063
Index: mail-callbacks.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/mail-callbacks.c,v
retrieving revision 1.446
diff -u -p -r1.446 mail-callbacks.c
--- mail-callbacks.c	17 Jun 2003 03:15:46 -0000	1.446
+++ mail-callbacks.c	23 Jun 2003 22:33:44 -0000
@@ -2913,6 +2913,7 @@ do_mail_print (FolderBrowser *fb, gboole
 	print_context = gnome_print_job_get_context (print_master);
 	
 	html = GTK_HTML (gtk_html_new ());
+	gtk_widget_set_name (GTK_WIDGET (html), "EvolutionMailPrintHTMLWidget");
 	mail_display_initialize_gtkhtml (fb->mail_display, html);
 	
 	/* Set our 'printing' flag to true and render.  This causes us
Index: mail-config.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/mail-config.c,v
retrieving revision 1.280
diff -u -p -r1.280 mail-config.c
--- mail-config.c	11 Jun 2003 16:19:34 -0000	1.280
+++ mail-config.c	23 Jun 2003 22:33:45 -0000
@@ -477,10 +477,10 @@ config_write_style (void)
 	fprintf (rc, "widget \"*.MailDisplay.*.GtkHTML\" style \"evolution-mail-custom-fonts\"\n");
 	fprintf (rc, "widget \"*.FolderBrowser.*.GtkHTML\" style \"evolution-mail-custom-fonts\"\n");
 	fprintf (rc, "widget \"*.BonoboPlug.*.GtkHTML\" style \"evolution-mail-custom-fonts\"\n");
-	
+	fprintf (rc, "widget \"*.EvolutionMailPrintHTMLWidget\" style \"evolution-mail-custom-fonts\"\n");
+
 	if (fclose (rc) == 0)
 		gtk_rc_reparse_all ();
-
 }
 
 static void


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