Added two new options to global settings dialog
authorSergio Villar Senín <svillar@igalia.com>
Thu, 26 Nov 2009 10:35:11 +0000 (11:35 +0100)
committerSergio Villar Senín <svillar@igalia.com>
Thu, 26 Nov 2009 15:59:44 +0000 (16:59 +0100)
Added "Incoming notifications" and "Automatically add to contacts" options to the global settings dialog

src/hildon2/modest-hildon2-global-settings-dialog.c
src/modest-defs.h
src/modest-init.c
src/widgets/modest-global-settings-dialog-priv.h
src/widgets/modest-global-settings-dialog.c

index 2d7771f..2215133 100644 (file)
@@ -263,6 +263,18 @@ create_updating_page (ModestHildon2GlobalSettingsDialog *self)
        }
 
 
+       /* Incoming notifications */
+       ppriv->notifications = hildon_check_button_new (MODEST_EDITABLE_SIZE);
+       gtk_button_set_label (GTK_BUTTON (ppriv->notifications), _("mcen_fi_options_incoming_notifications"));
+       gtk_button_set_alignment (GTK_BUTTON (ppriv->notifications), 0.0, 0.5);
+       gtk_box_pack_start (GTK_BOX (vbox), ppriv->notifications, FALSE, FALSE, 0);
+
+       /* Automatic add to contacts */
+       ppriv->add_to_contacts = hildon_check_button_new (MODEST_EDITABLE_SIZE);
+       gtk_button_set_label (GTK_BUTTON (ppriv->add_to_contacts), _("mcen_fi_options_automatic_add"));
+       gtk_button_set_alignment (GTK_BUTTON (ppriv->add_to_contacts), 0.0, 0.5);
+       gtk_box_pack_start (GTK_BOX (vbox), ppriv->add_to_contacts, FALSE, FALSE, 0);
+
        /* Separator label */
        separator = gtk_label_new (_("mcen_ti_updating"));
        gtk_label_set_justify ((GtkLabel *) separator, GTK_JUSTIFY_CENTER);
@@ -445,6 +457,26 @@ modest_hildon2_global_settings_dialog_load_settings (ModestGlobalSettingsDialog
        ppriv = MODEST_GLOBAL_SETTINGS_DIALOG_GET_PRIVATE (self);
        conf = modest_runtime_get_conf ();
 
+       /* Incoming notifications */
+       checked = modest_conf_get_bool (conf, MODEST_CONF_NOTIFICATIONS, &error);
+       if (error) {
+               g_clear_error (&error);
+               error = NULL;
+               checked = FALSE;
+       }
+       hildon_check_button_set_active (HILDON_CHECK_BUTTON (ppriv->notifications), checked);
+       ppriv->initial_state.notifications = checked;
+
+       /* Add to contacts */
+       checked = modest_conf_get_bool (conf, MODEST_CONF_AUTO_ADD_TO_CONTACTS, &error);
+       if (error) {
+               g_clear_error (&error);
+               error = NULL;
+               checked = FALSE;
+       }
+       hildon_check_button_set_active (HILDON_CHECK_BUTTON (ppriv->add_to_contacts), checked);
+       ppriv->initial_state.add_to_contacts = checked;
+
        /* Autoupdate */
        checked = modest_conf_get_bool (conf, MODEST_CONF_AUTO_UPDATE, &error);
        if (error) {
index 71bd007..4198225 100644 (file)
@@ -240,6 +240,8 @@ const gchar *modest_defs_namespace (const gchar *string);
 #define MODEST_CONF_PREFER_FORMATTED_TEXT (modest_defs_namespace ("/prefer_formatted_text")) /* bool */
 #define MODEST_CONF_REPLY_TYPE           (modest_defs_namespace ("/reply_type"))        /*  int  */
 #define MODEST_CONF_FORWARD_TYPE         (modest_defs_namespace  ("/forward_type"))      /*  int  */
+#define MODEST_CONF_NOTIFICATIONS (modest_defs_namespace ("/notifications")) /* bool */
+#define MODEST_CONF_AUTO_ADD_TO_CONTACTS (modest_defs_namespace ("/auto_add_to_contacs")) /* bool */
 
 /* hidden global settings */
 #define MODEST_CONF_FETCH_HTML_EXTERNAL_IMAGES (modest_defs_namespace ("/fetch_external_images")) /* bool */
index 88d9459..f911ea7 100644 (file)
@@ -756,6 +756,12 @@ init_default_settings (ModestConf *conf)
        if (!modest_conf_key_exists (conf, MODEST_CONF_AUTO_UPDATE, NULL))
                modest_conf_set_bool (conf, MODEST_CONF_AUTO_UPDATE, TRUE, NULL);
 
+       if (!modest_conf_key_exists (conf, MODEST_CONF_NOTIFICATIONS, NULL))
+               modest_conf_set_bool (conf, MODEST_CONF_NOTIFICATIONS, TRUE, NULL);
+
+       if (!modest_conf_key_exists (conf, MODEST_CONF_AUTO_ADD_TO_CONTACTS, NULL))
+               modest_conf_set_bool (conf, MODEST_CONF_AUTO_ADD_TO_CONTACTS, TRUE, NULL);
+
        if (!modest_conf_key_exists (conf, MODEST_CONF_UPDATE_WHEN_CONNECTED_BY, NULL))
                modest_conf_set_int (conf, MODEST_CONF_UPDATE_WHEN_CONNECTED_BY, MODEST_CONNECTED_VIA_WLAN_OR_WIMAX, NULL);
 
index c55472d..e048034 100644 (file)
@@ -40,9 +40,11 @@ typedef struct _ModestGlobalSettingsState {
        gint     connect_via;
        gint     update_interval;
        gint     size_limit;
-       gchar *default_account;
+       gchar   *default_account;
        gboolean play_sound;
        gboolean prefer_formatted_text;
+       gboolean notifications;
+       gboolean add_to_contacts;
 } ModestGlobalSettingsState;
 
 typedef struct _ModestGlobalSettingsDialogPrivate ModestGlobalSettingsDialogPrivate;
@@ -68,6 +70,9 @@ struct _ModestGlobalSettingsDialogPrivate {
        ModestPairList *msg_format_list;
        GtkWidget *msg_format;
 
+       GtkWidget *notifications;
+       GtkWidget *add_to_contacts;
+
        ModestGlobalSettingsState initial_state;
 };
 
index be57192..995606b 100644 (file)
@@ -247,6 +247,8 @@ get_current_settings (ModestGlobalSettingsDialogPrivate *priv,
        gint *id;
 
        /* Get values from UI */
+       state->notifications = modest_togglable_get_active (HILDON_CHECK_BUTTON (priv->notifications));
+       state->add_to_contacts = modest_togglabale_get_active (HILDON_CHECK_BUTTON (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);
@@ -275,6 +277,10 @@ 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);
@@ -298,7 +304,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;
                
@@ -344,6 +350,8 @@ 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 ||