Hi, <br><br>I have changed a few things in viewsource.py, and i am posting the diff file, <br>the issue still remains the same although i have changed view type from gtksourceview2 to gtk.textview. <br><br>--------------------------- git diff file.------------------------<br>
<br>diff --git a/install/lib/python2.6/site-packages/jarabe/view/viewsource.py b/install/lib/python2.6/site-packages/jarabe/view/viewsource.py<br>index 524db9e..24e361c 100644<br>--- a/install/lib/python2.6/site-packages/jarabe/view/viewsource.py<br>
+++ b/install/lib/python2.6/site-packages/jarabe/view/viewsource.py<br>@@ -321,18 +321,18 @@ class Toolbar(gtk.Toolbar):<br>         search_item.show()<br>         search_entry.show()<br> <br>-        _search_prev = ToolButton(&#39;go-previous-paired&#39;)<br>
-        _search_prev.set_tooltip(_(&#39;Previous&#39;))<br>-    #    self._search_prev.connect(&#39;clicked&#39;, self._search_prev_cb)<br>-        self.insert(_search_prev, -1)<br>-        _search_prev.show()<br>+        self._search_prev = ToolButton(&#39;go-previous-paired&#39;)<br>
+        self._search_prev.set_tooltip(_(&#39;Previous&#39;))<br>+        self._search_prev.connect(&#39;clicked&#39;, self._search_prev_cb)<br>+        self.insert(self._search_prev, -1)<br>+        self._search_prev.show()<br>
         <br>-        _search_next = ToolButton(&#39;go-next-paired&#39;)<br>-        _search_next.set_tooltip(_(&#39;Next&#39;))<br>-        #self._search_next.connect(&#39;clicked&#39;, self._search_next_cb)<br>-        self.insert(_search_next, -1)<br>
-        _search_next.show()<br>-        #self._update_search_buttons()<br>+        self._search_next = ToolButton(&#39;go-next-paired&#39;)<br>+        self._search_next.set_tooltip(_(&#39;Next&#39;))<br>+        self._search_next.connect(&#39;clicked&#39;, self._search_next_cb)<br>
+        self.insert(self._search_next, -1)<br>+        self._search_next.show()<br>+        self._update_search_buttons()<br> <br> <br>         stop = ToolButton(icon_name=&#39;dialog-cancel&#39;)<br>@@ -343,10 +343,30 @@ class Toolbar(gtk.Toolbar):<br>
 <br>     def _search_entry_activate_cb(self, entry):<br>         self.viewer.set_search_text(entry.props.text)<br>+        self._update_search_buttons()<br> <br>     def _search_entry_changed_cb(self, entry):<br>         self.viewer.set_search_text(entry.props.text)<br>
-     <br>+        self._update_search_buttons()<br>+<br>+    def _search_prev_cb(self, button):<br>+        self.viewer.search_next(&#39;backward&#39;)<br>+        self._update_search_buttons()<br>+<br>+    def _search_next_cb(self, button):<br>
+        self.viewer.search_next(&#39;forward&#39;)<br>+        self._update_search_buttons()<br>+<br>+    def _update_search_buttons(self,):<br>+        if len(self.viewer.search_text) == 0:<br>+            self._search_prev.props.sensitive = False<br>
+            self._search_next.props.sensitive = False<br>+        else:<br>+            prev = self.viewer.get_next_result(&#39;backward&#39;)<br>+            next = self.viewer.get_next_result(&#39;forward&#39;)<br>+            self._search_prev.props.sensitive = prev != None<br>
+            self._search_next.props.sensitive = next != None<br>+<br>     def _add_separator(self, expand=False):<br>         separator = gtk.SeparatorToolItem()<br>         separator.props.draw = False<br>@@ -452,22 +472,88 @@ class SourceDisplay(gtk.ScrolledWindow):<br>
         self._buffer = gtksourceview2.Buffer()<br>         self._buffer.set_highlight_syntax(True)<br> <br>-        self._source_view = gtksourceview2.View(self._buffer)<br>-        self._source_view.set_editable(False)<br>
-        self._source_view.set_cursor_visible(True)<br>-        self._source_view.set_show_line_numbers(True)<br>-        self._source_view.set_show_right_margin(True)<br>-        self._source_view.set_right_margin_position(80)<br>
+        self.search_text = &#39; &#39;<br>+<br>+        #self._source_view = gtksourceview2.View(self._buffer)<br>+        #self._source_view.set_editable(False)<br>+        #self._source_view.set_cursor_visible(True)<br>
+        #self._source_view.set_show_line_numbers(True)<br>+        #self._source_view.set_show_right_margin(True)<br>+        #self._source_view.set_right_margin_position(80)<br>         #self._source_view.set_highlight_current_line(True) #FIXME: Ugly color<br>
-        self._source_view.modify_font(_SOURCE_FONT)<br>-        self.add(self._source_view)<br>-        self._source_view.show()<br>+        #self._source_view.modify_font(_SOURCE_FONT)<br>+       # self.add(self._source_view)<br>
+       # self._source_view.show()<br>+        <br>+        self._textview = gtk.TextView(self._buffer)<br>+        self.add(self._textview)<br>+        self._tagtable = gtk.TextTagTable()<br>+        hilite_tag = gtk.TextTag(&#39;search-hilite&#39;)<br>
+        hilite_tag.props.background = &#39;#FFFFB0&#39;<br>+        self._tagtable.add(hilite_tag)<br>+        select_tag = gtk.TextTag(&#39;search-select&#39;)<br>+        select_tag.props.background = &#39;#B0B0FF&#39;<br>
+        self._tagtable.add(select_tag)<br>+        <br>+        scroll = gtk.ScrolledWindow()<br>+        scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)<br>+        scroll.add(self._textview)<br> <br>+        self._textview.show()<br>
+  <br>         self._file_path = None<br> <br>     def set_search_text(self, text):<br>         self.search_text = text<br>+        buffer = self._textview.get_buffer()<br>         <br>+        start, end = buffer.get_bounds()<br>
+       # buffer.remove_tag_by_name(&#39;search-hilite&#39;, start, end)<br>+       # buffer.remove_tag_by_name(&#39;search-select&#39;, start, end)<br>+        <br>+        iter = buffer.get_start_iter()<br>+        while True:<br>
+            next = iter.forward_search(text, 0)<br>+            if next is None: break<br>+            start, end = next<br>+            buffer.apply_tag_by_name(&#39;search-hilite&#39;, start, end)<br>+            iter = end<br>
+<br>+        if self.get_next_result(&#39;current&#39;):<br>+            self.search_next(&#39;current&#39;)<br>+        elif self.get_next_result(&#39;backward&#39;):<br>+            self.search_next(&#39;backward&#39;)<br>
+<br>+    def get_next_result(self, dir):<br>+        buffer = self._textview.get_buffer()<br>+        <br>+        if dir == &#39;forward&#39;:<br>+            iter = buffer.get_iter_at_mark(buffer.get_insert())<br>+            iter.forward_char()<br>
+        else:<br>+            iter = buffer.get_iter_at_mark(buffer.get_insert())<br>+            <br>+        if dir == &#39;backward&#39;:<br>+            return iter.backward_search(self.search_text, 0)<br>+        else:<br>
+            return iter.forward_search(self.search_text, 0)<br>+<br>+    def search_next(self, dir):        <br>+        next = self.get_next_result(dir)<br>+        if next:<br>+            buffer = self._textview.get_buffer()<br>
+<br>+            start, end = buffer.get_bounds()<br>+            buffer.remove_tag_by_name(&#39;search-select&#39;, start, end)<br>+<br>+            start, end = next<br>+            buffer.apply_tag_by_name(&#39;search-select&#39;, start, end)<br>
+            <br>+            buffer.place_cursor(start)<br>+            <br>+            self._textview.scroll_to_iter(start, 0.1)<br>+            self._textview.scroll_to_iter(end, 0.1)<br>+<br> <br><br><br><br>----------------------------------<br>
<br>Regards <br><br>Shan<br><br><br><br><br><div class="gmail_quote">On Mon, Sep 27, 2010 at 8:25 PM, Tomeu Vizoso <span dir="ltr">&lt;<a href="mailto:tomeu@sugarlabs.org">tomeu@sugarlabs.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im">On Mon, Sep 27, 2010 at 16:36, Shanjit Singh Jajmann<br>
&lt;<a href="mailto:shanjit@dev.seeta.in">shanjit@dev.seeta.in</a>&gt; wrote:<br>
&gt; Team,<br>
&gt;<br>
&gt; I am working on <a href="http://bugs.sugarlabs.org/ticket/398" target="_blank">http://bugs.sugarlabs.org/ticket/398</a>  : Regarding the search<br>
&gt; box, i have tried to introduce the same functionality as in the &#39;Log&#39;<br>
&gt; activity, in the toolbar of viewsource (jarabe/view/viewscreen.py), however<br>
&gt; i have run into some searching and highlighting issues regarding working<br>
<br>
</div>Without knowing which are the issues is a bit hard to know how to<br>
help. Can you be more explicit and also post the patch?<br>
<br>
Regards,<br>
<br>
Tomeu<br>
<div class="im"><br>
&gt; with gtksourceview used in the sourceview function of the same file. Could<br>
&gt; you please provide some pointers on how to achieve the searching and<br>
&gt; highlighting ? (i could not get the bounds of the buffer created, start,end<br>
&gt; . The highlight function has me confused as it isn&#39;t working) or any other<br>
&gt; approach if possible.<br>
&gt;<br>
&gt; Regards<br>
&gt; Shan<br>
&gt;<br>
</div>&gt; _______________________________________________<br>
&gt; Sugar-devel mailing list<br>
&gt; <a href="mailto:Sugar-devel@lists.sugarlabs.org">Sugar-devel@lists.sugarlabs.org</a><br>
&gt; <a href="http://lists.sugarlabs.org/listinfo/sugar-devel" target="_blank">http://lists.sugarlabs.org/listinfo/sugar-devel</a><br>
&gt;<br>
&gt;<br>
</blockquote></div><br>