[latexila/wip/gspell] spell: use GspellCheckerDialog



commit febf091f1b9dc99f5200ad7115ca1b35ff1ce935
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Tue Sep 15 12:32:47 2015 +0200

    spell: use GspellCheckerDialog
    
    This feature was not available with GtkSpell.

 src/document_view.vala     |   14 ++++++++++++++
 src/main_window_tools.vala |   10 ++++++++++
 src/ui/ui.xml              |    1 +
 3 files changed, 25 insertions(+), 0 deletions(-)
---
diff --git a/src/document_view.vala b/src/document_view.vala
index 3cd83b6..2e901f5 100644
--- a/src/document_view.vala
+++ b/src/document_view.vala
@@ -174,6 +174,20 @@ public class DocumentView : Gtk.SourceView
         return "\t";
     }
 
+    public void launch_spell_checker_dialog ()
+    {
+        return_if_fail (_spell_checker != null);
+
+        Gspell.Navigator navigator = Gspell.NavigatorGtv.new (this as TextView,
+            _spell_checker);
+
+        Gspell.CheckerDialog dialog =
+            new Gspell.CheckerDialog (this.get_toplevel () as Window, navigator);
+
+        dialog.run ();
+        dialog.destroy ();
+    }
+
     public void set_spell_language ()
     {
         return_if_fail (_spell_checker != null);
diff --git a/src/main_window_tools.vala b/src/main_window_tools.vala
index 04ffa59..6b96191 100644
--- a/src/main_window_tools.vala
+++ b/src/main_window_tools.vala
@@ -26,6 +26,8 @@ public class MainWindowTools
     private const Gtk.ActionEntry[] _action_entries =
     {
         { "Tools", null, N_("_Tools") },
+        { "ToolsSpellCheckerDialog", null, N_("_Check Spelling…"), null,
+            N_("Check the spelling of the current document"), on_spell_checker_dialog },
         { "ToolsSetSpellLanguage", null, N_("_Set Language…"), null,
             N_("Set the language used for the spell checking"), on_set_language }
     };
@@ -70,6 +72,7 @@ public class MainWindowTools
 
         string[] action_names =
         {
+            "ToolsSpellCheckerDialog",
             "ToolsSetSpellLanguage"
         };
 
@@ -82,6 +85,13 @@ public class MainWindowTools
 
     /* Gtk.Action callbacks */
 
+    public void on_spell_checker_dialog (Gtk.Action action)
+    {
+        return_if_fail (_main_window.active_view != null);
+
+        _main_window.active_view.launch_spell_checker_dialog ();
+    }
+
     public void on_set_language (Gtk.Action action)
     {
         return_if_fail (_main_window.active_view != null);
diff --git a/src/ui/ui.xml b/src/ui/ui.xml
index 289b908..f0083d2 100644
--- a/src/ui/ui.xml
+++ b/src/ui/ui.xml
@@ -371,6 +371,7 @@ along with LaTeXila.  If not, see <http://www.gnu.org/licenses/>.
     </menu>
 
     <menu action="Tools">
+      <menuitem action="ToolsSpellCheckerDialog" />
       <menuitem action="ToolsSetSpellLanguage" />
       <menuitem action="ToolsInlineSpellChecker" />
     </menu>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]