diff --git a/src/widgets/widget_definitions.rs b/src/widgets/widget_definitions.rs index a33a9c0..c1f629c 100644 --- a/src/widgets/widget_definitions.rs +++ b/src/widgets/widget_definitions.rs @@ -13,6 +13,7 @@ pub(super) fn widget_to_gtk_widget(bargs: &mut BuilderArgs) -> Result build_gtk_box(bargs)?.upcast(), "scale" => build_gtk_scale(bargs)?.upcast(), + "progress" => build_gtk_progress(bargs)?.upcast(), "image" => build_gtk_image(bargs)?.upcast(), "button" => build_gtk_button(bargs)?.upcast(), "label" => build_gtk_label(bargs)?.upcast(), @@ -259,6 +260,23 @@ fn build_gtk_scale(bargs: &mut BuilderArgs) -> Result { Ok(gtk_widget) } +/// @widget progress +/// @desc A progress bar +fn build_gtk_progress(bargs: &mut BuilderArgs) -> Result { + let gtk_widget = gtk::ProgressBar::new(); + resolve_block!(bargs, gtk_widget, { + // @prop flipped - flip the direction + prop(flipped: as_bool) { gtk_widget.set_inverted(flipped) }, + + // @prop value - value of the progress bar (between 0-100) + prop(value: as_f64) { gtk_widget.set_fraction(value / 100f64) }, + + // @prop orientation - orientation of the progress bar. possible values: $orientation + prop(orientation: as_string) { gtk_widget.set_orientation(parse_orientation(&orientation)?) }, + }); + Ok(gtk_widget) +} + /// @widget input /// @desc An input field. For this to be useful, set `focusable="true"` on the window. fn build_gtk_input(bargs: &mut BuilderArgs) -> Result {