2006-06-06 [paul] 2.2.1cvs4
[claws.git] / src / textview.c
index 2b1bb50313cc8b096e8a99675fdb08e4774c7eb4..3354b350ef48caf965f257e49bcf662c9587e61c 100644 (file)
@@ -451,13 +451,19 @@ void textview_init(TextView *textview)
        textview_create_tags(GTK_TEXT_VIEW(textview->text), textview);
 }
 
-#define CHANGE_TAG_COLOR(tagname, colorfg, colorbg) { \
+#if GTK_CHECK_VERSION(2, 8, 0)
+ #define CHANGE_TAG_COLOR(tagname, colorfg, colorbg) { \
        tag = gtk_text_tag_table_lookup(tags, tagname); \
-       if (tag && colorbg) \
+       if (tag) \
                g_object_set(G_OBJECT(tag), "foreground-gdk", colorfg, "paragraph-background-gdk", colorbg, NULL); \
-       else if (tag) \
+ }
+#else
+ #define CHANGE_TAG_COLOR(tagname, colorfg, colorbg) { \
+       tag = gtk_text_tag_table_lookup(tags, tagname); \
+       if (tag) \
                g_object_set(G_OBJECT(tag), "foreground-gdk", colorfg, NULL); \
-}
+ }
+#endif
 
 static void textview_update_message_colors(TextView *textview)
 {
@@ -900,7 +906,9 @@ static void textview_show_html(TextView *textview, FILE *fp,
                                /* ALF - the sylpheed html parser returns an empty string,
                                 * if still inside an <a>, but already parsed past HREF */
                                str = strtok(str, " ");
-                               if (str) { 
+                               if (str) {
+                                       while (str && *str && g_ascii_isspace(*str))
+                                               str++; 
                                        parser->href = g_strdup(str);
                                        /* the URL may (or not) be followed by the
                                         * referenced text */
@@ -1144,6 +1152,9 @@ void textview_write_link(TextView *textview, const gchar *str,
        if (!uri)
                return;
 
+       while (uri && *uri && g_ascii_isspace(*uri))
+               uri++;
+               
        text = GTK_TEXT_VIEW(textview->text);
        buffer = gtk_text_view_get_buffer(text);
        gtk_text_buffer_get_end_iter(buffer, &iter);
@@ -1182,6 +1193,11 @@ void textview_write_link(TextView *textview, const gchar *str,
        textview->uri_list = g_slist_append(textview->uri_list, r_uri);
 }
 
+static void textview_set_cursor(GdkWindow *window, GdkCursor *cursor)
+{
+       if (GDK_IS_WINDOW(window))
+               gdk_window_set_cursor(window, cursor);
+}
 void textview_clear(TextView *textview)
 {
        GtkTextView *text = GTK_TEXT_VIEW(textview->text);
@@ -1203,9 +1219,9 @@ void textview_clear(TextView *textview)
        textview->image = NULL;
 
        if (textview->messageview->mainwin->cursor_count == 0) {
-               gdk_window_set_cursor(window, text_cursor);
+               textview_set_cursor(window, text_cursor);
        } else {
-               gdk_window_set_cursor(window, watch_cursor);
+               textview_set_cursor(window, watch_cursor);
        }
 }
 
@@ -1525,7 +1541,9 @@ static void textview_show_header(TextView *textview, GPtrArray *headers)
                          procheader_headername_equal(header->name, "From") ||
                          procheader_headername_equal(header->name, "To") ||
                          procheader_headername_equal(header->name, "Cc") ||
-                         procheader_headername_equal(header->name, "Bcc");
+                         procheader_headername_equal(header->name, "Bcc") ||
+                         procheader_headername_equal(header->name, "Reply-To") ||
+                         procheader_headername_equal(header->name, "Sender");
                        textview_make_clickable_parts(textview, "header", 
                                                      "link", header->body, 
                                                      hdr);
@@ -1846,7 +1864,7 @@ void textview_cursor_wait(TextView *textview)
        GdkWindow *window = gtk_text_view_get_window(
                        GTK_TEXT_VIEW(textview->text),
                        GTK_TEXT_WINDOW_TEXT);
-       gdk_window_set_cursor(window, watch_cursor);
+       textview_set_cursor(window, watch_cursor);
 }
 
 void textview_cursor_normal(TextView *textview)
@@ -1854,7 +1872,7 @@ void textview_cursor_normal(TextView *textview)
        GdkWindow *window = gtk_text_view_get_window(
                        GTK_TEXT_VIEW(textview->text),
                        GTK_TEXT_WINDOW_TEXT);
-       gdk_window_set_cursor(window, text_cursor);
+       textview_set_cursor(window, text_cursor);
 }
 
 static void textview_uri_update(TextView *textview, gint x, gint y)
@@ -1916,9 +1934,9 @@ static void textview_uri_update(TextView *textview, gint x, gint y)
                window = gtk_text_view_get_window(GTK_TEXT_VIEW(textview->text),
                                                  GTK_TEXT_WINDOW_TEXT);
                if (textview->messageview->mainwin->cursor_count == 0) {
-                       gdk_window_set_cursor(window, uri ? hand_cursor : text_cursor);
+                       textview_set_cursor(window, uri ? hand_cursor : text_cursor);
                } else {
-                       gdk_window_set_cursor(window, watch_cursor);
+                       textview_set_cursor(window, watch_cursor);
                }
 
                TEXTVIEW_STATUSBAR_POP(textview);