/usr/share/gnome-schedule/scheduleapplet.py is in gnome-schedule 2.1.1-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 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 | # scheduleapplet.py: contains code for the gnome-schedule applet
# Copyright (C) 2004 - 2009 Gaute Hope <eg at gaute dot vetsj dot com>
# Copyright (C) 2004, 2005 Kristof Vansant <de_lupus at pandora dot be>
#
# 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., 675 Mass Ave, Cambridge, MA 02139, USA.
#python modules
import sys
import signal
import os
#custom modules
import config
import mainWindow
poscorrect_isset = os.getenv ("POSIXLY_CORRECT", False)
manual_poscorrect = False
if poscorrect_isset == False:
os.putenv ("POSIXLY_CORRECT", "enabled")
manual_poscorrect = True
##
## I18N
##
import gettext
import locale
gettext.install(config.GETTEXT_PACKAGE(), config.GNOMELOCALEDIR(), unicode=1)
if __name__ == "__main__":
signal.signal (signal.SIGINT, signal.SIG_DFL)
debug_flag = None
if '--debug' in sys.argv:
debug_flag = 1
try:
import pygtk
#tell pyGTK, if possible, that we want GTKv2
pygtk.require("2.0")
except:
#Some distributions come with GTK2, but not pyGTK
pass
try:
import gtk
import gtk.glade
# TODO: Gnome specific
import gnome
import gnome.ui
import gnomeapplet
import gobject
except:
print _("You need to install pyGTK or GTKv2,\n"
"or set your PYTHONPATH correctly.\n"
"try: export PYTHONPATH= ")
sys.exit(1)
props = { gnome.PARAM_APP_DATADIR : config.getPrefix() + "/share"}
pr = gnome.program_init ("gnome-schedule", config.getVersion(), properties=props)
class ScheduleApplet(gnomeapplet.Applet):
def __init__(self, applet, iid, gprogram, debug_flag, manual_poscorrect):
self.__gobject_init__()
self.debug_flag = debug_flag
self.manual_poscorrect = manual_poscorrect
gettext.bindtextdomain(config.GETTEXT_PACKAGE(), config.GNOMELOCALEDIR())
gettext.textdomain(config.GETTEXT_PACKAGE())
locale.bindtextdomain(config.GETTEXT_PACKAGE(), config.GNOMELOCALEDIR())
locale.textdomain(config.GETTEXT_PACKAGE())
self.applet = applet
self.gprogram = gprogram
self.__loadIcon__()
self.ev_box = gtk.EventBox()
self.image = gtk.Image()
self.image.set_from_pixbuf(self.iconPixbuf)
self.main_loaded = False
self.ev_box.add(self.image)
self.ev_box.show()
self.ev_box.set_events(gtk.gdk.BUTTON_PRESS_MASK)
self.ev_box.connect("button_press_event", self.event_box_clicked)
self.applet.add(self.ev_box)
self.create_menu()
self.applet.show_all()
def __loadIcon__(self):
if self.debug_flag:
if os.access("../icons/gnome-schedule.svg", os.F_OK):
self.iconPixbuf = gtk.gdk.pixbuf_new_from_file_at_size ("../icons/gnome-schedule.svg", 18, 18)
else:
try:
self.iconPixbuf = gtk.gdk.pixbuf_new_from_file_at_size (config.getImagedir() + "/gnome-schedule.svg", 24, 24)
except:
print _("ERROR: Could not load icon")
def create_menu(self):
self.verbs = [ ("show_main", self.show_main_window),
("add", self.add_task),
("help", self.show_help),
("about", self.show_about)
]
#check for file in current dir
if self.debug_flag:
if os.access ("gnome-schedule-applet.xml", os.F_OK):
datadir = './'
else:
if os.access (config.getGladedir() + "/gnome-schedule-applet.xml", os.F_OK):
datadir = config.getGladedir()
else:
print _("ERROR: Could not load menu xml file")
datadir = ''
quit ()
self.applet.setup_menu_from_file(datadir, "gnome-schedule-applet.xml", "gnome-schedule", self.verbs)
def event_box_clicked (self, widget, event):
if event.type == gtk.gdk._2BUTTON_PRESS:
self.show_main_window()
def show_main_window(self, *args):
if self.main_loaded == False:
self.main_loaded = True
self.main_window = mainWindow.main(None, True, self.gprogram, self.manual_poscorrect)
else:
self.main_window.widget.show ()
self.main_window.schedule_reload()
def add_task(self, *args):
if self.main_loaded == False:
self.show_main_window()
self.main_window.widget.hide()
self.main_window.on_add_scheduled_task_menu_activate()
def show_help(self, *args):
if self.main_loaded == False:
self.show_main_window()
self.main_window.widget.hide()
self.main_window.on_manual_menu_activate()
def show_about(self, *args):
if self.main_loaded == False:
self.show_main_window()
self.main_window.widget.hide()
self.main_window.on_about_menu_activate()
gobject.type_register(ScheduleApplet)
#factory
def schedule_applet_factory(applet, iid):
ScheduleApplet(applet, iid, pr, debug_flag, manual_poscorrect)
return True
gnomeapplet.bonobo_factory("OAFIID:GNOME_GnomeSchedule_Factory",
ScheduleApplet.__gtype__,
"GnomeScheduleApplet", "0", schedule_applet_factory)
|