GtkWidget *button_ok;
GtkWidget *button_cancel;
+
+ gboolean is_dirty;
};
static void
};
static void
+on_change(GtkWidget* widget, ModestConnectionSpecificSmtpEditWindow *self)
+{
+ ModestConnectionSpecificSmtpEditWindowPrivate *priv =
+ CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW_GET_PRIVATE (self);
+ priv->is_dirty = TRUE;
+}
+
+static void
on_combo_security_changed (GtkComboBox *widget, gpointer user_data)
{
ModestConnectionSpecificSmtpEditWindow *self =
ModestConnectionSpecificSmtpEditWindowPrivate *priv =
CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW_GET_PRIVATE (self);
+ on_change(GTK_WIDGET(widget), self);
+
const gint port_number =
modest_serversecurity_combo_box_get_active_serversecurity_port (
MODEST_SERVERSECURITY_COMBO_BOX (priv->combo_outgoing_security));
priv->entry_outgoingserver = gtk_entry_new ();
/* Auto-capitalization is the default, so let's turn it off: */
hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_outgoingserver), HILDON_GTK_INPUT_MODE_FULL);
+ g_signal_connect(G_OBJECT(priv->entry_outgoingserver), "changed", G_CALLBACK(on_change), self);
+
GtkWidget *caption = hildon_caption_new (sizegroup,
_("mcen_li_emailsetup_smtp"), priv->entry_outgoingserver, NULL, HILDON_CAPTION_OPTIONAL);
gtk_widget_show (priv->entry_outgoingserver);
priv->combo_outgoing_auth = GTK_WIDGET (modest_secureauth_combo_box_new ());
caption = hildon_caption_new (sizegroup, _("mcen_li_emailsetup_secure_authentication"),
priv->combo_outgoing_auth, NULL, HILDON_CAPTION_OPTIONAL);
+ g_signal_connect (G_OBJECT (priv->combo_outgoing_auth), "changed", G_CALLBACK(on_change), self);
gtk_widget_show (priv->combo_outgoing_auth);
gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
gtk_widget_show (caption);
hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_user_username), HILDON_GTK_INPUT_MODE_FULL);
caption = hildon_caption_new (sizegroup, _("mail_fi_username"),
priv->entry_user_username, NULL, HILDON_CAPTION_MANDATORY);
+ g_signal_connect(G_OBJECT(priv->entry_user_username), "changed", G_CALLBACK(on_change), self);
gtk_widget_show (priv->entry_user_username);
gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
gtk_widget_show (caption);
/* gtk_entry_set_invisible_char (GTK_ENTRY (priv->entry_user_password), '*'); */
caption = hildon_caption_new (sizegroup,
_("mail_fi_password"), priv->entry_user_password, NULL, HILDON_CAPTION_OPTIONAL);
+ g_signal_connect(G_OBJECT(priv->entry_user_password), "changed", G_CALLBACK(on_change), self);
gtk_widget_show (priv->entry_user_password);
gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
gtk_widget_show (caption);
priv->entry_port = GTK_WIDGET (hildon_number_editor_new (0, 65535));
caption = hildon_caption_new (sizegroup,
_("mcen_li_emailsetup_smtp"), priv->entry_port, NULL, HILDON_CAPTION_OPTIONAL);
+ /* FIXME: There is no changed signal for hildon_number_editor */
gtk_widget_show (priv->entry_port);
gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
gtk_widget_show (caption);
gtk_dialog_add_button (GTK_DIALOG (self), GTK_STOCK_OK, GTK_RESPONSE_OK);
gtk_dialog_add_button (GTK_DIALOG (self), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
+ priv->is_dirty = FALSE;
gtk_widget_show (box);
/* port: */
hildon_number_editor_set_value (
HILDON_NUMBER_EDITOR (priv->entry_port), data->port);
+
+
+ /* This will cause changed signals so we set dirty back to FALSE */
+ priv->is_dirty = FALSE;
}
}
return result;
}
+
+gboolean modest_connection_specific_smtp_edit_window_is_dirty(
+ ModestConnectionSpecificSmtpEditWindow *window)
+{
+ ModestConnectionSpecificSmtpEditWindowPrivate *priv =
+ CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW_GET_PRIVATE (window);
+
+ return priv->is_dirty;
+}
#include <gtk/gtkvbox.h>
#include <gtk/gtkstock.h>
+#include "modest-hildon-includes.h"
+
#include <glib/gi18n.h>
G_DEFINE_TYPE (ModestConnectionSpecificSmtpWindow, modest_connection_specific_smtp_window, GTK_TYPE_WINDOW);
}
gtk_window_set_transient_for (GTK_WINDOW (self), GTK_WINDOW (window));
- gint response = gtk_dialog_run (GTK_DIALOG (window));
- gtk_widget_hide (window);
- if (response == GTK_RESPONSE_OK) {
- /* Delete any previous data for this row: */
- if (data)
+ gboolean dialog_finished = FALSE;
+ while (!dialog_finished)
+ {
+ gint response = gtk_dialog_run (GTK_DIALOG (window));
+ if (response == GTK_RESPONSE_OK) {
+ gtk_widget_hide (window);
+ dialog_finished = TRUE;
+ /* Delete any previous data for this row: */
+ if (data)
+ {
+ modest_account_mgr_free_server_account_data (priv->account_manager, data);
+ data = NULL;
+ }
+
+ /* Get the new account data and save it in the row for later:
+ * We free this in finalize(),
+ * and save it to our configuration in
+ * modest_connection_specific_smtp_window_save_server_accounts(). */
+ data = modest_connection_specific_smtp_edit_window_get_settings (
+ MODEST_CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW (window),
+ priv->account_manager);
+
+ const gchar* server_name = data ? data->hostname : NULL;
+ gtk_list_store_set (GTK_LIST_STORE (priv->model), &iter,
+ MODEL_COL_SERVER_ACCOUNT_DATA, data,
+ MODEL_COL_SERVER_NAME, server_name,
+ -1);
+ }
+ else
{
- modest_account_mgr_free_server_account_data (priv->account_manager, data);
- data = NULL;
+ if (!modest_connection_specific_smtp_edit_window_is_dirty(
+ MODEST_CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW(window)))
+ {
+ gtk_widget_hide(window);
+ dialog_finished = TRUE;
+ }
+ else
+ {
+
+ /* FIXME: Add a logical ID here */
+ GtkDialog *dialog = GTK_DIALOG (hildon_note_new_confirmation (GTK_WINDOW (window),
+ _("All changes made to the SMTP settings will be lost. Continue anyway?")));
+ /* TODO: These button names will be ambiguous, and not specified in the UI specification. */
+
+ const gint dialog_response = gtk_dialog_run (dialog);
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+
+ if (dialog_response == GTK_RESPONSE_OK)
+ {
+ gtk_widget_hide(window);
+ dialog_finished = TRUE;
+ }
+ }
}
-
- /* Get the new account data and save it in the row for later:
- * We free this in finalize(),
- * and save it to our configuration in
- * modest_connection_specific_smtp_window_save_server_accounts(). */
- data = modest_connection_specific_smtp_edit_window_get_settings (
- MODEST_CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW (window),
- priv->account_manager);
-
- const gchar* server_name = data ? data->hostname : NULL;
- gtk_list_store_set (GTK_LIST_STORE (priv->model), &iter,
- MODEL_COL_SERVER_ACCOUNT_DATA, data,
- MODEL_COL_SERVER_NAME, server_name,
- -1);
}
}
-
g_free (connection_name);
g_free (id);
g_free (server_account_name);