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); */
}
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;
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:
}
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: */
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;
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
/* 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);