Hide the From header if only one account is set up

This lets us save vertical space in the mail composer
in the common case where the user has only a single
email account configured - then he doesn't need to
choose which account to send from.

Signed-off-by: Federico Mena Quintero <federico@novell.com>
This commit is contained in:
Federico Mena Quintero
2010-05-04 13:39:23 -05:00
parent e496f94b04
commit ac2ef9fb41

View File

@ -276,6 +276,27 @@ skip_custom:
return new_destinations;
}
static int
count_from_accounts (EComposerHeaderTable *table)
{
EComposerHeader *header;
EAccountComboBox *combo_box;
header = e_composer_header_table_get_header (table, E_COMPOSER_HEADER_FROM);
combo_box = E_ACCOUNT_COMBO_BOX (header->input_widget);
return e_account_combo_box_count_displayed_accounts (combo_box);
}
static gboolean
from_header_should_be_visible (EComposerHeaderTable *table)
{
int num_accounts;
num_accounts = count_from_accounts (table);
return (num_accounts > 1);
}
static void
composer_header_table_setup_mail_headers (EComposerHeaderTable *table)
{
@ -288,6 +309,8 @@ composer_header_table_setup_mail_headers (EComposerHeaderTable *table)
EComposerHeader *header;
const gchar *key;
guint binding_id;
gboolean sensitive;
gboolean visible;
binding_id = table->priv->gconf_bindings[ii];
header = e_composer_header_table_get_header (table, ii);
@ -304,10 +327,6 @@ composer_header_table_setup_mail_headers (EComposerHeaderTable *table)
key = COMPOSER_GCONF_PREFIX "/show_mail_cc";
break;
case E_COMPOSER_HEADER_FROM:
key = COMPOSER_GCONF_PREFIX "/show_mail_from";
break;
case E_COMPOSER_HEADER_REPLY_TO:
key = COMPOSER_GCONF_PREFIX "/show_mail_reply_to";
break;
@ -318,22 +337,29 @@ composer_header_table_setup_mail_headers (EComposerHeaderTable *table)
}
switch (ii) {
case E_COMPOSER_HEADER_FROM:
sensitive = TRUE;
visible = from_header_should_be_visible (table);
break;
case E_COMPOSER_HEADER_BCC:
case E_COMPOSER_HEADER_CC:
case E_COMPOSER_HEADER_FROM:
case E_COMPOSER_HEADER_REPLY_TO:
case E_COMPOSER_HEADER_SUBJECT:
case E_COMPOSER_HEADER_TO:
e_composer_header_set_sensitive (header, TRUE);
e_composer_header_set_visible (header, TRUE);
sensitive = TRUE;
visible = TRUE;
break;
default:
e_composer_header_set_sensitive (header, FALSE);
e_composer_header_set_visible (header, FALSE);
sensitive = FALSE;
visible = FALSE;
break;
}
e_composer_header_set_sensitive (header, sensitive);
e_composer_header_set_visible (header, visible);
if (key != NULL)
binding_id = gconf_bridge_bind_property (
bridge, key, G_OBJECT (header), "visible");