[five-or-more/arnaudb/gtk3: 21/24] Revert "Adapt to DrawingArea API."




commit fe5b32ce67c188b65da4faa1a738c23b9fd57712
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Thu Oct 22 17:30:16 2020 +0200

    Revert "Adapt to DrawingArea API."
    
    This reverts commit 133d1f04586733ece48bc136b028f30ca135976a.

 src/next-pieces-widget.vala |  8 ++++----
 src/view.vala               | 17 ++++++++++++-----
 2 files changed, 16 insertions(+), 9 deletions(-)
---
diff --git a/src/next-pieces-widget.vala b/src/next-pieces-widget.vala
index 4b40349..b891676 100644
--- a/src/next-pieces-widget.vala
+++ b/src/next-pieces-widget.vala
@@ -36,8 +36,6 @@ 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 ();
@@ -61,10 +59,10 @@ private class NextPiecesWidget : Gtk.DrawingArea
         queue_draw ();
     }
 
-    private void draw (Gtk.DrawingArea _this, Cairo.Context cr, int new_width, int new_height)
+    protected override bool draw (Cairo.Context cr)
     {
         if (theme == null)
-            return;
+            return false;
 
         if (widget_height == -1)
         {
@@ -88,5 +86,7 @@ private class NextPiecesWidget : Gtk.DrawingArea
         }
 
         cr.stroke ();
+
+        return true;
     }
 }
diff --git a/src/view.vala b/src/view.vala
index f40af7d..379a727 100644
--- a/src/view.vala
+++ b/src/view.vala
@@ -86,7 +86,6 @@ private class View : DrawingArea
 
         init_keyboard ();
         init_mouse ();
-        set_draw_func (draw);
 
         cs = get_style_context ();
         provider = new CssProvider ();
@@ -332,6 +331,14 @@ 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);
@@ -415,17 +422,17 @@ private class View : DrawingArea
         }
     }
 
-    private inline void draw (Gtk.DrawingArea _this, Cairo.Context cr, int new_width, int new_height)
+    protected override bool draw (Cairo.Context cr)
     {
         if (theme == null)
-            return;
-
-        update_sizes (new_width, new_height);
+            return false;
 
         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]