From b2cda1d0c6d44f53f71bad9e256f41188677dfba Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Wed, 1 Oct 2008 20:56:04 +0000 Subject: Merge revisions 36016:36533 from trunk. svn path=/branches/kill-bonobo/; revision=36534 --- calendar/gui/e-cal-model-tasks.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'calendar/gui/e-cal-model-tasks.c') diff --git a/calendar/gui/e-cal-model-tasks.c b/calendar/gui/e-cal-model-tasks.c index 98d56661bc..095cfabc4b 100644 --- a/calendar/gui/e-cal-model-tasks.c +++ b/calendar/gui/e-cal-model-tasks.c @@ -1,21 +1,25 @@ -/* Evolution calendar - Data model for ETable - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - * Authors: Rodrigo Moya +/* + * Evolution calendar - Data model for ETable * * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) version 3. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the program; if not, see + * + * + * Authors: + * Rodrigo Moya + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifdef HAVE_CONFIG_H -- cgit v1.2.3 From d6b8b58bb45b16c1cb3a575c277ffdc77441e2df Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Wed, 29 Oct 2008 20:11:07 +0000 Subject: Get the calendar's memopad and taskpad working. What's interesting here is we're actually sharing the ECalModel across views. Instead of having the Calendar view listen to GConf for changes to the Task and Memo models, the Calendar view fetches the models directly from the Task and Memo views -- starting the views if it has to, although the shell really takes care of that -- and loads the models into its own taskpad and memopad. We couldn't do that sort of thing before with Bonobo in the way. Big chunks of redundant code should begin falling out shortly. svn path=/branches/kill-bonobo/; revision=36696 --- calendar/gui/e-cal-model-tasks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'calendar/gui/e-cal-model-tasks.c') diff --git a/calendar/gui/e-cal-model-tasks.c b/calendar/gui/e-cal-model-tasks.c index 095cfabc4b..e4d7304c25 100644 --- a/calendar/gui/e-cal-model-tasks.c +++ b/calendar/gui/e-cal-model-tasks.c @@ -1108,7 +1108,7 @@ ecmt_fill_component_from_model (ECalModel *model, ECalModelComponent *comp_data, /** * e_cal_model_tasks_new */ -ECalModelTasks * +ECalModel * e_cal_model_tasks_new (void) { return g_object_new (E_TYPE_CAL_MODEL_TASKS, NULL); -- cgit v1.2.3 From e4afd3f9fb962ea1295a0657ec9f83a427829171 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 26 May 2009 23:21:02 -0400 Subject: Remove trailing whitespace, again. --- calendar/gui/e-cal-model-tasks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'calendar/gui/e-cal-model-tasks.c') diff --git a/calendar/gui/e-cal-model-tasks.c b/calendar/gui/e-cal-model-tasks.c index 5827117f14..a2b9eb6f2f 100644 --- a/calendar/gui/e-cal-model-tasks.c +++ b/calendar/gui/e-cal-model-tasks.c @@ -12,7 +12,7 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see + * License along with the program; if not, see * * * Authors: -- cgit v1.2.3 From 948235c3d1076dbe6ed2e57a24c16a083bbd9f01 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Wed, 27 May 2009 10:29:19 -0400 Subject: Prefer GLib basic types over C types. --- calendar/gui/e-cal-model-tasks.c | 116 +++++++++++++++++++-------------------- 1 file changed, 58 insertions(+), 58 deletions(-) (limited to 'calendar/gui/e-cal-model-tasks.c') diff --git a/calendar/gui/e-cal-model-tasks.c b/calendar/gui/e-cal-model-tasks.c index d66555a636..cc1ff58f67 100644 --- a/calendar/gui/e-cal-model-tasks.c +++ b/calendar/gui/e-cal-model-tasks.c @@ -42,17 +42,17 @@ struct _ECalModelTasksPrivate { static void e_cal_model_tasks_finalize (GObject *object); -static int ecmt_column_count (ETableModel *etm); -static void *ecmt_value_at (ETableModel *etm, int col, int row); -static void ecmt_set_value_at (ETableModel *etm, int col, int row, const void *value); -static gboolean ecmt_is_cell_editable (ETableModel *etm, int col, int row); -static void *ecmt_duplicate_value (ETableModel *etm, int col, const void *value); -static void ecmt_free_value (ETableModel *etm, int col, void *value); -static void *ecmt_initialize_value (ETableModel *etm, int col); -static gboolean ecmt_value_is_empty (ETableModel *etm, int col, const void *value); -static char *ecmt_value_to_string (ETableModel *etm, int col, const void *value); - -static const char *ecmt_get_color_for_component (ECalModel *model, ECalModelComponent *comp_data); +static gint ecmt_column_count (ETableModel *etm); +static gpointer ecmt_value_at (ETableModel *etm, gint col, gint row); +static void ecmt_set_value_at (ETableModel *etm, gint col, gint row, gconstpointer value); +static gboolean ecmt_is_cell_editable (ETableModel *etm, gint col, gint row); +static gpointer ecmt_duplicate_value (ETableModel *etm, gint col, gconstpointer value); +static void ecmt_free_value (ETableModel *etm, gint col, gpointer value); +static gpointer ecmt_initialize_value (ETableModel *etm, gint col); +static gboolean ecmt_value_is_empty (ETableModel *etm, gint col, gconstpointer value); +static gchar *ecmt_value_to_string (ETableModel *etm, gint col, gconstpointer value); + +static const gchar *ecmt_get_color_for_component (ECalModel *model, ECalModelComponent *comp_data); static void ecmt_fill_component_from_model (ECalModel *model, ECalModelComponent *comp_data, ETableModel *source_model, gint row); static void commit_component_changes (ECalModelComponent *comp_data); @@ -289,7 +289,7 @@ get_due (ECalModelComponent *comp_data) return comp_data->due; } -static void * +static gpointer get_geo (ECalModelComponent *comp_data) { icalproperty *prop; @@ -307,7 +307,7 @@ get_geo (ECalModelComponent *comp_data) return buf; } - return (void *) ""; + return (gpointer) ""; } static int @@ -322,7 +322,7 @@ get_percent (ECalModelComponent *comp_data) return 0; } -static void * +static gpointer get_priority (ECalModelComponent *comp_data) { icalproperty *prop; @@ -331,7 +331,7 @@ get_priority (ECalModelComponent *comp_data) if (prop) return e_cal_util_priority_to_string (icalproperty_get_priority (prop)); - return (void *) ""; + return (gpointer) ""; } static gboolean @@ -344,7 +344,7 @@ is_status_canceled (ECalModelComponent *comp_data) return prop && icalproperty_get_status (prop) == ICAL_STATUS_CANCELLED; } -static void * +static gpointer get_status (ECalModelComponent *comp_data) { icalproperty *prop; @@ -353,33 +353,33 @@ get_status (ECalModelComponent *comp_data) if (prop) { switch (icalproperty_get_status (prop)) { case ICAL_STATUS_NONE: - return (void *) ""; + return (gpointer) ""; case ICAL_STATUS_NEEDSACTION: - return (void *) _("Not Started"); + return (gpointer) _("Not Started"); case ICAL_STATUS_INPROCESS: - return (void *) _("In Progress"); + return (gpointer) _("In Progress"); case ICAL_STATUS_COMPLETED: - return (void *) _("Completed"); + return (gpointer) _("Completed"); case ICAL_STATUS_CANCELLED: - return (void *) _("Canceled"); + return (gpointer) _("Canceled"); default: - return (void *) ""; + return (gpointer) ""; } } - return (void *) ""; + return (gpointer) ""; } -static void * +static gpointer get_url (ECalModelComponent *comp_data) { icalproperty *prop; prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_URL_PROPERTY); if (prop) - return (void *) icalproperty_get_url (prop); + return (gpointer) icalproperty_get_url (prop); - return (void *) ""; + return (gpointer) ""; } static gboolean @@ -431,7 +431,7 @@ get_due_status (ECalModelTasks *model, ECalModelComponent *comp_data) /* Third, are we overdue as of right now? */ due_tt = icalproperty_get_due (prop); if (due_tt.is_date) { - int cmp; + gint cmp; now_tt = icaltime_current_time_with_zone (e_cal_model_get_timezone (E_CAL_MODEL (model))); cmp = icaltime_compare_date_only (due_tt, now_tt); @@ -444,7 +444,7 @@ get_due_status (ECalModelTasks *model, ECalModelComponent *comp_data) return E_CAL_MODEL_TASKS_DUE_FUTURE; } else { icalparameter *param; - const char *tzid; + const gchar *tzid; if(!(param = icalproperty_get_first_parameter (prop, ICAL_TZID_PARAMETER))) return E_CAL_MODEL_TASKS_DUE_FUTURE; @@ -483,8 +483,8 @@ is_overdue (ECalModelTasks *model, ECalModelComponent *comp_data) return FALSE; } -static void * -ecmt_value_at (ETableModel *etm, int col, int row) +static gpointer +ecmt_value_at (ETableModel *etm, gint col, gint row) { ECalModelComponent *comp_data; ECalModelTasks *model = (ECalModelTasks *) etm; @@ -499,7 +499,7 @@ ecmt_value_at (ETableModel *etm, int col, int row) comp_data = e_cal_model_get_component_at (E_CAL_MODEL (model), row); if (!comp_data) - return (void *) ""; + return (gpointer) ""; switch (col) { case E_CAL_MODEL_TASKS_FIELD_COMPLETED : @@ -524,11 +524,11 @@ ecmt_value_at (ETableModel *etm, int col, int row) return get_url (comp_data); } - return (void *) ""; + return (gpointer) ""; } static void -set_completed (ECalModelTasks *model, ECalModelComponent *comp_data, const void *value) +set_completed (ECalModelTasks *model, ECalModelComponent *comp_data, gconstpointer value) { ECellDateEditValue *dv = (ECellDateEditValue *) value; @@ -553,7 +553,7 @@ set_completed (ECalModelTasks *model, ECalModelComponent *comp_data, const void } static void -set_complete (ECalModelComponent *comp_data, const void *value) +set_complete (ECalModelComponent *comp_data, gconstpointer value) { gint state = GPOINTER_TO_INT (value); @@ -564,12 +564,12 @@ set_complete (ECalModelComponent *comp_data, const void *value) } static void -set_due (ECalModelComponent *comp_data, const void *value) +set_due (ECalModelComponent *comp_data, gconstpointer value) { ECellDateEditValue *dv = (ECellDateEditValue *) value; icalproperty *prop; icalparameter *param; - const char *tzid; + const gchar *tzid; prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_DUE_PROPERTY); if (prop) @@ -605,9 +605,9 @@ set_due (ECalModelComponent *comp_data, const void *value) /* If the TZID is set to "UTC", we don't want to save the TZID. */ if (tzid && strcmp (tzid, "UTC")) { if (param) { - icalparameter_set_tzid (param, (char *) tzid); + icalparameter_set_tzid (param, (gchar *) tzid); } else { - param = icalparameter_new_tzid ((char *) tzid); + param = icalparameter_new_tzid ((gchar *) tzid); icalproperty_add_parameter (prop, param); } } else if (param) { @@ -630,10 +630,10 @@ show_geo_warning (void) } static void -set_geo (ECalModelComponent *comp_data, const char *value) +set_geo (ECalModelComponent *comp_data, const gchar *value) { double latitude, longitude; - int matched; + gint matched; struct icalgeotype geo; icalproperty *prop; @@ -662,7 +662,7 @@ set_geo (ECalModelComponent *comp_data, const char *value) } static void -set_status (ECalModelComponent *comp_data, const char *value) +set_status (ECalModelComponent *comp_data, const gchar *value) { icalproperty_status status; icalproperty *prop; @@ -716,7 +716,7 @@ set_status (ECalModelComponent *comp_data, const char *value) } static void -set_percent (ECalModelComponent *comp_data, const void *value) +set_percent (ECalModelComponent *comp_data, gconstpointer value) { icalproperty *prop; gint percent = GPOINTER_TO_INT (value); @@ -758,10 +758,10 @@ set_percent (ECalModelComponent *comp_data, const void *value) } static void -set_priority (ECalModelComponent *comp_data, const char *value) +set_priority (ECalModelComponent *comp_data, const gchar *value) { icalproperty *prop; - int priority; + gint priority; prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_PRIORITY_PROPERTY); @@ -780,7 +780,7 @@ set_priority (ECalModelComponent *comp_data, const char *value) } static void -set_url (ECalModelComponent *comp_data, const char *value) +set_url (ECalModelComponent *comp_data, const gchar *value) { icalproperty *prop; @@ -802,7 +802,7 @@ set_url (ECalModelComponent *comp_data, const char *value) } static void -ecmt_set_value_at (ETableModel *etm, int col, int row, const void *value) +ecmt_set_value_at (ETableModel *etm, gint col, gint row, gconstpointer value) { ECalModelComponent *comp_data; ECalModelTasks *model = (ECalModelTasks *) etm; @@ -852,7 +852,7 @@ ecmt_set_value_at (ETableModel *etm, int col, int row, const void *value) } static gboolean -ecmt_is_cell_editable (ETableModel *etm, int col, int row) +ecmt_is_cell_editable (ETableModel *etm, gint col, gint row) { ECalModelTasks *model = (ECalModelTasks *) etm; @@ -882,8 +882,8 @@ ecmt_is_cell_editable (ETableModel *etm, int col, int row) return FALSE; } -static void * -ecmt_duplicate_value (ETableModel *etm, int col, const void *value) +static gpointer +ecmt_duplicate_value (ETableModel *etm, gint col, gconstpointer value) { g_return_val_if_fail (col >= 0 && col < E_CAL_MODEL_TASKS_FIELD_LAST, NULL); @@ -912,14 +912,14 @@ ecmt_duplicate_value (ETableModel *etm, int col, const void *value) case E_CAL_MODEL_TASKS_FIELD_COMPLETE : case E_CAL_MODEL_TASKS_FIELD_PERCENT : case E_CAL_MODEL_TASKS_FIELD_OVERDUE : - return (void *) value; + return (gpointer) value; } return NULL; } static void -ecmt_free_value (ETableModel *etm, int col, void *value) +ecmt_free_value (ETableModel *etm, gint col, gpointer value) { g_return_if_fail (col >= 0 && col < E_CAL_MODEL_TASKS_FIELD_LAST); @@ -945,8 +945,8 @@ ecmt_free_value (ETableModel *etm, int col, void *value) } } -static void * -ecmt_initialize_value (ETableModel *etm, int col) +static gpointer +ecmt_initialize_value (ETableModel *etm, gint col) { ECalModelTasks *model = (ECalModelTasks *) etm; @@ -975,7 +975,7 @@ ecmt_initialize_value (ETableModel *etm, int col) } static gboolean -ecmt_value_is_empty (ETableModel *etm, int col, const void *value) +ecmt_value_is_empty (ETableModel *etm, gint col, gconstpointer value) { ECalModelTasks *model = (ECalModelTasks *) etm; @@ -1004,8 +1004,8 @@ ecmt_value_is_empty (ETableModel *etm, int col, const void *value) return TRUE; } -static char * -ecmt_value_to_string (ETableModel *etm, int col, const void *value) +static gchar * +ecmt_value_to_string (ETableModel *etm, gint col, gconstpointer value) { ECalModelTasks *model = (ECalModelTasks *) etm; @@ -1039,7 +1039,7 @@ ecmt_value_to_string (ETableModel *etm, int col, const void *value) /* ECalModel class methods */ -static const char * +static const gchar * ecmt_get_color_for_component (ECalModel *model, ECalModelComponent *comp_data) { static gchar color_spec[16]; @@ -1077,7 +1077,7 @@ static void ecmt_fill_component_from_model (ECalModel *model, ECalModelComponent *comp_data, ETableModel *source_model, gint row) { - void *value; + gpointer value; g_return_if_fail (E_IS_CAL_MODEL_TASKS (model)); g_return_if_fail (comp_data != NULL); -- cgit v1.2.3 From 14f8eee012382f04090ea9277e9567d5f32e8bf0 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Thu, 28 May 2009 13:06:29 -0400 Subject: Whitespace cleanup. --- calendar/gui/e-cal-model-tasks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'calendar/gui/e-cal-model-tasks.c') diff --git a/calendar/gui/e-cal-model-tasks.c b/calendar/gui/e-cal-model-tasks.c index cc1ff58f67..6e7996dfea 100644 --- a/calendar/gui/e-cal-model-tasks.c +++ b/calendar/gui/e-cal-model-tasks.c @@ -136,7 +136,7 @@ ensure_task_complete (ECalModelComponent *comp_data, time_t completed_date) if (completed_date == -1) { if (prop) set_completed = FALSE; - else + else completed_date = time (NULL); } -- cgit v1.2.3 From 433eac7844481b8ceda0bae8bf08f6bb623185b0 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Mon, 1 Jun 2009 19:09:19 -0400 Subject: More code cleanup. --- calendar/gui/e-cal-model-tasks.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'calendar/gui/e-cal-model-tasks.c') diff --git a/calendar/gui/e-cal-model-tasks.c b/calendar/gui/e-cal-model-tasks.c index 6e7996dfea..43b54db368 100644 --- a/calendar/gui/e-cal-model-tasks.c +++ b/calendar/gui/e-cal-model-tasks.c @@ -112,7 +112,7 @@ e_cal_model_tasks_finalize (GObject *object) } /* ETableModel methods */ -static int +static gint ecmt_column_count (ETableModel *etm) { return E_CAL_MODEL_TASKS_FIELD_LAST; @@ -310,7 +310,7 @@ get_geo (ECalModelComponent *comp_data) return (gpointer) ""; } -static int +static gint get_percent (ECalModelComponent *comp_data) { icalproperty *prop; -- cgit v1.2.3 From b0e26e9c5f13c710c7677959cc457158206befe1 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Fri, 5 Jun 2009 14:48:29 +0200 Subject: Fix even more compiler warnings and disable one for format strings --- calendar/gui/e-cal-model-tasks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'calendar/gui/e-cal-model-tasks.c') diff --git a/calendar/gui/e-cal-model-tasks.c b/calendar/gui/e-cal-model-tasks.c index 43b54db368..5a0a75bea2 100644 --- a/calendar/gui/e-cal-model-tasks.c +++ b/calendar/gui/e-cal-model-tasks.c @@ -329,7 +329,7 @@ get_priority (ECalModelComponent *comp_data) prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_PRIORITY_PROPERTY); if (prop) - return e_cal_util_priority_to_string (icalproperty_get_priority (prop)); + return (gpointer) e_cal_util_priority_to_string (icalproperty_get_priority (prop)); return (gpointer) ""; } -- cgit v1.2.3 From 374bd42f69aca2e132fd854c9619f3d7491f1f96 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sun, 12 Jul 2009 23:33:07 -0400 Subject: Fix excessive whitespace. --- calendar/gui/e-cal-model-tasks.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'calendar/gui/e-cal-model-tasks.c') diff --git a/calendar/gui/e-cal-model-tasks.c b/calendar/gui/e-cal-model-tasks.c index 5a0a75bea2..acf3175765 100644 --- a/calendar/gui/e-cal-model-tasks.c +++ b/calendar/gui/e-cal-model-tasks.c @@ -199,7 +199,6 @@ ensure_task_partially_complete (ECalModelComponent *comp_data) icalcomponent_add_property (comp_data->icalcomp, icalproperty_new_status (ICAL_STATUS_INPROCESS)); } - /* This makes sure a task is marked as incomplete. It clears the "Date Completed" property. If the percent is set to 100 it removes it, and if the status is "Completed" it sets it to "Needs Action". @@ -410,7 +409,6 @@ typedef enum { E_CAL_MODEL_TASKS_DUE_COMPLETE } ECalModelTasksDueStatus; - static ECalModelTasksDueStatus get_due_status (ECalModelTasks *model, ECalModelComponent *comp_data) { -- cgit v1.2.3 From fa360fde289f9b850191f89059d1a5e6d67c07c7 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sat, 18 Jul 2009 14:07:42 -0400 Subject: More whitespace cleanup. --- calendar/gui/e-cal-model-tasks.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'calendar/gui/e-cal-model-tasks.c') diff --git a/calendar/gui/e-cal-model-tasks.c b/calendar/gui/e-cal-model-tasks.c index acf3175765..6d841c495e 100644 --- a/calendar/gui/e-cal-model-tasks.c +++ b/calendar/gui/e-cal-model-tasks.c @@ -444,7 +444,7 @@ get_due_status (ECalModelTasks *model, ECalModelComponent *comp_data) icalparameter *param; const gchar *tzid; - if(!(param = icalproperty_get_first_parameter (prop, ICAL_TZID_PARAMETER))) + if (!(param = icalproperty_get_first_parameter (prop, ICAL_TZID_PARAMETER))) return E_CAL_MODEL_TASKS_DUE_FUTURE; /* Get the current time in the same timezone as the DUE date.*/ @@ -1214,7 +1214,7 @@ e_cal_model_tasks_update_due_tasks (ECalModelTasks *model) { comp_data = e_cal_model_get_component_at (E_CAL_MODEL (model), row); status = get_due_status (E_CAL_MODEL_TASKS (model), comp_data); - if((status == E_CAL_MODEL_TASKS_DUE_TODAY) || (status == E_CAL_MODEL_TASKS_DUE_OVERDUE)) + if ((status == E_CAL_MODEL_TASKS_DUE_TODAY) || (status == E_CAL_MODEL_TASKS_DUE_OVERDUE)) { e_table_model_pre_change (E_TABLE_MODEL (model)); e_table_model_row_changed (E_TABLE_MODEL (model), row); -- cgit v1.2.3 From de85e3c7862100da10fe860aef2b651245a1fdbf Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sat, 1 Aug 2009 07:29:41 -0400 Subject: Replace more "config" classes with property bindings. --- calendar/gui/e-cal-model-tasks.c | 250 ++++++++++++++++++++++++++++++--------- 1 file changed, 193 insertions(+), 57 deletions(-) (limited to 'calendar/gui/e-cal-model-tasks.c') diff --git a/calendar/gui/e-cal-model-tasks.c b/calendar/gui/e-cal-model-tasks.c index 6d841c495e..10e59d08af 100644 --- a/calendar/gui/e-cal-model-tasks.c +++ b/calendar/gui/e-cal-model-tasks.c @@ -36,12 +36,15 @@ #include "e-cell-date-edit-text.h" #include "misc.h" +#define E_CAL_MODEL_TASKS_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_CAL_MODEL_TASKS, ECalModelTasksPrivate)) + struct _ECalModelTasksPrivate { - guint reserved; + gchar *color_due_today; + gchar *color_overdue; }; -static void e_cal_model_tasks_finalize (GObject *object); - static gint ecmt_column_count (ETableModel *etm); static gpointer ecmt_value_at (ETableModel *etm, gint col, gint row); static void ecmt_set_value_at (ETableModel *etm, gint col, gint row, gconstpointer value); @@ -59,56 +62,153 @@ static void commit_component_changes (ECalModelComponent *comp_data); G_DEFINE_TYPE (ECalModelTasks, e_cal_model_tasks, E_TYPE_CAL_MODEL) +enum { + PROP_0, + PROP_COLOR_DUE_TODAY, + PROP_COLOR_OVERDUE +}; + static void -e_cal_model_tasks_class_init (ECalModelTasksClass *klass) +cal_model_tasks_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) { - GObjectClass *object_class = G_OBJECT_CLASS (klass); - ETableModelClass *etm_class = E_TABLE_MODEL_CLASS (klass); - ECalModelClass *model_class = E_CAL_MODEL_CLASS (klass); - - object_class->finalize = e_cal_model_tasks_finalize; - - etm_class->column_count = ecmt_column_count; - etm_class->value_at = ecmt_value_at; - etm_class->set_value_at = ecmt_set_value_at; - etm_class->is_cell_editable = ecmt_is_cell_editable; - etm_class->duplicate_value = ecmt_duplicate_value; - etm_class->free_value = ecmt_free_value; - etm_class->initialize_value = ecmt_initialize_value; - etm_class->value_is_empty = ecmt_value_is_empty; - etm_class->value_to_string = ecmt_value_to_string; - - model_class->get_color_for_component = ecmt_get_color_for_component; - model_class->fill_component_from_model = ecmt_fill_component_from_model; + switch (property_id) { + 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_COLOR_OVERDUE: + e_cal_model_tasks_set_color_overdue ( + E_CAL_MODEL_TASKS (object), + g_value_get_string (value)); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } static void -e_cal_model_tasks_init (ECalModelTasks *model) +cal_model_tasks_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_COLOR_DUE_TODAY: + g_value_set_string ( + value, + e_cal_model_tasks_get_color_due_today ( + E_CAL_MODEL_TASKS (object))); + return; + + case PROP_COLOR_OVERDUE: + g_value_set_string ( + value, + e_cal_model_tasks_get_color_overdue ( + E_CAL_MODEL_TASKS (object))); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +cal_model_tasks_finalize (GObject *object) { ECalModelTasksPrivate *priv; - priv = g_new0 (ECalModelTasksPrivate, 1); - model->priv = priv; + priv = E_CAL_MODEL_TASKS_GET_PRIVATE (object); + + g_free (priv->color_due_today); + g_free (priv->color_overdue); - e_cal_model_set_component_kind (E_CAL_MODEL (model), ICAL_VTODO_COMPONENT); + /* Chain up to parent's finalize() method. */ + G_OBJECT_CLASS (e_cal_model_tasks_parent_class)->finalize (object); } static void -e_cal_model_tasks_finalize (GObject *object) +cal_model_tasks_constructed (GObject *object) { - ECalModelTasksPrivate *priv; - ECalModelTasks *model = (ECalModelTasks *) object; + ECalModel *model; + EShellSettings *shell_settings; - g_return_if_fail (E_IS_CAL_MODEL_TASKS (model)); + model = E_CAL_MODEL (object); + shell_settings = e_cal_model_get_shell_settings (model); - priv = model->priv; - if (priv) { - g_free (priv); - model->priv = NULL; - } + e_binding_new ( + G_OBJECT (shell_settings), "cal-tasks-color-due-today", + G_OBJECT (model), "color-due-today"); + + e_binding_new ( + G_OBJECT (shell_settings), "cal-tasks-color-overdue", + G_OBJECT (model), "color-overdue"); + + /* Chain up to parent's constructed() method. */ + G_OBJECT_CLASS (e_cal_model_tasks_parent_class)->constructed (object); +} + +static void +e_cal_model_tasks_class_init (ECalModelTasksClass *class) +{ + GObjectClass *object_class; + ETableModelClass *table_model_class; + ECalModelClass *cal_model_class; + + g_type_class_add_private (class, sizeof (ECalModelTasksPrivate)); + + object_class = G_OBJECT_CLASS (class); + object_class->set_property = cal_model_tasks_set_property; + object_class->get_property = cal_model_tasks_get_property; + object_class->finalize = cal_model_tasks_finalize; + object_class->constructed = cal_model_tasks_constructed; + + table_model_class = E_TABLE_MODEL_CLASS (class); + table_model_class->column_count = ecmt_column_count; + table_model_class->value_at = ecmt_value_at; + table_model_class->set_value_at = ecmt_set_value_at; + table_model_class->is_cell_editable = ecmt_is_cell_editable; + table_model_class->duplicate_value = ecmt_duplicate_value; + table_model_class->free_value = ecmt_free_value; + table_model_class->initialize_value = ecmt_initialize_value; + table_model_class->value_is_empty = ecmt_value_is_empty; + table_model_class->value_to_string = ecmt_value_to_string; + + cal_model_class = E_CAL_MODEL_CLASS (class); + cal_model_class->get_color_for_component = ecmt_get_color_for_component; + cal_model_class->fill_component_from_model = ecmt_fill_component_from_model; + + g_object_class_install_property ( + object_class, + PROP_COLOR_DUE_TODAY, + g_param_spec_string ( + "color-due-today", + "Color Due Today", + NULL, + "#1e90ff", + G_PARAM_READWRITE)); + + g_object_class_install_property ( + object_class, + PROP_COLOR_OVERDUE, + g_param_spec_string ( + "color-overdue", + "Color Overdue", + NULL, + "#ff0000", + G_PARAM_READWRITE)); +} + +static void +e_cal_model_tasks_init (ECalModelTasks *model) +{ + model->priv = E_CAL_MODEL_TASKS_GET_PRIVATE (model); - if (G_OBJECT_CLASS (e_cal_model_tasks_parent_class)->finalize) - G_OBJECT_CLASS (e_cal_model_tasks_parent_class)->finalize (object); + e_cal_model_set_component_kind ( + E_CAL_MODEL (model), ICAL_VTODO_COMPONENT); } /* ETableModel methods */ @@ -1038,11 +1138,9 @@ ecmt_value_to_string (ETableModel *etm, gint col, gconstpointer value) /* ECalModel class methods */ static const gchar * -ecmt_get_color_for_component (ECalModel *model, ECalModelComponent *comp_data) +ecmt_get_color_for_component (ECalModel *model, + ECalModelComponent *comp_data) { - static gchar color_spec[16]; - GdkColor color; - g_return_val_if_fail (E_IS_CAL_MODEL_TASKS (model), NULL); g_return_val_if_fail (comp_data != NULL, NULL); @@ -1051,24 +1149,19 @@ ecmt_get_color_for_component (ECalModel *model, ECalModelComponent *comp_data) switch (get_due_status ((ECalModelTasks *) model, comp_data)) { case E_CAL_MODEL_TASKS_DUE_TODAY: - /* XXX ugly hack */ - calendar_config_get_tasks_due_today_color (&color); - g_snprintf (color_spec, sizeof (color_spec), "#%04x%04x%04x", - color.red, color.green, color.blue); - return color_spec; + return e_cal_model_tasks_get_color_due_today ( + E_CAL_MODEL_TASKS (model)); case E_CAL_MODEL_TASKS_DUE_OVERDUE: - /* XXX ugly hack */ - calendar_config_get_tasks_overdue_color (&color); - g_snprintf (color_spec, sizeof (color_spec), "#%04x%04x%04x", - color.red, color.green, color.blue); - return color_spec; + return e_cal_model_tasks_get_color_overdue ( + E_CAL_MODEL_TASKS (model)); case E_CAL_MODEL_TASKS_DUE_NEVER: case E_CAL_MODEL_TASKS_DUE_FUTURE: case E_CAL_MODEL_TASKS_DUE_COMPLETE: break; } - return E_CAL_MODEL_CLASS (e_cal_model_tasks_parent_class)->get_color_for_component (model, comp_data); + return E_CAL_MODEL_CLASS (e_cal_model_tasks_parent_class)-> + get_color_for_component (model, comp_data); } static void @@ -1103,13 +1196,56 @@ ecmt_fill_component_from_model (ECalModel *model, ECalModelComponent *comp_data, e_table_model_value_at (source_model, E_CAL_MODEL_TASKS_FIELD_URL, row)); } -/** - * e_cal_model_tasks_new - */ ECalModel * -e_cal_model_tasks_new (void) +e_cal_model_tasks_new (EShellSettings *shell_settings) +{ + g_return_val_if_fail (E_IS_SHELL_SETTINGS (shell_settings), NULL); + + return g_object_new ( + E_TYPE_CAL_MODEL_TASKS, + "shell-settings", shell_settings, NULL); +} + +const gchar * +e_cal_model_tasks_get_color_due_today (ECalModelTasks *model) +{ + g_return_val_if_fail (E_IS_CAL_MODEL_TASKS (model), NULL); + + return model->priv->color_due_today; +} + +void +e_cal_model_tasks_set_color_due_today (ECalModelTasks *model, + const gchar *color_due_today) +{ + g_return_if_fail (E_IS_CAL_MODEL_TASKS (model)); + g_return_if_fail (color_due_today != NULL); + + g_free (model->priv->color_due_today); + model->priv->color_due_today = g_strdup (color_due_today); + + g_object_notify (G_OBJECT (model), "color-due-today"); +} + +const gchar * +e_cal_model_tasks_get_color_overdue (ECalModelTasks *model) +{ + g_return_val_if_fail (E_IS_CAL_MODEL_TASKS (model), NULL); + + return model->priv->color_overdue; +} + +void +e_cal_model_tasks_set_color_overdue (ECalModelTasks *model, + const gchar *color_overdue) { - return g_object_new (E_TYPE_CAL_MODEL_TASKS, NULL); + g_return_if_fail (E_IS_CAL_MODEL_TASKS (model)); + g_return_if_fail (color_overdue != NULL); + + g_free (model->priv->color_overdue); + model->priv->color_overdue = g_strdup (color_overdue); + + g_object_notify (G_OBJECT (model), "color-overdue"); } /** -- cgit v1.2.3 From 672adf12a0923437e90d08ab7925bd9329fcce0d Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sun, 16 Aug 2009 11:25:08 -0400 Subject: Fix compiler warnings and deprecated GTK+ API usage. --- calendar/gui/e-cal-model-tasks.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'calendar/gui/e-cal-model-tasks.c') diff --git a/calendar/gui/e-cal-model-tasks.c b/calendar/gui/e-cal-model-tasks.c index 10e59d08af..74647e46dc 100644 --- a/calendar/gui/e-cal-model-tasks.c +++ b/calendar/gui/e-cal-model-tasks.c @@ -31,6 +31,8 @@ #include #include #include + +#include "e-util/e-binding.h" #include "calendar-config.h" #include "e-cal-model-tasks.h" #include "e-cell-date-edit-text.h" -- cgit v1.2.3