aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@helixcode.com>2000-09-14 05:38:12 +0800
committerFederico Mena Quintero <federico@src.gnome.org>2000-09-14 05:38:12 +0800
commit1657cfe34134673a5a09b2e62a9044eca8a6ea09 (patch)
tree05e0f5c88debcfaa2d165e94e82156c8b7afb3b5
parent534132510d788bd8b3d86262ffe98a6b0ddc8cc0 (diff)
downloadgsoc2013-evolution-1657cfe34134673a5a09b2e62a9044eca8a6ea09.tar.gz
gsoc2013-evolution-1657cfe34134673a5a09b2e62a9044eca8a6ea09.tar.zst
gsoc2013-evolution-1657cfe34134673a5a09b2e62a9044eca8a6ea09.zip
See if the new object matches the type of objects we were told to deal
2000-09-13 Federico Mena Quintero <federico@helixcode.com> * gui/calendar-model.c (obj_updated_cb): See if the new object matches the type of objects we were told to deal with. (load_objects): Likewise. svn path=/trunk/; revision=5410
-rw-r--r--calendar/ChangeLog6
-rw-r--r--calendar/gui/calendar-model.c31
2 files changed, 37 insertions, 0 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 9a0b44b070..852d41d2ba 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,9 @@
+2000-09-13 Federico Mena Quintero <federico@helixcode.com>
+
+ * gui/calendar-model.c (obj_updated_cb): See if the new object
+ matches the type of objects we were told to deal with.
+ (load_objects): Likewise.
+
2000-09-13 JP Rosevear <jpr@helixcode.com>
* pcs/cal-backend-file.c (remove_component): Only remove the pilot
diff --git a/calendar/gui/calendar-model.c b/calendar/gui/calendar-model.c
index 57193f45c9..5a640fe515 100644
--- a/calendar/gui/calendar-model.c
+++ b/calendar/gui/calendar-model.c
@@ -1496,6 +1496,15 @@ remove_object (CalendarModel *model, const char *uid)
return n;
}
+/* Returns whether a component's type matches the types we support */
+static gboolean
+matches_type (CalObjType type, CalComponentVType vtype)
+{
+ return ((vtype == CAL_COMPONENT_EVENT && (type & CALOBJ_TYPE_EVENT))
+ || (vtype == CAL_COMPONENT_TODO && (type & CALOBJ_TYPE_TODO))
+ || (vtype == CAL_COMPONENT_JOURNAL && (type & CALOBJ_TYPE_JOURNAL)));
+}
+
/* Callback used when an object is updated in the server */
static void
obj_updated_cb (CalClient *client, const char *uid, gpointer data)
@@ -1504,6 +1513,7 @@ obj_updated_cb (CalClient *client, const char *uid, gpointer data)
CalendarModelPrivate *priv;
int orig_idx;
CalComponent *new_comp;
+ CalComponentVType new_comp_vtype;
const char *new_comp_uid;
int *new_idx;
CalClientGetStatus status;
@@ -1520,6 +1530,16 @@ obj_updated_cb (CalClient *client, const char *uid, gpointer data)
switch (status) {
case CAL_CLIENT_GET_SUCCESS:
+ /* Check if we are interested in this type of object */
+
+ new_comp_vtype = cal_component_get_vtype (new_comp);
+ if (!matches_type (priv->type, new_comp_vtype)) {
+ gtk_object_unref (GTK_OBJECT (new_comp));
+ break;
+ }
+
+ /* Insert the object into the model */
+
cal_component_get_uid (new_comp, &new_comp_uid);
if (orig_idx == -1) {
@@ -1622,6 +1642,7 @@ load_objects (CalendarModel *model)
CalComponent *comp;
const char *comp_uid;
CalClientGetStatus status;
+ CalComponentVType comp_vtype;
int *idx;
uid = l->data;
@@ -1643,6 +1664,16 @@ load_objects (CalendarModel *model)
g_assert_not_reached ();
}
+ /* Check if we are interested in this type of object */
+
+ comp_vtype = cal_component_get_vtype (comp);
+ if (!matches_type (priv->type, comp_vtype)) {
+ gtk_object_unref (GTK_OBJECT (comp));
+ continue;
+ }
+
+ /* Insert the object into the model */
+
idx = g_new (int, 1);
g_array_append_val (priv->objects, comp);