[gnome-music/wip/jfelder/playback-status-v3: 6/10] albumwidget: Define different display modes
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/playback-status-v3: 6/10] albumwidget: Define different display modes
- Date: Mon, 4 Feb 2019 07:38:07 +0000 (UTC)
commit 1ef360836b872c2a012897de0b30efa81599cc0b
Author: Jean Felder <jfelder src gnome org>
Date: Mon Sep 10 08:05:52 2018 +0200
albumwidget: Define different display modes
Define two separate display mode for AlbumWidget: ALBUM and PLAYBACK.
ALBUM mode is the one already used by AlbumsView.
PLAYBACK mode is designed to be a smaller widget: it displays less
information (favorite status, year and composer are hidden), margins
are smaller and there is no selection mode. It will be used by the
future PlaybackPopover widget.
data/ui/AlbumWidget.ui | 2 +-
gnomemusic/views/albumsview.py | 2 +-
gnomemusic/views/searchview.py | 2 +-
gnomemusic/widgets/albumwidget.py | 49 +++++++++++++++++++++++++--------------
4 files changed, 35 insertions(+), 20 deletions(-)
---
diff --git a/data/ui/AlbumWidget.ui b/data/ui/AlbumWidget.ui
index f57634b3..fd514054 100644
--- a/data/ui/AlbumWidget.ui
+++ b/data/ui/AlbumWidget.ui
@@ -95,7 +95,7 @@
</packing>
</child>
<child>
- <object class="GtkGrid" id="grid">
+ <object class="GtkGrid" id="_information_grid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">21</property>
diff --git a/gnomemusic/views/albumsview.py b/gnomemusic/views/albumsview.py
index 4e0edf4f..175a0568 100644
--- a/gnomemusic/views/albumsview.py
+++ b/gnomemusic/views/albumsview.py
@@ -44,7 +44,7 @@ class AlbumsView(BaseView):
super().__init__('albums', _("Albums"), window)
self.player = player
- self._album_widget = AlbumWidget(player, self)
+ self._album_widget = AlbumWidget(player, self, AlbumWidget.Mode.ALBUM)
self.add(self._album_widget)
self.albums_selected = []
self.all_items = []
diff --git a/gnomemusic/views/searchview.py b/gnomemusic/views/searchview.py
index 010def73..8253dbfd 100644
--- a/gnomemusic/views/searchview.py
+++ b/gnomemusic/views/searchview.py
@@ -68,7 +68,7 @@ class SearchView(BaseView):
self._albums_selected = []
self._albums = {}
self._albums_index = 0
- self._album_widget = AlbumWidget(player, self)
+ self._album_widget = AlbumWidget(player, self, AlbumWidget.Mode.ALBUM)
self.add(self._album_widget)
self._artists_albums_selected = []
diff --git a/gnomemusic/widgets/albumwidget.py b/gnomemusic/widgets/albumwidget.py
index 286de2cb..1814ddc4 100644
--- a/gnomemusic/widgets/albumwidget.py
+++ b/gnomemusic/widgets/albumwidget.py
@@ -22,6 +22,8 @@
# code, but you are not obligated to do so. If you do not wish to do so,
# delete this exception statement from your version.
+from enum import IntEnum
+
from gettext import ngettext
from gi.repository import GdkPixbuf, GObject, Gtk
@@ -51,20 +53,26 @@ class AlbumWidget(Gtk.EventBox):
_composer_info_label = Gtk.Template.Child()
_cover_stack = Gtk.Template.Child()
_disc_listbox = Gtk.Template.Child()
+ _information_grid = Gtk.Template.Child()
_released_info_label = Gtk.Template.Child()
_running_info_label = Gtk.Template.Child()
_title_label = Gtk.Template.Child()
+ _viewport = Gtk.Template.Child()
selected_items_count = GObject.Property(type=int, default=0, minimum=0)
selection_mode = GObject.Property(type=bool, default=False)
_duration = 0
+ class Mode(IntEnum):
+ ALBUM = 0
+ PLAYBACK = 1
+
def __repr__(self):
return '<AlbumWidget>'
@log
- def __init__(self, player, parent_view):
+ def __init__(self, player, parent_view, mode):
"""Initialize the AlbumWidget.
:param player: The player object
@@ -77,22 +85,29 @@ class AlbumWidget(Gtk.EventBox):
self._cover_stack.props.size = Art.Size.LARGE
self._parent_view = parent_view
self._player = player
+ self._mode = mode
self._iter_to_clean = None
self._create_model()
self._album_id = None
- self.bind_property(
- 'selection-mode', self._disc_listbox, 'selection-mode',
- GObject.BindingFlags.BIDIRECTIONAL)
+ if self._mode == AlbumWidget.Mode.ALBUM:
+ self.bind_property(
+ 'selection-mode', self._disc_listbox, 'selection-mode',
+ GObject.BindingFlags.BIDIRECTIONAL)
- self.bind_property(
- 'selection-mode', self._parent_view, 'selection-mode',
- GObject.BindingFlags.BIDIRECTIONAL
- | GObject.BindingFlags.SYNC_CREATE)
+ self.bind_property(
+ 'selection-mode', self._parent_view, 'selection-mode',
+ GObject.BindingFlags.BIDIRECTIONAL
+ | GObject.BindingFlags.SYNC_CREATE)
- self.bind_property(
- 'selected-items-count', self._parent_view, 'selected-items-count')
+ else:
+ self._album_info.props.margin_top = 0
+ self._disc_listbox.props.margin_top = 0
+ self._viewport.props.width_request = 400
+
+ album_mode = (self._mode == AlbumWidget.Mode.ALBUM)
+ self._information_grid.props.visible = album_mode
@log
def _create_model(self):
@@ -138,12 +153,12 @@ class AlbumWidget(Gtk.EventBox):
self._artist_label.props.label = artist
self._artist_label.props.tooltip_text = artist
- year = utils.get_media_year(album)
- if not year:
- year = '----'
- self._released_info_label.props.label = year
-
- self._set_composer_label(album)
+ if self._mode == AlbumWidget.Mode.ALBUM:
+ year = utils.get_media_year(album)
+ if not year:
+ year = '----'
+ self._released_info_label.props.label = year
+ self._set_composer_label(album)
self._player.connect('song-changed', self._update_model)
@@ -182,7 +197,7 @@ class AlbumWidget(Gtk.EventBox):
disc_box.set_disc_number(disc_nr)
disc_box.props.columns = 1
disc_box.props.show_durations = True
- disc_box.props.show_favorites = True
+ disc_box.props.show_favorites = (self._mode == AlbumWidget.Mode.ALBUM)
disc_box.props.show_song_numbers = False
disc_box.connect('song-activated', self._song_activated)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]