[gnome-games/wip/exalm/gtk4: 16/28] ui: Stop using 'draw' signal for GdkDrawingArea



commit f976b215693b5fc50d265a15d8dd23e67bdcb278
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date:   Sun Jul 29 13:06:34 2018 +0500

    ui: Stop using 'draw' signal for GdkDrawingArea
    
    Use gtk_drawing_area_set_draw_func() instead.

 src/ui/game-thumbnail.vala | 14 +++++++-------
 src/ui/gamepad-view.vala   | 12 ++++--------
 2 files changed, 11 insertions(+), 15 deletions(-)
---
diff --git a/src/ui/game-thumbnail.vala b/src/ui/game-thumbnail.vala
index d5960fb9..62d15a9c 100644
--- a/src/ui/game-thumbnail.vala
+++ b/src/ui/game-thumbnail.vala
@@ -79,22 +79,24 @@ private class Games.GameThumbnail : Gtk.DrawingArea {
                minimum_height = natural_height = width;
        }
 
-       public override bool draw (Cairo.Context cr) {
+       construct {
+               set_draw_func (draw);
+       }
+
+       public void draw (Gtk.DrawingArea area, Cairo.Context cr, int width, int height) {
                var surface = get_surface ();
                var style = get_style_context ();
                var state = get_state_flags ();
-               var width = get_allocated_width ();
-               var height = get_allocated_height ();
 
                DrawingContext context = {
                        cr, surface, style, state, width, height
                };
 
                if (icon == null)
-                       return false;
+                       return;
 
                if (cover == null)
-                       return false;
+                       return;
 
                var drawn = false;
 
@@ -106,8 +108,6 @@ private class Games.GameThumbnail : Gtk.DrawingArea {
                // Draw the default thumbnail if no thumbnail have been drawn
                if (!drawn)
                        draw_default (context);
-
-               return true;
        }
 
        public bool draw_icon (DrawingContext context) {
diff --git a/src/ui/gamepad-view.vala b/src/ui/gamepad-view.vala
index 86494130..bdfe5749 100644
--- a/src/ui/gamepad-view.vala
+++ b/src/ui/gamepad-view.vala
@@ -41,6 +41,7 @@ private class Games.GamepadView : Gtk.DrawingArea {
                handle = new Rsvg.Handle ();
                configuration = { "", new GamepadInputPath[0] };
                input_highlights = {};
+               set_draw_func (draw);
        }
 
        public void reset () {
@@ -63,17 +64,15 @@ private class Games.GamepadView : Gtk.DrawingArea {
                return false;
        }
 
-       public override bool draw (Cairo.Context context) {
+       public void draw (Gtk.DrawingArea area, Cairo.Context context, int width, int height) {
                double x, y, scale;
-               calculate_image_dimensions (out x, out y, out scale);
+               calculate_image_dimensions (width, height, out x, out y, out scale);
 
                context.translate (x, y);
                context.scale (scale, scale);
 
                color_gamepad (context);
                highlight_gamepad (context);
-
-               return false;
        }
 
        private void color_gamepad (Cairo.Context context) {
@@ -101,10 +100,7 @@ private class Games.GamepadView : Gtk.DrawingArea {
                        }
        }
 
-       private void calculate_image_dimensions (out double x, out double y, out double scale) {
-               double w = get_allocated_width ();
-               double h = get_allocated_height ();
-
+       private void calculate_image_dimensions (double w, double h, out double x, out double y, out double 
scale) {
                Rsvg.Rectangle rect = {};
                if (!handle.get_geometry_sub (null, out rect, null))
                        assert_not_reached ();


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