Shan,<br><br>I think we should get back to the original format and try to implement the search with the existing functions. For the first target, since the hilite word function is nowhere to be found so far for gtk2viewer, try to implement a system in which you can hilite the line of the search text, like I said that day. Try your best.<br>
<br>About git diff, do as Tomeu instructed. run git diff inside jhbuild.<br>Sorry about that day, on which I hurriedly explained you how to create a gut diff file in a source dir itself.<br><br>Regards,<br>Dipankar<br><br>
<div class="gmail_quote">On Thu, Sep 30, 2010 at 3:08 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;">
On Wed, Sep 29, 2010 at 17:49, Shanjit Singh Jajmann<br>
<div class="im">&lt;<a href="mailto:shanjit@dev.seeta.in">shanjit@dev.seeta.in</a>&gt; wrote:<br>
</div><div class="im">&gt; Hi,<br>
&gt;<br>
&gt; I have changed a few things in viewsource.py, and i am posting the diff<br>
&gt; file,<br>
<br>
</div>You should be making changes in sugar-jhbuild/source/sugar and use<br>
&quot;git diff&quot; to generate the diff. Ask your colleagues in Seeta if you<br>
have doubts.<br>
<div class="im"><br>
&gt; the issue still remains the same although i have changed view type from<br>
&gt; gtksourceview2 to gtk.textview.<br>
<br>
</div>I have no idea why you think changing that may have helped with<br>
whatever problems you have found.<br>
<br>
Regards,<br>
<font color="#888888"><br>
Tomeu<br>
</font><div><div></div><div class="h5"><br>
&gt; --------------------------- git diff file.------------------------<br>
&gt;<br>
&gt; diff --git a/install/lib/python2.6/site-packages/jarabe/view/viewsource.py<br>
&gt; b/install/lib/python2.6/site-packages/jarabe/view/viewsource.py<br>
&gt; index 524db9e..24e361c 100644<br>
&gt; --- a/install/lib/python2.6/site-packages/jarabe/view/viewsource.py<br>
&gt; +++ b/install/lib/python2.6/site-packages/jarabe/view/viewsource.py<br>
&gt; @@ -321,18 +321,18 @@ class Toolbar(gtk.Toolbar):<br>
&gt;          search_item.show()<br>
&gt;          search_entry.show()<br>
&gt;<br>
&gt; -        _search_prev = ToolButton(&#39;go-previous-paired&#39;)<br>
&gt; -        _search_prev.set_tooltip(_(&#39;Previous&#39;))<br>
&gt; -    #    self._search_prev.connect(&#39;clicked&#39;, self._search_prev_cb)<br>
&gt; -        self.insert(_search_prev, -1)<br>
&gt; -        _search_prev.show()<br>
&gt; +        self._search_prev = ToolButton(&#39;go-previous-paired&#39;)<br>
&gt; +        self._search_prev.set_tooltip(_(&#39;Previous&#39;))<br>
&gt; +        self._search_prev.connect(&#39;clicked&#39;, self._search_prev_cb)<br>
&gt; +        self.insert(self._search_prev, -1)<br>
&gt; +        self._search_prev.show()<br>
&gt;<br>
&gt; -        _search_next = ToolButton(&#39;go-next-paired&#39;)<br>
&gt; -        _search_next.set_tooltip(_(&#39;Next&#39;))<br>
&gt; -        #self._search_next.connect(&#39;clicked&#39;, self._search_next_cb)<br>
&gt; -        self.insert(_search_next, -1)<br>
&gt; -        _search_next.show()<br>
&gt; -        #self._update_search_buttons()<br>
&gt; +        self._search_next = ToolButton(&#39;go-next-paired&#39;)<br>
&gt; +        self._search_next.set_tooltip(_(&#39;Next&#39;))<br>
&gt; +        self._search_next.connect(&#39;clicked&#39;, self._search_next_cb)<br>
&gt; +        self.insert(self._search_next, -1)<br>
&gt; +        self._search_next.show()<br>
&gt; +        self._update_search_buttons()<br>
&gt;<br>
&gt;<br>
&gt;          stop = ToolButton(icon_name=&#39;dialog-cancel&#39;)<br>
&gt; @@ -343,10 +343,30 @@ class Toolbar(gtk.Toolbar):<br>
&gt;<br>
&gt;      def _search_entry_activate_cb(self, entry):<br>
&gt;          self.viewer.set_search_text(entry.props.text)<br>
&gt; +        self._update_search_buttons()<br>
&gt;<br>
&gt;      def _search_entry_changed_cb(self, entry):<br>
&gt;          self.viewer.set_search_text(entry.props.text)<br>
&gt; -<br>
&gt; +        self._update_search_buttons()<br>
&gt; +<br>
&gt; +    def _search_prev_cb(self, button):<br>
&gt; +        self.viewer.search_next(&#39;backward&#39;)<br>
&gt; +        self._update_search_buttons()<br>
&gt; +<br>
&gt; +    def _search_next_cb(self, button):<br>
&gt; +        self.viewer.search_next(&#39;forward&#39;)<br>
&gt; +        self._update_search_buttons()<br>
&gt; +<br>
&gt; +    def _update_search_buttons(self,):<br>
&gt; +        if len(self.viewer.search_text) == 0:<br>
&gt; +            self._search_prev.props.sensitive = False<br>
&gt; +            self._search_next.props.sensitive = False<br>
&gt; +        else:<br>
&gt; +            prev = self.viewer.get_next_result(&#39;backward&#39;)<br>
&gt; +            next = self.viewer.get_next_result(&#39;forward&#39;)<br>
&gt; +            self._search_prev.props.sensitive = prev != None<br>
&gt; +            self._search_next.props.sensitive = next != None<br>
&gt; +<br>
&gt;      def _add_separator(self, expand=False):<br>
&gt;          separator = gtk.SeparatorToolItem()<br>
&gt;          separator.props.draw = False<br>
&gt; @@ -452,22 +472,88 @@ class SourceDisplay(gtk.ScrolledWindow):<br>
&gt;          self._buffer = gtksourceview2.Buffer()<br>
&gt;          self._buffer.set_highlight_syntax(True)<br>
&gt;<br>
&gt; -        self._source_view = gtksourceview2.View(self._buffer)<br>
&gt; -        self._source_view.set_editable(False)<br>
&gt; -        self._source_view.set_cursor_visible(True)<br>
&gt; -        self._source_view.set_show_line_numbers(True)<br>
&gt; -        self._source_view.set_show_right_margin(True)<br>
&gt; -        self._source_view.set_right_margin_position(80)<br>
&gt; +        self.search_text = &#39; &#39;<br>
&gt; +<br>
&gt; +        #self._source_view = gtksourceview2.View(self._buffer)<br>
&gt; +        #self._source_view.set_editable(False)<br>
&gt; +        #self._source_view.set_cursor_visible(True)<br>
&gt; +        #self._source_view.set_show_line_numbers(True)<br>
&gt; +        #self._source_view.set_show_right_margin(True)<br>
&gt; +        #self._source_view.set_right_margin_position(80)<br>
&gt;          #self._source_view.set_highlight_current_line(True) #FIXME: Ugly<br>
&gt; color<br>
&gt; -        self._source_view.modify_font(_SOURCE_FONT)<br>
&gt; -        self.add(self._source_view)<br>
&gt; -        self._source_view.show()<br>
&gt; +        #self._source_view.modify_font(_SOURCE_FONT)<br>
&gt; +       # self.add(self._source_view)<br>
&gt; +       # self._source_view.show()<br>
&gt; +<br>
&gt; +        self._textview = gtk.TextView(self._buffer)<br>
&gt; +        self.add(self._textview)<br>
&gt; +        self._tagtable = gtk.TextTagTable()<br>
&gt; +        hilite_tag = gtk.TextTag(&#39;search-hilite&#39;)<br>
&gt; +        hilite_tag.props.background = &#39;#FFFFB0&#39;<br>
&gt; +        self._tagtable.add(hilite_tag)<br>
&gt; +        select_tag = gtk.TextTag(&#39;search-select&#39;)<br>
&gt; +        select_tag.props.background = &#39;#B0B0FF&#39;<br>
&gt; +        self._tagtable.add(select_tag)<br>
&gt; +<br>
&gt; +        scroll = gtk.ScrolledWindow()<br>
&gt; +        scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)<br>
&gt; +        scroll.add(self._textview)<br>
&gt;<br>
&gt; +        self._textview.show()<br>
&gt; +<br>
&gt;          self._file_path = None<br>
&gt;<br>
&gt;      def set_search_text(self, text):<br>
&gt;          self.search_text = text<br>
&gt; +        buffer = self._textview.get_buffer()<br>
&gt;<br>
&gt; +        start, end = buffer.get_bounds()<br>
&gt; +       # buffer.remove_tag_by_name(&#39;search-hilite&#39;, start, end)<br>
&gt; +       # buffer.remove_tag_by_name(&#39;search-select&#39;, start, end)<br>
&gt; +<br>
&gt; +        iter = buffer.get_start_iter()<br>
&gt; +        while True:<br>
&gt; +            next = iter.forward_search(text, 0)<br>
&gt; +            if next is None: break<br>
&gt; +            start, end = next<br>
&gt; +            buffer.apply_tag_by_name(&#39;search-hilite&#39;, start, end)<br>
&gt; +            iter = end<br>
&gt; +<br>
&gt; +        if self.get_next_result(&#39;current&#39;):<br>
&gt; +            self.search_next(&#39;current&#39;)<br>
&gt; +        elif self.get_next_result(&#39;backward&#39;):<br>
&gt; +            self.search_next(&#39;backward&#39;)<br>
&gt; +<br>
&gt; +    def get_next_result(self, dir):<br>
&gt; +        buffer = self._textview.get_buffer()<br>
&gt; +<br>
&gt; +        if dir == &#39;forward&#39;:<br>
&gt; +            iter = buffer.get_iter_at_mark(buffer.get_insert())<br>
&gt; +            iter.forward_char()<br>
&gt; +        else:<br>
&gt; +            iter = buffer.get_iter_at_mark(buffer.get_insert())<br>
&gt; +<br>
&gt; +        if dir == &#39;backward&#39;:<br>
&gt; +            return iter.backward_search(self.search_text, 0)<br>
&gt; +        else:<br>
&gt; +            return iter.forward_search(self.search_text, 0)<br>
&gt; +<br>
&gt; +    def search_next(self, dir):<br>
&gt; +        next = self.get_next_result(dir)<br>
&gt; +        if next:<br>
&gt; +            buffer = self._textview.get_buffer()<br>
&gt; +<br>
&gt; +            start, end = buffer.get_bounds()<br>
&gt; +            buffer.remove_tag_by_name(&#39;search-select&#39;, start, end)<br>
&gt; +<br>
&gt; +            start, end = next<br>
&gt; +            buffer.apply_tag_by_name(&#39;search-select&#39;, start, end)<br>
&gt; +<br>
&gt; +            buffer.place_cursor(start)<br>
&gt; +<br>
&gt; +            self._textview.scroll_to_iter(start, 0.1)<br>
&gt; +            self._textview.scroll_to_iter(end, 0.1)<br>
&gt; +<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; ----------------------------------<br>
&gt;<br>
&gt; Regards<br>
&gt;<br>
&gt; Shan<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; On Mon, Sep 27, 2010 at 8:25 PM, Tomeu Vizoso &lt;<a href="mailto:tomeu@sugarlabs.org">tomeu@sugarlabs.org</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; On Mon, Sep 27, 2010 at 16:36, Shanjit Singh Jajmann<br>
&gt;&gt; &lt;<a href="mailto:shanjit@dev.seeta.in">shanjit@dev.seeta.in</a>&gt; wrote:<br>
&gt;&gt; &gt; Team,<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; I am working on <a href="http://bugs.sugarlabs.org/ticket/398" target="_blank">http://bugs.sugarlabs.org/ticket/398</a>  : Regarding the<br>
&gt;&gt; &gt; search<br>
&gt;&gt; &gt; box, i have tried to introduce the same functionality as in the &#39;Log&#39;<br>
&gt;&gt; &gt; activity, in the toolbar of viewsource (jarabe/view/viewscreen.py),<br>
&gt;&gt; &gt; however<br>
&gt;&gt; &gt; i have run into some searching and highlighting issues regarding working<br>
&gt;&gt;<br>
&gt;&gt; Without knowing which are the issues is a bit hard to know how to<br>
&gt;&gt; help. Can you be more explicit and also post the patch?<br>
&gt;&gt;<br>
&gt;&gt; Regards,<br>
&gt;&gt;<br>
&gt;&gt; Tomeu<br>
&gt;&gt;<br>
&gt;&gt; &gt; with gtksourceview used in the sourceview function of the same file.<br>
&gt;&gt; &gt; Could<br>
&gt;&gt; &gt; you please provide some pointers on how to achieve the searching and<br>
&gt;&gt; &gt; highlighting ? (i could not get the bounds of the buffer created,<br>
&gt;&gt; &gt; start,end<br>
&gt;&gt; &gt; . The highlight function has me confused as it isn&#39;t working) or any<br>
&gt;&gt; &gt; other<br>
&gt;&gt; &gt; approach if possible.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Regards<br>
&gt;&gt; &gt; Shan<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; _______________________________________________<br>
&gt;&gt; &gt; Sugar-devel mailing list<br>
&gt;&gt; &gt; <a href="mailto:Sugar-devel@lists.sugarlabs.org">Sugar-devel@lists.sugarlabs.org</a><br>
&gt;&gt; &gt; <a href="http://lists.sugarlabs.org/listinfo/sugar-devel" target="_blank">http://lists.sugarlabs.org/listinfo/sugar-devel</a><br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;<br>
&gt;<br>
_______________________________________________<br>
Sugar-devel mailing list<br>
<a href="mailto:Sugar-devel@lists.sugarlabs.org">Sugar-devel@lists.sugarlabs.org</a><br>
<a href="http://lists.sugarlabs.org/listinfo/sugar-devel" target="_blank">http://lists.sugarlabs.org/listinfo/sugar-devel</a><br>
</div></div></blockquote></div><br>