[evolution] Bug 584902 – Disabled default account hides "From" in composer
- From: Matthew Barnes <mbarnes src gnome org>
- To: svn-commits-list gnome org
- Subject: [evolution] Bug 584902 – Disabled default account hides "From" in composer
- Date: Sun, 14 Jun 2009 15:33:20 -0400 (EDT)
commit 1276d2a9b42398e7ec978efc24e99aa6cd31e631
Author: Matthew Barnes <mbarnes redhat com>
Date: Sun Jun 14 15:30:14 2009 -0400
Bug 584902 â?? Disabled default account hides "From" in composer
widgets/misc/e-account-combo-box.c | 47 ++++++++++++++++++++++++++++++++---
1 files changed, 43 insertions(+), 4 deletions(-)
---
diff --git a/widgets/misc/e-account-combo-box.c b/widgets/misc/e-account-combo-box.c
index 7663f0f..a0d02bc 100644
--- a/widgets/misc/e-account-combo-box.c
+++ b/widgets/misc/e-account-combo-box.c
@@ -64,6 +64,44 @@ account_combo_box_has_dupes (GList *list,
return (count > 1);
}
+static EAccount *
+account_combo_box_choose_account (EAccountComboBox *combo_box)
+{
+ EAccountList *account_list;
+ EAccount *account;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+
+ account_list = e_account_combo_box_get_account_list (combo_box);
+ g_return_val_if_fail (account_list != NULL, NULL);
+
+ /* First try the default account. */
+
+ /* XXX EAccountList misuses const. */
+ account = (EAccount *)
+ e_account_list_get_default (account_list);
+
+ /* If there is no default account, give up. */
+ if (account == NULL)
+ return NULL;
+
+ /* Make sure the default account appears in the combo box. */
+ if (g_hash_table_lookup (combo_box->priv->index, account) != NULL)
+ return account;
+
+ /* Default account is disabled or otherwise unusable,
+ * so fall back to the first account in the combo box. */
+
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box));
+
+ if (!gtk_tree_model_get_iter_first (model, &iter))
+ return NULL;
+
+ gtk_tree_model_get (model, &iter, COLUMN_ACCOUNT, &account, -1);
+
+ return account;
+}
+
static gboolean
account_combo_box_test_account (EAccount *account)
{
@@ -416,11 +454,12 @@ e_account_combo_box_set_active (EAccountComboBox *combo_box,
account_list = combo_box->priv->account_list;
g_return_val_if_fail (account_list != NULL, FALSE);
- /* NULL means select the default account. */
- /* XXX EAccountList misuses const. */
+ /* NULL means choose an account ourselves. */
if (account == NULL)
- account = (EAccount *)
- e_account_list_get_default (account_list);
+ account = account_combo_box_choose_account (combo_box);
+
+ if (account == NULL)
+ return FALSE;
/* Lookup the tree row reference for the account. */
reference = g_hash_table_lookup (combo_box->priv->index, account);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]