aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-01-15 00:02:43 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-01-18 19:04:00 +0800
commite7dc37cd2c4be8c8ab892bfcebf57249c4a15460 (patch)
tree83086abe9eee501df3e89420edcd8492c2a67970
parentd8a99a7d7f833b1e6fae18661d1fb54ef22133b1 (diff)
downloadgsoc2013-empathy-e7dc37cd2c4be8c8ab892bfcebf57249c4a15460.tar
gsoc2013-empathy-e7dc37cd2c4be8c8ab892bfcebf57249c4a15460.tar.gz
gsoc2013-empathy-e7dc37cd2c4be8c8ab892bfcebf57249c4a15460.tar.bz2
gsoc2013-empathy-e7dc37cd2c4be8c8ab892bfcebf57249c4a15460.tar.lz
gsoc2013-empathy-e7dc37cd2c4be8c8ab892bfcebf57249c4a15460.tar.xz
gsoc2013-empathy-e7dc37cd2c4be8c8ab892bfcebf57249c4a15460.tar.zst
gsoc2013-empathy-e7dc37cd2c4be8c8ab892bfcebf57249c4a15460.zip
accounts-dialog: display status of accounts in the treeview (#605309)
-rw-r--r--src/empathy-accounts-dialog.c78
1 files changed, 78 insertions, 0 deletions
diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c
index 98eef43fa..15e6796e5 100644
--- a/src/empathy-accounts-dialog.c
+++ b/src/empathy-accounts-dialog.c
@@ -819,6 +819,75 @@ accounts_dialog_name_editing_started_cb (GtkCellRenderer *renderer,
DEBUG ("Editing account name started; stopping flashing");
}
+static const gchar *
+get_status_icon_for_account (EmpathyAccountsDialog *self,
+ TpAccount *account)
+{
+ EmpathyAccountsDialogPriv *priv = GET_PRIV (self);
+ TpConnectionStatus status;
+ TpConnectionStatusReason reason;
+ TpConnectionPresenceType presence;
+
+ if (account == NULL)
+ return empathy_icon_name_for_presence (TP_CONNECTION_PRESENCE_TYPE_OFFLINE);
+
+ if (!tp_account_is_enabled (account))
+ return empathy_icon_name_for_presence (TP_CONNECTION_PRESENCE_TYPE_OFFLINE);
+
+ status = tp_account_get_connection_status (account, &reason);
+
+ if (status == TP_CONNECTION_STATUS_DISCONNECTED)
+ {
+ if (reason != TP_CONNECTION_STATUS_REASON_REQUESTED)
+ /* An error occured */
+ return GTK_STOCK_DIALOG_ERROR;
+
+ presence = TP_CONNECTION_PRESENCE_TYPE_OFFLINE;
+ }
+ else if (status == TP_CONNECTION_STATUS_CONNECTING)
+ {
+ /* Account is connecting. Display a blinking account alternating between
+ * the offline icon and the requested presence. */
+ if (priv->connecting_show)
+ presence = tp_account_get_requested_presence (account, NULL, NULL);
+ else
+ presence = TP_CONNECTION_PRESENCE_TYPE_OFFLINE;
+ }
+ else
+ {
+ /* status == TP_CONNECTION_STATUS_CONNECTED */
+ presence = tp_account_get_current_presence (account, NULL, NULL);
+
+ /* If presence is Unset (CM doesn't implement SimplePresence),
+ * display the 'available' icon.
+ * We also check Offline because of this MC5 bug: fd.o #26060 */
+ if (presence == TP_CONNECTION_PRESENCE_TYPE_OFFLINE ||
+ presence == TP_CONNECTION_PRESENCE_TYPE_UNSET)
+ presence = TP_CONNECTION_PRESENCE_TYPE_AVAILABLE;
+ }
+
+ return empathy_icon_name_for_presence (presence);
+}
+
+static void
+accounts_dialog_model_status_pixbuf_data_func (GtkTreeViewColumn *tree_column,
+ GtkCellRenderer *cell,
+ GtkTreeModel *model,
+ GtkTreeIter *iter,
+ EmpathyAccountsDialog *dialog)
+{
+ TpAccount *account;
+
+ gtk_tree_model_get (model, iter, COL_ACCOUNT_POINTER, &account, -1);
+
+ g_object_set (cell,
+ "icon-name", get_status_icon_for_account (dialog, account),
+ NULL);
+
+ if (account != NULL)
+ g_object_unref (account);
+}
+
static void
accounts_dialog_model_protocol_pixbuf_data_func (GtkTreeViewColumn *tree_column,
GtkCellRenderer *cell,
@@ -1037,6 +1106,15 @@ accounts_dialog_model_add_columns (EmpathyAccountsDialog *dialog)
gtk_tree_view_column_set_expand (column, TRUE);
gtk_tree_view_append_column (view, column);
+ /* Status icon renderer */
+ cell = gtk_cell_renderer_pixbuf_new ();
+ gtk_tree_view_column_pack_start (column, cell, FALSE);
+ gtk_tree_view_column_set_cell_data_func (column, cell,
+ (GtkTreeCellDataFunc)
+ accounts_dialog_model_status_pixbuf_data_func,
+ dialog,
+ NULL);
+
/* Protocol icon renderer */
cell = gtk_cell_renderer_pixbuf_new ();
gtk_tree_view_column_pack_start (column, cell, FALSE);