[gnome-music/wip/jfelder/selection-misc-cleanups: 16/20] discbox: Inherit from GtkListBoxRow
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/selection-misc-cleanups: 16/20] discbox: Inherit from GtkListBoxRow
- Date: Fri, 10 Jan 2020 13:34:34 +0000 (UTC)
commit ea69f07d0fa5abe5864aa3364367128d11d5b64c
Author: Jean Felder <jfelder src gnome org>
Date: Thu Jan 9 17:48:41 2020 +0100
discbox: Inherit from GtkListBoxRow
This simplifies the code a little bit and ensures that the row is not
selectable by default.
data/ui/DiscBox.ui | 75 ++++++++++++++++++---------------
gnomemusic/widgets/albumwidget.py | 8 +---
gnomemusic/widgets/artistalbumwidget.py | 4 +-
gnomemusic/widgets/disclistboxwidget.py | 6 +--
4 files changed, 47 insertions(+), 46 deletions(-)
---
diff --git a/data/ui/DiscBox.ui b/data/ui/DiscBox.ui
index d1576f37..a769b65c 100644
--- a/data/ui/DiscBox.ui
+++ b/data/ui/DiscBox.ui
@@ -2,39 +2,46 @@
<!-- Generated with glade 3.20.0 -->
<interface>
<requires lib="gtk+" version="3.12"/>
- <template parent="GtkBox" class="DiscBox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <child>
- <object class="GtkLabel" id="_disc_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">fill</property>
- <!-- <property name="hexpand">True</property> -->
- <property name="no_show_all">True</property>
- <property name="xalign">0.0</property>
- <style>
- <class name="disc-label"/>
- </style>
- </object>
- <packing>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkListBox" id="_list_box">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="valign">start</property>
- <property name="selection_mode">none</property>
- <style>
- <class name="songs-list"/>
- </style>
- </object>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
+ <template parent="GtkListBoxRow" class="DiscBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="selectable">False</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkLabel" id="_disc_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">fill</property>
+ <!-- <property name="hexpand">True</property> -->
+ <property name="no_show_all">True</property>
+ <property name="xalign">0.0</property>
+ <style>
+ <class name="disc-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkListBox" id="_list_box">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="valign">start</property>
+ <property name="selection_mode">none</property>
+ <style>
+ <class name="songs-list"/>
+ </style>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
</template>
</interface>
diff --git a/gnomemusic/widgets/albumwidget.py b/gnomemusic/widgets/albumwidget.py
index 8b0a59fe..78590b29 100644
--- a/gnomemusic/widgets/albumwidget.py
+++ b/gnomemusic/widgets/albumwidget.py
@@ -139,15 +139,11 @@ class AlbumWidget(Gtk.EventBox):
def _on_model_items_changed(self, model, position, removed, added):
n_items = model.get_n_items()
if n_items == 1:
- row = self._disc_list_box.get_row_at_index(0)
- row.props.selectable = False
- discbox = row.get_child()
+ discbox = self._disc_list_box.get_row_at_index(0)
discbox.props.show_disc_label = False
else:
for i in range(n_items):
- row = self._disc_list_box.get_row_at_index(i)
- row.props.selectable = False
- discbox = row.get_child()
+ discbox = self._disc_list_box.get_row_at_index(i)
discbox.props.show_disc_label = True
def _set_composer_label(self, corealbum):
diff --git a/gnomemusic/widgets/artistalbumwidget.py b/gnomemusic/widgets/artistalbumwidget.py
index fcf89641..a579a302 100644
--- a/gnomemusic/widgets/artistalbumwidget.py
+++ b/gnomemusic/widgets/artistalbumwidget.py
@@ -114,9 +114,7 @@ class ArtistAlbumWidget(Gtk.Box):
def _on_model_items_changed(self, model, position, removed, added):
n_items = model.get_n_items()
for i in range(n_items):
- row = self._disc_list_box.get_row_at_index(i)
- row.props.selectable = False
- discbox = row.get_child()
+ discbox = self._disc_list_box.get_row_at_index(i)
discbox.props.show_disc_label = (n_items > 1)
def _song_activated(self, widget, song_widget):
diff --git a/gnomemusic/widgets/disclistboxwidget.py b/gnomemusic/widgets/disclistboxwidget.py
index fc7acea1..e183a9e3 100644
--- a/gnomemusic/widgets/disclistboxwidget.py
+++ b/gnomemusic/widgets/disclistboxwidget.py
@@ -30,7 +30,7 @@ from gnomemusic.widgets.songwidget import SongWidget
@Gtk.Template(resource_path='/org/gnome/Music/ui/DiscBox.ui')
-class DiscBox(Gtk.Box):
+class DiscBox(Gtk.ListBoxRow):
"""A widget which compromises one disc
DiscBox contains a disc label for the disc number on top
@@ -174,7 +174,7 @@ class DiscListBox(Gtk.ListBox):
def select_all(self):
"""Select all songs"""
def child_select_all(child):
- child.get_child().select_all()
+ child.select_all()
self.foreach(child_select_all)
@@ -182,7 +182,7 @@ class DiscListBox(Gtk.ListBox):
def select_none(self):
"""Deselect all songs"""
def child_select_none(child):
- child.get_child().select_none()
+ child.select_none()
self.foreach(child_select_none)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]