[evolution/gnome-2-32] Order matters, process master object first, then detached instances (cherry picked from commit b1008
- From: David Woodhouse <dwmw2 src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/gnome-2-32] Order matters, process master object first, then detached instances (cherry picked from commit b1008
- Date: Fri, 8 Apr 2011 15:17:02 +0000 (UTC)
commit 226430c112e9f98b6b63439c63a4a8e7279ad933
Author: Milan Crha <mcrha redhat com>
Date: Thu Feb 17 19:33:58 2011 +0100
Order matters, process master object first, then detached instances
(cherry picked from commit b1008815feab6b7a95fd0f11c18a7f018b1a605b)
(Bug 646164)
calendar/gui/e-cal-model.c | 42 ++++++++++++++++++++++++++++++++++++++++--
1 files changed, 40 insertions(+), 2 deletions(-)
---
diff --git a/calendar/gui/e-cal-model.c b/calendar/gui/e-cal-model.c
index d46302c..8f26881 100644
--- a/calendar/gui/e-cal-model.c
+++ b/calendar/gui/e-cal-model.c
@@ -1722,17 +1722,53 @@ ensure_dates_are_in_default_zone (ECalModel *model,
}
}
+static gint
+place_master_object_first_cb (gconstpointer p1, gconstpointer p2)
+{
+ icalcomponent *c1 = (icalcomponent *) p1, *c2 = (icalcomponent *) p2;
+ const gchar *uid1, *uid2;
+ gint res;
+
+ g_return_val_if_fail (c1 != NULL, 0);
+ g_return_val_if_fail (c2 != NULL, 0);
+
+ uid1 = icalcomponent_get_uid (c1);
+ uid2 = icalcomponent_get_uid (c2);
+
+ res = g_strcmp0 (uid1, uid2);
+ if (res == 0) {
+ struct icaltimetype rid1, rid2;
+
+ rid1 = icalcomponent_get_recurrenceid (c1);
+ rid2 = icalcomponent_get_recurrenceid (c2);
+
+ if (icaltime_is_null_time (rid1)) {
+ if (!icaltime_is_null_time (rid2))
+ res = -1;
+ } else if (icaltime_is_null_time (rid2)) {
+ res = 1;
+ } else {
+ res = icaltime_compare (rid1, rid2);
+ }
+ }
+
+ return res;
+}
+
static void e_cal_view_objects_added_cb (ECalView *query, GList *objects, ECalModel *model);
static void
process_added (ECalView *query, GList *objects, ECalModel *model)
{
ECalModelPrivate *priv;
- GList *l;
+ GList *l, *copy;
priv = model->priv;
- for (l = objects; l; l = l->next) {
+ /* order matters, process master object first, then detached instances */
+ copy = g_list_sort (g_list_copy (objects), place_master_object_first_cb);
+
+ for (l = copy; l; l = l->next) {
ECalModelComponent *comp_data;
ECalComponentId *id;
ECalComponent *comp = e_cal_component_new ();
@@ -1794,6 +1830,8 @@ process_added (ECalView *query, GList *objects, ECalModel *model)
e_table_model_row_inserted (E_TABLE_MODEL (model), priv->objects->len - 1);
}
}
+
+ g_list_free (copy);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]