2005-02-25 [paul] 1.0.1cvs15.12
authorPaul Mangan <paul@claws-mail.org>
Fri, 25 Feb 2005 09:02:57 +0000 (09:02 +0000)
committerPaul Mangan <paul@claws-mail.org>
Fri, 25 Feb 2005 09:02:57 +0000 (09:02 +0000)
* src/alertpanel.c
* src/codeconv.c
* src/compose.c
* src/textview.c
* src/gtk/gtkutils.c
* src/gtk/gtkutils.h
* src/gtk/logwindow.c
* src/gtk/progressdialog.c
sync with main (revision 127)
and fix logwindow clipping

ChangeLog-gtk2.claws
PATCHSETS
configure.ac
src/alertpanel.c
src/codeconv.c
src/compose.c
src/gtk/gtkutils.c
src/gtk/gtkutils.h
src/gtk/logwindow.c
src/gtk/progressdialog.c
src/textview.c

index 12f5298..797468b 100644 (file)
@@ -1,3 +1,16 @@
+2005-02-25 [paul]      1.0.1cvs15.12
+
+       * src/alertpanel.c
+       * src/codeconv.c
+       * src/compose.c
+       * src/textview.c
+       * src/gtk/gtkutils.c
+       * src/gtk/gtkutils.h
+       * src/gtk/logwindow.c
+       * src/gtk/progressdialog.c
+               sync with main (revision 127)
+               and fix logwindow clipping
+
 2005-02-24 [colin]     1.0.1cvs15.11
 
        * src/plugins/pgpmime/passphrase.c
index 7d06470..cf79063 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.395.2.56 -r 1.395.2.57 src/summaryview.c; ) > 1.0.1cvs15.9.patchset
 ( cvs diff -u -r 1.94.2.46 -r 1.94.2.47 src/messageview.c; ) > 1.0.1cvs15.10.patchset
 ( cvs diff -u -r 1.1.2.4 -r 1.1.2.5 src/plugins/pgpmime/passphrase.c; ) > 1.0.1cvs15.11.patchset
+( cvs diff -u -r 1.17.2.11 -r 1.17.2.12 src/alertpanel.c; cvs diff -u -r 1.65.2.24 -r 1.65.2.25 src/codeconv.c; cvs diff -u -r 1.382.2.107 -r 1.382.2.108 src/compose.c; cvs diff -u -r 1.96.2.48 -r 1.96.2.49 src/textview.c; cvs diff -u -r 1.5.2.9 -r 1.5.2.10 src/gtk/gtkutils.c; cvs diff -u -r 1.4.2.7 -r 1.4.2.8 src/gtk/gtkutils.h; cvs diff -u -r 1.1.4.7 -r 1.1.4.8 src/gtk/logwindow.c; cvs diff -u -r 1.1.4.7 -r 1.1.4.8 src/gtk/progressdialog.c; ) > 1.0.1cvs15.12.patchset
index f86cfd0..2596bc4 100644 (file)
@@ -13,7 +13,7 @@ INTERFACE_AGE=0
 BINARY_AGE=0
 EXTRA_VERSION=15
 EXTRA_RELEASE=
-EXTRA_GTK2_VERSION=.11
+EXTRA_GTK2_VERSION=.12
 
 if test \( $EXTRA_VERSION -eq 0 \) -o \( "x$EXTRA_RELEASE" != "x" \); then
     VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}${EXTRA_RELEASE}${EXTRA_GTK2_VERSION}
index 03ff73c..a708615 100644 (file)
@@ -259,18 +259,15 @@ static void alertpanel_create(const gchar *title,
        gtk_window_set_title(GTK_WINDOW(dialog), title);
        gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
        gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
-       gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
        
-       gtk_container_set_border_width
-               (GTK_CONTAINER(GTK_DIALOG(dialog)->action_area), 5);
        gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER);
+       gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
        g_signal_connect(G_OBJECT(dialog), "delete_event",
                         G_CALLBACK(alertpanel_deleted),
                         (gpointer)G_ALERTOTHER);
        g_signal_connect(G_OBJECT(dialog), "key_press_event",
                         G_CALLBACK(alertpanel_close),
                         (gpointer)G_ALERTOTHER);
-       gtk_widget_realize(dialog);
 
        gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 14);
        hbox = gtk_hbox_new (FALSE, 12);
@@ -299,18 +296,20 @@ static void alertpanel_create(const gchar *title,
        gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
        gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
        gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
+       gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
        if (!font_desc) {
                gint size;
 
-               size = pango_font_description_get_size(label->style->font_desc);
+               size = pango_font_description_get_size
+                       (label->style->font_desc);
                font_desc = pango_font_description_new();
-               pango_font_description_set_weight(font_desc, PANGO_WEIGHT_BOLD);
+               pango_font_description_set_weight
+                       (font_desc, PANGO_WEIGHT_BOLD);
                pango_font_description_set_size
-                       (font_desc, size * PANGO_SCALE_X_LARGE);
+                       (font_desc, size * PANGO_SCALE_LARGE);
        }
        if (font_desc)
                gtk_widget_modify_font(label, font_desc);
-       gtk_widget_show(label);
        g_free(title_full);
        
        label = gtk_label_new(message);
@@ -326,16 +325,20 @@ static void alertpanel_create(const gchar *title,
        }
        
        if (can_disable) {
+               hbox = gtk_hbox_new(FALSE, 0);
+               gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox,
+                                  FALSE, FALSE, 0);
+
                disable_chkbtn = gtk_check_button_new_with_label
                        (_("Show this message next time"));
                gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(disable_chkbtn),
                                             TRUE);
-               gtk_box_pack_start(GTK_BOX(vbox), disable_chkbtn,
-                                  FALSE, FALSE, 0);
+               gtk_box_pack_start(GTK_BOX(hbox), disable_chkbtn,
+                                  FALSE, FALSE, 12);
                g_signal_connect(G_OBJECT(disable_chkbtn), "toggled",
                                 G_CALLBACK(alertpanel_button_toggled),
                                 GUINT_TO_POINTER(G_ALERTDISABLE));
-       } 
+       }
 
        /* for button(s) */
        if (!button1_label)
@@ -350,7 +353,9 @@ static void alertpanel_create(const gchar *title,
                                      button2_label ? &button2 : NULL, label2,
                                      button3_label ? &button3 : NULL, label3);
 
-       gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->action_area), confirm_area, FALSE, FALSE, 12);
+       gtk_box_pack_end(GTK_BOX(GTK_DIALOG(dialog)->action_area),
+                        confirm_area, FALSE, FALSE, 0);
+       gtk_container_set_border_width(GTK_CONTAINER(confirm_area), 5);
        gtk_widget_grab_default(button1);
        gtk_widget_grab_focus(button1);
        if (button2_label && *button2_label == '+') {
@@ -399,7 +404,7 @@ static gint alertpanel_deleted(GtkWidget *widget, GdkEventAny *event,
 }
 
 static gboolean alertpanel_close(GtkWidget *widget, GdkEventAny *event,
-                            gpointer data)
+                                gpointer data)
 {
        if (event->type == GDK_KEY_PRESS)
                if (((GdkEventKey *)event)->keyval != GDK_Escape)
index 4633d36..89a2e5a 100644 (file)
@@ -655,7 +655,7 @@ static void conv_unreadable_latin(gchar *str)
                /* convert CR+LF -> LF */
                if (*p == '\r' && *(p + 1) == '\n')
                        memmove(p, p + 1, strlen(p));
-               else if ((*p & 0xff) >= 0x7f)
+               else if ((*p & 0xff) >= 0x7f && (*p & 0xff) <= 0x9f)
                        *p = SUBST_CHAR;
                p++;
        }
@@ -795,6 +795,8 @@ void conv_utf8todisp(gchar *outbuf, gint outlen, const gchar *inbuf)
 static void conv_anytodisp(gchar *outbuf, gint outlen, const gchar *inbuf)
 {
        conv_anytoutf8(outbuf, outlen, inbuf);
+       if (g_utf8_validate(outbuf, -1, NULL) != TRUE)
+               conv_unreadable_8bit(outbuf);
 }
 
 static void conv_ustodisp(gchar *outbuf, gint outlen, const gchar *inbuf)
@@ -813,7 +815,7 @@ void conv_localetodisp(gchar *outbuf, gint outlen, const gchar *inbuf)
                strncpy2(outbuf, tmpstr, outlen);
                g_free(tmpstr);
        } else
-               strncpy2(outbuf, inbuf, outlen);
+               conv_utf8todisp(outbuf, outlen, inbuf);
 }
 
 static void conv_noconv(gchar *outbuf, gint outlen, const gchar *inbuf)
@@ -1543,57 +1545,33 @@ void conv_unmime_header_overwrite(gchar *str)
 {
        gchar *buf;
        gint buflen;
-       CharSet cur_charset;
 
-       cur_charset = conv_get_locale_charset();
+       buflen = strlen(str) * 2 + 1;
+       Xalloca(buf, buflen, return);
 
-       if (cur_charset == C_EUC_JP) {
-               buflen = strlen(str) * 2 + 1;
-               Xalloca(buf, buflen, return);
+       if (conv_get_locale_charset() == C_EUC_JP)
                conv_anytodisp(buf, buflen, str);
-               unmime_header(str, buf);
-       } else {
-               buflen = strlen(str) + 1;
-               Xalloca(buf, buflen, return);
-               unmime_header(buf, str);
-               strncpy2(str, buf, buflen);
-       }
+       else
+               conv_localetodisp(buf, buflen, str);
+
+       unmime_header(str, buf);
 }
 
 void conv_unmime_header(gchar *outbuf, gint outlen, const gchar *str,
                        const gchar *charset)
 {
-       CharSet cur_charset;
-
-       cur_charset = conv_get_locale_charset();
+       gchar *buf;
+       gint buflen;
 
-       if (cur_charset == C_EUC_JP) {
-               gchar *buf;
-               gint buflen;
+       buflen = strlen(str) * 2 + 1;
+       Xalloca(buf, buflen, return);
 
-               buflen = strlen(str) * 2 + 1;
-               Xalloca(buf, buflen, return);
+       if (conv_get_locale_charset() == C_EUC_JP)
                conv_anytodisp(buf, buflen, str);
-               unmime_header(outbuf, buf);
-       } else {
-               gchar *tmp = NULL;
-               unmime_header(outbuf, str);
-
-               if (outbuf && !g_utf8_validate(outbuf, -1, NULL)) {
-                       if (conv_get_locale_charset() != C_INTERNAL)
-                               tmp = conv_codeset_strdup(outbuf,
-                                       conv_get_locale_charset_str(),
-                                       CS_INTERNAL);
-
-                       if (tmp) {
-                               strncpy(outbuf, tmp, outlen-1);
-                               g_free(tmp);
-                       } else {
-                               conv_unreadable_8bit(outbuf);
-                       }
-               }
-       }
+       else
+               conv_localetodisp(buf, buflen, str);
 
+       unmime_header(outbuf, buf);
 }
 
 #define MAX_LINELEN            76
index fda61e2..edf81cf 100644 (file)
@@ -2109,8 +2109,8 @@ static void compose_insert_sig(Compose *compose, gboolean replace)
        if (cur_pos > gtk_text_buffer_get_char_count (buffer))
                cur_pos = gtk_text_buffer_get_char_count (buffer);
 
-       gtk_text_buffer_get_iter_at_offset (buffer, &iter, cur_pos);
-       gtk_text_buffer_place_cursor (buffer, &iter);
+       gtk_text_buffer_get_iter_at_offset(buffer, &iter, cur_pos);
+       gtk_text_buffer_place_cursor(buffer, &iter);
 
        g_signal_handlers_unblock_by_func(G_OBJECT(buffer),
                                        G_CALLBACK(compose_changed_cb),
@@ -2122,6 +2122,7 @@ static gchar *compose_get_signature_str(Compose *compose)
 {
        gchar *sig_body = NULL;
        gchar *sig_str = NULL;
+       gchar *utf8_sig_str = NULL;
 
        g_return_val_if_fail(compose->account != NULL, NULL);
 
@@ -2148,15 +2149,20 @@ static gchar *compose_get_signature_str(Compose *compose)
                g_free(tmp);
        }
 
-       if (compose->account->sig_sep)
+       if (compose->account->sig_sep) {
                sig_str = g_strconcat("\n\n", compose->account->sig_sep, "\n", sig_body,
                                      NULL);
-       else
+               g_free(sig_body);
+       } else
                sig_str = g_strconcat("\n\n", sig_body, NULL);
 
-       g_free(sig_body);
-       
-       return sig_str;
+       if (sig_str) {
+               utf8_sig_str = conv_codeset_strdup
+                       (sig_str, conv_get_locale_charset_str(), CS_INTERNAL);
+               g_free(sig_str);
+       }
+
+       return utf8_sig_str;
 }
 
 static ComposeInsertResult compose_insert_file(Compose *compose, const gchar *file)
@@ -2169,6 +2175,7 @@ static ComposeInsertResult compose_insert_file(Compose *compose, const gchar *fi
        gchar buf[BUFFSIZE];
        gint len;
        FILE *fp;
+       gboolean prev_autowrap;
        gboolean badtxt = FALSE;
 
        g_return_val_if_fail(file != NULL, COMPOSE_INSERT_NO_FILE);
@@ -2189,6 +2196,9 @@ static ComposeInsertResult compose_insert_file(Compose *compose, const gchar *fi
 
        cur_encoding = conv_get_locale_charset_str();
 
+       prev_autowrap = compose->autowrap;
+       compose->autowrap = FALSE;
+
        while (fgets(buf, sizeof(buf), fp) != NULL) {
                gchar *str;
 
@@ -2211,6 +2221,9 @@ static ComposeInsertResult compose_insert_file(Compose *compose, const gchar *fi
        g_signal_handlers_unblock_by_func(G_OBJECT(buffer),
                                          G_CALLBACK(text_inserted),
                                          compose);
+       compose->autowrap = prev_autowrap;
+       if (compose->autowrap)
+               compose_wrap_all(compose);
 
        fclose(fp);
 
@@ -2563,7 +2576,12 @@ static gboolean compose_get_line_break_pos(GtkTextBuffer *buffer,
                wc = g_utf8_get_char(p);
                if (i >= quote_len && !g_unichar_isspace(wc))
                        break;
-               col += g_unichar_iswide(wc) ? 2 : 1;
+               if (g_unichar_iswide(wc))
+                       col += 2;
+               else if (*p == '\t')
+                       col += 8;
+               else
+                       col++;
                p = g_utf8_next_char(p);
        }
 
@@ -2589,7 +2607,12 @@ static gboolean compose_get_line_break_pos(GtkTextBuffer *buffer,
                }
 
                wc = g_utf8_get_char(p);
-               col += g_unichar_iswide(wc) ? 2 : 1;
+               if (g_unichar_iswide(wc))
+                       col += 2;
+               else if (*p == '\t')
+                       col += 8;
+               else
+                       col++;
                if (pos > 0 && col > max_col) {
                        do_break = TRUE;
                        break;
@@ -2649,6 +2672,7 @@ static gboolean compose_join_next_line(GtkTextBuffer *buffer,
        gchar *next_quote_str;
        gunichar wc1, wc2;
        gint quote_len;
+       gboolean keep_cursor = FALSE;
 
        if (!gtk_text_iter_forward_line(&iter_) ||
            gtk_text_iter_ends_line(&iter_))
@@ -2689,8 +2713,15 @@ static gboolean compose_join_next_line(GtkTextBuffer *buffer,
                gtk_text_iter_forward_char(&cur);
                next = cur;
        }
-       if (!gtk_text_iter_equal(&prev, &next))
+       if (!gtk_text_iter_equal(&prev, &next)) {
+               GtkTextMark *mark;
+
+               mark = gtk_text_buffer_get_insert(buffer);
+               gtk_text_buffer_get_iter_at_mark(buffer, &cur, mark);
+               if (gtk_text_iter_equal(&prev, &cur))
+                       keep_cursor = TRUE;
                gtk_text_buffer_delete(buffer, &prev, &next);
+       }
        iter_ = prev;
 
        /* insert space if required */
@@ -2701,8 +2732,13 @@ static gboolean compose_join_next_line(GtkTextBuffer *buffer,
        str = gtk_text_buffer_get_text(buffer, &prev, &next, FALSE);
        pango_default_break(str, -1, NULL, attrs, 3);
        if (!attrs[1].is_line_break ||
-           (!g_unichar_iswide(wc1) || !g_unichar_iswide(wc2)))
+           (!g_unichar_iswide(wc1) || !g_unichar_iswide(wc2))) {
                gtk_text_buffer_insert(buffer, &iter_, " ", 1);
+               if (keep_cursor) {
+                       gtk_text_iter_backward_char(&iter_);
+                       gtk_text_buffer_place_cursor(buffer, &iter_);
+               }
+       }
        g_free(str);
 
        *iter = iter_;
@@ -2763,7 +2799,29 @@ static void compose_wrap_paragraph(Compose *compose, GtkTextIter *par_iter)
                if (compose_get_line_break_pos(buffer, &iter, &break_pos,
                                               prefs_common.linewrap_len,
                                               quote_len)) {
+                       GtkTextIter prev, next, cur;
+
                        gtk_text_buffer_insert(buffer, &break_pos, "\n", 1);
+
+                       /* remove trailing spaces */
+                       cur = break_pos;
+                       gtk_text_iter_backward_char(&cur);
+                       prev = next = cur;
+                       while (!gtk_text_iter_starts_line(&cur)) {
+                               gunichar wc;
+
+                               gtk_text_iter_backward_char(&cur);
+                               wc = gtk_text_iter_get_char(&cur);
+                               if (!g_unichar_isspace(wc))
+                                       break;
+                               prev = cur;
+                       }
+                       if (!gtk_text_iter_equal(&prev, &next)) {
+                               gtk_text_buffer_delete(buffer, &prev, &next);
+                               break_pos = next;
+                               gtk_text_iter_forward_char(&break_pos);
+                       }
+
                        if (quote_str)
                                gtk_text_buffer_insert(buffer, &break_pos,
                                                       quote_str, -1);
@@ -6351,12 +6409,20 @@ static void compose_destroy_cb(GtkWidget *widget, Compose *compose)
 
 static void compose_undo_cb(Compose *compose)
 {
+       gboolean prev_autowrap = compose->autowrap;
+
+       compose->autowrap = FALSE;
        undo_undo(compose->undostruct);
+       compose->autowrap = prev_autowrap;
 }
 
 static void compose_redo_cb(Compose *compose)
 {
+       gboolean prev_autowrap = compose->autowrap;
+       
+       compose->autowrap = FALSE;
        undo_redo(compose->undostruct);
+       compose->autowrap = prev_autowrap;
 }
 
 static void entry_cut_clipboard(GtkWidget *entry)
@@ -6410,7 +6476,6 @@ static void entry_allsel(GtkWidget *entry)
        }
 }
 
-
 static void compose_cut_cb(Compose *compose)
 {
        if (compose->focused_editable &&
index fb714dc..b23177c 100644 (file)
@@ -516,6 +516,141 @@ void gtkut_container_remove(GtkContainer *container, GtkWidget *widget)
        gtk_container_remove(container, widget);
 }
 
+gboolean gtkut_text_buffer_match_string(GtkTextBuffer *textbuf,
+                                       const GtkTextIter *iter,
+                                       gunichar *wcs, gint len,
+                                       gboolean case_sens)
+{
+       GtkTextIter start_iter, end_iter;
+       gchar *utf8str, *p;
+       gint match_count;
+
+       start_iter = end_iter = *iter;
+       gtk_text_iter_forward_chars(&end_iter, len);
+
+       utf8str = gtk_text_buffer_get_text(textbuf, &start_iter, &end_iter,
+                                          FALSE);
+       if (!utf8str) return FALSE;
+
+       if ((gint)g_utf8_strlen(utf8str, -1) != len) {
+               g_free(utf8str);
+               return FALSE;
+       }
+
+       for (p = utf8str, match_count = 0;
+            *p != '\0' && match_count < len;
+            p = g_utf8_next_char(p), match_count++) {
+               gunichar wc;
+
+               wc = g_utf8_get_char(p);
+
+               if (case_sens) {
+                       if (wc != wcs[match_count])
+                               break;
+               } else {
+                       if (g_unichar_tolower(wc) !=
+                           g_unichar_tolower(wcs[match_count]))
+                               break;
+               }
+       }
+
+       g_free(utf8str);
+
+       if (match_count == len)
+               return TRUE;
+       else
+               return FALSE;
+}
+
+gboolean gtkut_text_buffer_find(GtkTextBuffer *buffer, const GtkTextIter *iter,
+                               const gchar *str, gboolean case_sens,
+                               GtkTextIter *match_pos)
+{
+       gunichar *wcs;
+       gint len;
+       glong items_read = 0, items_written = 0;
+       GError *error = NULL;
+       GtkTextIter iter_;
+       gboolean found = FALSE;
+
+       wcs = g_utf8_to_ucs4(str, -1, &items_read, &items_written, &error);
+       if (error != NULL) {
+               g_warning("An error occured while converting a string from UTF-8 to UCS-4: %s\n",
+                         error->message);
+               g_error_free(error);
+       }
+       if (!wcs || items_written <= 0) return FALSE;
+       len = (gint)items_written;
+
+       iter_ = *iter;
+       do {
+               found = gtkut_text_buffer_match_string
+                       (buffer, &iter_, wcs, len, case_sens);
+               if (found) {
+                       *match_pos = iter_;
+                       break;
+               }
+       } while (gtk_text_iter_forward_char(&iter_));
+
+       g_free(wcs);
+
+       return found;
+}
+
+gboolean gtkut_text_buffer_find_backward(GtkTextBuffer *buffer,
+                                        const GtkTextIter *iter,
+                                        const gchar *str, gboolean case_sens,
+                                        GtkTextIter *match_pos)
+{
+       gunichar *wcs;
+       gint len;
+       glong items_read = 0, items_written = 0;
+       GError *error = NULL;
+       GtkTextIter iter_;
+       gboolean found = FALSE;
+
+       wcs = g_utf8_to_ucs4(str, -1, &items_read, &items_written, &error);
+       if (error != NULL) {
+               g_warning("An error occured while converting a string from UTF-8 to UCS-4: %s\n", error->message);
+               g_error_free(error);
+       }
+       if (!wcs || items_written <= 0) return FALSE;
+       len = (gint)items_written;
+
+       iter_ = *iter;
+       while (gtk_text_iter_backward_char(&iter_)) {
+               found = gtkut_text_buffer_match_string
+                       (buffer, &iter_, wcs, len, case_sens);
+               if (found) {
+                       *match_pos = iter_;
+                       break;
+               }
+       }
+
+       g_free(wcs);
+
+       return found;
+}
+
+gchar *gtkut_text_view_get_selection(GtkTextView *textview)
+{
+       GtkTextBuffer *buffer;
+       GtkTextIter start_iter, end_iter;
+       gboolean found;
+
+       g_return_val_if_fail(GTK_IS_TEXT_VIEW(textview), NULL);
+
+       buffer = gtk_text_view_get_buffer(textview);
+       found = gtk_text_buffer_get_selection_bounds(buffer,
+                                                    &start_iter,
+                                                    &end_iter);
+       if (found)
+               return gtk_text_buffer_get_text(buffer, &start_iter, &end_iter,
+                                               FALSE);
+       else
+               return NULL;
+}
+
 void gtkut_window_popup(GtkWidget *window)
 {
        gint x, y, sx, sy, new_x, new_y;
@@ -555,26 +690,6 @@ void gtkut_widget_get_uposition(GtkWidget *widget, gint *px, gint *py)
        *py = y;
 }
 
-void gtkut_widget_disable_theme_engine(GtkWidget *widget)
-{
-#warning FIXME_GTK2
-#if 0
-       GtkStyle *style, *new_style;
-
-       style = gtk_widget_get_style(widget);
-
-       if (style->engine) {
-               GtkThemeEngine *engine;
-
-               engine = style->engine;
-               style->engine = NULL;
-               new_style = gtk_style_copy(style);
-               style->engine = engine;
-               gtk_widget_set_style(widget, new_style);
-       }
-#endif
-}
-
 void gtkut_widget_wait_for_draw(GtkWidget *widget)
 {
        if (!GTK_WIDGET_DRAWABLE(widget)) return;
@@ -698,188 +813,6 @@ void gtkut_set_widget_bgcolor_rgb(GtkWidget *widget, guint rgbvalue)
        gtk_widget_set_style(widget, newstyle);
 }
   
-gboolean gtkut_text_buffer_match_string(GtkTextBuffer *textbuf, gint pos, gunichar *wcs,
-                                       gint len, gboolean case_sens)
-{
-       GtkTextIter start_iter, end_iter;
-       gchar *utf8str;
-       gint match_count = 0;
-
-       gtk_text_buffer_get_iter_at_offset(textbuf, &start_iter, pos);
-       gtk_text_buffer_get_iter_at_offset(textbuf, &end_iter, pos + len);
-
-       utf8str = gtk_text_buffer_get_text(textbuf, &start_iter, &end_iter, FALSE);
-       if (!utf8str) return FALSE;
-
-       if ((gint) g_utf8_strlen(utf8str, -1) != len) {
-               g_free(utf8str);
-               return FALSE;
-       }
-
-       for (; match_count < len; match_count++) {
-               gchar *ptr;
-               gunichar ch;
-
-               ptr = g_utf8_offset_to_pointer(utf8str, match_count);
-               if (!ptr) break;
-               ch = g_utf8_get_char(ptr);
-
-               if (case_sens) {
-                       if (ch != wcs[match_count])
-                               break;
-               } else {
-                       if (g_unichar_tolower(ch) !=
-                           g_unichar_tolower(wcs[match_count]))
-                               break;
-               }
-       }
-
-       g_free(utf8str);
-
-       if (match_count == len)
-               return TRUE;
-       else
-               return FALSE;
-}
-
-guint gtkut_text_buffer_str_compare_n(GtkTextBuffer *textbuf,
-                                     guint pos1, guint pos2,
-                                     guint len, guint text_len)
-{
-       guint i;
-
-       for (i = 0; i < len && pos1 + i < text_len && pos2 + i < text_len; i++) {
-               GtkTextIter start_iter, end_iter;
-               gchar *utf8str1, *utf8str2;
-
-               gtk_text_buffer_get_iter_at_offset(textbuf, &start_iter,
-                                                  pos1 + i);
-               gtk_text_buffer_get_iter_at_offset(textbuf, &end_iter,
-                                                  pos1 + i + 1);
-               utf8str1 = gtk_text_buffer_get_text(textbuf,
-                                                   &start_iter,
-                                                   &end_iter,
-                                                   FALSE);
-
-               gtk_text_buffer_get_iter_at_offset(textbuf, &start_iter,
-                                                  pos2 + i);
-               gtk_text_buffer_get_iter_at_offset(textbuf, &end_iter,
-                                                  pos2 + i + 1);
-               utf8str2 = gtk_text_buffer_get_text(textbuf,
-                                                   &start_iter,
-                                                   &end_iter,
-                                                   FALSE);
-
-               if (!utf8str1 || !utf8str2 || strcmp(utf8str1, utf8str2)) {
-                       g_free(utf8str1);
-                       g_free(utf8str2);
-                       break;
-               }
-
-               g_free(utf8str1);
-               g_free(utf8str2);
-       }
-
-       return i;
-}
-
-guint gtkut_text_buffer_str_compare(GtkTextBuffer *textbuf,
-                                   guint start_pos, guint text_len,
-                                   const gchar *str)
-{
-       gunichar *wcs;
-       guint len = 0;
-       glong items_read = 0, items_written = 0;
-       gboolean result;
-       GError *error = NULL;
-
-       if (!str) return 0;
-
-       wcs = g_utf8_to_ucs4(str, -1, &items_read, &items_written, &error);
-       if (error != NULL) {
-               g_warning("An error occured while converting a string from UTF-8 to UCS-4: %s\n",
-                         error->message);
-               g_error_free(error);
-       }
-       if (!wcs || items_written <= 0) return 0;
-       len = (guint) items_written;
-
-       if (len > text_len - start_pos)
-               result = FALSE;
-       else
-               result = gtkut_text_buffer_match_string(textbuf, start_pos,
-                                                       wcs, len,
-                                                       TRUE);
-
-       g_free(wcs);
-
-       return result ? len : 0;
-}
-
-gint gtkut_text_buffer_find(GtkTextBuffer *buffer, guint start_pos,
-                           const gchar *str, gboolean case_sens)
-{
-       gint pos;
-       gunichar *wcs;
-       gint len;
-       glong items_read = 0, items_written = 0;
-       GError *error = NULL;
-       GtkTextIter iter;
-       gint found_pos = -1;
-
-       wcs = g_utf8_to_ucs4(str, -1, &items_read, &items_written, &error);
-       if (error != NULL) {
-               g_warning("An error occured while converting a string from UTF-8 to UCS-4: %s\n", error->message);
-               g_error_free(error);
-       }
-       if (!wcs || items_written <= 0) return -1;
-       len = (gint)items_written;
-
-       gtk_text_buffer_get_iter_at_offset(buffer, &iter, start_pos);
-       do {
-               pos = gtk_text_iter_get_offset(&iter);
-               if (gtkut_text_buffer_match_string
-                       (buffer, pos, wcs, len, case_sens) == TRUE) {
-                       found_pos = pos;
-                       break;
-               }
-       } while (gtk_text_iter_forward_char(&iter));
-
-       g_free(wcs);
-       return found_pos;
-}
-
-gboolean gtkut_text_buffer_is_uri_string(GtkTextBuffer *textbuf,
-                                        guint start_pos, guint text_len)
-{
-       if (gtkut_text_buffer_str_compare(textbuf, start_pos, text_len, "http://")  ||
-           gtkut_text_buffer_str_compare(textbuf, start_pos, text_len, "ftp://")   ||
-           gtkut_text_buffer_str_compare(textbuf, start_pos, text_len, "https://") ||
-           gtkut_text_buffer_str_compare(textbuf, start_pos, text_len, "www."))
-               return TRUE;
-
-       return FALSE;
-}
-  
-gchar *gtkut_text_view_get_selection(GtkTextView *textview)
-{
-       GtkTextBuffer *buffer;
-       GtkTextIter start_iter, end_iter;
-       gboolean found;
-
-       g_return_val_if_fail(GTK_IS_TEXT_VIEW(textview), NULL);
-
-       buffer = gtk_text_view_get_buffer(textview);
-       found = gtk_text_buffer_get_selection_bounds(buffer,
-                                                    &start_iter,
-                                                    &end_iter);
-       if (found)
-               return gtk_text_buffer_get_text(buffer, &start_iter, &end_iter,
-                                               FALSE);
-       else
-               return NULL;
-}
-
 /*!
  *\brief       Tries to find a focused child using a lame strategy
  */
index 40a3c30..9850886 100644 (file)
@@ -151,13 +151,29 @@ void gtkut_editable_disable_im            (GtkEditable    *editable);
 void gtkut_container_remove            (GtkContainer   *container,
                                         GtkWidget      *widget);
 
+gboolean gtkut_text_buffer_match_string        (GtkTextBuffer          *buffer,
+                                        const GtkTextIter      *iter,
+                                        gunichar               *wcs,
+                                        gint                    len,
+                                        gboolean                case_sens);
+gboolean gtkut_text_buffer_find                (GtkTextBuffer          *buffer,
+                                        const GtkTextIter      *iter,
+                                        const gchar            *str,
+                                        gboolean                case_sens,
+                                        GtkTextIter            *match_pos);
+gboolean gtkut_text_buffer_find_backward(GtkTextBuffer         *buffer,
+                                        const GtkTextIter      *iter,
+                                        const gchar            *str,
+                                        gboolean                case_sens,
+                                        GtkTextIter            *match_pos);
+
+gchar *gtkut_text_view_get_selection   (GtkTextView    *textview);
 
 void gtkut_window_popup                        (GtkWidget      *window);
 
 void gtkut_widget_get_uposition                (GtkWidget      *widget,
                                         gint           *px,
                                         gint           *py);
-void gtkut_widget_disable_theme_engine (GtkWidget      *widget);
 void gtkut_widget_wait_for_draw                (GtkWidget      *widget);
 void gtkut_widget_init                 (void);
 
@@ -171,23 +187,5 @@ GtkWidget *gtkut_account_menu_new  (GList                  *ac_list,
 void gtkut_set_widget_bgcolor_rgb      (GtkWidget      *widget,
                                         guint           rgbvalue);
 
-gboolean gtkut_text_buffer_match_string        (GtkTextBuffer  *text,
-                                        gint            pos,
-                                        gunichar       *wcs,
-                                        gint            len,
-                                        gboolean        case_sens);
-guint gtkut_text_buffer_str_compare_n  (GtkTextBuffer  *text,
-                                        guint           pos1,
-                                        guint           pos2,
-                                        guint           len,
-                                        guint           text_len);
-guint gtkut_text_buffer_str_compare    (GtkTextBuffer  *text,
-                                        guint           start_pos,
-                                        guint           text_len,
-                                        const gchar    *str);
-gboolean gtkut_text_buffer_is_uri_string(GtkTextBuffer *text,
-                                        guint           start_pos,
-                                        guint           text_len);
-gchar *gtkut_text_view_get_selection   (GtkTextView    *textview);
 GtkWidget *gtkut_get_focused_child     (GtkContainer   *parent);
 #endif /* __GTKUTILS_H__ */
index c6cb6a8..d20f081 100644 (file)
@@ -105,8 +105,6 @@ void log_window_init(LogWindow *logwin)
        gboolean success[3];
        gint i;
 
-       gtkut_widget_disable_theme_engine(logwin->text);
-
        logwin->msg_color   = color[0];
        logwin->warn_color  = color[1];
        logwin->error_color = color[2];
@@ -208,13 +206,13 @@ static gboolean log_window_append(gpointer source, gpointer data)
                                                 tag, NULL);
 
        gtk_text_buffer_get_start_iter(buffer, &iter);
-       gtk_text_buffer_place_cursor(buffer, &iter);
 
        if (logwindow->clip)
               log_window_clip (GTK_WIDGET (text), logwindow->clip_length);
 
        gtk_text_buffer_get_iter_at_offset(buffer, &iter, -1);
        gtk_text_view_scroll_to_iter(text, &iter, 0, TRUE, 0, 0);
+       gtk_text_buffer_place_cursor(buffer, &iter);
 
        return FALSE;
 }
@@ -239,14 +237,14 @@ static void log_window_clip(GtkWidget *textw, guint clip_length)
        GtkTextBuffer *textbuf = gtk_text_view_get_buffer(textview);
        GtkTextIter start_iter, end_iter;
        
-       length = gtk_text_buffer_get_char_count (textbuf);
-       debug_print("Log window length: %u\n", length);
+       length = gtk_text_buffer_get_line_count(textbuf);
+       /* debug_print("Log window length: %u\n", length); */
        
        if (length > clip_length) {
                /* find the end of the first line after the cut off
                 * point */
                        point = length - clip_length;
-               gtk_text_buffer_get_iter_at_offset(textbuf, &end_iter, point);
+               gtk_text_buffer_get_iter_at_line(textbuf, &end_iter, point);
                if (!gtk_text_iter_forward_to_line_end(&end_iter))
                        return;
                gtk_text_buffer_get_start_iter(textbuf, &start_iter);
index 328812b..dd4e8e9 100644 (file)
@@ -24,8 +24,7 @@
 #include <glib.h>
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
-#include <gtk/gtkwindow.h>
-#include <gtk/gtkvbox.h>
+#include <gtk/gtkdialog.h>
 #include <gtk/gtkhbox.h>
 #include <gtk/gtklabel.h>
 #include <gtk/gtkprogressbar.h>
@@ -57,12 +56,10 @@ static void progress_dialog_create_list_view_columns(GtkTreeView *list_view);
 ProgressDialog *progress_dialog_create(void)
 {
        ProgressDialog *progress;
-       GtkWidget *window;
-       GtkWidget *vbox;
+       GtkWidget *dialog;
        GtkWidget *hbox;
        GtkWidget *label;
        GtkWidget *cancel_btn;
-       GtkWidget *cancel_area;
        GtkWidget *progressbar;
        GtkWidget *scrolledwin;
        GtkWidget *clist;
@@ -75,38 +72,41 @@ ProgressDialog *progress_dialog_create(void)
        debug_print("Creating progress dialog...\n");
        progress = g_new0(ProgressDialog, 1);
 
-       window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
-       gtk_widget_set_usize(window, 460, -1);
-       gtk_container_set_border_width(GTK_CONTAINER(window), 8);
-       gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
-       gtk_widget_realize(window);
+       dialog = gtk_dialog_new();
+       gtk_widget_set_size_request(dialog, 460, -1);
+       gtk_container_set_border_width(GTK_CONTAINER(dialog), 8);
+       gtk_window_set_policy(GTK_WINDOW(dialog), FALSE, TRUE, TRUE);
+       gtk_widget_realize(dialog);
 
-       vbox = gtk_vbox_new(FALSE, 8);
-       gtk_container_add(GTK_CONTAINER(window), vbox);
-       gtk_widget_show(vbox);
+       gtk_container_set_border_width
+               (GTK_CONTAINER(GTK_DIALOG(dialog)->action_area), 0);
+       gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog)->vbox), 8);
+       gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
 
        hbox = gtk_hbox_new(FALSE, 0);
-       gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 8);
+       gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox,
+                          FALSE, FALSE, 8);
        gtk_widget_show(hbox);
 
        label = gtk_label_new("");
        gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 8);
        gtk_widget_show(label);
 
-       gtkut_stock_button_set_create
-               (&cancel_area, &cancel_btn, GTK_STOCK_CANCEL,
-                NULL, NULL, NULL, NULL);
-       gtk_box_pack_end(GTK_BOX(vbox), cancel_area, FALSE, FALSE, 0);
+       cancel_btn = gtk_dialog_add_button(GTK_DIALOG(dialog),
+                                          GTK_STOCK_CANCEL,
+                                          GTK_RESPONSE_NONE);
        gtk_widget_grab_default(cancel_btn);
-       gtk_widget_show_all(cancel_area);
+       gtk_widget_grab_focus(cancel_btn);
 
        progressbar = gtk_progress_bar_new();
-       gtk_box_pack_start(GTK_BOX(vbox), progressbar, FALSE, FALSE, 0);
+       gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), progressbar,
+                          FALSE, FALSE, 0);
        gtk_widget_show(progressbar);
 
        scrolledwin = gtk_scrolled_window_new(NULL, NULL);
        gtk_widget_show(scrolledwin);
-       gtk_box_pack_start(GTK_BOX(vbox), scrolledwin, TRUE, TRUE, 0);
+       gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), scrolledwin,
+                          TRUE, TRUE, 0);
        gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin),
                                       GTK_POLICY_AUTOMATIC,
                                       GTK_POLICY_AUTOMATIC);
@@ -128,7 +128,7 @@ ProgressDialog *progress_dialog_create(void)
        gtk_container_add(GTK_CONTAINER(scrolledwin), list_view);
        gtk_widget_set_usize(list_view, -1, 120);
 
-       progress->window      = window;
+       progress->window      = dialog;
        progress->label       = label;
        progress->cancel_btn  = cancel_btn;
        progress->progressbar = progressbar;
index 70404a3..4633179 100644 (file)
@@ -1445,12 +1445,6 @@ static void textview_show_header(TextView *textview, GPtrArray *headers)
                    procheader_headername_equal(header->name, "Cc"))
                        unfold_line(header->body);
 
-#warning FIXME_GTK2
-#if 0
-               if (textview->text_is_mb == TRUE)
-                       conv_unreadable_locale(header->body);
-#endif
-
                if (prefs_common.enable_color &&
                    (procheader_headername_equal(header->name, "X-Mailer") ||
                     procheader_headername_equal(header->name,
@@ -1478,9 +1472,8 @@ gboolean textview_search_string(TextView *textview, const gchar *str,
 {
        GtkTextView *text = GTK_TEXT_VIEW(textview->text);
        GtkTextBuffer *buffer;
-       GtkTextIter iter, end_iter;
+       GtkTextIter iter, match_pos;
        GtkTextMark *mark;
-       gint pos;
        gint len;
 
        g_return_val_if_fail(str != NULL, FALSE);
@@ -1492,12 +1485,14 @@ gboolean textview_search_string(TextView *textview, const gchar *str,
 
        mark = gtk_text_buffer_get_insert(buffer);
        gtk_text_buffer_get_iter_at_mark(buffer, &iter, mark);
-       pos = gtk_text_iter_get_offset(&iter);
 
-       if ((pos = gtkut_text_buffer_find(buffer, pos, str, case_sens)) != -1) {
-               gtk_text_buffer_get_iter_at_offset(buffer, &end_iter, pos);
-               gtk_text_buffer_get_iter_at_offset(buffer, &iter, pos + len);
-               gtk_text_buffer_select_range(buffer, &iter, &end_iter);
+       if (gtkut_text_buffer_find(buffer, &iter, str, case_sens,
+                                  &match_pos)) {
+               GtkTextIter end = match_pos;
+
+               gtk_text_iter_forward_chars(&end, len);
+               /* place "insert" at the last character */
+               gtk_text_buffer_select_range(buffer, &end, &match_pos);
                gtk_text_view_scroll_to_mark(text, mark, 0.0, FALSE, 0.0, 0.0);
                return TRUE;
        }
@@ -1510,47 +1505,31 @@ gboolean textview_search_string_backward(TextView *textview, const gchar *str,
 {
        GtkTextView *text = GTK_TEXT_VIEW(textview->text);
        GtkTextBuffer *buffer;
-       GtkTextIter iter, end_iter;
+       GtkTextIter iter, match_pos;
        GtkTextMark *mark;
-       gint pos;
-       gunichar *wcs;
        gint len;
-       glong items_read = 0, items_written = 0;
-       GError *error = NULL;
-       gboolean found = FALSE;
 
        g_return_val_if_fail(str != NULL, FALSE);
 
        buffer = gtk_text_view_get_buffer(text);
 
-       wcs = g_utf8_to_ucs4(str, -1, &items_read, &items_written, &error);
-       if (error != NULL) {
-               g_warning("An error occured while converting a string from UTF-8 to UCS-4: %s\n", error->message);
-               g_error_free(error);
-       }
-       if (!wcs || items_written <= 0) return FALSE;
-       len = (gint)items_written;
+       len = g_utf8_strlen(str, -1);
+       g_return_val_if_fail(len >= 0, FALSE);
 
        mark = gtk_text_buffer_get_insert(buffer);
        gtk_text_buffer_get_iter_at_mark(buffer, &iter, mark);
 
-       while (gtk_text_iter_backward_char(&iter)) {
-               pos = gtk_text_iter_get_offset(&iter);
-               if (gtkut_text_buffer_match_string
-                       (buffer, pos, wcs, len, case_sens) == TRUE) {
-                       gtk_text_buffer_get_iter_at_offset(buffer, &iter, pos);
-                       gtk_text_buffer_get_iter_at_offset
-                               (buffer, &end_iter, pos + len);
-                       gtk_text_buffer_select_range(buffer, &iter, &end_iter);
-                       gtk_text_view_scroll_to_mark
-                               (text, mark, 0.0, FALSE, 0.0, 0.0);
-                       found = TRUE;
-                       break;
-               }
+       if (gtkut_text_buffer_find_backward(buffer, &iter, str, case_sens,
+                                           &match_pos)) {
+               GtkTextIter end = match_pos;
+
+               gtk_text_iter_forward_chars(&end, len);
+               gtk_text_buffer_select_range(buffer, &match_pos, &end);
+               gtk_text_view_scroll_to_mark(text, mark, 0.0, FALSE, 0.0, 0.0);
+               return TRUE;
        }
 
-       g_free(wcs);
-       return found;
+       return FALSE;
 }
 
 void textview_scroll_one_line(TextView *textview, gboolean up)