From 867cd556b027272989d8ad83d930f4b8de792577 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Wed, 28 Aug 2024 16:19:27 -0700 Subject: [PATCH] GradeLabel: cleanup, gtk4 prep --- data/Application.css | 9 ++++++++- src/GradeLabel.vala | 29 +++++++++++++++-------------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/data/Application.css b/data/Application.css index 5d3d5e2..e059e30 100644 --- a/data/Application.css +++ b/data/Application.css @@ -17,11 +17,18 @@ * Boston, MA 02110-1301 USA */ -.grade { +grade { color: #fff; background-color: alpha(#333, 0.9); border-radius: 50%; box-shadow: 0 1px shade(@colorBackground, 1.15); + min-height: 76px; + min-width: 76px; +} + +grade label { + font-weight: bold; + margin-top: 20px; } .results { diff --git a/src/GradeLabel.vala b/src/GradeLabel.vala index ed92f89..1532e7a 100644 --- a/src/GradeLabel.vala +++ b/src/GradeLabel.vala @@ -3,16 +3,16 @@ * SPDX-FileCopyrightText: 2017-2024 Danielle Foré (https://github.com/danirabbit) */ -public class GradeLabel : Gtk.Grid { - private Gtk.Image icon; +public class GradeLabel : Gtk.Box { + private Gtk.Image image; public string level { get; construct; } public bool pass { set { if (value) { - icon.icon_name = "object-select-symbolic"; + image.icon_name = "object-select-symbolic"; } else { - icon.icon_name = "window-close-symbolic"; + image.icon_name = "window-close-symbolic"; } } } @@ -27,19 +27,20 @@ public class GradeLabel : Gtk.Grid { ); } + class construct { + set_css_name ("grade"); + } + construct { - var level = new Gtk.Label ("%s".printf (level)); - level.margin_top = 20; - level.width_request = 76; - level.use_markup = true; + var level = new Gtk.Label ("%s".printf (level)) { + use_markup = true + }; + level.get_style_context ().add_class (Granite.STYLE_CLASS_SMALL_LABEL); - icon = new Gtk.Image (); - icon.icon_size = Gtk.IconSize.LARGE_TOOLBAR; - icon.icon_name = "object-select-symbolic"; + image = new Gtk.Image.from_icon_name ("object-select-symbolic", LARGE_TOOLBAR); - orientation = Gtk.Orientation.VERTICAL; - get_style_context ().add_class ("grade"); + orientation = VERTICAL; add (level); - add (icon); + add (image); } }