2005-07-06 [colin] 1.9.12cvs24
[claws.git] / src / textview.c
index 2a3404cfa20cbee30512f254fc6b94161b9bc821..2756dad49d151ac9c1181b91b1d8bc6a48e08ceb 100644 (file)
@@ -211,15 +211,15 @@ static void save_file_cb                  (TextView       *textview,
 
 static GtkItemFactoryEntry textview_link_popup_entries[] = 
 {
-       {N_("/_Open link"),             NULL, open_uri_cb, 0, NULL},
-       {N_("/_Copy link location"),    NULL, copy_uri_cb, 0, NULL},
+       {N_("/_Open with Web browser"), NULL, open_uri_cb, 0, NULL},
+       {N_("/Copy this _link"),        NULL, copy_uri_cb, 0, NULL},
 };
 
 static GtkItemFactoryEntry textview_mail_popup_entries[] = 
 {
-       {N_("/_Add to addressbook"),    NULL, add_uri_to_addrbook_cb, 0, NULL},
-       {N_("/_Email"),                 NULL, mail_to_uri_cb, 0, NULL},
-       {N_("/_Copy"),                  NULL, copy_mail_to_uri_cb, 0, NULL},
+       {N_("/Compose _new message"),   NULL, mail_to_uri_cb, 0, NULL},
+       {N_("/Add to _address book"),   NULL, add_uri_to_addrbook_cb, 0, NULL},
+       {N_("/Copy this add_ress"),     NULL, copy_mail_to_uri_cb, 0, NULL},
 };
 
 static GtkItemFactoryEntry textview_file_popup_entries[] = 
@@ -388,7 +388,7 @@ void textview_init(TextView *textview)
        if (!text_cursor)
                text_cursor = gdk_cursor_new(GDK_XTERM);
 
-       textview_update_message_colors();
+       textview_reflect_prefs(textview);
        textview_set_all_headers(textview, FALSE);
        textview_set_font(textview, NULL);
        textview_create_tags(GTK_TEXT_VIEW(textview->text), textview);
@@ -416,6 +416,13 @@ void textview_update_message_colors(void)
        }
 }
 
+void textview_reflect_prefs(TextView *textview)
+{
+       textview_update_message_colors();
+       gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(textview->text),
+                                        prefs_common.textview_cursor_visible);
+}
+
 void textview_show_message(TextView *textview, MimeInfo *mimeinfo,
                           const gchar *file)
 {
@@ -437,8 +444,6 @@ void textview_show_message(TextView *textview, MimeInfo *mimeinfo,
 
 void textview_show_part(TextView *textview, MimeInfo *mimeinfo, FILE *fp)
 {
-       GtkTextView *text;
-
        g_return_if_fail(mimeinfo != NULL);
        g_return_if_fail(fp != NULL);
 
@@ -1073,7 +1078,7 @@ static gboolean get_email_part(const gchar *start, const gchar *scanpos,
                        && (((bp_ + 1) < ep_)    && isalnum(*(bp_ + 1)))) {
                                /* hyphens are allowed, but only in
                                   between alnums */
-                       } else if (!strchr(",;:=?./+<>!&", *bp_)) {
+                       } else if (!strchr(",;:=?./+<>!&\r\n\t", *bp_)) {
                                /* but anything not being a punctiation
                                   is ok */
                        } else {
@@ -1333,7 +1338,9 @@ void textview_write_link(TextView *textview, const gchar *str,
        gchar *bufp;
        RemoteURI *r_uri;
 
-       if (*str == '\0')
+       if (!str || *str == '\0')
+               return;
+       if (!uri)
                return;
 
        text = GTK_TEXT_VIEW(textview->text);
@@ -1345,12 +1352,21 @@ void textview_write_link(TextView *textview, const gchar *str,
        else if (conv_convert(conv, buf, sizeof(buf), str) < 0)
                conv_utf8todisp(buf, sizeof(buf), str);
 
+       if (g_utf8_validate(buf, -1, NULL) == FALSE)
+               return;
+
        strcrchomp(buf);
 
        gtk_text_buffer_get_end_iter(buffer, &iter);
+       for (bufp = buf; *bufp != '\0'; bufp = g_utf8_next_char(bufp)) {
+               gunichar ch;
 
-       for (bufp = buf; isspace(*(guchar *)bufp); bufp++)
-               gtk_text_buffer_insert(buffer, &iter, bufp, 1);
+               ch = g_utf8_get_char(bufp);
+               if (!g_unichar_isspace(ch))
+                       break;
+       }
+       if (bufp > buf)
+               gtk_text_buffer_insert(buffer, &iter, buf, bufp - buf);
 
        if (prefs_common.enable_color) {
                link_color = &uri_color;
@@ -1718,6 +1734,8 @@ static void textview_smooth_scroll_do(TextView *textview,
 
        vadj->value = last_value;
        g_signal_emit_by_name(G_OBJECT(vadj), "value_changed", 0);
+
+       gtk_widget_queue_draw(GTK_WIDGET(text));
 }
 
 static void textview_smooth_scroll_one_line(TextView *textview, gboolean up)
@@ -2069,8 +2087,6 @@ static gboolean textview_uri_button_pressed(GtkTextTag *tag, GObject *obj,
 {
        GdkEventButton *bevent;
        RemoteURI *uri = NULL;
-       GSList *cur;
-       gchar *trimmed_uri;
 
        if (!event)
                return FALSE;
@@ -2307,7 +2323,8 @@ static void copy_uri_cb   (TextView *textview, guint action, void *data)
        if (uri == NULL)
                return;
 
-       gtk_clipboard_set_text(gtk_clipboard_get(GDK_NONE), uri->uri, -1);
+       gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY), uri->uri, -1);
+       gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD), uri->uri, -1);
        g_object_set_data(G_OBJECT(textview->link_popup_menu), "menu_button",
                          NULL);
 }
@@ -2359,7 +2376,8 @@ static void copy_mail_to_uri_cb   (TextView *textview, guint action, void *data)
        if (uri == NULL)
                return;
 
-       gtk_clipboard_set_text(gtk_clipboard_get(GDK_NONE), uri->uri + 7, -1);
+       gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY), uri->uri +7, -1);
+       gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD), uri->uri +7, -1);
        g_object_set_data(G_OBJECT(textview->mail_popup_menu), "menu_button",
                          NULL);
 }