[gnome-music/wip/jfelder/artistsview-selection: 14/17] artistalbumswidget: Remove selection-mode-allowed logic



commit 473ece6f22bcc87b43e46506864fb9e14277ab6d
Author: Jean Felder <jfelder src gnome org>
Date:   Tue Mar 24 20:30:54 2020 +0100

    artistalbumswidget: Remove selection-mode-allowed logic
    
    The selection-mode-allowed logic was used by DiscListBox to
    distinguish the AlbumWidget use case (selection-mode allowed) from the
    ArtistAlbumWidget one (selection-mode is not allowed).
    
    Selection is now possible from an ArtistAlbumsWidget. Therefore, there
    is no need for selection-mode-allowed.

 data/ui/AlbumWidget.ui                   |  1 -
 gnomemusic/views/artistsview.py          |  3 +--
 gnomemusic/widgets/artistalbumswidget.py |  7 ++-----
 gnomemusic/widgets/artistalbumwidget.py  | 13 +------------
 gnomemusic/widgets/disclistboxwidget.py  |  9 +--------
 5 files changed, 5 insertions(+), 28 deletions(-)
---
diff --git a/data/ui/AlbumWidget.ui b/data/ui/AlbumWidget.ui
index a3673b65..010fdfec 100644
--- a/data/ui/AlbumWidget.ui
+++ b/data/ui/AlbumWidget.ui
@@ -228,7 +228,6 @@
                     <property name="margin_bottom">48</property>
                     <property name="margin_end">32</property>
                     <property name="selection_mode">0</property>
-                    <property name="selection_mode_allowed">True</property>
                     <property name="visible">True</property>
                   </object>
                 </child>
diff --git a/gnomemusic/views/artistsview.py b/gnomemusic/views/artistsview.py
index e1692560..18212c13 100644
--- a/gnomemusic/views/artistsview.py
+++ b/gnomemusic/views/artistsview.py
@@ -154,8 +154,7 @@ class ArtistsView(BaseView):
             self._view.set_visible_child_name(coreartist.props.artist)
             return
 
-        self._artist_albums = ArtistAlbumsWidget(
-            coreartist, self._application, True)
+        self._artist_albums = ArtistAlbumsWidget(coreartist, self._application)
 
         self.bind_property(
             "selection-mode", self._artist_albums, "selection-mode",
diff --git a/gnomemusic/widgets/artistalbumswidget.py b/gnomemusic/widgets/artistalbumswidget.py
index 42bb42ed..c6027dee 100644
--- a/gnomemusic/widgets/artistalbumswidget.py
+++ b/gnomemusic/widgets/artistalbumswidget.py
@@ -40,15 +40,13 @@ class ArtistAlbumsWidget(Gtk.ListBox):
 
     selection_mode = GObject.Property(type=bool, default=False)
 
-    def __init__(
-            self, coreartist, application, selection_mode_allowed=False):
+    def __init__(self, coreartist, application):
         super().__init__()
 
         self._application = application
         self._artist = coreartist.props.artist
         self._model = coreartist.props.model
         self._player = self._application.props.player
-        self._selection_mode_allowed = selection_mode_allowed
 
         self._cover_size_group = Gtk.SizeGroup.new(
             Gtk.SizeGroupMode.HORIZONTAL)
@@ -81,8 +79,7 @@ class ArtistAlbumsWidget(Gtk.ListBox):
         row.props.activatable = False
 
         widget = ArtistAlbumWidget(
-            corealbum, self._selection_mode_allowed,
-            self._songs_grid_size_group, self._cover_size_group)
+            corealbum, self._songs_grid_size_group, self._cover_size_group)
 
         self.bind_property(
             'selection-mode', widget, 'selection-mode',
diff --git a/gnomemusic/widgets/artistalbumwidget.py b/gnomemusic/widgets/artistalbumwidget.py
index 2c7e5d73..ee2faea4 100644
--- a/gnomemusic/widgets/artistalbumwidget.py
+++ b/gnomemusic/widgets/artistalbumwidget.py
@@ -47,23 +47,17 @@ class ArtistAlbumWidget(Gtk.Box):
         ),
     }
 
-    def __init__(
-            self, corealbum, selection_mode_allowed, size_group=None,
-            cover_size_group=None):
+    def __init__(self, corealbum, size_group=None, cover_size_group=None):
         super().__init__(orientation=Gtk.Orientation.HORIZONTAL)
 
         self._size_group = size_group
         self._cover_size_group = cover_size_group
 
         self._selection_mode = False
-        self._selection_mode_allowed = selection_mode_allowed
 
         self._cover_stack.props.size = Art.Size.MEDIUM
         self._cover_stack.update(corealbum)
 
-        allowed = self._selection_mode_allowed
-        self._disc_list_box.props.selection_mode_allowed = allowed
-
         self.bind_property(
             'selection-mode', self._disc_list_box, 'selection-mode',
             GObject.BindingFlags.BIDIRECTIONAL
@@ -90,11 +84,6 @@ class ArtistAlbumWidget(Gtk.Box):
     def _create_widget(self, disc):
         disc_box = self._create_disc_box(disc.props.disc_nr, disc.model)
 
-        self._disc_list_box.bind_property(
-            "selection-mode-allowed", disc_box, "selection-mode-allowed",
-            GObject.BindingFlags.BIDIRECTIONAL
-            | GObject.BindingFlags.SYNC_CREATE)
-
         self._disc_list_box.bind_property(
             "selection-mode", disc_box, "selection-mode",
             GObject.BindingFlags.BIDIRECTIONAL
diff --git a/gnomemusic/widgets/disclistboxwidget.py b/gnomemusic/widgets/disclistboxwidget.py
index 8c6fea4a..514393f4 100644
--- a/gnomemusic/widgets/disclistboxwidget.py
+++ b/gnomemusic/widgets/disclistboxwidget.py
@@ -45,7 +45,6 @@ class DiscBox(Gtk.ListBoxRow):
     }
 
     selection_mode = GObject.Property(type=bool, default=False)
-    selection_mode_allowed = GObject.Property(type=bool, default=True)
     show_disc_label = GObject.Property(type=bool, default=False)
     show_durations = GObject.Property(type=bool, default=False)
     show_favorites = GObject.Property(type=bool, default=False)
@@ -125,8 +124,7 @@ class DiscBox(Gtk.ListBoxRow):
 
         mod_mask = Gtk.accelerator_get_default_mod_mask()
         if ((event.get_state() & mod_mask) == Gdk.ModifierType.CONTROL_MASK
-                and not self.props.selection_mode
-                and self.props.selection_mode_allowed):
+                and not self.props.selection_mode):
             self.props.selection_mode = True
             widget.props.select_click = True
             widget.props.coresong.props.selected = True
@@ -151,8 +149,6 @@ class DiscListBox(Gtk.ListBox):
     """
     __gtype_name__ = 'DiscListBox'
 
-    selection_mode_allowed = GObject.Property(type=bool, default=False)
-
     def __init__(self):
         """Initialize"""
         super().__init__()
@@ -191,7 +187,4 @@ class DiscListBox(Gtk.ListBox):
 
         :param bool value: Activate selection mode
         """
-        if not self.props.selection_mode_allowed:
-            return
-
         self._selection_mode = value


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