Skip to content

Commit

Permalink
Fix levelbar color
Browse files Browse the repository at this point in the history
  • Loading branch information
danirabbit committed Oct 18, 2023
1 parent 6e809b4 commit 6c313e8
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Widgets/InkLevel.vala
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class Printers.InkLevel : Gtk.Widget {
public unowned Printer printer { get; construct; }
private const string STYLE_CLASS =
"""
block.filled {
levelbar.%s block.filled {
background-color: #%s;
}
""";
Expand Down Expand Up @@ -62,7 +62,8 @@ public class Printers.InkLevel : Gtk.Widget {
var ink_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 3);

for (int i = 1; i < colors_codes.length; i++) {
var css_color = STYLE_CLASS.printf (colors_codes[i]);
var style_class = color.name + "%i".printf (i);
var css_color = STYLE_CLASS.printf (style_class, colors_codes[i]);

var level = new Gtk.LevelBar.for_interval (color.level_min, color.level_max) {
height_request = 64,
Expand All @@ -72,11 +73,12 @@ public class Printers.InkLevel : Gtk.Widget {
orientation = Gtk.Orientation.VERTICAL,
value = color.level
};
level.add_css_class (style_class);

var provider = new Gtk.CssProvider ();
try {
provider.load_from_data (css_color.data);
level.get_style_context ().add_provider (provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
Gtk.StyleContext.add_provider_for_display (Gdk.Display.get_default (), provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
} catch (Error e) {
warning ("Could not create CSS Provider: %s\nStylesheet:\n%s", e.message, css_color);
}
Expand Down

0 comments on commit 6c313e8

Please sign in to comment.