[gnome-sudoku/arnaudb/wip/gtk4: 13/26] Adapt to DrawingArea API.



commit 90f999b3d152b3935a9091eea2ec6f193a653a75
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 0377dfa..f166bdf 100644
--- a/src/sudoku-view.vala
+++ b/src/sudoku-view.vala
@@ -103,6 +103,7 @@ private class SudokuCellView : DrawingArea
 
         init_mouse ();
         init_keyboard ();
+        set_draw_func (draw);
 
         value = game.board [row, col];
 
@@ -344,7 +345,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)
@@ -367,7 +368,7 @@ private class SudokuCellView : DrawingArea
             c.set_source_rgb (0.0, 0.0, 0.0);
 
         if (game.paused)
-            return false;
+            return;
 
         if (value != 0)
         {
@@ -377,11 +378,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)
@@ -428,8 +429,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)
@@ -500,7 +499,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);
@@ -602,7 +601,7 @@ public class SudokuView : AspectFrame
         overlay.add (grid);
     }
 
-    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)
         {
@@ -622,8 +621,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]