[empathy] factor out account_is_selected()
- From: Guillaume Desmottes <gdesmott src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [empathy] factor out account_is_selected()
- Date: Thu, 15 Mar 2012 15:14:44 +0000 (UTC)
commit 500ef8529e04b2e1606f35d9c0697ef96423a828
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date: Thu Mar 15 14:55:39 2012 +0100
factor out account_is_selected()
https://bugzilla.gnome.org/show_bug.cgi?id=671035
src/empathy-accounts-dialog.c | 43 +++++++++++++++++++++++++---------------
1 files changed, 27 insertions(+), 16 deletions(-)
---
diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c
index 189f22b..847e1a5 100644
--- a/src/empathy-accounts-dialog.c
+++ b/src/empathy-accounts-dialog.c
@@ -277,6 +277,32 @@ install_haze_cb (GObject *source,
}
}
+static gboolean
+account_is_selected (EmpathyAccountsDialog *dialog,
+ TpAccount *account)
+{
+ EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
+ GtkTreeSelection *selection;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ TpAccount *selected_account;
+
+ if (account == NULL)
+ return FALSE;
+
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview));
+
+ if (!gtk_tree_selection_get_selected (selection, &model, &iter))
+ return FALSE;
+
+ gtk_tree_model_get (model, &iter, COL_ACCOUNT, &selected_account, -1);
+
+ if (selected_account != NULL)
+ g_object_unref (selected_account);
+
+ return account == selected_account;
+}
+
static void
accounts_dialog_update_status_infobar (EmpathyAccountsDialog *dialog,
TpAccount *account)
@@ -286,28 +312,13 @@ accounts_dialog_update_status_infobar (EmpathyAccountsDialog *dialog,
guint status;
guint reason;
guint presence;
- GtkTreeView *view;
- GtkTreeModel *model;
- GtkTreeSelection *selection;
- GtkTreeIter iter;
- TpAccount *selected_account;
gboolean account_enabled;
gboolean creating_account;
TpStorageRestrictionFlags storage_restrictions = 0;
gboolean display_switch = TRUE;
- view = GTK_TREE_VIEW (priv->treeview);
- selection = gtk_tree_view_get_selection (view);
-
- if (!gtk_tree_selection_get_selected (selection, &model, &iter))
- return;
-
- gtk_tree_model_get (model, &iter, COL_ACCOUNT, &selected_account, -1);
- if (selected_account != NULL)
- g_object_unref (selected_account);
-
/* do not update the infobar when the account is not selected */
- if (account != selected_account)
+ if (!account_is_selected (dialog, account))
return;
if (account != NULL)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]