MCGClient: method next() added

This commit is contained in:
coderkun 2012-06-24 01:15:07 +02:00
parent 1f3a7aef88
commit 1fe9ce31a2
2 changed files with 18 additions and 17 deletions

17
mcg.py
View file

@ -97,6 +97,12 @@ class MCGClient:
self._add_action(self._playpause) self._add_action(self._playpause)
def next(self):
"""Plays the next album in the current order
"""
self._add_action(self._next)
def connect_signal(self, signal, callback): def connect_signal(self, signal, callback):
"""Connects a callback function to a signal (event). """Connects a callback function to a signal (event).
""" """
@ -169,7 +175,7 @@ class MCGClient:
self._connected = True self._connected = True
self._callback(self.SIGNAL_CONNECT, self._connected, None) self._callback(self.SIGNAL_CONNECT, self._connected, None)
self.update() self.update()
self._add_action(self._get_status) self.get_status()
except IOError as e: except IOError as e:
self._connected = False self._connected = False
self._callback(self.SIGNAL_CONNECT, self._connected, e) self._callback(self.SIGNAL_CONNECT, self._connected, e)
@ -245,6 +251,15 @@ class MCGClient:
self._client.play() self._client.play()
def _next(self):
"""Action: Performs the real next command.
"""
song = self._client.currentsong()
if song:
current_album = MCGAlbum(song['artist'], song['album'], song['date'], os.path.dirname(song['file']))
# TODO _next()
def _idle(self, modules): def _idle(self, modules):
"""Reacts to idle events from MPD. """Reacts to idle events from MPD.
""" """

View file

@ -37,7 +37,6 @@ class MCGGtk(Gtk.Window):
self.connect('delete-event', self.destroy) self.connect('delete-event', self.destroy)
self._toolbar.connect_signal(Toolbar.SIGNAL_CONNECT, self.toolbar_connect_cb) self._toolbar.connect_signal(Toolbar.SIGNAL_CONNECT, self.toolbar_connect_cb)
self._toolbar.connect_signal(Toolbar.SIGNAL_UPDATE, self.toolbar_update_cb) self._toolbar.connect_signal(Toolbar.SIGNAL_UPDATE, self.toolbar_update_cb)
self._toolbar.connect_signal(Toolbar.SIGNAL_PREV, self.toolbar_prev_cb)
self._toolbar.connect_signal(Toolbar.SIGNAL_PLAYPAUSE, self.toolbar_playpause_cb) self._toolbar.connect_signal(Toolbar.SIGNAL_PLAYPAUSE, self.toolbar_playpause_cb)
self._toolbar.connect_signal(Toolbar.SIGNAL_NEXT, self.toolbar_next_cb) self._toolbar.connect_signal(Toolbar.SIGNAL_NEXT, self.toolbar_next_cb)
self._cover_panel.connect_signal(CoverPanel.SIGNAL_PLAY, self.cover_panel_play_cb) self._cover_panel.connect_signal(CoverPanel.SIGNAL_PLAY, self.cover_panel_play_cb)
@ -85,19 +84,12 @@ class MCGGtk(Gtk.Window):
self._mcg.update() self._mcg.update()
def toolbar_prev_cb(self):
"""TODO prev()
"""
pass
def toolbar_playpause_cb(self): def toolbar_playpause_cb(self):
self._mcg.playpause() self._mcg.playpause()
def toolbar_next_cb(self): def toolbar_next_cb(self):
"""TODO next() self._mcg.next()
"""
pass
# Cover panel callbacks # Cover panel callbacks
@ -170,9 +162,8 @@ class MCGGtk(Gtk.Window):
class Toolbar(Gtk.Toolbar): class Toolbar(Gtk.Toolbar):
SIGNAL_CONNECT = 'connect' SIGNAL_CONNECT = 'connect'
SIGNAL_UPDATE = 'update' SIGNAL_UPDATE = 'update'
SIGNAL_PREV = 'prev'
SIGNAL_NEXT = 'next'
SIGNAL_PLAYPAUSE = 'playpause' SIGNAL_PLAYPAUSE = 'playpause'
SIGNAL_NEXT = 'next'
def __init__(self): def __init__(self):
Gtk.Toolbar.__init__(self) Gtk.Toolbar.__init__(self)
@ -186,8 +177,6 @@ class Toolbar(Gtk.Toolbar):
self._update_button = Gtk.ToolButton(Gtk.STOCK_REFRESH) self._update_button = Gtk.ToolButton(Gtk.STOCK_REFRESH)
self.add(self._update_button) self.add(self._update_button)
self.add(Gtk.SeparatorToolItem()) self.add(Gtk.SeparatorToolItem())
self._prev_button = Gtk.ToolButton(Gtk.STOCK_MEDIA_PREVIOUS)
self.add(self._prev_button)
self._playpause_button = Gtk.ToolButton(Gtk.STOCK_MEDIA_PLAY) self._playpause_button = Gtk.ToolButton(Gtk.STOCK_MEDIA_PLAY)
self.add(self._playpause_button) self.add(self._playpause_button)
self._next_button = Gtk.ToolButton(Gtk.STOCK_MEDIA_NEXT) self._next_button = Gtk.ToolButton(Gtk.STOCK_MEDIA_NEXT)
@ -196,7 +185,6 @@ class Toolbar(Gtk.Toolbar):
# Signals # Signals
self._connection_button.connect('clicked', self._callback) self._connection_button.connect('clicked', self._callback)
self._update_button.connect('clicked', self._callback) self._update_button.connect('clicked', self._callback)
self._prev_button.connect('clicked', self._callback)
self._playpause_button.connect('clicked', self._callback) self._playpause_button.connect('clicked', self._callback)
self._next_button.connect('clicked', self._callback) self._next_button.connect('clicked', self._callback)
@ -240,8 +228,6 @@ class Toolbar(Gtk.Toolbar):
signal = self.SIGNAL_CONNECT signal = self.SIGNAL_CONNECT
if widget == self._update_button: if widget == self._update_button:
signal = self.SIGNAL_UPDATE signal = self.SIGNAL_UPDATE
if widget == self._prev_button:
signal = self.SIGNAL_PREV
if widget == self._playpause_button: if widget == self._playpause_button:
signal = self.SIGNAL_PLAYPAUSE signal = self.SIGNAL_PLAYPAUSE
if widget == self._next_button: if widget == self._next_button: