aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2013-06-01 22:06:47 +0800
committerMatthew Barnes <mbarnes@redhat.com>2013-06-01 22:08:23 +0800
commit2aa759bc58ea8e14dd1d28a9d7f23e2f5f627c3f (patch)
tree6fd760ec188da3cc4148b74d2c3d20c5a0d15884
parent6477dd65708b286001b487ca89d4d5066a25bbfd (diff)
downloadgsoc2013-evolution-2aa759bc58ea8e14dd1d28a9d7f23e2f5f627c3f.tar
gsoc2013-evolution-2aa759bc58ea8e14dd1d28a9d7f23e2f5f627c3f.tar.gz
gsoc2013-evolution-2aa759bc58ea8e14dd1d28a9d7f23e2f5f627c3f.tar.bz2
gsoc2013-evolution-2aa759bc58ea8e14dd1d28a9d7f23e2f5f627c3f.tar.lz
gsoc2013-evolution-2aa759bc58ea8e14dd1d28a9d7f23e2f5f627c3f.tar.xz
gsoc2013-evolution-2aa759bc58ea8e14dd1d28a9d7f23e2f5f627c3f.tar.zst
gsoc2013-evolution-2aa759bc58ea8e14dd1d28a9d7f23e2f5f627c3f.zip
Add a boolean return to e_cal_model_remove_client().
The function now returns TRUE if the ECalClient was actually removed from the model, or FALSE if the model did not have the ECalClient. Use this to avoid an unnecessary gnome_calendar_update_query() call in cal_shell_view_selector_client_removed().
-rw-r--r--calendar/gui/e-cal-model.c19
-rw-r--r--calendar/gui/e-cal-model.h2
-rw-r--r--modules/calendar/e-cal-shell-view-private.c5
3 files changed, 19 insertions, 7 deletions
diff --git a/calendar/gui/e-cal-model.c b/calendar/gui/e-cal-model.c
index b74485b28a..16c968d704 100644
--- a/calendar/gui/e-cal-model.c
+++ b/calendar/gui/e-cal-model.c
@@ -3578,21 +3578,34 @@ remove_client (ECalModel *model,
/**
* e_cal_model_remove_client
+ * @model: an #ECalModel
+ * @client: an #ECalClient
+ *
+ * Removes @client from @model along with its internal #ECalClientView.
+ *
+ * If @model does not have @client then the function does nothing and
+ * returns %FALSE.
+ *
+ * Returns: %TRUE is @client was remove, %FALSE if @model did not have it
*/
-void
+gboolean
e_cal_model_remove_client (ECalModel *model,
ECalClient *client)
{
ClientData *client_data;
+ gboolean removed = FALSE;
- g_return_if_fail (E_IS_CAL_MODEL (model));
- g_return_if_fail (E_IS_CAL_CLIENT (client));
+ g_return_val_if_fail (E_IS_CAL_MODEL (model), FALSE);
+ g_return_val_if_fail (E_IS_CAL_CLIENT (client), FALSE);
client_data = cal_model_clients_lookup (model, client);
if (client_data != NULL) {
remove_client (model, client_data);
client_data_unref (client_data);
+ removed = TRUE;
}
+
+ return removed;
}
/**
diff --git a/calendar/gui/e-cal-model.h b/calendar/gui/e-cal-model.h
index 407195117a..602db1cae4 100644
--- a/calendar/gui/e-cal-model.h
+++ b/calendar/gui/e-cal-model.h
@@ -256,7 +256,7 @@ void e_cal_model_set_default_client (ECalModel *model,
GList * e_cal_model_list_clients (ECalModel *model);
gboolean e_cal_model_add_client (ECalModel *model,
ECalClient *cal_client);
-void e_cal_model_remove_client (ECalModel *model,
+gboolean e_cal_model_remove_client (ECalModel *model,
ECalClient *cal_client);
void e_cal_model_remove_all_clients (ECalModel *model);
void e_cal_model_get_time_range (ECalModel *model,
diff --git a/modules/calendar/e-cal-shell-view-private.c b/modules/calendar/e-cal-shell-view-private.c
index 94176c31f3..5322ad07b8 100644
--- a/modules/calendar/e-cal-shell-view-private.c
+++ b/modules/calendar/e-cal-shell-view-private.c
@@ -351,9 +351,8 @@ cal_shell_view_selector_client_removed_cb (ECalShellView *cal_shell_view,
calendar = e_cal_shell_content_get_calendar (cal_shell_content);
model = gnome_calendar_get_model (calendar);
- e_cal_model_remove_client (model, client);
-
- gnome_calendar_update_query (calendar);
+ if (e_cal_model_remove_client (model, client))
+ gnome_calendar_update_query (calendar);
}
static void