[gnome-music/wip/jfelder/gtk4-v3: 146/259] songwidget: Restore star toggle
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/gtk4-v3: 146/259] songwidget: Restore star toggle
- Date: Thu, 17 Feb 2022 08:41:22 +0000 (UTC)
commit 7cf11e3c7a110136e6d787be4d0e6ed4eaabd9e9
Author: Jean Felder <jfelder src gnome org>
Date: Thu Feb 3 20:53:27 2022 +0100
songwidget: Restore star toggle
data/ui/SongWidget.ui | 8 +++++++-
gnomemusic/widgets/songwidget.py | 18 ++++++++----------
2 files changed, 15 insertions(+), 11 deletions(-)
---
diff --git a/data/ui/SongWidget.ui b/data/ui/SongWidget.ui
index 3a2ff6650..d6ce06c0e 100644
--- a/data/ui/SongWidget.ui
+++ b/data/ui/SongWidget.ui
@@ -134,7 +134,13 @@
<property name="focusable">0</property>
<property name="halign">end</property>
<property name="valign">center</property>
- <!-- <signal name="button-release-event" handler="_on_star_toggle" swapped="no"/> -->
+ <child>
+ <object class="GtkGestureClick">
+ <property name="button">1</property>
+ <property name="propagation-phase">capture</property>
+ <signal name="released" handler="_on_star_toggle" swapped="no"/>
+ </object>
+ </child>
<child>
<object class="GtkEventControllerMotion">
<signal name="enter" handler="_on_star_hover" swapped="no"/>
diff --git a/gnomemusic/widgets/songwidget.py b/gnomemusic/widgets/songwidget.py
index 83d566cf3..5048ee49b 100644
--- a/gnomemusic/widgets/songwidget.py
+++ b/gnomemusic/widgets/songwidget.py
@@ -201,16 +201,14 @@ class SongWidget(Gtk.ListBoxRow):
# (one event in SongWidget and the other one in select_button).
self.props.select_click = not self.props.select_click
- # @Gtk.Template.Callback()
- # def _on_star_toggle(self, widget, event):
- # (_, button) = event.get_button()
- # if button != Gdk.BUTTON_PRIMARY:
- # return False
-
- # favorite = not self._star_image.favorite
- # self._star_image.props.favorite = favorite
-
- # return True
+ @Gtk.Template.Callback()
+ def _on_star_toggle(
+ self, controller: Gtk.GestureClick, n_press: int, x: float,
+ y: float) -> bool:
+ controller.set_state(Gtk.EventSequenceState.CLAIMED)
+ favorite = not self._star_image.favorite
+ self._star_image.props.favorite = favorite
+ return Gdk.EVENT_STOP
@Gtk.Template.Callback()
def _on_star_hover(self, controller, x, y):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]