diff options
-rw-r--r-- | widgets/misc/e-account-combo-box.c | 22 | ||||
-rw-r--r-- | 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 0ded393e72..786478a5e3 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 12d4be6c72..60078690e9 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 */ |