mirror of
https://github.com/elkowar/eww.git
synced 2024-10-05 15:40:12 +03:00
add gravity
property to label
widget (#949)
This commit is contained in:
parent
e95d3af963
commit
8c977892d4
@ -12,6 +12,7 @@ All notable changes to eww will be listed here, starting at changes since versio
|
||||
- Add `:namespace` window option
|
||||
- Default to building with x11 and wayland support simultaneously
|
||||
- Add `truncate-left` property on `label` widgets (By: kawaki-san)
|
||||
- Add `gravity` property on `label` widgets (By: Elekrisk)
|
||||
- Add support for safe access (`?.`) in simplexpr (By: oldwomanjosiah)
|
||||
- Allow floating-point numbers in percentages for window-geometry
|
||||
- Add support for safe access with index (`?.[n]`) (By: ModProg)
|
||||
|
@ -861,6 +861,10 @@ fn build_gtk_label(bargs: &mut BuilderArgs) -> Result<gtk::Label> {
|
||||
prop(wrap: as_bool) { gtk_widget.set_line_wrap(wrap) },
|
||||
// @prop angle - the angle of rotation for the label (between 0 - 360)
|
||||
prop(angle: as_f64 = 0) { gtk_widget.set_angle(angle) },
|
||||
// @prop gravity - the gravity of the string (south, east, west, north, auto). Text will want to face the direction of gravity.
|
||||
prop(gravity: as_string = "south") {
|
||||
gtk_widget.pango_context().set_base_gravity(parse_gravity(&gravity)?);
|
||||
},
|
||||
// @prop xalign - the alignment of the label text on the x axis (between 0 - 1, 0 -> left, 0.5 -> center, 1 -> right)
|
||||
prop(xalign: as_f64 = 0.5) { gtk_widget.set_xalign(xalign as f32) },
|
||||
// @prop yalign - the alignment of the label text on the y axis (between 0 - 1, 0 -> bottom, 0.5 -> center, 1 -> top)
|
||||
@ -1148,6 +1152,17 @@ fn parse_justification(j: &str) -> Result<gtk::Justification> {
|
||||
}
|
||||
}
|
||||
|
||||
/// @var gravity - "south", "east", "west", "north", "auto"
|
||||
fn parse_gravity(g: &str) -> Result<gtk::pango::Gravity> {
|
||||
enum_parse! { "gravity", g,
|
||||
"south" => gtk::pango::Gravity::South,
|
||||
"east" => gtk::pango::Gravity::East,
|
||||
"west" => gtk::pango::Gravity::West,
|
||||
"north" => gtk::pango::Gravity::North,
|
||||
"auto" => gtk::pango::Gravity::Auto,
|
||||
}
|
||||
}
|
||||
|
||||
/// Connect a function to the first map event of a widget. After that first map, the handler will get disconnected.
|
||||
fn connect_first_map<W: IsA<gtk::Widget>, F: Fn(&W) + 'static>(widget: &W, func: F) {
|
||||
let signal_handler_id = std::rc::Rc::new(std::cell::RefCell::new(None));
|
||||
|
Loading…
Reference in New Issue
Block a user