diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2013-06-01 21:10:16 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2013-06-01 22:31:39 +0800 |
commit | c6b96f4e4492552b0a9256140706f7d98bf2bdee (patch) | |
tree | 21509c266cc4dfa1d74853ffe0c88ebcf486fa9a | |
parent | 2a147de5a11defeec02bd9abad330b453916d378 (diff) | |
download | gsoc2013-evolution-c6b96f4e4492552b0a9256140706f7d98bf2bdee.tar gsoc2013-evolution-c6b96f4e4492552b0a9256140706f7d98bf2bdee.tar.gz gsoc2013-evolution-c6b96f4e4492552b0a9256140706f7d98bf2bdee.tar.bz2 gsoc2013-evolution-c6b96f4e4492552b0a9256140706f7d98bf2bdee.tar.lz gsoc2013-evolution-c6b96f4e4492552b0a9256140706f7d98bf2bdee.tar.xz gsoc2013-evolution-c6b96f4e4492552b0a9256140706f7d98bf2bdee.tar.zst gsoc2013-evolution-c6b96f4e4492552b0a9256140706f7d98bf2bdee.zip |
Add a boolean return to e_cal_model_add_client().
The function now returns TRUE if the ECalClient was actually added
to the model, or FALSE if the model already had the ECalClient.
Use this to avoid an unnecessary gnome_calendar_update_query() call
in cal_shell_view_selector_client_added_cb().
(cherry picked from commit 6477dd65708b286001b487ca89d4d5066a25bbfd)
-rw-r--r-- | calendar/gui/e-cal-model.c | 26 | ||||
-rw-r--r-- | calendar/gui/e-cal-model.h | 2 | ||||
-rw-r--r-- | modules/calendar/e-cal-shell-view-private.c | 5 |
3 files changed, 22 insertions, 11 deletions
diff --git a/calendar/gui/e-cal-model.c b/calendar/gui/e-cal-model.c index 49d89cd805..b9c4d84f63 100644 --- a/calendar/gui/e-cal-model.c +++ b/calendar/gui/e-cal-model.c @@ -155,7 +155,7 @@ static gchar *ecm_value_to_string (ETableModel *etm, gint col, gconstpointer val static const gchar *ecm_get_color_for_component (ECalModel *model, ECalModelComponent *comp_data); -static void add_new_client (ECalModel *model, ECalClient *client, gboolean do_query); +static gboolean add_new_client (ECalModel *model, ECalClient *client, gboolean do_query); static void remove_client_objects (ECalModel *model, ClientData *client_data); static void remove_client (ECalModel *model, ClientData *client_data); static void redo_queries (ECalModel *model); @@ -3182,7 +3182,7 @@ e_cal_model_update_status_message (ECalModel *model, g_signal_emit (model, signals[STATUS_MESSAGE], 0, message, percent); } -static void +static gboolean add_new_client (ECalModel *model, ECalClient *client, gboolean do_query) @@ -3212,19 +3212,31 @@ add_new_client (ECalModel *model, update_e_cal_view_for_client (model, client_data); client_data_unref (client_data); + + return update_view; } /** - * e_cal_model_add_client + * e_cal_model_add_client: + * @model: an #ECalModel + * @client: an #ECalClient + * + * Adds @client to @model and creates an internal #ECalClientView for it. + * + * If @model already has @client from a previous e_cal_model_add_client() + * call (in other words, excluding e_cal_model_set_default_client()), then + * the function does nothing and returns %FALSE. + * + * Returns: %TRUE if @client was added, %FALSE if @model already had it */ -void +gboolean e_cal_model_add_client (ECalModel *model, ECalClient *client) { - 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); - add_new_client (model, client, TRUE); + return add_new_client (model, client, TRUE); } static void diff --git a/calendar/gui/e-cal-model.h b/calendar/gui/e-cal-model.h index 0a30ff6b7d..19c89a7775 100644 --- a/calendar/gui/e-cal-model.h +++ b/calendar/gui/e-cal-model.h @@ -247,7 +247,7 @@ ECalClient * e_cal_model_ref_default_client (ECalModel *model); void e_cal_model_set_default_client (ECalModel *model, ECalClient *client); GList * e_cal_model_list_clients (ECalModel *model); -void e_cal_model_add_client (ECalModel *model, +gboolean e_cal_model_add_client (ECalModel *model, ECalClient *cal_client); void e_cal_model_remove_client (ECalModel *model, ECalClient *cal_client); diff --git a/modules/calendar/e-cal-shell-view-private.c b/modules/calendar/e-cal-shell-view-private.c index b0757b0080..37e686e6c9 100644 --- a/modules/calendar/e-cal-shell-view-private.c +++ b/modules/calendar/e-cal-shell-view-private.c @@ -334,9 +334,8 @@ cal_shell_view_selector_client_added_cb (ECalShellView *cal_shell_view, calendar = e_cal_shell_content_get_calendar (cal_shell_content); model = gnome_calendar_get_model (calendar); - e_cal_model_add_client (model, client); - - gnome_calendar_update_query (calendar); + if (e_cal_model_add_client (model, client)) + gnome_calendar_update_query (calendar); } static void |