e82b9b52ca539448f5abaabc0c500f02251d1f25
[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), _HL_SAVE, GTK_RESPONSE_OK);
150         gtk_dialog_set_has_separator (GTK_DIALOG (self), FALSE);
151
152         /* Set the default focusable widgets */
153         g_object_set_data (G_OBJECT(ppriv->updating_page), DEFAULT_FOCUS_WIDGET,
154                            (gpointer)ppriv->auto_update);
155
156         gtk_container_add (GTK_CONTAINER (top_vbox), ppriv->updating_page);
157         gtk_container_add (GTK_CONTAINER (align), top_vbox);
158         gtk_container_add (GTK_CONTAINER (GTK_DIALOG (self)->vbox), align);
159         gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (self)->vbox), MODEST_MARGIN_HALF);
160         gtk_window_set_default_size (GTK_WINDOW (self), MODEST_DIALOG_WINDOW_MAX_WIDTH, -1);
161
162         gtk_widget_show (align);
163         gtk_widget_show (top_vbox);
164 }
165
166 static void
167 modest_default_global_settings_dialog_finalize (GObject *obj)
168 {
169         ModestGlobalSettingsDialogPrivate *ppriv;
170         ModestDefaultGlobalSettingsDialogPrivate *priv;
171
172         priv = MODEST_DEFAULT_GLOBAL_SETTINGS_DIALOG_GET_PRIVATE (obj);
173         ppriv = MODEST_GLOBAL_SETTINGS_DIALOG_GET_PRIVATE (obj);
174
175 /*      free/unref instance resources here */
176         G_OBJECT_CLASS(parent_class)->finalize (obj);
177 }
178
179 GtkWidget*
180 modest_default_global_settings_dialog_new (void)
181 {
182         GtkWidget *self = GTK_WIDGET(g_object_new(MODEST_TYPE_DEFAULT_GLOBAL_SETTINGS_DIALOG, NULL));
183
184         /* Load settings */
185         modest_default_global_settings_dialog_load_settings (MODEST_GLOBAL_SETTINGS_DIALOG (self));
186
187         return self;
188 }
189
190 /*
191  * Creates the updating page
192  */
193 static GtkWidget*
194 create_updating_page (ModestDefaultGlobalSettingsDialog *self)
195 {
196         GtkWidget *vbox;
197         GtkSizeGroup *title_size_group;
198         GtkSizeGroup *value_size_group;
199         ModestGlobalSettingsDialogPrivate *ppriv;
200         GtkWidget *scrollable, *separator;
201         ModestDefaultGlobalSettingsDialogPrivate *priv;
202         PangoAttrList *attr_list;
203
204         priv = MODEST_DEFAULT_GLOBAL_SETTINGS_DIALOG_GET_PRIVATE (self);
205         ppriv = MODEST_GLOBAL_SETTINGS_DIALOG_GET_PRIVATE (self);
206         vbox = gtk_vbox_new (FALSE, MODEST_MARGIN_HALF);
207
208         title_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
209         value_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
210
211         /* Default account selector */
212         ppriv->accounts_list = get_accounts_list ();
213         ppriv->default_account_selector = modest_toolkit_factory_create_selector (modest_runtime_get_toolkit_factory (),
214                                                                                   ppriv->accounts_list,
215                                                                                   g_str_equal);
216         if (ppriv->accounts_list == NULL) {
217                 gtk_widget_set_sensitive (GTK_WIDGET (ppriv->default_account_selector), FALSE);
218         } else {
219                 gchar *default_account;
220
221                 default_account = modest_account_mgr_get_default_account (
222                         modest_runtime_get_account_mgr ());
223                 if (default_account) {
224                         modest_selector_set_active_id (ppriv->default_account_selector,
225                                                        default_account);
226                         ppriv->initial_state.default_account = default_account;
227                 }
228         }
229         if (GTK_IS_COMBO_BOX (ppriv->default_account_selector)) {
230                 GtkWidget *caption;
231
232                 caption = modest_toolkit_utils_create_vcaptioned (title_size_group,
233                                                                   _("mcen_ti_default_account"), FALSE,
234                                                                   ppriv->default_account_selector);
235                 gtk_widget_show (caption);
236                 gtk_box_pack_start (GTK_BOX (vbox), caption,
237                                     FALSE, FALSE, 0);
238         } else {
239                 modest_toolkit_utils_set_vbutton_layout (title_size_group,
240                                                          _("mcen_ti_default_account"),
241                                                          ppriv->default_account_selector);
242                 gtk_box_pack_start (GTK_BOX (vbox), ppriv->default_account_selector,
243                                     FALSE, FALSE, 0);
244         }
245
246         /* Message format */
247         /* Note: This ModestPairList* must exist for as long as the picker
248          * that uses it, because the ModestSelectorPicker uses the ID opaquely,
249          * so it can't know how to manage its memory. */
250         ppriv->msg_format_list = _modest_global_settings_dialog_get_msg_formats ();
251         ppriv->msg_format = modest_toolkit_factory_create_selector (modest_runtime_get_toolkit_factory (),
252                                                                     ppriv->msg_format_list, g_int_equal);
253         if (GTK_IS_COMBO_BOX (ppriv->msg_format)) {
254                 GtkWidget *caption;
255                 caption = modest_toolkit_utils_create_vcaptioned (title_size_group,
256                                                                   _("mcen_fi_options_messageformat"), FALSE,
257                                                                   ppriv->msg_format);
258                 gtk_widget_show (caption);
259                 gtk_box_pack_start (GTK_BOX (vbox), caption, FALSE, FALSE, 0);
260         } else {
261                 modest_toolkit_utils_set_vbutton_layout (title_size_group,
262                                                          _("mcen_fi_options_messageformat"),
263                                                          ppriv->msg_format);
264                 gtk_box_pack_start (GTK_BOX (vbox), ppriv->msg_format, FALSE, FALSE, 0);
265         }
266
267
268         /* Incoming notifications */
269         ppriv->notifications = modest_toolkit_factory_create_check_button (modest_runtime_get_toolkit_factory (),
270                                                                            _("mcen_fi_options_incoming_notifications"));
271         gtk_box_pack_start (GTK_BOX (vbox), ppriv->notifications, FALSE, FALSE, 0);
272
273         /* Automatic add to contacts */
274         ppriv->add_to_contacts = modest_toolkit_factory_create_check_button (modest_runtime_get_toolkit_factory (),
275                                                                              _("mcen_fi_options_automatic_add"));
276         gtk_box_pack_start (GTK_BOX (vbox), ppriv->add_to_contacts, FALSE, FALSE, 0);
277
278         /* Separator label */
279         separator = gtk_label_new (_("mcen_ti_updating"));
280         attr_list = pango_attr_list_new ();
281         pango_attr_list_insert (attr_list, pango_attr_weight_new (PANGO_WEIGHT_BOLD));
282         gtk_label_set_attributes (GTK_LABEL (separator), attr_list);
283         pango_attr_list_unref (attr_list);
284         gtk_label_set_justify ((GtkLabel *) separator, GTK_JUSTIFY_CENTER);
285         gtk_box_pack_start (GTK_BOX (vbox), separator, FALSE, FALSE, MODEST_MARGIN_DEFAULT);
286
287         /* Auto update */
288         ppriv->auto_update = modest_toolkit_factory_create_check_button (modest_runtime_get_toolkit_factory (),
289                                                                          _("mcen_fi_options_autoupdate"));
290         gtk_box_pack_start (GTK_BOX (vbox), ppriv->auto_update, FALSE, FALSE, 0);
291         g_signal_connect (ppriv->auto_update, "clicked", G_CALLBACK (on_auto_update_clicked), self);
292
293         /* Connected via */
294
295         /* Note: This ModestPairList* must exist for as long as the picker
296          * that uses it, because the ModestSelectorPicker uses the ID opaquely, 
297          * so it can't know how to manage its memory. */ 
298         ppriv->connect_via_list = _modest_global_settings_dialog_get_connected_via ();
299         ppriv->connect_via = modest_toolkit_factory_create_selector (modest_runtime_get_toolkit_factory (),
300                                                                      ppriv->connect_via_list, g_int_equal);
301         if (GTK_IS_COMBO_BOX (ppriv->connect_via)) {
302                 GtkWidget *caption;
303                 caption = modest_toolkit_utils_create_vcaptioned (title_size_group,
304                                                                   _("mcen_fi_options_connectiontype"), FALSE,
305                                                                   ppriv->connect_via);
306                 gtk_widget_show (caption);
307                 gtk_box_pack_start (GTK_BOX (vbox), caption, FALSE, FALSE, 0);
308         } else {
309                 modest_toolkit_utils_set_vbutton_layout (title_size_group, 
310                                                          _("mcen_fi_options_connectiontype"),
311                                                          ppriv->connect_via);
312                 gtk_box_pack_start (GTK_BOX (vbox), ppriv->connect_via, FALSE, FALSE, 0);
313         }
314
315         /* Update interval */
316
317         /* Note: This ModestPairList* must exist for as long as the picker
318          * that uses it, because the ModestSelectorPicker uses the ID opaquely, 
319          * so it can't know how to manage its memory. */ 
320         ppriv->update_interval_list = _modest_global_settings_dialog_get_update_interval ();
321         ppriv->update_interval = modest_toolkit_factory_create_selector (modest_runtime_get_toolkit_factory (),
322                                                                          ppriv->update_interval_list, g_int_equal);
323         if (GTK_IS_COMBO_BOX (ppriv->update_interval)) {
324                 GtkWidget *caption;
325                 caption = modest_toolkit_utils_create_vcaptioned (title_size_group,
326                                                                   _("mcen_fi_options_updateinterval"), FALSE,
327                                                                   ppriv->update_interval);
328                 gtk_widget_show (caption);
329                 gtk_box_pack_start (GTK_BOX (vbox), caption, FALSE, FALSE, 0);
330         } else {
331                 modest_toolkit_utils_set_vbutton_layout (title_size_group, 
332                                                          _("mcen_fi_options_updateinterval"), 
333                                                          ppriv->update_interval);
334                 gtk_box_pack_start (GTK_BOX (vbox), ppriv->update_interval, FALSE, FALSE, 0);
335         }
336
337         scrollable = modest_toolkit_factory_create_scrollable (modest_runtime_get_toolkit_factory ());
338
339         modest_scrollable_add_with_viewport (MODEST_SCROLLABLE (scrollable), vbox);
340         gtk_widget_show (vbox);
341         gtk_widget_show (scrollable);
342
343         g_object_unref (title_size_group);
344         g_object_unref (value_size_group);
345
346         return scrollable;
347 }
348
349
350 static void
351 update_sensitive (ModestGlobalSettingsDialog *dialog)
352 {
353         ModestGlobalSettingsDialogPrivate *ppriv;
354
355         g_return_if_fail (MODEST_IS_GLOBAL_SETTINGS_DIALOG (dialog));
356         ppriv = MODEST_GLOBAL_SETTINGS_DIALOG_GET_PRIVATE (dialog);
357
358         if (modest_togglable_get_active (ppriv->auto_update)) {
359                 gtk_widget_set_sensitive (ppriv->connect_via, TRUE);
360                 gtk_widget_set_sensitive (ppriv->update_interval, TRUE);
361         } else {
362                 gtk_widget_set_sensitive (ppriv->connect_via, FALSE);
363                 gtk_widget_set_sensitive (ppriv->update_interval, FALSE);
364         }
365 }
366
367 static void
368 on_auto_update_clicked (GtkButton *button,
369                         gpointer user_data)
370 {
371         g_return_if_fail (MODEST_IS_GLOBAL_SETTINGS_DIALOG (user_data));
372         update_sensitive ((ModestGlobalSettingsDialog *) user_data);
373 }
374
375 static ModestConnectedVia
376 current_connection (void)
377 {
378         return modest_platform_get_current_connection ();
379 }
380
381 static gint
382 order_by_acc_name (gconstpointer a,
383                    gconstpointer b)
384 {
385         ModestPair *pair_a, *pair_b;
386
387         pair_a = (ModestPair *) a;
388         pair_b = (ModestPair *) b;
389
390         if (pair_a->second && pair_b->second) {
391                 gint compare = g_utf8_collate ((gchar *) pair_a->second,
392                                                (gchar *) pair_b->second);
393                 if (compare > 0)
394                         compare = -1;
395                 else if (compare < 0)
396                         compare = 1;
397
398                 return compare;
399         } else {
400                 return 0;
401         }
402 }
403
404 static ModestPairList *
405 get_accounts_list (void)
406 {
407         GSList *list = NULL;
408         GSList *cursor, *account_names;
409         ModestAccountMgr *account_mgr;
410
411         account_mgr = modest_runtime_get_account_mgr ();
412
413         cursor = account_names = modest_account_mgr_account_names (account_mgr, TRUE /*only enabled*/);
414         while (cursor) {
415                 gchar *account_name;
416                 ModestAccountSettings *settings;
417                 ModestServerAccountSettings *store_settings;
418
419                 account_name = (gchar*)cursor->data;
420
421                 settings = modest_account_mgr_load_account_settings (account_mgr, account_name);
422                 if (!settings) {
423                         g_printerr ("modest: failed to get account data for %s\n", account_name);
424                         cursor = cursor->next;
425                         continue;
426                 }
427                 store_settings = modest_account_settings_get_store_settings (settings);
428
429                 /* don't display accounts without stores */
430                 if (modest_server_account_settings_get_account_name (store_settings) != NULL) {
431
432                         if (modest_account_settings_get_enabled (settings)) {
433                                 ModestPair *pair;
434
435                                 pair = modest_pair_new (
436                                         g_strdup (account_name),
437                                         g_strdup (modest_account_settings_get_display_name (settings)),
438                                         FALSE);
439                                 list = g_slist_insert_sorted (list, pair, order_by_acc_name);
440                         }
441                 }
442
443                 g_object_unref (store_settings);
444                 g_object_unref (settings);
445                 cursor = cursor->next;
446         }
447
448         return (ModestPairList *) g_slist_reverse (list);
449 }
450
451
452 static void
453 modest_default_global_settings_dialog_load_settings (ModestGlobalSettingsDialog *self)
454 {
455         ModestConf *conf;
456         gboolean checked;
457         gint combo_id;
458         GError *error = NULL;
459         ModestGlobalSettingsDialogPrivate *ppriv;
460
461         ppriv = MODEST_GLOBAL_SETTINGS_DIALOG_GET_PRIVATE (self);
462         conf = modest_runtime_get_conf ();
463
464         /* Incoming notifications */
465         checked = modest_conf_get_bool (conf, MODEST_CONF_NOTIFICATIONS, &error);
466         if (error) {
467                 g_clear_error (&error);
468                 error = NULL;
469                 checked = FALSE;
470         }
471         modest_togglable_set_active (ppriv->notifications, checked);
472         ppriv->initial_state.notifications = checked;
473
474         /* Add to contacts */
475         checked = modest_conf_get_bool (conf, MODEST_CONF_AUTO_ADD_TO_CONTACTS, &error);
476         if (error) {
477                 g_clear_error (&error);
478                 error = NULL;
479                 checked = FALSE;
480         }
481         modest_togglable_set_active (ppriv->add_to_contacts, checked);
482         ppriv->initial_state.add_to_contacts = checked;
483
484         /* Autoupdate */
485         checked = modest_conf_get_bool (conf, MODEST_CONF_AUTO_UPDATE, &error);
486         if (error) {
487                 g_clear_error (&error);
488                 error = NULL;
489                 checked = FALSE;
490         }
491         modest_togglable_set_active (ppriv->auto_update, checked);
492         ppriv->initial_state.auto_update = checked;
493
494         /* Connected by */
495         combo_id = modest_conf_get_int (conf, MODEST_CONF_UPDATE_WHEN_CONNECTED_BY, &error);
496         if (error) {
497                 g_error_free (error);
498                 error = NULL;
499                 combo_id = MODEST_CONNECTED_VIA_WLAN_OR_WIMAX;
500         }
501         modest_selector_set_active_id (ppriv->connect_via,
502                                        (gpointer) &combo_id);
503         ppriv->initial_state.connect_via = combo_id;
504
505         /* Update interval */
506         combo_id = modest_conf_get_int (conf, MODEST_CONF_UPDATE_INTERVAL, &error);
507         if (error) {
508                 g_error_free (error);
509                 error = NULL;
510                 combo_id = MODEST_UPDATE_INTERVAL_15_MIN;
511         }
512         modest_selector_set_active_id (ppriv->update_interval,
513                                        (gpointer) &combo_id);
514         ppriv->initial_state.update_interval = combo_id;
515
516         /* Play sound */
517         checked = modest_conf_get_bool (conf, MODEST_CONF_PLAY_SOUND_MSG_ARRIVE, &error);
518         if (error) {
519                 g_error_free (error);
520                 error = NULL;
521                 checked = FALSE;
522         }
523         ppriv->initial_state.play_sound = checked;
524
525         /* Msg format */
526         checked = modest_conf_get_bool (conf, MODEST_CONF_PREFER_FORMATTED_TEXT, &error);
527         if (error) {
528                 g_error_free (error);
529                 error = NULL;
530                 combo_id = MODEST_FILE_FORMAT_FORMATTED_TEXT;
531         }
532         combo_id = (checked) ? MODEST_FILE_FORMAT_FORMATTED_TEXT : MODEST_FILE_FORMAT_PLAIN_TEXT;
533         modest_selector_set_active_id (ppriv->msg_format,
534                                        (gpointer) &combo_id);
535         ppriv->initial_state.prefer_formatted_text = checked;
536
537         /* force update of sensitiveness */
538         update_sensitive (MODEST_GLOBAL_SETTINGS_DIALOG (self));
539 }