[gnome-online-accounts] owncloud: Make the cancel button work
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-online-accounts] owncloud: Make the cancel button work
- Date: Wed, 5 Dec 2012 18:59:22 +0000 (UTC)
commit c7a2aa951a546ef5169a34572eb67a009c20cb65
Author: Debarshi Ray <debarshir gnome org>
Date: Tue Dec 4 18:20:38 2012 +0100
owncloud: Make the cancel button work
Fixes: https://bugzilla.gnome.org/689642
src/goabackend/goaowncloudprovider.c | 47 +++++++++++++++++++++++++++++++---
1 files changed, 43 insertions(+), 4 deletions(-)
---
diff --git a/src/goabackend/goaowncloudprovider.c b/src/goabackend/goaowncloudprovider.c
index 7fc4352..bbce559 100644
--- a/src/goabackend/goaowncloudprovider.c
+++ b/src/goabackend/goaowncloudprovider.c
@@ -427,6 +427,8 @@ add_entry (GtkWidget *grid1,
typedef struct
{
+ GCancellable *cancellable;
+
GtkDialog *dialog;
GMainLoop *loop;
@@ -655,6 +657,15 @@ check_cb (GObject *source_object, GAsyncResult *res, gpointer user_data)
gtk_widget_hide (data->progress_grid);
}
+static void
+dialog_response_cb (GtkDialog *dialog, gint response_id, gpointer user_data)
+{
+ AddAccountData *data = user_data;
+
+ if (response_id == GTK_RESPONSE_CANCEL)
+ g_cancellable_cancel (data->cancellable);
+}
+
/* ---------------------------------------------------------------------------------------------------- */
static GoaObject *
@@ -687,12 +698,14 @@ add_account (GoaProvider *provider,
ret = NULL;
memset (&data, 0, sizeof (AddAccountData));
+ data.cancellable = g_cancellable_new ();
data.loop = g_main_loop_new (NULL, FALSE);
data.dialog = dialog;
data.error = NULL;
create_account_details_ui (provider, dialog, vbox, TRUE, &data);
gtk_widget_show_all (GTK_WIDGET (vbox));
+ g_signal_connect (dialog, "response", G_CALLBACK (dialog_response_cb), &data);
http_client = goa_http_client_new ();
@@ -724,11 +737,12 @@ add_account (GoaProvider *provider,
uri = normalize_uri (uri_text, &server);
uri_webdav = g_strconcat (uri, WEBDAV_ENDPOINT, NULL);
+ g_cancellable_reset (data.cancellable);
goa_http_client_check (http_client,
uri_webdav,
username,
password,
- NULL,
+ data.cancellable,
check_cb,
&data);
g_free (uri_webdav);
@@ -737,7 +751,17 @@ add_account (GoaProvider *provider,
gtk_widget_show (data.progress_grid);
g_main_loop_run (data.loop);
- if (data.error != NULL)
+ if (g_cancellable_is_cancelled (data.cancellable))
+ {
+ g_prefix_error (&data.error,
+ _("Dialog was dismissed (%s, %d): "),
+ g_quark_to_string (data.error->domain),
+ data.error->code);
+ data.error->domain = GOA_ERROR;
+ data.error->code = GOA_ERROR_DIALOG_DISMISSED;
+ goto out;
+ }
+ else if (data.error != NULL)
{
gchar *markup;
@@ -806,6 +830,7 @@ add_account (GoaProvider *provider,
g_free (data.account_object_path);
if (data.loop != NULL)
g_main_loop_unref (data.loop);
+ g_clear_object (&data.cancellable);
g_clear_object (&http_client);
return ret;
}
@@ -857,6 +882,7 @@ refresh_account (GoaProvider *provider,
gtk_box_set_spacing (GTK_BOX (vbox), 12);
memset (&data, 0, sizeof (AddAccountData));
+ data.cancellable = g_cancellable_new ();
data.loop = g_main_loop_new (NULL, FALSE);
data.dialog = GTK_DIALOG (dialog);
data.error = NULL;
@@ -873,6 +899,7 @@ refresh_account (GoaProvider *provider,
gtk_editable_set_editable (GTK_EDITABLE (data.username), FALSE);
gtk_widget_show_all (dialog);
+ g_signal_connect (dialog, "response", G_CALLBACK (dialog_response_cb), &data);
http_client = goa_http_client_new ();
uri_webdav = g_strconcat (uri, WEBDAV_ENDPOINT, NULL);
@@ -889,18 +916,29 @@ refresh_account (GoaProvider *provider,
}
password = gtk_entry_get_text (GTK_ENTRY (data.password));
+ g_cancellable_reset (data.cancellable);
goa_http_client_check (http_client,
uri_webdav,
username,
password,
- NULL,
+ data.cancellable,
check_cb,
&data);
gtk_widget_set_sensitive (data.connect_button, FALSE);
gtk_widget_show (data.progress_grid);
g_main_loop_run (data.loop);
- if (data.error != NULL)
+ if (g_cancellable_is_cancelled (data.cancellable))
+ {
+ g_prefix_error (&data.error,
+ _("Dialog was dismissed (%s, %d): "),
+ g_quark_to_string (data.error->domain),
+ data.error->code);
+ data.error->domain = GOA_ERROR;
+ data.error->code = GOA_ERROR_DIALOG_DISMISSED;
+ goto out;
+ }
+ else if (data.error != NULL)
{
gchar *markup;
@@ -941,6 +979,7 @@ refresh_account (GoaProvider *provider,
g_free (uri_webdav);
if (data.loop != NULL)
g_main_loop_unref (data.loop);
+ g_clear_object (&data.cancellable);
g_clear_object (&http_client);
return ret;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]