From bf6024b8aae26ded4b06c5cd381254870dc210d3 Mon Sep 17 00:00:00 2001 From: Bruce Cowan <bruce@bcowan.me.uk> Date: Sun, 13 Oct 2024 20:38:39 +0100 Subject: [PATCH] Don't look up colours --- src/rugby-possibility-widget.c | 40 +++++++++++++++------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/src/rugby-possibility-widget.c b/src/rugby-possibility-widget.c index cd6b8ae..3935647 100644 --- a/src/rugby-possibility-widget.c +++ b/src/rugby-possibility-widget.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2018-2022 Bruce Cowan <bruce@bcowan.me.uk> + * SPDX-FileCopyrightText: 2018-2024 Bruce Cowan <bruce@bcowan.me.uk> * * SPDX-License-Identifier: GPL-3.0-or-later */ @@ -77,8 +77,7 @@ rugby_possibility_widget_set_property (GObject *object, } static void -render_bar (GtkWidget *widget, - GtkSnapshot *snapshot, +render_bar (GtkSnapshot *snapshot, float x, float w, float h, @@ -97,20 +96,20 @@ render_bar (GtkWidget *widget, &area); gtk_snapshot_pop (snapshot); - G_GNUC_BEGIN_IGNORE_DEPRECATIONS - GdkRGBA border_colour; - - GtkStyleContext *ctx = gtk_widget_get_style_context (widget); - gtk_style_context_lookup_color (ctx, "card_fg_color", &border_colour); - G_GNUC_END_IGNORE_DEPRECATIONS + GdkRGBA border; + AdwStyleManager *manager = adw_style_manager_get_default (); + if (adw_style_manager_get_dark (manager)) + gdk_rgba_parse (&border, "white"); + else + gdk_rgba_parse (&border, "black"); gtk_snapshot_append_border (snapshot, &rounded, (float[]) { 2.0, 2.0, 2.0, 2.0 }, - (GdkRGBA[]) { border_colour, - border_colour, - border_colour, - border_colour }); + (GdkRGBA[]) { border, + border, + border, + border }); } static void @@ -135,16 +134,14 @@ rugby_possibility_widget_snapshot (GtkWidget *widget, NULL); int score = tries * try_points + utries * utry_points + kicks * kick_points; - G_GNUC_BEGIN_IGNORE_DEPRECATIONS - GtkStyleContext *ctx = gtk_widget_get_style_context (widget); GdkRGBA rgba; // Tries float w = width / (score / (float) try_points); for (int i = 0; i < tries; i++) { - gtk_style_context_lookup_color (ctx, "green_3", &rgba); - render_bar (widget, snapshot, x, w, height, rgba); + gdk_rgba_parse (&rgba, "#33d17a"); // Green 3 + render_bar (snapshot, x, w, height, rgba); x += w; } @@ -152,8 +149,8 @@ rugby_possibility_widget_snapshot (GtkWidget *widget, w = width / (score / (float) utry_points); for (int i = 0; i < utries; i++) { - gtk_style_context_lookup_color (ctx, "red_3", &rgba); - render_bar (widget, snapshot, x, w, height, rgba); + gdk_rgba_parse (&rgba, "#e01b24"); // Red 3 + render_bar (snapshot, x, w, height, rgba); x += w; } @@ -161,11 +158,10 @@ rugby_possibility_widget_snapshot (GtkWidget *widget, w = width / (score / (float) kick_points); for (int i = 0; i < kicks; i++) { - gtk_style_context_lookup_color (ctx, "yellow_3", &rgba); - render_bar (widget, snapshot, x, w, height, rgba); + gdk_rgba_parse (&rgba, "#f6d32d"); // Yellow 3 + render_bar (snapshot, x, w, height, rgba); x += w; } - G_GNUC_END_IGNORE_DEPRECATIONS } static void -- GitLab