Modified webpage: now tinymail repository is in gitorious.
[modest] / src / widgets / modest-global-settings-dialog.c
index 043c7c6..59cd35c 100644 (file)
 #include "modest-tny-msg.h"
 #include "modest-platform.h"
 #ifdef MODEST_TOOLKIT_HILDON2
-#include "hildon2/modest-selector-picker.h"
 #include "modest-hildon-includes.h"
-#else
-#include "widgets/modest-combo-box.h"
-#endif
-#ifndef MODEST_TOOLKIT_GTK
-#if MODEST_HILDON_API == 0
-#include <hildon-widgets/hildon-number-editor.h>
-#else
 #include <hildon/hildon-number-editor.h>
-#endif /*MODEST_HILDON_API = 0*/
 #endif
 /* include other impl specific header files */
 
@@ -104,15 +95,9 @@ modest_global_settings_dialog_get_type (void)
                        (GInstanceInitFunc) modest_global_settings_dialog_init,
                        NULL
                };
-#ifdef MODEST_TOOLKIT_HILDON2
-               my_type = g_type_register_static (HILDON_TYPE_DIALOG,
-                                                 "ModestGlobalSettingsDialog",
-                                                 &my_info, 0);
-#else
                my_type = g_type_register_static (GTK_TYPE_DIALOG,
                                                  "ModestGlobalSettingsDialog",
                                                  &my_info, 0);
-#endif
        }
        return my_type;
 }
@@ -213,25 +198,35 @@ _modest_global_settings_dialog_get_update_interval (void)
 {
        GSList *list = NULL;
 
-       add_to_modest_pair_list (MODEST_UPDATE_INTERVAL_5_MIN, 
-                                _("mcen_va_options_updateinterval_5min"), 
+       add_to_modest_pair_list (MODEST_UPDATE_INTERVAL_5_MIN,
+                                _("mcen_va_options_updateinterval_5min"),
                                 &list);
-       add_to_modest_pair_list (MODEST_UPDATE_INTERVAL_10_MIN, 
-                                _("mcen_va_options_updateinterval_10min"), 
+       add_to_modest_pair_list (MODEST_UPDATE_INTERVAL_10_MIN,
+                                _("mcen_va_options_updateinterval_10min"),
                                 &list);
-       add_to_modest_pair_list (MODEST_UPDATE_INTERVAL_15_MIN, 
-                                _("mcen_va_options_updateinterval_15min"), 
+       add_to_modest_pair_list (MODEST_UPDATE_INTERVAL_15_MIN,
+                                _("mcen_va_options_updateinterval_15min"),
                                 &list);
-       add_to_modest_pair_list (MODEST_UPDATE_INTERVAL_30_MIN, 
-                                _("mcen_va_options_updateinterval_30min"), 
+       add_to_modest_pair_list (MODEST_UPDATE_INTERVAL_30_MIN,
+                                _("mcen_va_options_updateinterval_30min"),
                                 &list);
-       add_to_modest_pair_list (MODEST_UPDATE_INTERVAL_1_HOUR, 
-                                _("mcen_va_options_updateinterval_1h"), 
+       add_to_modest_pair_list (MODEST_UPDATE_INTERVAL_1_HOUR,
+                                _("mcen_va_options_updateinterval_1h"),
                                 &list);
-       add_to_modest_pair_list (MODEST_UPDATE_INTERVAL_2_HOUR, 
-                                _("mcen_va_options_updateinterval_2h"), 
+       add_to_modest_pair_list (MODEST_UPDATE_INTERVAL_2_HOUR,
+                                _("mcen_va_options_updateinterval_2h"),
+                                &list);
+       add_to_modest_pair_list (MODEST_UPDATE_INTERVAL_4_HOUR,
+                                _("mcen_va_options_updateinterval_4h"),
+                                &list);
+       add_to_modest_pair_list (MODEST_UPDATE_INTERVAL_8_HOUR,
+                                _("mcen_va_options_updateinterval_8h"),
+                                &list);
+       add_to_modest_pair_list (MODEST_UPDATE_INTERVAL_24_HOUR,
+                                _("mcen_va_options_updateinterval_24h"),
                                 &list);
 
+
        return (ModestPairList *) g_slist_reverse (list);
 }
 
@@ -260,44 +255,18 @@ get_current_settings (ModestGlobalSettingsDialogPrivate *priv,
        gint *id;
 
        /* Get values from UI */
-#ifdef MODEST_TOOLKIT_HILDON2
-       id = modest_selector_picker_get_active_id (MODEST_SELECTOR_PICKER (priv->connect_via));
-       state->auto_update = hildon_check_button_get_active (HILDON_CHECK_BUTTON (priv->auto_update));
-       state->default_account = modest_selector_picker_get_active_id (MODEST_SELECTOR_PICKER (priv->default_account_selector));
-#else
-       id = modest_combo_box_get_active_id (MODEST_COMBO_BOX (priv->connect_via));
-       state->auto_update = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->auto_update));
-       state->default_account = NULL;
-#endif
+       state->notifications = modest_togglable_get_active (priv->notifications);
+       state->add_to_contacts = modest_togglable_get_active (priv->add_to_contacts);
+       state->auto_update = modest_togglable_get_active (priv->auto_update);
+       id = modest_selector_get_active_id (priv->connect_via);
+       state->default_account = modest_selector_get_active_id (priv->default_account_selector);
        state->connect_via = *id;
-#ifndef MODEST_TOOLKIT_GTK
-#ifndef MODEST_TOOLKIT_HILDON2
-       state->size_limit = hildon_number_editor_get_value (HILDON_NUMBER_EDITOR (priv->size_limit));
-#endif
-#else
-       state->size_limit = gtk_spin_button_get_value (GTK_SPIN_BUTTON (priv->size_limit));
-#endif
 
-#ifdef MODEST_TOOLKIT_HILDON2
-       id = modest_selector_picker_get_active_id (MODEST_SELECTOR_PICKER (priv->update_interval));
-#else
-       id = modest_combo_box_get_active_id (MODEST_COMBO_BOX (priv->update_interval));
-#endif
+       id = modest_selector_get_active_id (priv->update_interval);
        state->update_interval = *id;
-#ifdef MODEST_TOOLKIT_HILDON2
-       id = modest_selector_picker_get_active_id (MODEST_SELECTOR_PICKER (priv->msg_format));
+       id = modest_selector_get_active_id (priv->msg_format);
        state->play_sound = priv->initial_state.play_sound;
-#else
-       state->play_sound = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->play_sound));
-#ifndef MODEST_TOOLKIT_GTK
-       id = modest_combo_box_get_active_id (MODEST_COMBO_BOX (priv->msg_format));
-#endif
-#endif
-#ifdef MODEST_TOOLKIT_GTK
-       state->prefer_formatted_text = FALSE;
-#else
        state->prefer_formatted_text = (*id == MODEST_FILE_FORMAT_FORMATTED_TEXT) ? TRUE : FALSE;
-#endif
 }
 
 static gboolean
@@ -315,14 +284,16 @@ modest_global_settings_dialog_save_settings_default (ModestGlobalSettingsDialog
        get_current_settings (priv, &current_state);
 
        /* Save configuration */
+       modest_conf_set_bool (conf, MODEST_CONF_NOTIFICATIONS, current_state.notifications, &error);
+       RETURN_FALSE_ON_ERROR(error);
+       modest_conf_set_bool (conf, MODEST_CONF_AUTO_ADD_TO_CONTACTS, current_state.add_to_contacts, &error);
+       RETURN_FALSE_ON_ERROR(error);
        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_bool (conf, MODEST_CONF_PREFER_FORMATTED_TEXT, current_state.prefer_formatted_text, NULL);
@@ -338,7 +309,7 @@ modest_global_settings_dialog_save_settings_default (ModestGlobalSettingsDialog
        if (priv->initial_state.auto_update != current_state.auto_update ||
            priv->initial_state.connect_via != current_state.connect_via ||
            priv->initial_state.update_interval != current_state.update_interval) {
-               
+
                TnyAccountStore *account_store;
                TnyDevice *device;
                
@@ -384,9 +355,10 @@ settings_changed (ModestGlobalSettingsState initial_state,
                  ModestGlobalSettingsState current_state)
 {
        if (initial_state.auto_update != current_state.auto_update ||
+           initial_state.notifications != current_state.notifications ||
+           initial_state.add_to_contacts != current_state.add_to_contacts ||
            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.prefer_formatted_text != current_state.prefer_formatted_text ||
            (current_state.default_account &&