* revert to the in-place 'modest_text_utils_get_display_address',
[modest] / src / maemo / modest-connection-specific-smtp-window.c
index b6d276e..e8c76a5 100644 (file)
@@ -65,6 +65,8 @@ struct _ModestConnectionSpecificSmtpWindowPrivate
        ModestAccountMgr *account_manager;
 };
 
+static gboolean on_key_pressed (GtkWidget *self, GdkEventKey *event, gpointer user_data);
+
 static void
 modest_connection_specific_smtp_window_get_property (GObject *object, guint property_id,
                                                                                                                        GValue *value, GParamSpec *pspec)
@@ -452,6 +454,11 @@ modest_connection_specific_smtp_window_init (ModestConnectionSpecificSmtpWindow
 
        /* Set window title */
        gtk_window_set_title (GTK_WINDOW (self), _("mcen_ti_optionalsmtp_servers"));
+
+       /* Track key presses to close the window if the Escape is pressed */
+       g_signal_connect (G_OBJECT (self), 
+                         "key-press-event", 
+                         G_CALLBACK (on_key_pressed), NULL);
 }
 
 ModestConnectionSpecificSmtpWindow*
@@ -515,23 +522,22 @@ modest_connection_specific_smtp_window_save_server_accounts (ModestConnectionSpe
                                
                        } else {
                                /* Change an existing server account: */
-                               success = modest_account_mgr_set_string (priv->account_manager, server_account_name,
-                                       MODEST_ACCOUNT_HOSTNAME, data->hostname, TRUE /* server account */);
+                               modest_account_mgr_set_server_account_hostname (priv->account_manager, server_account_name, 
+                                                                               data->hostname);
                                                
-                               modest_server_account_set_username (priv->account_manager, server_account_name,
+                               modest_account_mgr_set_server_account_username (priv->account_manager, server_account_name,
                                        data->username);
                                                        
-                               modest_server_account_set_password (priv->account_manager, server_account_name,
+                               modest_account_mgr_set_server_account_password (priv->account_manager, server_account_name,
                                        data->password);
                                                
-                               modest_server_account_set_secure_auth (priv->account_manager, server_account_name, 
+                               modest_account_mgr_set_server_account_secure_auth (priv->account_manager, server_account_name, 
                                        data->secure_auth);
                                                
-                               modest_server_account_set_security (priv->account_manager, server_account_name, 
+                               modest_account_mgr_set_server_account_security (priv->account_manager, server_account_name, 
                                        data->security);
-                               
-                               modest_account_mgr_set_int (priv->account_manager, server_account_name,
-                                               MODEST_ACCOUNT_PORT, data->port, TRUE /* server account */);
+
+                               modest_account_mgr_set_server_account_port (priv->account_manager, server_account_name, data->port);
                        }
                }
                
@@ -566,8 +572,8 @@ void update_model_server_names (ModestConnectionSpecificSmtpWindow *self)
                                 
                if (server_account_name) {
                        /* Get the server hostname and show it in the treemodel: */     
-                       gchar *hostname = modest_account_mgr_get_string (priv->account_manager, 
-                               server_account_name, MODEST_ACCOUNT_HOSTNAME, TRUE /* server account */);
+                       gchar *hostname = modest_account_mgr_get_server_account_hostname (priv->account_manager, 
+                                                                                         server_account_name);
                        gtk_list_store_set (GTK_LIST_STORE (priv->model), &iter, 
                                            MODEL_COL_SERVER_NAME, hostname,
                                            -1);
@@ -583,3 +589,15 @@ void update_model_server_names (ModestConnectionSpecificSmtpWindow *self)
        }
 }
 
+static gboolean
+on_key_pressed (GtkWidget *self,
+               GdkEventKey *event,
+               gpointer user_data)
+{
+       if (event->keyval == GDK_Escape) {
+               /* Simulate a press on Cancel to close the dialog */
+               on_button_cancel (NULL, self);
+       }
+       
+       return FALSE;
+}