aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
Diffstat (limited to 'calendar')
-rw-r--r--calendar/ChangeLog19
-rw-r--r--calendar/cal-util/cal-component.h1
-rw-r--r--calendar/gui/calendar-commands.c1
-rw-r--r--calendar/gui/calendar-model.c48
-rw-r--r--calendar/gui/e-calendar-table.c74
5 files changed, 129 insertions, 14 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 6928df5c52..c82faa58bc 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,22 @@
+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.
+
2001-06-22 Jeffrey Stedfast <fejj@ximian.com>
* gui/Makefile.am: Added itip-control-factory.* to the build.
diff --git a/calendar/cal-util/cal-component.h b/calendar/cal-util/cal-component.h
index 937d3f098f..cd9ee725ed 100644
--- a/calendar/cal-util/cal-component.h
+++ b/calendar/cal-util/cal-component.h
@@ -78,6 +78,7 @@ typedef enum {
CAL_COMPONENT_FIELD_OVERDUE, /* not a real field */
CAL_COMPONENT_FIELD_COLOR, /* not a real field */
CAL_COMPONENT_FIELD_STATUS,
+ CAL_COMPONENT_FIELD_COMPONENT, /* not a real field */
CAL_COMPONENT_FIELD_NUM_FIELDS
} CalComponentField;
diff --git a/calendar/gui/calendar-commands.c b/calendar/gui/calendar-commands.c
index 5a7ca045e7..3167e002f6 100644
--- a/calendar/gui/calendar-commands.c
+++ b/calendar/gui/calendar-commands.c
@@ -48,6 +48,7 @@
#include <bonobo/bonobo-ui-util.h>
#include <cal-util/timeutil.h>
#include "calendar-commands.h"
+#include "calendar-config.h"
#include "gnome-cal.h"
#include "goto.h"
#include "print.h"
diff --git a/calendar/gui/calendar-model.c b/calendar/gui/calendar-model.c
index 85d7dd4236..8a90b507f9 100644
--- a/calendar/gui/calendar-model.c
+++ b/calendar/gui/calendar-model.c
@@ -164,7 +164,7 @@ calendar_model_class_init (CalendarModelClass *class)
categories_changed),
gtk_signal_default_marshaller,
GTK_TYPE_NONE, 0);
-
+
gtk_object_class_add_signals (object_class, calendar_model_signals,
LAST_SIGNAL);
@@ -749,8 +749,12 @@ calendar_model_value_at (ETableModel *etm, int col, int row)
case CAL_COMPONENT_FIELD_STATUS:
return get_status (comp);
+ case CAL_COMPONENT_FIELD_COMPONENT:
+ return comp;
+
default:
g_message ("calendar_model_value_at(): Requested invalid column %d", col);
+ g_assert_not_reached ();
return NULL;
}
}
@@ -1283,7 +1287,8 @@ calendar_model_set_value_at (ETableModel *etm, int col, int row, const void *val
default:
g_message ("calendar_model_set_value_at(): Requested invalid column %d", col);
- break;
+ g_assert_not_reached ();
+ return;
}
if (!cal_client_update_object (priv->client, comp))
@@ -1410,6 +1415,10 @@ calendar_model_duplicate_value (ETableModel *etm, int col, const void *value)
case CAL_COMPONENT_FIELD_COLOR:
return (void *) value;
+ case CAL_COMPONENT_FIELD_COMPONENT:
+ gtk_object_ref (GTK_OBJECT (value));
+ return;
+
default:
g_message ("calendar_model_duplicate_value(): Requested invalid column %d", col);
return NULL;
@@ -1425,9 +1434,10 @@ calendar_model_free_value (ETableModel *etm, int col, void *value)
switch (col) {
case CAL_COMPONENT_FIELD_CATEGORIES:
g_free (value);
+ break;
case CAL_COMPONENT_FIELD_CLASSIFICATION:
- return;
+ break;
case CAL_COMPONENT_FIELD_COMPLETED:
case CAL_COMPONENT_FIELD_DTEND:
@@ -1439,12 +1449,14 @@ calendar_model_free_value (ETableModel *etm, int col, void *value)
case CAL_COMPONENT_FIELD_SUMMARY:
case CAL_COMPONENT_FIELD_STATUS:
g_free (value);
+ break;
case CAL_COMPONENT_FIELD_TRANSPARENCY:
- return;
+ break;
case CAL_COMPONENT_FIELD_URL:
g_free (value);
+ break;
case CAL_COMPONENT_FIELD_HAS_ALARMS:
case CAL_COMPONENT_FIELD_ICON:
@@ -1452,11 +1464,14 @@ calendar_model_free_value (ETableModel *etm, int col, void *value)
case CAL_COMPONENT_FIELD_RECURRING:
case CAL_COMPONENT_FIELD_OVERDUE:
case CAL_COMPONENT_FIELD_COLOR:
- return;
+ break;
+
+ case CAL_COMPONENT_FIELD_COMPONENT:
+ gtk_object_unref (GTK_OBJECT (value));
+ break;
default:
g_message ("calendar_model_free_value(): Requested invalid column %d", col);
- return;
}
}
@@ -1501,6 +1516,7 @@ calendar_model_initialize_value (ETableModel *etm, int col)
case CAL_COMPONENT_FIELD_RECURRING:
case CAL_COMPONENT_FIELD_OVERDUE:
case CAL_COMPONENT_FIELD_COLOR:
+ case CAL_COMPONENT_FIELD_COMPONENT:
return NULL;
default:
@@ -1540,6 +1556,7 @@ calendar_model_value_is_empty (ETableModel *etm, int col, const void *value)
case CAL_COMPONENT_FIELD_RECURRING:
case CAL_COMPONENT_FIELD_OVERDUE:
case CAL_COMPONENT_FIELD_COLOR:
+ case CAL_COMPONENT_FIELD_COMPONENT:
return TRUE;
default:
@@ -1548,7 +1565,7 @@ calendar_model_value_is_empty (ETableModel *etm, int col, const void *value)
}
}
-static char *
+static char *
calendar_model_value_to_string (ETableModel *etm, int col, const void *value)
{
g_return_val_if_fail (col >= 0 && col < CAL_COMPONENT_FIELD_NUM_FIELDS, NULL);
@@ -1586,6 +1603,9 @@ calendar_model_value_to_string (ETableModel *etm, int col, const void *value)
case CAL_COMPONENT_FIELD_COLOR:
return NULL;
+ case CAL_COMPONENT_FIELD_COMPONENT:
+ return NULL;
+
default:
g_message ("calendar_model_value_as_string(): Requested invalid column %d", col);
return NULL;
@@ -1887,9 +1907,9 @@ load_objects (CalendarModel *model)
/**
* calendar_model_get_cal_client:
* @model: A calendar model.
- *
+ *
* Queries the calendar client interface object that a calendar model is using.
- *
+ *
* Return value: A calendar client interface object.
**/
CalClient *
@@ -1967,7 +1987,7 @@ calendar_model_set_cal_client (CalendarModel *model, CalClient *client, CalObjTy
* calendar_model_set_new_comp_vtype:
* @model: A calendar model.
* @vtype: Type of calendar components to create.
- *
+ *
* Sets the type of calendar components that will be created by a calendar table
* model when the click-to-add functionality of the table is used.
**/
@@ -1987,10 +2007,10 @@ calendar_model_set_new_comp_vtype (CalendarModel *model, CalComponentVType vtype
/**
* calendar_model_get_new_comp_vtype:
* @model: A calendar model.
- *
+ *
* Queries the type of calendar components that are created by a calendar table
* model when using the click-to-add functionality in a table.
- *
+ *
* Return value: Type of components that are created.
**/
CalComponentVType
@@ -2034,9 +2054,9 @@ calendar_model_mark_task_complete (CalendarModel *model,
* calendar_model_get_component:
* @model: A calendar model.
* @row: Row number of sought calendar component.
- *
+ *
* Queries a calendar component from a calendar model based on its row number.
- *
+ *
* Return value: The sought calendar component.
**/
CalComponent *
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])