Add :icon and :icon-size properties to the image widget
Add a new :icon property which allows using icons from the currently selected theme. For completeness, add :icon-size as well. As a nice extra, GTK automatically makes such images follow the selected icon theme.
This commit is contained in:
parent
e7f7046ddd
commit
5fdaa4e03f
2 changed files with 19 additions and 1 deletions
|
@ -18,6 +18,7 @@ All notable changes to eww will be listed here, starting at changes since versio
|
||||||
- Remove `eww windows` command, replace with `eww active-windows` and `eww list-windows`
|
- Remove `eww windows` command, replace with `eww active-windows` and `eww list-windows`
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
- Add `:icon` and `:icon-size` to the image widget (By: Adrian Perez de Castro)
|
||||||
- Add `get_env` function (By: RegenJacob)
|
- Add `get_env` function (By: RegenJacob)
|
||||||
- Add `:namespace` window option
|
- Add `:namespace` window option
|
||||||
- Default to building with x11 and wayland support simultaneously
|
- Default to building with x11 and wayland support simultaneously
|
||||||
|
|
|
@ -513,6 +513,18 @@ fn build_gtk_button(bargs: &mut BuilderArgs) -> Result<gtk::Button> {
|
||||||
Ok(gtk_widget)
|
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";
|
const WIDGET_NAME_IMAGE: &str = "image";
|
||||||
/// @widget image
|
/// @widget image
|
||||||
/// @desc A widget displaying an image
|
/// @desc A widget displaying an image
|
||||||
|
@ -530,7 +542,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)?;
|
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));
|
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)
|
Ok(gtk_widget)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue