diff --git a/mcg.py b/mcg.py index 6c783f3..5cafe85 100644 --- a/mcg.py +++ b/mcg.py @@ -208,7 +208,6 @@ class MCGClient: album.add_track(track) except KeyError: pass - # TODO Alben sortieren self._callback(self.SIGNAL_UPDATE, self._albums) @@ -221,9 +220,11 @@ class MCGClient: state = status['state'] song = self._client.currentsong() album = None + pos = None if song: - album = MCGAlbum(song['artist'], song['album'], song['date'], os.path.dirname(song['file'])) - self._callback(self.SIGNAL_STATUS, state, album) + album = self._albums[MCGAlbum(song['artist'], song['album'], song['date'], os.path.dirname(song['file'])).get_hash()] + pos = int(song['pos']) + self._callback(self.SIGNAL_STATUS, state, album, pos) def _play(self, album): diff --git a/mcgGtk.py b/mcgGtk.py index 8093a7b..2a32703 100755 --- a/mcgGtk.py +++ b/mcgGtk.py @@ -147,14 +147,15 @@ class MCGGtk(Gtk.Window): GObject.idle_add(self._connect_disconnected) - def mcg_status_cb(self, state, album): + def mcg_status_cb(self, state, album, pos): if state == 'play': GObject.idle_add(self._toolbar.set_pause) elif state == 'pause' or state == 'stop': GObject.idle_add(self._toolbar.set_play) 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): @@ -243,6 +244,11 @@ class Toolbar(Gtk.Toolbar): self.add(self._playpause_button) self._next_button = Gtk.ToolButton(Gtk.STOCK_MEDIA_NEXT) 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.set_draw(False) separator.set_expand(True) @@ -304,6 +310,11 @@ class Toolbar(Gtk.Toolbar): 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): value = round(value) range = self._grid_size_scale.get_adjustment() @@ -590,6 +601,7 @@ class CoverPanel(Gtk.HPaned): album = albums[hash] file = album.get_cover() if file is None: + # TODO Dummy continue pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(file, self._config.grid_item_size, self._config.grid_item_size) if pixbuf is None: @@ -610,8 +622,10 @@ class CoverPanel(Gtk.HPaned): 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 + url = album.get_cover() if url is not None and url != "": # Load image and draw it self._cover_pixbuf = GdkPixbuf.Pixbuf.new_from_file(url)