Port to master of commit aa843e2.. from Aleksander Chumakov:
[modest] / src / widgets / modest-default-global-settings-dialog.c
1 /* Copyright (c) 2006, 2009, Nokia Corporation
2  * All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  *   notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  *   notice, this list of conditions and the following disclaimer in the
12  *   documentation and/or other materials provided with the distribution.
13  * * Neither the name of the Nokia Corporation nor the names of its
14  *   contributors may be used to endorse or promote products derived from
15  *   this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
18  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
20  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
21  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  */
29
30 #ifdef HAVE_CONFIG_H
31 #include <config.h>
32 #endif /*HAVE_CONFIG_H*/
33
34 #include <modest-scrollable.h>
35
36 #include <glib/gi18n.h>
37 #include <string.h>
38 #include <gtk/gtkbox.h>
39 #include <gtk/gtkvbox.h>
40 #include <gtk/gtknotebook.h>
41 #include <gtk/gtklabel.h>
42 #include <gtk/gtkcheckbutton.h>
43 #include "modest-runtime.h"
44 #include <modest-global-settings-dialog-priv.h>
45 #include <modest-default-global-settings-dialog.h>
46 #include <modest-ui-constants.h>
47 #include "modest-text-utils.h"
48 #include "modest-defs.h"
49 #include <tny-account-store.h>
50 #include <modest-account-mgr-helpers.h>
51 #include <modest-toolkit-utils.h>
52
53
54 #define MSG_SIZE_MAX_VAL 5000
55 #define MSG_SIZE_DEF_VAL 1000
56 #define MSG_SIZE_MIN_VAL 1
57
58 #define DEFAULT_FOCUS_WIDGET "default-focus-widget"
59
60 /* 'private'/'protected' functions */
61 static void modest_default_global_settings_dialog_class_init (ModestDefaultGlobalSettingsDialogClass *klass);
62 static void modest_default_global_settings_dialog_init       (ModestDefaultGlobalSettingsDialog *obj);
63 static void modest_default_global_settings_dialog_finalize   (GObject *obj);
64
65 static ModestConnectedVia current_connection (void);
66
67 static GtkWidget* create_updating_page   (ModestDefaultGlobalSettingsDialog *self);
68
69 static void       on_auto_update_clicked (GtkButton *button,
70                                           gpointer user_data);
71 static void       update_sensitive       (ModestGlobalSettingsDialog *dialog);
72 static ModestPairList * get_accounts_list (void);
73
74 static void modest_default_global_settings_dialog_load_settings (ModestGlobalSettingsDialog *self);
75
76 typedef struct _ModestDefaultGlobalSettingsDialogPrivate ModestDefaultGlobalSettingsDialogPrivate;
77 struct _ModestDefaultGlobalSettingsDialogPrivate {
78         ModestPairList *connect_via_list;
79 };
80 #define MODEST_DEFAULT_GLOBAL_SETTINGS_DIALOG_GET_PRIVATE(o)      (G_TYPE_INSTANCE_GET_PRIVATE((o), \
81                                                            MODEST_TYPE_DEFAULT_GLOBAL_SETTINGS_DIALOG, \
82                                                            ModestDefaultGlobalSettingsDialogPrivate))
83 /* globals */
84 static GtkDialogClass *parent_class = NULL;
85
86 GType
87 modest_default_global_settings_dialog_get_type (void)
88 {
89         static GType my_type = 0;
90         if (!my_type) {
91                 static const GTypeInfo my_info = {
92                         sizeof(ModestDefaultGlobalSettingsDialogClass),
93                         NULL,           /* base init */
94                         NULL,           /* base finalize */
95                         (GClassInitFunc) modest_default_global_settings_dialog_class_init,
96                         NULL,           /* class finalize */
97                         NULL,           /* class data */
98                         sizeof(ModestDefaultGlobalSettingsDialog),
99                         1,              /* n_preallocs */
100                         (GInstanceInitFunc) modest_default_global_settings_dialog_init,
101                         NULL
102                 };
103                 my_type = g_type_register_static (MODEST_TYPE_GLOBAL_SETTINGS_DIALOG,
104                                                   "ModestDefaultGlobalSettingsDialog",
105                                                   &my_info, 0);
106         }
107         return my_type;
108 }
109
110 static void
111 modest_default_global_settings_dialog_class_init (ModestDefaultGlobalSettingsDialogClass *klass)
112 {
113         GObjectClass *gobject_class;
114         gobject_class = (GObjectClass*) klass;
115
116         parent_class            = g_type_class_peek_parent (klass);
117         gobject_class->finalize = modest_default_global_settings_dialog_finalize;
118
119         g_type_class_add_private (gobject_class, sizeof(ModestDefaultGlobalSettingsDialogPrivate));
120
121         MODEST_GLOBAL_SETTINGS_DIALOG_CLASS (klass)->current_connection_func = current_connection;
122 }
123
124 typedef struct {
125         ModestDefaultGlobalSettingsDialog *dia;
126         GtkWidget *focus_widget;
127 } SwitchPageHelper;
128
129
130 static void
131 modest_default_global_settings_dialog_init (ModestDefaultGlobalSettingsDialog *self)
132 {
133         ModestDefaultGlobalSettingsDialogPrivate *priv;
134         ModestGlobalSettingsDialogPrivate *ppriv;
135         GtkWidget *align;
136         GtkWidget *top_vbox;
137
138         priv  = MODEST_DEFAULT_GLOBAL_SETTINGS_DIALOG_GET_PRIVATE (self);
139         ppriv = MODEST_GLOBAL_SETTINGS_DIALOG_GET_PRIVATE (self);
140
141         ppriv->updating_page = create_updating_page (self);
142         top_vbox = gtk_vbox_new (FALSE, 0);
143         align = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
144         gtk_alignment_set_padding (GTK_ALIGNMENT (align), 
145                                    MODEST_MARGIN_DOUBLE, MODEST_MARGIN_DOUBLE, 
146                                    MODEST_MARGIN_DOUBLE, MODEST_MARGIN_TRIPLE);
147
148         /* Add the buttons: */
149         gtk_dialog_add_button (GTK_DIALOG (self), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
150         gtk_dialog_add_button (GTK_DIALOG (self), _HL_SAVE, GTK_RESPONSE_OK);
151         gtk_dialog_set_has_separator (GTK_DIALOG (self), FALSE);
152
153         /* Set the default focusable widgets */
154         g_object_set_data (G_OBJECT(ppriv->updating_page), DEFAULT_FOCUS_WIDGET,
155                            (gpointer)ppriv->auto_update);
156
157         gtk_container_add (GTK_CONTAINER (top_vbox), ppriv->updating_page);
158         gtk_container_add (GTK_CONTAINER (align), top_vbox);
159         gtk_container_add (GTK_CONTAINER (GTK_DIALOG (self)->vbox), align);
160         gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (self)->vbox), MODEST_MARGIN_HALF);
161         gtk_window_set_default_size (GTK_WINDOW (self), MODEST_DIALOG_WINDOW_MAX_WIDTH, MODEST_DIALOG_WINDOW_MAX_HEIGHT);
162
163         gtk_widget_show (align);
164         gtk_widget_show (top_vbox);
165 }
166
167 static void
168 modest_default_global_settings_dialog_finalize (GObject *obj)
169 {
170         ModestGlobalSettingsDialogPrivate *ppriv;
171         ModestDefaultGlobalSettingsDialogPrivate *priv;
172
173         priv = MODEST_DEFAULT_GLOBAL_SETTINGS_DIALOG_GET_PRIVATE (obj);
174         ppriv = MODEST_GLOBAL_SETTINGS_DIALOG_GET_PRIVATE (obj);
175
176 /*      free/unref instance resources here */
177         G_OBJECT_CLASS(parent_class)->finalize (obj);
178 }
179
180 GtkWidget*
181 modest_default_global_settings_dialog_new (void)
182 {
183         GtkWidget *self = GTK_WIDGET(g_object_new(MODEST_TYPE_DEFAULT_GLOBAL_SETTINGS_DIALOG, NULL));
184
185         /* Load settings */
186         modest_default_global_settings_dialog_load_settings (MODEST_GLOBAL_SETTINGS_DIALOG (self));
187
188         return self;
189 }
190
191 /*
192  * Creates the updating page
193  */
194 static GtkWidget*
195 create_updating_page (ModestDefaultGlobalSettingsDialog *self)
196 {
197         GtkWidget *vbox;
198         GtkSizeGroup *title_size_group;
199         GtkSizeGroup *value_size_group;
200         ModestGlobalSettingsDialogPrivate *ppriv;
201         GtkWidget *scrollable, *separator;
202         ModestDefaultGlobalSettingsDialogPrivate *priv;
203         PangoAttrList *attr_list;
204
205         priv = MODEST_DEFAULT_GLOBAL_SETTINGS_DIALOG_GET_PRIVATE (self);
206         ppriv = MODEST_GLOBAL_SETTINGS_DIALOG_GET_PRIVATE (self);
207         vbox = gtk_vbox_new (FALSE, MODEST_MARGIN_HALF);
208
209         title_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
210         value_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
211
212         /* Default account selector */
213         ppriv->accounts_list = get_accounts_list ();
214         ppriv->default_account_selector = modest_toolkit_factory_create_selector (modest_runtime_get_toolkit_factory (),
215                                                                                   ppriv->accounts_list,
216                                                                                   g_str_equal, TRUE);
217         if (ppriv->accounts_list == NULL) {
218                 gtk_widget_set_sensitive (GTK_WIDGET (ppriv->default_account_selector), FALSE);
219         } else {
220                 gchar *default_account;
221
222                 default_account = modest_account_mgr_get_default_account (
223                         modest_runtime_get_account_mgr ());
224                 if (default_account) {
225                         modest_selector_set_active_id (ppriv->default_account_selector,
226                                                        default_account);
227                         ppriv->initial_state.default_account = default_account;
228                 }
229         }
230         if (GTK_IS_COMBO_BOX (ppriv->default_account_selector)) {
231                 GtkWidget *caption;
232
233                 caption = modest_toolkit_utils_create_vcaptioned (title_size_group,
234                                                                   _("mcen_ti_default_account"), FALSE,
235                                                                   ppriv->default_account_selector);
236                 gtk_widget_show (caption);
237                 gtk_box_pack_start (GTK_BOX (vbox), caption,
238                                     FALSE, FALSE, 0);
239         } else {
240                 modest_toolkit_utils_set_vbutton_layout (title_size_group,
241                                                          _("mcen_ti_default_account"),
242                                                          ppriv->default_account_selector);
243                 gtk_box_pack_start (GTK_BOX (vbox), ppriv->default_account_selector,
244                                     FALSE, FALSE, 0);
245         }
246
247         /* Message format */
248         /* Note: This ModestPairList* must exist for as long as the picker
249          * that uses it, because the ModestSelectorPicker uses the ID opaquely,
250          * so it can't know how to manage its memory. */
251         ppriv->msg_format_list = _modest_global_settings_dialog_get_msg_formats ();
252         ppriv->msg_format = modest_toolkit_factory_create_selector (modest_runtime_get_toolkit_factory (),
253                                                                     ppriv->msg_format_list, g_int_equal, TRUE);
254         if (GTK_IS_COMBO_BOX (ppriv->msg_format)) {
255                 GtkWidget *caption;
256                 caption = modest_toolkit_utils_create_vcaptioned (title_size_group,
257                                                                   _("mcen_fi_options_messageformat"), FALSE,
258                                                                   ppriv->msg_format);
259                 gtk_widget_show (caption);
260                 gtk_box_pack_start (GTK_BOX (vbox), caption, FALSE, FALSE, 0);
261         } else {
262                 modest_toolkit_utils_set_vbutton_layout (title_size_group,
263                                                          _("mcen_fi_options_messageformat"),
264                                                          ppriv->msg_format);
265                 gtk_box_pack_start (GTK_BOX (vbox), ppriv->msg_format, FALSE, FALSE, 0);
266         }
267
268
269         /* Incoming notifications */
270         ppriv->notifications = modest_toolkit_factory_create_check_button (modest_runtime_get_toolkit_factory (),
271                                                                            _("mcen_fi_options_incoming_notifications"));
272         gtk_box_pack_start (GTK_BOX (vbox), ppriv->notifications, FALSE, FALSE, 0);
273
274         /* Automatic add to contacts */
275         ppriv->add_to_contacts = modest_toolkit_factory_create_check_button (modest_runtime_get_toolkit_factory (),
276                                                                              _("mcen_fi_options_automatic_add"));
277         gtk_box_pack_start (GTK_BOX (vbox), ppriv->add_to_contacts, FALSE, FALSE, 0);
278
279         /* Separator label */
280         separator = gtk_label_new (_("mcen_ti_updating"));
281         attr_list = pango_attr_list_new ();
282         pango_attr_list_insert (attr_list, pango_attr_weight_new (PANGO_WEIGHT_BOLD));
283         gtk_label_set_attributes (GTK_LABEL (separator), attr_list);
284         pango_attr_list_unref (attr_list);
285         gtk_label_set_justify ((GtkLabel *) separator, GTK_JUSTIFY_CENTER);
286         gtk_box_pack_start (GTK_BOX (vbox), separator, FALSE, FALSE, MODEST_MARGIN_DEFAULT);
287
288         /* Auto update */
289         ppriv->auto_update = modest_toolkit_factory_create_check_button (modest_runtime_get_toolkit_factory (),
290                                                                          _("mcen_fi_options_autoupdate"));
291         gtk_box_pack_start (GTK_BOX (vbox), ppriv->auto_update, FALSE, FALSE, 0);
292         g_signal_connect (ppriv->auto_update, "clicked", G_CALLBACK (on_auto_update_clicked), self);
293
294         /* Connected via */
295
296         /* Note: This ModestPairList* must exist for as long as the picker
297          * that uses it, because the ModestSelectorPicker uses the ID opaquely, 
298          * so it can't know how to manage its memory. */ 
299         ppriv->connect_via_list = _modest_global_settings_dialog_get_connected_via ();
300         ppriv->connect_via = modest_toolkit_factory_create_selector (modest_runtime_get_toolkit_factory (),
301                                                                      ppriv->connect_via_list, g_int_equal, TRUE);
302         if (GTK_IS_COMBO_BOX (ppriv->connect_via)) {
303                 GtkWidget *caption;
304                 caption = modest_toolkit_utils_create_vcaptioned (title_size_group,
305                                                                   _("mcen_fi_options_connectiontype"), FALSE,
306                                                                   ppriv->connect_via);
307                 gtk_widget_show (caption);
308                 gtk_box_pack_start (GTK_BOX (vbox), caption, FALSE, FALSE, 0);
309         } else {
310                 modest_toolkit_utils_set_vbutton_layout (title_size_group, 
311                                                          _("mcen_fi_options_connectiontype"),
312                                                          ppriv->connect_via);
313                 gtk_box_pack_start (GTK_BOX (vbox), ppriv->connect_via, FALSE, FALSE, 0);
314         }
315
316         /* Update interval */
317
318         /* Note: This ModestPairList* must exist for as long as the picker
319          * that uses it, because the ModestSelectorPicker uses the ID opaquely, 
320          * so it can't know how to manage its memory. */ 
321         ppriv->update_interval_list = _modest_global_settings_dialog_get_update_interval ();
322         ppriv->update_interval = modest_toolkit_factory_create_selector (modest_runtime_get_toolkit_factory (),
323                                                                          ppriv->update_interval_list, g_int_equal, TRUE);
324         if (GTK_IS_COMBO_BOX (ppriv->update_interval)) {
325                 GtkWidget *caption;
326                 caption = modest_toolkit_utils_create_vcaptioned (title_size_group,
327                                                                   _("mcen_fi_options_updateinterval"), FALSE,
328                                                                   ppriv->update_interval);
329                 gtk_widget_show (caption);
330                 gtk_box_pack_start (GTK_BOX (vbox), caption, FALSE, FALSE, 0);
331         } else {
332                 modest_toolkit_utils_set_vbutton_layout (title_size_group, 
333                                                          _("mcen_fi_options_updateinterval"), 
334                                                          ppriv->update_interval);
335                 gtk_box_pack_start (GTK_BOX (vbox), ppriv->update_interval, FALSE, FALSE, 0);
336         }
337
338         scrollable = modest_toolkit_factory_create_scrollable (modest_runtime_get_toolkit_factory ());
339
340         modest_scrollable_add_with_viewport (MODEST_SCROLLABLE (scrollable), vbox);
341         gtk_widget_show (vbox);
342         gtk_widget_show (scrollable);
343
344         g_object_unref (title_size_group);
345         g_object_unref (value_size_group);
346
347         return scrollable;
348 }
349
350
351 static void
352 update_sensitive (ModestGlobalSettingsDialog *dialog)
353 {
354         ModestGlobalSettingsDialogPrivate *ppriv;
355
356         g_return_if_fail (MODEST_IS_GLOBAL_SETTINGS_DIALOG (dialog));
357         ppriv = MODEST_GLOBAL_SETTINGS_DIALOG_GET_PRIVATE (dialog);
358
359         if (modest_togglable_get_active (ppriv->auto_update)) {
360                 gtk_widget_set_sensitive (ppriv->connect_via, TRUE);
361                 gtk_widget_set_sensitive (ppriv->update_interval, TRUE);
362         } else {
363                 gtk_widget_set_sensitive (ppriv->connect_via, FALSE);
364                 gtk_widget_set_sensitive (ppriv->update_interval, FALSE);
365         }
366 }
367
368 static void
369 on_auto_update_clicked (GtkButton *button,
370                         gpointer user_data)
371 {
372         g_return_if_fail (MODEST_IS_GLOBAL_SETTINGS_DIALOG (user_data));
373         update_sensitive ((ModestGlobalSettingsDialog *) user_data);
374 }
375
376 static ModestConnectedVia
377 current_connection (void)
378 {
379         return modest_platform_get_current_connection ();
380 }
381
382 static gint
383 order_by_acc_name (gconstpointer a,
384                    gconstpointer b)
385 {
386         ModestPair *pair_a, *pair_b;
387
388         pair_a = (ModestPair *) a;
389         pair_b = (ModestPair *) b;
390
391         if (pair_a->second && pair_b->second) {
392                 gint compare = g_utf8_collate ((gchar *) pair_a->second,
393                                                (gchar *) pair_b->second);
394                 if (compare > 0)
395                         compare = -1;
396                 else if (compare < 0)
397                         compare = 1;
398
399                 return compare;
400         } else {
401                 return 0;
402         }
403 }
404
405 static ModestPairList *
406 get_accounts_list (void)
407 {
408         GSList *list = NULL;
409         GSList *cursor, *account_names;
410         ModestAccountMgr *account_mgr;
411
412         account_mgr = modest_runtime_get_account_mgr ();
413
414         cursor = account_names = modest_account_mgr_account_names (account_mgr, TRUE /*only enabled*/);
415         while (cursor) {
416                 gchar *account_name;
417                 ModestAccountSettings *settings;
418                 ModestServerAccountSettings *store_settings;
419
420                 account_name = (gchar*)cursor->data;
421
422                 settings = modest_account_mgr_load_account_settings (account_mgr, account_name);
423                 if (!settings) {
424                         g_printerr ("modest: failed to get account data for %s\n", account_name);
425                         cursor = cursor->next;
426                         continue;
427                 }
428                 store_settings = modest_account_settings_get_store_settings (settings);
429
430                 /* don't display accounts without stores */
431                 if (modest_server_account_settings_get_account_name (store_settings) != NULL) {
432
433                         if (modest_account_settings_get_enabled (settings)) {
434                                 ModestPair *pair;
435
436                                 pair = modest_pair_new (
437                                         g_strdup (account_name),
438                                         g_strdup (modest_account_settings_get_display_name (settings)),
439                                         FALSE);
440                                 list = g_slist_insert_sorted (list, pair, order_by_acc_name);
441                         }
442                 }
443
444                 g_object_unref (store_settings);
445                 g_object_unref (settings);
446                 cursor = cursor->next;
447         }
448
449         return (ModestPairList *) g_slist_reverse (list);
450 }
451
452
453 static void
454 modest_default_global_settings_dialog_load_settings (ModestGlobalSettingsDialog *self)
455 {
456         ModestConf *conf;
457         gboolean checked;
458         gint combo_id;
459         GError *error = NULL;
460         ModestGlobalSettingsDialogPrivate *ppriv;
461
462         ppriv = MODEST_GLOBAL_SETTINGS_DIALOG_GET_PRIVATE (self);
463         conf = modest_runtime_get_conf ();
464
465         /* Incoming notifications */
466         checked = modest_conf_get_bool (conf, MODEST_CONF_NOTIFICATIONS, &error);
467         if (error) {
468                 g_clear_error (&error);
469                 error = NULL;
470                 checked = FALSE;
471         }
472         modest_togglable_set_active (ppriv->notifications, checked);
473         ppriv->initial_state.notifications = checked;
474
475         /* Add to contacts */
476         checked = modest_conf_get_bool (conf, MODEST_CONF_AUTO_ADD_TO_CONTACTS, &error);
477         if (error) {
478                 g_clear_error (&error);
479                 error = NULL;
480                 checked = FALSE;
481         }
482         modest_togglable_set_active (ppriv->add_to_contacts, checked);
483         ppriv->initial_state.add_to_contacts = checked;
484
485         /* Autoupdate */
486         checked = modest_conf_get_bool (conf, MODEST_CONF_AUTO_UPDATE, &error);
487         if (error) {
488                 g_clear_error (&error);
489                 error = NULL;
490                 checked = FALSE;
491         }
492         modest_togglable_set_active (ppriv->auto_update, checked);
493         ppriv->initial_state.auto_update = checked;
494
495         /* Connected by */
496         combo_id = modest_conf_get_int (conf, MODEST_CONF_UPDATE_WHEN_CONNECTED_BY, &error);
497         if (error) {
498                 g_error_free (error);
499                 error = NULL;
500                 combo_id = MODEST_CONNECTED_VIA_WLAN_OR_WIMAX;
501         }
502         modest_selector_set_active_id (ppriv->connect_via,
503                                        (gpointer) &combo_id);
504         ppriv->initial_state.connect_via = combo_id;
505
506         /* Update interval */
507         combo_id = modest_conf_get_int (conf, MODEST_CONF_UPDATE_INTERVAL, &error);
508         if (error) {
509                 g_error_free (error);
510                 error = NULL;
511                 combo_id = MODEST_UPDATE_INTERVAL_15_MIN;
512         }
513         modest_selector_set_active_id (ppriv->update_interval,
514                                        (gpointer) &combo_id);
515         ppriv->initial_state.update_interval = combo_id;
516
517         /* Play sound */
518         checked = modest_conf_get_bool (conf, MODEST_CONF_PLAY_SOUND_MSG_ARRIVE, &error);
519         if (error) {
520                 g_error_free (error);
521                 error = NULL;
522                 checked = FALSE;
523         }
524         ppriv->initial_state.play_sound = checked;
525
526         /* Msg format */
527         checked = modest_conf_get_bool (conf, MODEST_CONF_PREFER_FORMATTED_TEXT, &error);
528         if (error) {
529                 g_error_free (error);
530                 error = NULL;
531                 combo_id = MODEST_FILE_FORMAT_FORMATTED_TEXT;
532         }
533         combo_id = (checked) ? MODEST_FILE_FORMAT_FORMATTED_TEXT : MODEST_FILE_FORMAT_PLAIN_TEXT;
534         modest_selector_set_active_id (ppriv->msg_format,
535                                        (gpointer) &combo_id);
536         ppriv->initial_state.prefer_formatted_text = checked;
537
538         /* force update of sensitiveness */
539         update_sensitive (MODEST_GLOBAL_SETTINGS_DIALOG (self));
540 }