Fix calendar months being indexed by 0 (fixes #544)

This commit is contained in:
elkowar 2022-09-03 10:16:01 +02:00
parent 44a8331417
commit bf532e63cc
No known key found for this signature in database
GPG key ID: E321AD71B1D1F27F
2 changed files with 17 additions and 2 deletions

View file

@ -5,6 +5,9 @@ All notable changes to eww will be listed here, starting at changes since versio
## [Unreleased] ## [Unreleased]
### BREAKING CHANGES
- Change `calendar`-widget to index months starting at 1 rather than indexed from 0
### Features ### Features
- Add support for output names in X11 to select `:monitor`. - Add support for output names in X11 to select `:monitor`.

View file

@ -904,9 +904,21 @@ fn build_gtk_calendar(bargs: &mut BuilderArgs) -> Result<gtk::Calendar> {
let gtk_widget = gtk::Calendar::new(); let gtk_widget = gtk::Calendar::new();
def_widget!(bargs, _g, gtk_widget, { def_widget!(bargs, _g, gtk_widget, {
// @prop day - the selected day // @prop day - the selected day
prop(day: as_f64) { gtk_widget.set_day(day as i32) }, prop(day: as_f64) {
if day < 1f64 || day > 31f64 {
log::warn!("Calendar day is not a number between 1 and 31");
} else {
gtk_widget.set_day(day as i32)
}
},
// @prop month - the selected month // @prop month - the selected month
prop(month: as_f64) { gtk_widget.set_month(month as i32) }, prop(month: as_f64) {
if month < 1f64 || month > 12f64 {
log::warn!("Calendar month is not a number between 1 and 12");
} else {
gtk_widget.set_month(month as i32 - 1)
}
},
// @prop year - the selected year // @prop year - the selected year
prop(year: as_f64) { gtk_widget.set_year(year as i32) }, prop(year: as_f64) { gtk_widget.set_year(year as i32) },
// @prop show-details - show details // @prop show-details - show details