This file is indexed.

/usr/share/sugar/activities/Browse.activity/edittoolbar.py is in sugar-browse-activity 137-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# Copyright (C) 2008, One Laptop Per Child
# Copyright (C) 2009 Simon Schampijer
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

from gi.repository import GObject
from gi.repository import Gtk
from gi.repository import Gdk
from gettext import gettext as _

from sugar3.activity.widgets import EditToolbar as BaseEditToolbar
from sugar3.graphics import iconentry
from sugar3.graphics.toolbutton import ToolButton
from sugar3.graphics import style


class EditToolbar(BaseEditToolbar):
    def __init__(self, act):
        BaseEditToolbar.__init__(self)

        self._activity = act
        self._browser = None

        self.undo.connect('clicked', self.__undo_cb)
        self.redo.connect('clicked', self.__redo_cb)
        self.copy.connect('clicked', self.__copy_cb)
        self.paste.connect('clicked', self.__paste_cb)

        separator = Gtk.SeparatorToolItem()
        separator.set_draw(False)
        separator.set_expand(True)
        self.insert(separator, -1)
        separator.show()

        search_item = Gtk.ToolItem()
        self.search_entry = iconentry.IconEntry()
        self.search_entry.set_icon_from_name(iconentry.ICON_ENTRY_PRIMARY,
                                             'system-search')
        self.search_entry.add_clear_button()
        self.search_entry.connect('activate', self.__search_entry_activate_cb)
        self.search_entry.connect('changed', self.__search_entry_changed_cb)

        width = int(Gdk.Screen.width() / 3)
        self.search_entry.set_size_request(width, -1)

        search_item.add(self.search_entry)
        self.search_entry.show()

        self.insert(search_item, -1)
        search_item.show()

        self._prev = ToolButton('go-previous-paired')
        self._prev.set_tooltip(_('Previous'))
        self._prev.props.sensitive = False
        self._prev.connect('clicked', self.__find_previous_cb)
        self.insert(self._prev, -1)
        self._prev.show()

        self._next = ToolButton('go-next-paired')
        self._next.set_tooltip(_('Next'))
        self._next.props.sensitive = False
        self._next.connect('clicked', self.__find_next_cb)
        self.insert(self._next, -1)
        self._next.show()

        tabbed_view = self._activity.get_canvas()

        GObject.idle_add(lambda:
                self._connect_to_browser(tabbed_view.props.current_browser))

        tabbed_view.connect_after('switch-page', self.__switch_page_cb)

    def __switch_page_cb(self, tabbed_view, page, page_num):
        self._connect_to_browser(tabbed_view.props.current_browser)

    def _connect_to_browser(self, browser):
        if self._browser is not None:
            self._browser.disconnect(self._selection_changed_hid)

        self._browser = browser

        self._update_undoredo_buttons()
        self._update_copypaste_buttons()

        self._selection_changed_hid = self._browser.connect(
                'selection-changed', self._selection_changed_cb)

    def _selection_changed_cb(self, widget):
        self._update_undoredo_buttons()
        self._update_copypaste_buttons()

    def _update_undoredo_buttons(self):
        self.undo.set_sensitive(self._browser.can_undo())
        self.redo.set_sensitive(self._browser.can_redo())

    def _update_copypaste_buttons(self):
        self.copy.set_sensitive(self._browser.can_copy_clipboard())
        self.paste.set_sensitive(self._browser.can_paste_clipboard())

    def __undo_cb(self, button):
        self._browser.undo()
        self._update_undoredo_buttons()

    def __redo_cb(self, button):
        self._browser.redo()
        self._update_undoredo_buttons()

    def __copy_cb(self, button):
        self._browser.copy_clipboard()

    def __paste_cb(self, button):
        self._browser.paste_clipboard()

    def _find_and_mark_text(self, entry):
        search_text = entry.get_text()
        self._browser.unmark_text_matches()
        self._browser.mark_text_matches(search_text, case_sensitive=False,
                                        limit=0)
        self._browser.set_highlight_text_matches(True)
        found = self._browser.search_text(search_text, case_sensitive=False,
                                          forward=True, wrap=True)
        return found

    def __search_entry_activate_cb(self, entry):
        self._find_and_mark_text(entry)

    def __search_entry_changed_cb(self, entry):
        found = self._find_and_mark_text(entry)
        if not found:
            self._prev.props.sensitive = False
            self._next.props.sensitive = False
            entry.modify_text(Gtk.StateType.NORMAL,
                              style.COLOR_BUTTON_GREY.get_gdk_color())
        else:
            self._prev.props.sensitive = True
            self._next.props.sensitive = True
            entry.modify_text(Gtk.StateType.NORMAL,
                              style.COLOR_BLACK.get_gdk_color())

    def __find_previous_cb(self, button):
        search_text = self.search_entry.get_text()
        self._browser.search_text(search_text, case_sensitive=False,
                                  forward=False, wrap=True)

    def __find_next_cb(self, button):
        search_text = self.search_entry.get_text()
        self._browser.search_text(search_text, case_sensitive=False,
                                  forward=True, wrap=True)