* Fixed an small leak
[modest] / src / maemo / modest-account-settings-dialog.c
index da42c8f..43cb5c9 100644 (file)
@@ -66,8 +66,6 @@
 #include <config.h>
 #endif
 
-#define EXAMPLE_EMAIL_ADDRESS "first.last@provider.com"
-
 #define PORT_MIN 1
 #define PORT_MAX 65535
 
@@ -172,6 +170,15 @@ on_modified_number_editor_changed (HildonNumberEditor *number_editor, gint new_v
        self->modified = TRUE;
 }
 
+static void       
+on_number_editor_notify (HildonNumberEditor *editor, GParamSpec *arg1, gpointer user_data)
+{
+       ModestAccountSettingsDialog *dialog = MODEST_ACCOUNT_SETTINGS_DIALOG (user_data);
+       gint value = hildon_number_editor_get_value (editor);
+
+       gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, value > 0);
+}
+
 /* Set a modified boolean whenever the widget is changed, 
  * so we can check for it later.
  */
@@ -181,6 +188,7 @@ connect_for_modified (ModestAccountSettingsDialog *self, GtkWidget *widget)
        if (HILDON_IS_NUMBER_EDITOR (widget)) {
                g_signal_connect (G_OBJECT (widget), "notify::value",
                        G_CALLBACK (on_modified_number_editor_changed), self);
+               g_signal_connect (G_OBJECT (widget), "notify", G_CALLBACK (on_number_editor_notify), self);
        }
        else if (GTK_IS_ENTRY (widget)) {
                g_signal_connect (G_OBJECT (widget), "changed",
@@ -529,7 +537,7 @@ create_page_user_details (ModestAccountSettingsDialog *self)
        hildon_gtk_entry_set_input_mode (GTK_ENTRY (self->entry_user_email), HILDON_GTK_INPUT_MODE_FULL);
        caption = create_caption_new_with_asterisk (self, sizegroup, 
                _("mcen_li_emailsetup_email_address"), self->entry_user_email, NULL, HILDON_CAPTION_MANDATORY);
-       gtk_entry_set_text (GTK_ENTRY (self->entry_user_email), EXAMPLE_EMAIL_ADDRESS); /* Default text. */
+       gtk_entry_set_text (GTK_ENTRY (self->entry_user_email), MODEST_EXAMPLE_EMAIL_ADDRESS); /* Default text. */
        gtk_widget_show (self->entry_user_email);
        connect_for_modified (self, self->entry_user_email);
        gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
@@ -705,7 +713,8 @@ on_button_outgoing_smtp_servers (GtkButton *button, gpointer user_data)
        /* Show the window: */  
        gtk_window_set_transient_for (GTK_WINDOW (self->specific_window), GTK_WINDOW (self));
        gtk_window_set_modal (GTK_WINDOW (self->specific_window), TRUE);
-    gtk_widget_show (self->specific_window);
+       gtk_widget_show (self->specific_window);
+       self->modified = TRUE;
 }
 
 static void
@@ -900,39 +909,6 @@ static GtkWidget* create_page_outgoing (ModestAccountSettingsDialog *self)
        
        return GTK_WIDGET (scrollwin);
 }
-
-
-/** TODO: This doesn't work because hildon_number_editor_get_value() does not work until 
- * focus has been lost:
- * See https://bugs.maemo.org/show_bug.cgi?id=1806.
- */
-static gboolean
-check_hildon_number_editor_and_warn_value_not_in_range (HildonNumberEditor *widget, gint min, gint max)
-{
-       g_return_val_if_fail (widget, FALSE);
-       
-       const gint port = hildon_number_editor_get_value (widget);
-       /* printf ("DEBUG: %s, port=%d\n", __FUNCTION__, port); */
-       if (port < PORT_MIN || 
-               port > PORT_MAX) {
-                       
-               /* Warn the user via a dialog: */
-               gchar *message = g_strdup_printf (_CS("ckct_ib_set_a_value_within_range"), 
-                                      min, 
-                                      max);
-               hildon_banner_show_information (GTK_WIDGET (widget), NULL, message);
-               g_free (message);
-               message = NULL;
-
-               /* Return focus to the email address entry: */
-               gtk_widget_grab_focus (GTK_WIDGET (widget));
-               
-               return FALSE;
-       }
-       
-       return TRUE;
-}
-
        
 static gboolean
 check_data (ModestAccountSettingsDialog *self)
@@ -1007,18 +983,6 @@ check_data (ModestAccountSettingsDialog *self)
                return FALSE;
        }
        
-       /* Check that the port numbers are acceptable: */
-       if (!check_hildon_number_editor_and_warn_value_not_in_range ( 
-               HILDON_NUMBER_EDITOR (self->entry_incoming_port), PORT_MIN, PORT_MAX)) {
-               return FALSE;
-       }
-               
-       if (!check_hildon_number_editor_and_warn_value_not_in_range ( 
-               HILDON_NUMBER_EDITOR (self->entry_outgoing_port), PORT_MIN, PORT_MAX)) {
-               return FALSE;
-       }
-
-               
        /* Find a suitable authentication method when secure authentication is desired */
 
        const gint port_num = hildon_number_editor_get_value (
@@ -1214,6 +1178,9 @@ modest_account_settings_dialog_init (ModestAccountSettingsDialog *self)
         * because there is no sensible way to save the state: */
     modest_window_mgr_prevent_hibernation_while_window_is_shown (
        modest_runtime_get_window_mgr (), GTK_WINDOW (self)); 
+
+    hildon_help_dialog_help_enable (GTK_DIALOG(self), "applications_email_accountsettings",
+                                   modest_maemo_utils_get_osso_context());
 }
 
 ModestAccountSettingsDialog*