[gnome-chess] No longer need to keep event controllers alive
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-chess] No longer need to keep event controllers alive
- Date: Sun, 27 Dec 2020 15:01:01 +0000 (UTC)
commit 72cbf108eafce616973941df4d71867f2fb79874
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Sun Dec 27 09:01:00 2020 -0600
No longer need to keep event controllers alive
The controller is now owned by its widget.
src/chess-view.vala | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
---
diff --git a/src/chess-view.vala b/src/chess-view.vala
index f41a123..5aa877b 100644
--- a/src/chess-view.vala
+++ b/src/chess-view.vala
@@ -19,8 +19,6 @@ public class ChessView : Gtk.DrawingArea
private Cairo.Surface? selected_model_surface;
private string loaded_theme_name = "";
- private Gtk.GestureClick click_controller; // for keeping in memory
-
private ChessScene _scene;
public ChessScene scene
{
@@ -42,7 +40,10 @@ public class ChessView : Gtk.DrawingArea
{
Object (scene: scene);
- init_mouse ();
+ var click_controller = new Gtk.GestureClick (); // only reacts to Gdk.BUTTON_PRIMARY
+ click_controller.pressed.connect (on_click);
+ add_controller (click_controller);
+
set_draw_func (draw);
hexpand = true;
@@ -275,13 +276,6 @@ public class ChessView : Gtk.DrawingArea
c.paint_with_alpha (alpha);
}
- private void init_mouse ()
- {
- click_controller = new Gtk.GestureClick (); // only reacts to Gdk.BUTTON_PRIMARY
- click_controller.pressed.connect (on_click);
- add_controller (click_controller);
- }
-
private void on_click (Gtk.GestureClick _click_controller, int n_press, double event_x, double event_y)
{
if (scene.game == null || scene.game.should_show_paused_overlay)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]