-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
89 lines (77 loc) · 2.58 KB
/
main.py
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
import findrox; findrox.version(2, 0, 3)
import rox
from rox import choices, OptionsBox
def build_filechooser(self, node, label, option):
"""<filechooser name='...' label='...'/>Tooltip</filechooser>.
Lets the user choose a file (using a GtkFileChooser or by drag-and-drop).
Note: Since the FileChooserButton widget requires GTK >= 2.6, lesser GTK
versions will just show a normal text entry box, which should work with DND.
"""
if g.gtk_version >= (2,6,0):
filebutton = g.FileChooserButton(label)
eb = g.EventBox()
eb.add(filebutton)
clearbutton = g.Button("Clear")
self.may_add_tip(eb, node)
hbox = g.HBox(False, 4)
if label:
hbox.pack_start(g.Label(label + ":"), False, True, 0)
hbox.pack_start(eb, True, True, 0)
hbox.pack_start(clearbutton, False, True, 0)
self.handlers[option] = (
lambda: filebutton.get_filename(),
lambda: filebutton.set_filename(option.value))
filebutton.connect('selection-changed', lambda w: self.check_widget(option))
clearbutton.connect('clicked', lambda w: filebutton.set_filename("") )
return [hbox]
else:
# Fallback to text input
return self.build_entry(node, label, option)
OptionsBox.widget_registry['filechooser'] = build_filechooser
choices.migrate('Memo', 'rox.sourceforge.net')
import os, __builtin__
__builtin__._ = rox.i18n.translation(os.path.join(rox.app_dir, 'Messages'))
rox.setup_app_options('Memo', site = 'rox.sourceforge.net')
from rox.Menu import set_save_name
set_save_name('Memo', site = 'rox.sourceforge.net')
import Window, memos, clock
try:
# Need this for the Systray options
import Systray
except AssertionError:
pass
# All options must be registered by the time we get here
rox.app_options.notify()
# This is just to prevent us from loading two copies...
memo_service = 'net.sourceforge.rox.Memo'
from rox import xxmlrpc, g, tasks
try:
proxy = xxmlrpc.XXMLProxy(memo_service)
# Check to make sure it really is running...
def check():
call = proxy.get_object('/').get_pid()
yield call, tasks.TimeoutBlocker(2)
if call.happened:
pid = call.get_response()
rox.alert('Memo is already running (PID = %d)!' % pid)
os._exit(1)
g.main_quit()
tasks.Task(check())
g.main()
print "Possible existing copy of Memo is not responding"
except xxmlrpc.NoSuchService:
pass # Good
server = xxmlrpc.XXMLRPCServer(memo_service)
class MemoObject:
allowed_methods = ['get_pid']
def get_pid(self):
return os.getpid()
server.add_object('/', MemoObject())
memo_list = memos.MasterList()
main_window = Window.Window(memo_list)
def main():
try:
rox.mainloop()
finally:
import dbus_notify
dbus_notify.close_all()