Added trackinfo in toolbar
This commit is contained in:
parent
098c2e2d14
commit
0d270d3fab
2 changed files with 21 additions and 6 deletions
7
mcg.py
7
mcg.py
|
|
@ -208,7 +208,6 @@ class MCGClient:
|
||||||
album.add_track(track)
|
album.add_track(track)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
# TODO Alben sortieren
|
|
||||||
self._callback(self.SIGNAL_UPDATE, self._albums)
|
self._callback(self.SIGNAL_UPDATE, self._albums)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -221,9 +220,11 @@ class MCGClient:
|
||||||
state = status['state']
|
state = status['state']
|
||||||
song = self._client.currentsong()
|
song = self._client.currentsong()
|
||||||
album = None
|
album = None
|
||||||
|
pos = None
|
||||||
if song:
|
if song:
|
||||||
album = MCGAlbum(song['artist'], song['album'], song['date'], os.path.dirname(song['file']))
|
album = self._albums[MCGAlbum(song['artist'], song['album'], song['date'], os.path.dirname(song['file'])).get_hash()]
|
||||||
self._callback(self.SIGNAL_STATUS, state, album)
|
pos = int(song['pos'])
|
||||||
|
self._callback(self.SIGNAL_STATUS, state, album, pos)
|
||||||
|
|
||||||
|
|
||||||
def _play(self, album):
|
def _play(self, album):
|
||||||
|
|
|
||||||
20
mcgGtk.py
20
mcgGtk.py
|
|
@ -147,14 +147,15 @@ class MCGGtk(Gtk.Window):
|
||||||
GObject.idle_add(self._connect_disconnected)
|
GObject.idle_add(self._connect_disconnected)
|
||||||
|
|
||||||
|
|
||||||
def mcg_status_cb(self, state, album):
|
def mcg_status_cb(self, state, album, pos):
|
||||||
if state == 'play':
|
if state == 'play':
|
||||||
GObject.idle_add(self._toolbar.set_pause)
|
GObject.idle_add(self._toolbar.set_pause)
|
||||||
elif state == 'pause' or state == 'stop':
|
elif state == 'pause' or state == 'stop':
|
||||||
GObject.idle_add(self._toolbar.set_play)
|
GObject.idle_add(self._toolbar.set_play)
|
||||||
|
|
||||||
if album:
|
if album:
|
||||||
GObject.idle_add(self._cover_panel.set_album, album.get_cover())
|
GObject.idle_add(self._cover_panel.set_album, album)
|
||||||
|
GObject.idle_add(self._toolbar.set_album, album, pos);
|
||||||
|
|
||||||
|
|
||||||
def mcg_update_cb(self, albums):
|
def mcg_update_cb(self, albums):
|
||||||
|
|
@ -243,6 +244,11 @@ class Toolbar(Gtk.Toolbar):
|
||||||
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)
|
||||||
self.add(self._next_button)
|
self.add(self._next_button)
|
||||||
|
self.add(Gtk.SeparatorToolItem())
|
||||||
|
self._track_item = Gtk.ToolItem()
|
||||||
|
self._track_label = Gtk.Label("hi")
|
||||||
|
self._track_item.add(self._track_label)
|
||||||
|
self.add(self._track_item)
|
||||||
separator = Gtk.SeparatorToolItem()
|
separator = Gtk.SeparatorToolItem()
|
||||||
separator.set_draw(False)
|
separator.set_draw(False)
|
||||||
separator.set_expand(True)
|
separator.set_expand(True)
|
||||||
|
|
@ -304,6 +310,11 @@ class Toolbar(Gtk.Toolbar):
|
||||||
self._playpause_button.set_sensitive(False);
|
self._playpause_button.set_sensitive(False);
|
||||||
|
|
||||||
|
|
||||||
|
def set_album(self, album, pos):
|
||||||
|
info = "{0} – {1} – {2} – {3}".format(album.get_tracks()[pos].get_title(), pos+1, album.get_title(), album.get_artist())
|
||||||
|
self._track_label.set_text(info)
|
||||||
|
|
||||||
|
|
||||||
def grid_size_temp_cb(self, widget, scroll, value):
|
def grid_size_temp_cb(self, widget, scroll, value):
|
||||||
value = round(value)
|
value = round(value)
|
||||||
range = self._grid_size_scale.get_adjustment()
|
range = self._grid_size_scale.get_adjustment()
|
||||||
|
|
@ -590,6 +601,7 @@ class CoverPanel(Gtk.HPaned):
|
||||||
album = albums[hash]
|
album = albums[hash]
|
||||||
file = album.get_cover()
|
file = album.get_cover()
|
||||||
if file is None:
|
if file is None:
|
||||||
|
# TODO Dummy
|
||||||
continue
|
continue
|
||||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(file, self._config.grid_item_size, self._config.grid_item_size)
|
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(file, self._config.grid_item_size, self._config.grid_item_size)
|
||||||
if pixbuf is None:
|
if pixbuf is None:
|
||||||
|
|
@ -610,8 +622,10 @@ class CoverPanel(Gtk.HPaned):
|
||||||
self._callback(self.SIGNAL_UPDATE_END)
|
self._callback(self.SIGNAL_UPDATE_END)
|
||||||
|
|
||||||
|
|
||||||
def set_album(self, url):
|
def set_album(self, album):
|
||||||
|
self._cover_image.set_tooltip_text(GObject.markup_escape_text("\n".join([album.get_title(), album.get_artist()])))
|
||||||
# Check path
|
# Check path
|
||||||
|
url = album.get_cover()
|
||||||
if url is not None and url != "":
|
if url is not None and url != "":
|
||||||
# Load image and draw it
|
# Load image and draw it
|
||||||
self._cover_pixbuf = GdkPixbuf.Pixbuf.new_from_file(url)
|
self._cover_pixbuf = GdkPixbuf.Pixbuf.new_from_file(url)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue