Closes #5006 Option to disable spell check

This commit is contained in:
Eric Gregory 2012-04-05 12:16:45 -07:00
parent 459af216b2
commit 6b511888af
5 changed files with 81 additions and 7 deletions

View file

@ -6,6 +6,9 @@
// Wrapper class for GSettings.
public class Configuration {
public signal void display_preview_changed();
public signal void spell_check_changed();
private Settings settings;
private Settings gnome_interface;
private Settings? indicator_datetime;
@ -49,10 +52,21 @@ public class Configuration {
private const string DISPLAY_PREVIEW_NAME = "display-preview";
public bool display_preview {
get { return settings.get_boolean(DISPLAY_PREVIEW_NAME); }
set { settings.set_boolean(DISPLAY_PREVIEW_NAME, value); display_preview_changed(); }
set {
settings.set_boolean(DISPLAY_PREVIEW_NAME, value);
display_preview_changed();
}
}
public signal void display_preview_changed();
private const string SPELL_CHECK_NAME = "spell-check";
public bool spell_check {
get { return settings.get_boolean(SPELL_CHECK_NAME); }
set {
settings.set_boolean(SPELL_CHECK_NAME, value);
spell_check_changed();
}
}
private const string CLOCK_FORMAT_NAME = "clock-format";
private const string TIME_FORMAT_NAME = "time-format";
public Date.ClockFormat clock_format {

View file

@ -44,6 +44,12 @@
<description>True if we should display a short preview of each message.</description>
</key>
<key name="spell-check" type="b">
<default>true</default>
<summary>enable inline spell checking</summary>
<description>True to spell check while typing.</description>
</key>
</schema>
</schemalist>

View file

@ -180,8 +180,10 @@ public class ComposerWindow : Gtk.Window {
editor.navigation_policy_decision_requested.connect(on_navigation_policy_decision_requested);
editor.new_window_policy_decision_requested.connect(on_navigation_policy_decision_requested);
GearyApplication.instance.config.spell_check_changed.connect(on_spell_check_changed);
WebKit.WebSettings s = new WebKit.WebSettings();
s.enable_spell_checking = true;
s.enable_spell_checking = GearyApplication.instance.config.spell_check;
s.auto_load_images = false;
s.enable_default_context_menu = true;
s.enable_scripts = false;
@ -380,6 +382,10 @@ public class ComposerWindow : Gtk.Window {
message_overlay_label.label = url;
}
private void on_spell_check_changed() {
editor.settings.enable_spell_checking = GearyApplication.instance.config.spell_check;
}
public override bool key_press_event(Gdk.EventKey event) {
bool handled = true;

View file

@ -8,6 +8,7 @@ public class PreferencesDialog : Object {
private Gtk.Dialog dialog;
private Gtk.CheckButton autoselect;
private Gtk.CheckButton display_preview;
private Gtk.CheckButton spell_check;
private Gtk.Button close_button;
private Configuration config;
@ -19,15 +20,18 @@ public class PreferencesDialog : Object {
dialog = builder.get_object("dialog") as Gtk.Dialog;
autoselect = builder.get_object("autoselect") as Gtk.CheckButton;
display_preview = builder.get_object("display_preview") as Gtk.CheckButton;
spell_check = builder.get_object("spell_check") as Gtk.CheckButton;
close_button = builder.get_object("close_button") as Gtk.Button;
// Populate the dialog with our current settings.
autoselect.active = config.autoselect;
display_preview.active = config.display_preview;
spell_check.active = config.spell_check;
// Connect to element signals.
autoselect.toggled.connect(on_autoselect_toggled);
display_preview.toggled.connect(on_display_preview_toggled);
spell_check.toggled.connect(on_spell_check_toggled);
GearyApplication.instance.exiting.connect(on_exit);
}
@ -49,4 +53,9 @@ public class PreferencesDialog : Object {
private void on_display_preview_toggled() {
config.display_preview = display_preview.active;
}
private void on_spell_check_toggled() {
config.spell_check = spell_check.active;
}
}

View file

@ -4,7 +4,6 @@
<object class="GtkDialog" id="dialog">
<property name="can_focus">False</property>
<property name="border_width">5</property>
<property name="modal">False</property>
<property name="window_position">center-on-parent</property>
<property name="type_hint">dialog</property>
<property name="has_resize_grip">False</property>
@ -105,7 +104,7 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">3</property>
<property name="top_attach">2</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
@ -126,6 +125,26 @@
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">3</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_right">5</property>
<property name="margin_top">5</property>
<property name="margin_bottom">5</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Composer</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">4</property>
@ -134,7 +153,27 @@
</packing>
</child>
<child>
<placeholder/>
<object class="GtkCheckButton" id="spell_check">
<property name="label" translatable="yes">_Spell check while typing</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="margin_left">12</property>
<property name="margin_right">5</property>
<property name="margin_top">5</property>
<property name="margin_bottom">5</property>
<property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">5</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
</object>
<packing>