calendar-monitor: Turn "completed" signal into a boolean property
And make GcalTimeline decrease the completed calendars counter when any GcalCalendarMonitor goes from complete to incomplete. Fixes https://gitlab.gnome.org/GNOME/gnome-calendar/-/issues/625
This commit is contained in:
committed by
Georges Basile Stavracas Neto
parent
41a3e0a853
commit
78cb11c64d
+11
-13
@@ -204,17 +204,6 @@ reset_completed_calendars (GcalTimeline *self)
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_COMPLETE]);
|
||||
}
|
||||
|
||||
static void
|
||||
increase_completed_calendars (GcalTimeline *self)
|
||||
{
|
||||
self->completed_calendars++;
|
||||
|
||||
g_assert (self->completed_calendars <= g_hash_table_size (self->calendars));
|
||||
|
||||
if (is_timeline_complete (self))
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_COMPLETE]);
|
||||
}
|
||||
|
||||
static void
|
||||
add_event_to_subscriber (GcalTimelineSubscriber *subscriber,
|
||||
GcalEvent *event)
|
||||
@@ -591,11 +580,20 @@ on_calendar_monitor_event_removed_cb (GcalCalendarMonitor *monitor,
|
||||
|
||||
static void
|
||||
on_calendar_monitor_completed_cb (GcalCalendarMonitor *monitor,
|
||||
GParamSpec *pspec,
|
||||
GcalTimeline *self)
|
||||
{
|
||||
GCAL_ENTRY;
|
||||
|
||||
increase_completed_calendars (self);
|
||||
if (gcal_calendar_monitor_is_complete (monitor))
|
||||
self->completed_calendars++;
|
||||
else
|
||||
self->completed_calendars--;
|
||||
|
||||
g_assert (self->completed_calendars <= g_hash_table_size (self->calendars));
|
||||
|
||||
if (is_timeline_complete (self))
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_COMPLETE]);
|
||||
|
||||
GCAL_EXIT;
|
||||
}
|
||||
@@ -953,7 +951,7 @@ gcal_timeline_add_calendar (GcalTimeline *self,
|
||||
g_signal_connect (monitor, "event-added", G_CALLBACK (on_calendar_monitor_event_added_cb), self);
|
||||
g_signal_connect (monitor, "event-updated", G_CALLBACK (on_calendar_monitor_event_updated_cb), self);
|
||||
g_signal_connect (monitor, "event-removed", G_CALLBACK (on_calendar_monitor_event_removed_cb), self);
|
||||
g_signal_connect (monitor, "completed", G_CALLBACK (on_calendar_monitor_completed_cb), self);
|
||||
g_signal_connect (monitor, "notify::complete", G_CALLBACK (on_calendar_monitor_completed_cb), self);
|
||||
g_hash_table_insert (self->calendars, calendar, g_object_ref (monitor));
|
||||
|
||||
if (self->range)
|
||||
|
||||
Reference in New Issue
Block a user