[evolution/relayout-composer] Add function to count the displayed accounts in an EAccountComboBox



commit e496f94b0433b22e1ecdf35328bcaf16b4abb6a4
Author: Federico Mena Quintero <federico novell com>
Date:   Tue May 4 13:14:01 2010 -0500

    Add function to count the displayed accounts in an EAccountComboBox
    
    We will need this to see how many accounts are shown in the From header
    in the mail composer.
    
    Signed-off-by: Federico Mena Quintero <federico novell com>

 widgets/misc/e-account-combo-box.c |   22 ++++++++++++++++++++++
 widgets/misc/e-account-combo-box.h |    2 ++
 2 files changed, 24 insertions(+), 0 deletions(-)
---
diff --git a/widgets/misc/e-account-combo-box.c b/widgets/misc/e-account-combo-box.c
index 0ded393..786478a 100644
--- a/widgets/misc/e-account-combo-box.c
+++ b/widgets/misc/e-account-combo-box.c
@@ -41,6 +41,7 @@ enum {
 struct _EAccountComboBoxPrivate {
 	EAccountList *account_list;
 	GHashTable *index;
+	int num_displayed_accounts;
 };
 
 static gpointer parent_class;
@@ -150,6 +151,8 @@ account_combo_box_refresh_cb (EAccountList *account_list,
 	GList *list = NULL;
 	GList *iter;
 
+	combo_box->priv->num_displayed_accounts = 0;
+
 	store = gtk_list_store_new (2, G_TYPE_STRING, E_TYPE_ACCOUNT);
 	model = GTK_TREE_MODEL (store);
 	index = combo_box->priv->index;
@@ -182,6 +185,7 @@ account_combo_box_refresh_cb (EAccountList *account_list,
 		gchar *string;
 
 		account = iter->data;
+		combo_box->priv->num_displayed_accounts++;
 
 		/* Show the account name for duplicate email addresses. */
 		if (account_combo_box_has_dupes (list, account->id->address))
@@ -514,3 +518,21 @@ e_account_combo_box_set_active_name (EAccountComboBox *combo_box,
 
 	return e_account_combo_box_set_active (combo_box, account);
 }
+
+/**
+ * e_account_combo_box_count_displayed_accounts:
+ * @combo_box: an #EAccountComboBox
+ *
+ * Counts the number of accounts that are displayed in the @combo_box.  This may not
+ * be the actual number of accounts that are configured, as some of those accounts
+ * may be disabled by the user.
+ *
+ * Return value: number of active and valid accounts as shown in the @combo_box.
+ */
+int
+e_account_combo_box_count_displayed_accounts (EAccountComboBox *combo_box)
+{
+	g_return_val_if_fail (E_IS_ACCOUNT_COMBO_BOX (combo_box), -1);
+
+	return combo_box->priv->num_displayed_accounts;
+}
diff --git a/widgets/misc/e-account-combo-box.h b/widgets/misc/e-account-combo-box.h
index 12d4be6..6007869 100644
--- a/widgets/misc/e-account-combo-box.h
+++ b/widgets/misc/e-account-combo-box.h
@@ -78,6 +78,8 @@ gboolean	e_account_combo_box_set_active_name
 						(EAccountComboBox *combo_box,
 						 const gchar *account_name);
 
+int		e_account_combo_box_count_displayed_accounts (EAccountComboBox *combo_box);
+
 G_END_DECLS
 
 #endif /* E_ACCOUNT_COMBO_BOX_H */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]