[gnome-music/wip/jfelder/event-controller-key: 3/3] songwidget: Use a controller to handle star hover effect
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/event-controller-key: 3/3] songwidget: Use a controller to handle star hover effect
- Date: Wed, 24 Mar 2021 20:24:56 +0000 (UTC)
commit c0e7a7faba1a85ad60cce2b70d29b6114deb9081
Author: Jean Felder <jfelder src gnome org>
Date: Wed Mar 24 21:06:44 2021 +0100
songwidget: Use a controller to handle star hover effect
The "enter-notify-event" and "leave-notify-event" signals have been
removed from GTK4. Use a controller instead.
data/ui/SongWidget.ui | 7 +++++--
gnomemusic/widgets/songwidget.py | 5 +++--
2 files changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/data/ui/SongWidget.ui b/data/ui/SongWidget.ui
index 8280ce9db..deae1890c 100644
--- a/data/ui/SongWidget.ui
+++ b/data/ui/SongWidget.ui
@@ -165,8 +165,6 @@
<property name="visible_window">True</property>
<property name="margin_right">12</property>
<signal name="button-release-event" handler="_on_star_toggle" swapped="no"/>
- <signal name="enter-notify-event" handler="_on_star_hover" swapped="no"/>
- <signal name="leave-notify-event" handler="_on_star_unhover" swapped="no"/>
<child>
<object class="StarImage" id="_star_image">
<property name="visible">True</property>
@@ -202,4 +200,9 @@
<widget name="_album_duration_box"/>
</widgets>
</object>
+ <object class="GtkEventControllerMotion" id="_controller_motion">
+ <property name="widget">_star_eventbox</property>
+ <signal name="enter" handler="_on_star_hover" swapped="no"/>
+ <signal name="leave" handler="_on_star_unhover" swapped="no"/>
+ </object>
</interface>
diff --git a/gnomemusic/widgets/songwidget.py b/gnomemusic/widgets/songwidget.py
index 73b35e1a7..2a1d61776 100644
--- a/gnomemusic/widgets/songwidget.py
+++ b/gnomemusic/widgets/songwidget.py
@@ -63,6 +63,7 @@ class SongWidget(Gtk.EventBox):
_album_duration_box = Gtk.Template.Child()
_artist_box = Gtk.Template.Child()
_artist_label = Gtk.Template.Child()
+ _controller_motion = Gtk.Template.Child()
_dnd_eventbox = Gtk.Template.Child()
_select_button = Gtk.Template.Child()
_number_label = Gtk.Template.Child()
@@ -215,11 +216,11 @@ class SongWidget(Gtk.EventBox):
return True
@Gtk.Template.Callback()
- def _on_star_hover(self, widget, event):
+ def _on_star_hover(self, controller, x, y):
self._star_image.props.hover = True
@Gtk.Template.Callback()
- def _on_star_unhover(self, widget, event):
+ def _on_star_unhover(self, controller):
self._star_image.props.hover = False
@GObject.Property(type=bool, default=False)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]