#include <gtk/gtkbutton.h>
#include <gtk/gtkmessagedialog.h>
#include <gtk/gtkseparator.h>
-#include "modest-country-picker.h"
#include "modest-provider-picker.h"
#include "modest-servertype-picker.h"
#include "widgets/modest-validating-entry.h"
gboolean destroyed;
GtkWidget *page_account_details;
- GtkWidget *account_country_picker;
+ GtkWidget *account_country_selector;
GtkWidget *account_serviceprovider_picker;
GtkWidget *entry_account_title;
GtkWidget *caption_account_title;
}
static void
-on_picker_button_value_changed (HildonPickerButton *widget, gpointer user_data)
+on_picker_button_value_changed (GtkWidget *widget, gpointer user_data)
{
ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
g_assert(self);
self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
- on_picker_button_value_changed (widget, user_data);
+ on_picker_button_value_changed (GTK_WIDGET (widget), user_data);
provider_id_type = modest_provider_picker_get_active_id_type (
MODEST_PROVIDER_PICKER (priv->account_serviceprovider_picker));
}
static void
-on_account_country_selector_changed (HildonTouchSelector *widget, gpointer user_data)
+on_account_country_selector_changed (GtkWidget *widget, gpointer user_data)
{
ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
g_assert(self);
/* Fill the providers picker, based on the selected country: */
if (priv->presets != NULL) {
- gint mcc = modest_country_picker_get_active_country_mcc (
- MODEST_COUNTRY_PICKER (priv->account_country_picker));
+ gint mcc = modest_country_selector_get_active_country_mcc (priv->account_country_selector);
modest_provider_picker_fill (
MODEST_PROVIDER_PICKER (priv->account_serviceprovider_picker), priv->presets, mcc);
}
GtkSizeGroup* value_sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
/* The country widgets: */
- priv->account_country_picker = GTK_WIDGET (modest_country_picker_new (MODEST_EDITABLE_SIZE,
- HILDON_BUTTON_ARRANGEMENT_HORIZONTAL));
- modest_maemo_utils_set_hbutton_layout (title_sizegroup, value_sizegroup,
- _("mcen_fi_country"), priv->account_country_picker);
- g_signal_connect (G_OBJECT (priv->account_country_picker), "value-changed",
- G_CALLBACK (on_picker_button_value_changed), self);
- gtk_box_pack_start (GTK_BOX (box), priv->account_country_picker, FALSE, FALSE, MODEST_MARGIN_HALF);
- gtk_widget_show (priv->account_country_picker);
+ priv->account_country_selector = modest_toolkit_factory_create_country_selector (modest_runtime_get_toolkit_factory ());
+ if (GTK_IS_COMBO_BOX (priv->account_country_selector)) {
+ GtkWidget *captioned;
+ g_signal_connect (G_OBJECT (priv->account_country_selector), "changed",
+ G_CALLBACK (on_picker_button_value_changed), self);
+ captioned = modest_maemo_utils_create_captioned (title_sizegroup, value_sizegroup,
+ _("mcen_fi_country"), FALSE,
+ priv->account_country_selector);
+
+ gtk_box_pack_start (GTK_BOX (box), captioned, FALSE, FALSE, MODEST_MARGIN_HALF);
+ gtk_widget_show (captioned);
+ } else {
+ modest_maemo_utils_set_hbutton_layout (title_sizegroup, value_sizegroup,
+ _("mcen_fi_country"), priv->account_country_selector);
+ g_signal_connect (G_OBJECT (priv->account_country_selector), "value-changed",
+ G_CALLBACK (on_picker_button_value_changed), self);
+ gtk_box_pack_start (GTK_BOX (box), priv->account_country_selector, FALSE, FALSE, MODEST_MARGIN_HALF);
+ }
+ gtk_widget_show (priv->account_country_selector);
/* The service provider widgets: */
priv->account_serviceprovider_picker = GTK_WIDGET (modest_provider_picker_new (MODEST_EDITABLE_SIZE,
{
ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
- if (MODEST_IS_COUNTRY_PICKER (priv->account_country_picker)) {
+ if (priv->account_country_selector) {
/* gint mcc = get_default_country_code(); */
gint mcc;
/* Fill the combo in an idle call, as it takes a lot of time */
- modest_country_picker_load_data(
- MODEST_COUNTRY_PICKER (priv->account_country_picker));
+ modest_country_selector_load_data(priv->account_country_selector);
/* connect to country picker's changed signal, so we can fill the provider picker: */
- g_signal_connect ((GObject *) priv->account_country_picker,
- "value-changed",
- G_CALLBACK (on_account_country_selector_changed), self);
-
- modest_country_picker_set_active_country_locale (
- MODEST_COUNTRY_PICKER (priv->account_country_picker));
- mcc = modest_country_picker_get_active_country_mcc (
- MODEST_COUNTRY_PICKER (priv->account_country_picker));
+ if (GTK_IS_COMBO_BOX (priv->account_country_selector)) {
+ g_signal_connect ((GObject *) priv->account_country_selector,
+ "changed",
+ G_CALLBACK (on_account_country_selector_changed), self);
+ } else {
+ g_signal_connect ((GObject *) priv->account_country_selector,
+ "value-changed",
+ G_CALLBACK (on_account_country_selector_changed), self);
+ }
+
+ modest_country_selector_set_active_country_locale (priv->account_country_selector);
+ mcc = modest_country_selector_get_active_country_mcc (priv->account_country_selector);
modest_provider_picker_fill (
MODEST_PROVIDER_PICKER (priv->account_serviceprovider_picker),
priv->presets, mcc);
g_signal_connect (priv->check_support_cancel_note, "response", G_CALLBACK (on_check_support_cancel), self);
} else {
priv->check_support_done = TRUE;
+ if (priv->presets)
+ fill_providers (self);
}
invoke_enable_buttons_vfunc (self);
}
modest-compact-mail-header-view.c \
modest-compact-mail-header-view.h \
modest-connection-specific-smtp-window.h \
+ modest-country-combo-box.c \
+ modest-country-combo-box.h \
modest-default-account-settings-dialog.h \
modest-dnd.c \
modest-dnd.h \
--- /dev/null
+/* Copyright (c) 2006, Nokia Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Nokia Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE /* So we can use the getline() function, which is a convenient GNU extension. */
+#endif
+
+#include <stdio.h>
+
+#include <modest-utils.h>
+#include <modest-country-combo-box.h>
+#include <gtk/gtkliststore.h>
+#include <gtk/gtkcelllayout.h>
+#include <gtk/gtkcellrenderertext.h>
+
+#include <stdlib.h>
+#include <string.h> /* For memcpy() */
+#include <langinfo.h>
+#include <locale.h>
+#include <libintl.h> /* For dgettext(). */
+
+/* Include config.h so that _() works: */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#define MAX_LINE_LEN 128 /* max length of a line in MCC file */
+
+G_DEFINE_TYPE (ModestCountryComboBox, modest_country_combo_box, GTK_TYPE_COMBO_BOX);
+
+typedef struct
+{
+ gint locale_mcc;
+} ModestCountryComboBoxPrivate;
+
+#define MODEST_COUNTRY_COMBO_BOX_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
+ MODEST_TYPE_COUNTRY_COMBO_BOX, \
+ ModestCountryComboBoxPrivate))
+
+static void
+modest_country_combo_box_get_property (GObject *object, guint property_id,
+ GValue *value, GParamSpec *pspec)
+{
+ switch (property_id) {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
+}
+
+static void
+modest_country_combo_box_set_property (GObject *object, guint property_id,
+ const GValue *value, GParamSpec *pspec)
+{
+ switch (property_id) {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
+}
+
+static void
+modest_country_combo_box_dispose (GObject *object)
+{
+ if (G_OBJECT_CLASS (modest_country_combo_box_parent_class)->dispose)
+ G_OBJECT_CLASS (modest_country_combo_box_parent_class)->dispose (object);
+}
+
+enum MODEL_COLS {
+ MODEL_COL_NAME = 0, /* string */
+ MODEL_COL_MCC = 1 /* the 'effective mcc' for this country */
+};
+
+
+static void
+modest_country_combo_box_finalize (GObject *object)
+{
+ G_OBJECT_CLASS (modest_country_combo_box_parent_class)->finalize (object);
+}
+
+static void
+modest_country_combo_box_class_init (ModestCountryComboBoxClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (ModestCountryComboBoxPrivate));
+
+ object_class->get_property = modest_country_combo_box_get_property;
+ object_class->set_property = modest_country_combo_box_set_property;
+ object_class->dispose = modest_country_combo_box_dispose;
+ object_class->finalize = modest_country_combo_box_finalize;
+}
+
+
+static void
+modest_country_combo_box_init (ModestCountryComboBox *self)
+{
+ ModestCountryComboBoxPrivate *priv = MODEST_COUNTRY_COMBO_BOX_GET_PRIVATE (self);
+ priv->locale_mcc = 0;
+}
+
+void
+modest_country_combo_box_load_data(ModestCountryComboBox *self)
+{
+ ModestCountryComboBoxPrivate *priv;
+ GtkTreeModel *model;
+
+ priv = MODEST_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.
+ * This must match our MODEL_COLS enum constants.
+ */
+ model = modest_utils_create_country_model ();
+
+ /* 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 (self), renderer, TRUE);
+ gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (self), renderer,
+ "text", MODEST_UTILS_COUNTRY_MODEL_COLUMN_NAME, NULL);
+
+ modest_utils_fill_country_model (model, &(priv->locale_mcc));
+
+ /* Set this _after_ loading from file, it makes loading faster */
+ gtk_combo_box_set_model (GTK_COMBO_BOX (self), model);
+}
+
+GtkWidget*
+modest_country_combo_box_new (void)
+{
+ return g_object_new (MODEST_TYPE_COUNTRY_COMBO_BOX,
+ NULL);
+}
+
+/**
+ * Returns the MCC number of the selected country, or 0 if no country was selected.
+ */
+gint
+modest_country_combo_box_get_active_country_mcc (ModestCountryComboBox *self)
+{
+ GtkTreeIter active;
+ gboolean found;
+
+ found = gtk_combo_box_get_active_iter (GTK_COMBO_BOX (self), &active);
+ if (found) {
+ gint mcc = 0;
+ gtk_tree_model_get (gtk_combo_box_get_model (GTK_COMBO_BOX (self)),
+ &active, MODEST_UTILS_COUNTRY_MODEL_COLUMN_MCC, &mcc, -1);
+ return mcc;
+ }
+ return 0; /* Failed. */
+}
+
+
+/**
+ * Selects the MCC number of the selected country.
+ * Specify 0 to select no country.
+ */
+gboolean
+modest_country_combo_box_set_active_country_locale (ModestCountryComboBox *self)
+{
+ ModestCountryComboBoxPrivate *priv = MODEST_COUNTRY_COMBO_BOX_GET_PRIVATE (self);
+ GtkTreeIter iter;
+ gint current_mcc;
+ GtkTreeModel *model;
+
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX (self));
+ if (!gtk_tree_model_get_iter_first (model, &iter))
+ return FALSE;
+ do {
+ gtk_tree_model_get (model, &iter, MODEST_UTILS_COUNTRY_MODEL_COLUMN_MCC, ¤t_mcc, -1);
+ if (priv->locale_mcc == current_mcc) {
+ gtk_combo_box_set_active_iter (GTK_COMBO_BOX (self), &iter);
+ return TRUE;
+ }
+ } while (gtk_tree_model_iter_next (model, &iter));
+
+ return FALSE; /* not found */
+}
+
--- /dev/null
+/* Copyright (c) 2006, Nokia Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Nokia Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _MODEST_COUNTRY_COMBO_BOX
+#define _MODEST_COUNTRY_COMBO_BOX
+
+#include <gtk/gtkcombobox.h>
+
+G_BEGIN_DECLS
+
+#define MODEST_TYPE_COUNTRY_COMBO_BOX modest_country_combo_box_get_type()
+
+#define MODEST_COUNTRY_COMBO_BOX(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ MODEST_TYPE_COUNTRY_COMBO_BOX, ModestCountryComboBox))
+
+#define MODEST_COUNTRY_COMBO_BOX_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST ((klass), \
+ MODEST_TYPE_COUNTRY_COMBO_BOX, ModestCountryComboBoxClass))
+
+#define MODEST_IS_COUNTRY_COMBO_BOX(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ MODEST_TYPE_COUNTRY_COMBO_BOX))
+
+#define MODEST_IS_COUNTRY_COMBO_BOX_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+ MODEST_TYPE_COUNTRY_COMBO_BOX))
+
+#define MODEST_COUNTRY_COMBO_BOX_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+ MODEST_TYPE_COUNTRY_COMBO_BOX, ModestCountryComboBoxClass))
+
+typedef struct {
+ GtkComboBox parent;
+} ModestCountryComboBox;
+
+typedef struct {
+ GtkComboBoxClass parent_class;
+} ModestCountryComboBoxClass;
+
+GType modest_country_combo_box_get_type (void);
+
+GtkWidget* modest_country_combo_box_new (void);
+
+void modest_country_combo_box_load_data(ModestCountryComboBox *self);
+
+gint modest_country_combo_box_get_active_country_mcc (ModestCountryComboBox *self);
+
+
+gboolean modest_country_combo_box_set_active_country_locale (ModestCountryComboBox *self);
+
+G_END_DECLS
+
+#endif /* _MODEST_COUNTRY_COMBO_BOX */
#include <hildon/hildon.h>
#include <hildon/hildon-file-chooser-dialog.h>
#include <modest-number-editor.h>
+#include <modest-ui-constants.h>
#endif
#include "modest-toolkit-factory.h"
#define USE_GTK_CHECK_MENU
#define USE_GTK_ENTRY
#define USE_GTK_FILE_CHOOSER
+#define USE_COUNTRY_COMBOBOX
#endif
#ifdef USE_SCROLLED_WINDOW
#include <modest-hildon-find-toolbar.h>
#endif
+#ifdef USE_COUNTRY_COMBOBOX
+#include <modest-country-combo-box.h>
+#else
+#include <modest-country-picker.h>
+#endif
+
static void modest_toolkit_factory_class_init (ModestToolkitFactoryClass *klass);
static void modest_toolkit_factory_init (ModestToolkitFactory *self);
const gchar *title,
GtkWindow *parent,
GtkFileChooserAction action);
+static GtkWidget * modest_toolkit_factory_create_country_selector_default (ModestToolkitFactory *self);
/* globals */
static GObjectClass *parent_class = NULL;
klass->create_entry = modest_toolkit_factory_create_entry_default;
klass->create_number_entry = modest_toolkit_factory_create_number_entry_default;
klass->create_file_chooser_dialog = modest_toolkit_factory_create_file_chooser_dialog_default;
+ klass->create_country_selector = modest_toolkit_factory_create_country_selector_default;
}
static void
#endif
return result;
}
+
+GtkWidget *
+modest_toolkit_factory_create_country_selector (ModestToolkitFactory *self)
+{
+ return MODEST_TOOLKIT_FACTORY_GET_CLASS (self)->create_country_selector (self);
+}
+
+static GtkWidget *
+modest_toolkit_factory_create_country_selector_default (ModestToolkitFactory *self)
+{
+ GtkWidget *result;
+#ifdef USE_COUNTRY_COMBOBOX
+ result = modest_country_combo_box_new ();
+#else
+ result = GTK_WIDGET (modest_country_picker_new (MODEST_EDITABLE_SIZE,
+ HILDON_BUTTON_ARRANGEMENT_HORIZONTAL));
+#endif
+ return result;
+}
+
+gint
+modest_country_selector_get_active_country_mcc (GtkWidget *widget)
+{
+#ifdef USE_COUNTRY_COMBOBOX
+ return modest_country_combo_box_get_active_country_mcc (MODEST_COUNTRY_COMBO_BOX (widget));
+#else
+ return modest_country_picker_get_active_country_mcc (MODEST_COUNTRY_PICKER (widget));
+#endif
+}
+
+void
+modest_country_selector_load_data (GtkWidget *widget)
+{
+#ifdef USE_COUNTRY_COMBOBOX
+ modest_country_combo_box_load_data (MODEST_COUNTRY_COMBO_BOX (widget));
+#else
+ modest_country_picker_load_data (MODEST_COUNTRY_PICKER (widget));
+#endif
+}
+
+gboolean
+modest_country_selector_set_active_country_locale (GtkWidget *widget)
+{
+#ifdef USE_COUNTRY_COMBOBOX
+ return modest_country_combo_box_set_active_country_locale (MODEST_COUNTRY_COMBO_BOX (widget));
+#else
+ return modest_country_picker_set_active_country_locale (MODEST_COUNTRY_PICKER (widget));
+#endif
+}
GtkWidget * (*create_number_entry) (ModestToolkitFactory *self, gint min, gint max);
GtkWidget * (*create_file_chooser_dialog) (ModestToolkitFactory *self, const gchar *title,
GtkWindow *parent, GtkFileChooserAction action);
+ GtkWidget * (*create_country_selector) (ModestToolkitFactory *self);
};
struct _ModestToolkitFactory
modest_toolkit_factory_create_file_chooser_dialog (ModestToolkitFactory *self, const gchar *title,
GtkWindow *parent, GtkFileChooserAction action);
+GtkWidget *
+modest_toolkit_factory_create_country_selector (ModestToolkitFactory *self);
+
gboolean
modest_togglable_get_active (GtkWidget *widget);
gboolean
modest_is_number_entry (GtkWidget *widget);
+gint
+modest_country_selector_get_active_country_mcc (GtkWidget *widget);
+
+void
+modest_country_selector_load_data (GtkWidget *widget);
+
+gboolean
+modest_country_selector_set_active_country_locale (GtkWidget *widget);
+
+
#ifndef MODEST_TOOLKIT_HILDON2
#define USE_GTK_SPIN_BUTTON
#endif