[gitg/wip/spellcheck: 10/13] Added basic spell checking support for commit message
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg/wip/spellcheck: 10/13] Added basic spell checking support for commit message
- Date: Sun, 7 Jul 2013 13:30:35 +0000 (UTC)
commit 986eb4b8fd29769e36d44eeaf055d7399c32627a
Author: Jesse van den Kieboom <jessevdk gmail com>
Date: Sun Jul 7 12:39:52 2013 +0200
Added basic spell checking support for commit message
configure.ac | 1 +
data/org.gnome.gitg.gschema.xml.in.in | 6 +++
gitg/Makefile.am | 1 +
gitg/commit/gitg-commit-dialog.vala | 63 ++++++++++++++++++++++++++++++++-
4 files changed, 70 insertions(+), 1 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 5b66fb8..de08f18 100644
--- a/configure.ac
+++ b/configure.ac
@@ -176,6 +176,7 @@ PKG_CHECK_MODULES(GITG, [
gsettings-desktop-schemas
libpeas-1.0 >= $LIBPEAS_REQUIRED_VERSION
libpeas-gtk-1.0 >= $LIBPEAS_GTK_REQUIRED_VERSION
+ gtkspell3-3.0
])
GITG_CFLAGS="$LIBGITG_CFLAGS $GITG_CFLAGS"
diff --git a/data/org.gnome.gitg.gschema.xml.in.in b/data/org.gnome.gitg.gschema.xml.in.in
index 40718c2..688f1a5 100644
--- a/data/org.gnome.gitg.gschema.xml.in.in
+++ b/data/org.gnome.gitg.gschema.xml.in.in
@@ -113,6 +113,12 @@
preference is set to TRUE.
</_description>
</key>
+ <key name="enable-spell-checking" type="b">
+ <default>true</default>
+ </key>
+ <key name="spell-checking-language" type="s">
+ <default>'EN_us'</default>
+ </key>
</schema>
<schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.gitg.preferences.hidden"
path="/org/gnome/gitg/preferences/hidden/">
<key name="sign-tag" type="b">
diff --git a/gitg/Makefile.am b/gitg/Makefile.am
index b433cad..044c863 100644
--- a/gitg/Makefile.am
+++ b/gitg/Makefile.am
@@ -25,6 +25,7 @@ AM_VALAFLAGS = \
--pkg gd-1.0 \
--pkg webkit2gtk-3.0 \
--pkg gtksourceview-3.0 \
+ --pkg GtkSpell-3.0 \
--girdir "$(top_builddir)/libgd" \
--girdir "$(top_builddir)/libgitg" \
--girdir "$(top_builddir)/libgitg-ext" \
diff --git a/gitg/commit/gitg-commit-dialog.vala b/gitg/commit/gitg-commit-dialog.vala
index 900cb14..7eb38ea 100644
--- a/gitg/commit/gitg-commit-dialog.vala
+++ b/gitg/commit/gitg-commit-dialog.vala
@@ -70,6 +70,9 @@ class Dialog : Gtk.Dialog
private Settings? d_message_settings;
private Settings? d_font_settings;
private Settings? d_commit_settings;
+ private bool d_enable_spell_checking;
+ private string d_spell_checking_language;
+ private GtkSpell.Checker? d_spell_checker;
public GtkSource.View source_view_message
{
@@ -159,7 +162,6 @@ class Dialog : Gtk.Dialog
default = true;
}
-
[Notify]
public int right_margin_position
{
@@ -200,6 +202,55 @@ class Dialog : Gtk.Dialog
}
}
+ [Notify]
+ public string spell_checking_language
+ {
+ get { return d_spell_checking_language; }
+
+ set
+ {
+ d_spell_checking_language = value;
+
+ if (d_spell_checker != null)
+ {
+ d_spell_checker.set_language(value);
+ }
+ }
+ }
+
+ [Notify]
+ public bool enable_spell_checking
+ {
+ get { return d_enable_spell_checking; }
+ set
+ {
+ d_enable_spell_checking = value;
+
+ if (d_enable_spell_checking)
+ {
+ if (d_spell_checker == null)
+ {
+ d_spell_checker = new GtkSpell.Checker();
+ d_spell_checker.attach(d_source_view_message);
+
+ d_spell_checker.set_language(d_spell_checking_language);
+
+ d_spell_checker.language_changed.connect(() => {
+ spell_checking_language = d_spell_checker.get_language();
+ });
+ }
+ }
+ else
+ {
+ if (d_spell_checker != null)
+ {
+ d_spell_checker.detach();
+ d_spell_checker = null;
+ }
+ }
+ }
+ }
+
private void load_author_info()
{
if (d_cancel_avatar != null)
@@ -313,6 +364,16 @@ class Dialog : Gtk.Dialog
"subject-margin-position",
SettingsBindFlags.GET);
+ d_message_settings.bind("enable-spell-checking",
+ this,
+ "enable-spell-checking",
+ SettingsBindFlags.GET | SettingsBindFlags.SET);
+
+ d_message_settings.bind("spell-checking-language",
+ this,
+ "spell-checking-language",
+ SettingsBindFlags.GET | SettingsBindFlags.SET);
+
d_constructed = true;
init_message_area();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]