[gedit/wip/spell-checking: 12/13] auto-spell: don't depend on GeditView



commit 3d2ae13f94942ee5b6d4917139a3f403c48c1ee2
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Fri Jul 17 13:16:13 2015 +0200

    auto-spell: don't depend on GeditView
    
    Depend only on GtkTextView, so the code is more easily reusable for
    other text editors.

 plugins/spell/gedit-automatic-spell-checker.c |   20 ++++++++++----------
 plugins/spell/gedit-automatic-spell-checker.h |    6 ++----
 plugins/spell/gedit-spell-plugin.c            |    2 +-
 3 files changed, 13 insertions(+), 15 deletions(-)
---
diff --git a/plugins/spell/gedit-automatic-spell-checker.c b/plugins/spell/gedit-automatic-spell-checker.c
index 256642e..27e263a 100644
--- a/plugins/spell/gedit-automatic-spell-checker.c
+++ b/plugins/spell/gedit-automatic-spell-checker.c
@@ -36,6 +36,8 @@
 struct _GeditAutomaticSpellChecker
 {
        GtkSourceBuffer *buffer;
+
+       /* List of GtkTextView* */
        GSList *views;
 
        GtkTextMark *mark_insert_start;
@@ -55,7 +57,7 @@ struct _GeditAutomaticSpellChecker
 static void gedit_automatic_spell_checker_free_internal (GeditAutomaticSpellChecker *spell);
 
 static void
-view_destroy (GeditView                  *view,
+view_destroy (GtkTextView                *view,
              GeditAutomaticSpellChecker *spell)
 {
        gedit_automatic_spell_checker_detach_view (spell, view);
@@ -927,7 +929,7 @@ gedit_automatic_spell_checker_free_internal (GeditAutomaticSpellChecker *spell)
        list = spell->views;
        while (list != NULL)
        {
-               GeditView *view = GEDIT_VIEW (list->data);
+               GtkTextView *view = GTK_TEXT_VIEW (list->data);
 
                g_signal_handlers_disconnect_matched (G_OBJECT (view),
                                G_SIGNAL_MATCH_DATA,
@@ -949,13 +951,12 @@ gedit_automatic_spell_checker_free_internal (GeditAutomaticSpellChecker *spell)
 
 void
 gedit_automatic_spell_checker_attach_view (GeditAutomaticSpellChecker *spell,
-                                          GeditView                  *view)
+                                          GtkTextView                *view)
 {
        g_return_if_fail (spell != NULL);
-       g_return_if_fail (GEDIT_IS_VIEW (view));
+       g_return_if_fail (GTK_IS_TEXT_VIEW (view));
 
-       g_return_if_fail (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)) ==
-                         GTK_TEXT_BUFFER (spell->buffer));
+       g_return_if_fail (gtk_text_view_get_buffer (view) == GTK_TEXT_BUFFER (spell->buffer));
 
        g_signal_connect (view,
                          "button-press-event",
@@ -979,13 +980,12 @@ gedit_automatic_spell_checker_attach_view (GeditAutomaticSpellChecker *spell,
 
 void
 gedit_automatic_spell_checker_detach_view (GeditAutomaticSpellChecker *spell,
-                                          GeditView                  *view)
+                                          GtkTextView                *view)
 {
        g_return_if_fail (spell != NULL);
-       g_return_if_fail (GEDIT_IS_VIEW (view));
+       g_return_if_fail (GTK_IS_TEXT_VIEW (view));
 
-       g_return_if_fail (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)) ==
-                         GTK_TEXT_BUFFER (spell->buffer));
+       g_return_if_fail (gtk_text_view_get_buffer (view) == GTK_TEXT_BUFFER (spell->buffer));
        g_return_if_fail (spell->views != NULL);
 
        g_signal_handlers_disconnect_matched (G_OBJECT (view),
diff --git a/plugins/spell/gedit-automatic-spell-checker.h b/plugins/spell/gedit-automatic-spell-checker.h
index 8c50960..8dd1280 100644
--- a/plugins/spell/gedit-automatic-spell-checker.h
+++ b/plugins/spell/gedit-automatic-spell-checker.h
@@ -28,8 +28,6 @@
 #define __GEDIT_AUTOMATIC_SPELL_CHECKER_H__
 
 #include <gtksourceview/gtksource.h>
-#include <gedit/gedit-view.h>
-
 #include "gedit-spell-checker.h"
 
 typedef struct _GeditAutomaticSpellChecker GeditAutomaticSpellChecker;
@@ -44,10 +42,10 @@ GeditAutomaticSpellChecker *
 void   gedit_automatic_spell_checker_free              (GeditAutomaticSpellChecker *spell);
 
 void   gedit_automatic_spell_checker_attach_view       (GeditAutomaticSpellChecker *spell,
-                                                        GeditView                  *view);
+                                                        GtkTextView                *view);
 
 void   gedit_automatic_spell_checker_detach_view       (GeditAutomaticSpellChecker *spell,
-                                                        GeditView                  *view);
+                                                        GtkTextView                *view);
 
 void   gedit_automatic_spell_checker_recheck_all       (GeditAutomaticSpellChecker *spell);
 
diff --git a/plugins/spell/gedit-spell-plugin.c b/plugins/spell/gedit-spell-plugin.c
index cecd71f..54c71e5 100644
--- a/plugins/spell/gedit-spell-plugin.c
+++ b/plugins/spell/gedit-spell-plugin.c
@@ -881,7 +881,7 @@ set_auto_spell (GeditWindow   *window,
                if (autospell == NULL)
                {
                        autospell = gedit_automatic_spell_checker_new (GTK_SOURCE_BUFFER (doc), spell);
-                       gedit_automatic_spell_checker_attach_view (autospell, view);
+                       gedit_automatic_spell_checker_attach_view (autospell, GTK_TEXT_VIEW (view));
                        gedit_automatic_spell_checker_recheck_all (autospell);
                }
        }


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