aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2011-12-14 21:48:34 +0800
committerMilan Crha <mcrha@redhat.com>2011-12-14 21:48:34 +0800
commit017f373b5284b4d7177c19e5ac2a142a5362a15c (patch)
treed180e617b7b080cf9a324154a5c49fdc2294b3d1 /calendar
parent10ee75dfdfd41fc35e6307619e891915b6f3cafe (diff)
downloadgsoc2013-evolution-017f373b5284b4d7177c19e5ac2a142a5362a15c.tar.gz
gsoc2013-evolution-017f373b5284b4d7177c19e5ac2a142a5362a15c.tar.zst
gsoc2013-evolution-017f373b5284b4d7177c19e5ac2a142a5362a15c.zip
Bug #582649 - Toggle for coloring today and overdue tasks
Diffstat (limited to 'calendar')
-rw-r--r--calendar/gui/e-cal-model-tasks.c113
-rw-r--r--calendar/gui/e-cal-model-tasks.h10
-rw-r--r--calendar/gui/e-task-table.c33
3 files changed, 151 insertions, 5 deletions
diff --git a/calendar/gui/e-cal-model-tasks.c b/calendar/gui/e-cal-model-tasks.c
index 8602ce58cf..fdbcd379b4 100644
--- a/calendar/gui/e-cal-model-tasks.c
+++ b/calendar/gui/e-cal-model-tasks.c
@@ -38,7 +38,9 @@
#include "misc.h"
struct _ECalModelTasksPrivate {
+ gboolean highlight_due_today;
gchar *color_due_today;
+ gboolean highlight_overdue;
gchar *color_overdue;
};
@@ -61,7 +63,9 @@ G_DEFINE_TYPE (ECalModelTasks, e_cal_model_tasks, E_TYPE_CAL_MODEL)
enum {
PROP_0,
+ PROP_HIGHLIGHT_DUE_TODAY,
PROP_COLOR_DUE_TODAY,
+ PROP_HIGHLIGHT_OVERDUE,
PROP_COLOR_OVERDUE
};
@@ -72,12 +76,24 @@ cal_model_tasks_set_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
+ case PROP_HIGHLIGHT_DUE_TODAY:
+ e_cal_model_tasks_set_highlight_due_today (
+ E_CAL_MODEL_TASKS (object),
+ g_value_get_boolean (value));
+ return;
+
case PROP_COLOR_DUE_TODAY:
e_cal_model_tasks_set_color_due_today (
E_CAL_MODEL_TASKS (object),
g_value_get_string (value));
return;
+ case PROP_HIGHLIGHT_OVERDUE:
+ e_cal_model_tasks_set_highlight_overdue (
+ E_CAL_MODEL_TASKS (object),
+ g_value_get_boolean (value));
+ return;
+
case PROP_COLOR_OVERDUE:
e_cal_model_tasks_set_color_overdue (
E_CAL_MODEL_TASKS (object),
@@ -95,6 +111,13 @@ cal_model_tasks_get_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
+ case PROP_HIGHLIGHT_DUE_TODAY:
+ g_value_set_boolean (
+ value,
+ e_cal_model_tasks_get_highlight_due_today (
+ E_CAL_MODEL_TASKS (object)));
+ return;
+
case PROP_COLOR_DUE_TODAY:
g_value_set_string (
value,
@@ -102,6 +125,13 @@ cal_model_tasks_get_property (GObject *object,
E_CAL_MODEL_TASKS (object)));
return;
+ case PROP_HIGHLIGHT_OVERDUE:
+ g_value_set_boolean (
+ value,
+ e_cal_model_tasks_get_highlight_overdue (
+ E_CAL_MODEL_TASKS (object)));
+ return;
+
case PROP_COLOR_OVERDUE:
g_value_set_string (
value,
@@ -158,6 +188,16 @@ e_cal_model_tasks_class_init (ECalModelTasksClass *class)
g_object_class_install_property (
object_class,
+ PROP_HIGHLIGHT_DUE_TODAY,
+ g_param_spec_boolean (
+ "highlight-due-today",
+ "Highlight Due Today",
+ NULL,
+ TRUE,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (
+ object_class,
PROP_COLOR_DUE_TODAY,
g_param_spec_string (
"color-due-today",
@@ -168,6 +208,16 @@ e_cal_model_tasks_class_init (ECalModelTasksClass *class)
g_object_class_install_property (
object_class,
+ PROP_HIGHLIGHT_OVERDUE,
+ g_param_spec_boolean (
+ "highlight-overdue",
+ "Highlight Overdue",
+ NULL,
+ TRUE,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (
+ object_class,
PROP_COLOR_OVERDUE,
g_param_spec_string (
"color-overdue",
@@ -183,6 +233,9 @@ e_cal_model_tasks_init (ECalModelTasks *model)
model->priv = G_TYPE_INSTANCE_GET_PRIVATE (
model, E_TYPE_CAL_MODEL_TASKS, ECalModelTasksPrivate);
+ model->priv->highlight_due_today = TRUE;
+ model->priv->highlight_overdue = TRUE;
+
e_cal_model_set_component_kind (
E_CAL_MODEL (model), ICAL_VTODO_COMPONENT);
}
@@ -1104,19 +1157,25 @@ static const gchar *
ecmt_get_color_for_component (ECalModel *model,
ECalModelComponent *comp_data)
{
+ ECalModelTasks *tasks;
+
g_return_val_if_fail (E_IS_CAL_MODEL_TASKS (model), NULL);
g_return_val_if_fail (comp_data != NULL, NULL);
+ tasks = E_CAL_MODEL_TASKS (model);
+
/* XXX ECalModel's get_color_for_component() method should really
* get a GdkColor instead of a color specification string. */
- switch (get_due_status ((ECalModelTasks *) model, comp_data)) {
+ switch (get_due_status (tasks, comp_data)) {
case E_CAL_MODEL_TASKS_DUE_TODAY:
- return e_cal_model_tasks_get_color_due_today (
- E_CAL_MODEL_TASKS (model));
+ if (!e_cal_model_tasks_get_highlight_due_today (tasks))
+ break;
+ return e_cal_model_tasks_get_color_due_today (tasks);
case E_CAL_MODEL_TASKS_DUE_OVERDUE:
- return e_cal_model_tasks_get_color_overdue (
- E_CAL_MODEL_TASKS (model));
+ if (!e_cal_model_tasks_get_highlight_overdue (tasks))
+ break;
+ return e_cal_model_tasks_get_color_overdue (tasks);
case E_CAL_MODEL_TASKS_DUE_NEVER:
case E_CAL_MODEL_TASKS_DUE_FUTURE:
case E_CAL_MODEL_TASKS_DUE_COMPLETE:
@@ -1167,6 +1226,28 @@ e_cal_model_tasks_new (void)
return g_object_new (E_TYPE_CAL_MODEL_TASKS, NULL);
}
+gboolean
+e_cal_model_tasks_get_highlight_due_today (ECalModelTasks *model)
+{
+ g_return_val_if_fail (E_IS_CAL_MODEL_TASKS (model), FALSE);
+
+ return model->priv->highlight_due_today;
+}
+
+void
+e_cal_model_tasks_set_highlight_due_today (ECalModelTasks *model,
+ gboolean highlight)
+{
+ g_return_if_fail (E_IS_CAL_MODEL_TASKS (model));
+
+ if ((highlight ? 1 : 0) == (model->priv->highlight_due_today ? 1 : 0))
+ return;
+
+ model->priv->highlight_due_today = highlight;
+
+ g_object_notify (G_OBJECT (model), "highlight-due-today");
+}
+
const gchar *
e_cal_model_tasks_get_color_due_today (ECalModelTasks *model)
{
@@ -1188,6 +1269,28 @@ e_cal_model_tasks_set_color_due_today (ECalModelTasks *model,
g_object_notify (G_OBJECT (model), "color-due-today");
}
+gboolean
+e_cal_model_tasks_get_highlight_overdue (ECalModelTasks *model)
+{
+ g_return_val_if_fail (E_IS_CAL_MODEL_TASKS (model), FALSE);
+
+ return model->priv->highlight_overdue;
+}
+
+void
+e_cal_model_tasks_set_highlight_overdue (ECalModelTasks *model,
+ gboolean highlight)
+{
+ g_return_if_fail (E_IS_CAL_MODEL_TASKS (model));
+
+ if ((highlight ? 1 : 0) == (model->priv->highlight_overdue ? 1 : 0))
+ return;
+
+ model->priv->highlight_overdue = highlight;
+
+ g_object_notify (G_OBJECT (model), "highlight-overdue");
+}
+
const gchar *
e_cal_model_tasks_get_color_overdue (ECalModelTasks *model)
{
diff --git a/calendar/gui/e-cal-model-tasks.h b/calendar/gui/e-cal-model-tasks.h
index f35f8dd28c..54d31cbaaa 100644
--- a/calendar/gui/e-cal-model-tasks.h
+++ b/calendar/gui/e-cal-model-tasks.h
@@ -80,11 +80,21 @@ struct _ECalModelTasksClass {
GType e_cal_model_tasks_get_type (void);
ECalModel * e_cal_model_tasks_new (void);
+gboolean e_cal_model_tasks_get_highlight_due_today
+ (ECalModelTasks *model);
+void e_cal_model_tasks_set_highlight_due_today
+ (ECalModelTasks *model,
+ gboolean highlight);
const gchar * e_cal_model_tasks_get_color_due_today
(ECalModelTasks *model);
void e_cal_model_tasks_set_color_due_today
(ECalModelTasks *model,
const gchar *color_due_today);
+gboolean e_cal_model_tasks_get_highlight_overdue
+ (ECalModelTasks *model);
+void e_cal_model_tasks_set_highlight_overdue
+ (ECalModelTasks *model,
+ gboolean highlight);
const gchar * e_cal_model_tasks_get_color_overdue
(ECalModelTasks *model);
void e_cal_model_tasks_set_color_overdue
diff --git a/calendar/gui/e-task-table.c b/calendar/gui/e-task-table.c
index e052e82357..4efe8d0669 100644
--- a/calendar/gui/e-task-table.c
+++ b/calendar/gui/e-task-table.c
@@ -288,6 +288,16 @@ delete_selected_components (ETaskTable *task_table)
}
static void
+task_table_queue_draw_cb (ECalModelTasks *tasks_model,
+ GParamSpec *param,
+ GtkWidget *task_table)
+{
+ g_return_if_fail (task_table != NULL);
+
+ gtk_widget_queue_draw (task_table);
+}
+
+static void
task_table_set_model (ETaskTable *task_table,
ECalModel *model)
{
@@ -304,6 +314,28 @@ task_table_set_model (ETaskTable *task_table,
model, "cal-view-complete",
G_CALLBACK (task_table_model_cal_view_complete_cb),
task_table);
+
+ /* redraw on drawing options change */
+ g_signal_connect (
+ model, "notify::highlight-due-today",
+ G_CALLBACK (task_table_queue_draw_cb),
+ task_table);
+
+ g_signal_connect (
+ model, "notify::color-due-today",
+ G_CALLBACK (task_table_queue_draw_cb),
+ task_table);
+
+ g_signal_connect (
+ model, "notify::highlight-overdue",
+ G_CALLBACK (task_table_queue_draw_cb),
+ task_table);
+
+ g_signal_connect (
+ model, "notify::color-overdue",
+ G_CALLBACK (task_table_queue_draw_cb),
+ task_table);
+
}
static void
@@ -397,6 +429,7 @@ task_table_dispose (GObject *object)
}
if (priv->model != NULL) {
+ g_signal_handlers_disconnect_by_func (priv->model, task_table_queue_draw_cb, object);
g_object_unref (priv->model);
priv->model = NULL;
}