LAST_SIGNAL
};
-static GtkWidget* create_updating_page (ModestMaemoGlobalSettingsDialog *self);
-static GtkWidget* create_composing_page (ModestMaemoGlobalSettingsDialog *self);
+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);
+static gboolean on_range_error (HildonNumberEditor *editor,
+ HildonNumberEditorErrorType type,
+ gpointer user_data);
+
+static void on_auto_update_toggled (GtkToggleButton *togglebutton,
+ gpointer user_data);
typedef struct _ModestMaemoGlobalSettingsDialogPrivate ModestMaemoGlobalSettingsDialogPrivate;
struct _ModestMaemoGlobalSettingsDialogPrivate {
modest_maemo_global_settings_dialog_init (ModestMaemoGlobalSettingsDialog *self)
{
ModestGlobalSettingsDialogPrivate *ppriv;
-/* GdkGeometry *geometry; */
ppriv = MODEST_GLOBAL_SETTINGS_DIALOG_GET_PRIVATE (self);
NULL,
HILDON_CAPTION_MANDATORY);
gtk_box_pack_start (GTK_BOX (vbox_update), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
+ g_signal_connect (ppriv->auto_update, "toggled", G_CALLBACK (on_auto_update_toggled), self);
/* Connected via */
list = _modest_global_settings_dialog_get_connected_via ();
return vbox;
}
+static void
+on_auto_update_toggled (GtkToggleButton *togglebutton,
+ gpointer user_data)
+{
+ ModestGlobalSettingsDialogPrivate *ppriv;
+ GtkWidget *caption;
+
+ ppriv = MODEST_GLOBAL_SETTINGS_DIALOG_GET_PRIVATE (user_data);
+ caption = gtk_widget_get_ancestor (ppriv->connect_via, HILDON_TYPE_CAPTION);
+
+ if (gtk_toggle_button_get_active (togglebutton))
+ gtk_widget_set_sensitive (caption, TRUE);
+ else
+ gtk_widget_set_sensitive (caption, FALSE);
+}
+
static gboolean
on_range_error (HildonNumberEditor *editor,
HildonNumberEditorErrorType type,
#include "modest-runtime.h"
#include "modest-ui-constants.h"
#include "modest-tny-msg.h"
+#include "modest-platform.h"
#include "widgets/modest-combo-box.h"
#ifdef MODEST_PLATFORM_MAEMO
#ifdef MODEST_HILDON_VERSION_0
#endif
/* include other impl specific header files */
+#define RETURN_FALSE_ON_ERROR(error) if (error) { g_clear_error (&error); return FALSE; }
+
/* 'private'/'protected' functions */
static void modest_global_settings_dialog_class_init (ModestGlobalSettingsDialogClass *klass);
static void modest_global_settings_dialog_init (ModestGlobalSettingsDialog *obj);
static void on_response (GtkDialog *dialog,
gint arg1,
gpointer user_data);
+static void get_current_settings (ModestGlobalSettingsDialogPrivate *priv,
+ ModestGlobalSettingsState *state);
/* list my signals */
enum {
priv = MODEST_GLOBAL_SETTINGS_DIALOG_GET_PRIVATE (self);
priv->notebook = gtk_notebook_new ();
-
+ priv->changed = FALSE;
+
/* Add the buttons: */
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: */
- g_signal_connect (G_OBJECT (self), "response",
- G_CALLBACK (on_response), self);
+ g_signal_connect (G_OBJECT (self), "response", G_CALLBACK (on_response), self);
/* Set title */
gtk_window_set_title (GTK_WINDOW (self), _("mcen_ti_options"));
checked = FALSE;
}
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->auto_update), checked);
+ priv->initial_state.auto_update = checked;
/* Connected by */
combo_id = modest_conf_get_int (conf, MODEST_CONF_UPDATE_WHEN_CONNECTED_BY, &error);
}
modest_combo_box_set_active_id (MODEST_COMBO_BOX (priv->connect_via),
(gpointer) &combo_id);
+ priv->initial_state.connect_via = combo_id;
+
+ /* Emit toggled to update the visibility of connect_by caption */
+ gtk_toggle_button_toggled (GTK_TOGGLE_BUTTON (priv->auto_update));
/* Update interval */
combo_id = modest_conf_get_int (conf, MODEST_CONF_UPDATE_INTERVAL, &error);
}
modest_combo_box_set_active_id (MODEST_COMBO_BOX (priv->update_interval),
(gpointer) &combo_id);
+ priv->initial_state.update_interval = combo_id;
/* Size limit */
value = modest_conf_get_int (conf, MODEST_CONF_MSG_SIZE_LIMIT, &error);
#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);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->size_limit, value));
#endif
-
- /* TODO Fix with the value */
+ priv->initial_state.size_limit = value;
/* Play sound */
checked = modest_conf_get_bool (conf, MODEST_CONF_PLAY_SOUND_MSG_ARRIVE, &error);
checked = FALSE;
}
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->play_sound), checked);
+ priv->initial_state.play_sound = checked;
/* Msg format */
combo_id = modest_conf_get_int (conf, MODEST_CONF_PREFER_FORMATTED_TEXT, &error);
}
modest_combo_box_set_active_id (MODEST_COMBO_BOX (priv->msg_format),
(gpointer) &combo_id);
+ priv->initial_state.msg_format = combo_id;
/* Include reply */
value = modest_conf_get_int (conf, MODEST_CONF_REPLY_TYPE, &error);
else
checked = FALSE;
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->include_reply), checked);
+ priv->initial_state.include_reply = checked;
}
-void
-_modest_global_settings_dialog_save_conf (ModestGlobalSettingsDialogPrivate *priv)
+static void
+get_current_settings (ModestGlobalSettingsDialogPrivate *priv,
+ ModestGlobalSettingsState *state)
{
- 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);
+ gint *id;
- /* 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 */
+ /* Get values from UI */
+ state->auto_update = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->auto_update));
+ id = modest_combo_box_get_active_id (MODEST_COMBO_BOX (priv->connect_via));
+ state->connect_via = *id;
#ifdef MODEST_PLATFORM_MAEMO
- value = hildon_number_editor_get_value (HILDON_NUMBER_EDITOR (priv->size_limit));
+ state->size_limit = hildon_number_editor_get_value (HILDON_NUMBER_EDITOR (priv->size_limit));
#else
- value = gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->size_limit);
+ state->size_limit = gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->size_limit));
#endif
- modest_conf_set_int (conf, MODEST_CONF_MSG_SIZE_LIMIT, value, NULL);
+ id = modest_combo_box_get_active_id (MODEST_COMBO_BOX (priv->update_interval));
+ state->update_interval = *id;
+ state->play_sound = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->play_sound));
+ id = modest_combo_box_get_active_id (MODEST_COMBO_BOX (priv->msg_format));
+ state->msg_format = *id;
+ state->include_reply = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->include_reply));
+}
- /* 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);
+gboolean
+_modest_global_settings_dialog_save_conf (ModestGlobalSettingsDialogPrivate *priv)
+{
+ ModestConf *conf;
+ ModestGlobalSettingsState current_state;
+ GError *error = 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);
+ conf = modest_runtime_get_conf ();
- /* 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 :
+ get_current_settings (priv, ¤t_state);
+
+ /* Save configuration */
+ modest_conf_set_bool (conf, MODEST_CONF_AUTO_UPDATE, current_state.auto_update, &error);
+ RETURN_FALSE_ON_ERROR(error);
+ modest_conf_set_int (conf, MODEST_CONF_UPDATE_WHEN_CONNECTED_BY, current_state.connect_via, NULL);
+ RETURN_FALSE_ON_ERROR(error);
+ modest_conf_set_int (conf, MODEST_CONF_UPDATE_INTERVAL, current_state.update_interval, NULL);
+ RETURN_FALSE_ON_ERROR(error);
+ modest_conf_set_int (conf, MODEST_CONF_MSG_SIZE_LIMIT, current_state.size_limit, NULL);
+ RETURN_FALSE_ON_ERROR(error);
+ modest_conf_set_bool (conf, MODEST_CONF_PLAY_SOUND_MSG_ARRIVE, current_state.play_sound, NULL);
+ RETURN_FALSE_ON_ERROR(error);
+ modest_conf_set_int (conf, MODEST_CONF_PREFER_FORMATTED_TEXT, current_state.msg_format, NULL);
+ RETURN_FALSE_ON_ERROR(error);
+ modest_conf_set_int (conf, MODEST_CONF_REPLY_TYPE,
+ (current_state.include_reply) ? MODEST_TNY_MSG_REPLY_TYPE_QUOTE :
MODEST_TNY_MSG_REPLY_TYPE_CITE, NULL);
+ RETURN_FALSE_ON_ERROR(error);
+
+ return TRUE;
+}
+
+static gboolean
+settings_changed (ModestGlobalSettingsState initial_state,
+ ModestGlobalSettingsState current_state)
+{
+ if (initial_state.auto_update != current_state.auto_update ||
+ initial_state.connect_via != current_state.connect_via ||
+ initial_state.update_interval != current_state.update_interval ||
+ initial_state.size_limit != current_state.size_limit ||
+ initial_state.play_sound != current_state.play_sound ||
+ initial_state.msg_format != current_state.msg_format ||
+ initial_state.include_reply != current_state.include_reply)
+ return TRUE;
+ else
+ return FALSE;
}
static void
gpointer user_data)
{
ModestGlobalSettingsDialogPrivate *priv;
+ ModestGlobalSettingsState current_state;
+ gboolean changed;
priv = MODEST_GLOBAL_SETTINGS_DIALOG_GET_PRIVATE (user_data);
- if (arg1 == GTK_RESPONSE_OK)
- _modest_global_settings_dialog_save_conf (priv);
+ get_current_settings (priv, ¤t_state);
+ changed = settings_changed (priv->initial_state, current_state);
+
+ if (arg1 == GTK_RESPONSE_OK) {
+ if (changed) {
+ gboolean saved;
+
+ saved = _modest_global_settings_dialog_save_conf (priv);
+ if (saved)
+ modest_platform_run_information_dialog (GTK_WINDOW (user_data),
+ _("mcen_ib_advsetup_settings_saved"));
+ else
+ modest_platform_run_information_dialog (GTK_WINDOW (user_data),
+ _("mail_ib_setting_failed"));
+ }
+ } else {
+ if (changed) {
+ gint response;
+ response = modest_platform_run_confirmation_dialog (GTK_WINDOW (user_data),
+ _("imum_nc_wizard_confirm_lose_changes"));
+ /* Do not close if the user Cancels */
+ if (response == GTK_RESPONSE_CANCEL)
+ g_signal_stop_emission_by_name (dialog, "response");
+ }
+ }
}