From: Johannes Schmid Date: Thu, 14 Jun 2007 17:22:18 +0000 (+0000) Subject: 2007-06-14 Johannes Schmid X-Git-Tag: git_migration_finished~3271 X-Git-Url: http://git.maemo.org/git/?p=modest;a=commitdiff_plain;h=cf63d171adc697c5d87d48c4b4b6ff57c7221979 2007-06-14 Johannes Schmid * src/maemo/modest-connection-specific-smtp-edit-window.c: (on_change), (on_combo_security_changed), (modest_connection_specific_smtp_edit_window_init), (modest_connection_specific_smtp_edit_window_set_connection), (modest_connection_specific_smtp_edit_window_is_dirty): * src/maemo/modest-connection-specific-smtp-edit-window.h: * src/maemo/modest-connection-specific-smtp-window.c: (on_button_edit): Show an comfirmation dialog for the smpt-edit-window if there are unsaved changes and the user hits cancel. (projects.maemo.org but NB#60479 pmo-trunk-r2242 --- diff --git a/ChangeLog2 b/ChangeLog2 index cb751cd..1ef6ee1 100644 --- a/ChangeLog2 +++ b/ChangeLog2 @@ -1,3 +1,18 @@ +2007-06-14 Johannes Schmid + + * src/maemo/modest-connection-specific-smtp-edit-window.c: + (on_change), (on_combo_security_changed), + (modest_connection_specific_smtp_edit_window_init), + (modest_connection_specific_smtp_edit_window_set_connection), + (modest_connection_specific_smtp_edit_window_is_dirty): + * src/maemo/modest-connection-specific-smtp-edit-window.h: + * src/maemo/modest-connection-specific-smtp-window.c: + (on_button_edit): + + Show an comfirmation dialog for the smpt-edit-window if there are + unsaved changes and the user hits cancel. + (projects.maemo.org but NB#60479 + 2007-06-14 Armin Burgmeier * src/maemo/easysetup/modest-easysetup-wizard.c: diff --git a/src/maemo/modest-connection-specific-smtp-edit-window.c b/src/maemo/modest-connection-specific-smtp-edit-window.c index 49d72e4..ae1a07d 100644 --- a/src/maemo/modest-connection-specific-smtp-edit-window.c +++ b/src/maemo/modest-connection-specific-smtp-edit-window.c @@ -61,6 +61,8 @@ struct _ModestConnectionSpecificSmtpEditWindowPrivate GtkWidget *button_ok; GtkWidget *button_cancel; + + gboolean is_dirty; }; static void @@ -116,6 +118,14 @@ enum MODEL_COLS { }; 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 = @@ -123,6 +133,8 @@ on_combo_security_changed (GtkComboBox *widget, gpointer user_data) 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)); @@ -153,6 +165,8 @@ modest_connection_specific_smtp_edit_window_init (ModestConnectionSpecificSmtpEd 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); @@ -164,6 +178,7 @@ modest_connection_specific_smtp_edit_window_init (ModestConnectionSpecificSmtpEd 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); @@ -174,6 +189,7 @@ modest_connection_specific_smtp_edit_window_init (ModestConnectionSpecificSmtpEd 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); @@ -196,6 +212,7 @@ modest_connection_specific_smtp_edit_window_init (ModestConnectionSpecificSmtpEd /* 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); @@ -218,6 +235,7 @@ modest_connection_specific_smtp_edit_window_init (ModestConnectionSpecificSmtpEd 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); @@ -230,6 +248,7 @@ modest_connection_specific_smtp_edit_window_init (ModestConnectionSpecificSmtpEd 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); @@ -274,6 +293,10 @@ modest_connection_specific_smtp_edit_window_set_connection ( /* 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; } } @@ -307,3 +330,12 @@ modest_connection_specific_smtp_edit_window_get_settings ( 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; +} diff --git a/src/maemo/modest-connection-specific-smtp-edit-window.h b/src/maemo/modest-connection-specific-smtp-edit-window.h index 278838d..5f57dac 100644 --- a/src/maemo/modest-connection-specific-smtp-edit-window.h +++ b/src/maemo/modest-connection-specific-smtp-edit-window.h @@ -79,7 +79,9 @@ void modest_connection_specific_smtp_edit_window_set_connection ( ModestServerAccountData* modest_connection_specific_smtp_edit_window_get_settings ( ModestConnectionSpecificSmtpEditWindow *window, ModestAccountMgr *account_manager); - + +gboolean modest_connection_specific_smtp_edit_window_is_dirty( + ModestConnectionSpecificSmtpEditWindow *window); G_END_DECLS diff --git a/src/maemo/modest-connection-specific-smtp-window.c b/src/maemo/modest-connection-specific-smtp-window.c index 26278ce..bfeaf36 100644 --- a/src/maemo/modest-connection-specific-smtp-window.c +++ b/src/maemo/modest-connection-specific-smtp-window.c @@ -17,6 +17,8 @@ #include #include +#include "modest-hildon-includes.h" + #include G_DEFINE_TYPE (ModestConnectionSpecificSmtpWindow, modest_connection_specific_smtp_window, GTK_TYPE_WINDOW); @@ -232,33 +234,63 @@ on_button_edit (GtkButton *button, gpointer user_data) } 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);