[gnome-klotski/arnaudb/wip/gtk4: 23/42] Update to GestureClick.



commit 7ea96ce63285c464d7433c18a7ad17cc1e34bc5a
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Thu Mar 5 18:46:00 2020 +0100

    Update to GestureClick.
    
    And other EventController things.

 src/klotski-window.vala |  3 ++-
 src/puzzle-view.vala    | 12 +++++++-----
 2 files changed, 9 insertions(+), 6 deletions(-)
---
diff --git a/src/klotski-window.vala b/src/klotski-window.vala
index 2c17460..da471ba 100644
--- a/src/klotski-window.vala
+++ b/src/klotski-window.vala
@@ -1052,9 +1052,10 @@ private class KlotskiWindow : ApplicationWindow
 
     private inline void init_keyboard ()
     {
-        key_controller = new EventControllerKey (this);
+        key_controller = new EventControllerKey ();
         key_controller.propagation_phase = PropagationPhase.CAPTURE;
         key_controller.key_pressed.connect (on_key_pressed);
+        ((Widget) this).add_controller (key_controller);
     }
 
     private inline bool on_key_pressed (EventControllerKey _key_controller, uint keyval, uint keycode, 
Gdk.ModifierType state)
diff --git a/src/puzzle-view.vala b/src/puzzle-view.vala
index 55cf7a4..7bb5310 100644
--- a/src/puzzle-view.vala
+++ b/src/puzzle-view.vala
@@ -230,19 +230,21 @@ private class PuzzleView : Gtk.DrawingArea
     \*/
 
     private Gtk.EventControllerMotion motion_controller;    // for keeping in memory
-    private Gtk.GestureMultiPress click_controller;         // for keeping in memory
+    private Gtk.GestureClick click_controller;              // for keeping in memory
 
     private void init_mouse ()  // called on construct
     {
-        motion_controller = new Gtk.EventControllerMotion (this);
+        motion_controller = new Gtk.EventControllerMotion ();
         motion_controller.motion.connect (on_motion);
+        add_controller (motion_controller);
 
-        click_controller = new Gtk.GestureMultiPress (this);    // only targets Gdk.BUTTON_PRIMARY
+        click_controller = new Gtk.GestureClick ();         // only targets Gdk.BUTTON_PRIMARY
         click_controller.pressed.connect (on_click);
         click_controller.released.connect (on_release);
+        add_controller (click_controller);
     }
 
-    private static inline void on_click (Gtk.GestureMultiPress _click_controller, int n_press, double 
event_x, double event_y)
+    private static inline void on_click (Gtk.GestureClick _click_controller, int n_press, double event_x, 
double event_y)
     {
         PuzzleView _this = (PuzzleView) _click_controller.get_widget ();
         if (_this.puzzle.game_over ())
@@ -278,7 +280,7 @@ private class PuzzleView : Gtk.DrawingArea
         _this.puzzle.move_map = _this.puzzle.map;
     }
 
-    private static inline void on_release (Gtk.GestureMultiPress _click_controller, int n_press, double 
event_x, double event_y)
+    private static inline void on_release (Gtk.GestureClick _click_controller, int n_press, double event_x, 
double event_y)
     {
         PuzzleView _this = (PuzzleView) _click_controller.get_widget ();
         if (_this.piece_id != '\0')


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]