[gnome-music/wip/jfelder/new-album-design-v3: 1/4] albumwidget: Update album infos




commit 19f061056327ec60347cf45df2eec60e61f11b7e
Author: Jean Felder <jfelder src gnome org>
Date:   Thu Jul 29 18:22:52 2021 +0200

    albumwidget: Update album infos
    
    The GTK depedency is bumped to 3.24.14 to handle the typography
    classes used by the widget: 'title-1' and 'title-3'.

 data/org.gnome.Music.css          |   6 --
 data/ui/AlbumWidget.ui            | 166 +++++++++-----------------------------
 gnomemusic/widgets/albumwidget.py |  38 +++++----
 meson.build                       |   2 +-
 po/POTFILES.in                    |   1 -
 5 files changed, 61 insertions(+), 152 deletions(-)
---
diff --git a/data/org.gnome.Music.css b/data/org.gnome.Music.css
index 4659aec06..96d518888 100644
--- a/data/org.gnome.Music.css
+++ b/data/org.gnome.Music.css
@@ -17,12 +17,6 @@
     background-color: transparent;
 }
 
-/* AlbumWidget */
-.title-artist {
-    font-size: larger;
-    font-weight: bold;
-}
-
 .disc-label {
     color: alpha(@theme_fg_color, 0.8);
     padding: 12px 0;
diff --git a/data/ui/AlbumWidget.ui b/data/ui/AlbumWidget.ui
index dc174a160..632471ad3 100644
--- a/data/ui/AlbumWidget.ui
+++ b/data/ui/AlbumWidget.ui
@@ -49,141 +49,53 @@
                     <property name="halign">center</property>
                     <property name="valign">start</property>
                     <property name="orientation">vertical</property>
-                    <property name="spacing">18</property>
+                    <property name="margin-top">18</property>
                     <child>
-                      <object class="GtkBox" id="artistBox">
+                      <object class="GtkLabel" id="_title_label">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="halign">center</property>
-                        <property name="valign">start</property>
-                        <property name="orientation">vertical</property>
-                        <property name="spacing">3</property>
-                        <child>
-                          <object class="GtkLabel" id="_title_label">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="halign">center</property>
-                            <property name="justify">center</property>
-                            <property name="ellipsize">middle</property>
-                            <style>
-                              <class name="title-artist"/>
-                            </style>
-                          </object>
-                        </child>
-                        <child>
-                          <object class="GtkLabel" id="_artist_label">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="halign">center</property>
-                            <property name="justify">center</property>
-                            <property name="ellipsize">middle</property>
-                            <style>
-                              <class name="title-artist"/>
-                              <class name="dim-label"/>
-                            </style>
-                          </object>
-                        </child>
+                        <property name="halign">start</property>
+                        <property name="ellipsize">middle</property>
+                        <property name="margin-bottom">18</property>
+                        <style>
+                          <class name="title-1"/>
+                        </style>
                       </object>
                     </child>
                     <child>
-                      <object class="GtkGrid" id="grid">
+                      <object class="GtkLabel" id="_artist_label">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="margin-top">21</property>
-                        <property name="column_spacing">32</property>
-                        <property name="column_homogeneous">True</property>
-                        <child>
-                          <object class="GtkLabel" id="released_label">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="halign">end</property>
-                            <property name="margin-bottom">2</property>
-                            <property name="margin-top">2</property>
-                            <property name="label" translatable="yes">Released</property>
-                            <property name="use_markup">True</property>
-                            <style>
-                              <class name="dim-label"/>
-                            </style>
-                          </object>
-                          <packing>
-                            <property name="left_attach">0</property>
-                            <property name="top_attach">0</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkLabel" id="running_label">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="halign">end</property>
-                            <property name="label" translatable="yes">Running Length</property>
-                            <property name="use_markup">True</property>
-                            <style>
-                              <class name="dim-label"/>
-                            </style>
-                          </object>
-                          <packing>
-                            <property name="left_attach">0</property>
-                            <property name="top_attach">1</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkLabel" id="_released_info_label">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="halign">start</property>
-                            <property name="margin-bottom">2</property>
-                            <property name="margin-top">2</property>
-                            <property name="label">----</property>
-                          </object>
-                          <packing>
-                            <property name="left_attach">1</property>
-                            <property name="top_attach">0</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkLabel" id="_running_info_label">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="halign">start</property>
-                            <property name="label">--:--</property>
-                          </object>
-                          <packing>
-                            <property name="left_attach">1</property>
-                            <property name="top_attach">1</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkLabel" id="_composer_label">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="halign">end</property>
-                            <property name="margin-bottom">2</property>
-                            <property name="margin-top">2</property>
-                            <property name="label" translatable="yes">Composer</property>
-                            <property name="use_markup">True</property>
-                            <style>
-                              <class name="dim-label"/>
-                            </style>
-                          </object>
-                          <packing>
-                            <property name="left_attach">0</property>
-                            <property name="top_attach">2</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkLabel" id="_composer_info_label">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="halign">start</property>
-                            <property name="margin-bottom">2</property>
-                            <property name="margin-top">2</property>
-                            <property name="ellipsize">end</property>
-                          </object>
-                          <packing>
-                            <property name="left_attach">1</property>
-                            <property name="top_attach">2</property>
-                          </packing>
-                        </child>
+                        <property name="halign">start</property>
+                        <property name="ellipsize">middle</property>
+                        <property name="margin-bottom">12</property>
+                        <style>
+                          <class name="title-3"/>
+                        </style>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="_released_label">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="halign">start</property>
+                        <property name="use_markup">True</property>
+                        <property name="margin-bottom">12</property>
+                        <style>
+                          <class name="dim-label"/>
+                        </style>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="_composer_label">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="halign">start</property>
+                        <property name="ellipsize">end</property>
+                        <property name="margin-bottom">12</property>
+                        <style>
+                          <class name="dim-label"/>
+                        </style>
                       </object>
                     </child>
                   </object>
diff --git a/gnomemusic/widgets/albumwidget.py b/gnomemusic/widgets/albumwidget.py
index 3d417bd89..11d4cbb69 100644
--- a/gnomemusic/widgets/albumwidget.py
+++ b/gnomemusic/widgets/albumwidget.py
@@ -51,11 +51,9 @@ class AlbumWidget(Gtk.ScrolledWindow):
 
     _artist_label = Gtk.Template.Child()
     _composer_label = Gtk.Template.Child()
-    _composer_info_label = Gtk.Template.Child()
     _art_stack = Gtk.Template.Child()
     _disc_list_box = Gtk.Template.Child()
-    _released_info_label = Gtk.Template.Child()
-    _running_info_label = Gtk.Template.Child()
+    _released_label = Gtk.Template.Child()
     _title_label = Gtk.Template.Child()
 
     selection_mode = GObject.Property(type=bool, default=False)
@@ -71,6 +69,7 @@ class AlbumWidget(Gtk.ScrolledWindow):
         self._corealbum: Optional[CoreAlbum] = None
         self._coremodel = self._application.props.coremodel
         self._duration_signal_id = 0
+        self._year_signal_id = 0
         self._model_signal_id = 0
 
         self._art_stack.props.size = ArtSize.LARGE
@@ -101,6 +100,7 @@ class AlbumWidget(Gtk.ScrolledWindow):
         """
         if self._corealbum:
             self._corealbum.disconnect(self._duration_signal_id)
+            self._corealbum.disconnect(self._year_signal_id)
             self._corealbum.props.model.disconnect(self._model_signal_id)
 
         self._corealbum = corealbum
@@ -116,8 +116,10 @@ class AlbumWidget(Gtk.ScrolledWindow):
         self._artist_label.props.label = artist
         self._artist_label.props.tooltip_text = artist
 
-        self._released_info_label.props.label = self._corealbum.props.year
-
+        self._duration_signal_id = self._corealbum.connect(
+            "notify::duration", self._on_release_info_changed)
+        self._year_signal_id = self._corealbum.connect(
+            "notify::year", self._on_release_info_changed)
         self._set_composer_label(corealbum)
 
         self._album_model = self._corealbum.props.model
@@ -125,10 +127,6 @@ class AlbumWidget(Gtk.ScrolledWindow):
             "items-changed", self._on_model_items_changed)
         self._disc_list_box.bind_model(self._album_model, self._create_widget)
 
-        self._on_duration_changed(self._corealbum, 0)
-        self._duration_signal_id = self._corealbum.connect(
-            "notify::duration", self._on_duration_changed)
-
         self._album_model.items_changed(0, 0, 0)
 
     def _create_widget(self, disc: CoreDisc) -> DiscBox:
@@ -159,18 +157,24 @@ class AlbumWidget(Gtk.ScrolledWindow):
         show = False
 
         if composer:
-            self._composer_info_label.props.label = composer
-            self._composer_info_label.props.max_width_chars = 10
-            self._composer_info_label.props.tooltip_text = composer
+            self._composer_label.props.label = composer
+            self._composer_label.props.tooltip_text = composer
             show = True
 
         self._composer_label.props.visible = show
-        self._composer_info_label.props.visible = show
+        self._composer_label.props.visible = show
+
+    def _on_release_info_changed(
+            self, klass: CoreAlbum,
+            value: Optional[GObject.ParamSpecString]) -> None:
+        if not self._corealbum:
+            return
 
-    def _on_duration_changed(self, coredisc: CoreDisc, duration: int) -> None:
-        mins = (coredisc.props.duration // 60) + 1
-        self._running_info_label.props.label = ngettext(
-            "{} minute", "{} minutes", mins).format(mins)
+        mins = (self._corealbum.props.duration // 60) + 1
+        year = self._corealbum.props.year
+        release_info_label = ngettext(
+            "{}, {} minute", "{}, {} minutes", mins).format(year, mins)
+        self._released_label.props.label = release_info_label
 
     def _song_activated(
             self, widget: Gtk.Widget, song_widget: SongWidget) -> None:
diff --git a/meson.build b/meson.build
index c73d2ad8d..2f9f13468 100644
--- a/meson.build
+++ b/meson.build
@@ -44,7 +44,7 @@ PKGLIB_DIR = join_paths(get_option('prefix'), get_option('libdir'), APPLICATION_
 dependency('glib-2.0', version: '>= 2.67.1')
 dependency('goa-1.0', version: '>= 3.35.90')
 dependency('gobject-introspection-1.0', version: '>= 1.35.0')
-dependency('gtk+-3.0', version: '>= 3.24.13')
+dependency('gtk+-3.0', version: '>= 3.24.14')
 dependency('libhandy-1', version: '>= 1.2.0')
 dependency('libdazzle-1.0', version: '>= 3.28.0')
 dependency('libmediaart-2.0', version: '>= 1.9.1')
diff --git a/po/POTFILES.in b/po/POTFILES.in
index c88c5b2cc..084766770 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -4,7 +4,6 @@ data/org.gnome.Music.appdata.xml.in.in
 data/org.gnome.Music.desktop.in.in
 data/org.gnome.Music.gschema.xml
 data/ui/AboutDialog.ui.in
-data/ui/AlbumWidget.ui
 data/ui/AppMenu.ui
 data/ui/HeaderBar.ui
 data/ui/help-overlay.ui


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]