#ifdef MODEST_HILDON_VERSION_0
#include <hildon-widgets/hildon-caption.h>
#include <hildon-widgets/hildon-number-editor.h>
+#include <hildon-widgets/hildon-banner.h>
#else
#include <hildon/hildon-caption.h>
#include <hildon/hildon-number-editor.h>
+#include <hildon/hildon-banner.h>
#endif /*MODEST_HILDON_VERSION_0*/
#include <glib/gi18n.h>
#include "maemo/modest-maemo-global-settings-dialog.h"
#include "widgets/modest-ui-constants.h"
-
-/* include other impl specific header files */
+#define MSG_SIZE_MAX_VAL 5000
+#define MSG_SIZE_DEF_VAL 1000
+#define MSG_SIZE_MIN_VAL 1
/* 'private'/'protected' functions */
static void modest_maemo_global_settings_dialog_class_init (ModestMaemoGlobalSettingsDialogClass *klass);
static GtkWidget* create_updating_page (ModestMaemoGlobalSettingsDialog *self);
static GtkWidget* create_composing_page (ModestMaemoGlobalSettingsDialog *self);
+static gboolean on_range_error (HildonNumberEditor *editor,
+ HildonNumberEditorErrorType type,
+ gpointer user_data);
+
typedef struct _ModestMaemoGlobalSettingsDialogPrivate ModestMaemoGlobalSettingsDialogPrivate;
struct _ModestMaemoGlobalSettingsDialogPrivate {
};
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (self)->vbox), ppriv->notebook);
gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (self)->vbox), MODEST_MARGIN_HALF);
+
+ /* Load current config */
+ _modest_global_settings_dialog_load_conf (ppriv);
gtk_widget_show_all (ppriv->notebook);
}
size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
/* Size limit */
- ppriv->size_limit = hildon_number_editor_new (1, 5000);;
- hildon_number_editor_set_value (HILDON_NUMBER_EDITOR (ppriv->size_limit), 1000);;
+ ppriv->size_limit = hildon_number_editor_new (MSG_SIZE_MIN_VAL, MSG_SIZE_MAX_VAL);;
+ hildon_number_editor_set_value (HILDON_NUMBER_EDITOR (ppriv->size_limit), MSG_SIZE_DEF_VAL);;
+ g_signal_connect (ppriv->size_limit, "range_error", G_CALLBACK (on_range_error), self);
caption = hildon_caption_new (size_group,
_("mcen_fi_advsetup_sizelimit"),
ppriv->size_limit,
/* Reply */
ppriv->include_reply = gtk_check_button_new ();
caption = hildon_caption_new (size_group,
- _("mcen_fi_options_playsound"),
+ _("mcen_va_options_include_original_inreply"),
ppriv->include_reply,
NULL,
HILDON_CAPTION_MANDATORY);
return vbox;
}
+
+static gboolean
+on_range_error (HildonNumberEditor *editor,
+ HildonNumberEditorErrorType type,
+ gpointer user_data)
+{
+ gchar *msg;
+ gint new_val;
+
+ switch (type) {
+ case MAXIMUM_VALUE_EXCEED:
+ msg = g_strdup_printf (_("ckct_ib_maximum_value"), MSG_SIZE_MAX_VAL);
+ new_val = MSG_SIZE_MAX_VAL;
+ break;
+ case MINIMUM_VALUE_EXCEED:
+ msg = g_strdup_printf (_("ckct_ib_minimum_value"), MSG_SIZE_MIN_VAL);
+ new_val = MSG_SIZE_MIN_VAL;
+ break;
+ case ERRONEOUS_VALUE:
+ msg = g_strdup_printf (_("ckct_ib_set_a_value_within_range"),
+ MSG_SIZE_MIN_VAL,
+ MSG_SIZE_MAX_VAL);
+ /* FIXME: use the previous */
+ new_val = MSG_SIZE_DEF_VAL;
+ break;
+ default:
+ g_return_val_if_reached (FALSE);
+ }
+
+ /* Restore value */
+ hildon_number_editor_set_value (editor, new_val);
+
+ /* Show error */
+ hildon_banner_show_information (GTK_WIDGET (user_data), NULL, msg);
+
+ /* Free */
+ g_free (msg);
+
+ return TRUE;
+}
modest_combo_box_get_active_id (ModestComboBox *self)
{
GValue val = {0,};
- gpointer retval;
g_return_val_if_fail (self, NULL);
/* Do not unset the GValue */
get_active (self, &val, COLUMN_ID);
- retval = g_value_peek_pointer (&val);
- return retval;
+ return g_value_get_pointer (&val);
}
do {
gpointer row_id;
gtk_tree_model_get (model, &iter, COLUMN_ID, &row_id, -1);
- if ((priv->id_equal_func)(id, row_id) == 0) {
+ if ((priv->id_equal_func)(id, row_id)) {
gtk_combo_box_set_active_iter (GTK_COMBO_BOX(self), &iter);
found = TRUE;
}
const gchar*
modest_combo_box_get_active_display_name (ModestComboBox *self)
{
- GValue val = {0,};
- gpointer retval;
+ const GValue val = {0,};
+ const gchar *retval;
g_return_val_if_fail (self, NULL);
/* Do not unset the GValue */
- get_active (self, &val, COLUMN_DISPLAY_NAME);
- retval = g_value_peek_pointer (&val);
+ get_active (self, (GValue *)&val, COLUMN_DISPLAY_NAME);
+ retval = g_value_get_string (&val);
- return (gchar*) retval;
+ return retval;
}
#include <gtk/gtknotebook.h>
#include <gtk/gtkstock.h>
#include <gtk/gtklabel.h>
-#include "modest-global-settings-dialog.h"
+#include <gtk/gtktogglebutton.h>
+#include "widgets/modest-global-settings-dialog.h"
+#include "widgets/modest-global-settings-dialog-priv.h"
#include "modest-defs.h"
+#include "modest-conf.h"
+#include "modest-runtime.h"
#include "modest-ui-constants.h"
+#include "modest-tny-msg.h"
#include "widgets/modest-combo-box.h"
+#ifdef MODEST_PLATFORM_MAEMO
+#ifdef MODEST_HILDON_VERSION_0
+#include <hildon-widgets/hildon-number-editor.h>
+#else
+#include <hildon/hildon-number-editor.h>
+#endif /*MODEST_HILDON_VERSION_0*/
+#endif
/* include other impl specific header files */
/* 'private'/'protected' functions */
static void modest_global_settings_dialog_init (ModestGlobalSettingsDialog *obj);
static void modest_global_settings_dialog_finalize (GObject *obj);
+static void on_response (GtkDialog *dialog,
+ gint arg1,
+ gpointer user_data);
+
/* list my signals */
enum {
/* MY_SIGNAL_1, */
gtk_dialog_add_button (GTK_DIALOG (self), GTK_STOCK_OK, GTK_RESPONSE_OK);
gtk_dialog_add_button (GTK_DIALOG (self), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
-/* /\* Connect to the dialog's response signal: *\/ */
-/* /\* We use connect-before */
-/* * so we can stop the signal emission, */
-/* * to stop the default signal handler from closing the dialog. */
-/* *\/ */
-/* g_signal_connect (G_OBJECT (self), "response", */
-/* G_CALLBACK (on_response), self); */
+ /* Connect to the dialog's response signal: */
+ g_signal_connect (G_OBJECT (self), "response",
+ G_CALLBACK (on_response), self);
/* Set title */
gtk_window_set_title (GTK_WINDOW (self), _("mcen_ti_options"));
static void
add_to_modest_pair_list (const gint num, const gchar *str, GSList **list)
{
- guint *number;
+ gint *number;
ModestPair *pair;
- number = g_malloc0 (sizeof (guint));
+ number = g_malloc0 (sizeof (gint));
*number = num;
- pair = modest_pair_new (number, g_strdup (str), TRUE);
+ pair = modest_pair_new (number, g_strdup (str), FALSE);
*list = g_slist_prepend (*list, pair);
}
return (ModestPairList *) g_slist_reverse (list);
}
+
+void
+_modest_global_settings_dialog_load_conf (ModestGlobalSettingsDialogPrivate *priv)
+{
+ ModestConf *conf;
+ gboolean checked;
+ gint combo_id, value;
+ GError *error = NULL;
+
+ conf = modest_runtime_get_conf ();
+
+ /* Autoupdate */
+ checked = modest_conf_get_bool (conf, MODEST_CONF_AUTO_UPDATE, &error);
+ if (error) {
+ g_clear_error (&error);
+ error = NULL;
+ checked = FALSE;
+ }
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->auto_update), checked);
+
+ /* Connected by */
+ combo_id = modest_conf_get_int (conf, MODEST_CONF_UPDATE_WHEN_CONNECTED_BY, &error);
+ if (error) {
+ g_error_free (error);
+ error = NULL;
+ combo_id = MODEST_CONNECTED_VIA_WLAN;
+ }
+ modest_combo_box_set_active_id (MODEST_COMBO_BOX (priv->connect_via),
+ (gpointer) &combo_id);
+
+ /* Update interval */
+ combo_id = modest_conf_get_int (conf, MODEST_CONF_UPDATE_INTERVAL, &error);
+ if (error) {
+ g_error_free (error);
+ error = NULL;
+ combo_id = MODEST_UPDATE_INTERVAL_15_MIN;
+ }
+ modest_combo_box_set_active_id (MODEST_COMBO_BOX (priv->update_interval),
+ (gpointer) &combo_id);
+
+ /* Size limit */
+ value = modest_conf_get_int (conf, MODEST_CONF_MSG_SIZE_LIMIT, &error);
+ if (error) {
+ g_error_free (error);
+ error = NULL;
+ value = 1000;
+ }
+ /* It's better to do this in the subclasses, but it's just one
+ line, so we'll leave it here for the moment */
+#ifdef MODEST_PLATFORM_MAEMO
+ hildon_number_editor_set_value (HILDON_NUMBER_EDITOR (priv->size_limit), value);
+#else
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->size_limit, value);
+#endif
+
+ /* TODO Fix with the value */
+
+ /* Play sound */
+ checked = modest_conf_get_bool (conf, MODEST_CONF_PLAY_SOUND_MSG_ARRIVE, &error);
+ if (error) {
+ g_error_free (error);
+ error = NULL;
+ checked = FALSE;
+ }
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->play_sound), checked);
+
+ /* Msg format */
+ combo_id = modest_conf_get_int (conf, MODEST_CONF_PREFER_FORMATTED_TEXT, &error);
+ if (error) {
+ g_error_free (error);
+ error = NULL;
+ combo_id = MODEST_FILE_FORMAT_FORMATTED_TEXT;
+ }
+ modest_combo_box_set_active_id (MODEST_COMBO_BOX (priv->msg_format),
+ (gpointer) &combo_id);
+
+ /* Include reply */
+ value = modest_conf_get_int (conf, MODEST_CONF_REPLY_TYPE, &error);
+ if (error) {
+ g_error_free (error);
+ error = NULL;
+ value = MODEST_TNY_MSG_REPLY_TYPE_QUOTE;
+ }
+ if (value == MODEST_TNY_MSG_REPLY_TYPE_QUOTE)
+ checked = TRUE;
+ else
+ checked = FALSE;
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->include_reply), checked);
+}
+
+void
+_modest_global_settings_dialog_save_conf (ModestGlobalSettingsDialogPrivate *priv)
+{
+ ModestConf *conf;
+ gboolean checked;
+ gint *combo_id, value;
+
+ conf = modest_runtime_get_conf ();
+
+ /* Autoupdate */
+ checked = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->auto_update));
+ modest_conf_set_bool (conf, MODEST_CONF_AUTO_UPDATE, checked, NULL);
+
+ /* Connected by */
+ combo_id = modest_combo_box_get_active_id (MODEST_COMBO_BOX (priv->connect_via));
+ modest_conf_set_int (conf, MODEST_CONF_UPDATE_WHEN_CONNECTED_BY, *combo_id, NULL);
+
+ /* Update interval */
+ combo_id = modest_combo_box_get_active_id (MODEST_COMBO_BOX (priv->update_interval));
+ modest_conf_set_int (conf, MODEST_CONF_UPDATE_INTERVAL, *combo_id, NULL);
+
+ /* Size limit */
+ /* It's better to do this in the subclasses, but it's just one
+ line, so we'll leave it here for the moment */
+#ifdef MODEST_PLATFORM_MAEMO
+ value = hildon_number_editor_get_value (HILDON_NUMBER_EDITOR (priv->size_limit));
+#else
+ value = gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->size_limit);
+#endif
+ modest_conf_set_int (conf, MODEST_CONF_MSG_SIZE_LIMIT, value, NULL);
+
+ /* Play sound */
+ checked = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->play_sound));
+ modest_conf_set_bool (conf, MODEST_CONF_PLAY_SOUND_MSG_ARRIVE, checked, NULL);
+
+ /* Msg format */
+ combo_id = modest_combo_box_get_active_id (MODEST_COMBO_BOX (priv->msg_format));
+ modest_conf_set_int (conf, MODEST_CONF_PREFER_FORMATTED_TEXT, *combo_id, NULL);
+
+ /* Include reply */
+ checked = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->include_reply));
+ modest_conf_set_int (conf, MODEST_CONF_REPLY_TYPE,
+ (checked) ? MODEST_TNY_MSG_REPLY_TYPE_QUOTE :
+ MODEST_TNY_MSG_REPLY_TYPE_CITE, NULL);
+}
+
+static void
+on_response (GtkDialog *dialog,
+ gint arg1,
+ gpointer user_data)
+{
+ ModestGlobalSettingsDialogPrivate *priv;
+
+ priv = MODEST_GLOBAL_SETTINGS_DIALOG_GET_PRIVATE (user_data);
+
+ if (arg1 == GTK_RESPONSE_OK)
+ _modest_global_settings_dialog_save_conf (priv);
+}