[empathy] empathy_account_chooser_set_account: select account later if not ready yet
- From: Guillaume Desmottes <gdesmott src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [empathy] empathy_account_chooser_set_account: select account later if not ready yet
- Date: Fri, 28 Oct 2011 13:54:31 +0000 (UTC)
commit 8bb2b53dad076cbc9fc92ab11e11f1ba6fcbfd92
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date: Wed Oct 26 12:23:45 2011 +0200
empathy_account_chooser_set_account: select account later if not ready yet
It's stupid to have to ask to any user of this widget to do this itself.
https://bugzilla.gnome.org/show_bug.cgi?id=662604
libempathy-gtk/empathy-account-chooser.c | 24 ++++++++++++++++++-
libempathy-gtk/empathy-log-window.c | 38 ++++--------------------------
2 files changed, 28 insertions(+), 34 deletions(-)
---
diff --git a/libempathy-gtk/empathy-account-chooser.c b/libempathy-gtk/empathy-account-chooser.c
index 3f7d70b..87fdbbf 100644
--- a/libempathy-gtk/empathy-account-chooser.c
+++ b/libempathy-gtk/empathy-account-chooser.c
@@ -65,6 +65,8 @@ struct _EmpathyAccountChooserPriv
EmpathyAccountChooserFilterFunc filter;
gpointer filter_data;
gboolean ready;
+
+ TpAccount *select_when_ready;
};
typedef struct
@@ -154,6 +156,8 @@ static gboolean account_chooser_set_account_foreach (GtkTreeModel *model,
SetAccountData *data);
static void update_account (EmpathyAccountChooser *self,
TpAccount *account);
+static gboolean select_account (EmpathyAccountChooser *self,
+ TpAccount *account);
enum {
PROP_0,
@@ -295,6 +299,13 @@ account_manager_prepared_cb (GObject *source_object,
g_list_free (accounts);
+ if (self->priv->select_when_ready != NULL)
+ {
+ select_account (self, self->priv->select_when_ready);
+
+ g_clear_object (&self->priv->select_when_ready);
+ }
+
self->priv->ready = TRUE;
g_signal_emit (self, signals[READY], 0);
}
@@ -354,6 +365,7 @@ account_chooser_dispose (GObject *object)
EmpathyAccountChooser *self = EMPATHY_ACCOUNT_CHOOSER (object);
g_clear_object (&self->priv->manager);
+ g_clear_object (&self->priv->select_when_ready);
G_OBJECT_CLASS (empathy_account_chooser_parent_class)->dispose (object);
}
@@ -570,7 +582,17 @@ gboolean
empathy_account_chooser_set_account (EmpathyAccountChooser *self,
TpAccount *account)
{
- return select_account (self, account);
+ if (self->priv->ready)
+ return select_account (self, account);
+
+ /* Account chooser is not ready yet, we'll try selecting the account once it
+ * is */
+ g_clear_object (&self->priv->select_when_ready);
+
+ if (account != NULL)
+ self->priv->select_when_ready = g_object_ref (account);
+
+ return FALSE;
}
void
diff --git a/libempathy-gtk/empathy-log-window.c b/libempathy-gtk/empathy-log-window.c
index ab15b16..b899cfa 100644
--- a/libempathy-gtk/empathy-log-window.c
+++ b/libempathy-gtk/empathy-log-window.c
@@ -299,16 +299,6 @@ ctx_free (Ctx *ctx)
}
static void
-account_chooser_ready_cb (EmpathyAccountChooser *chooser,
- EmpathyLogWindow *self)
-{
- /* We'll display the account once the model has been populate with the chats
- * of this account. */
- empathy_account_chooser_set_account (EMPATHY_ACCOUNT_CHOOSER (
- self->priv->account_chooser), self->priv->selected_account);
-}
-
-static void
select_account_once_ready (EmpathyLogWindow *self,
TpAccount *account,
const gchar *chat_id,
@@ -326,12 +316,8 @@ select_account_once_ready (EmpathyLogWindow *self,
self->priv->selected_is_chatroom = is_chatroom;
- if (empathy_account_chooser_is_ready (account_chooser))
- account_chooser_ready_cb (account_chooser, self);
- else
- /* Chat will be selected once the account chooser is ready */
- g_signal_connect (account_chooser, "ready",
- G_CALLBACK (account_chooser_ready_cb), self);
+ empathy_account_chooser_set_account (EMPATHY_ACCOUNT_CHOOSER (
+ self->priv->account_chooser), self->priv->selected_account);
}
static void
@@ -3707,18 +3693,6 @@ log_window_logger_clear_account_cb (TpProxy *proxy,
}
static void
-log_window_clear_logs_chooser_select_account (EmpathyAccountChooser *chooser,
- EmpathyLogWindow *self)
-{
- EmpathyAccountChooser *account_chooser;
-
- account_chooser = EMPATHY_ACCOUNT_CHOOSER (self->priv->account_chooser);
-
- empathy_account_chooser_set_account (chooser,
- empathy_account_chooser_get_account (account_chooser));
-}
-
-static void
log_window_delete_menu_clicked_cb (GtkMenuItem *menuitem,
EmpathyLogWindow *self)
{
@@ -3735,11 +3709,9 @@ log_window_delete_menu_clicked_cb (GtkMenuItem *menuitem,
empathy_account_chooser_refilter (account_chooser);
/* Select the same account as in the history window */
- if (empathy_account_chooser_is_ready (account_chooser))
- log_window_clear_logs_chooser_select_account (account_chooser, self);
- else
- g_signal_connect (account_chooser, "ready",
- G_CALLBACK (log_window_clear_logs_chooser_select_account), self);
+ empathy_account_chooser_set_account (account_chooser,
+ empathy_account_chooser_get_account (
+ EMPATHY_ACCOUNT_CHOOSER (self->priv->account_chooser)));
dialog = gtk_message_dialog_new_with_markup (GTK_WINDOW (self),
GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]