diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2004-02-28 04:17:02 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2004-02-28 04:17:02 +0800 |
commit | 180e9032df85343ae81de583b99b90511b1cf507 (patch) | |
tree | 624afffd5b74cc44510f0191e311ac2ae6499daf | |
parent | 77ce8408267d25bd060e5558847f61bc70575e82 (diff) | |
download | gsoc2013-evolution-180e9032df85343ae81de583b99b90511b1cf507.tar.gz gsoc2013-evolution-180e9032df85343ae81de583b99b90511b1cf507.tar.zst gsoc2013-evolution-180e9032df85343ae81de583b99b90511b1cf507.zip |
If gconf_entry_get_value() returns NULL, then it means the key was unset
2004-02-27 Jeffrey Stedfast <fejj@ximian.com>
* em-folder-view.c (emfv_setting_notify): If
gconf_entry_get_value() returns NULL, then it means the key was
unset or something. Don't use g_return_if_fail() for that.
First of the lockdown fixes...
* em-composer-prefs.c (em_composer_prefs_construct): Same as
below.
* em-mailer-prefs.c (em_mailer_prefs_construct): Respect
locked-down keys by disabling their sensitivity to the user.
(settings_changed): Don't re-enable check_incoming_imap if the key
is locked.
svn path=/trunk/; revision=24911
-rw-r--r-- | mail/ChangeLog | 16 | ||||
-rw-r--r-- | mail/em-composer-prefs.c | 70 | ||||
-rw-r--r-- | mail/em-folder-view.c | 25 | ||||
-rw-r--r-- | mail/em-mailer-prefs.c | 208 |
4 files changed, 240 insertions, 79 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index b006299882..4e02f76391 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,19 @@ +2004-02-27 Jeffrey Stedfast <fejj@ximian.com> + + * em-folder-view.c (emfv_setting_notify): If + gconf_entry_get_value() returns NULL, then it means the key was + unset or something. Don't use g_return_if_fail() for that. + + First of the lockdown fixes... + + * em-composer-prefs.c (em_composer_prefs_construct): Same as + below. + + * em-mailer-prefs.c (em_mailer_prefs_construct): Respect + locked-down keys by disabling their sensitivity to the user. + (settings_changed): Don't re-enable check_incoming_imap if the key + is locked. + 2004-02-26 Rodney Dawes <dobey@ximian.com> * em-format-html-display.c (efhd_attachment_button): Create the diff --git a/mail/em-composer-prefs.c b/mail/em-composer-prefs.c index aaa3a623f9..e4b68b9b3d 100644 --- a/mail/em-composer-prefs.c +++ b/mail/em-composer-prefs.c @@ -329,7 +329,7 @@ sig_add_script_response (GtkWidget *widget, int button, EMComposerPrefs *prefs) return; } } - + g_free(script); dialog = gtk_message_dialog_new (GTK_WINDOW (prefs->sig_script_dialog), GTK_DIALOG_DESTROY_WITH_PARENT, @@ -497,9 +497,9 @@ spell_set_ui (EMComposerPrefs *prefs) gboolean go; char **strv = NULL; int i; - + prefs->spell_active = FALSE; - + /* setup the language list */ present = g_hash_table_new (g_str_hash, g_str_equal); if (prefs->language_str && (strv = g_strsplit (prefs->language_str, " ", 0))) { @@ -536,7 +536,7 @@ spell_get_language_str (EMComposerPrefs *prefs) GtkTreeIter iter; gboolean go; char *rv; - + model = (GtkListStore *) gtk_tree_view_get_model (prefs->language); for (go = gtk_tree_model_get_iter_first ((GtkTreeModel *) model, &iter); go; @@ -595,7 +595,7 @@ spell_load_values (EMComposerPrefs *prefs) { GConfValue *val; char *def_lang; - + def_lang = g_strdup (e_iconv_locale_language ()); g_free (prefs->language_str); prefs->language_str = g_strdup (def_lang); @@ -673,7 +673,7 @@ spell_language_selection_changed (GtkTreeSelection *selection, EMComposerPrefs * GtkTreeIter iter; GtkTreeModel *model; gboolean state = FALSE; - + if (gtk_tree_selection_get_selected (selection, &model, &iter)) { gtk_tree_model_get ((GtkTreeModel *) model, &iter, 0, &state, -1); gtk_button_set_label ((GtkButton *) prefs->spell_able_button, state ? _("Disable") : _("Enable")); @@ -788,6 +788,22 @@ spell_setup_check_options (EMComposerPrefs *prefs) * End of Spell checking */ + +static void +toggle_button_init (GtkToggleButton *toggle, GConfClient *gconf, const char *key, int not, GCallback toggled, void *user_data) +{ + gboolean bool; + + bool = gconf_client_get_bool (gconf, key, NULL); + gtk_toggle_button_set_active (toggle, not ? !bool : bool); + + if (toggled) + g_signal_connect (toggle, "toggled", toggled, user_data); + + if (!gconf_client_key_is_writable (gconf, key, NULL)) + gtk_widget_set_sensitive ((GtkWidget *) toggle, FALSE); +} + static void em_composer_prefs_construct (EMComposerPrefs *prefs) { @@ -796,7 +812,7 @@ em_composer_prefs_construct (EMComposerPrefs *prefs) GladeXML *gui; GtkListStore *model; GtkTreeSelection *selection; - gboolean bool; + gboolean bool, locked; int style; char *buf; @@ -819,35 +835,37 @@ em_composer_prefs_construct (EMComposerPrefs *prefs) /* Default Behavior */ prefs->send_html = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "chkSendHTML")); - bool = gconf_client_get_bool (prefs->gconf, "/apps/evolution/mail/composer/send_html", NULL); - gtk_toggle_button_set_active (prefs->send_html, bool); - g_signal_connect (prefs->send_html, "toggled", G_CALLBACK (toggle_button_toggled), prefs); + toggle_button_init (prefs->send_html, prefs->gconf, + "/apps/evolution/mail/composer/send_html", + FALSE, G_CALLBACK (toggle_button_toggled), prefs); prefs->prompt_empty_subject = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "chkPromptEmptySubject")); - bool = gconf_client_get_bool (prefs->gconf, "/apps/evolution/mail/prompts/empty_subject", NULL); - gtk_toggle_button_set_active (prefs->prompt_empty_subject, bool); - g_signal_connect (prefs->prompt_empty_subject, "toggled", G_CALLBACK (toggle_button_toggled), prefs); + toggle_button_init (prefs->prompt_empty_subject, prefs->gconf, + "/apps/evolution/mail/prompts/empty_subject", + FALSE, G_CALLBACK (toggle_button_toggled), prefs); prefs->prompt_bcc_only = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "chkPromptBccOnly")); - bool = gconf_client_get_bool (prefs->gconf, "/apps/evolution/mail/prompts/only_bcc", NULL); - gtk_toggle_button_set_active (prefs->prompt_bcc_only, bool); - g_signal_connect (prefs->prompt_bcc_only, "toggled", G_CALLBACK (toggle_button_toggled), prefs); + toggle_button_init (prefs->prompt_bcc_only, prefs->gconf, + "/apps/evolution/mail/prompts/only_bcc", + FALSE, G_CALLBACK (toggle_button_toggled), prefs); prefs->auto_smileys = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "chkAutoSmileys")); - bool = gconf_client_get_bool (prefs->gconf, "/apps/evolution/mail/composer/magic_smileys", NULL); - gtk_toggle_button_set_active (prefs->auto_smileys, bool); - g_signal_connect (prefs->auto_smileys, "toggled", G_CALLBACK (toggle_button_toggled), prefs); - + toggle_button_init (prefs->auto_smileys, prefs->gconf, + "/apps/evolution/mail/composer/magic_smileys", + FALSE, G_CALLBACK (toggle_button_toggled), prefs); + prefs->spell_check = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "chkEnableSpellChecking")); - bool = gconf_client_get_bool (prefs->gconf, "/apps/evolution/mail/composer/inline_spelling", NULL); - gtk_toggle_button_set_active (prefs->spell_check, bool); - g_signal_connect (prefs->spell_check, "toggled", G_CALLBACK (toggle_button_toggled), prefs); - + toggle_button_init (prefs->auto_smileys, prefs->gconf, + "/apps/evolution/mail/composer/inline_spelling", + FALSE, G_CALLBACK (toggle_button_toggled), prefs); + prefs->charset = GTK_OPTION_MENU (glade_xml_get_widget (gui, "omenuCharset")); buf = gconf_client_get_string (prefs->gconf, "/apps/evolution/mail/composer/charset", NULL); menu = e_charset_picker_new (buf && *buf ? buf : e_iconv_locale_charset ()); gtk_option_menu_set_menu (prefs->charset, GTK_WIDGET (menu)); option_menu_connect (prefs->charset, prefs); + if (!gconf_client_key_is_writable (prefs->gconf, "/apps/evolution/mail/composer/charset", NULL)) + gtk_widget_set_sensitive ((GtkWidget *) prefs->charset, FALSE); g_free (buf); /* Spell Checking: GNOME Spell part */ @@ -883,6 +901,8 @@ em_composer_prefs_construct (EMComposerPrefs *prefs) gtk_container_foreach (GTK_CONTAINER (gtk_option_menu_get_menu (prefs->forward_style)), attach_style_info, &style); option_menu_connect (prefs->forward_style, prefs); + if (!gconf_client_key_is_writable (prefs->gconf, "/apps/evolution/mail/format/forward_style", NULL)) + gtk_widget_set_sensitive ((GtkWidget *) prefs->forward_style, FALSE); prefs->reply_style = GTK_OPTION_MENU (glade_xml_get_widget (gui, "omenuReplyStyle")); style = gconf_client_get_int (prefs->gconf, "/apps/evolution/mail/format/reply_style", NULL); @@ -891,6 +911,8 @@ em_composer_prefs_construct (EMComposerPrefs *prefs) gtk_container_foreach (GTK_CONTAINER (gtk_option_menu_get_menu (prefs->reply_style)), attach_style_info, &style); option_menu_connect (prefs->reply_style, prefs); + if (!gconf_client_key_is_writable (prefs->gconf, "/apps/evolution/mail/format/reply_style", NULL)) + gtk_widget_set_sensitive ((GtkWidget *) prefs->reply_style, FALSE); /* Signatures */ dialog = (GtkDialog *) gtk_dialog_new (); diff --git a/mail/em-folder-view.c b/mail/em-folder-view.c index a6d45dec63..d7da84caff 100644 --- a/mail/em-folder-view.c +++ b/mail/em-folder-view.c @@ -2014,27 +2014,30 @@ static GHashTable *emfv_setting_key; static void emfv_setting_notify(GConfClient *gconf, guint cnxn_id, GConfEntry *entry, EMFolderView *emfv) { + GConfValue *value; char *tkey; g_return_if_fail (gconf_entry_get_key (entry) != NULL); - g_return_if_fail (gconf_entry_get_value (entry) != NULL); + + if (!(value = gconf_entry_get_value (entry))) + return; tkey = strrchr(entry->key, '/'); g_return_if_fail (tkey != NULL); switch(GPOINTER_TO_INT(g_hash_table_lookup(emfv_setting_key, tkey+1))) { case EMFV_ANIMATE_IMAGES: - em_format_html_display_set_animate(emfv->preview, gconf_value_get_bool(gconf_entry_get_value(entry))); + em_format_html_display_set_animate(emfv->preview, gconf_value_get_bool (value)); break; case EMFV_CHARSET: - em_format_set_default_charset((EMFormat *)emfv->preview, gconf_value_get_string(gconf_entry_get_value(entry))); + em_format_set_default_charset((EMFormat *)emfv->preview, gconf_value_get_string (value)); break; case EMFV_CITATION_COLOUR: { const char *s; GdkColor colour; guint32 rgb; - s = gconf_value_get_string(gconf_entry_get_value(entry)); + s = gconf_value_get_string (value); gdk_color_parse(s?s:"#737373", &colour); rgb = ((colour.red & 0xff00) << 8) | (colour.green & 0xff00) | ((colour.blue & 0xff00) >> 8); em_format_html_set_mark_citations((EMFormatHTML *)emfv->preview, @@ -2042,15 +2045,15 @@ emfv_setting_notify(GConfClient *gconf, guint cnxn_id, GConfEntry *entry, EMFold break; } case EMFV_CITATION_MARK: em_format_html_set_mark_citations((EMFormatHTML *)emfv->preview, - gconf_value_get_bool(gconf_entry_get_value(entry)), + gconf_value_get_bool (value), ((EMFormatHTML *)emfv->preview)->citation_colour); break; case EMFV_CARET_MODE: - em_format_html_display_set_caret_mode(emfv->preview, gconf_value_get_bool(gconf_entry_get_value(entry))); + em_format_html_display_set_caret_mode(emfv->preview, gconf_value_get_bool (value)); break; case EMFV_MESSAGE_STYLE: if (EM_FOLDER_VIEW_GET_CLASS (emfv)->update_message_style) { - int style = gconf_value_get_int(gconf_entry_get_value(entry)); + int style = gconf_value_get_int (value); if (style < EM_FORMAT_NORMAL || style > EM_FORMAT_SOURCE) style = EM_FORMAT_NORMAL; @@ -2058,19 +2061,19 @@ emfv_setting_notify(GConfClient *gconf, guint cnxn_id, GConfEntry *entry, EMFold } break; case EMFV_MARK_SEEN: - emfv->mark_seen = gconf_value_get_bool(gconf_entry_get_value(entry)); + emfv->mark_seen = gconf_value_get_bool (value); break; case EMFV_MARK_SEEN_TIMEOUT: - emfv->mark_seen_timeout = gconf_value_get_int(gconf_entry_get_value(entry)); + emfv->mark_seen_timeout = gconf_value_get_int (value); break; case EMFV_LOAD_HTTP: { - int style = gconf_value_get_int(gconf_entry_get_value(entry)); + int style = gconf_value_get_int (value); /* FIXME: this doesn't handle the 'sometimes' case, only the always case */ em_format_html_set_load_http((EMFormatHTML *)emfv->preview, style == 2); break; } case EMFV_XMAILER_MASK: - em_format_html_set_xmailer_mask((EMFormatHTML *)emfv->preview, gconf_value_get_int(gconf_entry_get_value(entry))); + em_format_html_set_xmailer_mask((EMFormatHTML *)emfv->preview, gconf_value_get_int (value)); break; case EMFV_HEADERS: { GSList *header_config_list, *p; diff --git a/mail/em-mailer-prefs.c b/mail/em-mailer-prefs.c index 946baec956..ca13a8da77 100644 --- a/mail/em-mailer-prefs.c +++ b/mail/em-mailer-prefs.c @@ -159,8 +159,12 @@ static void settings_changed (GtkWidget *widget, gpointer user_data) { EMMailerPrefs *prefs = (EMMailerPrefs *) user_data; + gboolean check_incoming, locked = FALSE; - gtk_widget_set_sensitive (GTK_WIDGET (prefs->check_incoming_imap), gtk_toggle_button_get_active (prefs->check_incoming)); + if ((check_incoming = gtk_toggle_button_get_active (prefs->check_incoming))) + locked = gconf_client_key_is_writable (prefs->gconf, "/apps/evolution/mail/junk/sa/check_incoming_imap", NULL); + + gtk_widget_set_sensitive (GTK_WIDGET (prefs->check_incoming_imap), check_incoming && !locked); if (prefs->control) evolution_config_control_changed (prefs->control); } @@ -388,6 +392,80 @@ emmp_header_entry_changed (GtkWidget *entry, gpointer user_data) } static void +entry_init (GtkEntry *entry, GConfClient *gconf, const char *key, GCallback changed, void *user_data) +{ + char *string; + + string = gconf_client_get_string (gconf, key, NULL); + gtk_entry_set_text (entry, string ? string : ""); + g_free (string); + + if (changed) + g_signal_connect (entry, "changed", changed, user_data); + + if (!gconf_client_key_is_writable (gconf, key, NULL)) + gtk_widget_set_sensitive ((GtkWidget *) entry, FALSE); +} + +static void +spin_button_init (GtkSpinButton *spin, GConfClient *gconf, const char *key, float div, GCallback value_changed, void *user_data) +{ + GError *err = NULL; + double min, max; + char *mkey, *p; + int val; + + gtk_spin_button_get_range (spin, &min, &max); + + mkey = g_alloca (strlen (key) + 5); + p = g_stpcpy (mkey, key); + *p++ = '_'; + + /* see if the admin locked down the min value */ + strcpy (p, "min"); + val = gconf_client_get_int (gconf, mkey, &err); + if (err == NULL) + g_clear_error (&err); + else + min = (1.0 * val) / div; + + /* see if the admin locked down the max value */ + strcpy (p, "max"); + val = gconf_client_get_int (gconf, mkey, &err); + if (err == NULL) + g_clear_error (&err); + else + max = (1.0 * val) / div; + + gtk_spin_button_set_range (spin, min, max); + + /* get the value */ + val = gconf_client_get_int (gconf, key, NULL); + gtk_spin_button_set_value (spin, (1.0 * val) / div); + + if (value_changed) + g_signal_connect (spin, "value-changed", value_changed, user_data); + + if (!gconf_client_key_is_writable (gconf, key, NULL)) + gtk_widget_set_sensitive ((GtkWidget *) spin, FALSE); +} + +static void +toggle_button_init (GtkToggleButton *toggle, GConfClient *gconf, const char *key, int not, GCallback toggled, void *user_data) +{ + gboolean bool; + + bool = gconf_client_get_bool (gconf, key, NULL); + gtk_toggle_button_set_active (toggle, not ? !bool : bool); + + if (toggled) + g_signal_connect (toggle, "toggled", toggled, user_data); + + if (!gconf_client_key_is_writable (gconf, key, NULL)) + gtk_widget_set_sensitive ((GtkWidget *) toggle, FALSE); +} + +static void em_mailer_prefs_construct (EMMailerPrefs *prefs) { GSList *list, *header_config_list, *header_add_list, *p; @@ -398,7 +476,7 @@ em_mailer_prefs_construct (EMMailerPrefs *prefs) GtkTreeIter iter; char *font, *buf; GladeXML *gui; - gboolean bool, check_incoming; + gboolean locked, check_incoming; int val, i; gui = glade_xml_new (EVOLUTION_GLADEDIR "/mail-config.glade", "preferences_tab", NULL); @@ -417,63 +495,77 @@ em_mailer_prefs_construct (EMMailerPrefs *prefs) /* Message Display */ prefs->timeout_toggle = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "chkMarkTimeout")); - bool = gconf_client_get_bool (prefs->gconf, "/apps/evolution/mail/display/mark_seen", NULL); - gtk_toggle_button_set_active (prefs->timeout_toggle, bool); - g_signal_connect (prefs->timeout_toggle, "toggled", G_CALLBACK (settings_changed), prefs); + toggle_button_init (prefs->timeout_toggle, prefs->gconf, + "/apps/evolution/mail/display/mark_seen", + FALSE, G_CALLBACK (settings_changed), prefs); prefs->timeout = GTK_SPIN_BUTTON (glade_xml_get_widget (gui, "spinMarkTimeout")); - val = gconf_client_get_int (prefs->gconf, "/apps/evolution/mail/display/mark_seen_timeout", NULL); - gtk_spin_button_set_value (prefs->timeout, (1.0 * val) / 1000.0); - g_signal_connect (prefs->timeout, "value-changed", G_CALLBACK (settings_changed), prefs); + spin_button_init (prefs->timeout, prefs->gconf, + "/apps/evolution/mail/display/mark_seen_timeout", + 1000.0, G_CALLBACK (settings_changed), prefs); prefs->charset = GTK_OPTION_MENU (glade_xml_get_widget (gui, "omenuCharset")); buf = gconf_client_get_string (prefs->gconf, "/apps/evolution/mail/display/charset", NULL); menu = e_charset_picker_new (buf && *buf ? buf : e_iconv_locale_charset ()); gtk_option_menu_set_menu (prefs->charset, GTK_WIDGET (menu)); option_menu_connect (prefs->charset, prefs); + if (!gconf_client_key_is_writable (prefs->gconf, "/apps/evolution/mail/display/charset", NULL)) + gtk_widget_set_sensitive ((GtkWidget *) prefs->charset, FALSE); g_free (buf); prefs->citation_highlight = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "chkHighlightCitations")); - bool = gconf_client_get_bool (prefs->gconf, "/apps/evolution/mail/display/mark_citations", NULL); - gtk_toggle_button_set_active (prefs->citation_highlight, bool); - g_signal_connect (prefs->citation_highlight, "toggled", G_CALLBACK (settings_changed), prefs); + toggle_button_init (prefs->citation_highlight, prefs->gconf, + "/apps/evolution/mail/display/mark_citations", + FALSE, G_CALLBACK (settings_changed), prefs); prefs->citation_color = GNOME_COLOR_PICKER (glade_xml_get_widget (gui, "colorpickerHighlightCitations")); buf = gconf_client_get_string (prefs->gconf, "/apps/evolution/mail/display/citation_colour", NULL); colorpicker_set_color (prefs->citation_color, buf ? buf : "#737373"); g_signal_connect (prefs->citation_color, "color-set", G_CALLBACK (color_set), prefs); + if (!gconf_client_key_is_writable (prefs->gconf, "/apps/evolution/mail/display/citation_colour", NULL)) + gtk_widget_set_sensitive ((GtkWidget *) prefs->citation_color, FALSE); g_free (buf); /* Deleting Mail */ prefs->empty_trash = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "chkEmptyTrashOnExit")); - bool = gconf_client_get_bool (prefs->gconf, "/apps/evolution/mail/trash/empty_on_exit", NULL); - gtk_toggle_button_set_active (prefs->empty_trash, bool); - g_signal_connect (prefs->empty_trash, "toggled", G_CALLBACK (settings_changed), prefs); + toggle_button_init (prefs->empty_trash, prefs->gconf, + "/apps/evolution/mail/trash/empty_on_exit", + FALSE, G_CALLBACK (settings_changed), prefs); prefs->confirm_expunge = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "chkConfirmExpunge")); - bool = gconf_client_get_bool (prefs->gconf, "/apps/evolution/mail/prompts/expunge", NULL); - gtk_toggle_button_set_active (prefs->confirm_expunge, bool); - g_signal_connect (prefs->confirm_expunge, "toggled", G_CALLBACK (settings_changed), prefs); + toggle_button_init (prefs->empty_trash, prefs->gconf, + "/apps/evolution/mail/prompts/expunge", + FALSE, G_CALLBACK (settings_changed), prefs); /* New Mail Notification */ + locked = !gconf_client_key_is_writable (prefs->gconf, "/apps/evolution/mail/notify/type", NULL); + val = gconf_client_get_int (prefs->gconf, "/apps/evolution/mail/notify/type", NULL); prefs->notify_not = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "radNotifyNot")); gtk_toggle_button_set_active (prefs->notify_not, val == MAIL_CONFIG_NOTIFY_NOT); g_signal_connect (prefs->notify_not, "toggled", G_CALLBACK (settings_changed), prefs); + if (locked) + gtk_widget_set_sensitive ((GtkWidget *) prefs->notify_not, FALSE); prefs->notify_beep = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "radNotifyBeep")); gtk_toggle_button_set_active (prefs->notify_beep, val == MAIL_CONFIG_NOTIFY_BEEP); g_signal_connect (prefs->notify_beep, "toggled", G_CALLBACK (settings_changed), prefs); + if (locked) + gtk_widget_set_sensitive ((GtkWidget *) prefs->notify_beep, FALSE); prefs->notify_play_sound = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "radNotifyPlaySound")); gtk_toggle_button_set_active (prefs->notify_play_sound, val == MAIL_CONFIG_NOTIFY_PLAY_SOUND); g_signal_connect (prefs->notify_play_sound, "toggled", G_CALLBACK (settings_changed), prefs); + if (locked) + gtk_widget_set_sensitive ((GtkWidget *) prefs->notify_play_sound, FALSE); prefs->notify_sound_file = GNOME_FILE_ENTRY (glade_xml_get_widget (gui, "fileNotifyPlaySound")); buf = gconf_client_get_string (prefs->gconf, "/apps/evolution/mail/notify/sound", NULL); gtk_entry_set_text (GTK_ENTRY (gnome_file_entry_gtk_entry (prefs->notify_sound_file)), buf ? buf : ""); g_signal_connect (gnome_file_entry_gtk_entry (prefs->notify_sound_file), "changed", G_CALLBACK (settings_changed), prefs); + if (!gconf_client_key_is_writable (prefs->gconf, "/apps/evolution/mail/notify/sound", NULL)) + gtk_widget_set_sensitive ((GtkWidget *) prefs->notify_sound_file, FALSE); g_free (buf); /* Mail Fonts */ @@ -481,45 +573,58 @@ em_mailer_prefs_construct (EMMailerPrefs *prefs) prefs->font_fixed = GNOME_FONT_PICKER (glade_xml_get_widget (gui, "radFontFixed")); gnome_font_picker_set_font_name (prefs->font_fixed, font); g_signal_connect (prefs->font_fixed, "font-set", G_CALLBACK (font_changed), prefs); + if (!gconf_client_key_is_writable (prefs->gconf, "/apps/evolution/mail/display/fonts/monospace", NULL)) + gtk_widget_set_sensitive ((GtkWidget *) prefs->font_fixed, FALSE); font = gconf_client_get_string (prefs->gconf, "/apps/evolution/mail/display/fonts/variable", NULL); prefs->font_variable = GNOME_FONT_PICKER (glade_xml_get_widget (gui, "radFontVariable")); gnome_font_picker_set_font_name (prefs->font_variable, font); g_signal_connect (prefs->font_variable, "font-set", G_CALLBACK (font_changed), prefs); - - bool = gconf_client_get_bool (prefs->gconf, "/apps/evolution/mail/display/fonts/use_custom", NULL); + if (!gconf_client_key_is_writable (prefs->gconf, "/apps/evolution/mail/display/fonts/variable", NULL)) + gtk_widget_set_sensitive ((GtkWidget *) prefs->font_variable, FALSE); + prefs->font_share = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "radFontUseSame")); - gtk_toggle_button_set_active (prefs->font_share, !bool); - g_signal_connect (prefs->font_share, "toggled", G_CALLBACK (font_share_changed), prefs); + toggle_button_init (prefs->font_share, prefs->gconf, + "/apps/evolution/mail/display/fonts/use_custom", + TRUE, G_CALLBACK (font_share_changed), prefs); font_share_changed (GTK_WIDGET (prefs->font_share), prefs); /* HTML Mail tab */ /* Loading Images */ + locked = !gconf_client_key_is_writable (prefs->gconf, "/apps/evolution/mail/display/load_http_images", NULL); val = gconf_client_get_int (prefs->gconf, "/apps/evolution/mail/display/load_http_images", NULL); prefs->images_never = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "radImagesNever")); gtk_toggle_button_set_active (prefs->images_never, val == MAIL_CONFIG_HTTP_NEVER); g_signal_connect (prefs->images_never, "toggled", G_CALLBACK (settings_changed), prefs); + if (locked) + gtk_widget_set_sensitive ((GtkWidget *) prefs->images_never, FALSE); prefs->images_sometimes = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "radImagesSometimes")); gtk_toggle_button_set_active (prefs->images_sometimes, val == MAIL_CONFIG_HTTP_SOMETIMES); g_signal_connect (prefs->images_sometimes, "toggled", G_CALLBACK (settings_changed), prefs); + if (locked) + gtk_widget_set_sensitive ((GtkWidget *) prefs->images_sometimes, FALSE); prefs->images_always = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "radImagesAlways")); gtk_toggle_button_set_active (prefs->images_always, val == MAIL_CONFIG_HTTP_ALWAYS); g_signal_connect (prefs->images_always, "toggled", G_CALLBACK (settings_changed), prefs); + if (locked) + gtk_widget_set_sensitive ((GtkWidget *) prefs->images_always, FALSE); prefs->show_animated = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "chkShowAnimatedImages")); - bool = gconf_client_get_bool (prefs->gconf, "/apps/evolution/mail/display/animate_images", NULL); - gtk_toggle_button_set_active (prefs->show_animated, bool); - g_signal_connect (prefs->show_animated, "toggled", G_CALLBACK (settings_changed), prefs); - + toggle_button_init (prefs->show_animated, prefs->gconf, + "/apps/evolution/mail/display/animate_images", + FALSE, G_CALLBACK (settings_changed), prefs); + prefs->prompt_unwanted_html = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "chkPromptWantHTML")); - bool = gconf_client_get_bool (prefs->gconf, "/apps/evolution/mail/prompts/unwanted_html", NULL); - gtk_toggle_button_set_active (prefs->prompt_unwanted_html, bool); - g_signal_connect (prefs->prompt_unwanted_html, "toggled", G_CALLBACK (settings_changed), prefs); + toggle_button_init (prefs->prompt_unwanted_html, prefs->gconf, + "/apps/evolution/mail/prompts/unwanted_html", + FALSE, G_CALLBACK (settings_changed), prefs); + /* Labels... */ + locked = !gconf_client_key_is_writable (prefs->gconf, "/apps/evolution/mail/labels", NULL); i = 0; list = mail_config_get_labels (); while (list != NULL && i < 5) { @@ -530,10 +635,12 @@ em_mailer_prefs_construct (EMMailerPrefs *prefs) widget_name = g_strdup_printf ("txtLabel%d", i); prefs->labels[i].name = GTK_ENTRY (glade_xml_get_widget (gui, widget_name)); + gtk_widget_sensitive ((GtkWidget *) prefs->labels[i].name, !locked); g_free (widget_name); widget_name = g_strdup_printf ("colorLabel%d", i); prefs->labels[i].color = GNOME_COLOR_PICKER (glade_xml_get_widget (gui, widget_name)); + gtk_widget_sensitive ((GtkWidget *) prefs->labels[i].color, !locked); g_free (widget_name); gtk_entry_set_text (prefs->labels[i].name, label->name); @@ -547,13 +654,24 @@ em_mailer_prefs_construct (EMMailerPrefs *prefs) } prefs->restore_labels = GTK_BUTTON (glade_xml_get_widget (gui, "cmdRestoreLabels")); + gtk_widget_sensitive ((GtkWidget *) prefs->restore_labels, !locked); g_signal_connect (prefs->restore_labels, "clicked", G_CALLBACK (restore_labels_clicked), prefs); /* headers */ + locked = !gconf_client_key_is_writable (prefs->gconf, "/apps/evolution/mail/display/headers", NULL); + prefs->add_header = GTK_BUTTON (glade_xml_get_widget (gui, "cmdHeadersAdd")); + gtk_widget_set_sensitive ((GtkWidget *) prefs->add_header, !locked); + prefs->remove_header = GTK_BUTTON (glade_xml_get_widget (gui, "cmdHeadersRemove")); + gtk_widget_set_sensitive ((GtkWidget *) prefs->remove_header, !locked); + prefs->entry_header = GTK_ENTRY (glade_xml_get_widget (gui, "txtHeaders")); + gtk_widget_set_sensitive ((GtkWidget *) prefs->entry_header, !locked); + prefs->header_list = GTK_TREE_VIEW (glade_xml_get_widget (gui, "treeHeaders")); + gtk_widget_set_sensitive ((GtkWidget *) prefs->header_list, !locked); + selection = gtk_tree_view_get_selection (prefs->header_list); g_signal_connect (selection, "changed", G_CALLBACK (emmp_header_list_row_selected), prefs); g_signal_connect (prefs->entry_header, "changed", G_CALLBACK (emmp_header_entry_changed), prefs); @@ -650,25 +768,27 @@ em_mailer_prefs_construct (EMMailerPrefs *prefs) /* Junk prefs */ prefs->check_incoming = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "chkCheckIncomingMail")); - check_incoming = bool = gconf_client_get_bool (prefs->gconf, "/apps/evolution/mail/junk/check_incoming", NULL); - gtk_toggle_button_set_active (prefs->check_incoming, bool); - g_signal_connect (prefs->check_incoming, "toggled", G_CALLBACK (settings_changed), prefs); - + toggle_button_init (prefs->check_incoming, prefs->gconf, + "/apps/evolution/mail/junk/sa/check_incoming", + FALSE, G_CALLBACK (settings_changed), prefs); + + check_incoming = gtk_toggle_button_get_active (prefs->check_incoming); prefs->check_incoming_imap = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "chkDoNotCheckIMAP")); - gtk_widget_set_sensitive (GTK_WIDGET (prefs->check_incoming_imap), check_incoming); - bool = gconf_client_get_bool (prefs->gconf, "/apps/evolution/mail/junk/check_incoming_imap", NULL); - gtk_toggle_button_set_active (prefs->check_incoming_imap, !bool); - g_signal_connect (prefs->check_incoming_imap, "toggled", G_CALLBACK (settings_changed), prefs); - + toggle_button_init (prefs->check_incoming_imap, prefs->gconf, + "/apps/evolution/mail/junk/sa/check_incoming_imap", + TRUE, G_CALLBACK (settings_changed), prefs); + if (!gtk_toggle_button_get_active (prefs->check_incoming)) + gtk_widget_set_sensitive ((GtkWidget *) prefs->check_incoming_imap, FALSE); + prefs->sa_local_tests_only = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "chkSALocalTestsOnly")); - bool = gconf_client_get_bool (prefs->gconf, "/apps/evolution/mail/junk/sa/local_only", NULL); - gtk_toggle_button_set_active (prefs->sa_local_tests_only, bool); - g_signal_connect (prefs->sa_local_tests_only, "toggled", G_CALLBACK (settings_changed), prefs); - + toggle_button_init (prefs->sa_local_tests_only, prefs->gconf, + "/apps/evolution/mail/junk/sa/local_only", + FALSE, G_CALLBACK (settings_changed), prefs); + prefs->sa_use_daemon = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "chkSAUseDaemon")); - bool = gconf_client_get_bool (prefs->gconf, "/apps/evolution/mail/junk/sa/use_daemon", NULL); - gtk_toggle_button_set_active (prefs->sa_use_daemon, bool); - g_signal_connect (prefs->sa_use_daemon, "toggled", G_CALLBACK (settings_changed), prefs); + toggle_button_init (prefs->sa_use_daemon, prefs->gconf, + "/apps/evolution/mail/junk/sa/use_daemon", + FALSE, G_CALLBACK (settings_changed), prefs); } GtkWidget * |