[gnome-music/wip/mschraal/core-thumb-property: 15/16] utils: Add ArtSize enum



commit cc73028071fc9541f71d57798147b3b25b0634c9
Author: Marinus Schraal <mschraal gnome org>
Date:   Sun Jun 14 21:01:46 2020 +0200

    utils: Add ArtSize enum
    
    Renamed from Art.Size.

 gnomemusic/artcache.py                  |  2 +-
 gnomemusic/utils.py                     | 14 ++++++++++++++
 gnomemusic/views/emptyview.py           |  6 +++---
 gnomemusic/widgets/albumcover.py        |  4 ++--
 gnomemusic/widgets/albumwidget.py       |  4 ++--
 gnomemusic/widgets/artistalbumwidget.py |  4 ++--
 gnomemusic/widgets/artistsearchtile.py  |  4 ++--
 gnomemusic/widgets/artstack.py          | 11 +++++------
 gnomemusic/widgets/playertoolbar.py     |  4 ++--
 9 files changed, 33 insertions(+), 20 deletions(-)
---
diff --git a/gnomemusic/artcache.py b/gnomemusic/artcache.py
index 28f29cdc..93549c0e 100644
--- a/gnomemusic/artcache.py
+++ b/gnomemusic/artcache.py
@@ -150,7 +150,7 @@ class DefaultIcon(GObject.GObject):
         given size and shape.
 
         :param enum icon_type: The DefaultIcon.Type of the icon
-        :param enum art_size: The Art.Size requested
+        :param enum art_size: The ArtSize requested
         :param int scale: The scale
         :param bool round_shape: Indicates square or round icon shape
 
diff --git a/gnomemusic/utils.py b/gnomemusic/utils.py
index b00f5ec1..1e265a0b 100644
--- a/gnomemusic/utils.py
+++ b/gnomemusic/utils.py
@@ -31,6 +31,20 @@ from gi.repository import Gio
 from gi._gi import pygobject_new_full
 
 
+class ArtSize(Enum):
+    """Enum for icon sizes"""
+    XSMALL = (34, 34)
+    SMALL = (48, 48)
+    MEDIUM = (128, 128)
+    LARGE = (256, 256)
+    XLARGE = (512, 512)
+
+    def __init__(self, width, height):
+        """Intialize width and height"""
+        self.width = width
+        self.height = height
+
+
 class SongStateIcon(Enum):
     """Enum for icons used in song playing and validation"""
     ERROR = "dialog-error-symbolic"
diff --git a/gnomemusic/views/emptyview.py b/gnomemusic/views/emptyview.py
index b7efcd2a..b8ed23ea 100644
--- a/gnomemusic/views/emptyview.py
+++ b/gnomemusic/views/emptyview.py
@@ -27,7 +27,7 @@ from enum import IntEnum
 from gettext import gettext as _
 from gi.repository import GLib, GObject, Gtk, Tracker
 
-from gnomemusic.albumartcache import Art
+from gnomemusic.utils import ArtSize
 
 
 @Gtk.Template(resource_path="/org/gnome/Music/ui/EmptyView.ui")
@@ -114,8 +114,8 @@ class EmptyView(Gtk.Stack):
 
         self._icon.props.resource = "/org/gnome/Music/icons/initial-state.png"
         self._icon.props.margin_bottom = 32
-        self._icon.props.height_request = Art.Size.LARGE.height
-        self._icon.props.width_request = Art.Size.LARGE.width
+        self._icon.props.height_request = ArtSize.LARGE.height
+        self._icon.props.width_request = ArtSize.LARGE.width
 
     def _set_empty_state(self):
         self._main_label.props.label = _("No music found")
diff --git a/gnomemusic/widgets/albumcover.py b/gnomemusic/widgets/albumcover.py
index 557b318b..59878ca2 100644
--- a/gnomemusic/widgets/albumcover.py
+++ b/gnomemusic/widgets/albumcover.py
@@ -26,8 +26,8 @@ import gi
 gi.require_version('Grl', '0.3')
 from gi.repository import GObject, Gtk
 
-from gnomemusic.albumartcache import Art
 from gnomemusic.corealbum import CoreAlbum
+from gnomemusic.utils import ArtSize
 from gnomemusic.widgets.twolinetip import TwoLineTip
 
 
@@ -81,7 +81,7 @@ class AlbumCover(Gtk.FlowBoxChild):
 
         self.connect('query-tooltip', self._on_tooltip_query)
 
-        self._art_stack.props.size = Art.Size.MEDIUM
+        self._art_stack.props.size = ArtSize.MEDIUM
 
         self.show()
 
diff --git a/gnomemusic/widgets/albumwidget.py b/gnomemusic/widgets/albumwidget.py
index 6bc81f5b..99e775ab 100644
--- a/gnomemusic/widgets/albumwidget.py
+++ b/gnomemusic/widgets/albumwidget.py
@@ -26,8 +26,8 @@ from gettext import ngettext
 
 from gi.repository import GObject, Grl, Gtk
 
-from gnomemusic.albumartcache import Art
 from gnomemusic.player import PlayerPlaylist
+from gnomemusic.utils import ArtSize
 from gnomemusic.widgets.disclistboxwidget import DiscBox
 from gnomemusic.widgets.disclistboxwidget import DiscListBox  # noqa: F401
 
@@ -68,7 +68,7 @@ class AlbumWidget(Gtk.EventBox):
         self._duration_signal_id = None
         self._model_signal_id = None
 
-        self._art_stack.props.size = Art.Size.LARGE
+        self._art_stack.props.size = ArtSize.LARGE
         self._player = self._application.props.player
 
         self.bind_property(
diff --git a/gnomemusic/widgets/artistalbumwidget.py b/gnomemusic/widgets/artistalbumwidget.py
index b80be261..5993e7cb 100644
--- a/gnomemusic/widgets/artistalbumwidget.py
+++ b/gnomemusic/widgets/artistalbumwidget.py
@@ -24,7 +24,7 @@
 
 from gi.repository import GObject, Gtk
 
-from gnomemusic.albumartcache import Art
+from gnomemusic.utils import ArtSize
 from gnomemusic.widgets.disclistboxwidget import DiscBox
 from gnomemusic.widgets.songwidget import SongWidget
 
@@ -66,7 +66,7 @@ class ArtistAlbumWidget(Gtk.Box):
 
         self._selection_mode = False
 
-        self._art_stack.props.size = Art.Size.MEDIUM
+        self._art_stack.props.size = ArtSize.MEDIUM
         self._art_stack.props.coreobject = corealbum
 
         self.bind_property(
diff --git a/gnomemusic/widgets/artistsearchtile.py b/gnomemusic/widgets/artistsearchtile.py
index c4236ceb..177ab948 100644
--- a/gnomemusic/widgets/artistsearchtile.py
+++ b/gnomemusic/widgets/artistsearchtile.py
@@ -24,8 +24,8 @@
 
 from gi.repository import Gdk, GObject, Gtk
 
-from gnomemusic.albumartcache import Art
 from gnomemusic.coreartist import CoreArtist
+from gnomemusic.utils import ArtSize
 from gnomemusic.widgets.artstack import ArtStack  # noqa: F401
 from gnomemusic.widgets.twolinetip import TwoLineTip
 
@@ -60,7 +60,7 @@ class ArtistSearchTile(Gtk.FlowBoxChild):
 
         self.props.coreartist = coreartist
 
-        self._art_stack.props.size = Art.Size.MEDIUM
+        self._art_stack.props.size = ArtSize.MEDIUM
         self._art_stack.props.coreobject = self.props.coreartist
 
         self._tooltip = TwoLineTip()
diff --git a/gnomemusic/widgets/artstack.py b/gnomemusic/widgets/artstack.py
index ac0f7c83..cc677c86 100644
--- a/gnomemusic/widgets/artstack.py
+++ b/gnomemusic/widgets/artstack.py
@@ -24,9 +24,8 @@
 
 from gi.repository import GObject, Gtk
 
-from gnomemusic.albumartcache import Art
 from gnomemusic.artcache import ArtCache
-from gnomemusic.coreartist import CoreArtist
+from gnomemusic.utils import ArtSize
 
 
 class ArtStack(Gtk.Stack):
@@ -39,10 +38,10 @@ class ArtStack(Gtk.Stack):
 
     __gtype_name__ = "ArtStack"
 
-    def __init__(self, size=Art.Size.MEDIUM):
+    def __init__(self, size=ArtSize.MEDIUM):
         """Initialize the ArtStack
 
-        :param Art.Size size: The size of the art used for the cover
+        :param ArtSize size: The size of the art used for the cover
         """
         super().__init__()
 
@@ -70,7 +69,7 @@ class ArtStack(Gtk.Stack):
         """Size of the cover
 
         :returns: The size used
-        :rtype: Art.Size
+        :rtype: ArtSize
         """
         return self._size
 
@@ -78,7 +77,7 @@ class ArtStack(Gtk.Stack):
     def size(self, value):
         """Set the cover size
 
-        :param Art.Size value: The size to use for the cover
+        :param ArtSize value: The size to use for the cover
         """
         self._cover_a.set_size_request(value.width, value.height)
         self._size = value
diff --git a/gnomemusic/widgets/playertoolbar.py b/gnomemusic/widgets/playertoolbar.py
index ba72f7af..78eb0f46 100644
--- a/gnomemusic/widgets/playertoolbar.py
+++ b/gnomemusic/widgets/playertoolbar.py
@@ -25,8 +25,8 @@
 from gettext import gettext as _
 from gi.repository import GObject, Gtk
 
-from gnomemusic.albumartcache import Art
 from gnomemusic.gstplayer import Playback
+from gnomemusic.utils import ArtSize
 from gnomemusic.player import Player, RepeatMode
 from gnomemusic.widgets.smoothscale import SmoothScale  # noqa: F401
 from gnomemusic.widgets.twolinetip import TwoLineTip
@@ -68,7 +68,7 @@ class PlayerToolbar(Gtk.ActionBar):
 
         self._player = None
 
-        self._art_stack.props.size = Art.Size.XSMALL
+        self._art_stack.props.size = ArtSize.XSMALL
 
         self._tooltip = TwoLineTip()
 


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