Theme changes, fix for unicode conversion errors, misc
[rox-musicbox.git] / AppRun
blobd34f49a95ad63974eedbb3ba73a97f1d8cb0aeaf
1 #!/usr/bin/env python
2 import findrox; findrox.version(2, 0, 0)
3 import os, rox, sys
5 try:
6 __builtins__._ = rox.i18n.translation(os.path.join(rox.app_dir, 'Messages'))
8 from optparse import OptionParser
10 parser = OptionParser()
11 parser.add_option("--options",
12 action="store_true", dest="options", default=False,
13 help="display options dialog without running application")
15 parser.add_option("-l", "--load",
16 action="store_true", dest="load_songs", default=False,
17 help="replace the current playlist with listed songs and start playing")
19 parser.add_option("-e", "--enqueue",
20 action="store_true", dest="add_songs", default=False,
21 help="add listed songs to the playlist, do not start playing")
23 parser.add_option("-p", "--play",
24 action="store_true", dest="play", default=False,
25 help="start playing the current song")
27 parser.add_option("--pause",
28 action="store_true", dest="pause", default=False,
29 help="pause playing")
31 parser.add_option("--stop",
32 action="store_true", dest="stop", default=False,
33 help="stop playing")
35 parser.add_option("--next",
36 action="store_true", dest="next", default=False,
37 help="skip to the next song and start playing.")
39 parser.add_option("--prev",
40 action="store_true", dest="prev", default=False,
41 help="play the previous song")
43 (options, args) = parser.parse_args()
45 import gtk, musicbox, xsoap
47 if options.options:
48 rox.edit_options()
49 rox.mainloop()
50 else:
51 #see if another instance is running and pass it our args
52 window = xsoap.get_server("_ROX_MUSICBOX")
53 if window:
54 cmd = "load_songs" #default action
55 for opt in options.__dict__: #probably abusing optparse here, but I can see no
56 if options.__dict__[opt]: #other way to enumerate the options
57 cmd = opt
58 break #we don't support more than one, so stop at the first one.
59 xsoap.send_message(window, cmd, args)
60 else:
61 #if not then start a new instance
62 gtk.threads_init()
63 gtk.threads_enter()
64 box = musicbox.MusicBox()
65 box.show()
66 rox.mainloop()
67 gtk.threads_leave()
68 except:
69 rox.report_exception()