[gnome-games/wip/exalm/gtk4: 32/44] ui: Stop using 'draw' signal for GdkDrawingArea
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/gtk4: 32/44] ui: Stop using 'draw' signal for GdkDrawingArea
- Date: Mon, 25 Feb 2019 11:40:07 +0000 (UTC)
commit aa236f58ad3531b70575a1ed0903cb64af87bb92
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 9cba3a50..5785bdd5 100644
--- a/src/ui/gamepad-view.vala
+++ b/src/ui/gamepad-view.vala
@@ -33,6 +33,7 @@ private class Games.GamepadView : Gtk.DrawingArea {
handle = new Rsvg.Handle ();
configuration = { "", new GamepadInputPath[0] };
input_highlights = {};
+ set_draw_func (draw);
}
public void reset () {
@@ -55,17 +56,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) {
@@ -93,10 +92,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 (int w, int h, out double x, out double y, out double scale) {
scale = double.min (h / handle.height, w / handle.width);
x = (w - handle.width * scale) / 2;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]