[empathy/gnome-2-34] Optionally call a callback on Apply to do additional things
- From: Danielle Madeley <daniellem src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [empathy/gnome-2-34] Optionally call a callback on Apply to do additional things
- Date: Thu, 17 Mar 2011 23:42:40 +0000 (UTC)
commit ca830f84306dc6ec626107857b2a770c3faa2401
Author: Danielle Madeley <danielle madeley collabora co uk>
Date: Tue Mar 15 20:47:20 2011 +1100
Optionally call a callback on Apply to do additional things
libempathy-gtk/empathy-account-widget-private.h | 7 ++++
libempathy-gtk/empathy-account-widget.c | 45 ++++++++++++++++++++++-
2 files changed, 50 insertions(+), 2 deletions(-)
---
diff --git a/libempathy-gtk/empathy-account-widget-private.h b/libempathy-gtk/empathy-account-widget-private.h
index db8dc7d..d15aa55 100644
--- a/libempathy-gtk/empathy-account-widget-private.h
+++ b/libempathy-gtk/empathy-account-widget-private.h
@@ -34,6 +34,13 @@ struct _EmpathyAccountWidgetUIDetails {
GtkBuilder *gui;
char *default_focus;
+
+ /* an optional callback to call after calling
+ * empathy_account_settings_apply_async () -- must use a GSimpleAsyncResult
+ * which sets a gboolean indicating reconnect_required */
+ void (* additional_apply_async) (EmpathyAccountWidget *,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
};
diff --git a/libempathy-gtk/empathy-account-widget.c b/libempathy-gtk/empathy-account-widget.c
index c1d625c..95d998e 100644
--- a/libempathy-gtk/empathy-account-widget.c
+++ b/libempathy-gtk/empathy-account-widget.c
@@ -756,16 +756,19 @@ account_widget_account_enabled_cb (GObject *source_object,
g_object_unref (widget);
}
+static void account_widget_applied_continue (EmpathyAccountWidget *widget,
+ gboolean reconnect_required);
+static void account_widget_applied_additional_cb (GObject *widget,
+ GAsyncResult *result, gpointer user_data);
+
static void
account_widget_applied_cb (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
GError *error = NULL;
- TpAccount *account;
EmpathyAccountSettings *settings = EMPATHY_ACCOUNT_SETTINGS (source_object);
EmpathyAccountWidget *widget = EMPATHY_ACCOUNT_WIDGET (user_data);
- EmpathyAccountWidgetPriv *priv = GET_PRIV (widget);
gboolean reconnect_required;
empathy_account_settings_apply_finish (settings, res, &reconnect_required,
@@ -778,6 +781,44 @@ account_widget_applied_cb (GObject *source_object,
return;
}
+ DEBUG ("First stage apply complete: reconnect_required = %s",
+ reconnect_required ? "yes" : "no");
+
+ /* if there is additional work for this widget, do that now */
+ if (widget->ui_details->additional_apply_async != NULL)
+ widget->ui_details->additional_apply_async (widget,
+ account_widget_applied_additional_cb,
+ GUINT_TO_POINTER (reconnect_required));
+ else
+ account_widget_applied_continue (widget, reconnect_required);
+}
+
+static void
+account_widget_applied_additional_cb (GObject *obj,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ EmpathyAccountWidget *widget = EMPATHY_ACCOUNT_WIDGET (obj);
+ GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
+ gboolean reconnect_required = GPOINTER_TO_UINT (user_data);
+
+ /* we don't care about the error status, the async method can report it,
+ * just get the result */
+ reconnect_required |= g_simple_async_result_get_op_res_gboolean (simple);
+
+ DEBUG ("Second stage apply complete: reconnect_required = %s",
+ reconnect_required ? "yes" : "no");
+
+ account_widget_applied_continue (widget, reconnect_required);
+}
+
+static void
+account_widget_applied_continue (EmpathyAccountWidget *widget,
+ gboolean reconnect_required)
+{
+ EmpathyAccountWidgetPriv *priv = GET_PRIV (widget);
+ TpAccount *account;
+
account = empathy_account_settings_get_account (priv->settings);
if (account != NULL)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]