2005-07-20 [colin] 1.9.12cvs87
[claws.git] / src / textview.c
index 2756dad49d151ac9c1181b91b1d8bc6a48e08ceb..09c59dc3545e74cdefba161f0e0bc79f859a5967 100644 (file)
@@ -836,7 +836,7 @@ static gboolean get_uri_part(const gchar *start, const gchar *scanpos,
        for (ep_ = scanpos; *ep_ != '\0'; ep_++) {
                if (!isgraph(*(const guchar *)ep_) ||
                    !IS_ASCII(*(const guchar *)ep_) ||
-                   strchr("()<>\"", *ep_))
+                   strchr("[]{}()<>\"", *ep_))
                        break;
        }
 
@@ -1158,7 +1158,8 @@ static void textview_make_clickable_parts(TextView *textview,
        GtkTextView *text = GTK_TEXT_VIEW(textview->text);
        GtkTextBuffer *buffer = gtk_text_view_get_buffer(text);
        GtkTextIter iter;
-
+       gchar *mybuf = g_strdup(linebuf);
+       
        /* parse table - in order of priority */
        struct table {
                const gchar *needle; /* token */
@@ -1195,10 +1196,15 @@ static void textview_make_clickable_parts(TextView *textview,
                struct txtpos   *next;          /* next */
        } head = {NULL, NULL, 0,  NULL}, *last = &head;
 
+       if (!g_utf8_validate(linebuf, -1, NULL)) {
+               mybuf = g_malloc(strlen(linebuf)*2 +1);
+               conv_localetodisp(mybuf, strlen(linebuf)*2 +1, linebuf);
+       }
+
        gtk_text_buffer_get_end_iter(buffer, &iter);
 
        /* parse for clickable parts, and build a list of begin and end positions  */
-       for (walk = linebuf, n = 0;;) {
+       for (walk = mybuf, n = 0;;) {
                gint last_index = PARSE_ELEMS;
                gchar *scanpos = NULL;
 
@@ -1230,7 +1236,7 @@ static void textview_make_clickable_parts(TextView *textview,
 
        /* colorize this line */
        if (head.next) {
-               const gchar *normal_text = linebuf;
+               const gchar *normal_text = mybuf;
 
                /* insert URIs */
                for (last = head.next; last != NULL;
@@ -1260,8 +1266,9 @@ static void textview_make_clickable_parts(TextView *textview,
                                (buffer, &iter, normal_text, -1, fg_tag, NULL);
        } else {
                gtk_text_buffer_insert_with_tags_by_name
-                       (buffer, &iter, linebuf, -1, fg_tag, NULL);
+                       (buffer, &iter, mybuf, -1, fg_tag, NULL);
        }
+       g_free(mybuf);
 }
 
 #undef ADD_TXT_POS
@@ -1284,8 +1291,8 @@ static void textview_write_line(TextView *textview, const gchar *str,
        if (!conv)
                strncpy2(buf, str, sizeof(buf));
        else if (conv_convert(conv, buf, sizeof(buf), str) < 0)
-               conv_utf8todisp(buf, sizeof(buf), str);
-
+               conv_localetodisp(buf, sizeof(buf), str);
+               
        strcrchomp(buf);
        //if (prefs_common.conv_mb_alnum) conv_mb_alnum(buf);
        fg_color = NULL;
@@ -2203,11 +2210,12 @@ static gboolean textview_uri_security_check(TextView *textview, RemoteURI *uri)
 
                msg = g_strdup_printf(_("The real URL (%s) is different from\n"
                                        "the apparent URL (%s).\n"
+                                       "\n"
                                        "Open it anyway?"),
                                      uri->uri, visible_str);
-               aval = alertpanel_with_type(_("Warning"), msg,
-                                           GTK_STOCK_YES, GTK_STOCK_NO,
-                                           NULL, NULL, ALERT_WARNING);
+               aval = alertpanel_full(_("Fake URL warning"), msg,
+                                      GTK_STOCK_YES, GTK_STOCK_NO, NULL, FALSE,
+                                      NULL, ALERT_WARNING, G_ALERTALTERNATE);
                g_free(msg);
                if (aval == G_ALERTDEFAULT)
                        retval = TRUE;