14
gnome.sound_init("localhost")
24
class __GstPlayThread(threading.Thread):
25
def __init__(self, ply):
27
threading.Thread.__init__(self)
29
self.ply.set_state(gst.STATE_PLAYING)
30
def bus_event(bus, message):
32
if t == gst.MESSAGE_EOS:
33
self.ply.set_state(gst.STATE_NULL)
35
self.ply.get_bus().add_watch(bus_event)
38
def __gstplay(filename):
41
location = os.path.join(cwd, filename)
42
ply = gst.element_factory_make("playbin", "player")
43
ply.set_property("uri", "file://" + location)
44
pt = __GstPlayThread(ply)
49
if ENGINE == GNOMEPLAY:
50
def playsnd(filename):
51
gnome.sound_play(filename)
52
elif ENGINE == GSTPLAY:
55
def playsnd(filename):
60
def invoke_subprocess(cmdline):
62
setsid = getattr(os, 'setsid', None)
63
p = subprocess.Popen(cmdline, close_fds = True, preexec_fn = setsid)
65
print "Warning: cannot execute", cmdline
69
def get_default_mail_reader():
70
client = gconf.client_get_default()
71
cmd = client.get_string("/desktop/gnome/url-handlers/mailto/command")
74
def open_mail_reader():
75
cmdline = get_default_mail_reader()
76
invoke_subprocess(cmdline)
78
def open_browser(url):
79
client = gconf.client_get_default()
80
cmd = client.get_string("/desktop/gnome/applications/browser/exec")
81
cmdline = [cmd.split()[0], url]
82
invoke_subprocess(cmdline)
84
if __name__ == "__main__":
86
open_browser("http://google.it")