[five-or-more/arnaudb/gtk3: 16/24] Revert "Fix background stuff."
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [five-or-more/arnaudb/gtk3: 16/24] Revert "Fix background stuff."
- Date: Thu, 22 Oct 2020 15:32:55 +0000 (UTC)
commit 6bbdf03c765f43fe7c5a85d5db6f288c3c0e3805
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Thu Oct 22 17:29:06 2020 +0200
Revert "Fix background stuff."
This reverts commit 8082e192a224e826194e094db027322584c44607.
src/view.vala | 28 ++++++++++++++++------------
1 file changed, 16 insertions(+), 12 deletions(-)
---
diff --git a/src/view.vala b/src/view.vala
index ef9c203..a5ff89d 100644
--- a/src/view.vala
+++ b/src/view.vala
@@ -53,7 +53,6 @@ private class View : DrawingArea
private EventControllerKey key_controller; // for keeping in memory
private GestureClick click_controller; // for keeping in memory
- private Gdk.RGBA background_color_rgba;
internal const string default_background_color = "rgb(117,144,174)";
private string _background_color = default_background_color;
internal string background_color
@@ -61,11 +60,21 @@ private class View : DrawingArea
internal get { return _background_color; }
internal set
{
- if (!background_color_rgba.parse (value))
- if (!background_color_rgba.parse (default_background_color))
- assert_not_reached ();
- _background_color = background_color_rgba.to_string ();
+ Gdk.RGBA color = Gdk.RGBA ();
+ if (!color.parse (value))
+ _background_color = default_background_color;
+ else
+ _background_color = color.to_string ();
+ try
+ {
+ provider.load_from_data (".game-view { background-color: %s; }".printf (_background_color));
+ }
+ catch (Error e)
+ {
+ warning ("Failed to load CSS data to provider");
+ return;
+ }
queue_draw ();
}
}
@@ -319,18 +328,13 @@ private class View : DrawingArea
private void update_sizes (int width, int height)
{
piece_size = (width - 1) / game.n_cols;
- board_rectangle.width = piece_size * game.n_cols;
+ board_rectangle.width = piece_size * game.n_cols;
board_rectangle.height = piece_size * game.n_rows;
}
private void fill_background (Cairo.Context cr)
{
- Gdk.cairo_set_source_rgba (cr, background_color_rgba);
- cr.rectangle (/* x and y */ board_rectangle.x + 1.0,
- board_rectangle.y + 1.0,
- /* w and h */ board_rectangle.width,
- board_rectangle.height);
- cr.fill ();
+ cs.render_background (cr, board_rectangle.x, board_rectangle.y, board_rectangle.width,
board_rectangle.height);
}
private void draw_gridlines (Cairo.Context cr)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]