[gnome-sudoku/arnaudb/wip/gtk4: 25/43] Adapt to DrawingArea API.




commit 93d69c62ae74ea9d29d33eb4c57634cbb08424ce
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Sun Apr 12 15:43:03 2020 +0200

    Adapt to DrawingArea API.

 src/sudoku-view.vala | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)
---
diff --git a/src/sudoku-view.vala b/src/sudoku-view.vala
index 57e8185..2fbb54a 100644
--- a/src/sudoku-view.vala
+++ b/src/sudoku-view.vala
@@ -104,6 +104,7 @@ private class SudokuCellView : DrawingArea
 
         init_mouse ();
         init_keyboard ();
+        set_draw_func (draw);
 
         value = game.board [row, col];
 
@@ -345,7 +346,7 @@ private class SudokuCellView : DrawingArea
         return false;
     }
 
-    public override bool draw (Cairo.Context c)
+    private inline void draw (DrawingArea _this, Cairo.Context c, int new_width, int new_height)
     {
         RGBA background_color;
         if (_selected && is_focus)
@@ -370,7 +371,7 @@ private class SudokuCellView : DrawingArea
             c.set_source_rgb (0.0, 0.0, 0.0);
 
         if (game.paused)
-            return false;
+            return;
 
         if (value != 0)
         {
@@ -380,11 +381,11 @@ private class SudokuCellView : DrawingArea
 
             c.set_font_size (height / size_ratio);
             print_centered (c, text, width, height);
-            return false;
+            return;
         }
 
         if (is_fixed && game.mode == GameMode.PLAY)
-            return false;
+            return;
 
         bool[] marks = null;
         if (!_show_possibilities)
@@ -431,8 +432,6 @@ private class SudokuCellView : DrawingArea
             c.set_source_rgb (1.0, 0.0, 0.0);
             print_centered (c, "X", get_allocated_width (), get_allocated_height ());
         }
-
-        return false;
     }
 
     private void print_centered (Cairo.Context c, string text, double width, double height)
@@ -509,7 +508,7 @@ public class SudokuView : AspectFrame
 
         drawing = new DrawingArea ();
         drawing.visible = false;
-        drawing.draw.connect (draw_board);
+        drawing.set_draw_func (draw_board);
 
         if (grid != null)
             overlay.remove (grid);
@@ -623,7 +622,7 @@ public class SudokuView : AspectFrame
         }
     }
 
-    private bool draw_board (Cairo.Context c)
+    private inline void draw_board (DrawingArea _drawing, Cairo.Context c, int new_width, int new_height)
     {
         if (game.paused)
         {
@@ -643,8 +642,6 @@ public class SudokuView : AspectFrame
             c.set_source_rgb (1, 1, 1);
             c.show_text (text);
         }
-
-        return false;
     }
 
     public void clear ()


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