Support glib 2.73.1+: Avoid property notification during object construction
bobby285271 opened this issue · 1 comments
What Happened?
In elementary/calendar#756 (comment), we noticed that wingpanel-indicator-datetime does not show any date numbers, after making a minimal reproducer in https://github.com/bobby285271/e-calendar-issue and bisecting glib commits (thanks @jtojnar
!), we noticed that this glib commit intentionally changes the behavior, which is part of glib 2.73.1+. It will be nice to adjust the code here so the indicator can still work nicely with glib 2.73.1+.
The affected code is at
wingpanel-indicator-datetime/src/Widgets/calendar/GridDay.vala
Lines 82 to 85 in 2bd9445
The workaround is
diff --git a/src/Widgets/calendar/Grid.vala b/src/Widgets/calendar/Grid.vala
index e440306..21a631a 100644
--- a/src/Widgets/calendar/Grid.vala
+++ b/src/Widgets/calendar/Grid.vala
@@ -229,7 +229,7 @@ namespace DateTime.Widgets {
day.sensitive_container (false);
}
- day.date = new_date;
+ day.update_date (new_date);
return day;
}
diff --git a/src/Widgets/calendar/GridDay.vala b/src/Widgets/calendar/GridDay.vala
index 8602875..7bd6140 100644
--- a/src/Widgets/calendar/GridDay.vala
+++ b/src/Widgets/calendar/GridDay.vala
@@ -79,10 +79,6 @@ public class DateTime.Widgets.GridDay : Gtk.EventBox {
button_press_event.connect (on_button_press);
key_press_event.connect (on_key_press);
- notify["date"].connect (() => {
- label.label = date.get_day_of_month ().to_string ();
- });
-
component_dots = new Gee.HashMap<string, Gtk.Widget> ();
}
@@ -124,6 +120,11 @@ public class DateTime.Widgets.GridDay : Gtk.EventBox {
}
}
+ public void update_date (GLib.DateTime date) {
+ this.date = date;
+ label.label = date.get_day_of_month ().to_string ();
+ }
+
public void set_selected (bool selected) {
if (selected) {
set_state_flags (Gtk.StateFlags.SELECTED, true);
Steps to Reproduce
- Build with glib 2.73.1+
- Notice the indicator does not show any date numbers
Thanks for the patch @bobby285271. I’ll try to build an MR around that after checking that it effectively fix the thing on my side too.