* trunk: together with the update modest-providers-data (r4454), fixes NB#84852
[modest] / src / maemo / easysetup / modest-easysetup-provider-combo-box.c
index 0ca0cf3..ce36138 100644 (file)
@@ -114,7 +114,7 @@ enum MODEL_COLS {
  * strictly, we should sort providers with mcc=0 after the other ones.... but, we don't have
  * that info here, so ignoring for now.
  */
-gint
+static gint
 provider_sort_func (GtkTreeModel *model, GtkTreeIter *iter1, GtkTreeIter *iter2, gpointer user_data)
 {
        gchar *prov1, *prov2;
@@ -177,6 +177,8 @@ void
 easysetup_provider_combo_box_fill (EasysetupProviderComboBox *combobox, ModestPresets *presets,
                                   gint mcc)
 {      
+       g_return_if_fail (EASYSETUP_IS_PROVIDER_COMBO_BOX(combobox));
+       
        EasysetupProviderComboBoxPrivate *priv = PROVIDER_COMBO_BOX_GET_PRIVATE (combobox);
        
        /* Remove any existing rows: */
@@ -194,7 +196,7 @@ easysetup_provider_combo_box_fill (EasysetupProviderComboBox *combobox, ModestPr
        while(iter_provider_names && *iter_provider_names && iter_provider_ids && *iter_provider_ids) {
                const gchar* provider_name = *iter_provider_names;
                const gchar* provider_id = *iter_provider_ids;
-               
+
                /* Prevent duplicate providers: */
                if (g_slist_find_custom (provider_ids_used_already, 
                                         provider_id, (GCompareFunc)strcmp) == NULL) {
@@ -211,11 +213,11 @@ easysetup_provider_combo_box_fill (EasysetupProviderComboBox *combobox, ModestPr
                        provider_ids_used_already = g_slist_prepend (
                                provider_ids_used_already, (gpointer)g_strdup (provider_id));
                }
-
-                       ++iter_provider_names;
-                       ++iter_provider_ids;
-               }
-
+               
+               ++iter_provider_names;
+               ++iter_provider_ids;
+       }
+       
        /* Free the result of modest_presets_get_providers()
         * as specified by its documentation: */
        g_strfreev (provider_names);
@@ -227,7 +229,9 @@ easysetup_provider_combo_box_fill (EasysetupProviderComboBox *combobox, ModestPr
        /* TODO: We need a Logical ID for this text. */
        GtkTreeIter iter;
        gtk_list_store_prepend (liststore, &iter);
-       gtk_list_store_set (liststore, &iter, MODEL_COL_ID, 0, MODEL_COL_NAME, _("mcen_va_serviceprovider_other"),
+       gtk_list_store_set (liststore, &iter,
+                           MODEL_COL_ID, 0,
+                           MODEL_COL_NAME, _("mcen_va_serviceprovider_other"),
                            -1);
        
        /* Select the "Other" item: */
@@ -245,6 +249,9 @@ gchar*
 easysetup_provider_combo_box_get_active_provider_id (EasysetupProviderComboBox *combobox)
 {
        GtkTreeIter active;
+
+       g_return_val_if_fail (EASYSETUP_IS_PROVIDER_COMBO_BOX(combobox), NULL);
+
        const gboolean found = gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combobox), &active);
        if (found) {
                EasysetupProviderComboBoxPrivate *priv = PROVIDER_COMBO_BOX_GET_PRIVATE (combobox);
@@ -256,3 +263,17 @@ easysetup_provider_combo_box_get_active_provider_id (EasysetupProviderComboBox *
 
        return NULL; /* Failed. */
 }
+
+void 
+easysetup_provider_combo_box_set_others_provider (EasysetupProviderComboBox *combobox)
+{
+       GtkTreeModel *model;
+       GtkTreeIter others_iter;
+
+       g_return_if_fail (EASYSETUP_IS_PROVIDER_COMBO_BOX(combobox));
+       
+       model = gtk_combo_box_get_model (GTK_COMBO_BOX (combobox));
+       
+       if (gtk_tree_model_get_iter_first (model, &others_iter))
+               gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combobox), &others_iter);
+}