Commit 048ce099 authored by Jean Felder's avatar Jean Felder Committed by Jean Felder
Browse files

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.
parent e0a9c598
Pipeline #273627 passed with stages
in 10 minutes and 13 seconds
......@@ -165,8 +165,6 @@
<property name="visible_window">True</property>
<property name="margin-end">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>
......@@ -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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment