[gnome-music/wip/jfelder/gtk4-v3: 14/130] GTK4 gestures rework
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/gtk4-v3: 14/130] GTK4 gestures rework
- Date: Thu, 3 Feb 2022 14:59:56 +0000 (UTC)
commit dd8ab62a1423c17d79fec65f8cbfffb109890345
Author: Marinus Schraal <mschraal gnome org>
Date: Sun Apr 11 14:13:43 2021 +0200
GTK4 gestures rework
data/ui/AlbumsView.ui | 13 +++++++------
data/ui/LastfmDialog.ui | 9 +++++----
data/ui/SongsView.ui | 11 ++++++-----
gnomemusic/widgets/lastfmdialog.py | 1 -
gnomemusic/widgets/smoothscale.py | 8 ++++----
gnomemusic/window.py | 8 ++++----
6 files changed, 26 insertions(+), 24 deletions(-)
---
diff --git a/data/ui/AlbumsView.ui b/data/ui/AlbumsView.ui
index a0832384c..caa1f1d49 100644
--- a/data/ui/AlbumsView.ui
+++ b/data/ui/AlbumsView.ui
@@ -26,6 +26,13 @@
<style>
<class name="content-view"/>
</style>
+ <child>
+ <object class="GtkGestureLongPress" id="_flowbox_long_press">
+ <property name="propagation-phase">capture</property>
+ <signal name="begin" handler="_on_flowbox_press_begin" swapped="no"/>
+ <signal name="cancel" handler="_on_flowbox_press_cancel" swapped="no"/>
+ </object>
+ </child>
</object>
</child>
</object>
@@ -46,10 +53,4 @@
</packing>
</child>
</template>
- <object class="GtkGestureLongPress" id="_flowbox_long_press">
- <property name="propagation-phase">capture</property>
- <property name="widget">_flowbox</property>
- <signal name="begin" handler="_on_flowbox_press_begin" swapped="no"/>
- <signal name="cancel" handler="_on_flowbox_press_cancel" swapped="no"/>
- </object>
</interface>
diff --git a/data/ui/LastfmDialog.ui b/data/ui/LastfmDialog.ui
index 6096f608d..1ec99eac0 100644
--- a/data/ui/LastfmDialog.ui
+++ b/data/ui/LastfmDialog.ui
@@ -56,6 +56,11 @@
</child>
<child>
<object class="GtkButton" id="_action_button">
+ <child>
+ <object class="GtkGestureClick">
+ <signal name="released" handler="_on_action_button_clicked" swapped="no"/>
+ </object>
+ </child>
<property name="halign">start</property>
<property name="label" translatable="yes">Login</property>
<property name="margin-bottom">8</property>
@@ -65,8 +70,4 @@
</object>
</child>
</template>
- <object class="GtkGestureMultiPress" id="_action_button_gesture">
- <property name="widget">_action_button</property>
- <signal name="released" handler="_on_action_button_clicked" swapped="no"/>
- </object>
</interface>
diff --git a/data/ui/SongsView.ui b/data/ui/SongsView.ui
index 223df3758..433243d02 100644
--- a/data/ui/SongsView.ui
+++ b/data/ui/SongsView.ui
@@ -15,6 +15,12 @@
<style>
<class name="songs-list-old"/>
</style>
+ <child>
+ <object class="GtkGestureClick" id="_songs_ctrlr">
+ <property name="propagation-phase">capture</property>
+ <signal name="released" handler="_on_view_clicked" swapped="no"/>
+ </object>
+ </child>
<child internal-child="selection">
<object class="GtkTreeSelection">
<property name="mode">single</property>
@@ -115,9 +121,4 @@
</object>
</child>
</template>
- <object class="GtkGestureMultiPress" id="_songs_ctrlr">
- <property name="widget">_songs_view</property>
- <property name="propagation-phase">capture</property>
- <signal name="released" handler="_on_view_clicked" swapped="no"/>
- </object>
</interface>
diff --git a/gnomemusic/widgets/lastfmdialog.py b/gnomemusic/widgets/lastfmdialog.py
index 5ba226563..1cf32cf11 100644
--- a/gnomemusic/widgets/lastfmdialog.py
+++ b/gnomemusic/widgets/lastfmdialog.py
@@ -36,7 +36,6 @@ class LastfmDialog(Gtk.Dialog):
__gtype_name__ = "LastfmDialog"
_action_button = Gtk.Template.Child()
- _action_button_gesture = Gtk.Template.Child()
_action_label = Gtk.Template.Child()
_status_label = Gtk.Template.Child()
diff --git a/gnomemusic/widgets/smoothscale.py b/gnomemusic/widgets/smoothscale.py
index d1f6d3f9d..51e977174 100644
--- a/gnomemusic/widgets/smoothscale.py
+++ b/gnomemusic/widgets/smoothscale.py
@@ -46,10 +46,10 @@ class SmoothScale(Gtk.Scale):
self._timeout = None
- self._controller = Gtk.GestureMultiPress().new(self)
- self._controller.props.propagation_phase = Gtk.PropagationPhase.CAPTURE
- self._controller.connect("pressed", self._on_button_pressed)
- self._controller.connect("released", self._on_button_released)
+ ctrl = Gtk.GestureClick()
+ ctrl.connect("pressed", self._on_button_pressed)
+ ctrl.connect("released", self._on_button_released)
+ self.add_controller(ctrl)
self.connect('change-value', self._on_smooth_scale_seek)
diff --git a/gnomemusic/window.py b/gnomemusic/window.py
index 3a19653f8..e257b332e 100644
--- a/gnomemusic/window.py
+++ b/gnomemusic/window.py
@@ -229,11 +229,11 @@ class Window(Adw.ApplicationWindow):
if self.views[View.ALBUM] is not None:
return
- self._btn_ctrl = Gtk.GestureMultiPress().new(self)
- self._btn_ctrl.props.propagation_phase = Gtk.PropagationPhase.CAPTURE
+ ctrl = Gtk.GestureClick().new()
# Mouse button 8 is the back button.
- self._btn_ctrl.props.button = 8
- self._btn_ctrl.connect("pressed", self._on_back_button_pressed)
+ ctrl.props.button = 8
+ ctrl.connect("pressed", self._on_back_button_pressed)
+ self.add_controller(ctrl)
self.views[View.EMPTY].props.state = EmptyView.State.SEARCH
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]