[gnome-mahjongg/arnaudb/wip/gtk4: 6/23] Use GestureClick.



commit 9547b2d46537e71e86bcd378f8aaa420a7900682
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Sat Apr 25 11:17:53 2020 +0200

    Use GestureClick.

 src/game-view.vala      | 7 ++++---
 src/gnome-mahjongg.vala | 7 ++++---
 2 files changed, 8 insertions(+), 6 deletions(-)
---
diff --git a/src/game-view.vala b/src/game-view.vala
index 484585a..4449685 100644
--- a/src/game-view.vala
+++ b/src/game-view.vala
@@ -32,7 +32,7 @@ public class GameView : Gtk.DrawingArea
     private uint   theme_resize_timer;
     private uint   theme_timer_id;
 
-    private Gtk.GestureMultiPress click_controller;     // for keeping in memory
+    private Gtk.GestureClick click_controller;          // for keeping in memory
 
     private Game? _game;
     public Game? game
@@ -315,11 +315,12 @@ public class GameView : Gtk.DrawingArea
 
     private inline void init_mouse ()
     {
-        click_controller = new Gtk.GestureMultiPress (this);    // only reacts to Gdk.BUTTON_PRIMARY
+        click_controller = new Gtk.GestureClick ();     // only reacts to Gdk.BUTTON_PRIMARY
         click_controller.pressed.connect (on_click);
+        add_controller (click_controller);
     }
 
-    private inline void on_click (Gtk.GestureMultiPress _click_controller, int n_press, double event_x, 
double event_y)
+    private inline void on_click (Gtk.GestureClick _click_controller, int n_press, double event_x, double 
event_y)
     {
         if (game == null || game.paused)
             return;
diff --git a/src/gnome-mahjongg.vala b/src/gnome-mahjongg.vala
index 460570a..b604e1a 100644
--- a/src/gnome-mahjongg.vala
+++ b/src/gnome-mahjongg.vala
@@ -101,8 +101,9 @@ public class Mahjongg : Gtk.Application
         var vbox = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
 
         game_view = new GameView ();
-        view_click_controller = new Gtk.GestureMultiPress (game_view);
+        view_click_controller = new Gtk.GestureClick ();
         view_click_controller.pressed.connect (on_click);
+        game_view.add_controller (view_click_controller);
         game_view.set_size_request (600, 400);
 
         title = new Gtk.Label ("");
@@ -298,8 +299,8 @@ public class Mahjongg : Gtk.Application
         }
     }
 
-    private Gtk.GestureMultiPress view_click_controller;    // for keeping in memory
-    private inline void on_click (Gtk.GestureMultiPress _view_click_controller, int n_press, double event_x, 
double event_y)
+    private Gtk.GestureClick view_click_controller;    // for keeping in memory
+    private inline void on_click (Gtk.GestureClick _view_click_controller, int n_press, double event_x, 
double event_y)
     {
         /* Cancel pause on click */
         if (game_view.game.paused)


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