event-widget : Add/rework new event sort function
The overflow layout used to display "Other X events" text when there is no enough space to accomodate more events. But due to the way the events were sorted, some events are folded to 'Other events' popover even when the cell has enough space to accomodate the event(s) or when it is not required to be folded. We rework how the events will be sorted. First, the events are sorted by their start dates(starting with the closest). But if two or more events have same start date then they are sorted according to their lengths. And still if they have same start date and length then they are sorted according to their modified times(the closest first). https://bugzilla.gnome.org/show_bug.cgi?id=778478
This commit is contained in:
committed by
Georges Basile Stavracas Neto
parent
9033d987a3
commit
0a02a1269b
@@ -1239,3 +1239,31 @@ gcal_event_widget_compare_by_start_date (GcalEventWidget *widget1,
|
||||
{
|
||||
return g_date_time_compare (widget1->dt_start, widget2->dt_start);
|
||||
}
|
||||
|
||||
gint
|
||||
gcal_event_widget_sort_events (GcalEventWidget *widget1,
|
||||
GcalEventWidget *widget2)
|
||||
{
|
||||
g_autoptr (GDateTime) dt_time1, dt_time2;
|
||||
icaltimetype *ical_dt;
|
||||
gint diff;
|
||||
|
||||
dt_time1 = dt_time2 = NULL;
|
||||
diff = gcal_event_widget_compare_by_start_date (widget1, widget2);
|
||||
|
||||
if (diff != 0)
|
||||
return diff;
|
||||
|
||||
diff = gcal_event_widget_compare_by_length (widget1, widget2);
|
||||
|
||||
if (diff != 0)
|
||||
return diff;
|
||||
|
||||
e_cal_component_get_last_modified (gcal_event_get_component (widget1->event), &ical_dt);
|
||||
dt_time1 = icaltime_to_datetime (ical_dt);
|
||||
|
||||
e_cal_component_get_last_modified (gcal_event_get_component (widget2->event), &ical_dt);
|
||||
dt_time2 = icaltime_to_datetime (ical_dt);
|
||||
|
||||
return g_date_time_compare (dt_time2, dt_time1);
|
||||
}
|
||||
|
||||
@@ -70,6 +70,9 @@ gint gcal_event_widget_compare_by_length (GcalEventWidget *
|
||||
gint gcal_event_widget_compare_by_start_date (GcalEventWidget *widget1,
|
||||
GcalEventWidget *widget2);
|
||||
|
||||
gint gcal_event_widget_sort_events (GcalEventWidget *widget1,
|
||||
GcalEventWidget *widget2);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GCAL_EVENT_WIDGET_H__ */
|
||||
|
||||
@@ -240,7 +240,7 @@ gcal_subscriber_view_add (GtkContainer *container,
|
||||
if (gcal_event_is_multiday (event))
|
||||
{
|
||||
priv->multi_cell_children = g_list_insert_sorted (priv->multi_cell_children, widget,
|
||||
(GCompareFunc) gcal_event_widget_compare_by_length);
|
||||
(GCompareFunc) gcal_event_widget_sort_events);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user