Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add value-pos to scale widget #1285

Merged
merged 3 commits into from
Feb 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
13 changes: 13 additions & 0 deletions crates/eww/src/widgets/widget_definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,9 @@ fn build_gtk_scale(bargs: &mut BuilderArgs) -> Result<gtk::Scale> {
// @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) }

Expand Down Expand Up @@ -1381,6 +1384,16 @@ fn parse_justification(j: &str) -> Result<gtk::Justification> {
}
}

/// @var position - "left", "right", "top", "bottom"
fn parse_position_type(g: &str) -> Result<gtk::PositionType> {
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<gtk::pango::Gravity> {
enum_parse! { "gravity", g,
Expand Down
Loading