[gnome-music/wip/mschraal/artrework: 2/3] Move ArtSize into the Art class.



commit 29ebf9e2dab03632adbd2d4f2801ae7cf5fc5285
Author: Marinus Schraal <mschraal gnome org>
Date:   Sat Jan 6 01:45:45 2018 +0100

    Move ArtSize into the Art class.

 gnomemusic/albumartcache.py             | 27 +++++++++++++--------------
 gnomemusic/player.py                    |  4 ++--
 gnomemusic/views/albumsview.py          |  4 ++--
 gnomemusic/views/baseview.py            |  4 ++--
 gnomemusic/views/initialstateview.py    |  4 ++--
 gnomemusic/views/searchview.py          |  4 ++--
 gnomemusic/widgets/albumwidget.py       |  4 ++--
 gnomemusic/widgets/artistalbumwidget.py |  4 ++--
 8 files changed, 27 insertions(+), 28 deletions(-)
---
diff --git a/gnomemusic/albumartcache.py b/gnomemusic/albumartcache.py
index 2758b20..489ba9a 100644
--- a/gnomemusic/albumartcache.py
+++ b/gnomemusic/albumartcache.py
@@ -136,20 +136,6 @@ def _make_icon_frame(pixbuf, art_size=None, scale=1):
     return surface
 
 
-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 DefaultIcon(GObject.GObject):
     """Provides the symbolic fallback and loading icons."""
 
@@ -224,6 +210,19 @@ class Art(GObject.GObject):
         'finished': (GObject.SignalFlags.RUN_FIRST, None, ())
     }
 
+    class Size(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
+
     @log
     def __init__(self, image, size, media):
         super().__init__()
diff --git a/gnomemusic/player.py b/gnomemusic/player.py
index c755850..9c6c6ca 100644
--- a/gnomemusic/player.py
+++ b/gnomemusic/player.py
@@ -46,7 +46,7 @@ from gi.repository import Gtk, Gdk, GLib, Gio, GObject, Gst, GstAudio, GstPbutil
 from gettext import gettext as _, ngettext
 
 from gnomemusic import log
-from gnomemusic.albumartcache import Art, ArtSize
+from gnomemusic.albumartcache import Art
 from gnomemusic.grilo import grilo
 from gnomemusic.playlists import Playlists
 from gnomemusic.scrobbler import LastFmScrobbler
@@ -579,7 +579,7 @@ class Player(GObject.GObject):
         artist = utils.get_artist_name(media)
         self.artistLabel.set_label(artist)
 
-        Art(self._image, ArtSize.XSMALL, media)
+        Art(self._image, Art.Size.XSMALL, media)
 
         title = utils.get_media_title(media)
         self.titleLabel.set_label(title)
diff --git a/gnomemusic/views/albumsview.py b/gnomemusic/views/albumsview.py
index b20b316..2a85d01 100644
--- a/gnomemusic/views/albumsview.py
+++ b/gnomemusic/views/albumsview.py
@@ -26,7 +26,7 @@ from gettext import gettext as _
 from gi.repository import GLib, GObject, Gtk, Gdk
 
 from gnomemusic import log
-from gnomemusic.albumartcache import Art, ArtSize
+from gnomemusic.albumartcache import Art
 from gnomemusic.grilo import grilo
 from gnomemusic.toolbar import ToolbarState
 from gnomemusic.views.baseview import BaseView
@@ -182,7 +182,7 @@ class AlbumsView(BaseView):
         child.add(builder.get_object('main_box'))
         child.show()
 
-        Art(child.image, ArtSize.MEDIUM, item)
+        Art(child.image, Art.Size.MEDIUM, item)
 
         return child
 
diff --git a/gnomemusic/views/baseview.py b/gnomemusic/views/baseview.py
index 1a6583b..d4bdc69 100644
--- a/gnomemusic/views/baseview.py
+++ b/gnomemusic/views/baseview.py
@@ -26,7 +26,7 @@ from gettext import gettext as _, ngettext
 from gi.repository import Gd, Gdk, GdkPixbuf, GObject, Gtk
 
 from gnomemusic import log
-from gnomemusic.albumartcache import Art, ArtSize
+from gnomemusic.albumartcache import Art
 from gnomemusic.grilo import grilo
 from gnomemusic.widgets.starhandlerwidget import StarHandlerWidget
 import gnomemusic.utils as utils
@@ -228,7 +228,7 @@ class BaseView(Gtk.Stack):
         itr = self.model.append(None)
 
         pixbuf = GdkPixbuf.Pixbuf()
-        art = Art(pixbuf, ArtSize.MEDIUM, item)
+        art = Art(pixbuf, Art.Size.MEDIUM, item)
 
         self.model[itr][0, 1, 2, 3, 4, 5, 7, 9] = [
             str(item.get_id()),
diff --git a/gnomemusic/views/initialstateview.py b/gnomemusic/views/initialstateview.py
index d005537..e06d065 100644
--- a/gnomemusic/views/initialstateview.py
+++ b/gnomemusic/views/initialstateview.py
@@ -25,7 +25,7 @@
 from gettext import gettext as _
 
 from gnomemusic import log
-from gnomemusic.albumartcache import ArtSize
+from gnomemusic.albumartcache import Art
 from gnomemusic.views.emptyview import EmptyView
 
 
@@ -43,7 +43,7 @@ class InitialStateView(EmptyView):
         icon.set_margin_bottom(32)
         icon.set_opacity(1)
         icon.set_from_resource('/org/gnome/Music/initial-state.png')
-        icon.set_size_request(ArtSize.LARGE.width, ArtSize.LARGE.height)
+        icon.set_size_request(Art.Size.LARGE.width, Art.Size.LARGE.height)
 
         # Update label
         label = self.builder.get_object('label')
diff --git a/gnomemusic/views/searchview.py b/gnomemusic/views/searchview.py
index 16796cd..0362e6e 100644
--- a/gnomemusic/views/searchview.py
+++ b/gnomemusic/views/searchview.py
@@ -25,7 +25,7 @@
 from gettext import gettext as _
 from gi.repository import Gd, GdkPixbuf, GObject, Grl, Gtk, Pango
 
-from gnomemusic.albumartcache import Art, ArtSize
+from gnomemusic.albumartcache import Art
 from gnomemusic.grilo import grilo
 from gnomemusic import log
 from gnomemusic.player import DiscoveryStatus
@@ -240,7 +240,7 @@ class SearchView(BaseView):
         # icon for the search view.
         _iter = None
         image = GdkPixbuf.Pixbuf()
-        art = Art(image, ArtSize.SMALL, item)
+        art = Art(image, Art.Size.SMALL, item)
         if category == 'album':
             _iter = self.model.insert_with_values(
                 self._head_iters[group], -1, [0, 2, 3, 4, 5, 9, 11],
diff --git a/gnomemusic/widgets/albumwidget.py b/gnomemusic/widgets/albumwidget.py
index 0167867..e8cca64 100644
--- a/gnomemusic/widgets/albumwidget.py
+++ b/gnomemusic/widgets/albumwidget.py
@@ -26,7 +26,7 @@ from gettext import gettext as _, ngettext
 from gi.repository import GdkPixbuf, GLib, GObject, Gtk
 
 from gnomemusic import log
-from gnomemusic.albumartcache import Art, ArtSize
+from gnomemusic.albumartcache import Art
 from gnomemusic.grilo import grilo
 from gnomemusic.widgets.disclistboxwidget import DiscBox, DiscListBox
 import gnomemusic.utils as utils
@@ -138,7 +138,7 @@ class AlbumWidget(Gtk.EventBox):
         self._header_bar = header_bar
         self._album = album
         self._duration = 0
-        Art(self._builder.get_object('cover'), ArtSize.LARGE, item)
+        Art(self._builder.get_object('cover'), Art.Size.LARGE, item)
 
         GLib.idle_add(grilo.populate_album_songs, item, self.add_item)
         header_bar._select_button.connect(
diff --git a/gnomemusic/widgets/artistalbumwidget.py b/gnomemusic/widgets/artistalbumwidget.py
index 86fa72b..d041fa9 100644
--- a/gnomemusic/widgets/artistalbumwidget.py
+++ b/gnomemusic/widgets/artistalbumwidget.py
@@ -25,7 +25,7 @@
 from gi.repository import GObject, Gtk
 
 from gnomemusic import log
-from gnomemusic.albumartcache import Art, ArtSize
+from gnomemusic.albumartcache import Art
 from gnomemusic.grilo import grilo
 from gnomemusic.widgets.disclistboxwidget import DiscBox
 import gnomemusic.utils as utils
@@ -67,7 +67,7 @@ class ArtistAlbumWidget(Gtk.Box):
         ui.add_from_resource('/org/gnome/Music/ArtistAlbumWidget.ui')
 
         self.cover = ui.get_object('cover')
-        Art(self.cover, ArtSize.MEDIUM, self._media)
+        Art(self.cover, Art.Size.MEDIUM, self._media)
 
         self._disc_listbox = ui.get_object('disclistbox')
         self._disc_listbox.set_selection_mode_allowed(


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