This file is indexed.

/usr/lib/sltv/ui/overlay.py is in landell 0.92.1-1.1ubuntu1.

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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
# -*- coding: utf-8 -*-
# Copyright (C) 2010 Holoscópio Tecnologia
# Author: Luciana Fujii Pontello <luciana@holoscopio.com>
# Author: Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
# Author: Marcelo Jorge Vieira <metal@holoscopio.com>
#
# 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 Street, Fifth Floor, Boston, MA 02110-1301 USA.


import gobject
import gtk
from sltv.settings import UI_DIR
import sltv.config as config

DEFAULT_FONT = "Sans Bold 14"
DEFAULT_HALIGN = "center"
DEFAULT_VALIGN = "baseline"

class OverlayUI:

    def __init__(self, ui, sltv):
        self.ui = ui
        self.sltv = sltv
        self.interface = gtk.Builder()
        self.interface.add_from_file(UI_DIR + "/overlay.ui")
        self.widget = self.interface.get_object("vbox")

        self.button = self.interface.get_object("apply_button")
        self.clear_button = self.interface.get_object("clear_button")
        self.textview = self.interface.get_object("overlay_textview")

        self.font_selector = gtk.FontSelectionDialog("Select a font name")

        self.font_selector_button = self.interface.get_object(
            "font_selector_button"
        )

        self.font_selector.set_transient_for(self.ui.main_window)
        self.font_selector.set_destroy_with_parent(True)

        self.font_selector_entry = self.interface.get_object(
            "font_selector_entry"
        )

        # halign
        self.left_button = self.interface.get_object("left_toolbutton")
        self.center_button = self.interface.get_object("center_toolbutton")
        self.right_button = self.interface.get_object("right_toolbutton")

        self.horizontal_group = gtk.ActionGroup("horizontal_group")
        horizontal_actions = [
            ("left_radioaction", "gtk-justify-left", "Left", None,
                "Left", 0),
            ("center_radioaction", "gtk-justify-center", "Center", None,
                "Center", 1),
            ("right_radioaction", "gtk-justify-right", "Right", None,
                "Right", 2)
        ]
        self.horizontal_group.add_radio_actions(
                horizontal_actions, 0, None, None
        )
        self.left_radioaction = self.horizontal_group.get_action("left_radioaction")
        self.left_radioaction.connect_proxy(self.left_button)
        self.center_radioaction = self.horizontal_group.get_action(
                "center_radioaction"
        )
        self.center_radioaction.connect_proxy(self.center_button)
        self.right_radioaction = self.horizontal_group.get_action(
                "right_radioaction"
        )
        self.right_radioaction.connect_proxy(self.right_button)

        # valign
        self.top_button = self.interface.get_object("top_toolbutton")
        self.baseline_button = self.interface.get_object("baseline_toolbutton")
        self.bottom_button = self.interface.get_object("bottom_toolbutton")

        self.vertical_group = gtk.ActionGroup("vertical_group")
        vertical_actions = [
            ("top_radioaction", "gtk-goto-top", "Top", None,
                "Top", 0),
            ("baseline_radioaction", "gtk-missing-image", "Baseline", None,
                "Baseline", 1),
            ("bottom_radioaction", "gtk-goto-bottom", "Bottom", None,
                "Bottom", 2)
        ]
        self.vertical_group.add_radio_actions(
                vertical_actions, 0, None, None
        )

        self.top_radioaction = self.vertical_group.get_action("top_radioaction")
        self.top_radioaction.connect_proxy(self.top_button)
        self.baseline_radioaction = self.vertical_group.get_action(
                "baseline_radioaction"
        )
        self.baseline_radioaction.connect_proxy(self.baseline_button)
        self.bottom_radioaction = self.vertical_group.get_action(
                "bottom_radioaction"
        )
        self.bottom_radioaction.connect_proxy(self.bottom_button)

        self._set_font(DEFAULT_FONT)
        self._set_halign(DEFAULT_HALIGN)
        self._set_valign(DEFAULT_VALIGN)

        self._set_config()
        self._load_config()

        self.button.connect("clicked", self.on_apply_clicked)
        self.clear_button.connect("clicked", self.on_clear_clicked)
        self.sltv.connect("preplay", self._preplay)
        self.sltv.connect("playing", self._playing)
        self.sltv.connect("stopped", self._stopped)
        self.font_selector_button.connect("clicked", self.on_font_change)
        self.font_selector.connect("response", self.on_close_dialog)
        self.left_radioaction.connect("changed", self.on_horizontal_changed)
        self.top_radioaction.connect("changed", self.on_vertical_changed)

    def _set_config(self):
        self.config = config.config
        self.section = "Settings"
        self.item = "Text Overlay"

    def _load_config(self):
        config_item = self.config.get_item(self.section, self.item)
        if config_item:
            if "font" in config_item:
                self._set_font(config_item['font'])
            if "halign" in config_item:
                self._set_halign(config_item['halign'])
            if "valign" in config_item:
                self._set_valign(config_item['valign'])

    def _set_halign(self, halign):
        self.halign = halign
        action = self.horizontal_group.get_action(self.halign+"_radioaction")
        action.set_active(True)

    def _set_valign(self, valign):
        self.valign = valign
        action = self.vertical_group.get_action(self.valign+"_radioaction")
        action.set_active(True)

    def _set_font(self, font):
        self.font = font
        self.font_selector_entry.set_text(font)
        self.font_selector.set_font_name(font)

    def on_font_change(self, event):
        self.font_selector.show_all()
        self.font_selector.run()

    def on_horizontal_changed(self, widget, current):
        name = current.get_name()
        if name == "left_radioaction":
            action = "left"
        elif name == "right_radioaction":
            action = "right"
        elif name == "center_radioaction":
            action = "center"

        self.halign = action
        self.save()

    def on_vertical_changed(self, widget, current):
        name = current.get_name()
        if name == "top_radioaction":
            action = "top"
        elif name == "bottom_radioaction":
            action = "bottom"
        elif name == "baseline_radioaction":
            action = "baseline"

        self.valign = action
        self.save()

    def _make_config(self):
        config = {}
        config['font'] = self.font
        config['valign'] = self.valign
        config['halign'] = self.halign
        return config

    def save(self):
        self.config.set_item(self.section, self.item, self._make_config())

    def on_close_dialog(self, dialog, response):
        if response == gtk.RESPONSE_CANCEL or \
           response == gtk.RESPONSE_DELETE_EVENT:
            dialog.hide_all()

        if response == gtk.RESPONSE_OK:
            font = self.font_selector.get_font_name()
            self._set_font(font)
            self.save()
            dialog.hide_all()

        if response == gtk.RESPONSE_APPLY:
            font = self.font_selector.get_font_name()
            self._set_font(font)
            self.save()

    def _get_text(self):
        buffer = self.textview.get_buffer()
        start_iter = buffer.get_start_iter()
        end_iter = buffer.get_end_iter()
        text = buffer.get_text(start_iter, end_iter, True)
        return text

    def apply_settings(self):
        self.sltv.set_overlay_text(self._get_text())
        self.sltv.set_overlay_font(self.font)
        self.sltv.set_halign(self.halign)
        self.sltv.set_valign(self.valign)

    def _preplay(self, sltv):
        self.apply_settings()

    def _playing(self, sltv):
        self.button.set_sensitive(True)

    def _stopped(self, sltv):
        self.button.set_sensitive(False)

    def on_apply_clicked(self, event):
        self.apply_settings()

    def on_clear_clicked(self, event):
        buffer = self.textview.get_buffer()
        buffer.set_text("")
        self.apply_settings()

    def get_widget(self):
        return self.widget