* Renamed modest-easysetup-wizard by modest-easysetup-wizard-dialog because it was...
[modest] / src / maemo / easysetup / modest-easysetup-country-combo-box.c
index d3c699d..b761ae9 100644 (file)
@@ -159,7 +159,7 @@ static int
 parse_mcc_mapping_line (const char* line,  char** country)
 {
        int i, j;
-       char mcc[3];  /* the mcc code, always 3 bytes*/
+       char mcc[4];  /* the mcc code, always 3 bytes*/
        static char my_country[128];
 
        if (!line) {
@@ -181,9 +181,11 @@ parse_mcc_mapping_line (const char* line,  char** country)
        mcc[0] = line[0];
        mcc[1] = line[1];
        mcc[2] = line[2];
+       mcc[3] = '\0';
        
        *country = my_country;
-       return effective_mcc (atoi((const char *)mcc));
+
+       return effective_mcc ((int) strtol ((const char*)mcc, NULL, 10));
 }
 
 /** Note that the mcc_mapping file is installed 
@@ -204,7 +206,7 @@ load_from_file (EasysetupCountryComboBox *self)
                return;
        }
 
-       while (fgets (line, MAX_LINE_LEN, file) > 0) { 
+       while (fgets (line, MAX_LINE_LEN, file) != NULL) { 
 
                int mcc;
                char *country = NULL;
@@ -246,6 +248,13 @@ static void
 easysetup_country_combo_box_init (EasysetupCountryComboBox *self)
 {
        EasysetupCountryComboBoxPrivate *priv = COUNTRY_COMBO_BOX_GET_PRIVATE (self);
+       priv->model = NULL;
+}
+
+void
+easysetup_country_combo_box_load_data(EasysetupCountryComboBox *self)
+{
+       EasysetupCountryComboBoxPrivate *priv = COUNTRY_COMBO_BOX_GET_PRIVATE (self);
 
        /* Create a tree model for the combo box,
         * with a string for the name, and an int for the MCC ID.
@@ -255,7 +264,6 @@ easysetup_country_combo_box_init (EasysetupCountryComboBox *self)
        
        /* Setup the combo box: */
        GtkComboBox *combobox = GTK_COMBO_BOX (self);
-       gtk_combo_box_set_model (combobox, priv->model);
        
        /* Country column:
         * The ID model column in not shown in the view. */
@@ -271,6 +279,8 @@ easysetup_country_combo_box_init (EasysetupCountryComboBox *self)
        
        /* Fill the model with rows: */
        load_from_file (self);
+       /* Set this _after_ loading from file, it makes loading faster */
+       gtk_combo_box_set_model (combobox, priv->model);
 }
 
 EasysetupCountryComboBox*