#define PORT_MIN 1
#define PORT_MAX 65535
+#define RESPONSE_DELETE_DUMMY 1
+#define RESPONSE_SIGNATURE_DUMMY 2
+
static void modest_account_settings_dialog_init (gpointer g, gpointer iface_data);
G_DEFINE_TYPE_EXTENDED (ModestDefaultAccountSettingsDialog,
if (priv->account_manager)
g_object_unref (G_OBJECT (priv->account_manager));
- if (priv->signature_dialog)
- gtk_widget_destroy (priv->signature_dialog);
-
if (priv->settings) {
g_object_unref (priv->settings);
priv->settings = NULL;
static void
-on_button_signature (GtkButton *button, gpointer user_data)
+signature_button_clicked (ModestDefaultAccountSettingsDialog *self)
{
- ModestDefaultAccountSettingsDialog *self;
gint response;
ModestDefaultAccountSettingsDialogPrivate *priv;
- self = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG (user_data);
priv = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE (self);
/* Create the window, if necessary: */
if (!(priv->signature_dialog)) {
priv->signature_dialog = GTK_WIDGET (modest_signature_editor_dialog_new ());
-
+
gboolean use_signature = modest_account_settings_get_use_signature (priv->settings);
const gchar *signature = modest_account_settings_get_signature(priv->settings);
gchar* account_title = get_entered_account_title (self);
}
}
-static void
-on_button_delete (GtkButton *button, gpointer user_data)
+static gboolean
+delete_button_clicked (ModestDefaultAccountSettingsDialog *self)
{
- ModestDefaultAccountSettingsDialog *self;
ModestDefaultAccountSettingsDialogPrivate *priv;
gchar *account_title;
gboolean removed;
- self = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG (user_data);
priv = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE (self);
if (priv->modified)
(const gchar *) account_title);
g_free (account_title);
- /* Close window */
- if (removed)
- gtk_widget_destroy (GTK_WIDGET (self));
+ return removed;
}
static GtkWidget*
box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
title_sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
value_sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
-
+
/* The name widgets: */
priv->entry_user_name = GTK_WIDGET (modest_validating_entry_new ());
/* Auto-capitalization is the default, so let's turn it off: */
- hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_user_name), HILDON_GTK_INPUT_MODE_FULL);
+ hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_user_name),
+ HILDON_GTK_INPUT_MODE_FULL |
+ HILDON_GTK_INPUT_MODE_AUTOCAP);
/* Set max length as in the UI spec:
* The UI spec seems to want us to show a dialog if we hit the maximum. */
gtk_entry_set_max_length (GTK_ENTRY (priv->entry_user_name), 64);
/* Delete button: */
if (!priv->button_delete)
- priv->button_delete = gtk_button_new_with_label (_HL("wdgt_bd_delete"));
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (self)->action_area), priv->button_delete,
- FALSE, FALSE, 0);
+ priv->button_delete = gtk_dialog_add_button (GTK_DIALOG (self),
+ _HL("wdgt_bd_delete"),
+ RESPONSE_DELETE_DUMMY);
/* Signature button: */
if (!priv->button_signature)
- priv->button_signature = gtk_button_new_with_label (_("mcen_bd_email_signature"));
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (self)->action_area), priv->button_signature,
- FALSE, FALSE, 0);
+ priv->button_signature = gtk_dialog_add_button (GTK_DIALOG (self),
+ _("mcen_bd_email_signature"),
+ RESPONSE_SIGNATURE_DUMMY);
gtk_widget_show (priv->button_signature);
g_object_unref (title_sizegroup);
g_object_unref (value_sizegroup);
-
- g_signal_connect (G_OBJECT (priv->button_signature), "clicked",
- G_CALLBACK (on_button_signature), self);
-
- g_signal_connect (G_OBJECT (priv->button_delete), "clicked",
- G_CALLBACK (on_button_delete), self);
-
+
gtk_widget_show (GTK_WIDGET (box));
return GTK_WIDGET (box);
G_CALLBACK (on_missing_mandatory_data), self);
GtkWidget *separator = gtk_hseparator_new ();
- gtk_box_pack_start (GTK_BOX (box), separator, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (box), separator, FALSE, FALSE, MODEST_MARGIN_DEFAULT);
gtk_widget_show (separator);
/* connection-specific checkbox: */
gboolean prevent_response = FALSE, sec_changed;
ModestSecurityOptionsView *incoming_sec, *outgoing_sec;
+ /* Dummy and delete buttons have a response id because they're
+ added with gtk_dialog_add_button in order to get the proper
+ theme */
+ if (response_id == RESPONSE_SIGNATURE_DUMMY) {
+ signature_button_clicked (self);
+ g_signal_stop_emission_by_name (wizard_dialog, "response");
+ return;
+ }
+
+ if (response_id == RESPONSE_DELETE_DUMMY) {
+ if (!delete_button_clicked (self))
+ g_signal_stop_emission_by_name (wizard_dialog, "response");
+ return;
+ }
+
priv = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE (self);
enable_buttons (self);
}
if (prevent_response) {
- /* This is a nasty hack. murrayc. */
/* Don't let the dialog close */
g_signal_stop_emission_by_name (wizard_dialog, "response");
return;
separator = gtk_hseparator_new ();
gtk_box_pack_start (GTK_BOX (priv->main_container), separator,
- FALSE, FALSE, 0);
+ FALSE, FALSE, MODEST_MARGIN_DEFAULT);
gtk_widget_show (separator);
gtk_box_pack_start (GTK_BOX (priv->main_container),
priv->page_incoming,
FALSE, FALSE, 0);
separator = gtk_hseparator_new ();
gtk_box_pack_start (GTK_BOX (priv->main_container), separator,
- FALSE, FALSE, 0);
+ FALSE, FALSE, MODEST_MARGIN_DEFAULT);
gtk_widget_show (separator);
gtk_box_pack_start (GTK_BOX (priv->main_container),
priv->page_outgoing,
ModestProtocolRegistry *protocol_registry;
const gchar *account_name, *server_account_name;
ModestDefaultAccountSettingsDialogPrivate *priv;
- gboolean username_known;
g_return_if_fail (MODEST_IS_ACCOUNT_SETTINGS_DIALOG (dialog));
g_return_if_fail (MODEST_IS_ACCOUNT_SETTINGS (settings));
priv = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE (dialog);
protocol_registry = modest_runtime_get_protocol_registry ();
- incoming_account = modest_account_settings_get_store_settings (settings);
- outgoing_account = modest_account_settings_get_transport_settings (settings);
-
account_name = modest_account_settings_get_account_name (settings);
-
+
/* Save the account name so we can refer to it later: */
if (priv->account_name)
g_free (priv->account_name);
if (priv->settings)
g_object_unref (priv->settings);
priv->settings = g_object_ref (settings);
-
+
/* Save the account title so we can refer to it if the user changes it: */
if (priv->original_account_title)
g_free (priv->original_account_title);
priv->original_account_title = g_strdup (modest_account_settings_get_display_name (settings));
-
+
/* Show the account data in the widgets: */
-
+
/* Note that we never show the non-display name in the UI.
* (Though the display name defaults to the non-display name at the start.) */
gtk_entry_set_text( GTK_ENTRY (priv->entry_account_title),
modest_limit_retrieve_picker_set_active_limit_retrieve (
MODEST_LIMIT_RETRIEVE_PICKER (priv->limit_retrieve_picker),
modest_account_settings_get_retrieve_limit (settings));
-
-
+
hildon_check_button_set_active (HILDON_CHECK_BUTTON (priv->checkbox_leave_messages),
modest_account_settings_get_leave_messages_on_server (settings));
-
+ incoming_account = modest_account_settings_get_store_settings (settings);
if (incoming_account) {
const gchar *username, *password, *hostname, *proto_str, *account_title;
gchar *proto_name, *title;
modest_retrieve_picker_fill (MODEST_RETRIEVE_PICKER (priv->retrieve_picker), modest_server_account_settings_get_protocol (incoming_account));
modest_retrieve_picker_set_active_retrieve_conf (MODEST_RETRIEVE_PICKER (priv->retrieve_picker),
modest_account_settings_get_retrieve_type (settings));
-
+
if (!modest_protocol_registry_protocol_type_has_leave_on_server (protocol_registry,
modest_server_account_settings_get_protocol (incoming_account))) {
gtk_widget_hide (priv->checkbox_leave_messages);
/* Remember this for later: */
incoming_protocol = modest_server_account_settings_get_protocol (incoming_account);;
-
+
hostname = modest_server_account_settings_get_hostname (incoming_account);
username = modest_server_account_settings_get_username (incoming_account);
password = modest_server_account_settings_get_password (incoming_account);
null_means_empty (username));
gtk_entry_set_text( GTK_ENTRY (priv->entry_user_password),
null_means_empty (password));
-
+
gtk_entry_set_text( GTK_ENTRY (priv->entry_incomingserver),
null_means_empty (hostname));
MODEST_SECURITY_OPTIONS_VIEW (priv->incoming_security),
settings);
gtk_widget_show (priv->incoming_security);
-
+
/* Update the incoming label */
update_incoming_server_title (MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG (dialog),
incoming_protocol);
-
+
/* Set window title according to account */
proto_str = modest_protocol_get_display_name (modest_protocol_registry_get_protocol_by_type (protocol_registry, incoming_protocol));
proto_name = g_utf8_strup (proto_str, -1);
account_title = modest_account_settings_get_display_name(settings);
title = g_strdup_printf(_("mcen_ti_account_settings"), proto_name, account_title);
-
+
gtk_window_set_title (GTK_WINDOW (dialog), title);
g_free (proto_name);
g_free (title);
g_object_unref (incoming_account);
}
-
+
outgoing_account = modest_account_settings_get_transport_settings (settings);
if (outgoing_account) {
const gchar *hostname;
/* Switch to user page */
/* Check if we allow changes or not */
server_account_name = modest_server_account_settings_get_account_name (incoming_account);
- username_known =
- modest_account_mgr_get_server_account_username_has_succeeded (priv->account_manager,
- server_account_name);
- gtk_widget_set_sensitive (priv->entry_user_username, !username_known);
- gtk_widget_set_sensitive (priv->entry_incomingserver, !username_known);
- modest_security_options_view_enable_changes (MODEST_SECURITY_OPTIONS_VIEW (priv->incoming_security),
- !username_known);
-
+ if (server_account_name) {
+ gboolean username_known;
+
+ username_known =
+ modest_account_mgr_get_server_account_username_has_succeeded (priv->account_manager,
+ server_account_name);
+ gtk_widget_set_sensitive (priv->entry_user_username, !username_known);
+ gtk_widget_set_sensitive (priv->entry_incomingserver, !username_known);
+ modest_security_options_view_enable_changes (MODEST_SECURITY_OPTIONS_VIEW (priv->incoming_security),
+ !username_known);
+ }
/* Unset the modified flag so we can detect changes later: */
priv->modified = FALSE;
{
gboolean enable_ok = TRUE;
ModestProtocolRegistry *protocol_registry;
+ ModestSecurityOptionsView *sec_view;
ModestDefaultAccountSettingsDialogPrivate *priv;
priv = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE (self);
-
+
/* The account details title is mandatory: */
if (entry_is_empty(priv->entry_account_title))
enable_ok = FALSE;
/* The user details username is mandatory: */
if (enable_ok && entry_is_empty(priv->entry_user_username))
enable_ok = FALSE;
-
+
/* The user details email address is mandatory: */
if (enable_ok && entry_is_empty (priv->entry_user_email))
enable_ok = FALSE;
if (enable_ok && entry_is_empty(priv->entry_incomingserver))
enable_ok = FALSE;
+ sec_view = MODEST_SECURITY_OPTIONS_VIEW (priv->incoming_security);
+ if (enable_ok &&
+ modest_security_options_view_has_missing_mandatory_data (sec_view))
+ enable_ok = FALSE;
+
/* The custom outgoing server is mandatory: */
if (enable_ok && entry_is_empty(priv->entry_outgoingserver))
enable_ok = FALSE;
+ sec_view = MODEST_SECURITY_OPTIONS_VIEW (priv->outgoing_security);
+ if (enable_ok &&
+ modest_security_options_view_has_missing_mandatory_data (sec_view))
+ enable_ok = FALSE;
+
protocol_registry = modest_runtime_get_protocol_registry ();
-
+
/* Enable the buttons,
* identifying them via their associated response codes:
*/