aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/e-calendar-table.c
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@ximian.com>2001-06-24 13:53:43 +0800
committerFederico Mena Quintero <federico@src.gnome.org>2001-06-24 13:53:43 +0800
commit8677833cfac274823f23f8ef4669cbeda1293780 (patch)
tree2ff5d25560c20519a2e6f16c84f3d8c01e72927f /calendar/gui/e-calendar-table.c
parent602fee638e44de17ddd438d9327d7087c72bc41d (diff)
downloadgsoc2013-evolution-8677833cfac274823f23f8ef4669cbeda1293780.tar.gz
gsoc2013-evolution-8677833cfac274823f23f8ef4669cbeda1293780.tar.zst
gsoc2013-evolution-8677833cfac274823f23f8ef4669cbeda1293780.zip
New function to compare tasks like the Pilot task list.
2001-06-23 Federico Mena Quintero <federico@ximian.com> * gui/e-calendar-table.c (task_compare_cb): New function to compare tasks like the Pilot task list. * cal-util/cal-component.h (CalComponentField): Added a semi-hackish CAL_COMPONENT_FIELD_COMPONENT. In the ETable model, it is intended to return a pointer to the component itself. * gui/calendar-model.c (calendar_model_value_at): Return the component itself for CAL_COMPONENT_FIELD_COMPONENT. Be more paranoid about invalid columns. (calendar_model_set_value_at): Be more paranoid about invalid columns. (calendar_model_duplicate_value): Ref the component field. (calendar_model_initialize_value): Deal with the component field. (calendar_model_value_is_empty): Likewise. (calendar_model_value_to_string): Likewise. svn path=/trunk/; revision=10447
Diffstat (limited to 'calendar/gui/e-calendar-table.c')
-rw-r--r--calendar/gui/e-calendar-table.c74
1 files changed, 74 insertions, 0 deletions
diff --git a/calendar/gui/e-calendar-table.c b/calendar/gui/e-calendar-table.c
index 2568db2b49..7a1ecc11ea 100644
--- a/calendar/gui/e-calendar-table.c
+++ b/calendar/gui/e-calendar-table.c
@@ -172,6 +172,72 @@ e_calendar_table_class_init (ECalendarTableClass *class)
clipboard_atom = gdk_atom_intern ("CLIPBOARD", FALSE);
}
+/* Compares two priority values, which may not exist */
+static int
+compare_priorities (int *a, int *b)
+{
+ if (a && b) {
+ if (*a < *b)
+ return -1;
+ else if (*a > *b)
+ return 1;
+ else
+ return 0;
+ } else if (a)
+ return -1;
+ else if (b)
+ return 1;
+ else
+ return 0;
+}
+
+/* Comparison function for the task-sort column. Sorts by due date and then by
+ * priority.
+ */
+static gint
+task_compare_cb (gconstpointer a, gconstpointer b)
+{
+ CalComponent *ca, *cb;
+ CalComponentDateTime due_a, due_b;
+ int *prio_a, *prio_b;
+ int retval;
+
+ ca = CAL_COMPONENT (a);
+ cb = CAL_COMPONENT (b);
+
+ cal_component_get_due (ca, &due_a);
+ cal_component_get_due (cb, &due_b);
+ cal_component_get_priority (ca, &prio_a);
+ cal_component_get_priority (cb, &prio_b);
+
+ if (due_a.value && due_b.value) {
+ int v;
+
+ v = icaltime_compare (*due_a.value, *due_b.value);
+
+ if (v == 0)
+ retval = compare_priorities (prio_a, prio_b);
+ else
+ retval = v;
+ } else if (due_a.value)
+ retval = -1;
+ else if (due_b.value)
+ retval = 1;
+ else
+ retval = compare_priorities (prio_a, prio_b);
+
+ cal_component_free_datetime (&due_a);
+ cal_component_free_datetime (&due_b);
+
+ if (prio_a)
+ cal_component_free_priority (prio_a);
+
+ if (prio_b)
+ cal_component_free_priority (prio_b);
+
+ return retval;
+}
+
#ifdef JUST_FOR_TRANSLATORS
static char *list [] = {
N_("Categories"),
@@ -243,6 +309,8 @@ static char *list [] = {
" <ETableColumn model_col=\"18\" _title=\"Status\" " \
" expansion=\"1.0\" minimum_width=\"10\" resizable=\"true\" " \
" cell=\"calstatus\" compare=\"string\"/>" \
+ " <ETableColumn model_col=\"19\" _title=\"Task sort\" " \
+ " cell=\"task-sort\" compare=\"task-sort\"/>" \
" <ETableState>" \
" <column source=\"13\"/>" \
" <column source=\"14\"/>" \
@@ -452,6 +520,12 @@ e_calendar_table_init (ECalendarTable *cal_table)
e_table_extras_add_cell (extras, "calstatus", popup_cell);
+ /* Task sorting field */
+ /* FIXME: This column should not be displayed, but ETableExtras requires
+ * its shit to be visible columns listed in the XML spec.
+ */
+ e_table_extras_add_compare (extras, "task-sort", task_compare_cb);
+
/* Create pixmaps */
if (!icon_pixbufs[0])