[gnome-games/wip/exalm/gtk4: 16/26] 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: 16/26] ui: Stop using 'draw' signal for GdkDrawingArea
- Date: Fri, 19 Oct 2018 20:19:04 +0000 (UTC)
commit b8ef6243d2db24329b674c726866e6660a7d2c06
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 bd4c12a1..61added3 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 98a3817b..aa9833c2 100644
--- a/src/ui/gamepad-view.vala
+++ b/src/ui/gamepad-view.vala
@@ -9,6 +9,7 @@ private class Games.GamepadView : Gtk.DrawingArea {
handle = new Rsvg.Handle ();
configuration = { "", new GamepadInputPath[0] };
input_highlights = {};
+ set_draw_func (draw);
}
public void set_configuration (GamepadViewConfiguration configuration) throws Error {
@@ -43,17 +44,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) {
@@ -81,10 +80,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]