year-view: move comparing function from gcal-event-widget.c
The compare_for_single_day() method is reproducing the same functionality from gcal_event_compare(), and the only consumer is the Year View. So, for now, simplify the comparing function and put it in year view file. Also, this commit vastly improves and documents the year view's algorithm to add events to the sidebar list.
This commit is contained in:
@@ -865,54 +865,3 @@ gcal_event_widget_compare_by_start_date (GcalEventWidget *widget1,
|
||||
{
|
||||
return g_date_time_compare (widget1->dt_start, widget2->dt_start);
|
||||
}
|
||||
|
||||
/**
|
||||
* gcal_event_widget_compare_for_single_day:
|
||||
* @widget1:
|
||||
* @widget2:
|
||||
*
|
||||
* Compare widgets by putting those that span over a day before the rest, and between those
|
||||
* who last less than a day by its start time/date
|
||||
*
|
||||
* Returns:
|
||||
**/
|
||||
gint
|
||||
gcal_event_widget_compare_for_single_day (GcalEventWidget *widget1,
|
||||
GcalEventWidget *widget2)
|
||||
{
|
||||
if (gcal_event_is_multiday (widget1->event) && gcal_event_is_multiday (widget2->event))
|
||||
{
|
||||
time_t time_s1, time_s2;
|
||||
time_t time_e1, time_e2;
|
||||
time_t result;
|
||||
|
||||
time_s1 = g_date_time_to_unix (widget1->dt_start);
|
||||
time_s2 = g_date_time_to_unix (widget2->dt_start);
|
||||
time_e1 = g_date_time_to_unix (widget1->dt_end);
|
||||
time_e2 = g_date_time_to_unix (widget2->dt_end);
|
||||
|
||||
result = (time_e2 - time_s2) - (time_e1 - time_s1);
|
||||
if (result != 0)
|
||||
return result;
|
||||
else
|
||||
return g_date_time_compare (widget1->dt_start, widget2->dt_start);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gcal_event_is_multiday (widget1->event))
|
||||
return -1;
|
||||
else if (gcal_event_is_multiday (widget2->event))
|
||||
return 1;
|
||||
else
|
||||
{
|
||||
if (gcal_event_get_all_day (widget1->event) && gcal_event_get_all_day (widget2->event))
|
||||
return 0;
|
||||
else if (gcal_event_get_all_day (widget1->event))
|
||||
return -1;
|
||||
else if (gcal_event_get_all_day (widget2->event))
|
||||
return 1;
|
||||
else
|
||||
return g_date_time_compare (widget1->dt_start, widget2->dt_start);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user