Skip to content

Commit

Permalink
Merge branch 'master' into string-truncation
Browse files Browse the repository at this point in the history
  • Loading branch information
Rayzeq committed Apr 7, 2024
2 parents 730b340 + ebe5f34 commit 9046fbf
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ All notable changes to eww will be listed here, starting at changes since versio

### Features
- Add `systray` widget (By: ralismark)
- Add `:checked` property to checkbox (By: levnikmyskin)

## [0.5.0] (17.02.2024)

### BREAKING CHANGES
- Remove `eww windows` command, replace with `eww active-windows` and `eww list-windows`

### Features
- Add `:icon` and `:icon-size` to the image widget (By: Adrian Perez de Castro)
- Add `get_env` function (By: RegenJacob)
- Add `:namespace` window option
- Default to building with x11 and wayland support simultaneously
Expand Down
23 changes: 21 additions & 2 deletions crates/eww/src/widgets/widget_definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,10 +345,12 @@ const WIDGET_NAME_CHECKBOX: &str = "checkbox";
fn build_gtk_checkbox(bargs: &mut BuilderArgs) -> Result<gtk::CheckButton> {
let gtk_widget = gtk::CheckButton::new();
def_widget!(bargs, _g, gtk_widget, {
// @prop checked - whether the checkbox is toggled or not when created
// @prop timeout - timeout of the command. Default: "200ms"
// @prop onchecked - action (command) to be executed when checked by the user
// @prop onunchecked - similar to onchecked but when the widget is unchecked
prop(timeout: as_duration = Duration::from_millis(200), onchecked: as_string = "", onunchecked: as_string = "") {
prop(checked: as_bool = false, timeout: as_duration = Duration::from_millis(200), onchecked: as_string = "", onunchecked: as_string = "") {
gtk_widget.set_active(checked);
connect_signal_handler!(gtk_widget, gtk_widget.connect_toggled(move |gtk_widget| {
run_command(timeout, if gtk_widget.is_active() { &onchecked } else { &onunchecked }, &[] as &[&str]);
}));
Expand Down Expand Up @@ -513,6 +515,18 @@ fn build_gtk_button(bargs: &mut BuilderArgs) -> Result<gtk::Button> {
Ok(gtk_widget)
}

/// @var icon-size - "menu", "small-toolbar", "toolbar", "large-toolbar", "button", "dnd", "dialog"
fn parse_icon_size(o: &str) -> Result<gtk::IconSize> {
enum_parse! { "icon-size", o,
"menu" => gtk::IconSize::Menu,
"small-toolbar" | "toolbar" => gtk::IconSize::SmallToolbar,
"large-toolbar" => gtk::IconSize::LargeToolbar,
"button" => gtk::IconSize::Button,
"dnd" => gtk::IconSize::Dnd,
"dialog" => gtk::IconSize::Dialog,
}
}

const WIDGET_NAME_IMAGE: &str = "image";
/// @widget image
/// @desc A widget displaying an image
Expand All @@ -530,7 +544,12 @@ fn build_gtk_image(bargs: &mut BuilderArgs) -> Result<gtk::Image> {
let pixbuf = gtk::gdk_pixbuf::Pixbuf::from_file_at_size(std::path::PathBuf::from(path), image_width, image_height)?;
gtk_widget.set_from_pixbuf(Some(&pixbuf));
}
}
},
// @prop icon - name of a theme icon
// @prop icon-size - size of the theme icon
prop(icon: as_string, icon_size: as_string = "button") {
gtk_widget.set_from_icon_name(Some(&icon), parse_icon_size(&icon_size)?);
},
});
Ok(gtk_widget)
}
Expand Down
2 changes: 1 addition & 1 deletion docs/src/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ have:
Here we have two arguments, `arg1` and `arg2` (an optional parameter).

Once we have these parameters, when opening a new window, we must specify them
(unless they are required, like `arg2`), but how? Well, we use the `--arg`
(unless they are optional, like `arg2`), but how? Well, we use the `--arg`
option when running the `open` command:

```bash
Expand Down

0 comments on commit 9046fbf

Please sign in to comment.