/usr/share/pyshared/timerapplet/ui/AddEditPresetDialog.py is in timer-applet 2.1.2-4.
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 | # Copyright (C) 2008 Jimmy Do <jimmydo@users.sourceforge.net>
#
# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import gtk
import gtk.glade as glade
from DurationChooser import DurationChooser
class AddEditPresetDialog(object):
def __init__(self, glade_file_name, title, name_validator_func,
name='', hours=0, minutes=0, seconds=0):
self._valid_name_func = name_validator_func
glade_widgets = glade.XML(glade_file_name, 'add_edit_preset_dialog')
self._dialog = glade_widgets.get_widget('add_edit_preset_dialog')
self._ok_button = glade_widgets.get_widget('ok_button')
self._cancel_button = glade_widgets.get_widget('cancel_button')
self._name_entry = glade_widgets.get_widget('name_entry')
duration_chooser_container = glade_widgets.get_widget('duration_chooser_container')
self._duration_chooser = DurationChooser(gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL))
duration_chooser_container.pack_start(self._duration_chooser)
self._dialog.set_title(title)
self._dialog.set_default_response(gtk.RESPONSE_OK)
self._name_entry.set_text(name)
self._duration_chooser.set_duration(hours, minutes, seconds)
self._name_entry.connect('changed', lambda entry: self._check_for_valid_save_preset_input())
self._duration_chooser.connect('duration-changed',
lambda chooser: self._check_for_valid_save_preset_input())
self._duration_chooser.show()
def _non_zero_duration(self):
(hours, minutes, seconds) = self._duration_chooser.get_duration()
return (hours > 0 or minutes > 0 or seconds > 0)
def _check_for_valid_save_preset_input(self):
self._ok_button.props.sensitive = (self._non_zero_duration() and
self._valid_name_func(self._name_entry.get_text()))
def get_preset(self):
self._check_for_valid_save_preset_input()
result = self._dialog.run()
self._dialog.hide()
if result == gtk.RESPONSE_OK:
(hours, minutes, seconds) = self._duration_chooser.get_duration()
return (self._name_entry.get_text(), hours, minutes, seconds)
else:
return None
|