2005-02-03 [paul] 1.0.0cvs25.3
[claws.git] / src / textview.c
index 0adce34e82734a1d941a8f5eabe3ee30090a0339..a50dd104f7a633ec1f6687ef6d5a8ca01b63907b 100644 (file)
@@ -211,7 +211,6 @@ TextView *textview_create(void)
        GtkItemFactory *popupfactory;
        GtkWidget *popupmenu;
        gint n_entries;
-       PangoFontDescription *font_desc = NULL;
 
        debug_print("Creating text view...\n");
        textview = g_new0(TextView, 1);
@@ -240,14 +239,6 @@ TextView *textview_create(void)
 
        gtk_widget_ensure_style(text);
 
-       if (prefs_common.normalfont)
-               font_desc = pango_font_description_from_string
-                                       (prefs_common.normalfont);
-       if (font_desc) {
-               gtk_widget_modify_font(text, font_desc);
-       }
-       pango_font_description_free(font_desc);
-
        gtk_widget_ref(scrolledwin);
 
        gtk_container_add(GTK_CONTAINER(scrolledwin), text);
@@ -298,19 +289,34 @@ TextView *textview_create(void)
 
 static void textview_create_tags(GtkTextView *text, TextView *textview)
 {
-       GtkTextBuffer *buffer = gtk_text_view_get_buffer(text);
+       GtkTextBuffer *buffer;
        GtkTextTag *tag;
+       static PangoFontDescription *font_desc, *bold_font_desc;
+
+       if (!font_desc)
+               font_desc = pango_font_description_from_string
+                       (NORMAL_FONT);
+
+       if (!bold_font_desc) {
+               bold_font_desc = pango_font_description_from_string
+                       (BOLD_FONT);
+               pango_font_description_set_weight
+                       (bold_font_desc, PANGO_WEIGHT_BOLD);
+       }
+
+       buffer = gtk_text_view_get_buffer(text);
 
        gtk_text_buffer_create_tag(buffer, "header",
                                   "pixels-above-lines", 0,
                                   "pixels-above-lines-set", TRUE,
                                   "pixels-below-lines", 0,
                                   "pixels-below-lines-set", TRUE,
+                                  "font-desc", font_desc,
                                   "left-margin", 0,
                                   "left-margin-set", TRUE,
                                   NULL);
        gtk_text_buffer_create_tag(buffer, "header_title",
-                                  "font", prefs_common.boldfont,
+                                  "font-desc", bold_font_desc,
                                   NULL);
        gtk_text_buffer_create_tag(buffer, "quote0",
                                   "foreground-gdk", &quote_colors[0],
@@ -1155,11 +1161,10 @@ static void textview_write_line(TextView *textview, const gchar *str,
        buffer = gtk_text_view_get_buffer(text);
        gtk_text_buffer_get_end_iter(buffer, &iter);
 
-       if (!conv) {
+       if (!conv)
                strncpy2(buf, str, sizeof(buf));
-       } else if (conv_convert(conv, buf, sizeof(buf), str) < 0) {
-               conv_localetodisp(buf, sizeof(buf), str);
-       }
+       else if (conv_convert(conv, buf, sizeof(buf), str) < 0)
+               conv_utf8todisp(buf, sizeof(buf), str);
 
        strcrchomp(buf);
        //if (prefs_common.conv_mb_alnum) conv_mb_alnum(buf);
@@ -1220,23 +1225,10 @@ void textview_write_link(TextView *textview, const gchar *str,
        buffer = gtk_text_view_get_buffer(text);
        gtk_text_buffer_get_end_iter(buffer, &iter);
 
-#warning FIXME_GTK2
-#if 0
-       if (!conv) {
-               if (textview->text_is_mb)
-                       conv_localetodisp(buf, sizeof(buf), str);
-               else
-                       strncpy2(buf, str, sizeof(buf));
-       } else if (conv_convert(conv, buf, sizeof(buf), str) < 0)
-               conv_localetodisp(buf, sizeof(buf), str);
-       else if (textview->text_is_mb)
-               conv_unreadable_locale(buf);
-#else
        if (!conv)
                strncpy2(buf, str, sizeof(buf));
        else if (conv_convert(conv, buf, sizeof(buf), str) < 0)
-               conv_localetodisp(buf, sizeof(buf), str);
-#endif
+               conv_utf8todisp(buf, sizeof(buf), str);
 
        strcrchomp(buf);
 
@@ -1290,8 +1282,7 @@ void textview_set_font(TextView *textview, const gchar *codeset)
        if (prefs_common.textfont) {
                PangoFontDescription *font_desc = NULL;
 
-               if (prefs_common.textfont)
-                       font_desc = pango_font_description_from_string
+               font_desc = pango_font_description_from_string
                                                (prefs_common.textfont);
                if (font_desc) {
                        gtk_widget_modify_font(textview->text, font_desc);