From 5b4cc3e7a8055afb758421f4a114ef4032806e39 Mon Sep 17 00:00:00 2001 From: ipsvn <80017804+ipsvn@users.noreply.github.com> Date: Sun, 16 Feb 2025 15:46:18 +0000 Subject: [PATCH] Add value-pos to scale widget (#1285) * Add value-pos to gtk scale * add possible values to value-pos * add value-pos change to CHANGELOG.md --- CHANGELOG.md | 1 + crates/eww/src/widgets/widget_definitions.rs | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44b261e..d94afd6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,7 @@ All notable changes to eww will be listed here, starting at changes since versio - Support empty string for safe access operator (By: ModProg) - Add `log` function calls to simplexpr (By: topongo) - Add `:lines` and `:wrap-mode` properties to label widget (By: vaporii) +- Add `value-pos` to scale widget (By: ipsvn) ## [0.6.0] (21.04.2024) diff --git a/crates/eww/src/widgets/widget_definitions.rs b/crates/eww/src/widgets/widget_definitions.rs index c5158ea..226406b 100644 --- a/crates/eww/src/widgets/widget_definitions.rs +++ b/crates/eww/src/widgets/widget_definitions.rs @@ -459,6 +459,9 @@ fn build_gtk_scale(bargs: &mut BuilderArgs) -> Result { // @prop draw-value - draw the value of the property prop(draw_value: as_bool = false) { gtk_widget.set_draw_value(draw_value) }, + // @prop value-pos - position of the drawn value. possible values: $position + prop(value_pos: as_string) { gtk_widget.set_value_pos(parse_position_type(&value_pos)?) }, + // @prop round-digits - Sets the number of decimals to round the value to when it changes prop(round_digits: as_i32 = 0) { gtk_widget.set_round_digits(round_digits) } @@ -1381,6 +1384,16 @@ fn parse_justification(j: &str) -> Result { } } +/// @var position - "left", "right", "top", "bottom" +fn parse_position_type(g: &str) -> Result { + enum_parse! { "position", g, + "left" => gtk::PositionType::Left, + "right" => gtk::PositionType::Right, + "top" => gtk::PositionType::Top, + "bottom" => gtk::PositionType::Bottom, + } +} + /// @var gravity - "south", "east", "west", "north", "auto" fn parse_gravity(g: &str) -> Result { enum_parse! { "gravity", g,