aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2012-02-03 00:00:08 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2012-02-03 19:57:51 +0800
commit42993a422a490daa5099acbb78ebbfbbbffcea63 (patch)
treed68d69470448663368b65cb30c0f23da038347a6 /src
parentdf8e44cd8c2f09928d31d21540b1de47a1f757f0 (diff)
downloadgsoc2013-empathy-42993a422a490daa5099acbb78ebbfbbbffcea63.tar
gsoc2013-empathy-42993a422a490daa5099acbb78ebbfbbbffcea63.tar.gz
gsoc2013-empathy-42993a422a490daa5099acbb78ebbfbbbffcea63.tar.bz2
gsoc2013-empathy-42993a422a490daa5099acbb78ebbfbbbffcea63.tar.lz
gsoc2013-empathy-42993a422a490daa5099acbb78ebbfbbbffcea63.tar.xz
gsoc2013-empathy-42993a422a490daa5099acbb78ebbfbbbffcea63.tar.zst
gsoc2013-empathy-42993a422a490daa5099acbb78ebbfbbbffcea63.zip
display a message if accounts need to be enabled
https://bugzilla.gnome.org/show_bug.cgi?id=656097
Diffstat (limited to 'src')
-rw-r--r--src/empathy-roster-window.c87
1 files changed, 83 insertions, 4 deletions
diff --git a/src/empathy-roster-window.c b/src/empathy-roster-window.c
index 709df601d..12299015c 100644
--- a/src/empathy-roster-window.c
+++ b/src/empathy-roster-window.c
@@ -2120,19 +2120,78 @@ add_account (EmpathyRosterWindow *self,
roster_window_setup_balance (self, account);
}
+/* @account: if not %NULL, the only account which can be enabled */
+static void
+display_page_account_not_enabled (EmpathyRosterWindow *self,
+ TpAccount *account)
+{
+ if (account == NULL)
+ {
+ display_page_message (self,
+ _("You need to enable one of your accounts to see contacts here."),
+ TRUE);
+ }
+ else
+ {
+ gchar *tmp;
+
+ /* translators: argument is an account name */
+ tmp = g_strdup_printf (_("You need to enable %s to see contacts here."),
+ tp_account_get_display_name (account));
+
+ display_page_message (self, tmp, TRUE);
+ g_free (tmp);
+ }
+}
+static gboolean
+has_enabled_account (GList *accounts)
+{
+ GList *l;
+
+ for (l = accounts; l != NULL; l = g_list_next (l))
+ {
+ TpAccount *account = l->data;
+
+ if (tp_account_is_enabled (account))
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
static void
set_notebook_page (EmpathyRosterWindow *self)
{
GList *accounts;
+ guint len;
accounts = tp_account_manager_get_valid_accounts (
self->priv->account_manager);
- if (g_list_length (accounts) == 0)
- display_page_no_account (self);
- else
- display_page_contact_list (self);
+ len = g_list_length (accounts);
+ if (len == 0)
+ {
+ /* No account */
+ display_page_no_account (self);
+ goto out;
+ }
+
+ if (!has_enabled_account (accounts))
+ {
+ TpAccount *account = NULL;
+
+ /* Pass the account if there is only one which can be enabled */
+ if (len == 1)
+ account = accounts->data;
+
+ display_page_account_not_enabled (self, account);
+ goto out;
+ }
+
+ display_page_contact_list (self);
+
+out:
g_list_free (accounts);
}
@@ -2187,6 +2246,22 @@ roster_window_connection_items_setup (EmpathyRosterWindow *self,
}
static void
+account_enabled_cb (TpAccountManager *manager,
+ TpAccount *account,
+ EmpathyRosterWindow *self)
+{
+ set_notebook_page (self);
+}
+
+static void
+account_disabled_cb (TpAccountManager *manager,
+ TpAccount *account,
+ EmpathyRosterWindow *self)
+{
+ set_notebook_page (self);
+}
+
+static void
account_manager_prepared_cb (GObject *source_object,
GAsyncResult *result,
gpointer user_data)
@@ -2213,6 +2288,10 @@ account_manager_prepared_cb (GObject *source_object,
g_signal_connect (manager, "account-validity-changed",
G_CALLBACK (roster_window_account_validity_changed_cb), self);
+ tp_g_signal_connect_object (manager, "account-disabled",
+ G_CALLBACK (account_disabled_cb), self, 0);
+ tp_g_signal_connect_object (manager, "account-enabled",
+ G_CALLBACK (account_enabled_cb), self, 0);
roster_window_update_status (self);