From dafcf05cc318e3beae037ba2092eff2b9eb36d4d Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Thu, 14 Feb 2008 18:16:31 +0000 Subject: ** Fix for bug #514987 2008-02-14 Milan Crha ** Fix for bug #514987 * gui/e-calendar-table.etspec: * gui/e-calendar-table.c: (status_from_string), (status_compare_cb), (e_calendar_table_init): New sorting by Status based on the index in popup, not on the text. svn path=/trunk/; revision=35013 --- calendar/gui/e-calendar-table.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'calendar/gui/e-calendar-table.c') diff --git a/calendar/gui/e-calendar-table.c b/calendar/gui/e-calendar-table.c index 0718ac5a49..f649c1b17c 100644 --- a/calendar/gui/e-calendar-table.c +++ b/calendar/gui/e-calendar-table.c @@ -220,6 +220,39 @@ priority_compare_cb (gconstpointer a, gconstpointer b) return 0; } +static gint +status_from_string (const char *str) +{ + int status = -2; + + if (!str || !str[0]) + status = -1; + else if (!g_utf8_collate (str, _("Not Started"))) + status = 0; + else if (!g_utf8_collate (str, _("In Progress"))) + status = 1; + else if (!g_utf8_collate (str, _("Completed"))) + status = 2; + else if (!g_utf8_collate (str, _("Canceled"))) + status = 3; + + return status; +} + +static gint +status_compare_cb (gconstpointer a, gconstpointer b) +{ + int sa = status_from_string ((const char *)a); + int sb = status_from_string ((const char *)b); + + if (sa < sb) + return -1; + else if (sa > sb) + return 1; + + return 0; +} + static void row_appended_cb (ECalModel *model, ECalendarTable *cal_table) { @@ -412,6 +445,8 @@ e_calendar_table_init (ECalendarTable *cal_table) percent_compare_cb); e_table_extras_add_compare (extras, "priority-compare", priority_compare_cb); + e_table_extras_add_compare (extras, "status-compare", + status_compare_cb); /* Create pixmaps */ -- cgit