2004-08-11 [colin] 0.9.12cvs57.3
authorColin Leroy <colin@colino.net>
Wed, 11 Aug 2004 17:01:29 +0000 (17:01 +0000)
committerColin Leroy <colin@colino.net>
Wed, 11 Aug 2004 17:01:29 +0000 (17:01 +0000)
* src/message_search.c
* src/summary_search.c
Make searches case insensitive by default
* src/textview.c
Fix case-insensitive search in message

ChangeLog-gtk2.claws
PATCHSETS
configure.ac
src/message_search.c
src/summary_search.c
src/textview.c

index 89daa8cac4f8f34e27ed2c8ff49dc791cab6db91..89dabdc700deeb790a922906c53f49e2406e4b5e 100644 (file)
@@ -1,3 +1,11 @@
+2004-08-11 [colin]     0.9.12cvs57.3
+
+       * src/message_search.c
+       * src/summary_search.c
+               Make searches case insensitive by default
+       * src/textview.c
+               Fix case-insensitive search in message
+
 2004-08-11 [colin]     0.9.12cvs57.2
 
        * src/summary_search.c
index 5d46098e039f7270a630f89d49517d24d3d4ce95..6b586c28f87eaf7ab92894864fb3b4fc8b8bbefb 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.654.2.141 -r 1.654.2.142 configure.ac; cvs diff -u -r 1.155.2.8 -r 1.155.2.9 src/Makefile.am; cvs diff -u -r 1.24.2.3 -r 1.24.2.4 src/common/Makefile.am; ) > 0.9.12cvs55.3.patchset
 ( cvs diff -u -r 1.13.2.7 -r 1.13.2.8 src/common/socket.c; ) > 0.9.12cvs55.4.patchset
 ( cvs diff -u -r 1.15.2.6 -r 1.15.2.7 src/summary_search.c; ) > 0.9.12cvs57.2.patchset
+( cvs diff -u -r 1.3.12.4 -r 1.3.12.5 src/message_search.c; cvs diff -u -r 1.15.2.7 -r 1.15.2.8 src/summary_search.c; cvs diff -u -r 1.96.2.15 -r 1.96.2.16 src/textview.c; ) > 0.9.12cvs57.3.patchset
index b21d60a0c7609bb8716ac1c4143eebe9b5d2beb5..9d53c4a95105845f34efe46caf6372cc4ad102cd 100644 (file)
@@ -13,7 +13,7 @@ INTERFACE_AGE=0
 BINARY_AGE=0
 EXTRA_VERSION=57
 EXTRA_RELEASE=
-EXTRA_GTK2_VERSION=.2
+EXTRA_GTK2_VERSION=.3
 
 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 4e95defb418f00b53b9ba910ff95f0336144c86f..d5f0808c1e12166a9700a6e69bf362043b79c7e0 100644 (file)
@@ -122,8 +122,7 @@ static void message_search_create(MessageView *messageview)
        gtk_widget_show (case_checkbtn);
        gtk_box_pack_start (GTK_BOX (checkbtn_hbox), case_checkbtn,
                            FALSE, FALSE, 0);
-       gtk_widget_set_sensitive(case_checkbtn, FALSE);
-       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(case_checkbtn), TRUE);
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(case_checkbtn), FALSE);
 
        backward_checkbtn =
                gtk_check_button_new_with_label (_("Backward search"));
index 499027a273b7bf7721db653fb004b86f78f1e882..23739c7785809c79c8bd73929801290a18dfce2f 100644 (file)
@@ -181,7 +181,7 @@ static void summary_search_create(SummaryView *summaryview)
        gtk_container_set_border_width (GTK_CONTAINER (checkbtn_hbox), 8);
 
        case_checkbtn = gtk_check_button_new_with_label (_("Case sensitive"));
-       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(case_checkbtn), TRUE);
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(case_checkbtn), FALSE);
        gtk_widget_show (case_checkbtn);
        gtk_box_pack_start (GTK_BOX (checkbtn_hbox), case_checkbtn,
                            FALSE, FALSE, 0);
index 2c0b266d2dcdc432fd97f8dce278abf015865168..d9b839724577ec52b55d31210341b4317825307e 100644 (file)
@@ -1472,12 +1472,11 @@ static void textview_show_header(TextView *textview, GPtrArray *headers)
 gboolean textview_search_string(TextView *textview, const gchar *str,
                                gboolean case_sens)
 {
-#warning FIXME_GTK2 /* currently, these search functions ignores case_sens */
        GtkTextView *text = GTK_TEXT_VIEW(textview->text);
        GtkTextBuffer *buffer = gtk_text_view_get_buffer(text);
        GtkTextMark *mark;
-       GtkTextIter iter, start, end, *pos;
-       gboolean found;
+       GtkTextIter iter, start, end, real_end, *pos;
+       gboolean found = FALSE;
        gint insert_offset, selbound_offset;
 
        /* reset selection */
@@ -1494,12 +1493,36 @@ gboolean textview_search_string(TextView *textview, const gchar *str,
        /* search */
        mark = gtk_text_buffer_get_insert(buffer);
        gtk_text_buffer_get_iter_at_mark(buffer, &iter, mark);
-       found = gtk_text_iter_forward_search(&iter, str,
+       if (case_sens) {
+               found = gtk_text_iter_forward_search(&iter, str,
                                             GTK_TEXT_SEARCH_VISIBLE_ONLY,
                                             &start, &end, NULL);
+       } else {
+               gchar *text = NULL;
+               int i = 0;
+               gtk_text_buffer_get_end_iter(buffer, &real_end);
+               text = strdup(gtk_text_buffer_get_text(buffer, &iter, 
+                                                      &real_end, FALSE));
+               
+               while (!found && i++ < strlen(text)) {
+                       found = (strncasecmp(text+i, str, strlen(str)) == 0);
+               }
+               
+               i += gtk_text_iter_get_offset(&end);
+               
+               if (found) {
+                       gtk_text_buffer_get_iter_at_offset(buffer, &start, i);
+                       gtk_text_buffer_get_iter_at_offset(buffer, &end, 
+                                                          i + strlen(str));
+               }
+               
+               g_free(text);
+       }
+       
        if (found) {
                gtk_text_buffer_place_cursor(buffer, &start);
-               gtk_text_buffer_move_mark_by_name(buffer, "selection_bound", &end);
+               gtk_text_buffer_move_mark_by_name(buffer, "selection_bound", 
+                                                 &end);
                mark = gtk_text_buffer_get_mark(buffer, "insert");
                gtk_text_view_scroll_mark_onscreen(text, mark);
        }
@@ -1510,12 +1533,11 @@ gboolean textview_search_string(TextView *textview, const gchar *str,
 gboolean textview_search_string_backward(TextView *textview, const gchar *str,
                                         gboolean case_sens)
 {
-#warning FIXME_GTK2
        GtkTextView *text = GTK_TEXT_VIEW(textview->text);
        GtkTextBuffer *buffer = gtk_text_view_get_buffer(text);
        GtkTextMark *mark;
-       GtkTextIter iter, start, end, *pos;
-       gboolean found;
+       GtkTextIter iter, start, real_start, end, *pos;
+       gboolean found = FALSE;
        gint insert_offset, selbound_offset;
 
        /* reset selection */
@@ -1532,12 +1554,39 @@ gboolean textview_search_string_backward(TextView *textview, const gchar *str,
        /* search */
        mark = gtk_text_buffer_get_insert(buffer);
        gtk_text_buffer_get_iter_at_mark(buffer, &iter, mark);
-       found = gtk_text_iter_backward_search(&iter, str,
+       if (case_sens) {
+               found = gtk_text_iter_backward_search(&iter, str,
                                              GTK_TEXT_SEARCH_VISIBLE_ONLY,
                                              &start, &end, NULL);
+       } else {
+               gchar *text = NULL;
+               int i = 0;
+               if (gtk_text_iter_get_offset(&iter) == 0) 
+                       gtk_text_buffer_get_end_iter(buffer, &iter);
+               
+               i = gtk_text_iter_get_offset(&iter) - strlen(str) - 1;
+               gtk_text_buffer_get_start_iter(buffer, &real_start);
+               
+               text = strdup(gtk_text_buffer_get_text(buffer, &real_start, 
+                                                      &iter, FALSE));
+
+               while (!found && i-- >= 0) {
+                       found = (strncasecmp(text+i, str, strlen(str)) == 0);
+               }
+                               
+               if (found) {
+                       gtk_text_buffer_get_iter_at_offset(buffer, &start, i);
+                       gtk_text_buffer_get_iter_at_offset(buffer, &end, 
+                                                          i + strlen(str));
+               }
+               
+               g_free(text);
+       }
+               
        if (found) {
                gtk_text_buffer_place_cursor(buffer, &end);
-               gtk_text_buffer_move_mark_by_name(buffer, "selection_bound", &start);
+               gtk_text_buffer_move_mark_by_name(buffer, "selection_bound", 
+                                                 &start);
                mark = gtk_text_buffer_get_mark(buffer, "insert");
                gtk_text_view_scroll_mark_onscreen(text, mark);
        }