[PATCH] fix charset selection for header lines



The attached patch (against today's cvs) fixes a small problem of the header
lines display. If the header lines (or the complete message) are encoded in a 
different encoding than the current setting, some characters may display 
incorrectly.

The patch displays the header *values* in the messages charset (if set), but 
keeps the font and charset for the labels as the label's charset is defined 
by the current locale setting. Note that this might fail as different headers 
might have different (inlined) encodings, but these are stripped by libmutt. 
However, I think this will be an extremely rare case.

Cheers,

	Albrecht.

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      Albrecht Dreß  -  Monschauer Straße 22  -  D-53121 Bonn (Germany)
        Phone (+49) 228 6199571  -  mailto:albrecht.dress@arcormail.de
_________________________________________________________________________

--- balsa/src/balsa-message.c	Mon Nov 19 19:22:46 2001
+++ balsa-patched/src/balsa-message.c	Wed Nov 21 20:53:50 2001
@@ -607,17 +607,34 @@
     gchar cr[] = "\n";
     gchar *line_start, *line_end;
     gchar *wrapped_value;
+    const gchar *msgcharset;
 
     if (!(bm->shown_headers == HEADERS_ALL || libbalsa_find_word(header, balsa_app.selected_headers))) 
 	return;
 
+    /* always display the label in the predefined font */
     if (strcmp(header, "subject") != 0)
 	fnt = gdk_font_load(balsa_app.message_font);
     else
 	fnt = gdk_font_load(balsa_app.subject_font);
 
     gtk_text_insert(GTK_TEXT(bm->header_text), fnt, NULL, NULL, label, -1);
-
+    
+    /* select the font for the value according to the msg charset */
+    if ((msgcharset = libbalsa_message_charset(bm->message))) {
+	if (strcmp(header, "subject") != 0)
+	    fnt = balsa_get_font_by_charset(balsa_app.message_font, 
+					    msgcharset);
+	else
+	    fnt = balsa_get_font_by_charset(balsa_app.subject_font,
+					    msgcharset);
+    } else {
+	if (strcmp(header, "subject") != 0)
+	    fnt = gdk_font_load(balsa_app.message_font);
+	else
+	    fnt = gdk_font_load(balsa_app.subject_font);
+    }
+	
     if (value && *value != '\0') {
 	if (strlen(label) < 15)
 	    gtk_text_insert(GTK_TEXT(bm->header_text), fnt, NULL, NULL,


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