[gnome-mines/arnaudb/wip/gtk4: 7/36] Clean Tile code.



commit cf71f0c2ae54cea1d2e549c7e1e88dac8fbe6a47
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Thu Apr 16 21:28:54 2020 +0200

    Clean Tile code.

 src/tile.vala | 24 ++++++++++--------------
 1 file changed, 10 insertions(+), 14 deletions(-)
---
diff --git a/src/tile.vala b/src/tile.vala
index bc95986..f1c1a4f 100644
--- a/src/tile.vala
+++ b/src/tile.vala
@@ -1,32 +1,28 @@
 public class Tile : Gtk.Button
 {
-    private int _row;
-    private int _column;
+    public int row      { internal get; protected construct; }
+    public int column   { internal get; protected construct; }
+
     private Gtk.GestureLongPress _gesture;
+
     public signal void tile_mouse_over (int x, int y);
     public signal void tile_pressed (int x, int y, Gdk.EventButton event);
     public signal void tile_released (int x, int y, Gdk.EventButton event);
     public signal void tile_long_pressed (int x, int y);
 
-    public int row
-    {
-        get { return _row; }
-    }
-    public int column
+    public Tile (int prow, int pcol)
     {
-        get { return _column; }
+        Object (row: prow, column: pcol);
     }
 
-    public Tile (int prow, int pcol)
+    construct
     {
-        _row = prow;
-        _column = pcol;
         can_focus = false;
         add_class ("tile");
         _gesture = new Gtk.GestureLongPress (this);
         _gesture.pressed.connect((x, y) =>
         {
-            tile_long_pressed (prow, pcol);
+            tile_long_pressed (row, column);
         });
         button_press_event.connect ((event) =>
         {
@@ -35,12 +31,12 @@ public class Tile : Gtk.Button
             event.get_seat().ungrab ();
 //            event.device.ungrab (event.time);
 
-            tile_pressed (prow, pcol, event);
+            tile_pressed (row, column, event);
             return false;
         });
         button_release_event.connect ((event) =>
         {
-            tile_released (prow, pcol, event);
+            tile_released (row, column, event);
             return false;
         });
     }


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