1 import findrox
; findrox
.version(2, 0, 3)
3 from rox
import choices
, OptionsBox
5 def build_filechooser(self
, node
, label
, option
):
6 """<filechooser name='...' label='...'/>Tooltip</filechooser>.
7 Lets the user choose a file (using a GtkFileChooser or by drag-and-drop).
8 Note: Since the FileChooserButton widget requires GTK >= 2.6, lesser GTK
9 versions will just show a normal text entry box, which should work with DND.
11 if g
.gtk_version
>= (2,6,0):
12 filebutton
= g
.FileChooserButton(label
)
15 clearbutton
= g
.Button("Clear")
16 self
.may_add_tip(eb
, node
)
17 hbox
= g
.HBox(False, 4)
19 hbox
.pack_start(g
.Label(label
+ ":"), False, True, 0)
20 hbox
.pack_start(eb
, True, True, 0)
21 hbox
.pack_start(clearbutton
, False, True, 0)
22 self
.handlers
[option
] = (
23 lambda: filebutton
.get_filename(),
24 lambda: filebutton
.set_filename(option
.value
))
25 filebutton
.connect('selection-changed', lambda w
: self
.check_widget(option
))
26 clearbutton
.connect('clicked', lambda w
: filebutton
.set_filename("") )
29 # Fallback to text input
30 return self
.build_entry(node
, label
, option
)
32 OptionsBox
.widget_registry
['filechooser'] = build_filechooser
34 choices
.migrate('Memo', 'rox.sourceforge.net')
36 import os
, __builtin__
37 __builtin__
._ = rox
.i18n
.translation(os
.path
.join(rox
.app_dir
, 'Messages'))
39 rox
.setup_app_options('Memo', site
= 'rox.sourceforge.net')
41 from rox
.Menu
import set_save_name
42 set_save_name('Memo', site
= 'rox.sourceforge.net')
44 import Window
, memos
, clock
46 # All options must be registered by the time we get here
47 rox
.app_options
.notify()
49 # This is just to prevent us from loading two copies...
50 memo_service
= 'net.sourceforge.rox.Memo'
51 from rox
import xxmlrpc
, g
, tasks
53 proxy
= xxmlrpc
.XXMLProxy(memo_service
)
54 # Check to make sure it really is running...
56 call
= proxy
.get_object('/').get_pid()
57 yield call
, tasks
.TimeoutBlocker(2)
59 pid
= call
.get_response()
60 rox
.alert('Memo is already running (PID = %d)!' % pid
)
65 print "Possible existing copy of Memo is not responding"
66 except xxmlrpc
.NoSuchService
:
68 server
= xxmlrpc
.XXMLRPCServer(memo_service
)
70 allowed_methods
= ['get_pid']
73 server
.add_object('/', MemoObject())
75 memo_list
= memos
.MasterList()
77 main_window
= Window
.Window(memo_list
)
84 dbus_notify
.close_all()