2007-04-20 Murray Cumming <murrayc@murrayc.com>
+ * src/maemo/easysetup/Makefile.am:
+ * src/maemo/easysetup/modest-easysetup-secureauth-combo-box.c:
+ * src/maemo/easysetup/modest-easysetup-secureauth-combo-box.h:
+ * src/maemo/easysetup/modest-easysetup-serversecurity-combo-box.c:
+ * src/maemo/easysetup/modest-easysetup-serversecurity-combo-box.h:
+ * src/maemo/easysetup/modest-easysetup-wizard.c:
+ * src/maemo/easysetup/modest-validating-entry.c:
+ * src/maemo/easysetup/modest-validating-entry.h:
+ * src/maemo/modest-account-settings-dialog.c:
+ * src/maemo/modest-connection-specific-smtp-edit-window.c:
+ * src/widgets/Makefile.am: Moved these widgets from maemo/easysetup into
+ widgets/ because they are used outside of easysetup too. After checking in,
+ svn will allow me to rename them too.
+
+2007-04-20 Murray Cumming <murrayc@murrayc.com>
+
* src/gnome/modest-msg-edit-window.c:
(modest_msg_edit_window_set_priority_flags): Added an empty implementation to fix a
linker error, to fix the build on the GNOME platform.
modest-easysetup-wizard.h modest-easysetup-wizard.c \
modest-easysetup-country-combo-box.h modest-easysetup-country-combo-box.c \
modest-easysetup-provider-combo-box.h modest-easysetup-provider-combo-box.c \
- modest-easysetup-servertype-combo-box.h modest-easysetup-servertype-combo-box.c \
- modest-easysetup-serversecurity-combo-box.h modest-easysetup-serversecurity-combo-box.c \
- modest-easysetup-secureauth-combo-box.h modest-easysetup-secureauth-combo-box.c \
- modest-validating-entry.h modest-validating-entry.c
+ modest-easysetup-servertype-combo-box.h modest-easysetup-servertype-combo-box.c
LDADD = \
$(MODEST_GSTUFF_LIBS) \
+++ /dev/null
-/* Copyright (c) 2007, Nokia Corporation
- * All rights reserved.
- *
- */
-
-#include "modest-easysetup-secureauth-combo-box.h"
-#include <gtk/gtkliststore.h>
-#include <gtk/gtkcelllayout.h>
-#include <gtk/gtkcellrenderertext.h>
-#include <glib/gi18n.h>
-
-#include <stdlib.h>
-#include <string.h> /* For memcpy() */
-
-/* Include config.h so that _() works: */
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-G_DEFINE_TYPE (EasysetupSecureauthComboBox, easysetup_secureauth_combo_box, GTK_TYPE_COMBO_BOX);
-
-#define SECUREAUTH_COMBO_BOX_GET_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((o), EASYSETUP_TYPE_SECUREAUTH_COMBO_BOX, EasysetupSecureauthComboBoxPrivate))
-
-typedef struct _EasysetupSecureauthComboBoxPrivate EasysetupSecureauthComboBoxPrivate;
-
-struct _EasysetupSecureauthComboBoxPrivate
-{
- GtkTreeModel *model;
-};
-
-static void
-easysetup_secureauth_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
-easysetup_secureauth_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
-easysetup_secureauth_combo_box_dispose (GObject *object)
-{
- if (G_OBJECT_CLASS (easysetup_secureauth_combo_box_parent_class)->dispose)
- G_OBJECT_CLASS (easysetup_secureauth_combo_box_parent_class)->dispose (object);
-}
-
-static void
-easysetup_secureauth_combo_box_finalize (GObject *object)
-{
- EasysetupSecureauthComboBoxPrivate *priv = SECUREAUTH_COMBO_BOX_GET_PRIVATE (object);
-
- g_object_unref (G_OBJECT (priv->model));
-
- G_OBJECT_CLASS (easysetup_secureauth_combo_box_parent_class)->finalize (object);
-}
-
-static void
-easysetup_secureauth_combo_box_class_init (EasysetupSecureauthComboBoxClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- g_type_class_add_private (klass, sizeof (EasysetupSecureauthComboBoxPrivate));
-
- object_class->get_property = easysetup_secureauth_combo_box_get_property;
- object_class->set_property = easysetup_secureauth_combo_box_set_property;
- object_class->dispose = easysetup_secureauth_combo_box_dispose;
- object_class->finalize = easysetup_secureauth_combo_box_finalize;
-}
-
-enum MODEL_COLS {
- MODEL_COL_NAME = 0, /* a string */
- MODEL_COL_ID = 1 /* an int. */
-};
-
-void easysetup_secureauth_combo_box_fill (EasysetupSecureauthComboBox *combobox);
-
-static void
-easysetup_secureauth_combo_box_init (EasysetupSecureauthComboBox *self)
-{
- EasysetupSecureauthComboBoxPrivate *priv = SECUREAUTH_COMBO_BOX_GET_PRIVATE (self);
-
- /* Create a tree model for the combo box,
- * with a string for the name, and an ID for the secureauth.
- * This must match our MODEL_COLS enum constants.
- */
- priv->model = GTK_TREE_MODEL (gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT));
-
- /* Setup the combo box: */
- GtkComboBox *combobox = GTK_COMBO_BOX (self);
- gtk_combo_box_set_model (combobox, priv->model);
-
- /* Secureauth column:
- * The ID model column in not shown in the view. */
- GtkCellRenderer *renderer = gtk_cell_renderer_text_new ();
- 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);
-
- easysetup_secureauth_combo_box_fill (self);
-}
-
-EasysetupSecureauthComboBox*
-easysetup_secureauth_combo_box_new (void)
-{
- return g_object_new (EASYSETUP_TYPE_SECUREAUTH_COMBO_BOX, NULL);
-}
-
-/* Fill the combo box with appropriate choices.
- * #combobox: The combo box.
- * @protocol: IMAP or POP.
- */
-void easysetup_secureauth_combo_box_fill (EasysetupSecureauthComboBox *combobox)
-{
- EasysetupSecureauthComboBoxPrivate *priv = SECUREAUTH_COMBO_BOX_GET_PRIVATE (combobox);
-
- /* Remove any existing rows: */
- GtkListStore *liststore = GTK_LIST_STORE (priv->model);
- gtk_list_store_clear (liststore);
-
- GtkTreeIter iter;
- gtk_list_store_append (liststore, &iter);
- gtk_list_store_set (liststore, &iter, MODEL_COL_ID, (gint)MODEST_PROTOCOL_AUTH_NONE, MODEL_COL_NAME, _("mcen_fi_advsetup_smtp_none"), -1);
-
- /* Select the None item: */
- gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combobox), &iter);
-
- gtk_list_store_append (liststore, &iter);
- gtk_list_store_set (liststore, &iter, MODEL_COL_ID, (gint)MODEST_PROTOCOL_AUTH_PASSWORD, MODEL_COL_NAME, _("mcen_fi_advsetup_smtp_login"), -1);
-
- gtk_list_store_append (liststore, &iter);
- gtk_list_store_set (liststore, &iter, MODEL_COL_ID, (gint)MODEST_PROTOCOL_AUTH_CRAMMD5, MODEL_COL_NAME, _("mcen_fi_advsetup_smtp_cram_md5"), -1);
-}
-
-/**
- * Returns the selected secureauth,
- * or MODEST_PROTOCOL_UNKNOWN if no secureauth was selected.
- */
-ModestProtocol
-easysetup_secureauth_combo_box_get_active_secureauth (EasysetupSecureauthComboBox *combobox)
-{
- GtkTreeIter active;
- const gboolean found = gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combobox), &active);
- if (found) {
- EasysetupSecureauthComboBoxPrivate *priv = SECUREAUTH_COMBO_BOX_GET_PRIVATE (combobox);
-
- ModestProtocol secureauth = MODEST_PROTOCOL_UNKNOWN;
- gtk_tree_model_get (priv->model, &active, MODEL_COL_ID, &secureauth, -1);
- return secureauth;
- }
-
- return MODEST_PROTOCOL_UNKNOWN; /* Failed. */
-}
-
-/* This allows us to pass more than one piece of data to the signal handler,
- * and get a result: */
-typedef struct
-{
- EasysetupSecureauthComboBox* self;
- gint id;
- gboolean found;
-} ForEachData;
-
-static gboolean
-on_model_foreach_select_id(GtkTreeModel *model,
- GtkTreePath *path, GtkTreeIter *iter, gpointer user_data)
-{
- ForEachData *state = (ForEachData*)(user_data);
-
- /* Select the item if it has the matching ID: */
- guint id = 0;
- gtk_tree_model_get (model, iter, MODEL_COL_ID, &id, -1);
- if(id == state->id) {
- gtk_combo_box_set_active_iter (GTK_COMBO_BOX (state->self), iter);
-
- state->found = TRUE;
- return TRUE; /* Stop walking the tree. */
- }
-
- return FALSE; /* Keep walking the tree. */
-}
-
-/**
- * Selects the specified secureauth,
- * or MODEST_PROTOCOL_UNKNOWN if no secureauth was selected.
- */
-gboolean
-easysetup_secureauth_combo_box_set_active_secureauth (EasysetupSecureauthComboBox *combobox, ModestProtocol secureauth)
-{
- EasysetupSecureauthComboBoxPrivate *priv = SECUREAUTH_COMBO_BOX_GET_PRIVATE (combobox);
-
- /* Create a state instance so we can send two items of data to the signal handler: */
- ForEachData *state = g_new0 (ForEachData, 1);
- state->self = combobox;
- state->id = secureauth;
- state->found = FALSE;
-
- /* Look at each item, and select the one with the correct ID: */
- gtk_tree_model_foreach (priv->model, &on_model_foreach_select_id, state);
-
- const gboolean result = state->found;
-
- /* Free the state instance: */
- g_free(state);
-
- return result;
-}
-
+++ /dev/null
-/* Copyright (c) 2007, Nokia Corporation
- * All rights reserved.
- *
- */
-
-#ifndef _EASYSETUP_SECUREAUTH_COMBO_BOX
-#define _EASYSETUP_SECUREAUTH_COMBO_BOX
-
-#include <gtk/gtkcombobox.h>
-#include "modest-protocol-info.h"
-
-G_BEGIN_DECLS
-
-#define EASYSETUP_TYPE_SECUREAUTH_COMBO_BOX easysetup_secureauth_combo_box_get_type()
-
-#define EASYSETUP_SECUREAUTH_COMBO_BOX(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
- EASYSETUP_TYPE_SECUREAUTH_COMBO_BOX, EasysetupSecureauthComboBox))
-
-#define EASYSETUP_SECUREAUTH_COMBO_BOX_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST ((klass), \
- EASYSETUP_TYPE_SECUREAUTH_COMBO_BOX, EasysetupSecureauthComboBoxClass))
-
-#define EASYSETUP_IS_SECUREAUTH_COMBO_BOX(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
- EASYSETUP_TYPE_SECUREAUTH_COMBO_BOX))
-
-#define EASYSETUP_IS_SECUREAUTH_COMBO_BOX_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE ((klass), \
- EASYSETUP_TYPE_SECUREAUTH_COMBO_BOX))
-
-#define EASYSETUP_SECUREAUTH_COMBO_BOX_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), \
- EASYSETUP_TYPE_SECUREAUTH_COMBO_BOX, EasysetupSecureauthComboBoxClass))
-
-typedef struct {
- GtkComboBox parent;
-} EasysetupSecureauthComboBox;
-
-typedef struct {
- GtkComboBoxClass parent_class;
-} EasysetupSecureauthComboBoxClass;
-
-GType easysetup_secureauth_combo_box_get_type (void);
-
-EasysetupSecureauthComboBox* easysetup_secureauth_combo_box_new (void);
-
-ModestProtocol easysetup_secureauth_combo_box_get_active_secureauth (EasysetupSecureauthComboBox *combobox);
-
-gboolean easysetup_secureauth_combo_box_set_active_secureauth (EasysetupSecureauthComboBox *combobox, ModestProtocol secureauth);
-
-
-G_END_DECLS
-
-#endif /* _EASYSETUP_PROVIDER_COMBO_BOX */
+++ /dev/null
-/* Copyright (c) 2007, Nokia Corporation
- * All rights reserved.
- *
- */
-
-#include "modest-easysetup-serversecurity-combo-box.h"
-#include <gtk/gtkliststore.h>
-#include <gtk/gtkcelllayout.h>
-#include <gtk/gtkcellrenderertext.h>
-#include <glib/gi18n.h>
-
-#include <stdlib.h>
-#include <string.h> /* For memcpy() */
-
-/* Include config.h so that _() works: */
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-G_DEFINE_TYPE (EasysetupServersecurityComboBox, easysetup_serversecurity_combo_box, GTK_TYPE_COMBO_BOX);
-
-#define SERVERSECURITY_COMBO_BOX_GET_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((o), EASYSETUP_TYPE_SERVERSECURITY_COMBO_BOX, EasysetupServersecurityComboBoxPrivate))
-
-typedef struct _EasysetupServersecurityComboBoxPrivate EasysetupServersecurityComboBoxPrivate;
-
-struct _EasysetupServersecurityComboBoxPrivate
-{
- GtkTreeModel *model;
- ModestProtocol protocol;
-};
-
-static void
-easysetup_serversecurity_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
-easysetup_serversecurity_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
-easysetup_serversecurity_combo_box_dispose (GObject *object)
-{
- if (G_OBJECT_CLASS (easysetup_serversecurity_combo_box_parent_class)->dispose)
- G_OBJECT_CLASS (easysetup_serversecurity_combo_box_parent_class)->dispose (object);
-}
-
-static void
-easysetup_serversecurity_combo_box_finalize (GObject *object)
-{
- EasysetupServersecurityComboBoxPrivate *priv = SERVERSECURITY_COMBO_BOX_GET_PRIVATE (object);
-
- g_object_unref (G_OBJECT (priv->model));
-
- G_OBJECT_CLASS (easysetup_serversecurity_combo_box_parent_class)->finalize (object);
-}
-
-static void
-easysetup_serversecurity_combo_box_class_init (EasysetupServersecurityComboBoxClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- g_type_class_add_private (klass, sizeof (EasysetupServersecurityComboBoxPrivate));
-
- object_class->get_property = easysetup_serversecurity_combo_box_get_property;
- object_class->set_property = easysetup_serversecurity_combo_box_set_property;
- object_class->dispose = easysetup_serversecurity_combo_box_dispose;
- object_class->finalize = easysetup_serversecurity_combo_box_finalize;
-}
-
-enum MODEL_COLS {
- MODEL_COL_NAME = 0, /* a string */
- MODEL_COL_ID = 1 /* an int. */
-};
-
-static void
-easysetup_serversecurity_combo_box_init (EasysetupServersecurityComboBox *self)
-{
- EasysetupServersecurityComboBoxPrivate *priv = SERVERSECURITY_COMBO_BOX_GET_PRIVATE (self);
-
- /* Create a tree model for the combo box,
- * with a string for the name, and an ID for the serversecurity.
- * This must match our MODEL_COLS enum constants.
- */
- priv->model = GTK_TREE_MODEL (gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT));
-
- /* Setup the combo box: */
- GtkComboBox *combobox = GTK_COMBO_BOX (self);
- gtk_combo_box_set_model (combobox, priv->model);
-
- /* Serversecurity column:
- * The ID model column in not shown in the view. */
- GtkCellRenderer *renderer = gtk_cell_renderer_text_new ();
- 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);
-
- /* The application must call easysetup_serversecurity_combo_box_fill().
- */
-}
-
-EasysetupServersecurityComboBox*
-easysetup_serversecurity_combo_box_new (void)
-{
- return g_object_new (EASYSETUP_TYPE_SERVERSECURITY_COMBO_BOX, NULL);
-}
-
-/* Fill the combo box with appropriate choices.
- * #combobox: The combo box.
- * @protocol: IMAP or POP.
- */
-void easysetup_serversecurity_combo_box_fill (EasysetupServersecurityComboBox *combobox, ModestProtocol protocol)
-{
- EasysetupServersecurityComboBoxPrivate *priv = SERVERSECURITY_COMBO_BOX_GET_PRIVATE (combobox);
- priv->protocol = protocol; /* Remembered for later. */
-
- /* Remove any existing rows: */
- GtkListStore *liststore = GTK_LIST_STORE (priv->model);
- gtk_list_store_clear (liststore);
-
- GtkTreeIter iter;
- gtk_list_store_append (liststore, &iter);
- gtk_list_store_set (liststore, &iter, MODEL_COL_ID, (gint)MODEST_PROTOCOL_SECURITY_NONE, MODEL_COL_NAME, _("mcen_fi_advsetup_other_security_none"), -1);
-
- /* Select the None item: */
- gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combobox), &iter);
-
- gtk_list_store_append (liststore, &iter);
- gtk_list_store_set (liststore, &iter, MODEL_COL_ID, (gint)MODEST_PROTOCOL_SECURITY_TLS, MODEL_COL_NAME, _("mcen_fi_advsetup_other_security_normal"), -1);
-
- /* Add security choices with protocol-specific names, as in the UI spec:
- * (Note: Changing the title seems pointless. murrayc) */
- if(protocol == MODEST_PROTOCOL_STORE_POP) {
- gtk_list_store_append (liststore, &iter);
- gtk_list_store_set (liststore, &iter, MODEL_COL_ID, (gint)MODEST_PROTOCOL_SECURITY_SSL, MODEL_COL_NAME, _("mcen_fi_advsetup_other_security_securepop3s"), -1);
- } else if(protocol == MODEST_PROTOCOL_STORE_IMAP) {
- gtk_list_store_append (liststore, &iter);
- gtk_list_store_set (liststore, &iter, MODEL_COL_ID, (gint)MODEST_PROTOCOL_SECURITY_SSL, MODEL_COL_NAME, _("mcen_fi_advsetup_other_security_secureimap4"), -1);
- } else if(protocol == MODEST_PROTOCOL_TRANSPORT_SMTP) {
- gtk_list_store_append (liststore, &iter);
- gtk_list_store_set (liststore, &iter, MODEL_COL_ID, (gint)MODEST_PROTOCOL_SECURITY_SSL, MODEL_COL_NAME, _("mcen_fi_advsetup_other_security_ssl"), -1);
- }
-}
-
-static gint get_port_for_security (ModestProtocol protocol, ModestProtocol security)
-{
- /* See the UI spec, section Email Wizards, Incoming Details [MSG-WIZ001]: */
- gint result = 0;
-
- /* Get the default port number for this protocol with this security: */
- if(protocol == MODEST_PROTOCOL_STORE_POP) {
- if ((security == MODEST_PROTOCOL_SECURITY_NONE) || (security == MODEST_PROTOCOL_SECURITY_TLS))
- result = 110;
- else if (security == MODEST_PROTOCOL_SECURITY_SSL)
- result = 995;
- } else if (protocol == MODEST_PROTOCOL_STORE_IMAP) {
- if ((security == MODEST_PROTOCOL_SECURITY_NONE) || (security == MODEST_PROTOCOL_SECURITY_TLS))
- result = 143;
- else if (security == MODEST_PROTOCOL_SECURITY_SSL)
- result = 993;
- } else if (protocol == MODEST_PROTOCOL_TRANSPORT_SMTP) {
- if ((security == MODEST_PROTOCOL_SECURITY_NONE) || (security == MODEST_PROTOCOL_SECURITY_TLS))
- result = 25;
- else if (security == MODEST_PROTOCOL_SECURITY_SSL)
- result = 465;
- }
-
- return result;
-}
-
-/**
- * Returns the selected serversecurity,
- * or MODEST_PROTOCOL_UNKNOWN if no serversecurity was selected.
- */
-ModestProtocol
-easysetup_serversecurity_combo_box_get_active_serversecurity (EasysetupServersecurityComboBox *combobox)
-{
- GtkTreeIter active;
- const gboolean found = gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combobox), &active);
- if (found) {
- EasysetupServersecurityComboBoxPrivate *priv = SERVERSECURITY_COMBO_BOX_GET_PRIVATE (combobox);
-
- ModestProtocol serversecurity = MODEST_PROTOCOL_UNKNOWN;
- gtk_tree_model_get (priv->model, &active, MODEL_COL_ID, &serversecurity, -1);
- return serversecurity;
- }
-
- return MODEST_PROTOCOL_UNKNOWN; /* Failed. */
-}
-
-/**
- * Returns the default port to be used for the selected serversecurity,
- * or 0 if no serversecurity was selected.
- */
-gint
-easysetup_serversecurity_combo_box_get_active_serversecurity_port (EasysetupServersecurityComboBox *combobox)
-{
- EasysetupServersecurityComboBoxPrivate *priv = SERVERSECURITY_COMBO_BOX_GET_PRIVATE (combobox);
-
- const ModestProtocol security = easysetup_serversecurity_combo_box_get_active_serversecurity
- (combobox);
- return get_port_for_security (priv->protocol, security);
-}
-
-/* This allows us to pass more than one piece of data to the signal handler,
- * and get a result: */
-typedef struct
-{
- EasysetupServersecurityComboBox* self;
- gint id;
- gboolean found;
-} ForEachData;
-
-static gboolean
-on_model_foreach_select_id(GtkTreeModel *model,
- GtkTreePath *path, GtkTreeIter *iter, gpointer user_data)
-{
- ForEachData *state = (ForEachData*)(user_data);
-
- /* Select the item if it has the matching ID: */
- guint id = 0;
- gtk_tree_model_get (model, iter, MODEL_COL_ID, &id, -1);
- if(id == state->id) {
- gtk_combo_box_set_active_iter (GTK_COMBO_BOX (state->self), iter);
-
- state->found = TRUE;
- return TRUE; /* Stop walking the tree. */
- }
-
- return FALSE; /* Keep walking the tree. */
-}
-
-/**
- * Selects the specified serversecurity,
- * or MODEST_PROTOCOL_UNKNOWN if no serversecurity was selected.
- */
-gboolean
-easysetup_serversecurity_combo_box_set_active_serversecurity (EasysetupServersecurityComboBox *combobox, ModestProtocol serversecurity)
-{
- EasysetupServersecurityComboBoxPrivate *priv = SERVERSECURITY_COMBO_BOX_GET_PRIVATE (combobox);
-
- /* Create a state instance so we can send two items of data to the signal handler: */
- ForEachData *state = g_new0 (ForEachData, 1);
- state->self = combobox;
- state->id = serversecurity;
- state->found = FALSE;
-
- /* Look at each item, and select the one with the correct ID: */
- gtk_tree_model_foreach (priv->model, &on_model_foreach_select_id, state);
-
- const gboolean result = state->found;
-
- /* Free the state instance: */
- g_free(state);
-
- return result;
-}
-
+++ /dev/null
-/* Copyright (c) 2007, Nokia Corporation
- * All rights reserved.
- *
- */
-
-#ifndef _EASYSETUP_SERVERSECURITY_COMBO_BOX
-#define _EASYSETUP_SERVERSECURITY_COMBO_BOX
-
-#include <gtk/gtkcombobox.h>
-#include "modest-protocol-info.h"
-
-G_BEGIN_DECLS
-
-#define EASYSETUP_TYPE_SERVERSECURITY_COMBO_BOX easysetup_serversecurity_combo_box_get_type()
-
-#define EASYSETUP_SERVERSECURITY_COMBO_BOX(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
- EASYSETUP_TYPE_SERVERSECURITY_COMBO_BOX, EasysetupServersecurityComboBox))
-
-#define EASYSETUP_SERVERSECURITY_COMBO_BOX_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST ((klass), \
- EASYSETUP_TYPE_SERVERSECURITY_COMBO_BOX, EasysetupServersecurityComboBoxClass))
-
-#define EASYSETUP_IS_SERVERSECURITY_COMBO_BOX(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
- EASYSETUP_TYPE_SERVERSECURITY_COMBO_BOX))
-
-#define EASYSETUP_IS_SERVERSECURITY_COMBO_BOX_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE ((klass), \
- EASYSETUP_TYPE_SERVERSECURITY_COMBO_BOX))
-
-#define EASYSETUP_SERVERSECURITY_COMBO_BOX_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), \
- EASYSETUP_TYPE_SERVERSECURITY_COMBO_BOX, EasysetupServersecurityComboBoxClass))
-
-typedef struct {
- GtkComboBox parent;
-} EasysetupServersecurityComboBox;
-
-typedef struct {
- GtkComboBoxClass parent_class;
-} EasysetupServersecurityComboBoxClass;
-
-GType easysetup_serversecurity_combo_box_get_type (void);
-
-EasysetupServersecurityComboBox* easysetup_serversecurity_combo_box_new (void);
-
-void easysetup_serversecurity_combo_box_fill (EasysetupServersecurityComboBox *combobox, ModestProtocol protocol);
-
-ModestProtocol easysetup_serversecurity_combo_box_get_active_serversecurity (EasysetupServersecurityComboBox *combobox);
-
-gboolean easysetup_serversecurity_combo_box_set_active_serversecurity (EasysetupServersecurityComboBox *combobox, ModestProtocol serversecurity);
-
-gint easysetup_serversecurity_combo_box_get_active_serversecurity_port (EasysetupServersecurityComboBox *combobox);
-
-
-G_END_DECLS
-
-#endif /* _EASYSETUP_PROVIDER_COMBO_BOX */
#include "maemo/easysetup/modest-easysetup-country-combo-box.h"
#include "maemo/easysetup/modest-easysetup-provider-combo-box.h"
#include "maemo/easysetup/modest-easysetup-servertype-combo-box.h"
-#include "maemo/easysetup/modest-easysetup-serversecurity-combo-box.h"
-#include "maemo/easysetup/modest-easysetup-secureauth-combo-box.h"
-#include "maemo/easysetup/modest-validating-entry.h"
+#include "widgets/modest-easysetup-serversecurity-combo-box.h"
+#include "widgets/modest-easysetup-secureauth-combo-box.h"
+#include "widgets/modest-validating-entry.h"
#include "modest-text-utils.h"
#include "modest-account-mgr.h"
#include "modest-account-mgr-helpers.h"
+++ /dev/null
-/* Copyright (c) 2007, Nokia Corporation
- * All rights reserved.
- *
- */
-
-#include "modest-validating-entry.h"
-#include <gtk/gtksignal.h> /* For the gtk_signal_stop_emit_by_name() convenience function. */
-#include <string.h> /* For strlen(). */
-
-/* Include config.h so that _() works: */
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-G_DEFINE_TYPE (EasysetupValidatingEntry, easysetup_validating_entry, GTK_TYPE_ENTRY);
-
-#define VALIDATING_ENTRY_GET_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((o), EASYSETUP_TYPE_VALIDATING_ENTRY, EasysetupValidatingEntryPrivate))
-
-typedef struct _EasysetupValidatingEntryPrivate EasysetupValidatingEntryPrivate;
-
-struct _EasysetupValidatingEntryPrivate
-{
- /* A list of gunichar, rather than char*,
- * because gunichar is easier to deal with internally,
- * but gchar* is easier to supply from the external interface.
- */
- GList *list_prevent;
-
- gboolean prevent_whitespace;
-};
-
-static void
-easysetup_validating_entry_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
-easysetup_validating_entry_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
-easysetup_validating_entry_dispose (GObject *object)
-{
- if (G_OBJECT_CLASS (easysetup_validating_entry_parent_class)->dispose)
- G_OBJECT_CLASS (easysetup_validating_entry_parent_class)->dispose (object);
-}
-
-static void
-easysetup_validating_entry_finalize (GObject *object)
-{
- EasysetupValidatingEntryPrivate *priv = VALIDATING_ENTRY_GET_PRIVATE (object);
-
- /* Free the list and its items: */
- if (priv->list_prevent) {
- g_list_foreach (priv->list_prevent, (GFunc)&g_free, NULL);
- g_list_free (priv->list_prevent);
- }
-
- G_OBJECT_CLASS (easysetup_validating_entry_parent_class)->finalize (object);
-}
-
-static void
-easysetup_validating_entry_class_init (EasysetupValidatingEntryClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- g_type_class_add_private (klass, sizeof (EasysetupValidatingEntryPrivate));
-
- object_class->get_property = easysetup_validating_entry_get_property;
- object_class->set_property = easysetup_validating_entry_set_property;
- object_class->dispose = easysetup_validating_entry_dispose;
- object_class->finalize = easysetup_validating_entry_finalize;
-}
-
-static gint
-on_list_compare(gconstpointer a, gconstpointer b)
-{
- gunichar* unichar_a = (gunichar*)(a);
- gunichar* unichar_b = (gunichar*)(b);
- if(*unichar_a == *unichar_b)
- return 0;
- else
- return -1; /* Really, we should return > and <, but we don't use this for sorting. */
-}
-
-static void
-on_insert_text(GtkEditable *editable,
- gchar *new_text, gint new_text_length,
- gint *position,
- gpointer user_data)
-{
- EasysetupValidatingEntry *self = EASYSETUP_VALIDATING_ENTRY (user_data);
- EasysetupValidatingEntryPrivate *priv = VALIDATING_ENTRY_GET_PRIVATE (self);
-
- if(!new_text_length)
- return;
-
- /* Note: new_text_length is documented as the number of bytes, not characters. */
- if(!g_utf8_validate (new_text, new_text_length, NULL))
- return;
-
- /* Look at each UTF-8 character in the text (it could be several via a drop or a paste),
- * and check them */
- gboolean allow = TRUE;
- gchar *iter = new_text; /* new_text seems to be NULL-terminated, though that is not documented. */
- while (iter)
- {
- if(priv->list_prevent) {
- /* If the character is in our prevent list,
- * then do not allow this text to be entered.
- *
- * This prevents entry of all text, without removing the unwanted characters.
- * It is debatable whether that is the best thing to do.
- */
- gunichar one_char = g_utf8_get_char (iter);
- GList *found = g_list_find_custom(priv->list_prevent, &one_char, &on_list_compare);
- if(found) {
- allow = FALSE;
- break;
- }
- }
-
- if(priv->prevent_whitespace) {
- /* Check for whitespace characters: */
- gunichar one_char = g_utf8_get_char (iter);
- if (g_unichar_isspace (one_char)) {
- allow = FALSE;
- break;
- }
- }
-
- /* Crashes. Don't know why: iter = g_utf8_next_char (iter);
- * Maybe it doesn't check for null-termination. */
- iter = g_utf8_find_next_char (iter, new_text + new_text_length);
- }
-
- if(!allow) {
- /* The signal documentation says
- * "by connecting to this signal and then stopping the signal with
- * gtk_signal_emit_stop(), it is possible to modify the inserted text,
- * or prevent it from being inserted entirely."
- */
- gtk_signal_emit_stop_by_name (GTK_OBJECT (self), "insert-text");
- }
-}
-
-static void
-easysetup_validating_entry_init (EasysetupValidatingEntry *self)
-{
- /* Connect to the GtkEditable::insert-text signal
- * so we can filter out some characters:
- * We connect _before_ so we can stop the default signal handler from running.
- */
- g_signal_connect (G_OBJECT (self), "insert-text", (GCallback)&on_insert_text, self);
-}
-
-EasysetupValidatingEntry*
-easysetup_validating_entry_new (void)
-{
- return g_object_new (EASYSETUP_TYPE_VALIDATING_ENTRY, NULL);
-}
-
-/** Specify characters that may not be entered into this GtkEntry.
- *
- * list: A list of gchar* strings. Each one identifies a UTF-8 character.
- */
-void easysetup_validating_entry_set_unallowed_characters (EasysetupValidatingEntry *self, GList *list)
-{
- EasysetupValidatingEntryPrivate *priv = VALIDATING_ENTRY_GET_PRIVATE (self);
-
- /* Free the list and its items: */
- if (priv->list_prevent) {
- g_list_foreach (priv->list_prevent, (GFunc)&g_free, NULL);
- g_list_free (priv->list_prevent);
- }
-
- /* Do a deep copy of the list, converting gchar* to gunichar: */
- priv->list_prevent = NULL;
- GList *iter = NULL;
- for (iter = list; iter != NULL; iter = iter->next) {
- gunichar *one_char = g_new0 (gunichar, 1);
- if(iter->data)
- *one_char = g_utf8_get_char ((gchar*)iter->data);
- else
- *one_char = 0;
-
- priv->list_prevent = g_list_append (priv->list_prevent, one_char);
- }
-}
-
-/** Specify that no whitespace characters may be entered into this GtkEntry.
- *
- */
-void easysetup_validating_entry_set_unallowed_characters_whitespace (EasysetupValidatingEntry *self)
-{
- EasysetupValidatingEntryPrivate *priv = VALIDATING_ENTRY_GET_PRIVATE (self);
- priv->prevent_whitespace = TRUE;
-}
+++ /dev/null
-/* Copyright (c) 2007, Nokia Corporation
- * All rights reserved.
- *
- */
-
-#ifndef _EASYSETUP_VALIDATING_ENTRY
-#define _EASYSETUP_VALIDATING_ENTRY
-
-#include <gtk/gtkentry.h>
-
-G_BEGIN_DECLS
-
-#define EASYSETUP_TYPE_VALIDATING_ENTRY easysetup_validating_entry_get_type()
-
-#define EASYSETUP_VALIDATING_ENTRY(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
- EASYSETUP_TYPE_VALIDATING_ENTRY, EasysetupValidatingEntry))
-
-#define EASYSETUP_VALIDATING_ENTRY_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST ((klass), \
- EASYSETUP_TYPE_VALIDATING_ENTRY, EasysetupValidatingEntryClass))
-
-#define EASYSETUP_IS_VALIDATING_ENTRY(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
- EASYSETUP_TYPE_VALIDATING_ENTRY))
-
-#define EASYSETUP_IS_VALIDATING_ENTRY_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE ((klass), \
- EASYSETUP_TYPE_VALIDATING_ENTRY))
-
-#define EASYSETUP_VALIDATING_ENTRY_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), \
- EASYSETUP_TYPE_VALIDATING_ENTRY, EasysetupValidatingEntryClass))
-
-typedef struct {
- GtkEntry parent;
-} EasysetupValidatingEntry;
-
-typedef struct {
- GtkEntryClass parent_class;
-} EasysetupValidatingEntryClass;
-
-GType easysetup_validating_entry_get_type (void);
-
-EasysetupValidatingEntry* easysetup_validating_entry_new (void);
-
-void easysetup_validating_entry_set_unallowed_characters (EasysetupValidatingEntry *self, GList *list);
-void easysetup_validating_entry_set_unallowed_characters_whitespace (EasysetupValidatingEntry *self);
-
-G_END_DECLS
-
-#endif /* _EASYSETUP_VALIDATING_ENTRY */
#include "maemo/easysetup/modest-easysetup-country-combo-box.h"
#include "maemo/easysetup/modest-easysetup-provider-combo-box.h"
#include "maemo/easysetup/modest-easysetup-servertype-combo-box.h"
-#include "maemo/easysetup/modest-easysetup-serversecurity-combo-box.h"
-#include "maemo/easysetup/modest-easysetup-secureauth-combo-box.h"
-#include "maemo/easysetup/modest-validating-entry.h"
+#include "widgets/modest-easysetup-serversecurity-combo-box.h"
+#include "widgets/modest-easysetup-secureauth-combo-box.h"
+#include "widgets/modest-validating-entry.h"
#include "widgets/modest-retrieve-combo-box.h"
#include "widgets/modest-limit-retrieve-combo-box.h"
#include "modest-text-utils.h"
#include "maemo/easysetup/modest-easysetup-country-combo-box.h"
#include "maemo/easysetup/modest-easysetup-provider-combo-box.h"
#include "maemo/easysetup/modest-easysetup-servertype-combo-box.h"
-#include "maemo/easysetup/modest-easysetup-serversecurity-combo-box.h"
-#include "maemo/easysetup/modest-easysetup-secureauth-combo-box.h"
-#include "maemo/easysetup/modest-validating-entry.h"
+#include "widgets/modest-easysetup-serversecurity-combo-box.h"
+#include "widgets/modest-easysetup-secureauth-combo-box.h"
+#include "widgets/modest-validating-entry.h"
#include <modest-account-mgr-helpers.h>
#include <gtk/gtkbutton.h>
#include <gtk/gtkhbox.h>
modest-retrieve-combo-box.c \
modest-scroll-text.c \
modest-scroll-text.h \
+ modest-easysetup-serversecurity-combo-box.h modest-easysetup-serversecurity-combo-box.c \
+ modest-easysetup-secureauth-combo-box.h modest-easysetup-secureauth-combo-box.c \
modest-tny-stream-gtkhtml.c \
modest-tny-stream-gtkhtml.h \
+ modest-validating-entry.h modest-validating-entry.c \
modest-window.c \
modest-window.h \
modest-window-mgr.h \
--- /dev/null
+/* Copyright (c) 2007, Nokia Corporation
+ * All rights reserved.
+ *
+ */
+
+#include "modest-easysetup-secureauth-combo-box.h"
+#include <gtk/gtkliststore.h>
+#include <gtk/gtkcelllayout.h>
+#include <gtk/gtkcellrenderertext.h>
+#include <glib/gi18n.h>
+
+#include <stdlib.h>
+#include <string.h> /* For memcpy() */
+
+/* Include config.h so that _() works: */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+G_DEFINE_TYPE (EasysetupSecureauthComboBox, easysetup_secureauth_combo_box, GTK_TYPE_COMBO_BOX);
+
+#define SECUREAUTH_COMBO_BOX_GET_PRIVATE(o) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((o), EASYSETUP_TYPE_SECUREAUTH_COMBO_BOX, EasysetupSecureauthComboBoxPrivate))
+
+typedef struct _EasysetupSecureauthComboBoxPrivate EasysetupSecureauthComboBoxPrivate;
+
+struct _EasysetupSecureauthComboBoxPrivate
+{
+ GtkTreeModel *model;
+};
+
+static void
+easysetup_secureauth_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
+easysetup_secureauth_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
+easysetup_secureauth_combo_box_dispose (GObject *object)
+{
+ if (G_OBJECT_CLASS (easysetup_secureauth_combo_box_parent_class)->dispose)
+ G_OBJECT_CLASS (easysetup_secureauth_combo_box_parent_class)->dispose (object);
+}
+
+static void
+easysetup_secureauth_combo_box_finalize (GObject *object)
+{
+ EasysetupSecureauthComboBoxPrivate *priv = SECUREAUTH_COMBO_BOX_GET_PRIVATE (object);
+
+ g_object_unref (G_OBJECT (priv->model));
+
+ G_OBJECT_CLASS (easysetup_secureauth_combo_box_parent_class)->finalize (object);
+}
+
+static void
+easysetup_secureauth_combo_box_class_init (EasysetupSecureauthComboBoxClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (EasysetupSecureauthComboBoxPrivate));
+
+ object_class->get_property = easysetup_secureauth_combo_box_get_property;
+ object_class->set_property = easysetup_secureauth_combo_box_set_property;
+ object_class->dispose = easysetup_secureauth_combo_box_dispose;
+ object_class->finalize = easysetup_secureauth_combo_box_finalize;
+}
+
+enum MODEL_COLS {
+ MODEL_COL_NAME = 0, /* a string */
+ MODEL_COL_ID = 1 /* an int. */
+};
+
+void easysetup_secureauth_combo_box_fill (EasysetupSecureauthComboBox *combobox);
+
+static void
+easysetup_secureauth_combo_box_init (EasysetupSecureauthComboBox *self)
+{
+ EasysetupSecureauthComboBoxPrivate *priv = SECUREAUTH_COMBO_BOX_GET_PRIVATE (self);
+
+ /* Create a tree model for the combo box,
+ * with a string for the name, and an ID for the secureauth.
+ * This must match our MODEL_COLS enum constants.
+ */
+ priv->model = GTK_TREE_MODEL (gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT));
+
+ /* Setup the combo box: */
+ GtkComboBox *combobox = GTK_COMBO_BOX (self);
+ gtk_combo_box_set_model (combobox, priv->model);
+
+ /* Secureauth column:
+ * The ID model column in not shown in the view. */
+ GtkCellRenderer *renderer = gtk_cell_renderer_text_new ();
+ 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);
+
+ easysetup_secureauth_combo_box_fill (self);
+}
+
+EasysetupSecureauthComboBox*
+easysetup_secureauth_combo_box_new (void)
+{
+ return g_object_new (EASYSETUP_TYPE_SECUREAUTH_COMBO_BOX, NULL);
+}
+
+/* Fill the combo box with appropriate choices.
+ * #combobox: The combo box.
+ * @protocol: IMAP or POP.
+ */
+void easysetup_secureauth_combo_box_fill (EasysetupSecureauthComboBox *combobox)
+{
+ EasysetupSecureauthComboBoxPrivate *priv = SECUREAUTH_COMBO_BOX_GET_PRIVATE (combobox);
+
+ /* Remove any existing rows: */
+ GtkListStore *liststore = GTK_LIST_STORE (priv->model);
+ gtk_list_store_clear (liststore);
+
+ GtkTreeIter iter;
+ gtk_list_store_append (liststore, &iter);
+ gtk_list_store_set (liststore, &iter, MODEL_COL_ID, (gint)MODEST_PROTOCOL_AUTH_NONE, MODEL_COL_NAME, _("mcen_fi_advsetup_smtp_none"), -1);
+
+ /* Select the None item: */
+ gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combobox), &iter);
+
+ gtk_list_store_append (liststore, &iter);
+ gtk_list_store_set (liststore, &iter, MODEL_COL_ID, (gint)MODEST_PROTOCOL_AUTH_PASSWORD, MODEL_COL_NAME, _("mcen_fi_advsetup_smtp_login"), -1);
+
+ gtk_list_store_append (liststore, &iter);
+ gtk_list_store_set (liststore, &iter, MODEL_COL_ID, (gint)MODEST_PROTOCOL_AUTH_CRAMMD5, MODEL_COL_NAME, _("mcen_fi_advsetup_smtp_cram_md5"), -1);
+}
+
+/**
+ * Returns the selected secureauth,
+ * or MODEST_PROTOCOL_UNKNOWN if no secureauth was selected.
+ */
+ModestProtocol
+easysetup_secureauth_combo_box_get_active_secureauth (EasysetupSecureauthComboBox *combobox)
+{
+ GtkTreeIter active;
+ const gboolean found = gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combobox), &active);
+ if (found) {
+ EasysetupSecureauthComboBoxPrivate *priv = SECUREAUTH_COMBO_BOX_GET_PRIVATE (combobox);
+
+ ModestProtocol secureauth = MODEST_PROTOCOL_UNKNOWN;
+ gtk_tree_model_get (priv->model, &active, MODEL_COL_ID, &secureauth, -1);
+ return secureauth;
+ }
+
+ return MODEST_PROTOCOL_UNKNOWN; /* Failed. */
+}
+
+/* This allows us to pass more than one piece of data to the signal handler,
+ * and get a result: */
+typedef struct
+{
+ EasysetupSecureauthComboBox* self;
+ gint id;
+ gboolean found;
+} ForEachData;
+
+static gboolean
+on_model_foreach_select_id(GtkTreeModel *model,
+ GtkTreePath *path, GtkTreeIter *iter, gpointer user_data)
+{
+ ForEachData *state = (ForEachData*)(user_data);
+
+ /* Select the item if it has the matching ID: */
+ guint id = 0;
+ gtk_tree_model_get (model, iter, MODEL_COL_ID, &id, -1);
+ if(id == state->id) {
+ gtk_combo_box_set_active_iter (GTK_COMBO_BOX (state->self), iter);
+
+ state->found = TRUE;
+ return TRUE; /* Stop walking the tree. */
+ }
+
+ return FALSE; /* Keep walking the tree. */
+}
+
+/**
+ * Selects the specified secureauth,
+ * or MODEST_PROTOCOL_UNKNOWN if no secureauth was selected.
+ */
+gboolean
+easysetup_secureauth_combo_box_set_active_secureauth (EasysetupSecureauthComboBox *combobox, ModestProtocol secureauth)
+{
+ EasysetupSecureauthComboBoxPrivate *priv = SECUREAUTH_COMBO_BOX_GET_PRIVATE (combobox);
+
+ /* Create a state instance so we can send two items of data to the signal handler: */
+ ForEachData *state = g_new0 (ForEachData, 1);
+ state->self = combobox;
+ state->id = secureauth;
+ state->found = FALSE;
+
+ /* Look at each item, and select the one with the correct ID: */
+ gtk_tree_model_foreach (priv->model, &on_model_foreach_select_id, state);
+
+ const gboolean result = state->found;
+
+ /* Free the state instance: */
+ g_free(state);
+
+ return result;
+}
+
--- /dev/null
+/* Copyright (c) 2007, Nokia Corporation
+ * All rights reserved.
+ *
+ */
+
+#ifndef _EASYSETUP_SECUREAUTH_COMBO_BOX
+#define _EASYSETUP_SECUREAUTH_COMBO_BOX
+
+#include <gtk/gtkcombobox.h>
+#include "modest-protocol-info.h"
+
+G_BEGIN_DECLS
+
+#define EASYSETUP_TYPE_SECUREAUTH_COMBO_BOX easysetup_secureauth_combo_box_get_type()
+
+#define EASYSETUP_SECUREAUTH_COMBO_BOX(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ EASYSETUP_TYPE_SECUREAUTH_COMBO_BOX, EasysetupSecureauthComboBox))
+
+#define EASYSETUP_SECUREAUTH_COMBO_BOX_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST ((klass), \
+ EASYSETUP_TYPE_SECUREAUTH_COMBO_BOX, EasysetupSecureauthComboBoxClass))
+
+#define EASYSETUP_IS_SECUREAUTH_COMBO_BOX(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ EASYSETUP_TYPE_SECUREAUTH_COMBO_BOX))
+
+#define EASYSETUP_IS_SECUREAUTH_COMBO_BOX_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+ EASYSETUP_TYPE_SECUREAUTH_COMBO_BOX))
+
+#define EASYSETUP_SECUREAUTH_COMBO_BOX_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+ EASYSETUP_TYPE_SECUREAUTH_COMBO_BOX, EasysetupSecureauthComboBoxClass))
+
+typedef struct {
+ GtkComboBox parent;
+} EasysetupSecureauthComboBox;
+
+typedef struct {
+ GtkComboBoxClass parent_class;
+} EasysetupSecureauthComboBoxClass;
+
+GType easysetup_secureauth_combo_box_get_type (void);
+
+EasysetupSecureauthComboBox* easysetup_secureauth_combo_box_new (void);
+
+ModestProtocol easysetup_secureauth_combo_box_get_active_secureauth (EasysetupSecureauthComboBox *combobox);
+
+gboolean easysetup_secureauth_combo_box_set_active_secureauth (EasysetupSecureauthComboBox *combobox, ModestProtocol secureauth);
+
+
+G_END_DECLS
+
+#endif /* _EASYSETUP_PROVIDER_COMBO_BOX */
--- /dev/null
+/* Copyright (c) 2007, Nokia Corporation
+ * All rights reserved.
+ *
+ */
+
+#include "modest-easysetup-serversecurity-combo-box.h"
+#include <gtk/gtkliststore.h>
+#include <gtk/gtkcelllayout.h>
+#include <gtk/gtkcellrenderertext.h>
+#include <glib/gi18n.h>
+
+#include <stdlib.h>
+#include <string.h> /* For memcpy() */
+
+/* Include config.h so that _() works: */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+G_DEFINE_TYPE (EasysetupServersecurityComboBox, easysetup_serversecurity_combo_box, GTK_TYPE_COMBO_BOX);
+
+#define SERVERSECURITY_COMBO_BOX_GET_PRIVATE(o) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((o), EASYSETUP_TYPE_SERVERSECURITY_COMBO_BOX, EasysetupServersecurityComboBoxPrivate))
+
+typedef struct _EasysetupServersecurityComboBoxPrivate EasysetupServersecurityComboBoxPrivate;
+
+struct _EasysetupServersecurityComboBoxPrivate
+{
+ GtkTreeModel *model;
+ ModestProtocol protocol;
+};
+
+static void
+easysetup_serversecurity_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
+easysetup_serversecurity_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
+easysetup_serversecurity_combo_box_dispose (GObject *object)
+{
+ if (G_OBJECT_CLASS (easysetup_serversecurity_combo_box_parent_class)->dispose)
+ G_OBJECT_CLASS (easysetup_serversecurity_combo_box_parent_class)->dispose (object);
+}
+
+static void
+easysetup_serversecurity_combo_box_finalize (GObject *object)
+{
+ EasysetupServersecurityComboBoxPrivate *priv = SERVERSECURITY_COMBO_BOX_GET_PRIVATE (object);
+
+ g_object_unref (G_OBJECT (priv->model));
+
+ G_OBJECT_CLASS (easysetup_serversecurity_combo_box_parent_class)->finalize (object);
+}
+
+static void
+easysetup_serversecurity_combo_box_class_init (EasysetupServersecurityComboBoxClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (EasysetupServersecurityComboBoxPrivate));
+
+ object_class->get_property = easysetup_serversecurity_combo_box_get_property;
+ object_class->set_property = easysetup_serversecurity_combo_box_set_property;
+ object_class->dispose = easysetup_serversecurity_combo_box_dispose;
+ object_class->finalize = easysetup_serversecurity_combo_box_finalize;
+}
+
+enum MODEL_COLS {
+ MODEL_COL_NAME = 0, /* a string */
+ MODEL_COL_ID = 1 /* an int. */
+};
+
+static void
+easysetup_serversecurity_combo_box_init (EasysetupServersecurityComboBox *self)
+{
+ EasysetupServersecurityComboBoxPrivate *priv = SERVERSECURITY_COMBO_BOX_GET_PRIVATE (self);
+
+ /* Create a tree model for the combo box,
+ * with a string for the name, and an ID for the serversecurity.
+ * This must match our MODEL_COLS enum constants.
+ */
+ priv->model = GTK_TREE_MODEL (gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT));
+
+ /* Setup the combo box: */
+ GtkComboBox *combobox = GTK_COMBO_BOX (self);
+ gtk_combo_box_set_model (combobox, priv->model);
+
+ /* Serversecurity column:
+ * The ID model column in not shown in the view. */
+ GtkCellRenderer *renderer = gtk_cell_renderer_text_new ();
+ 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);
+
+ /* The application must call easysetup_serversecurity_combo_box_fill().
+ */
+}
+
+EasysetupServersecurityComboBox*
+easysetup_serversecurity_combo_box_new (void)
+{
+ return g_object_new (EASYSETUP_TYPE_SERVERSECURITY_COMBO_BOX, NULL);
+}
+
+/* Fill the combo box with appropriate choices.
+ * #combobox: The combo box.
+ * @protocol: IMAP or POP.
+ */
+void easysetup_serversecurity_combo_box_fill (EasysetupServersecurityComboBox *combobox, ModestProtocol protocol)
+{
+ EasysetupServersecurityComboBoxPrivate *priv = SERVERSECURITY_COMBO_BOX_GET_PRIVATE (combobox);
+ priv->protocol = protocol; /* Remembered for later. */
+
+ /* Remove any existing rows: */
+ GtkListStore *liststore = GTK_LIST_STORE (priv->model);
+ gtk_list_store_clear (liststore);
+
+ GtkTreeIter iter;
+ gtk_list_store_append (liststore, &iter);
+ gtk_list_store_set (liststore, &iter, MODEL_COL_ID, (gint)MODEST_PROTOCOL_SECURITY_NONE, MODEL_COL_NAME, _("mcen_fi_advsetup_other_security_none"), -1);
+
+ /* Select the None item: */
+ gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combobox), &iter);
+
+ gtk_list_store_append (liststore, &iter);
+ gtk_list_store_set (liststore, &iter, MODEL_COL_ID, (gint)MODEST_PROTOCOL_SECURITY_TLS, MODEL_COL_NAME, _("mcen_fi_advsetup_other_security_normal"), -1);
+
+ /* Add security choices with protocol-specific names, as in the UI spec:
+ * (Note: Changing the title seems pointless. murrayc) */
+ if(protocol == MODEST_PROTOCOL_STORE_POP) {
+ gtk_list_store_append (liststore, &iter);
+ gtk_list_store_set (liststore, &iter, MODEL_COL_ID, (gint)MODEST_PROTOCOL_SECURITY_SSL, MODEL_COL_NAME, _("mcen_fi_advsetup_other_security_securepop3s"), -1);
+ } else if(protocol == MODEST_PROTOCOL_STORE_IMAP) {
+ gtk_list_store_append (liststore, &iter);
+ gtk_list_store_set (liststore, &iter, MODEL_COL_ID, (gint)MODEST_PROTOCOL_SECURITY_SSL, MODEL_COL_NAME, _("mcen_fi_advsetup_other_security_secureimap4"), -1);
+ } else if(protocol == MODEST_PROTOCOL_TRANSPORT_SMTP) {
+ gtk_list_store_append (liststore, &iter);
+ gtk_list_store_set (liststore, &iter, MODEL_COL_ID, (gint)MODEST_PROTOCOL_SECURITY_SSL, MODEL_COL_NAME, _("mcen_fi_advsetup_other_security_ssl"), -1);
+ }
+}
+
+static gint get_port_for_security (ModestProtocol protocol, ModestProtocol security)
+{
+ /* See the UI spec, section Email Wizards, Incoming Details [MSG-WIZ001]: */
+ gint result = 0;
+
+ /* Get the default port number for this protocol with this security: */
+ if(protocol == MODEST_PROTOCOL_STORE_POP) {
+ if ((security == MODEST_PROTOCOL_SECURITY_NONE) || (security == MODEST_PROTOCOL_SECURITY_TLS))
+ result = 110;
+ else if (security == MODEST_PROTOCOL_SECURITY_SSL)
+ result = 995;
+ } else if (protocol == MODEST_PROTOCOL_STORE_IMAP) {
+ if ((security == MODEST_PROTOCOL_SECURITY_NONE) || (security == MODEST_PROTOCOL_SECURITY_TLS))
+ result = 143;
+ else if (security == MODEST_PROTOCOL_SECURITY_SSL)
+ result = 993;
+ } else if (protocol == MODEST_PROTOCOL_TRANSPORT_SMTP) {
+ if ((security == MODEST_PROTOCOL_SECURITY_NONE) || (security == MODEST_PROTOCOL_SECURITY_TLS))
+ result = 25;
+ else if (security == MODEST_PROTOCOL_SECURITY_SSL)
+ result = 465;
+ }
+
+ return result;
+}
+
+/**
+ * Returns the selected serversecurity,
+ * or MODEST_PROTOCOL_UNKNOWN if no serversecurity was selected.
+ */
+ModestProtocol
+easysetup_serversecurity_combo_box_get_active_serversecurity (EasysetupServersecurityComboBox *combobox)
+{
+ GtkTreeIter active;
+ const gboolean found = gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combobox), &active);
+ if (found) {
+ EasysetupServersecurityComboBoxPrivate *priv = SERVERSECURITY_COMBO_BOX_GET_PRIVATE (combobox);
+
+ ModestProtocol serversecurity = MODEST_PROTOCOL_UNKNOWN;
+ gtk_tree_model_get (priv->model, &active, MODEL_COL_ID, &serversecurity, -1);
+ return serversecurity;
+ }
+
+ return MODEST_PROTOCOL_UNKNOWN; /* Failed. */
+}
+
+/**
+ * Returns the default port to be used for the selected serversecurity,
+ * or 0 if no serversecurity was selected.
+ */
+gint
+easysetup_serversecurity_combo_box_get_active_serversecurity_port (EasysetupServersecurityComboBox *combobox)
+{
+ EasysetupServersecurityComboBoxPrivate *priv = SERVERSECURITY_COMBO_BOX_GET_PRIVATE (combobox);
+
+ const ModestProtocol security = easysetup_serversecurity_combo_box_get_active_serversecurity
+ (combobox);
+ return get_port_for_security (priv->protocol, security);
+}
+
+/* This allows us to pass more than one piece of data to the signal handler,
+ * and get a result: */
+typedef struct
+{
+ EasysetupServersecurityComboBox* self;
+ gint id;
+ gboolean found;
+} ForEachData;
+
+static gboolean
+on_model_foreach_select_id(GtkTreeModel *model,
+ GtkTreePath *path, GtkTreeIter *iter, gpointer user_data)
+{
+ ForEachData *state = (ForEachData*)(user_data);
+
+ /* Select the item if it has the matching ID: */
+ guint id = 0;
+ gtk_tree_model_get (model, iter, MODEL_COL_ID, &id, -1);
+ if(id == state->id) {
+ gtk_combo_box_set_active_iter (GTK_COMBO_BOX (state->self), iter);
+
+ state->found = TRUE;
+ return TRUE; /* Stop walking the tree. */
+ }
+
+ return FALSE; /* Keep walking the tree. */
+}
+
+/**
+ * Selects the specified serversecurity,
+ * or MODEST_PROTOCOL_UNKNOWN if no serversecurity was selected.
+ */
+gboolean
+easysetup_serversecurity_combo_box_set_active_serversecurity (EasysetupServersecurityComboBox *combobox, ModestProtocol serversecurity)
+{
+ EasysetupServersecurityComboBoxPrivate *priv = SERVERSECURITY_COMBO_BOX_GET_PRIVATE (combobox);
+
+ /* Create a state instance so we can send two items of data to the signal handler: */
+ ForEachData *state = g_new0 (ForEachData, 1);
+ state->self = combobox;
+ state->id = serversecurity;
+ state->found = FALSE;
+
+ /* Look at each item, and select the one with the correct ID: */
+ gtk_tree_model_foreach (priv->model, &on_model_foreach_select_id, state);
+
+ const gboolean result = state->found;
+
+ /* Free the state instance: */
+ g_free(state);
+
+ return result;
+}
+
--- /dev/null
+/* Copyright (c) 2007, Nokia Corporation
+ * All rights reserved.
+ *
+ */
+
+#ifndef _EASYSETUP_SERVERSECURITY_COMBO_BOX
+#define _EASYSETUP_SERVERSECURITY_COMBO_BOX
+
+#include <gtk/gtkcombobox.h>
+#include "modest-protocol-info.h"
+
+G_BEGIN_DECLS
+
+#define EASYSETUP_TYPE_SERVERSECURITY_COMBO_BOX easysetup_serversecurity_combo_box_get_type()
+
+#define EASYSETUP_SERVERSECURITY_COMBO_BOX(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ EASYSETUP_TYPE_SERVERSECURITY_COMBO_BOX, EasysetupServersecurityComboBox))
+
+#define EASYSETUP_SERVERSECURITY_COMBO_BOX_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST ((klass), \
+ EASYSETUP_TYPE_SERVERSECURITY_COMBO_BOX, EasysetupServersecurityComboBoxClass))
+
+#define EASYSETUP_IS_SERVERSECURITY_COMBO_BOX(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ EASYSETUP_TYPE_SERVERSECURITY_COMBO_BOX))
+
+#define EASYSETUP_IS_SERVERSECURITY_COMBO_BOX_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+ EASYSETUP_TYPE_SERVERSECURITY_COMBO_BOX))
+
+#define EASYSETUP_SERVERSECURITY_COMBO_BOX_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+ EASYSETUP_TYPE_SERVERSECURITY_COMBO_BOX, EasysetupServersecurityComboBoxClass))
+
+typedef struct {
+ GtkComboBox parent;
+} EasysetupServersecurityComboBox;
+
+typedef struct {
+ GtkComboBoxClass parent_class;
+} EasysetupServersecurityComboBoxClass;
+
+GType easysetup_serversecurity_combo_box_get_type (void);
+
+EasysetupServersecurityComboBox* easysetup_serversecurity_combo_box_new (void);
+
+void easysetup_serversecurity_combo_box_fill (EasysetupServersecurityComboBox *combobox, ModestProtocol protocol);
+
+ModestProtocol easysetup_serversecurity_combo_box_get_active_serversecurity (EasysetupServersecurityComboBox *combobox);
+
+gboolean easysetup_serversecurity_combo_box_set_active_serversecurity (EasysetupServersecurityComboBox *combobox, ModestProtocol serversecurity);
+
+gint easysetup_serversecurity_combo_box_get_active_serversecurity_port (EasysetupServersecurityComboBox *combobox);
+
+
+G_END_DECLS
+
+#endif /* _EASYSETUP_PROVIDER_COMBO_BOX */
--- /dev/null
+/* Copyright (c) 2007, Nokia Corporation
+ * All rights reserved.
+ *
+ */
+
+#include "modest-validating-entry.h"
+#include <gtk/gtksignal.h> /* For the gtk_signal_stop_emit_by_name() convenience function. */
+#include <string.h> /* For strlen(). */
+
+/* Include config.h so that _() works: */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+G_DEFINE_TYPE (EasysetupValidatingEntry, easysetup_validating_entry, GTK_TYPE_ENTRY);
+
+#define VALIDATING_ENTRY_GET_PRIVATE(o) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((o), EASYSETUP_TYPE_VALIDATING_ENTRY, EasysetupValidatingEntryPrivate))
+
+typedef struct _EasysetupValidatingEntryPrivate EasysetupValidatingEntryPrivate;
+
+struct _EasysetupValidatingEntryPrivate
+{
+ /* A list of gunichar, rather than char*,
+ * because gunichar is easier to deal with internally,
+ * but gchar* is easier to supply from the external interface.
+ */
+ GList *list_prevent;
+
+ gboolean prevent_whitespace;
+};
+
+static void
+easysetup_validating_entry_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
+easysetup_validating_entry_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
+easysetup_validating_entry_dispose (GObject *object)
+{
+ if (G_OBJECT_CLASS (easysetup_validating_entry_parent_class)->dispose)
+ G_OBJECT_CLASS (easysetup_validating_entry_parent_class)->dispose (object);
+}
+
+static void
+easysetup_validating_entry_finalize (GObject *object)
+{
+ EasysetupValidatingEntryPrivate *priv = VALIDATING_ENTRY_GET_PRIVATE (object);
+
+ /* Free the list and its items: */
+ if (priv->list_prevent) {
+ g_list_foreach (priv->list_prevent, (GFunc)&g_free, NULL);
+ g_list_free (priv->list_prevent);
+ }
+
+ G_OBJECT_CLASS (easysetup_validating_entry_parent_class)->finalize (object);
+}
+
+static void
+easysetup_validating_entry_class_init (EasysetupValidatingEntryClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (EasysetupValidatingEntryPrivate));
+
+ object_class->get_property = easysetup_validating_entry_get_property;
+ object_class->set_property = easysetup_validating_entry_set_property;
+ object_class->dispose = easysetup_validating_entry_dispose;
+ object_class->finalize = easysetup_validating_entry_finalize;
+}
+
+static gint
+on_list_compare(gconstpointer a, gconstpointer b)
+{
+ gunichar* unichar_a = (gunichar*)(a);
+ gunichar* unichar_b = (gunichar*)(b);
+ if(*unichar_a == *unichar_b)
+ return 0;
+ else
+ return -1; /* Really, we should return > and <, but we don't use this for sorting. */
+}
+
+static void
+on_insert_text(GtkEditable *editable,
+ gchar *new_text, gint new_text_length,
+ gint *position,
+ gpointer user_data)
+{
+ EasysetupValidatingEntry *self = EASYSETUP_VALIDATING_ENTRY (user_data);
+ EasysetupValidatingEntryPrivate *priv = VALIDATING_ENTRY_GET_PRIVATE (self);
+
+ if(!new_text_length)
+ return;
+
+ /* Note: new_text_length is documented as the number of bytes, not characters. */
+ if(!g_utf8_validate (new_text, new_text_length, NULL))
+ return;
+
+ /* Look at each UTF-8 character in the text (it could be several via a drop or a paste),
+ * and check them */
+ gboolean allow = TRUE;
+ gchar *iter = new_text; /* new_text seems to be NULL-terminated, though that is not documented. */
+ while (iter)
+ {
+ if(priv->list_prevent) {
+ /* If the character is in our prevent list,
+ * then do not allow this text to be entered.
+ *
+ * This prevents entry of all text, without removing the unwanted characters.
+ * It is debatable whether that is the best thing to do.
+ */
+ gunichar one_char = g_utf8_get_char (iter);
+ GList *found = g_list_find_custom(priv->list_prevent, &one_char, &on_list_compare);
+ if(found) {
+ allow = FALSE;
+ break;
+ }
+ }
+
+ if(priv->prevent_whitespace) {
+ /* Check for whitespace characters: */
+ gunichar one_char = g_utf8_get_char (iter);
+ if (g_unichar_isspace (one_char)) {
+ allow = FALSE;
+ break;
+ }
+ }
+
+ /* Crashes. Don't know why: iter = g_utf8_next_char (iter);
+ * Maybe it doesn't check for null-termination. */
+ iter = g_utf8_find_next_char (iter, new_text + new_text_length);
+ }
+
+ if(!allow) {
+ /* The signal documentation says
+ * "by connecting to this signal and then stopping the signal with
+ * gtk_signal_emit_stop(), it is possible to modify the inserted text,
+ * or prevent it from being inserted entirely."
+ */
+ gtk_signal_emit_stop_by_name (GTK_OBJECT (self), "insert-text");
+ }
+}
+
+static void
+easysetup_validating_entry_init (EasysetupValidatingEntry *self)
+{
+ /* Connect to the GtkEditable::insert-text signal
+ * so we can filter out some characters:
+ * We connect _before_ so we can stop the default signal handler from running.
+ */
+ g_signal_connect (G_OBJECT (self), "insert-text", (GCallback)&on_insert_text, self);
+}
+
+EasysetupValidatingEntry*
+easysetup_validating_entry_new (void)
+{
+ return g_object_new (EASYSETUP_TYPE_VALIDATING_ENTRY, NULL);
+}
+
+/** Specify characters that may not be entered into this GtkEntry.
+ *
+ * list: A list of gchar* strings. Each one identifies a UTF-8 character.
+ */
+void easysetup_validating_entry_set_unallowed_characters (EasysetupValidatingEntry *self, GList *list)
+{
+ EasysetupValidatingEntryPrivate *priv = VALIDATING_ENTRY_GET_PRIVATE (self);
+
+ /* Free the list and its items: */
+ if (priv->list_prevent) {
+ g_list_foreach (priv->list_prevent, (GFunc)&g_free, NULL);
+ g_list_free (priv->list_prevent);
+ }
+
+ /* Do a deep copy of the list, converting gchar* to gunichar: */
+ priv->list_prevent = NULL;
+ GList *iter = NULL;
+ for (iter = list; iter != NULL; iter = iter->next) {
+ gunichar *one_char = g_new0 (gunichar, 1);
+ if(iter->data)
+ *one_char = g_utf8_get_char ((gchar*)iter->data);
+ else
+ *one_char = 0;
+
+ priv->list_prevent = g_list_append (priv->list_prevent, one_char);
+ }
+}
+
+/** Specify that no whitespace characters may be entered into this GtkEntry.
+ *
+ */
+void easysetup_validating_entry_set_unallowed_characters_whitespace (EasysetupValidatingEntry *self)
+{
+ EasysetupValidatingEntryPrivate *priv = VALIDATING_ENTRY_GET_PRIVATE (self);
+ priv->prevent_whitespace = TRUE;
+}
--- /dev/null
+/* Copyright (c) 2007, Nokia Corporation
+ * All rights reserved.
+ *
+ */
+
+#ifndef _EASYSETUP_VALIDATING_ENTRY
+#define _EASYSETUP_VALIDATING_ENTRY
+
+#include <gtk/gtkentry.h>
+
+G_BEGIN_DECLS
+
+#define EASYSETUP_TYPE_VALIDATING_ENTRY easysetup_validating_entry_get_type()
+
+#define EASYSETUP_VALIDATING_ENTRY(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ EASYSETUP_TYPE_VALIDATING_ENTRY, EasysetupValidatingEntry))
+
+#define EASYSETUP_VALIDATING_ENTRY_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST ((klass), \
+ EASYSETUP_TYPE_VALIDATING_ENTRY, EasysetupValidatingEntryClass))
+
+#define EASYSETUP_IS_VALIDATING_ENTRY(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ EASYSETUP_TYPE_VALIDATING_ENTRY))
+
+#define EASYSETUP_IS_VALIDATING_ENTRY_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+ EASYSETUP_TYPE_VALIDATING_ENTRY))
+
+#define EASYSETUP_VALIDATING_ENTRY_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+ EASYSETUP_TYPE_VALIDATING_ENTRY, EasysetupValidatingEntryClass))
+
+typedef struct {
+ GtkEntry parent;
+} EasysetupValidatingEntry;
+
+typedef struct {
+ GtkEntryClass parent_class;
+} EasysetupValidatingEntryClass;
+
+GType easysetup_validating_entry_get_type (void);
+
+EasysetupValidatingEntry* easysetup_validating_entry_new (void);
+
+void easysetup_validating_entry_set_unallowed_characters (EasysetupValidatingEntry *self, GList *list);
+void easysetup_validating_entry_set_unallowed_characters_whitespace (EasysetupValidatingEntry *self);
+
+G_END_DECLS
+
+#endif /* _EASYSETUP_VALIDATING_ENTRY */