[five-or-more/arnaudb/wip/gtk4: 60/80] Adapt to DrawingArea API.




commit 01104b013ad1ba63408b04b130e8864791a8efa9
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Fri Mar 13 10:16:00 2020 +0100

    Adapt to DrawingArea API.

 src/next-pieces-widget.vala |  8 ++++----
 src/view.vala               | 17 +++++------------
 2 files changed, 9 insertions(+), 16 deletions(-)
---
diff --git a/src/next-pieces-widget.vala b/src/next-pieces-widget.vala
index b891676..4b40349 100644
--- a/src/next-pieces-widget.vala
+++ b/src/next-pieces-widget.vala
@@ -36,6 +36,8 @@ private class NextPiecesWidget : Gtk.DrawingArea
         this.game = game;
         this.theme = theme;
 
+        set_draw_func (draw);
+
         set_queue_size ();
         settings.changed[FiveOrMoreApp.KEY_SIZE].connect (() => {
             set_queue_size ();
@@ -59,10 +61,10 @@ private class NextPiecesWidget : Gtk.DrawingArea
         queue_draw ();
     }
 
-    protected override bool draw (Cairo.Context cr)
+    private void draw (Gtk.DrawingArea _this, Cairo.Context cr, int new_width, int new_height)
     {
         if (theme == null)
-            return false;
+            return;
 
         if (widget_height == -1)
         {
@@ -86,7 +88,5 @@ private class NextPiecesWidget : Gtk.DrawingArea
         }
 
         cr.stroke ();
-
-        return true;
     }
 }
diff --git a/src/view.vala b/src/view.vala
index 379a727..f40af7d 100644
--- a/src/view.vala
+++ b/src/view.vala
@@ -86,6 +86,7 @@ private class View : DrawingArea
 
         init_keyboard ();
         init_mouse ();
+        set_draw_func (draw);
 
         cs = get_style_context ();
         provider = new CssProvider ();
@@ -331,14 +332,6 @@ private class View : DrawingArea
         board_rectangle.height = piece_size * game.n_rows;
     }
 
-    protected override bool configure_event (Gdk.EventConfigure event)
-    {
-        update_sizes (event.width, event.height);
-        queue_draw ();
-
-        return true;
-    }
-
     private void fill_background (Cairo.Context cr)
     {
         cs.render_background (cr, board_rectangle.x, board_rectangle.y, board_rectangle.width, 
board_rectangle.height);
@@ -422,17 +415,17 @@ private class View : DrawingArea
         }
     }
 
-    protected override bool draw (Cairo.Context cr)
+    private inline void draw (Gtk.DrawingArea _this, Cairo.Context cr, int new_width, int new_height)
     {
         if (theme == null)
-            return false;
+            return;
+
+        update_sizes (new_width, new_height);
 
         fill_background (cr);
         draw_gridlines (cr);
         draw_shapes (cr);
         draw_cursor_box (cr);
         draw_path (cr);
-
-        return true;
     }
 }


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