aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/calendar-model.c
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@ximian.com>2001-07-01 12:59:24 +0800
committerFederico Mena Quintero <federico@src.gnome.org>2001-07-01 12:59:24 +0800
commita0afdf4f53224a55425a8826c0563faa510fa6c5 (patch)
tree0b73a44325df455ee96053f0b6983a1d5f9a7592 /calendar/gui/calendar-model.c
parent21f1aedda2c1c38589c1f0abb550cabeab8f551f (diff)
downloadgsoc2013-evolution-a0afdf4f53224a55425a8826c0563faa510fa6c5.tar
gsoc2013-evolution-a0afdf4f53224a55425a8826c0563faa510fa6c5.tar.gz
gsoc2013-evolution-a0afdf4f53224a55425a8826c0563faa510fa6c5.tar.bz2
gsoc2013-evolution-a0afdf4f53224a55425a8826c0563faa510fa6c5.tar.lz
gsoc2013-evolution-a0afdf4f53224a55425a8826c0563faa510fa6c5.tar.xz
gsoc2013-evolution-a0afdf4f53224a55425a8826c0563faa510fa6c5.tar.zst
gsoc2013-evolution-a0afdf4f53224a55425a8826c0563faa510fa6c5.zip
Fixes bug #1406.
2001-06-30 Federico Mena Quintero <federico@ximian.com> Fixes bug #1406. * gui/calendar-config.c (config_read): Handle the options for the task list colors. (calendar_config_write): Ditto. (calendar_config_get_tasks_due_today_color): New function. (calendar_config_set_tasks_due_today_color): New function. (calendar_config_get_tasks_overdue_color): New function. (calendar_config_set_tasks_overdue_color): New function. (calendar_config_configure_e_calendar_table): Use e_table_model_changed() for the colors. * gui/dialogs/cal-prefs-dialog.glade: Updated the options for the task list and alarms. * gui/dialogs/cal-prefs-dialog.c (cal_prefs_dialog_show_config): Update the task list settings. (cal_prefs_dialog_update_config): Ditto. * gui/calendar-model.c (get_color): Deal with tasks for today as well as overdue tasks. Make it cleaner, even though we have to duplicate a chunk of is_overdue(). * gui/calendar-commands.c (preferences_cmd): Renamed from properties_cmd(). svn path=/trunk/; revision=10648
Diffstat (limited to 'calendar/gui/calendar-model.c')
-rw-r--r--calendar/gui/calendar-model.c87
1 files changed, 68 insertions, 19 deletions
diff --git a/calendar/gui/calendar-model.c b/calendar/gui/calendar-model.c
index 1e64b940c4..bcd4d69843 100644
--- a/calendar/gui/calendar-model.c
+++ b/calendar/gui/calendar-model.c
@@ -43,8 +43,9 @@
#include <gal/widgets/e-unicode.h>
#include <e-util/e-time-utils.h>
#include <cal-util/timeutil.h>
-#include "calendar-model.h"
#include "calendar-commands.h"
+#include "calendar-config.h"
+#include "calendar-model.h"
/* Private part of the ECalendarModel structure */
@@ -561,7 +562,7 @@ get_url (CalComponent *comp)
/* Returns whether the completion date has been set on a component */
static gboolean
-get_is_complete (CalComponent *comp)
+is_complete (CalComponent *comp)
{
struct icaltimetype *t;
gboolean retval;
@@ -575,14 +576,11 @@ get_is_complete (CalComponent *comp)
return retval;
}
-/* Returns whether a calendar component is overdue.
- *
- * FIXME: This will only get called when the component is scrolled into the
- * ETable. There should be some sort of dynamic update thingy for if a component
- * becomes overdue while it is being viewed.
+/* Returns whether a component is overdue. Sigh, this is very similar to
+ * get_color() below.
*/
static gboolean
-get_is_overdue (CalComponent *comp)
+is_overdue (CalComponent *comp)
{
CalComponentDateTime dt;
gboolean retval;
@@ -598,15 +596,12 @@ get_is_overdue (CalComponent *comp)
/* Second, is it already completed? */
- if (get_is_complete (comp)) {
+ if (is_complete (comp)) {
retval = FALSE;
goto out;
}
- /* Third, are we overdue as of right now? We use <= in the
- * comparison below so that the table entries change color
- * immediately.
- */
+ /* Third, are we overdue as of right now? */
t = icaltime_as_timet (*dt.value);
@@ -623,6 +618,63 @@ get_is_overdue (CalComponent *comp)
return retval;
}
+/* Computes the color to be used to display a component */
+static const char *
+get_color (CalComponent *comp)
+{
+ CalComponentDateTime dt;
+ const char *retval;
+
+ cal_component_get_due (comp, &dt);
+
+ /* First, do we have a due date? */
+
+ if (!dt.value)
+ retval = NULL;
+ else {
+ time_t t, t_now;
+ struct tm tm, tm_now;
+
+ /* Second, is it already completed? */
+
+ if (is_complete (comp)) {
+ retval = NULL;
+ goto out;
+ }
+
+ /* Third, is it due today? */
+
+ t = icaltime_as_timet (*dt.value);
+ tm = *localtime (&t);
+
+ t_now = time (NULL);
+ tm_now = *localtime (&t_now);
+
+ if (tm.tm_year == tm_now.tm_year
+ && tm.tm_mon == tm_now.tm_mon
+ && tm.tm_mday == tm_now.tm_mday) {
+ retval = calendar_config_get_tasks_due_today_color ();
+ goto out;
+ }
+
+ /* Fourth, are we overdue as of right now? We use <= in the
+ * comparison below so that the table entries change color
+ * immediately.
+ */
+
+ if (t <= t_now)
+ retval = calendar_config_get_tasks_overdue_color ();
+ else
+ retval = NULL;
+ }
+
+ out:
+
+ cal_component_free_datetime (&dt);
+
+ return retval;
+}
+
static void *
get_status (CalComponent *comp)
{
@@ -732,19 +784,16 @@ calendar_model_value_at (ETableModel *etm, int col, int row)
}
}
case CAL_COMPONENT_FIELD_COMPLETE:
- return GINT_TO_POINTER (get_is_complete (comp));
+ return GINT_TO_POINTER (is_complete (comp));
case CAL_COMPONENT_FIELD_RECURRING:
return GINT_TO_POINTER (cal_component_has_recurrences (comp));
case CAL_COMPONENT_FIELD_OVERDUE:
- return GINT_TO_POINTER (get_is_overdue (comp));
+ return GINT_TO_POINTER (is_overdue (comp));
case CAL_COMPONENT_FIELD_COLOR:
- if (get_is_overdue (comp))
- return "red";
- else
- return NULL;
+ return (void *) get_color (comp);
case CAL_COMPONENT_FIELD_STATUS:
return get_status (comp);