diff options
author | Federico Mena Quintero <federico@helixcode.com> | 2000-09-14 05:38:12 +0800 |
---|---|---|
committer | Federico Mena Quintero <federico@src.gnome.org> | 2000-09-14 05:38:12 +0800 |
commit | 1657cfe34134673a5a09b2e62a9044eca8a6ea09 (patch) | |
tree | 05e0f5c88debcfaa2d165e94e82156c8b7afb3b5 /calendar/gui | |
parent | 534132510d788bd8b3d86262ffe98a6b0ddc8cc0 (diff) | |
download | gsoc2013-evolution-1657cfe34134673a5a09b2e62a9044eca8a6ea09.tar gsoc2013-evolution-1657cfe34134673a5a09b2e62a9044eca8a6ea09.tar.gz gsoc2013-evolution-1657cfe34134673a5a09b2e62a9044eca8a6ea09.tar.bz2 gsoc2013-evolution-1657cfe34134673a5a09b2e62a9044eca8a6ea09.tar.lz gsoc2013-evolution-1657cfe34134673a5a09b2e62a9044eca8a6ea09.tar.xz 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
Diffstat (limited to 'calendar/gui')
-rw-r--r-- | calendar/gui/calendar-model.c | 31 |
1 files changed, 31 insertions, 0 deletions
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); |