[Xfce4-commits] r25405 - in mousepad/branches/nick_0_3: . mousepad

Nick Schermer nick at xfce.org
Fri Apr 6 21:06:59 CEST 2007


Author: nick
Date: 2007-04-06 19:06:59 +0000 (Fri, 06 Apr 2007)
New Revision: 25405

Modified:
   mousepad/branches/nick_0_3/ChangeLog
   mousepad/branches/nick_0_3/mousepad/mousepad-document.c
Log:
	* mousepad/mousepad-document.c: Fix segfault from previous commit.
	* mousepad/mousepad-document.c: Fix bug in searching backwards, we have to
	  jump one iter backwards before searching, because we start with the
	  character right from the first iter. Also removed the equal check because
	  it's not needed and only causing problems with backwards searching on the
	  first character in the buffer.

Modified: mousepad/branches/nick_0_3/ChangeLog
===================================================================
--- mousepad/branches/nick_0_3/ChangeLog	2007-04-06 16:36:12 UTC (rev 25404)
+++ mousepad/branches/nick_0_3/ChangeLog	2007-04-06 19:06:59 UTC (rev 25405)
@@ -1,4 +1,13 @@
 2007-04-06	Nick Schermer <nick at xfce.org>
+	* mousepad/mousepad-document.c: Fix segfault from previous commit.
+	* mousepad/mousepad-document.c: Fix bug in searching backwards, we have to
+	  jump one iter backwards before searching, because we start with the
+	  character right from the first iter. Also removed the equal check because
+	  it's not needed and only causing problems with backwards searching on the
+	  first character in the buffer.
+
+
+2007-04-06	Nick Schermer <nick at xfce.org>
 	* mousepad/mousepad-window.c: Fix opening recent files that do not exist.
 	* mousepad/mousepad-window.c, mousepad/mousepad-document.c: Update the window
 	  title correctly and remove the unused notify::title signals.

Modified: mousepad/branches/nick_0_3/mousepad/mousepad-document.c
===================================================================
--- mousepad/branches/nick_0_3/mousepad/mousepad-document.c	2007-04-06 16:36:12 UTC (rev 25404)
+++ mousepad/branches/nick_0_3/mousepad/mousepad-document.c	2007-04-06 19:06:59 UTC (rev 25405)
@@ -68,7 +68,6 @@
                                                             MousepadSearchFlags     flags,
                                                             GtkTextIter            *match_start,
                                                             GtkTextIter            *match_end,
-                                                            const GtkTextIter      *limit,
                                                             gboolean                forward_search);
 static void      mousepad_document_update_tab              (MousepadDocument       *document);
 static void      mousepad_document_tab_button_clicked      (GtkWidget              *widget,
@@ -473,7 +472,8 @@
   document->display_name = g_filename_display_basename (filename);
 
   /* update the tab label and tooltip */
-  mousepad_document_update_tab (document);
+  if (document->ebox && document->label)
+    mousepad_document_update_tab (document);
 }
 
 
@@ -598,7 +598,6 @@
                                MousepadSearchFlags  flags,
                                GtkTextIter         *match_start,
                                GtkTextIter         *match_end,
-                               const GtkTextIter   *limit,
                                gboolean             search_forward)
 {
   GtkTextIter iter, begin;
@@ -608,7 +607,6 @@
   guint       str_offset = 0;
 
   _mousepad_return_val_if_fail (start != NULL, FALSE);
-  _mousepad_return_val_if_fail (limit != NULL, FALSE);
 
   /* set the start iter */
   iter = *start;
@@ -616,10 +614,6 @@
   /* walk from the start to the end iter */
   do
     {
-      /* break when we hit the search limit */
-      if (G_UNLIKELY (gtk_text_iter_equal (&iter, limit)))
-        break;
-
       /* get the characters we're going to compare */
       iter_char = gtk_text_iter_get_char (&iter);
       str_char  = g_utf8_get_char (str);
@@ -694,7 +688,7 @@
   GtkTextIter  doc_start, doc_end;
   GtkTextIter  sel_start, sel_end;
   GtkTextIter  match_start, match_end;
-  GtkTextIter  start, end;
+  GtkTextIter  start;
 
   _mousepad_return_val_if_fail (MOUSEPAD_IS_DOCUMENT (document), FALSE);
   _mousepad_return_val_if_fail (GTK_IS_TEXT_BUFFER (document->buffer), FALSE);
@@ -708,28 +702,27 @@
   if (flags & MOUSEPAD_SEARCH_FORWARDS)
     {
       start = sel_end;
-      end   = doc_end;
     }
-  else if (flags & MOUSEPAD_SEARCH_BACKWARDS)
+  else
     {
       start = sel_start;
-      end   = doc_start;
 
-      /* reverse the search string */
-      reversed = g_utf8_strreverse (string, -1);
+      if (flags & MOUSEPAD_SEARCH_BACKWARDS)
+        {
+          /* the character is right of the iter, go one iter backwards */
+          gtk_text_iter_backward_char (&start);
+
+          /* reverse the search string */
+          reversed = g_utf8_strreverse (string, -1);
+        }
     }
-  else /* type-ahead */
-    {
-      start = sel_start;
-      end   = doc_end;
-    }
 
 search:
   /* try to find the next occurence of the string */
   if (flags & MOUSEPAD_SEARCH_BACKWARDS)
-    found = mousepad_document_iter_search (&start, reversed, flags, &match_start, &match_end, &end, FALSE);
+    found = mousepad_document_iter_search (&start, reversed, flags, &match_start, &match_end, FALSE);
   else
-    found = mousepad_document_iter_search (&start, string, flags, &match_start, &match_end, &end, TRUE);
+    found = mousepad_document_iter_search (&start, string, flags, &match_start, &match_end, TRUE);
 
   /* select the occurence */
   if (found)
@@ -748,15 +741,9 @@
     {
       /* set the new start and end iter */
       if (flags & MOUSEPAD_SEARCH_BACKWARDS)
-        {
-          end   = start;
-          start = doc_end;
-        }
+        start = doc_end;
       else
-        {
-          end   = start;
-          start = doc_start;
-        }
+        start = doc_start;
 
       /* set we did the wrap, so we don't end up in a loop */
       already_wrapped = TRUE;
@@ -818,7 +805,7 @@
       do
         {
           /* search for the next occurence of the string */
-          found = mousepad_document_iter_search (&iter, string, flags, &match_start, &match_end, &doc_end, TRUE);
+          found = mousepad_document_iter_search (&iter, string, flags, &match_start, &match_end, TRUE);
 
           if (G_LIKELY (found))
             {



More information about the Xfce4-commits mailing list