aboutsummaryrefslogtreecommitdiffstats
path: root/src/empathy-account-assistant.c
diff options
context:
space:
mode:
authorCosimo Cecchi <cosimoc@gnome.org>2009-08-07 03:17:16 +0800
committerSjoerd Simons <sjoerd.simons@collabora.co.uk>2009-08-22 21:21:08 +0800
commitb047c404615a4137ced83c40d214f1092fbc733b (patch)
treed3a058ed4dff48504b2ea8431837350e39b485b5 /src/empathy-account-assistant.c
parent85883a63be4daae817ed194ba6fa014266d27c09 (diff)
downloadgsoc2013-empathy-b047c404615a4137ced83c40d214f1092fbc733b.tar
gsoc2013-empathy-b047c404615a4137ced83c40d214f1092fbc733b.tar.gz
gsoc2013-empathy-b047c404615a4137ced83c40d214f1092fbc733b.tar.bz2
gsoc2013-empathy-b047c404615a4137ced83c40d214f1092fbc733b.tar.lz
gsoc2013-empathy-b047c404615a4137ced83c40d214f1092fbc733b.tar.xz
gsoc2013-empathy-b047c404615a4137ced83c40d214f1092fbc733b.tar.zst
gsoc2013-empathy-b047c404615a4137ced83c40d214f1092fbc733b.zip
Emit the close signal only after we are done with the async machinery.
Diffstat (limited to 'src/empathy-account-assistant.c')
-rw-r--r--src/empathy-account-assistant.c53
1 files changed, 45 insertions, 8 deletions
diff --git a/src/empathy-account-assistant.c b/src/empathy-account-assistant.c
index 4e9044fdf..f5ef3c7f5 100644
--- a/src/empathy-account-assistant.c
+++ b/src/empathy-account-assistant.c
@@ -66,6 +66,7 @@ typedef struct {
GtkWidget *second_label;
GtkWidget *chooser;
EmpathyAccountSettings *settings;
+ gboolean is_creating;
GtkWindow *parent_window;
@@ -185,17 +186,40 @@ account_assistant_present_error_page (EmpathyAccountAssistant *self,
}
static void
+account_assistant_account_enabled_cb (GObject *source,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ GError *error = NULL;
+ EmpathyAccountAssistant *self = user_data;
+
+ empathy_account_set_enabled_finish (EMPATHY_ACCOUNT (source),
+ result, &error);
+
+ if (error)
+ {
+ g_warning ("Error enabling an account: %s", error->message);
+ g_error_free (error);
+ }
+
+ g_signal_emit_by_name (self, "close");
+}
+
+static void
account_assistant_apply_account_cb (GObject *source,
GAsyncResult *result,
gpointer user_data)
{
GError *error = NULL;
EmpathyAccountAssistant *self = user_data;
+ EmpathyAccountAssistantPriv *priv = GET_PRIV (self);
EmpathyAccountSettings *settings = EMPATHY_ACCOUNT_SETTINGS (source);
EmpathyAccount *account;
empathy_account_settings_apply_finish (settings, result, &error);
+ priv->is_creating = FALSE;
+
if (error != NULL)
{
account_assistant_present_error_page (self, error, PAGE_ENTER_CREATE);
@@ -205,7 +229,8 @@ account_assistant_apply_account_cb (GObject *source,
/* enable the newly created account */
account = empathy_account_settings_get_account (settings);
- empathy_account_set_enabled (account, TRUE);
+ empathy_account_set_enabled_async (account, TRUE,
+ account_assistant_account_enabled_cb, self);
}
static void
@@ -216,6 +241,8 @@ account_assistant_apply_account_and_finish (EmpathyAccountAssistant *self)
if (priv->settings == NULL)
return;
+ priv->is_creating = TRUE;
+
empathy_account_settings_apply_async (priv->settings,
account_assistant_apply_account_cb, self);
}
@@ -560,11 +587,25 @@ account_assistant_build_enter_or_create_page (EmpathyAccountAssistant *self,
}
static void
+account_assistant_close_cb (GtkAssistant *assistant,
+ gpointer user_data)
+{
+ EmpathyAccountAssistantPriv *priv = GET_PRIV (assistant);
+
+ if (priv->is_creating)
+ return;
+
+ gtk_widget_destroy (GTK_WIDGET (assistant));
+}
+
+static void
impl_signal_apply (GtkAssistant *assistant)
{
EmpathyAccountAssistant *self = EMPATHY_ACCOUNT_ASSISTANT (assistant);
+ // EmpathyAccountAssistantPriv *priv = GET_PRIV (self);
gint current_page;
+ g_print ("apply!!\n");
current_page = gtk_assistant_get_current_page (assistant);
if (current_page == RESPONSE_ENTER_ACCOUNT)
@@ -572,12 +613,6 @@ impl_signal_apply (GtkAssistant *assistant)
}
static void
-impl_signal_close (GtkAssistant *assistant)
-{
- gtk_widget_destroy (GTK_WIDGET (assistant));
-}
-
-static void
impl_signal_cancel (GtkAssistant *assistant)
{
gtk_widget_destroy (GTK_WIDGET (assistant));
@@ -687,7 +722,6 @@ empathy_account_assistant_class_init (EmpathyAccountAssistantClass *klass)
gtkclass->apply = impl_signal_apply;
gtkclass->prepare = impl_signal_prepare;
- gtkclass->close = impl_signal_close;
gtkclass->cancel = impl_signal_cancel;
param_spec = g_param_spec_object ("parent-window",
@@ -710,6 +744,9 @@ empathy_account_assistant_init (EmpathyAccountAssistant *self)
EmpathyAccountAssistantPriv);
self->priv = priv;
+ g_signal_connect (self, "close",
+ G_CALLBACK (account_assistant_close_cb), NULL);
+
gtk_assistant_set_forward_page_func (assistant,
account_assistant_page_forward_func, self, NULL);