[gnome-music/wip/mschraal/baseview-cleanup: 5/8] utils: Add SongStateIcon enum
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/baseview-cleanup: 5/8] utils: Add SongStateIcon enum
- Date: Wed, 17 Jul 2019 20:37:08 +0000 (UTC)
commit 08925c09ea67ad44f617acd468ef46fb3b58391f
Author: Marinus Schraal <mschraal gnome org>
Date: Wed Jul 17 17:09:37 2019 +0200
utils: Add SongStateIcon enum
It is used by SongWidget and SongsView.
gnomemusic/utils.py | 8 +++++++-
gnomemusic/views/baseview.py | 3 ---
gnomemusic/views/songsview.py | 7 ++++---
gnomemusic/widgets/songwidget.py | 5 +++--
4 files changed, 14 insertions(+), 9 deletions(-)
---
diff --git a/gnomemusic/utils.py b/gnomemusic/utils.py
index bd5d67d1..76310cb6 100644
--- a/gnomemusic/utils.py
+++ b/gnomemusic/utils.py
@@ -22,12 +22,18 @@
# 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 enum import Enum, IntEnum
from gettext import gettext as _
from gi.repository import Gio
+class SongStateIcon(Enum):
+ """Enum for icons used in song playing and validation"""
+ ERROR = "dialog-error-symbolic"
+ PLAYING = "media-playback-start-symbolic"
+
+
class View(IntEnum):
"""Enum for views"""
EMPTY = 0
diff --git a/gnomemusic/views/baseview.py b/gnomemusic/views/baseview.py
index 89b1b423..29d0053e 100644
--- a/gnomemusic/views/baseview.py
+++ b/gnomemusic/views/baseview.py
@@ -30,9 +30,6 @@ from gnomemusic import log
class BaseView(Gtk.Stack):
"""Base Class for all view classes"""
- _now_playing_icon_name = 'media-playback-start-symbolic'
- _error_icon_name = 'dialog-error-symbolic'
-
selected_items_count = GObject.Property(type=int, default=0, minimum=0)
selection_mode = GObject.Property(type=bool, default=False)
diff --git a/gnomemusic/views/songsview.py b/gnomemusic/views/songsview.py
index dfe73d8b..e4665c82 100644
--- a/gnomemusic/views/songsview.py
+++ b/gnomemusic/views/songsview.py
@@ -29,6 +29,7 @@ from gi.repository import Gdk, Gtk, Pango
from gnomemusic import log
from gnomemusic.coresong import CoreSong
from gnomemusic.player import PlayerPlaylist
+from gnomemusic.utils import SongStateIcon
from gnomemusic.views.baseview import BaseView
from gnomemusic.widgets.starhandlerwidget import StarHandlerWidget
@@ -146,10 +147,10 @@ class SongsView(BaseView):
coresong = model[itr][7]
if coresong.props.validation == CoreSong.Validation.FAILED:
- cell.props.icon_name = self._error_icon_name
+ cell.props.icon_name = SongStateIcon.ERROR.value
cell.props.visible = True
elif coresong.props.grlid == current_song.props.grlid:
- cell.props.icon_name = self._now_playing_icon_name
+ cell.props.icon_name = SongStateIcon.PLAYING.value
cell.props.visible = True
else:
cell.props.visible = False
@@ -225,7 +226,7 @@ class SongsView(BaseView):
self._view.props.model[iter_][9] = True
self._view.scroll_to_cell(path, None, True, 0.5, 0.5)
- if self._view.props.model[iter_][0] != self._error_icon_name:
+ if self._view.props.model[iter_][0] != SongStateIcon.ERROR.value:
self._iter_to_clean = iter_.copy()
return False
diff --git a/gnomemusic/widgets/songwidget.py b/gnomemusic/widgets/songwidget.py
index 365ccfd9..ff0a9293 100644
--- a/gnomemusic/widgets/songwidget.py
+++ b/gnomemusic/widgets/songwidget.py
@@ -32,6 +32,7 @@ from gi.repository.Dazzle import BoldingLabel # noqa: F401
from gnomemusic import log
from gnomemusic import utils
from gnomemusic.coresong import CoreSong
+from gnomemusic.utils import SongStateIcon
from gnomemusic.widgets.starimage import StarImage # noqa: F401
@@ -294,7 +295,7 @@ class SongWidget(Gtk.EventBox):
def _on_validation_changed(self, coresong, sate):
validation_status = coresong.props.validation
if validation_status == CoreSong.Validation.FAILED:
- self._play_icon.props.icon_name = "dialog-error-symbolic"
+ self._play_icon.props.icon_name = SongStateIcon.ERROR.value
self._play_icon.set_visible(True)
else:
- self._play_icon.props.icon_name = "media-playback-start-symbolic"
+ self._play_icon.props.icon_name = SongStateIcon.PLAYING.value
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]