[gnome-music/wip/mschraal/date-allow-none] corealbum: Allow None for year property




commit fceccb828ad766527604aef72199cb5b5a85525a
Author: Marinus Schraal <mschraal gnome org>
Date:   Sat Jun 4 15:40:11 2022 +0200

    corealbum: Allow None for year property
    
    Previously Music would use a dashed string to display an unknown
    release year, but more recently it does not show the year at
    all.
    
    Remove the dashed string in favour of setting the property to None if
    the year is unknown.

 gnomemusic/corealbum.py           | 2 +-
 gnomemusic/utils.py               | 6 +++---
 gnomemusic/widgets/albumwidget.py | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)
---
diff --git a/gnomemusic/corealbum.py b/gnomemusic/corealbum.py
index af3a1198c..dca42dc8b 100644
--- a/gnomemusic/corealbum.py
+++ b/gnomemusic/corealbum.py
@@ -45,7 +45,7 @@ class CoreAlbum(GObject.GObject):
     media = GObject.Property(type=Grl.Media)
     title = GObject.Property(type=str)
     url = GObject.Property(type=str)
-    year = GObject.Property(type=str, default="----")
+    year = GObject.Property(type=str, default=None)
 
     def __init__(self, application, media):
         """Initiate the CoreAlbum object
diff --git a/gnomemusic/utils.py b/gnomemusic/utils.py
index fd88be299..077859053 100644
--- a/gnomemusic/utils.py
+++ b/gnomemusic/utils.py
@@ -150,13 +150,13 @@ def get_media_year(item):
     """Returns the year when the media was published.
 
     :param Grl.Media item: A Grilo Media object
-    :return: The publication year or '----' if not defined
-    :rtype: str
+    :return: The publication year or None if not defined
+    :rtype: str or None
     """
     date = item.get_publication_date()
 
     if not date:
-        return "----"
+        return None
 
     return str(date.get_year())
 
diff --git a/gnomemusic/widgets/albumwidget.py b/gnomemusic/widgets/albumwidget.py
index 9e34ce8f4..0a91ab9a8 100644
--- a/gnomemusic/widgets/albumwidget.py
+++ b/gnomemusic/widgets/albumwidget.py
@@ -245,7 +245,7 @@ class AlbumWidget(Adw.Bin):
         mins_text = ngettext("{} minute", "{} minutes", mins).format(mins)
         year = self._corealbum.props.year
 
-        if year == "----":
+        if year is None:
             label = mins_text
         else:
             label = f"{year}, {mins_text}"


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