[gnome-music/wip/jfelder/playback-status-v4: 3/9] 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-v4: 3/9] albumwidget: Define different display modes
- Date: Mon, 1 Jun 2020 00:35:30 +0000 (UTC)
commit 27d1830c13097def268984a1487dd8f073eb33c3
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 | 3 ++-
gnomemusic/widgets/albumwidget.py | 17 ++++++++++++++++-
4 files changed, 20 insertions(+), 4 deletions(-)
---
diff --git a/data/ui/AlbumWidget.ui b/data/ui/AlbumWidget.ui
index 9fdb87cf..98fd1345 100644
--- a/data/ui/AlbumWidget.ui
+++ b/data/ui/AlbumWidget.ui
@@ -91,7 +91,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 1a1018cc..7a20327f 100644
--- a/gnomemusic/views/albumsview.py
+++ b/gnomemusic/views/albumsview.py
@@ -80,7 +80,7 @@ class AlbumsView(Gtk.Stack):
self._window.connect(
"notify::selection-mode", self._on_selection_mode_changed)
- self._album_widget = AlbumWidget(self._application)
+ self._album_widget = AlbumWidget(self._application, AlbumWidget.Mode.ALBUM)
self._album_widget.bind_property(
"selection-mode", self, "selection-mode",
GObject.BindingFlags.BIDIRECTIONAL)
diff --git a/gnomemusic/views/searchview.py b/gnomemusic/views/searchview.py
index 8cdb43d4..ecc2369b 100644
--- a/gnomemusic/views/searchview.py
+++ b/gnomemusic/views/searchview.py
@@ -127,7 +127,8 @@ class SearchView(Gtk.Stack):
'selection-mode', self._window, 'selection-mode',
GObject.BindingFlags.BIDIRECTIONAL)
- self._album_widget = AlbumWidget(self._application)
+ self._album_widget = AlbumWidget(
+ self._application, AlbumWidget.Mode.ALBUM)
self._album_widget.bind_property(
"selection-mode", self, "selection-mode",
GObject.BindingFlags.BIDIRECTIONAL)
diff --git a/gnomemusic/widgets/albumwidget.py b/gnomemusic/widgets/albumwidget.py
index 73283b1d..56c0c1b7 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 GObject, Grl, Gtk
@@ -46,18 +48,25 @@ class AlbumWidget(Gtk.EventBox):
_composer_info_label = Gtk.Template.Child()
_cover_stack = Gtk.Template.Child()
_disc_list_box = 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()
selection_mode = GObject.Property(type=bool, default=False)
_duration = 0
- def __init__(self, application):
+ class Mode(IntEnum):
+ ALBUM = 0
+ PLAYBACK = 1
+
+ def __init__(self, application, mode):
"""Initialize the AlbumWidget.
:param GtkApplication application: The application object
+ :param AlbumWidget.Mode mode: mode
"""
super().__init__()
@@ -70,6 +79,12 @@ class AlbumWidget(Gtk.EventBox):
self._cover_stack.props.size = Art.Size.LARGE
self._player = self._application.props.player
+ self._mode = mode
+ album_mode = (self._mode == AlbumWidget.Mode.ALBUM)
+ self._information_grid.props.visible = album_mode
+ if album_mode is False:
+ self._viewport.props.width_request = 400
+
self.bind_property(
"selection-mode", self._disc_list_box, "selection-mode",
GObject.BindingFlags.BIDIRECTIONAL
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]