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
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
import sys
import gtk
import gnomeapplet
import gobject
import gettext
from gettext import gettext as _
import fiveadayapplet
def _creating_dev_env():
p = os.getcwd()
bonobo_server = """ <oaf_info>
<oaf_server iid="OAFIID:GNOME_PyFiveADayApplet_Factory" type="exe" location="%s/5-a-day-applet">
<oaf_attribute name="repo_ids" type="stringv">
<item value="IDL:Bonobo/GenericFactory:1.0"/>
<item value="IDL:Bonobo/Unknown:1.0"/>
</oaf_attribute>
<oaf_attribute name="name" type="string" value="PyFiveADayApplet Factory"/>
<oaf_attribute name="description" type="string" value="PyFiveADayApplet"/>
</oaf_server>
<oaf_server iid="OAFIID:GNOME_PyFiveADayApplet"
type="factory" location="OAFIID:GNOME_PyFiveADayApplet_Factory">
<oaf_attribute name="repo_ids" type="stringv">
<item value="IDL:GNOME/Vertigo/PanelAppletShell:1.0"/>
<item value="IDL:Bonobo/Control:1.0"/>
<item value="IDL:Bonobo/Unknown:1.0"/>
</oaf_attribute>
<oaf_attribute name="name" type="string" value="5-a-day Applet"/>
<oaf_attribute name="description" type="string" value="Simplify committing data to the 5-a-day project"/>
<oaf_attribute name="description-de" type="string" value="Bugs per drag&drop zum 5-a-day Projekt hinzufuegen"/>
<oaf_attribute name="panel:category" type="string" value="Utility"/>
<oaf_attribute name="panel:icon" type="string" value="%s/data/5-a-day.svg"/>
</oaf_server>
</oaf_info>""" %(p,p)
f = file("/tmp/GNOME_PyFiveADayApplet.server","w")
f.write(bonobo_server)
f.close()
import subprocess
s = subprocess.Popen("activation-client --add-path /tmp", shell=True)
s.wait()
def find_data_dir():
filename = '5-a-day.svg'
for path in ['data/', '/usr/share/5-a-day-applet']:
print >>sys.stderr, 'Checking %s' % path
if os.path.isfile(os.path.join(path, filename)):
return path
print >>sys.stderr, 'Could not find data dir, exiting.'
sys.exit(1)
controller = None
def factory(applet, iid, dev_mode=False):
global controller
print >>sys.stderr, "Constructing FiveADayApplet Controller"
try:
controller = fiveadayapplet.Controller(applet, find_data_dir(), dev_mode)
except:
import traceback
print >>sys.stderr, traceback.format_exc()
return True
def main():
gobject.threads_init()
dev_mode = False
gtk.glade.bindtextdomain("5-a-day")
gettext.textdomain("5-a-day")
if '-d' in sys.argv:
dev_mode = os.getcwd()
_creating_dev_env()
else:
sys.stderr = open('/tmp/5-a-day-applet.txt', 'a+', 0)
print >>sys.stderr, "Starting Bonobo factory"
gnomeapplet.bonobo_factory("OAFIID:GNOME_PyFiveADayApplet_Factory",
gnomeapplet.Applet.__gtype__, 'PyFiveADayApplet', '0', factory, dev_mode)
if __name__ == "__main__":
sys.exit(main())
if '-d' in sys.argv:
import subprocess
s = subprocess.Popen("activation-client --remove-path /tmp", shell=True)
s.wait()
|