X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fhildon2%2Fmodest-provider-picker.c;h=51dc417b9a260a0410c42a317ad451474d098e0d;hb=8d9fe597cc27dab628e0e7ff18d08e11c58f45ec;hp=aef688c8b265eac09ebd168ae478c20d870929a8;hpb=bd1dd4fa59a3cfac003c3fd0c13d75727f36a29c;p=modest diff --git a/src/hildon2/modest-provider-picker.c b/src/hildon2/modest-provider-picker.c index aef688c..51dc417 100644 --- a/src/hildon2/modest-provider-picker.c +++ b/src/hildon2/modest-provider-picker.c @@ -28,6 +28,7 @@ */ #include "modest-provider-picker.h" +#include #include #include #include @@ -35,6 +36,7 @@ #include #include "modest-protocol-registry.h" #include "modest-runtime.h" +#include #include #include /* For memcpy() */ @@ -81,6 +83,21 @@ enum MODEL_COLS { MODEL_COL_ID_TYPE }; +static gint +id_type_index (ModestProviderPickerIdType id_type) +{ + switch (id_type) { + case MODEST_PROVIDER_PICKER_ID_OTHER: + return 2; + break; + case MODEST_PROVIDER_PICKER_ID_PLUGIN_PROTOCOL: + return 1; + break; + case MODEST_PROVIDER_PICKER_ID_PROVIDER: + default: + return 0; + } +} /* * strictly, we should sort providers with mcc=0 after the other ones.... but, we don't have @@ -90,10 +107,21 @@ static gint provider_sort_func (GtkTreeModel *model, GtkTreeIter *iter1, GtkTreeIter *iter2, gpointer user_data) { gchar *prov1, *prov2; + ModestProviderPickerIdType id_type1, id_type2; gint retval; - gtk_tree_model_get (model, iter1, MODEL_COL_NAME, &prov1, -1); - gtk_tree_model_get (model, iter2, MODEL_COL_NAME, &prov2, -1); + gtk_tree_model_get (model, iter1, + MODEL_COL_NAME, &prov1, + MODEL_COL_ID_TYPE, &id_type1, + -1); + gtk_tree_model_get (model, iter2, + MODEL_COL_NAME, &prov2, + MODEL_COL_ID_TYPE, &id_type2, + -1); + + retval = id_type_index (id_type2) - id_type_index (id_type1); + if (retval != 0) + goto end; if (strcmp (prov1, prov2) == 0) retval = 0; @@ -103,7 +131,7 @@ provider_sort_func (GtkTreeModel *model, GtkTreeIter *iter1, GtkTreeIter *iter2, retval = 1; else retval = modest_text_utils_utf8_strcmp (prov1, prov2, TRUE); - +end: g_free (prov1); g_free (prov2); @@ -111,7 +139,7 @@ provider_sort_func (GtkTreeModel *model, GtkTreeIter *iter1, GtkTreeIter *iter2, } static gchar * -touch_selector_print_func (HildonTouchSelector *selector) +touch_selector_print_func (HildonTouchSelector *selector, gpointer userdata) { GtkTreeIter iter; if (hildon_touch_selector_get_selected (HILDON_TOUCH_SELECTOR (selector), 0, &iter)) { @@ -143,6 +171,7 @@ modest_provider_picker_new (HildonSizeType size, ModestProviderPicker *self; GtkCellRenderer *renderer; GtkWidget *selector; + HildonTouchSelectorColumn *column; self = g_object_new (MODEST_TYPE_PROVIDER_PICKER, "arrangement", arrangement, @@ -165,16 +194,29 @@ modest_provider_picker_new (HildonSizeType size, renderer = gtk_cell_renderer_text_new (); g_object_set (G_OBJECT (renderer), "ellipsize", PANGO_ELLIPSIZE_END, NULL); - selector = hildon_touch_selector_new (); - hildon_touch_selector_append_column (HILDON_TOUCH_SELECTOR (selector), GTK_TREE_MODEL (priv->model), - renderer, "text", MODEL_COL_NAME, NULL); + selector = hildon_touch_selector_entry_new (); + hildon_touch_selector_set_print_func (HILDON_TOUCH_SELECTOR (selector), + (HildonTouchSelectorPrintFunc) touch_selector_print_func); + column = hildon_touch_selector_append_column (HILDON_TOUCH_SELECTOR (selector), GTK_TREE_MODEL (priv->model), + renderer, "text", MODEL_COL_NAME, NULL); + hildon_touch_selector_entry_set_text_column (HILDON_TOUCH_SELECTOR_ENTRY (selector), + MODEL_COL_NAME); + /* Set this _after_ loading from file, it makes loading faster */ hildon_touch_selector_set_model (HILDON_TOUCH_SELECTOR (selector), 0, GTK_TREE_MODEL (priv->model)); - hildon_touch_selector_set_print_func (HILDON_TOUCH_SELECTOR (selector), touch_selector_print_func); + hildon_touch_selector_entry_set_input_mode (HILDON_TOUCH_SELECTOR_ENTRY (selector), + HILDON_GTK_INPUT_MODE_ALPHA | + HILDON_GTK_INPUT_MODE_SPECIAL | + HILDON_GTK_INPUT_MODE_NUMERIC | + HILDON_GTK_INPUT_MODE_AUTOCAP); + hildon_picker_button_set_selector (HILDON_PICKER_BUTTON (self), HILDON_TOUCH_SELECTOR (selector)); modest_provider_picker_set_others_provider (MODEST_PROVIDER_PICKER (self)); + /* For theming purpouses. Widget name must end in Button-finger */ + gtk_widget_set_name ((GtkWidget *) self, "ModestProviderPickerButton-finger"); + return self; } @@ -262,6 +304,11 @@ modest_provider_picker_fill (ModestProviderPicker *self, continue; } + if (MODEST_ACCOUNT_PROTOCOL (proto) && + !modest_account_protocol_is_supported (MODEST_ACCOUNT_PROTOCOL (proto))) { + continue; + } + gtk_list_store_append (liststore, &iter); gtk_list_store_set (liststore, &iter, MODEL_COL_ID, modest_protocol_get_name (proto),