[gnome-games/wip/exalm/gtk4: 33/42] 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: 33/42] ui: Stop using 'draw' signal for GdkDrawingArea
- Date: Wed, 12 Sep 2018 11:54:49 +0000 (UTC)
commit 779f57de562d8c0353cc52f94496c325277ff842
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 | 11 ++++-------
2 files changed, 11 insertions(+), 14 deletions(-)
---
diff --git a/src/ui/game-thumbnail.vala b/src/ui/game-thumbnail.vala
index cb71c83e..3a5ba109 100644
--- a/src/ui/game-thumbnail.vala
+++ b/src/ui/game-thumbnail.vala
@@ -71,22 +71,24 @@ private class Games.GameThumbnail: Gtk.DrawingArea {
set_css_name ("gamesgamethumbnail");
}
- 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;
@@ -98,8 +100,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 88cfb187..e8f9692a 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 {
@@ -40,16 +41,14 @@ 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);
var color_context = create_similar_context (context, x, y, scale);
color_gamepad (context, color_context);
var highlight_context = create_similar_context (context, x, y, scale);
highlight_gamepad (context, highlight_context);
-
- return false;
}
private void color_gamepad (Cairo.Context gamepad_context, Cairo.Context color_context) {
@@ -88,9 +87,7 @@ private class Games.GamepadView : Gtk.DrawingArea {
return similar_context;
}
- 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) {
double allocation_ratio = w / h;
double image_ratio = (double) handle.width / handle.height;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]