diff options
author | Jörg Frings-Fürst <debian@jff.email> | 2022-03-19 18:05:09 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff.email> | 2022-03-19 18:05:09 +0100 |
commit | e2af6e905a98b8b90b0504bc8f245733196dd808 (patch) | |
tree | ed6425480e22209291077ee018858e2a7c9e26f9 /src/page-icon.vala | |
parent | 14afa21f4a428f9a6a5788dc1fb8a3507a42d02f (diff) | |
parent | 8ac2508eb094459c062d0c31b6367da393b4fa6e (diff) |
Update upstream source from tag 'upstream/42.0'
Update to upstream version '42.0'
with Debian dir baa60a251498352959c048578d8f76023260a87e
Diffstat (limited to 'src/page-icon.vala')
-rw-r--r-- | src/page-icon.vala | 68 |
1 files changed, 55 insertions, 13 deletions
diff --git a/src/page-icon.vala b/src/page-icon.vala index 793ca5b..f1a25ea 100644 --- a/src/page-icon.vala +++ b/src/page-icon.vala @@ -12,18 +12,14 @@ public class PageIcon : Gtk.DrawingArea { - private string text; - private double r; - private double g; - private double b; + private char side; + private int position; private const int MINIMUM_WIDTH = 20; - public PageIcon (string text, double r = 1.0, double g = 1.0, double b = 1.0) + public PageIcon (char side, int position) { - this.text = text; - this.r = r; - this.g = g; - this.b = b; + this.side = side; + this.position = position; } public override void get_preferred_width (out int minimum_width, out int natural_width) @@ -57,15 +53,61 @@ public class PageIcon : Gtk.DrawingArea c.translate ((get_allocated_width () - w) / 2, (get_allocated_height () - h) / 2); - c.rectangle (0.5, 0.5, w - 1, h - 1); + bool dark = Hdy.StyleManager.get_default ().dark; + bool hc = Hdy.StyleManager.get_default ().high_contrast; + + if (dark && !hc) + c.rectangle (1, 1, w - 2, h - 2); + else + c.rectangle (0, 0, w, h); + + Gdk.RGBA rgba = {}; + + switch (side) + { + case 'F': + /* Purple 2 */ + rgba.parse ("#c061cb"); + break; + case 'B': + /* Orange 3 */ + rgba.parse ("#ff7800"); + break; + default: + /* Yellow 3 to Red 2 */ + Gdk.RGBA start = {}, end = {}; + start.parse ("#f6d32d"); + end.parse ("#ed333b"); + + double progress = position / 5.0; + rgba.red = start.red + (end.red - start.red) * progress; + rgba.green = start.green + (end.green - start.green) * progress; + rgba.blue = start.blue + (end.blue - start.blue) * progress; + break; + } - c.set_source_rgb (r, g, b); - c.fill_preserve (); + rgba.alpha = 0.3; + + Gdk.cairo_set_source_rgba (c, rgba); + c.fill (); c.set_line_width (1.0); - c.set_source_rgb (0.0, 0.0, 0.0); + if (hc && dark) + c.set_source_rgba (1, 1, 1, 0.5); + else if (hc) + c.set_source_rgba (0, 0, 0, 0.5); + else + c.set_source_rgba (0, 0, 0, 0.15); + + c.rectangle (0.5, 0.5, w - 1, h - 1); c.stroke (); + if (dark) + c.set_source_rgb (1, 1, 1); + else + c.set_source_rgb (0, 0, 0); + + var text = @"$(position + 1)"; Cairo.TextExtents extents; c.text_extents (text, out extents); c.translate ((w - extents.width) * 0.5 - 0.5, (h + extents.height) * 0.5 - 0.5); |