aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
authorChenthill Palanisamy <pchen@src.gnome.org>2008-09-08 17:31:56 +0800
committerChenthill Palanisamy <pchen@src.gnome.org>2008-09-08 17:31:56 +0800
commitd620820eab5d5f3814debb1b5f0dc7c5a7138973 (patch)
treebdc2e6435990c7425142b18acfac1148dea90978 /calendar
parentc61bef657d2e6c8ab82573f6366761000881db9e (diff)
downloadgsoc2013-evolution-d620820eab5d5f3814debb1b5f0dc7c5a7138973.tar
gsoc2013-evolution-d620820eab5d5f3814debb1b5f0dc7c5a7138973.tar.gz
gsoc2013-evolution-d620820eab5d5f3814debb1b5f0dc7c5a7138973.tar.bz2
gsoc2013-evolution-d620820eab5d5f3814debb1b5f0dc7c5a7138973.tar.lz
gsoc2013-evolution-d620820eab5d5f3814debb1b5f0dc7c5a7138973.tar.xz
gsoc2013-evolution-d620820eab5d5f3814debb1b5f0dc7c5a7138973.tar.zst
gsoc2013-evolution-d620820eab5d5f3814debb1b5f0dc7c5a7138973.zip
Fixes #544187.
svn path=/trunk/; revision=36276
Diffstat (limited to 'calendar')
-rw-r--r--calendar/ChangeLog9
-rw-r--r--calendar/gui/e-cal-model.c124
-rw-r--r--calendar/gui/e-cal-model.h1
-rw-r--r--calendar/gui/e-day-view.c16
-rw-r--r--calendar/gui/e-week-view.c15
5 files changed, 135 insertions, 30 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index ab31823153..7f04a4c43b 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,12 @@
+2008-09-08 Chenthill Palanisamy <pchenthill@novell.com>
+
+ Fixes #544187
+ * calendar/gui/e-cal-model.c:
+ * calendar/gui/e-cal-model.h:
+ * calendar/gui/e-day-view.c:
+ * calendar/gui/e-week-view.c: Added a new signal
+ handler to update the views on comp deletion.
+
2008-09-06 Matthew Barnes <mbarnes@redhat.com>
** Fixes part of bug #549968
diff --git a/calendar/gui/e-cal-model.c b/calendar/gui/e-cal-model.c
index 42702c1416..d78e4f5dbc 100644
--- a/calendar/gui/e-cal-model.c
+++ b/calendar/gui/e-cal-model.c
@@ -109,6 +109,7 @@ static void remove_client (ECalModel *model, ECalModelClient *client_data);
enum {
TIME_RANGE_CHANGED,
ROW_APPENDED,
+ COMPS_DELETED,
CAL_VIEW_PROGRESS,
CAL_VIEW_DONE,
LAST_SIGNAL
@@ -159,6 +160,16 @@ e_cal_model_class_init (ECalModelClass *klass)
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
+
+ signals[COMPS_DELETED] =
+ g_signal_new ("comps_deleted",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (ECalModelClass, comps_deleted),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE, 1, G_TYPE_POINTER);
+
signals[CAL_VIEW_PROGRESS] =
g_signal_new ("cal_view_progress",
G_TYPE_FROM_CLASS (klass),
@@ -1431,13 +1442,21 @@ e_cal_view_objects_added_cb (ECalView *query, GList *objects, gpointer user_data
while ((comp_data = search_by_id_and_client (priv, client,
id))) {
int pos;
+ GSList *list = NULL;
pos = get_position_in_array (priv->objects, comp_data);
+
+ if (!g_ptr_array_remove (priv->objects, comp_data))
+ continue;
+
+ list = g_slist_append (list, comp_data);
+ g_signal_emit (G_OBJECT (model), signals[COMPS_DELETED], 0, list);
+
+ g_slist_free (list);
+ g_object_unref (comp_data);
+
e_table_model_pre_change (E_TABLE_MODEL (model));
e_table_model_row_deleted (E_TABLE_MODEL (model), pos);
-
- if (g_ptr_array_remove (priv->objects, comp_data))
- e_cal_model_free_component_data (comp_data);
}
e_cal_component_free_id (id);
@@ -1473,9 +1492,45 @@ static void
e_cal_view_objects_modified_cb (ECalView *query, GList *objects, gpointer user_data)
{
ECalModel *model = (ECalModel *) user_data;
+ ECalModelPrivate *priv;
+ GList *l, *list = NULL;
+
+ priv = model->priv;
+
+ /* re-add only the recurrence objects */
+ for (l = objects; l != NULL; l = g_list_next (l)) {
+ if (e_cal_util_component_has_recurrences (l->data) && (priv->flags & E_CAL_MODEL_FLAGS_EXPAND_RECURRENCES))
+ g_list_prepend (list, l->data);
+ else {
+ int pos;
+ ECalModelComponent *comp_data;
+ ECalComponentId *id;
+ ECalComponent *comp = e_cal_component_new ();
+ ECal *client = e_cal_view_get_client (query);
+
+ if (!e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (l->data))) {
+ g_object_unref (comp);
+ continue;
+ }
+
+ e_table_model_pre_change (E_TABLE_MODEL (model));
+
+ id = e_cal_component_get_id (comp);
+
+ comp_data = search_by_id_and_client (priv, client, id);
+ icalcomponent_free (comp_data->icalcomp);
+
+ comp_data->icalcomp = icalcomponent_new_clone (l->data);
+ e_cal_model_set_instance_times (comp_data, priv->zone);
+
+ pos = get_position_in_array (priv->objects, comp_data);
+
+ e_table_model_row_changed (E_TABLE_MODEL (model), pos);
+ }
+ }
- /* now re-add all objects */
- e_cal_view_objects_added_cb (query, objects, model);
+ e_cal_view_objects_added_cb (query, list, model);
+ g_list_free (list);
}
static void
@@ -1494,13 +1549,21 @@ e_cal_view_objects_removed_cb (ECalView *query, GList *ids, gpointer user_data)
/* make sure we remove all objects with this UID */
while ((comp_data = search_by_id_and_client (priv, e_cal_view_get_client (query), id))) {
+ GSList *l = NULL;
+
pos = get_position_in_array (priv->objects, comp_data);
+ if (!g_ptr_array_remove (priv->objects, comp_data))
+ continue;
+
+ l = g_slist_append (l, comp_data);
+ g_signal_emit (G_OBJECT (model), signals[COMPS_DELETED], 0, l);
+
+ g_slist_free (l);
+ g_object_unref (comp_data);
+
e_table_model_pre_change (E_TABLE_MODEL (model));
e_table_model_row_deleted (E_TABLE_MODEL (model), pos);
-
- if (g_ptr_array_remove (priv->objects, comp_data))
- e_cal_model_free_component_data (comp_data);
}
}
@@ -1692,11 +1755,18 @@ remove_client_objects (ECalModel *model, ECalModelClient *client_data)
g_return_if_fail (comp_data != NULL);
if (comp_data->client == client_data->client) {
- e_table_model_pre_change (E_TABLE_MODEL (model));
- e_table_model_row_deleted (E_TABLE_MODEL (model), i - 1);
+ GSList *l = NULL;
g_ptr_array_remove (model->priv->objects, comp_data);
- e_cal_model_free_component_data (comp_data);
+
+ l = g_slist_append (l, comp_data);
+ g_signal_emit (G_OBJECT (model), signals[COMPS_DELETED], 0, l);
+
+ g_slist_free (l);
+ g_object_unref (comp_data);
+
+ e_table_model_pre_change (E_TABLE_MODEL (model));
+ e_table_model_row_deleted (E_TABLE_MODEL (model), i - 1);
}
}
@@ -1768,11 +1838,34 @@ e_cal_model_remove_all_clients (ECalModel *model)
}
}
+static GSList *
+get_objects_as_list (ECalModel *model)
+{
+ gint i;
+ GSList *l = NULL;
+ ECalModelPrivate *priv = model->priv;
+
+ for (i = 0; i < priv->objects->len; i++) {
+ ECalModelComponent *comp_data;
+
+ comp_data = g_ptr_array_index (priv->objects, i);
+ if (comp_data == NULL) {
+ g_warning ("comp_data is null\n");
+ continue;
+ }
+
+ l = g_slist_prepend (l, comp_data);
+ }
+
+ return l;
+}
+
static void
redo_queries (ECalModel *model)
{
ECalModelPrivate *priv;
GList *l;
+ GSList *sl, *slist;
int len;
priv = model->priv;
@@ -1802,8 +1895,15 @@ redo_queries (ECalModel *model)
/* clean up the current contents */
e_table_model_pre_change (E_TABLE_MODEL (model));
len = priv->objects->len;
+
+ slist = get_objects_as_list (model);
+ g_ptr_array_set_size (priv->objects, 0);
+ g_signal_emit (G_OBJECT (model), signals[COMPS_DELETED], 0, slist);
+
e_table_model_rows_deleted (E_TABLE_MODEL (model), 0, len);
- clear_objects_array (priv);
+
+ g_slist_foreach (slist, (GFunc)g_object_unref, NULL);
+ g_slist_free (slist);
/* update the query for all clients */
for (l = priv->clients; l != NULL; l = l->next) {
diff --git a/calendar/gui/e-cal-model.h b/calendar/gui/e-cal-model.h
index edaecfe95f..ad9bc7d9ae 100644
--- a/calendar/gui/e-cal-model.h
+++ b/calendar/gui/e-cal-model.h
@@ -116,6 +116,7 @@ typedef struct {
/* Signals */
void (* time_range_changed) (ECalModel *model, time_t start, time_t end);
void (* row_appended) (ECalModel *model);
+ void (* comps_deleted) (ECalModel *model, gpointer list);
void (* cal_view_progress) (ECalModel *model, const char *message, int progress, ECalSourceType type);
void (* cal_view_done) (ECalModel *model, ECalendarStatus status, ECalSourceType type);
} ECalModelClass;
diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c
index ebf17eff78..f1fb84cd3c 100644
--- a/calendar/gui/e-day-view.c
+++ b/calendar/gui/e-day-view.c
@@ -624,10 +624,10 @@ model_rows_inserted_cb (ETableModel *etm, int row, int count, gpointer user_data
}
static void
-model_rows_deleted_cb (ETableModel *etm, int row, int count, gpointer user_data)
+model_comps_deleted_cb (ETableModel *etm, gpointer data, gpointer user_data)
{
EDayView *day_view = E_DAY_VIEW (user_data);
- int i;
+ GSList *l, *list = data;
if (!E_CALENDAR_VIEW (day_view)->in_focus) {
return;
@@ -635,15 +635,12 @@ model_rows_deleted_cb (ETableModel *etm, int row, int count, gpointer user_data)
e_day_view_stop_editing_event (day_view);
- for (i = row + count; i > row; i--) {
+ for (l = list; l != NULL; l = g_slist_next (l)) {
+ ECalModelComponent *comp_data = l->data;
gint day, event_num;
const char *uid = NULL;
char *rid = NULL;
- ECalModelComponent *comp_data;
- comp_data = e_cal_model_get_component_at (E_CAL_MODEL (etm), i - 1);
- if (!comp_data)
- continue;
uid = icalcomponent_get_uid (comp_data->icalcomp);
if (e_cal_util_component_is_instance (comp_data->icalcomp)) {
@@ -656,6 +653,7 @@ model_rows_deleted_cb (ETableModel *etm, int row, int count, gpointer user_data)
if (e_day_view_find_event_from_uid (day_view, comp_data->client, uid, rid, &day, &event_num))
e_day_view_remove_event_cb (day_view, day, event_num, NULL);
+
g_free (rid);
}
@@ -1024,8 +1022,8 @@ init_model (EDayView *day_view, ECalModel *model)
G_CALLBACK (model_cell_changed_cb), day_view);
g_signal_connect (G_OBJECT (model), "model_rows_inserted",
G_CALLBACK (model_rows_inserted_cb), day_view);
- g_signal_connect (G_OBJECT (model), "model_rows_deleted",
- G_CALLBACK (model_rows_deleted_cb), day_view);
+ g_signal_connect (G_OBJECT (model), "comps_deleted",
+ G_CALLBACK (model_comps_deleted_cb), day_view);
}
/* Turn off the background of the canvas windows. This reduces flicker
diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c
index aa459f817d..9e3ea5d30e 100644
--- a/calendar/gui/e-week-view.c
+++ b/calendar/gui/e-week-view.c
@@ -401,25 +401,22 @@ model_rows_inserted_cb (ETableModel *etm, int row, int count, gpointer user_data
}
static void
-model_rows_deleted_cb (ETableModel *etm, int row, int count, gpointer user_data)
+model_comps_deleted_cb (ETableModel *etm, gpointer data, gpointer user_data)
{
EWeekView *week_view = E_WEEK_VIEW (user_data);
int i;
+ GSList *l, *list = data;
/* FIXME Stop editing? */
if (!E_CALENDAR_VIEW (week_view)->in_focus) {
return;
}
- for (i = row + count; i > row; i--) {
+ for (l = list; l != NULL; l = g_slist_next (l)) {
gint event_num;
const char *uid;
char *rid = NULL;
- ECalModelComponent *comp_data;
-
- comp_data = e_cal_model_get_component_at (E_CAL_MODEL (etm), i - 1);
- if (!comp_data)
- continue;
+ ECalModelComponent *comp_data = l->data;
uid = icalcomponent_get_uid (comp_data->icalcomp);
if (e_cal_util_component_is_instance (comp_data->icalcomp)) {
@@ -626,8 +623,8 @@ init_model (EWeekView *week_view, ECalModel *model)
G_CALLBACK (model_cell_changed_cb), week_view);
g_signal_connect (G_OBJECT (model), "model_rows_inserted",
G_CALLBACK (model_rows_inserted_cb), week_view);
- g_signal_connect (G_OBJECT (model), "model_rows_deleted",
- G_CALLBACK (model_rows_deleted_cb), week_view);
+ g_signal_connect (G_OBJECT (model), "comps_deleted",
+ G_CALLBACK (model_comps_deleted_cb), week_view);
}