From ef00f85692d7ba7b6e3f89421dda704bfc9e609f Mon Sep 17 00:00:00 2001 From: Alberto Garcia Date: Wed, 5 Dec 2007 10:59:51 +0000 Subject: [PATCH] * Revert changes made in r3868. We have a better solution now * New function easysetup_country_combo_box_load_data(), to actually fill the combo with the list of countries. * Call it in an idle function so Modest startup time is even faster. pmo-trunk-r3872 --- .../easysetup/modest-easysetup-country-combo-box.c | 7 ++ .../easysetup/modest-easysetup-country-combo-box.h | 2 + src/maemo/easysetup/modest-easysetup-wizard.c | 87 ++++++++++---------- 3 files changed, 53 insertions(+), 43 deletions(-) diff --git a/src/maemo/easysetup/modest-easysetup-country-combo-box.c b/src/maemo/easysetup/modest-easysetup-country-combo-box.c index ba1a908..7005569 100644 --- a/src/maemo/easysetup/modest-easysetup-country-combo-box.c +++ b/src/maemo/easysetup/modest-easysetup-country-combo-box.c @@ -247,6 +247,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. diff --git a/src/maemo/easysetup/modest-easysetup-country-combo-box.h b/src/maemo/easysetup/modest-easysetup-country-combo-box.h index ef9813f..c89ecf1 100644 --- a/src/maemo/easysetup/modest-easysetup-country-combo-box.h +++ b/src/maemo/easysetup/modest-easysetup-country-combo-box.h @@ -68,6 +68,8 @@ GType easysetup_country_combo_box_get_type (void); EasysetupCountryComboBox* easysetup_country_combo_box_new (void); +void easysetup_country_combo_box_load_data(EasysetupCountryComboBox *self); + gint easysetup_country_combo_box_get_active_country_mcc (EasysetupCountryComboBox *self); diff --git a/src/maemo/easysetup/modest-easysetup-wizard.c b/src/maemo/easysetup/modest-easysetup-wizard.c index 28c41e3..6997a2d 100644 --- a/src/maemo/easysetup/modest-easysetup-wizard.c +++ b/src/maemo/easysetup/modest-easysetup-wizard.c @@ -419,6 +419,44 @@ on_entry_invalid_character (ModestValidatingEntry *self, const gchar* character, show_error (GTK_WIDGET (self), message); } +static gint +get_default_country_code(void) +{ + /* TODO: Default to the current country somehow. + * But I don't know how to get the information that is specified in the + * "Language and region" control panel. It does not seem be anywhere in gconf. murrayc. + * + * This is probably not the best choice of gconf key: + * This is the "mcc used in the last pairing", ie. the last connection you made. + * set by the osso-operator-wizard package, suggested by Dirk-Jan Binnema. + * + */ + GError *error = NULL; + const gchar* key = "/apps/osso/operator-wizard/last_mcc"; + gint mcc_id = modest_conf_get_int(modest_runtime_get_conf (), key, &error); + + if(mcc_id < 0) + mcc_id = 0; + + if (error) { + g_warning ("Error getting gconf key %s:\n%s", key, error->message); + g_error_free (error); + error = NULL; + + mcc_id = 0; + } + + /* Note that modest_conf_get_int() seems to return 0 without an error if the key is not there + * This might just be a Maemo bug. + */ + if (mcc_id == 0) + { + /* For now, we default to Finland when there is nothing better: */ + mcc_id = 244; + } + return mcc_id; +} + static GtkWidget* create_page_account_details (ModestEasysetupWizardDialog *self) { @@ -438,8 +476,7 @@ create_page_account_details (ModestEasysetupWizardDialog *self) self->combo_account_country = GTK_WIDGET (easysetup_country_combo_box_new ()); GtkWidget *caption = create_caption_new_with_asterisk (self, sizegroup, _("mcen_fi_country"), self->combo_account_country, NULL, HILDON_CAPTION_OPTIONAL); - /* _Don't_ do gtk_widget_show(self->combo_account_country) now, it's very slow. - * We're showing the combo later, in presets_idle() */ + gtk_widget_show (self->combo_account_country); gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF); gtk_widget_show (caption); @@ -465,43 +502,6 @@ create_page_account_details (ModestEasysetupWizardDialog *self) g_signal_connect (G_OBJECT (self->combo_account_serviceprovider), "changed", G_CALLBACK (on_combo_account_serviceprovider), self); - /* TODO: Default to the current country somehow. - * But I don't know how to get the information that is specified in the - * "Language and region" control panel. It does not seem be anywhere in gconf. murrayc. - * - * This is probably not the best choice of gconf key: - * This is the "mcc used in the last pairing", ie. the last connection you made. - * set by the osso-operator-wizard package, suggested by Dirk-Jan Binnema. - * - */ - GError *error = NULL; - const gchar* key = "/apps/osso/operator-wizard/last_mcc"; - gint mcc_id = modest_conf_get_int(modest_runtime_get_conf (), key, &error); - - if(mcc_id < 0) - mcc_id = 0; - - if (error) { - g_warning ("Error getting gconf key %s:\n%s", key, error->message); - g_error_free (error); - error = NULL; - - mcc_id = 0; - } - - /* Note that modest_conf_get_int() seems to return 0 without an error if the key is not there - * This might just be a Maemo bug. - */ - if (mcc_id == 0) - { - /* For now, we default to Finland when there is nothing better: */ - mcc_id = 244; - } - - easysetup_country_combo_box_set_active_country_mcc ( - EASYSETUP_COUNTRY_COMBO_BOX (self->combo_account_country), mcc_id); - - /* The description widgets: */ self->entry_account_title = GTK_WIDGET (modest_validating_entry_new ()); g_signal_connect(G_OBJECT(self->entry_account_title), "changed", @@ -1098,11 +1098,12 @@ presets_idle (gpointer userdata) priv->presets = idle_data->presets; if (self->combo_account_country) { - /* We're showing the combo now because it's very slow to do it - synchronously in create_page_account_details() */ - gtk_widget_show (self->combo_account_country); - gint mcc = easysetup_country_combo_box_get_active_country_mcc ( + gint mcc = get_default_country_code(); + /* Fill the combo in an idle call, as it takes a lot of time */ + easysetup_country_combo_box_load_data( EASYSETUP_COUNTRY_COMBO_BOX (self->combo_account_country)); + easysetup_country_combo_box_set_active_country_mcc ( + EASYSETUP_COUNTRY_COMBO_BOX (self->combo_account_country), mcc); easysetup_provider_combo_box_fill ( EASYSETUP_PROVIDER_COMBO_BOX (self->combo_account_serviceprovider), priv->presets, mcc); -- 1.7.9.5