diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2013-04-13 02:21:48 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2013-04-13 06:35:11 +0800 |
commit | 1141e231478410ecd83c78507612e57f58f2ccf1 (patch) | |
tree | fe34c86bab52d1cbf624cde02464c12e06b18742 /calendar | |
parent | ebef28545a2a74d675142afd6921f5e0e65b4b76 (diff) | |
download | gsoc2013-evolution-1141e231478410ecd83c78507612e57f58f2ccf1.tar.gz gsoc2013-evolution-1141e231478410ecd83c78507612e57f58f2ccf1.tar.zst gsoc2013-evolution-1141e231478410ecd83c78507612e57f58f2ccf1.zip |
Add e_cal_model_list_clients().
Replaces e_cal_model_get_client_list().
Does the same thing, except the returned ECalClient instances are
referenced for thread-safety.
Diffstat (limited to 'calendar')
-rw-r--r-- | calendar/gui/e-cal-model.c | 9 | ||||
-rw-r--r-- | calendar/gui/e-cal-model.h | 2 | ||||
-rw-r--r-- | calendar/gui/e-task-table.c | 4 | ||||
-rw-r--r-- | calendar/gui/gnome-cal.c | 26 |
4 files changed, 23 insertions, 18 deletions
diff --git a/calendar/gui/e-cal-model.c b/calendar/gui/e-cal-model.c index 1ed0720bec..d990bdbaf0 100644 --- a/calendar/gui/e-cal-model.c +++ b/calendar/gui/e-cal-model.c @@ -2621,7 +2621,7 @@ e_cal_model_set_default_client (ECalModel *model, } GList * -e_cal_model_get_client_list (ECalModel *model) +e_cal_model_list_clients (ECalModel *model) { GQueue results = G_QUEUE_INIT; GList *list, *link; @@ -2635,14 +2635,17 @@ e_cal_model_get_client_list (ECalModel *model) for (link = list; link != NULL; link = g_list_next (link)) { ClientData *client_data = link->data; + ECalClient *client; + + client = client_data->client; /* Exclude the default client if we're not querying it. */ - if (client_data->client == default_client) { + if (client == default_client) { if (!client_data->do_query) continue; } - g_queue_push_tail (&results, client_data->client); + g_queue_push_tail (&results, g_object_ref (client)); } g_list_free_full (list, (GDestroyNotify) client_data_unref); diff --git a/calendar/gui/e-cal-model.h b/calendar/gui/e-cal-model.h index f9eebad035..3827f25b18 100644 --- a/calendar/gui/e-cal-model.h +++ b/calendar/gui/e-cal-model.h @@ -253,7 +253,7 @@ void e_cal_model_set_work_day_start_minute ECalClient * e_cal_model_get_default_client (ECalModel *model); void e_cal_model_set_default_client (ECalModel *model, ECalClient *client); -GList * e_cal_model_get_client_list (ECalModel *model); +GList * e_cal_model_list_clients (ECalModel *model); ECalClient * e_cal_model_get_client_for_source (ECalModel *model, ESource *source); diff --git a/calendar/gui/e-task-table.c b/calendar/gui/e-task-table.c index e014fe117b..6f7fb83317 100644 --- a/calendar/gui/e-task-table.c +++ b/calendar/gui/e-task-table.c @@ -1873,7 +1873,7 @@ e_task_table_process_completed_tasks (ETaskTable *task_table, if (!(hide_sexp && show_sexp)) show_sexp = g_strdup ("(is-completed?)"); - client_list = e_cal_model_get_client_list (model); + client_list = e_cal_model_list_clients (model); /* Delete rows from model */ if (hide_sexp) { @@ -1889,7 +1889,7 @@ e_task_table_process_completed_tasks (ETaskTable *task_table, show_completed_rows_ready, model); } - g_list_free (client_list); + g_list_free_full (client_list, (GDestroyNotify) g_object_unref); g_free (hide_sexp); g_free (show_sexp); diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c index c464eef119..8716f5f927 100644 --- a/calendar/gui/gnome-cal.c +++ b/calendar/gui/gnome-cal.c @@ -1177,7 +1177,7 @@ update_query_async (struct _date_query_msg *msg) GnomeCalendarPrivate *priv; ECalClientView *new_view; gchar *real_sexp; - GList *list, *iter; + GList *list, *link; priv = gcal->priv; @@ -1191,12 +1191,11 @@ update_query_async (struct _date_query_msg *msg) return; /* No time range is set, so don't start a query */ } - list = e_cal_model_get_client_list (priv->model); - g_list_foreach (list, (GFunc) g_object_ref, NULL); + list = e_cal_model_list_clients (priv->model); /* create queries for each loaded client */ - for (iter = list; iter != NULL; iter = iter->next) { - ECalClient *client = E_CAL_CLIENT (iter->data); + for (link = list; link != NULL; link = g_list_next (link)) { + ECalClient *client = E_CAL_CLIENT (link->data); GError *error = NULL; new_view = NULL; @@ -1232,8 +1231,7 @@ update_query_async (struct _date_query_msg *msg) g_mutex_unlock (&priv->dn_query_lock); } - g_list_foreach (list, (GFunc) g_object_unref, NULL); - g_list_free (list); + g_list_free_full (list, (GDestroyNotify) g_object_unref); /* free memory */ g_free (real_sexp); @@ -2332,11 +2330,14 @@ void gnome_calendar_purge (GnomeCalendar *gcal, time_t older_than) { + ECalModel *model; gchar *sexp, *start, *end; - GList *clients, *l; + GList *list, *link; g_return_if_fail (GNOME_IS_CALENDAR (gcal)); + model = gnome_calendar_get_model (gcal); + start = isodate_from_time_t (0); end = isodate_from_time_t (older_than); sexp = g_strdup_printf ( @@ -2346,9 +2347,10 @@ gnome_calendar_purge (GnomeCalendar *gcal, gcal_update_status_message (gcal, _("Purging"), -1); /* FIXME Confirm expunge */ - clients = e_cal_model_get_client_list (gnome_calendar_get_model (gcal)); - for (l = clients; l != NULL; l = l->next) { - ECalClient *client = l->data; + list = e_cal_model_list_clients (model); + + for (link = list; link != NULL; link = g_list_next (link)) { + ECalClient *client = E_CAL_CLIENT (link->data); GSList *objects, *m; GError *error = NULL; @@ -2424,7 +2426,7 @@ gnome_calendar_purge (GnomeCalendar *gcal, g_slist_free (objects); } - g_list_free (clients); + g_list_free_full (list, (GDestroyNotify) g_object_unref); gcal_update_status_message (gcal, NULL, -1); |