[gnome-robots/arnaudb/wip/gtk4: 17/45] Use GtkGestureClick.




commit 1457831256cbd118f781c3a30774e04806c5df31
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Sat May 23 22:20:31 2020 +0200

    Use GtkGestureClick.
    
    And other GtkEventController things.

 src/game.c         | 14 ++++++++------
 src/game.h         | 10 +++++-----
 src/gnome-robots.c |  6 ++++--
 3 files changed, 17 insertions(+), 13 deletions(-)
---
diff --git a/src/game.c b/src/game.c
index 417c47b..6931f42 100644
--- a/src/game.c
+++ b/src/game.c
@@ -554,10 +554,12 @@ init_keyboard (void)
 {
   GtkEventController *key_controller;
 
-  key_controller = gtk_event_controller_key_new (window);
+  key_controller = gtk_event_controller_key_new ();
 
   g_signal_connect (G_OBJECT (key_controller), "key-pressed",
                     G_CALLBACK (keyboard_cb), 0);
+
+  gtk_widget_add_controller (window, key_controller);
 }
 
 
@@ -1322,11 +1324,11 @@ get_dir (int ix, int iy, int *odx, int *ody)
 }
 
 void
-mouse_cb (GtkGestureMultiPress *gesture,
-          gint                  n_press,
-          gdouble               x,
-          gdouble               y,
-          gpointer              user_data)
+mouse_cb (GtkGestureClick *gesture,
+          gint             n_press,
+          gdouble          x,
+          gdouble          y,
+          gpointer         user_data)
 {
   int dx, dy;
 
diff --git a/src/game.h b/src/game.h
index 3dec455..3029a9b 100644
--- a/src/game.h
+++ b/src/game.h
@@ -28,11 +28,11 @@ void quit_game (void);
 void game_keypress (gint);
 void show_scores (void);
 void start_new_game (void);
-void mouse_cb (GtkGestureMultiPress *gesture,
-               gint                  n_press,
-               gdouble               x,
-               gdouble               y,
-               gpointer              user_data);
+void mouse_cb (GtkGestureClick *gesture,
+               gint             n_press,
+               gdouble          x,
+               gdouble          y,
+               gpointer         user_data);
 void move_cb (GtkEventControllerMotion *controller,
               gdouble                   x,
               gdouble                   y,
diff --git a/src/gnome-robots.c b/src/gnome-robots.c
index b173736..20cc065 100644
--- a/src/gnome-robots.c
+++ b/src/gnome-robots.c
@@ -391,11 +391,13 @@ activate (GtkApplication *app, gpointer user_data)
   g_signal_connect (G_OBJECT (game_area), "draw",                   G_CALLBACK (draw_cb),   NULL);
   g_signal_connect (G_OBJECT (game_area), "destroy",                G_CALLBACK (gtk_widget_destroyed), 
&game_area);
 
-  click_controller = gtk_gesture_multi_press_new (game_area);
+  click_controller = gtk_gesture_click_new ();
   g_signal_connect (G_OBJECT (click_controller), "pressed", G_CALLBACK (mouse_cb), NULL);
+  gtk_widget_add_controller (game_area, GTK_EVENT_CONTROLLER (click_controller));
 
-  motion_controller = gtk_event_controller_motion_new (game_area);
+  motion_controller = gtk_event_controller_motion_new ();
   g_signal_connect (G_OBJECT (motion_controller), "motion", G_CALLBACK (move_cb), NULL);
+  gtk_widget_add_controller (game_area, motion_controller);
 
   gridframe = GTK_WIDGET (games_grid_frame_new (GAME_WIDTH, GAME_HEIGHT));
   gtk_container_add (GTK_CONTAINER (gridframe), game_area);


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