* src/maemo/easysetup/modest-easysetup-country-combo-box.c:
[modest] / src / maemo / easysetup / modest-easysetup-country-combo-box.c
index 1db0ef4..9bdef19 100644 (file)
@@ -191,10 +191,10 @@ static void load_from_file (EasysetupCountryComboBox *self)
        EasysetupCountryComboBoxPrivate *priv = COUNTRY_COMBO_BOX_GET_PRIVATE (self);
        
        /* Load the file one line at a time: */
-#ifndef MODEST_HILDON_VERSION_0
+#ifdef MODEST_HILDON_VERSION_0
        const gchar* filepath = PROVIDER_DATA_DIR "/mcc_mapping";
 #else
-       /* this is the official version, in the 'operator-wizard-settings' package */
+       /* This is the official version, in the 'operator-wizard-settings' package */
        const gchar* filepath = "/usr/share/operator-wizard/mcc_mapping";
 #endif /*MODEST_HILDON_VERSION_0*/
        /* printf ("DEBUG: %s: filepath=%s\n", __FUNCTION__, filepath); */
@@ -213,13 +213,13 @@ static void load_from_file (EasysetupCountryComboBox *self)
        }
 
        GtkListStore *liststore = GTK_LIST_STORE (priv->model);
-                       
+
        /* We use the getline() GNU extension,
         * because it reads per line, which simplifies our code,
         * and it doesn't require us to hard-code a buffer length.
         * TODO: Could we make this faster?
         */
-       int len = 0;
+       unsigned int len = 0;
        char *line = NULL;
        guint previous_id = 0;
        gchar* previous_country = NULL;
@@ -236,7 +236,7 @@ static void load_from_file (EasysetupCountryComboBox *self)
                        
                        if (previous_country) {
                                /* printf ("  debug: storing id=%d for country=%s\n", previous_id, previous_country); */
-                               list = g_slist_append (list, GUINT_TO_POINTER (previous_id));
+                               list = g_slist_prepend (list, GUINT_TO_POINTER (previous_id));
                        }
                        
                        /* Group multiple MMC IDs for the same country together:
@@ -270,14 +270,16 @@ static void load_from_file (EasysetupCountryComboBox *self)
                        }
                        
                        g_free (previous_country);
-                       previous_country = g_strdup (country);
+                       previous_country = country;
                        
                        const guint id = (guint)g_ascii_strtod(id_str, NULL); /* Note that this parses locale-independent text. */
                        previous_id = id;
                }
+               else if (country) {
+                       g_free (country);
+               }
                
                g_free (id_str);
-               g_free (country);
        }
        
        /* Deal with the last country: */
@@ -289,7 +291,9 @@ static void load_from_file (EasysetupCountryComboBox *self)
        GtkTreeIter iter;
        gtk_list_store_append (liststore, &iter);
        gtk_list_store_set(liststore, &iter, MODEL_COL_IDS, list, MODEL_COL_NAME, name_translated, -1);
-       
+
+       g_free(previous_country);
+
        if (list) {
                g_slist_free (list);
                list = NULL;
@@ -300,6 +304,10 @@ static void load_from_file (EasysetupCountryComboBox *self)
                free (line);
                
        fclose (file);
+       
+       /* Sort the items: */
+       gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (liststore), 
+               MODEL_COL_NAME, GTK_SORT_ASCENDING);
 }
 
 static void
@@ -322,6 +330,7 @@ easysetup_country_combo_box_init (EasysetupCountryComboBox *self)
        /* Country column:
         * The ID model column in not shown in the view. */
        GtkCellRenderer *renderer = gtk_cell_renderer_text_new ();
+       g_object_set (G_OBJECT (renderer), "ellipsize", PANGO_ELLIPSIZE_END, NULL);
        gtk_cell_layout_pack_start(GTK_CELL_LAYOUT (combobox), renderer, TRUE);
        gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer, 
        "text", MODEL_COL_NAME, NULL);