From f19241d136043d5cfffbfbaf5b2d6d1affc70682 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Wed, 23 Jan 2013 16:05:08 -0500 Subject: Use e_cal_client_connect(). Instead of e_client_utils_open_new() or e_cal_client_new(). --- calendar/gui/dialogs/event-page.c | 59 ++++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 25 deletions(-) (limited to 'calendar/gui/dialogs/event-page.c') diff --git a/calendar/gui/dialogs/event-page.c b/calendar/gui/dialogs/event-page.c index c12b7c7360..6850a3b151 100644 --- a/calendar/gui/dialogs/event-page.c +++ b/calendar/gui/dialogs/event-page.c @@ -183,7 +183,7 @@ struct _EventPagePrivate { /* either with-user-time or without it */ const gint *alarm_map; - GCancellable *open_cancellable; + GCancellable *connect_cancellable; }; static void event_page_set_dates (CompEditorPage *page, CompEditorPageDates *dates); @@ -878,10 +878,10 @@ event_page_dispose (GObject *object) priv = EVENT_PAGE_GET_PRIVATE (object); - if (priv->open_cancellable) { - g_cancellable_cancel (priv->open_cancellable); - g_object_unref (priv->open_cancellable); - priv->open_cancellable = NULL; + if (priv->connect_cancellable != NULL) { + g_cancellable_cancel (priv->connect_cancellable); + g_object_unref (priv->connect_cancellable); + priv->connect_cancellable = NULL; } if (priv->location_completion != NULL) { @@ -1842,7 +1842,6 @@ event_page_init (EventPage *epage) epage->priv->alarm_interval = -1; epage->priv->alarm_map = alarm_map_with_user_time; epage->priv->location_completion = gtk_entry_completion_new (); - epage->priv->open_cancellable = NULL; } void @@ -2988,23 +2987,27 @@ event_page_send_options_clicked_cb (EventPage *epage) } static void -epage_client_opened_cb (GObject *source_object, - GAsyncResult *result, - gpointer user_data) +epage_client_connect_cb (GObject *source_object, + GAsyncResult *result, + gpointer user_data) { - ESource *source = E_SOURCE (source_object); - EClient *client = NULL; + EClient *client; EventPage *epage = user_data; EventPagePrivate *priv; CompEditor *editor; GError *error = NULL; - if (!e_client_utils_open_new_finish (source, result, &client, &error)) { - if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) || - g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { - g_clear_error (&error); - return; - } + client = e_cal_client_connect_finish (result, &error); + + /* Sanity check. */ + g_return_if_fail ( + ((client != NULL) && (error == NULL)) || + ((client == NULL) && (error != NULL))); + + if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) || + g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + g_clear_error (&error); + return; } editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (epage)); @@ -3013,9 +3016,13 @@ epage_client_opened_cb (GObject *source_object, if (error) { GtkWidget *dialog; ECalClient *old_client; + ESource *source; old_client = comp_editor_get_client (editor); + source = e_source_combo_box_ref_active ( + E_SOURCE_COMBO_BOX (priv->source_combo_box)); + e_source_combo_box_set_active ( E_SOURCE_COMBO_BOX (priv->source_combo_box), e_client_get_source (E_CLIENT (old_client))); @@ -3029,6 +3036,8 @@ epage_client_opened_cb (GObject *source_object, gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); + g_object_unref (source); + g_clear_error (&error); } else { gchar *backend_addr = NULL; @@ -3074,16 +3083,16 @@ source_changed_cb (ESourceComboBox *source_combo_box, source = e_source_combo_box_ref_active (source_combo_box); g_return_if_fail (source != NULL); - if (priv->open_cancellable) { - g_cancellable_cancel (priv->open_cancellable); - g_object_unref (priv->open_cancellable); + if (priv->connect_cancellable != NULL) { + g_cancellable_cancel (priv->connect_cancellable); + g_object_unref (priv->connect_cancellable); } - priv->open_cancellable = g_cancellable_new (); + priv->connect_cancellable = g_cancellable_new (); - e_client_utils_open_new ( - source, E_CLIENT_SOURCE_TYPE_EVENTS, - FALSE, priv->open_cancellable, - epage_client_opened_cb, epage); + e_cal_client_connect ( + source, E_CAL_CLIENT_SOURCE_TYPE_EVENTS, + priv->connect_cancellable, + epage_client_connect_cb, epage); g_object_unref (source); } -- cgit v1.2.3