You are not logged in.
Pages: 1
I am currently writing a "skin" for xmms2, and although everything is going to plan, I have realised I am using GLib for my xmms2 connection. I have a connection.py file like this :-
from gi.repository.GLib import io_add_watch, IO_OUT, IO_IN, source_remove
class GLibConnector:
def __init__(self, xmms):
self.in_id = None
self.out_id = None
self.reconnect(xmms)
def need_out(self, i):
if self.xmms.want_ioout() and self.out_id is None:
self.out_id = io_add_watch(self.xmms.get_fd(), IO_OUT, self.handle_out)
def handle_in(self, source, cond):
if cond == IO_IN:
return self.xmms.ioin()
return True
def handle_out(self, source, cond):
if cond == IO_OUT and self.xmms.want_ioout():
self.xmms.ioout()
if not self.xmms.want_ioout():
self.out_id = None
return not self.out_id is None
def reconnect(self, xmms=None):
self.disconnect()
if not xmms is None:
self.xmms = xmms
self.xmms.set_need_out_fun(self.need_out)
self.in_id = io_add_watch(self.xmms.get_fd(), IO_IN, self.handle_in)
self.out_id = None
def disconnect(self):
if not self.in_id is None:
source_remove(self.in_id)
self.in_id = None
if not self.out_id is None:
source_remove(self.out_id)
self.out_id = None
and then in my functions I lead with this :-
xmms = xmmsclient.XMMS("myfunc")
try:
xmms.connect(os.getenv("XMMS_PATH"))
except IOError, detail:
print "Connection failed:", detail
sys.exit(1)
conn = GLibConnector(xmms)
then to get the current playing medialib id I can do something like :-
def get_current_id():
result = xmms.playback_current_id()
result.wait()
if result.is_error():
return False
return result
Like I said, everything works fine and I have no reason to change it except that gi.repository is not included with a standard install of q4os and I would like to make this with as few as possible extra install requirements. Plus of course it would be better to have my app completely "qt".
I have been looking at other xmms2 skins that use qt, but lack the current understanding of how they use the connections.
Any advice/suggestions welcome.
Dai
P.s. If anyone is interested I have attached a current screenshot of it working.
Offline
Pages: 1