This file is indexed.

/usr/share/pyshared/Onboard/Indicator.py is in onboard 0.97.0-0ubuntu3.

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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# -*- coding: utf-8 -*-

from __future__ import division, print_function, unicode_literals

import os

from gi.repository import GObject, Gtk

import Onboard.utils as utils

### Logging ###
import logging
_logger = logging.getLogger("Indicator")
###############

### Config Singleton ###
from Onboard.Config import Config
config = Config()
########################


class Indicator(GObject.GObject):

    __gsignals__ = {
        str('quit-onboard') : (GObject.SIGNAL_RUN_LAST, GObject.TYPE_NONE, ())
    }

    "Keyboard window managed by this indicator"
    _keyboard_window = None

    "Encapsulated appindicator instance"
    _indicator = None

    "Encapsulated GtkStatusIcon instance"
    _status_icon = None

    "Menu attached to indicator"
    _menu = None

    def __new__(cls, *args, **kwargs):
        """
        Singleton magic.
        """
        if not hasattr(cls, "self"):
            cls.self = GObject.GObject.__new__(cls, args, kwargs)
            #object.__new__(cls, args, kwargs)
            cls.self.init()
        return cls.self

    def __init__(self):
        """
        This constructor is still called multiple times.
        Do nothing here and use the singleton constructor "init()" instead.
        """
        pass

    def init(self):

        GObject.GObject.__init__(self)

        self._menu = Gtk.Menu()

        # This updates the menu in gnome-shell and gnome-classic, 
        # but not in unity or unity2D.
        self._menu.connect_object("show", Indicator.update_menu_items, self)

        self._show_label = _("_Show Onboard")
        self._hide_label = _("_Hide Onboard")

        show_item = Gtk.MenuItem.new_with_label(self._show_label)
        show_item.set_use_underline(True)
        show_item.connect_object("activate",
            Indicator._toggle_keyboard_window_state, self)
        self._menu.append(show_item)

        if not config.lockdown.disable_preferences:
            settings_item = Gtk.ImageMenuItem.new_with_label(Gtk.STOCK_PREFERENCES)
            settings_item.set_use_stock(True)
            settings_item.connect("activate", self._on_settings_clicked)
            self._menu.append(settings_item)

        if not config.lockdown.disable_quit:
            quit_item = Gtk.ImageMenuItem.new_with_label(Gtk.STOCK_QUIT)
            quit_item.set_use_stock(True)
            quit_item.connect("activate", self._emit_quit_onboard)
            self._menu.append(quit_item)
        self._menu.show_all()

        try:
            self._init_indicator()
        except ImportError:
            _logger.info("AppIndicator not available, falling back on"
                " GtkStatusIcon")
            self._init_status_icon()
        self.set_visible(False)

    def set_keyboard_window(self, keyboard_window):
        self._keyboard_window = keyboard_window

    def update_menu_items(self):
        if self._keyboard_window:
            if self._keyboard_window.is_visible():
                self._menu.get_children()[0].set_label(self._hide_label)
            else:
                self._menu.get_children()[0].set_label(self._show_label)

    def _init_indicator(self):
        from gi.repository import AppIndicator3 as AppIndicator
        self._indicator = AppIndicator.Indicator.new(
            "Onboard",
            "onboard",
            AppIndicator.IndicatorCategory.APPLICATION_STATUS)
        self._indicator.set_icon_full("onboard-mono", _("Onboard on-screen keyboard"))

        self._indicator.set_menu(self._menu)
        self._indicator.set_secondary_activate_target( \
                                                self._menu.get_children()[0])

    def _init_status_icon(self):
        self._status_icon = Gtk.StatusIcon(icon_name="onboard")
        self._status_icon.connect_object("activate",
            Indicator._toggle_keyboard_window_state, self)
        self._status_icon.connect("popup-menu", self._on_status_icon_popup_menu)

    def set_visible(self, visible):
        if self._status_icon:
            # Then we've falled back to using GtkStatusIcon
            self._status_icon.set_visible(visible)
        else:
            self._set_indicator_active(visible)

    def _on_settings_clicked(self, widget):
        utils.run_script("sokSettings")

    def _menu_position_func(self, menu, *args):
        # Work-around for gi annotation bug in gtk-3.0:
        # gtk_status_icon_position_menu() doesn't mark 'push_in' as inout
        # which is required for any (*GtkMenuPositionFunc)
        if len(args) == 1:    # in Precise
            status_icon, = args
        elif len(args) == 2:  # in <=Oneiric?
            push_in, status_icon = args
        return Gtk.StatusIcon.position_menu(self._menu, status_icon)

    def _on_status_icon_popup_menu(self, status_icon, button, activate_time):
        """
        Callback called when status icon right clicked.  Produces menu.
        """
        self._menu.popup(None, None,
                         self._menu_position_func, status_icon,
                         button, activate_time)

    def _toggle_keyboard_window_state(self):
        self._keyboard_window.keyboard.toggle_visible()

    def _set_indicator_active(self, active):
        try:
            from gi.repository import AppIndicator3 as AppIndicator
        except ImportError:
            pass
        else:
            if active:
                self._indicator.set_status(AppIndicator.IndicatorStatus.ACTIVE)
            else:
                self._indicator.set_status(AppIndicator.IndicatorStatus.PASSIVE)

    def _emit_quit_onboard(self, data=None):
        _logger.debug("Entered _emit_quit_onboard")
        self.emit("quit-onboard")

    def is_appindicator(self):
        if self._indicator:
            return True
        else:
            return False