[gnome-music/wip/jfelder/songwidget-listboxrow: 7/8] playlistswidget: Use the row-activated signal to handle song clicks
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/songwidget-listboxrow: 7/8] playlistswidget: Use the row-activated signal to handle song clicks
- Date: Sat, 8 May 2021 23:29:44 +0000 (UTC)
commit e3fec86d1b83c28a129b50c5b9a2daa2c9405823
Author: Jean Felder <jfelder src gnome org>
Date: Sat May 8 17:45:31 2021 +0200
playlistswidget: Use the row-activated signal to handle song clicks
SongWidget inherits from GtkEventBox and is inserted into a
GtkListBoxRow in order to be used by a GtkListBox. The SongWidget
consumers use the "button-release-event" signal from the GtkEventBox
to handle clicks on songs.
This commit changes the signal logic to use the "row-activated" signal
from the GtkListBox instead. It will make it possible to have
SongWidget directly inheriting from a GtkListBoxRow in the next
commit.
data/ui/PlaylistsWidget.ui | 1 +
gnomemusic/widgets/playlistswidget.py | 7 ++++---
2 files changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/data/ui/PlaylistsWidget.ui b/data/ui/PlaylistsWidget.ui
index cbfb68d97..72bb137ef 100644
--- a/data/ui/PlaylistsWidget.ui
+++ b/data/ui/PlaylistsWidget.ui
@@ -20,6 +20,7 @@
<property name="margin-top">20</property>
<property name="valign">start</property>
<property name="visible">True</property>
+ <signal name="row-activated" handler="_on_song_activated" swapped="no"/>
<style>
<class name="songs-list"/>
</style>
diff --git a/gnomemusic/widgets/playlistswidget.py b/gnomemusic/widgets/playlistswidget.py
index 74c8a99cf..3cc2e4b96 100644
--- a/gnomemusic/widgets/playlistswidget.py
+++ b/gnomemusic/widgets/playlistswidget.py
@@ -107,7 +107,6 @@ class PlaylistsWidget(Gtk.Box):
song_widget = SongWidget(coresong, can_dnd, True)
song_widget.props.show_song_number = False
- song_widget.connect("button-release-event", self._on_song_activated)
if can_dnd is True:
song_widget.connect("widget_moved", self._on_song_widget_moved)
@@ -117,8 +116,10 @@ class PlaylistsWidget(Gtk.Box):
return row
- def _on_song_activated(self, widget, event):
- coresong = widget.props.coresong
+ @Gtk.Template.Callback()
+ def _on_song_activated(
+ self, list_box: Gtk.ListBox, row: Gtk.ListBoxRow) -> bool:
+ coresong = row.get_child().props.coresong
self._play(coresong)
return True
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]