[evolution-patches] Fix for #264449 [Tasks]
- From: "Jukaku Mubeen" <jmubeen novell com>
- To: <evolution-patches lists ximian com>
- Subject: [evolution-patches] Fix for #264449 [Tasks]
- Date: Tue, 23 Aug 2005 05:18:51 -0600
Hi,
Attached patch fixes #264449. It solves the tasks refresh problem.
Thanks
Mubeen
Index: calendar/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/calendar/ChangeLog,v
retrieving revision 1.2800
diff -u -p -r1.2800 ChangeLog
--- calendar/ChangeLog 19 Aug 2005 13:11:55 -0000 1.2800
+++ calendar/ChangeLog 23 Aug 2005 10:53:59 -0000
@@ -1,3 +1,17 @@
+2005-08-23 Mohammed Mubeen <jmubeen novell com>
+
+ Fixes #264449
+ * gui/e-tasks.c: (update_view_cb): Use hide_completed_tasks
+ instead of update_view.
+ * gui/gnome-cal.c: ditto
+ * gui/calendar-config.[ch]: New function
+ calendar_config_get_hide_completed_tasks_sexp2 to filter completed
+ tasks.
+ * gui/e-cal-model.[ch]: Added wrapper functions
+ e_cal_model_search_by_uid_and_client,
+ e_cal_model_get_position_in_array,
+ and e_cal_model_remove_component_data.
+
2005-08-19 Harish Krishnaswamy <kharish novell com>
* gui/dialogs/comp-editor.h: Remove unwanted include of
Index: calendar/gui/e-tasks.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-tasks.c,v
retrieving revision 1.119
diff -u -p -r1.119 e-tasks.c
--- calendar/gui/e-tasks.c 9 Aug 2005 21:46:34 -0000 1.119
+++ calendar/gui/e-tasks.c 23 Aug 2005 10:54:42 -0000
@@ -55,6 +55,7 @@
#include "e-tasks.h"
#include "common/authentication.h"
#include "e-cal-menu.h"
+#include "e-cal-model.h"
/* Private part of the GnomeCalendar structure */
@@ -301,10 +302,68 @@ update_view (ETasks *tasks)
e_cal_component_preview_clear (E_CAL_COMPONENT_PREVIEW (priv->preview));
}
+static void
+delete_rows (ETasks *tasks, ECalModel *model, const char *sexp)
+{
+ ETasksPrivate *priv;
+ GList *l;
+
+ g_return_if_fail (tasks != NULL);
+ g_return_if_fail (E_IS_TASKS (tasks));
+
+ priv = tasks->priv;
+
+ for (l = priv->clients_list; l != NULL; l = l->next) {
+ ECal *client = l->data;
+ GList *objects = NULL, *m;
+
+ if (!e_cal_get_object_list (client, sexp, &objects, NULL)) {
+ g_warning (G_STRLOC ": Could not get the objects");
+
+ continue;
+ }
+
+ for (m = objects; m; m = m->next) {
+ ECalModelComponent *comp_data;
+ int pos;
+
+ e_table_model_pre_change (E_TABLE_MODEL (model));
+
+ if ((comp_data = e_cal_model_search_by_uid_and_client (model, client, icalcomponent_get_uid (m->data)))) {
+ pos = e_cal_model_get_position_in_array (model, comp_data);
+ e_table_model_row_deleted (E_TABLE_MODEL (model), pos);
+
+ e_cal_model_remove_component_data (model, comp_data);
+ e_cal_model_free_component_data (comp_data);
+ }
+ }
+
+ g_list_foreach (objects, (GFunc) icalcomponent_free, NULL);
+ g_list_free (objects);
+ }
+}
+
+static void
+hide_completed_tasks (ETasks *tasks)
+{
+ ETasksPrivate *priv;
+ ECalModel *model;
+ char *new_sexp = NULL;
+
+ priv = tasks->priv;
+
+ model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->tasks_view));
+
+ if ((new_sexp = calendar_config_get_hide_completed_tasks_sexp2 ()) != NULL) {
+ delete_rows (tasks, model, new_sexp);
+ g_free (new_sexp);
+ }
+}
+
static gboolean
update_view_cb (ETasks *tasks)
{
- update_view (tasks);
+ hide_completed_tasks (tasks);
return TRUE;
}
Index: calendar/gui/gnome-cal.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/gnome-cal.c,v
retrieving revision 1.385
diff -u -p -r1.385 gnome-cal.c
--- calendar/gui/gnome-cal.c 4 Aug 2005 10:17:43 -0000 1.385
+++ calendar/gui/gnome-cal.c 23 Aug 2005 10:55:34 -0000
@@ -81,6 +81,7 @@
#include "common/authentication.h"
#include "e-cal-popup.h"
#include "e-cal-menu.h"
+#include "e-cal-model.h"
/* FIXME glib 2.4 and above has this */
#ifndef G_MAXINT32
@@ -1146,10 +1147,68 @@ update_todo_view (GnomeCalendar *gcal)
}
+static void
+delete_rows (GnomeCalendar *gcal, ECalModel *model, const char *sexp)
+{
+ GnomeCalendarPrivate *priv;
+ GList *l;
+
+ g_return_if_fail (gcal != NULL);
+ g_return_if_fail (GNOME_IS_CALENDAR(gcal));
+
+ priv = gcal->priv;
+
+ for (l = priv->clients_list[E_CAL_SOURCE_TYPE_TODO]; l != NULL; l = l->next) {
+ ECal *client = l->data;
+ GList *objects = NULL, *m;
+
+ if (!e_cal_get_object_list (client, sexp, &objects, NULL)) {
+ g_warning (G_STRLOC ": Could not get the objects");
+
+ continue;
+ }
+
+ for (m = objects; m; m = m->next) {
+ ECalModelComponent *comp_data;
+ int pos;
+
+ e_table_model_pre_change (E_TABLE_MODEL (model));
+
+ if ((comp_data = e_cal_model_search_by_uid_and_client (model, client, icalcomponent_get_uid (m->data)))) {
+ pos = e_cal_model_get_position_in_array (model, comp_data);
+ e_table_model_row_deleted (E_TABLE_MODEL (model), pos);
+
+ e_cal_model_remove_component_data (model, comp_data);
+ e_cal_model_free_component_data (comp_data);
+ }
+ }
+
+ g_list_foreach (objects, (GFunc) icalcomponent_free, NULL);
+ g_list_free (objects);
+ }
+}
+
+static void
+hide_completed_tasks (GnomeCalendar *gcal)
+{
+ GnomeCalendarPrivate *priv;
+ ECalModel *model;
+ char *new_sexp = NULL;
+
+ priv = gcal->priv;
+
+ model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->todo));
+
+ if ((new_sexp = calendar_config_get_hide_completed_tasks_sexp2 ()) != NULL) {
+ delete_rows (gcal, model, new_sexp);
+ g_free (new_sexp);
+ }
+}
+
static gboolean
update_todo_view_cb (GnomeCalendar *gcal)
{
- update_todo_view(gcal);
+ hide_completed_tasks (gcal);
return TRUE;
}
Index: calendar/gui/calendar-config.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/calendar-config.c,v
retrieving revision 1.77
diff -u -p -r1.77 calendar-config.c
--- calendar/gui/calendar-config.c 13 Jul 2005 10:36:14 -0000 1.77
+++ calendar/gui/calendar-config.c 23 Aug 2005 10:56:37 -0000
@@ -1133,6 +1133,65 @@ calendar_config_get_hide_completed_tasks
return sexp;
}
+/**
+ * calendar_config_get_hide_completed_tasks_sexp2:
+ *
+ * Returns the subexpression to use to filter out completed tasks according
+ * to the config settings. The returned sexp should be freed.
+ **/
+char *
+calendar_config_get_hide_completed_tasks_sexp2 (void)
+{
+ char *sexp = NULL;
+
+ if (calendar_config_get_hide_completed_tasks ()) {
+ CalUnits units;
+ gint value;
+
+ units = calendar_config_get_hide_completed_tasks_units ();
+ value = calendar_config_get_hide_completed_tasks_value ();
+
+ if (value == 0) {
+ /* If the value is 0, we want to hide completed tasks
+ immediately, so we filter out all completed tasks.*/
+ sexp = g_strdup ("(is-completed?)");
+ } else {
+ char *isodate;
+ icaltimezone *zone;
+ struct icaltimetype tt;
+ time_t t;
+
+ /* Get the current time, and subtract the appropriate
+ number of days/hours/minutes. */
+ zone = calendar_config_get_icaltimezone ();
+ tt = icaltime_current_time_with_zone (zone);
+
+ switch (units) {
+ case CAL_DAYS:
+ icaltime_adjust (&tt, -value, 0, 0, 0);
+ break;
+ case CAL_HOURS:
+ icaltime_adjust (&tt, 0, -value, 0, 0);
+ break;
+ case CAL_MINUTES:
+ icaltime_adjust (&tt, 0, 0, -value, 0);
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+
+ t = icaltime_as_timet_with_zone (tt, zone);
+
+ /* Convert the time to an ISO date string, and build
+ the query sub-expression. */
+ isodate = isodate_from_time_t (t);
+ sexp = g_strdup_printf ("(completed-before? (make-time \"%s\"))", isodate);
+ }
+ }
+
+ return sexp;
+}
+
GSList *
calendar_config_get_free_busy (void)
{
Index: calendar/gui/e-cal-model.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-cal-model.c,v
retrieving revision 1.60
diff -u -p -r1.60 e-cal-model.c
--- calendar/gui/e-cal-model.c 22 Jul 2005 11:41:35 -0000 1.60
+++ calendar/gui/e-cal-model.c 23 Aug 2005 10:57:05 -0000
@@ -1279,6 +1279,24 @@ get_position_in_array (GPtrArray *object
return -1;
}
+ECalModelComponent *
+e_cal_model_search_by_uid_and_client (ECalModel *model, ECal *client, const char *uid)
+{
+ return search_by_uid_and_client (model->priv, client, uid);
+}
+
+gint
+e_cal_model_get_position_in_array (ECalModel *model, gpointer item)
+{
+ return get_position_in_array (model->priv->objects, item);
+}
+
+gboolean
+e_cal_model_remove_component_data (ECalModel *model, gpointer comp_data)
+{
+ return g_ptr_array_remove (model->priv->objects, comp_data);
+}
+
typedef struct {
ECal *client;
ECalView *query;
Index: calendar/gui/calendar-config.h
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/calendar-config.h,v
retrieving revision 1.39
diff -u -p -r1.39 calendar-config.h
--- calendar/gui/calendar-config.h 30 May 2005 09:14:26 -0000 1.39
+++ calendar/gui/calendar-config.h 23 Aug 2005 10:57:50 -0000
@@ -184,6 +184,7 @@ void calendar_config_set_hide_complete
guint calendar_config_add_notification_hide_completed_tasks_value (GConfClientNotifyFunc func, gpointer data);
char* calendar_config_get_hide_completed_tasks_sexp (void);
+char * calendar_config_get_hide_completed_tasks_sexp2 (void);
/* Confirmation options */
gboolean calendar_config_get_confirm_delete (void);
Index: calendar/gui/e-cal-model.h
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-cal-model.h,v
retrieving revision 1.16
diff -u -p -r1.16 e-cal-model.h
--- calendar/gui/e-cal-model.h 2 Jul 2005 14:54:44 -0000 1.16
+++ calendar/gui/e-cal-model.h 23 Aug 2005 10:58:06 -0000
@@ -152,6 +152,9 @@ void e_cal_model_generate
time_t end,
ECalRecurInstanceFn cb,
gpointer cb_data);
+ECalModelComponent * e_cal_model_search_by_uid_and_client (ECalModel *model, ECal *client, const char *uid);
+gint e_cal_model_get_position_in_array (ECalModel *model, gpointer item);
+gboolean e_cal_model_remove_component_data (ECalModel *model, gpointer comp_data);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]