aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@novell.com>2010-05-05 02:14:01 +0800
committerFederico Mena Quintero <federico@novell.com>2010-05-05 04:48:40 +0800
commite496f94b0433b22e1ecdf35328bcaf16b4abb6a4 (patch)
treee1b2da8f5e5de02d8ee30f0e20ebdc7c25073e6b /widgets
parent06c2d6b35fdca4f16c53bdbf85d9e8c3e620ee76 (diff)
downloadgsoc2013-evolution-e496f94b0433b22e1ecdf35328bcaf16b4abb6a4.tar.gz
gsoc2013-evolution-e496f94b0433b22e1ecdf35328bcaf16b4abb6a4.tar.zst
gsoc2013-evolution-e496f94b0433b22e1ecdf35328bcaf16b4abb6a4.zip
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>
Diffstat (limited to 'widgets')
-rw-r--r--widgets/misc/e-account-combo-box.c22
-rw-r--r--widgets/misc/e-account-combo-box.h2
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 */