[gtksourceview/wip/chergert/gsv-gtk4: 27/84] words: modernize GtkSourceCompletionWords



commit 00021bc185e9c7f9b5e9d6f5f52b98fc82508562
Author: Christian Hergert <chergert redhat com>
Date:   Thu Jan 9 13:35:13 2020 -0800

    words: modernize GtkSourceCompletionWords
    
     - Use G_DECLARE_ macros
     - Fix various indentation
     - Use get_instance_private()
     - Make various objects final

 .../words/gtksourcecompletionwords.c               | 189 ++++++++++++---------
 .../words/gtksourcecompletionwords.h               |  45 ++---
 .../words/gtksourcecompletionwordsbuffer.c         | 142 ++++++++--------
 .../words/gtksourcecompletionwordsbuffer.h         |  47 ++---
 .../words/gtksourcecompletionwordslibrary.c        |  25 ++-
 .../words/gtksourcecompletionwordslibrary.h        |  77 +++------
 .../words/gtksourcecompletionwordsproposal.c       |  19 +--
 .../words/gtksourcecompletionwordsproposal.h       |  36 +---
 .../words/gtksourcecompletionwordsutils.c          |  13 +-
 .../words/gtksourcecompletionwordsutils.h          |  22 +--
 10 files changed, 266 insertions(+), 349 deletions(-)
---
diff --git a/gtksourceview/completion-providers/words/gtksourcecompletionwords.c 
b/gtksourceview/completion-providers/words/gtksourcecompletionwords.c
index 548d1726..f593a1f7 100644
--- a/gtksourceview/completion-providers/words/gtksourcecompletionwords.c
+++ b/gtksourceview/completion-providers/words/gtksourcecompletionwords.c
@@ -56,7 +56,7 @@ enum
        N_PROPERTIES
 };
 
-struct _GtkSourceCompletionWordsPrivate
+typedef struct
 {
        gchar *name;
        GdkPixbuf *icon;
@@ -80,7 +80,7 @@ struct _GtkSourceCompletionWordsPrivate
        gint interactive_delay;
        gint priority;
        GtkSourceCompletionActivation activation;
-};
+}  GtkSourceCompletionWordsPrivate;
 
 typedef struct
 {
@@ -102,79 +102,88 @@ G_DEFINE_TYPE_WITH_CODE (GtkSourceCompletionWords,
 static gchar *
 gtk_source_completion_words_get_name (GtkSourceCompletionProvider *self)
 {
-       return g_strdup (GTK_SOURCE_COMPLETION_WORDS (self)->priv->name);
+       GtkSourceCompletionWords *words = GTK_SOURCE_COMPLETION_WORDS (self);
+       GtkSourceCompletionWordsPrivate *priv = gtk_source_completion_words_get_instance_private (words);
+
+       return g_strdup (priv->name);
 }
 
 static GdkPixbuf *
 gtk_source_completion_words_get_icon (GtkSourceCompletionProvider *self)
 {
-       return GTK_SOURCE_COMPLETION_WORDS (self)->priv->icon;
+       GtkSourceCompletionWords *words = GTK_SOURCE_COMPLETION_WORDS (self);
+       GtkSourceCompletionWordsPrivate *priv = gtk_source_completion_words_get_instance_private (words);
+
+       return priv->icon;
 }
 
 static void
 population_finished (GtkSourceCompletionWords *words)
 {
-       if (words->priv->idle_id != 0)
+       GtkSourceCompletionWordsPrivate *priv = gtk_source_completion_words_get_instance_private (words);
+
+       if (priv->idle_id != 0)
        {
-               g_source_remove (words->priv->idle_id);
-               words->priv->idle_id = 0;
+               g_source_remove (priv->idle_id);
+               priv->idle_id = 0;
        }
 
-       g_free (words->priv->word);
-       words->priv->word = NULL;
+       g_free (priv->word);
+       priv->word = NULL;
 
-       if (words->priv->context != NULL)
+       if (priv->context != NULL)
        {
-               if (words->priv->cancel_id)
+               if (priv->cancel_id)
                {
-                       g_signal_handler_disconnect (words->priv->context,
-                                                    words->priv->cancel_id);
-                       words->priv->cancel_id = 0;
+                       g_signal_handler_disconnect (priv->context,
+                                                    priv->cancel_id);
+                       priv->cancel_id = 0;
                }
 
-               g_clear_object (&words->priv->context);
+               g_clear_object (&priv->context);
        }
 }
 
 static gboolean
 add_in_idle (GtkSourceCompletionWords *words)
 {
+       GtkSourceCompletionWordsPrivate *priv = gtk_source_completion_words_get_instance_private (words);
        guint idx = 0;
        GList *ret = NULL;
        gboolean finished;
 
-       if (words->priv->populate_iter == NULL)
+       if (priv->populate_iter == NULL)
        {
-               words->priv->populate_iter =
-                       gtk_source_completion_words_library_find_first (words->priv->library,
-                                                                       words->priv->word,
-                                                                       words->priv->word_len);
+               priv->populate_iter =
+                       gtk_source_completion_words_library_find_first (priv->library,
+                                                                       priv->word,
+                                                                       priv->word_len);
        }
 
-       while (idx < words->priv->proposals_batch_size &&
-              words->priv->populate_iter)
+       while (idx < priv->proposals_batch_size &&
+              priv->populate_iter)
        {
                GtkSourceCompletionWordsProposal *proposal =
-                               gtk_source_completion_words_library_get_proposal (words->priv->populate_iter);
+                               gtk_source_completion_words_library_get_proposal (priv->populate_iter);
 
                /* Only add non-exact matches */
                if (strcmp (gtk_source_completion_words_proposal_get_word (proposal),
-                           words->priv->word) != 0)
+                           priv->word) != 0)
                {
                        ret = g_list_prepend (ret, proposal);
                }
 
-               words->priv->populate_iter =
-                               gtk_source_completion_words_library_find_next (words->priv->populate_iter,
-                                                                              words->priv->word,
-                                                                              words->priv->word_len);
+               priv->populate_iter =
+                               gtk_source_completion_words_library_find_next (priv->populate_iter,
+                                                                              priv->word,
+                                                                              priv->word_len);
                ++idx;
        }
 
        ret = g_list_reverse (ret);
-       finished = words->priv->populate_iter == NULL;
+       finished = priv->populate_iter == NULL;
 
-       gtk_source_completion_context_add_proposals (words->priv->context,
+       gtk_source_completion_context_add_proposals (priv->context,
                                                     GTK_SOURCE_COMPLETION_PROVIDER (words),
                                                     ret,
                                                     finished);
@@ -183,7 +192,7 @@ add_in_idle (GtkSourceCompletionWords *words)
 
        if (finished)
        {
-               gtk_source_completion_words_library_unlock (words->priv->library);
+               gtk_source_completion_words_library_unlock (priv->library);
                population_finished (words);
        }
 
@@ -215,6 +224,7 @@ gtk_source_completion_words_populate (GtkSourceCompletionProvider *provider,
                                       GtkSourceCompletionContext  *context)
 {
        GtkSourceCompletionWords *words = GTK_SOURCE_COMPLETION_WORDS (provider);
+       GtkSourceCompletionWordsPrivate *priv = gtk_source_completion_words_get_instance_private (words);
        GtkSourceCompletionActivation activation;
        GtkTextIter iter;
        gchar *word;
@@ -225,8 +235,8 @@ gtk_source_completion_words_populate (GtkSourceCompletionProvider *provider,
                return;
        }
 
-       g_free (words->priv->word);
-       words->priv->word = NULL;
+       g_free (priv->word);
+       priv->word = NULL;
 
        word = get_word_at_iter (&iter);
 
@@ -234,29 +244,29 @@ gtk_source_completion_words_populate (GtkSourceCompletionProvider *provider,
 
        if (word == NULL ||
            (activation == GTK_SOURCE_COMPLETION_ACTIVATION_INTERACTIVE &&
-            g_utf8_strlen (word, -1) < (glong)words->priv->minimum_word_size))
+            g_utf8_strlen (word, -1) < (glong)priv->minimum_word_size))
        {
                g_free (word);
                gtk_source_completion_context_add_proposals (context, provider, NULL, TRUE);
                return;
        }
 
-       words->priv->cancel_id =
+       priv->cancel_id =
                g_signal_connect_swapped (context,
                                          "cancelled",
                                          G_CALLBACK (population_finished),
                                          provider);
 
-       words->priv->context = g_object_ref (context);
+       priv->context = g_object_ref (context);
 
-       words->priv->word = word;
-       words->priv->word_len = strlen (word);
+       priv->word = word;
+       priv->word_len = strlen (word);
 
        /* Do first right now */
        if (add_in_idle (words))
        {
-               gtk_source_completion_words_library_lock (words->priv->library);
-               words->priv->idle_id = gdk_threads_add_idle ((GSourceFunc)add_in_idle,
+               gtk_source_completion_words_library_lock (priv->library);
+               priv->idle_id = gdk_threads_add_idle ((GSourceFunc)add_in_idle,
                                                             words);
        }
 }
@@ -265,22 +275,23 @@ static void
 gtk_source_completion_words_dispose (GObject *object)
 {
        GtkSourceCompletionWords *provider = GTK_SOURCE_COMPLETION_WORDS (object);
+       GtkSourceCompletionWordsPrivate *priv = gtk_source_completion_words_get_instance_private (provider);
 
        population_finished (provider);
 
-       while (provider->priv->buffers != NULL)
+       while (priv->buffers != NULL)
        {
-               BufferBinding *binding = provider->priv->buffers->data;
+               BufferBinding *binding = priv->buffers->data;
                GtkTextBuffer *buffer = gtk_source_completion_words_buffer_get_buffer (binding->buffer);
 
                gtk_source_completion_words_unregister (provider, buffer);
        }
 
-       g_free (provider->priv->name);
-       provider->priv->name = NULL;
+       g_free (priv->name);
+       priv->name = NULL;
 
-       g_clear_object (&provider->priv->icon);
-       g_clear_object (&provider->priv->library);
+       g_clear_object (&priv->icon);
+       g_clear_object (&priv->library);
 
        G_OBJECT_CLASS (gtk_source_completion_words_parent_class)->dispose (object);
 }
@@ -288,26 +299,28 @@ gtk_source_completion_words_dispose (GObject *object)
 static void
 update_buffers_batch_size (GtkSourceCompletionWords *words)
 {
+       GtkSourceCompletionWordsPrivate *priv = gtk_source_completion_words_get_instance_private (words);
        GList *item;
 
-       for (item = words->priv->buffers; item != NULL; item = g_list_next (item))
+       for (item = priv->buffers; item != NULL; item = g_list_next (item))
        {
                BufferBinding *binding = item->data;
                gtk_source_completion_words_buffer_set_scan_batch_size (binding->buffer,
-                                                                       words->priv->scan_batch_size);
+                                                                       priv->scan_batch_size);
        }
 }
 
 static void
 update_buffers_minimum_word_size (GtkSourceCompletionWords *words)
 {
+       GtkSourceCompletionWordsPrivate *priv = gtk_source_completion_words_get_instance_private (words);
        GList *item;
 
-       for (item = words->priv->buffers; item != NULL; item = g_list_next (item))
+       for (item = priv->buffers; item != NULL; item = g_list_next (item))
        {
                BufferBinding *binding = (BufferBinding *)item->data;
                gtk_source_completion_words_buffer_set_minimum_word_size (binding->buffer,
-                                                                         words->priv->minimum_word_size);
+                                                                         priv->minimum_word_size);
        }
 }
 
@@ -318,48 +331,49 @@ gtk_source_completion_words_set_property (GObject      *object,
                                           GParamSpec   *pspec)
 {
        GtkSourceCompletionWords *self = GTK_SOURCE_COMPLETION_WORDS (object);
+       GtkSourceCompletionWordsPrivate *priv = gtk_source_completion_words_get_instance_private (self);
 
        switch (prop_id)
        {
                case PROP_NAME:
-                       g_free (self->priv->name);
-                       self->priv->name = g_value_dup_string (value);
+                       g_free (priv->name);
+                       priv->name = g_value_dup_string (value);
 
-                       if (self->priv->name == NULL)
+                       if (priv->name == NULL)
                        {
-                               self->priv->name = g_strdup (_("Document Words"));
+                               priv->name = g_strdup (_("Document Words"));
                        }
                        break;
 
                case PROP_ICON:
-                       g_clear_object (&self->priv->icon);
-                       self->priv->icon = g_value_dup_object (value);
+                       g_clear_object (&priv->icon);
+                       priv->icon = g_value_dup_object (value);
                        break;
 
                case PROP_PROPOSALS_BATCH_SIZE:
-                       self->priv->proposals_batch_size = g_value_get_uint (value);
+                       priv->proposals_batch_size = g_value_get_uint (value);
                        break;
 
                case PROP_SCAN_BATCH_SIZE:
-                       self->priv->scan_batch_size = g_value_get_uint (value);
+                       priv->scan_batch_size = g_value_get_uint (value);
                        update_buffers_batch_size (self);
                        break;
 
                case PROP_MINIMUM_WORD_SIZE:
-                       self->priv->minimum_word_size = g_value_get_uint (value);
+                       priv->minimum_word_size = g_value_get_uint (value);
                        update_buffers_minimum_word_size (self);
                        break;
 
                case PROP_INTERACTIVE_DELAY:
-                       self->priv->interactive_delay = g_value_get_int (value);
+                       priv->interactive_delay = g_value_get_int (value);
                        break;
 
                case PROP_PRIORITY:
-                       self->priv->priority = g_value_get_int (value);
+                       priv->priority = g_value_get_int (value);
                        break;
 
                case PROP_ACTIVATION:
-                       self->priv->activation = g_value_get_flags (value);
+                       priv->activation = g_value_get_flags (value);
                        break;
 
                default:
@@ -375,39 +389,40 @@ gtk_source_completion_words_get_property (GObject    *object,
                                           GParamSpec *pspec)
 {
        GtkSourceCompletionWords *self = GTK_SOURCE_COMPLETION_WORDS (object);
+       GtkSourceCompletionWordsPrivate *priv = gtk_source_completion_words_get_instance_private (self);
 
        switch (prop_id)
        {
                case PROP_NAME:
-                       g_value_set_string (value, self->priv->name);
+                       g_value_set_string (value, priv->name);
                        break;
 
                case PROP_ICON:
-                       g_value_set_object (value, self->priv->icon);
+                       g_value_set_object (value, priv->icon);
                        break;
 
                case PROP_PROPOSALS_BATCH_SIZE:
-                       g_value_set_uint (value, self->priv->proposals_batch_size);
+                       g_value_set_uint (value, priv->proposals_batch_size);
                        break;
 
                case PROP_SCAN_BATCH_SIZE:
-                       g_value_set_uint (value, self->priv->scan_batch_size);
+                       g_value_set_uint (value, priv->scan_batch_size);
                        break;
 
                case PROP_MINIMUM_WORD_SIZE:
-                       g_value_set_uint (value, self->priv->minimum_word_size);
+                       g_value_set_uint (value, priv->minimum_word_size);
                        break;
 
                case PROP_INTERACTIVE_DELAY:
-                       g_value_set_int (value, self->priv->interactive_delay);
+                       g_value_set_int (value, priv->interactive_delay);
                        break;
 
                case PROP_PRIORITY:
-                       g_value_set_int (value, self->priv->priority);
+                       g_value_set_int (value, priv->priority);
                        break;
 
                case PROP_ACTIVATION:
-                       g_value_set_flags (value, self->priv->activation);
+                       g_value_set_flags (value, priv->activation);
                        break;
 
                default:
@@ -530,19 +545,28 @@ gtk_source_completion_words_get_start_iter (GtkSourceCompletionProvider *provide
 static gint
 gtk_source_completion_words_get_interactive_delay (GtkSourceCompletionProvider *provider)
 {
-       return GTK_SOURCE_COMPLETION_WORDS (provider)->priv->interactive_delay;
+       GtkSourceCompletionWords *words = GTK_SOURCE_COMPLETION_WORDS (provider);
+       GtkSourceCompletionWordsPrivate *priv = gtk_source_completion_words_get_instance_private (words);
+
+       return priv->interactive_delay;
 }
 
 static gint
 gtk_source_completion_words_get_priority (GtkSourceCompletionProvider *provider)
 {
-       return GTK_SOURCE_COMPLETION_WORDS (provider)->priv->priority;
+       GtkSourceCompletionWords *words = GTK_SOURCE_COMPLETION_WORDS (provider);
+       GtkSourceCompletionWordsPrivate *priv = gtk_source_completion_words_get_instance_private (words);
+
+       return priv->priority;
 }
 
 static GtkSourceCompletionActivation
 gtk_source_completion_words_get_activation (GtkSourceCompletionProvider *provider)
 {
-       return GTK_SOURCE_COMPLETION_WORDS (provider)->priv->activation;
+       GtkSourceCompletionWords *words = GTK_SOURCE_COMPLETION_WORDS (provider);
+       GtkSourceCompletionWordsPrivate *priv = gtk_source_completion_words_get_instance_private (words);
+
+       return priv->activation;
 }
 
 static void
@@ -560,9 +584,9 @@ gtk_source_completion_words_iface_init (GtkSourceCompletionProviderIface *iface)
 static void
 gtk_source_completion_words_init (GtkSourceCompletionWords *self)
 {
-       self->priv = gtk_source_completion_words_get_instance_private (self);
+       GtkSourceCompletionWordsPrivate *priv = gtk_source_completion_words_get_instance_private (self);
 
-       self->priv->library = gtk_source_completion_words_library_new ();
+       priv->library = gtk_source_completion_words_library_new ();
 }
 
 /**
@@ -585,8 +609,9 @@ gtk_source_completion_words_new (const gchar *name,
 static void
 buffer_destroyed (BufferBinding *binding)
 {
-       binding->words->priv->buffers = g_list_remove (binding->words->priv->buffers,
-                                                      binding);
+       GtkSourceCompletionWordsPrivate *priv = gtk_source_completion_words_get_instance_private 
(binding->words);
+
+       priv->buffers = g_list_remove (priv->buffers, binding);
        g_object_unref (binding->buffer);
        g_slice_free (BufferBinding, binding);
 }
@@ -602,6 +627,7 @@ void
 gtk_source_completion_words_register (GtkSourceCompletionWords *words,
                                       GtkTextBuffer            *buffer)
 {
+       GtkSourceCompletionWordsPrivate *priv = gtk_source_completion_words_get_instance_private (words);
        GtkSourceCompletionWordsBuffer *buf;
        BufferBinding *binding;
 
@@ -615,14 +641,14 @@ gtk_source_completion_words_register (GtkSourceCompletionWords *words,
                return;
        }
 
-       buf = gtk_source_completion_words_buffer_new (words->priv->library,
+       buf = gtk_source_completion_words_buffer_new (priv->library,
                                                      buffer);
 
        gtk_source_completion_words_buffer_set_scan_batch_size (buf,
-                                                               words->priv->scan_batch_size);
+                                                               priv->scan_batch_size);
 
        gtk_source_completion_words_buffer_set_minimum_word_size (buf,
-                                                                 words->priv->minimum_word_size);
+                                                                 priv->minimum_word_size);
 
        binding = g_slice_new (BufferBinding);
        binding->words = words;
@@ -633,8 +659,7 @@ gtk_source_completion_words_register (GtkSourceCompletionWords *words,
                                binding,
                                (GDestroyNotify)buffer_destroyed);
 
-       words->priv->buffers = g_list_prepend (words->priv->buffers,
-                                              binding);
+       priv->buffers = g_list_prepend (priv->buffers, binding);
 }
 
 /**
diff --git a/gtksourceview/completion-providers/words/gtksourcecompletionwords.h 
b/gtksourceview/completion-providers/words/gtksourcecompletionwords.h
index 499cd1e3..73c892c8 100644
--- a/gtksourceview/completion-providers/words/gtksourcecompletionwords.h
+++ b/gtksourceview/completion-providers/words/gtksourcecompletionwords.h
@@ -18,8 +18,7 @@
  * along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef GTK_SOURCE_COMPLETION_WORDS_H
-#define GTK_SOURCE_COMPLETION_WORDS_H
+#pragma once
 
 #if !defined (GTK_SOURCE_H_INSIDE) && !defined (GTK_SOURCE_COMPILATION)
 #error "Only <gtksourceview/gtksource.h> can be included directly."
@@ -30,43 +29,27 @@
 
 G_BEGIN_DECLS
 
-#define GTK_SOURCE_TYPE_COMPLETION_WORDS               (gtk_source_completion_words_get_type ())
-#define GTK_SOURCE_COMPLETION_WORDS(obj)               (G_TYPE_CHECK_INSTANCE_CAST ((obj), 
GTK_SOURCE_TYPE_COMPLETION_WORDS, GtkSourceCompletionWords))
-#define GTK_SOURCE_COMPLETION_WORDS_CLASS(klass)       (G_TYPE_CHECK_CLASS_CAST ((klass), 
GTK_SOURCE_TYPE_COMPLETION_WORDS, GtkSourceCompletionWordsClass))
-#define GTK_SOURCE_IS_COMPLETION_WORDS(obj)            (G_TYPE_CHECK_INSTANCE_TYPE ((obj), 
GTK_SOURCE_TYPE_COMPLETION_WORDS))
-#define GTK_SOURCE_IS_COMPLETION_WORDS_CLASS(klass)    (G_TYPE_CHECK_CLASS_TYPE ((klass), 
GTK_SOURCE_TYPE_COMPLETION_WORDS))
-#define GTK_SOURCE_COMPLETION_WORDS_GET_CLASS(obj)     (G_TYPE_INSTANCE_GET_CLASS ((obj), 
GTK_SOURCE_TYPE_COMPLETION_WORDS, GtkSourceCompletionWordsClass))
+#define GTK_SOURCE_TYPE_COMPLETION_WORDS (gtk_source_completion_words_get_type())
 
-typedef struct _GtkSourceCompletionWords               GtkSourceCompletionWords;
-typedef struct _GtkSourceCompletionWordsClass          GtkSourceCompletionWordsClass;
-typedef struct _GtkSourceCompletionWordsPrivate                GtkSourceCompletionWordsPrivate;
-
-struct _GtkSourceCompletionWords {
-       GObject parent;
-
-       GtkSourceCompletionWordsPrivate *priv;
-};
-
-struct _GtkSourceCompletionWordsClass {
+struct _GtkSourceCompletionWordsClass
+{
        GObjectClass parent_class;
+
+       /*< private >*/
+       gpointer _reserved[10];
 };
 
 GTK_SOURCE_AVAILABLE_IN_ALL
-GType          gtk_source_completion_words_get_type    (void) G_GNUC_CONST;
+G_DECLARE_DERIVABLE_TYPE (GtkSourceCompletionWords, gtk_source_completion_words, GTK_SOURCE, 
COMPLETION_WORDS, GObject)
 
 GTK_SOURCE_AVAILABLE_IN_ALL
-GtkSourceCompletionWords *
-               gtk_source_completion_words_new         (const gchar              *name,
-                                                        GdkPixbuf                *icon);
-
+GtkSourceCompletionWords *gtk_source_completion_words_new        (const gchar              *name,
+                                                                  GdkPixbuf                *icon);
 GTK_SOURCE_AVAILABLE_IN_ALL
-void           gtk_source_completion_words_register    (GtkSourceCompletionWords *words,
-                                                         GtkTextBuffer            *buffer);
-
+void                      gtk_source_completion_words_register   (GtkSourceCompletionWords *words,
+                                                                  GtkTextBuffer            *buffer);
 GTK_SOURCE_AVAILABLE_IN_ALL
-void           gtk_source_completion_words_unregister  (GtkSourceCompletionWords *words,
-                                                         GtkTextBuffer            *buffer);
+void                      gtk_source_completion_words_unregister (GtkSourceCompletionWords *words,
+                                                                  GtkTextBuffer            *buffer);
 
 G_END_DECLS
-
-#endif /* GTK_SOURCE_COMPLETION_WORDS_H */
diff --git a/gtksourceview/completion-providers/words/gtksourcecompletionwordsbuffer.c 
b/gtksourceview/completion-providers/words/gtksourcecompletionwordsbuffer.c
index a03e03a9..6d9a3e32 100644
--- a/gtksourceview/completion-providers/words/gtksourcecompletionwordsbuffer.c
+++ b/gtksourceview/completion-providers/words/gtksourcecompletionwordsbuffer.c
@@ -37,8 +37,10 @@ typedef struct
        guint use_count;
 } ProposalCache;
 
-struct _GtkSourceCompletionWordsBufferPrivate
+struct _GtkSourceCompletionWordsBuffer
 {
+       GObject parent_instance;
+
        GtkSourceCompletionWordsLibrary *library;
        GtkTextBuffer *buffer;
 
@@ -52,7 +54,7 @@ struct _GtkSourceCompletionWordsBufferPrivate
        GHashTable *words;
 };
 
-G_DEFINE_TYPE_WITH_PRIVATE (GtkSourceCompletionWordsBuffer, gtk_source_completion_words_buffer, 
G_TYPE_OBJECT)
+G_DEFINE_TYPE (GtkSourceCompletionWordsBuffer, gtk_source_completion_words_buffer, G_TYPE_OBJECT)
 
 static ProposalCache *
 proposal_cache_new (GtkSourceCompletionWordsProposal *proposal)
@@ -80,7 +82,7 @@ remove_proposal_cache (const gchar                    *key,
 
        for (i = 0; i < cache->use_count; ++i)
        {
-               gtk_source_completion_words_library_remove_word (buffer->priv->library,
+               gtk_source_completion_words_library_remove_word (buffer->library,
                                                                 cache->proposal);
        }
 }
@@ -88,11 +90,11 @@ remove_proposal_cache (const gchar                    *key,
 static void
 remove_all_words (GtkSourceCompletionWordsBuffer *buffer)
 {
-       g_hash_table_foreach (buffer->priv->words,
+       g_hash_table_foreach (buffer->words,
                              (GHFunc)remove_proposal_cache,
                              buffer);
 
-       g_hash_table_remove_all (buffer->priv->words);
+       g_hash_table_remove_all (buffer->words);
 }
 
 static void
@@ -101,29 +103,29 @@ gtk_source_completion_words_buffer_dispose (GObject *object)
        GtkSourceCompletionWordsBuffer *buffer =
                GTK_SOURCE_COMPLETION_WORDS_BUFFER (object);
 
-       if (buffer->priv->words != NULL)
+       if (buffer->words != NULL)
        {
                remove_all_words (buffer);
 
-               g_hash_table_destroy (buffer->priv->words);
-               buffer->priv->words = NULL;
+               g_hash_table_destroy (buffer->words);
+               buffer->words = NULL;
        }
 
-       if (buffer->priv->batch_scan_id != 0)
+       if (buffer->batch_scan_id != 0)
        {
-               g_source_remove (buffer->priv->batch_scan_id);
-               buffer->priv->batch_scan_id = 0;
+               g_source_remove (buffer->batch_scan_id);
+               buffer->batch_scan_id = 0;
        }
 
-       if (buffer->priv->initiate_scan_id != 0)
+       if (buffer->initiate_scan_id != 0)
        {
-               g_source_remove (buffer->priv->initiate_scan_id);
-               buffer->priv->initiate_scan_id = 0;
+               g_source_remove (buffer->initiate_scan_id);
+               buffer->initiate_scan_id = 0;
        }
 
-       g_clear_object (&buffer->priv->scan_region);
-       g_clear_object (&buffer->priv->buffer);
-       g_clear_object (&buffer->priv->library);
+       g_clear_object (&buffer->scan_region);
+       g_clear_object (&buffer->buffer);
+       g_clear_object (&buffer->library);
 
        G_OBJECT_CLASS (gtk_source_completion_words_buffer_parent_class)->dispose (object);
 }
@@ -139,15 +141,13 @@ gtk_source_completion_words_buffer_class_init (GtkSourceCompletionWordsBufferCla
 static void
 gtk_source_completion_words_buffer_init (GtkSourceCompletionWordsBuffer *self)
 {
-       self->priv = gtk_source_completion_words_buffer_get_instance_private (self);
-
-       self->priv->scan_batch_size = 20;
-       self->priv->minimum_word_size = 3;
+       self->scan_batch_size = 20;
+       self->minimum_word_size = 3;
 
-       self->priv->words = g_hash_table_new_full (g_str_hash,
-                                                  g_str_equal,
-                                                  (GDestroyNotify)g_free,
-                                                  (GDestroyNotify)proposal_cache_free);
+       self->words = g_hash_table_new_full (g_str_hash,
+                                            g_str_equal,
+                                            (GDestroyNotify)g_free,
+                                            (GDestroyNotify)proposal_cache_free);
 }
 
 /* Starts the scanning at @start, and ends at the line end or @end. So at most
@@ -183,12 +183,12 @@ scan_line (GtkSourceCompletionWordsBuffer *buffer,
 
        _gtk_source_completion_words_utils_check_scan_region (start, &text_end);
 
-       text = gtk_text_buffer_get_text (buffer->priv->buffer,
+       text = gtk_text_buffer_get_text (buffer->buffer,
                                         start,
                                         &text_end,
                                         FALSE);
 
-       words = _gtk_source_completion_words_utils_scan_words (text, buffer->priv->minimum_word_size);
+       words = _gtk_source_completion_words_utils_scan_words (text, buffer->minimum_word_size);
 
        g_free (text);
        return words;
@@ -198,7 +198,7 @@ static void
 remove_word (GtkSourceCompletionWordsBuffer *buffer,
             const gchar                    *word)
 {
-       ProposalCache *cache = g_hash_table_lookup (buffer->priv->words, word);
+       ProposalCache *cache = g_hash_table_lookup (buffer->words, word);
 
        if (cache == NULL)
        {
@@ -207,14 +207,14 @@ remove_word (GtkSourceCompletionWordsBuffer *buffer,
                return;
        }
 
-       gtk_source_completion_words_library_remove_word (buffer->priv->library,
+       gtk_source_completion_words_library_remove_word (buffer->library,
                                                         cache->proposal);
 
        --cache->use_count;
 
        if (cache->use_count == 0)
        {
-               g_hash_table_remove (buffer->priv->words, word);
+               g_hash_table_remove (buffer->words, word);
        }
 }
 
@@ -229,10 +229,10 @@ add_words (GtkSourceCompletionWordsBuffer *buffer,
                GtkSourceCompletionWordsProposal *proposal;
                ProposalCache *cache;
 
-               proposal = gtk_source_completion_words_library_add_word (buffer->priv->library,
+               proposal = gtk_source_completion_words_library_add_word (buffer->library,
                                                                         item->data);
 
-               cache = g_hash_table_lookup (buffer->priv->words,
+               cache = g_hash_table_lookup (buffer->words,
                                             item->data);
 
                if (cache != NULL)
@@ -244,7 +244,7 @@ add_words (GtkSourceCompletionWordsBuffer *buffer,
                {
                        /* Hash table takes over ownership of the word string */
                        cache = proposal_cache_new (proposal);
-                       g_hash_table_insert (buffer->priv->words,
+                       g_hash_table_insert (buffer->words,
                                             item->data,
                                             cache);
                }
@@ -301,15 +301,15 @@ scan_region (GtkSourceCompletionWordsBuffer *buffer,
 static gboolean
 idle_scan_regions (GtkSourceCompletionWordsBuffer *buffer)
 {
-       guint nb_remaining_lines = buffer->priv->scan_batch_size;
+       guint nb_remaining_lines = buffer->scan_batch_size;
        GtkSourceRegionIter region_iter;
        GtkTextIter start;
        GtkTextIter stop;
 
-       gtk_text_buffer_get_start_iter (buffer->priv->buffer, &start);
+       gtk_text_buffer_get_start_iter (buffer->buffer, &start);
        stop = start;
 
-       gtk_source_region_get_start_region_iter (buffer->priv->scan_region, &region_iter);
+       gtk_source_region_get_start_region_iter (buffer->scan_region, &region_iter);
 
        while (nb_remaining_lines > 0 &&
               !gtk_source_region_iter_is_end (&region_iter))
@@ -330,13 +330,13 @@ idle_scan_regions (GtkSourceCompletionWordsBuffer *buffer)
                gtk_source_region_iter_next (&region_iter);
        }
 
-       gtk_source_region_subtract_subregion (buffer->priv->scan_region,
+       gtk_source_region_subtract_subregion (buffer->scan_region,
                                              &start,
                                              &stop);
 
-       if (gtk_source_region_is_empty (buffer->priv->scan_region))
+       if (gtk_source_region_is_empty (buffer->scan_region))
        {
-               buffer->priv->batch_scan_id = 0;
+               buffer->batch_scan_id = 0;
                return G_SOURCE_REMOVE;
        }
 
@@ -346,10 +346,10 @@ idle_scan_regions (GtkSourceCompletionWordsBuffer *buffer)
 static gboolean
 initiate_scan (GtkSourceCompletionWordsBuffer *buffer)
 {
-       buffer->priv->initiate_scan_id = 0;
+       buffer->initiate_scan_id = 0;
 
        /* Add the batch scanner */
-       buffer->priv->batch_scan_id =
+       buffer->batch_scan_id =
                g_timeout_add_full (G_PRIORITY_LOW,
                                    BATCH_SCAN_TIMEOUT,
                                    (GSourceFunc)idle_scan_regions,
@@ -362,10 +362,10 @@ initiate_scan (GtkSourceCompletionWordsBuffer *buffer)
 static void
 install_initiate_scan (GtkSourceCompletionWordsBuffer *buffer)
 {
-       if (buffer->priv->batch_scan_id == 0 &&
-           buffer->priv->initiate_scan_id == 0)
+       if (buffer->batch_scan_id == 0 &&
+           buffer->initiate_scan_id == 0)
        {
-               buffer->priv->initiate_scan_id =
+               buffer->initiate_scan_id =
                        g_timeout_add_seconds_full (G_PRIORITY_LOW,
                                                    INITIATE_SCAN_TIMEOUT,
                                                    (GSourceFunc)initiate_scan,
@@ -427,12 +427,12 @@ compute_remove_region (GtkSourceCompletionWordsBuffer *buffer,
                       const GtkTextIter              *start,
                       const GtkTextIter              *end)
 {
-       GtkSourceRegion *remove_region = gtk_source_region_new (buffer->priv->buffer);
+       GtkSourceRegion *remove_region = gtk_source_region_new (buffer->buffer);
        GtkSourceRegionIter region_iter;
 
        gtk_source_region_add_subregion (remove_region, start, end);
 
-       gtk_source_region_get_start_region_iter (buffer->priv->scan_region, &region_iter);
+       gtk_source_region_get_start_region_iter (buffer->scan_region, &region_iter);
 
        while (!gtk_source_region_iter_is_end (&region_iter))
        {
@@ -484,7 +484,7 @@ add_to_scan_region (GtkSourceCompletionWordsBuffer *buffer,
 
        _gtk_source_completion_words_utils_adjust_region (&start_iter, &end_iter);
 
-       gtk_source_region_add_subregion (buffer->priv->scan_region,
+       gtk_source_region_add_subregion (buffer->scan_region,
                                         &start_iter,
                                         &end_iter);
 
@@ -538,8 +538,8 @@ on_delete_range_before_cb (GtkTextBuffer                  *text_buffer,
        {
                remove_all_words (buffer);
 
-               g_clear_object (&buffer->priv->scan_region);
-               buffer->priv->scan_region = gtk_source_region_new (text_buffer);
+               g_clear_object (&buffer->scan_region);
+               buffer->scan_region = gtk_source_region_new (text_buffer);
        }
        else
        {
@@ -571,11 +571,11 @@ scan_all_buffer (GtkSourceCompletionWordsBuffer *buffer)
        GtkTextIter start;
        GtkTextIter end;
 
-       gtk_text_buffer_get_bounds (buffer->priv->buffer,
+       gtk_text_buffer_get_bounds (buffer->buffer,
                                    &start,
                                    &end);
 
-       gtk_source_region_add_subregion (buffer->priv->scan_region,
+       gtk_source_region_add_subregion (buffer->scan_region,
                                         &start,
                                         &end);
 
@@ -585,25 +585,25 @@ scan_all_buffer (GtkSourceCompletionWordsBuffer *buffer)
 static void
 connect_buffer (GtkSourceCompletionWordsBuffer *buffer)
 {
-       g_signal_connect_object (buffer->priv->buffer,
+       g_signal_connect_object (buffer->buffer,
                                 "insert-text",
                                 G_CALLBACK (on_insert_text_before_cb),
                                 buffer,
                                 0);
 
-       g_signal_connect_object (buffer->priv->buffer,
+       g_signal_connect_object (buffer->buffer,
                                 "insert-text",
                                 G_CALLBACK (on_insert_text_after_cb),
                                 buffer,
                                 G_CONNECT_AFTER);
 
-       g_signal_connect_object (buffer->priv->buffer,
+       g_signal_connect_object (buffer->buffer,
                                 "delete-range",
                                 G_CALLBACK (on_delete_range_before_cb),
                                 buffer,
                                 0);
 
-       g_signal_connect_object (buffer->priv->buffer,
+       g_signal_connect_object (buffer->buffer,
                                 "delete-range",
                                 G_CALLBACK (on_delete_range_after_cb),
                                 buffer,
@@ -615,23 +615,23 @@ connect_buffer (GtkSourceCompletionWordsBuffer *buffer)
 static void
 on_library_lock (GtkSourceCompletionWordsBuffer *buffer)
 {
-       if (buffer->priv->batch_scan_id != 0)
+       if (buffer->batch_scan_id != 0)
        {
-               g_source_remove (buffer->priv->batch_scan_id);
-               buffer->priv->batch_scan_id = 0;
+               g_source_remove (buffer->batch_scan_id);
+               buffer->batch_scan_id = 0;
        }
 
-       if (buffer->priv->initiate_scan_id != 0)
+       if (buffer->initiate_scan_id != 0)
        {
-               g_source_remove (buffer->priv->initiate_scan_id);
-               buffer->priv->initiate_scan_id = 0;
+               g_source_remove (buffer->initiate_scan_id);
+               buffer->initiate_scan_id = 0;
        }
 }
 
 static void
 on_library_unlock (GtkSourceCompletionWordsBuffer *buffer)
 {
-       if (!gtk_source_region_is_empty (buffer->priv->scan_region))
+       if (!gtk_source_region_is_empty (buffer->scan_region))
        {
                install_initiate_scan (buffer);
        }
@@ -648,18 +648,18 @@ gtk_source_completion_words_buffer_new (GtkSourceCompletionWordsLibrary *library
 
        ret = g_object_new (GTK_SOURCE_TYPE_COMPLETION_WORDS_BUFFER, NULL);
 
-       ret->priv->library = g_object_ref (library);
-       ret->priv->buffer = g_object_ref (buffer);
+       ret->library = g_object_ref (library);
+       ret->buffer = g_object_ref (buffer);
 
-       ret->priv->scan_region = gtk_source_region_new (buffer);
+       ret->scan_region = gtk_source_region_new (buffer);
 
-       g_signal_connect_object (ret->priv->library,
+       g_signal_connect_object (ret->library,
                                 "lock",
                                 G_CALLBACK (on_library_lock),
                                 ret,
                                 G_CONNECT_SWAPPED);
 
-       g_signal_connect_object (ret->priv->library,
+       g_signal_connect_object (ret->library,
                                 "unlock",
                                 G_CALLBACK (on_library_unlock),
                                 ret,
@@ -675,7 +675,7 @@ gtk_source_completion_words_buffer_get_buffer (GtkSourceCompletionWordsBuffer *b
 {
        g_return_val_if_fail (GTK_SOURCE_IS_COMPLETION_WORDS_BUFFER (buffer), NULL);
 
-       return buffer->priv->buffer;
+       return buffer->buffer;
 }
 
 void
@@ -685,7 +685,7 @@ gtk_source_completion_words_buffer_set_scan_batch_size (GtkSourceCompletionWords
        g_return_if_fail (GTK_SOURCE_IS_COMPLETION_WORDS_BUFFER (buffer));
        g_return_if_fail (size != 0);
 
-       buffer->priv->scan_batch_size = size;
+       buffer->scan_batch_size = size;
 }
 
 void
@@ -695,9 +695,9 @@ gtk_source_completion_words_buffer_set_minimum_word_size (GtkSourceCompletionWor
        g_return_if_fail (GTK_SOURCE_IS_COMPLETION_WORDS_BUFFER (buffer));
        g_return_if_fail (size != 0);
 
-       if (buffer->priv->minimum_word_size != size)
+       if (buffer->minimum_word_size != size)
        {
-               buffer->priv->minimum_word_size = size;
+               buffer->minimum_word_size = size;
                remove_all_words (buffer);
                scan_all_buffer (buffer);
        }
diff --git a/gtksourceview/completion-providers/words/gtksourcecompletionwordsbuffer.h 
b/gtksourceview/completion-providers/words/gtksourcecompletionwordsbuffer.h
index 3d350e0a..21b8b7a8 100644
--- a/gtksourceview/completion-providers/words/gtksourcecompletionwordsbuffer.h
+++ b/gtksourceview/completion-providers/words/gtksourcecompletionwordsbuffer.h
@@ -18,8 +18,7 @@
  * along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef GTK_SOURCE_COMPLETION_WORDS_BUFFER_H
-#define GTK_SOURCE_COMPLETION_WORDS_BUFFER_H
+#pragma once
 
 #include <gtk/gtk.h>
 
@@ -27,47 +26,21 @@
 
 G_BEGIN_DECLS
 
-#define GTK_SOURCE_TYPE_COMPLETION_WORDS_BUFFER                        
(gtk_source_completion_words_buffer_get_type ())
-#define GTK_SOURCE_COMPLETION_WORDS_BUFFER(obj)                        (G_TYPE_CHECK_INSTANCE_CAST ((obj), 
GTK_SOURCE_TYPE_COMPLETION_WORDS_BUFFER, GtkSourceCompletionWordsBuffer))
-#define GTK_SOURCE_COMPLETION_WORDS_BUFFER_CONST(obj)          (G_TYPE_CHECK_INSTANCE_CAST ((obj), 
GTK_SOURCE_TYPE_COMPLETION_WORDS_BUFFER, GtkSourceCompletionWordsBuffer const))
-#define GTK_SOURCE_COMPLETION_WORDS_BUFFER_CLASS(klass)                (G_TYPE_CHECK_CLASS_CAST ((klass), 
GTK_SOURCE_TYPE_COMPLETION_WORDS_BUFFER, GtkSourceCompletionWordsBufferClass))
-#define GTK_SOURCE_IS_COMPLETION_WORDS_BUFFER(obj)             (G_TYPE_CHECK_INSTANCE_TYPE ((obj), 
GTK_SOURCE_TYPE_COMPLETION_WORDS_BUFFER))
-#define GTK_SOURCE_IS_COMPLETION_WORDS_BUFFER_CLASS(klass)     (G_TYPE_CHECK_CLASS_TYPE ((klass), 
GTK_SOURCE_TYPE_COMPLETION_WORDS_BUFFER))
-#define GTK_SOURCE_COMPLETION_WORDS_BUFFER_GET_CLASS(obj)      (G_TYPE_INSTANCE_GET_CLASS ((obj), 
GTK_SOURCE_TYPE_COMPLETION_WORDS_BUFFER, GtkSourceCompletionWordsBufferClass))
-
-typedef struct _GtkSourceCompletionWordsBuffer                 GtkSourceCompletionWordsBuffer;
-typedef struct _GtkSourceCompletionWordsBufferClass            GtkSourceCompletionWordsBufferClass;
-typedef struct _GtkSourceCompletionWordsBufferPrivate          GtkSourceCompletionWordsBufferPrivate;
-
-struct _GtkSourceCompletionWordsBuffer {
-       GObject parent;
-
-       GtkSourceCompletionWordsBufferPrivate *priv;
-};
-
-struct _GtkSourceCompletionWordsBufferClass {
-       GObjectClass parent_class;
-};
+#define GTK_SOURCE_TYPE_COMPLETION_WORDS_BUFFER (gtk_source_completion_words_buffer_get_type())
 
 G_GNUC_INTERNAL
-GType           gtk_source_completion_words_buffer_get_type                    (void) G_GNUC_CONST;
+G_DECLARE_FINAL_TYPE (GtkSourceCompletionWordsBuffer, gtk_source_completion_words_buffer, GTK_SOURCE, 
COMPLETION_WORDS_BUFFER, GObject)
 
 G_GNUC_INTERNAL
-GtkSourceCompletionWordsBuffer *
-                gtk_source_completion_words_buffer_new                         
(GtkSourceCompletionWordsLibrary *library,
-                                                                                GtkTextBuffer                
   *buffer);
-
+GtkSourceCompletionWordsBuffer *gtk_source_completion_words_buffer_new                   
(GtkSourceCompletionWordsLibrary *library,
+                                                                                          GtkTextBuffer      
             *buffer);
 G_GNUC_INTERNAL
-GtkTextBuffer  *gtk_source_completion_words_buffer_get_buffer                  
(GtkSourceCompletionWordsBuffer  *buffer);
-
+GtkTextBuffer                  *gtk_source_completion_words_buffer_get_buffer            
(GtkSourceCompletionWordsBuffer  *buffer);
 G_GNUC_INTERNAL
-void            gtk_source_completion_words_buffer_set_scan_batch_size         
(GtkSourceCompletionWordsBuffer  *buffer,
-                                                                                guint                        
    size);
-
+void                            gtk_source_completion_words_buffer_set_scan_batch_size   
(GtkSourceCompletionWordsBuffer  *buffer,
+                                                                                          guint              
              size);
 G_GNUC_INTERNAL
-void            gtk_source_completion_words_buffer_set_minimum_word_size       
(GtkSourceCompletionWordsBuffer  *buffer,
-                                                                                guint                        
    size);
+void                            gtk_source_completion_words_buffer_set_minimum_word_size 
(GtkSourceCompletionWordsBuffer  *buffer,
+                                                                                          guint              
              size);
 
 G_END_DECLS
-
-#endif /* GTK_SOURCE_COMPLETION_WORDS_BUFFER_H */
diff --git a/gtksourceview/completion-providers/words/gtksourcecompletionwordslibrary.c 
b/gtksourceview/completion-providers/words/gtksourcecompletionwordslibrary.c
index 3f39f8ac..90345332 100644
--- a/gtksourceview/completion-providers/words/gtksourcecompletionwordslibrary.c
+++ b/gtksourceview/completion-providers/words/gtksourcecompletionwordslibrary.c
@@ -32,22 +32,23 @@ enum
        N_SIGNALS
 };
 
-struct _GtkSourceCompletionWordsLibraryPrivate
+struct _GtkSourceCompletionWordsLibrary
 {
+       GObject parent_instance;
        GSequence *store;
        gboolean locked;
 };
 
 static guint signals[N_SIGNALS];
 
-G_DEFINE_TYPE_WITH_PRIVATE (GtkSourceCompletionWordsLibrary, gtk_source_completion_words_library, 
G_TYPE_OBJECT)
+G_DEFINE_TYPE (GtkSourceCompletionWordsLibrary, gtk_source_completion_words_library, G_TYPE_OBJECT)
 
 static void
 gtk_source_completion_words_library_finalize (GObject *object)
 {
        GtkSourceCompletionWordsLibrary *library = GTK_SOURCE_COMPLETION_WORDS_LIBRARY (object);
 
-       g_sequence_free (library->priv->store);
+       g_sequence_free (library->store);
 
        G_OBJECT_CLASS (gtk_source_completion_words_library_parent_class)->finalize (object);
 }
@@ -79,9 +80,7 @@ gtk_source_completion_words_library_class_init (GtkSourceCompletionWordsLibraryC
 static void
 gtk_source_completion_words_library_init (GtkSourceCompletionWordsLibrary *self)
 {
-       self->priv = gtk_source_completion_words_library_get_instance_private (self);
-
-       self->priv->store = g_sequence_new ((GDestroyNotify)g_object_unref);
+       self->store = g_sequence_new ((GDestroyNotify)g_object_unref);
 }
 
 GtkSourceCompletionWordsLibrary *
@@ -167,7 +166,7 @@ gtk_source_completion_words_library_find_first (GtkSourceCompletionWordsLibrary
 
        proposal = gtk_source_completion_words_proposal_new (word);
 
-       iter = g_sequence_lookup (library->priv->store,
+       iter = g_sequence_lookup (library->store,
                                  proposal,
                                  (GCompareDataFunc)compare_prefix,
                                  GINT_TO_POINTER (len));
@@ -220,7 +219,7 @@ gtk_source_completion_words_library_find (GtkSourceCompletionWordsLibrary  *libr
        g_return_val_if_fail (GTK_SOURCE_IS_COMPLETION_WORDS_LIBRARY (library), NULL);
        g_return_val_if_fail (GTK_SOURCE_IS_COMPLETION_WORDS_PROPOSAL (proposal), NULL);
 
-       return g_sequence_lookup (library->priv->store,
+       return g_sequence_lookup (library->store,
                                  proposal,
                                  (GCompareDataFunc)compare_full,
                                  NULL);
@@ -267,7 +266,7 @@ gtk_source_completion_words_library_add_word (GtkSourceCompletionWordsLibrary *l
                return iter_proposal;
        }
 
-       if (library->priv->locked)
+       if (library->locked)
        {
                g_object_unref (proposal);
                return NULL;
@@ -278,7 +277,7 @@ gtk_source_completion_words_library_add_word (GtkSourceCompletionWordsLibrary *l
                          G_CALLBACK (on_proposal_unused),
                          library);
 
-       g_sequence_insert_sorted (library->priv->store,
+       g_sequence_insert_sorted (library->store,
                                  proposal,
                                  (GCompareDataFunc)compare_full,
                                  NULL);
@@ -301,7 +300,7 @@ gtk_source_completion_words_library_lock (GtkSourceCompletionWordsLibrary *libra
 {
        g_return_if_fail (GTK_SOURCE_IS_COMPLETION_WORDS_LIBRARY (library));
 
-       library->priv->locked = TRUE;
+       library->locked = TRUE;
        g_signal_emit (library, signals[LOCK], 0);
 }
 
@@ -310,7 +309,7 @@ gtk_source_completion_words_library_unlock (GtkSourceCompletionWordsLibrary *lib
 {
        g_return_if_fail (GTK_SOURCE_IS_COMPLETION_WORDS_LIBRARY (library));
 
-       library->priv->locked = FALSE;
+       library->locked = FALSE;
        g_signal_emit (library, signals[UNLOCK], 0);
 }
 
@@ -319,5 +318,5 @@ gtk_source_completion_words_library_is_locked (GtkSourceCompletionWordsLibrary *
 {
        g_return_val_if_fail (GTK_SOURCE_IS_COMPLETION_WORDS_LIBRARY (library), TRUE);
 
-       return library->priv->locked;
+       return library->locked;
 }
diff --git a/gtksourceview/completion-providers/words/gtksourcecompletionwordslibrary.h 
b/gtksourceview/completion-providers/words/gtksourcecompletionwordslibrary.h
index 71474512..b1f375b5 100644
--- a/gtksourceview/completion-providers/words/gtksourcecompletionwordslibrary.h
+++ b/gtksourceview/completion-providers/words/gtksourcecompletionwordslibrary.h
@@ -18,82 +18,49 @@
  * along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef GTK_SOURCE_COMPLETION_WORDS_LIBRARY_H
-#define GTK_SOURCE_COMPLETION_WORDS_LIBRARY_H
+#pragma once
 
 #include <glib-object.h>
 #include "gtksourcecompletionwordsproposal.h"
 
 G_BEGIN_DECLS
 
-#define GTK_SOURCE_TYPE_COMPLETION_WORDS_LIBRARY                       
(gtk_source_completion_words_library_get_type ())
-#define GTK_SOURCE_COMPLETION_WORDS_LIBRARY(obj)                       (G_TYPE_CHECK_INSTANCE_CAST ((obj), 
GTK_SOURCE_TYPE_COMPLETION_WORDS_LIBRARY, GtkSourceCompletionWordsLibrary))
-#define GTK_SOURCE_COMPLETION_WORDS_LIBRARY_CONST(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), 
GTK_SOURCE_TYPE_COMPLETION_WORDS_LIBRARY, GtkSourceCompletionWordsLibrary const))
-#define GTK_SOURCE_COMPLETION_WORDS_LIBRARY_CLASS(klass)               (G_TYPE_CHECK_CLASS_CAST ((klass), 
GTK_SOURCE_TYPE_COMPLETION_WORDS_LIBRARY, GtkSourceCompletionWordsLibraryClass))
-#define GTK_SOURCE_IS_COMPLETION_WORDS_LIBRARY(obj)                    (G_TYPE_CHECK_INSTANCE_TYPE ((obj), 
GTK_SOURCE_TYPE_COMPLETION_WORDS_LIBRARY))
-#define GTK_SOURCE_IS_COMPLETION_WORDS_LIBRARY_CLASS(klass)            (G_TYPE_CHECK_CLASS_TYPE ((klass), 
GTK_SOURCE_TYPE_COMPLETION_WORDS_LIBRARY))
-#define GTK_SOURCE_COMPLETION_WORDS_LIBRARY_GET_CLASS(obj)             (G_TYPE_INSTANCE_GET_CLASS ((obj), 
GTK_SOURCE_TYPE_COMPLETION_WORDS_LIBRARY, GtkSourceCompletionWordsLibraryClass))
+#define GTK_SOURCE_TYPE_COMPLETION_WORDS_LIBRARY (gtk_source_completion_words_library_get_type())
 
-typedef struct _GtkSourceCompletionWordsLibrary                        GtkSourceCompletionWordsLibrary;
-typedef struct _GtkSourceCompletionWordsLibraryClass           GtkSourceCompletionWordsLibraryClass;
-typedef struct _GtkSourceCompletionWordsLibraryPrivate         GtkSourceCompletionWordsLibraryPrivate;
-
-struct _GtkSourceCompletionWordsLibrary {
-       GObject parent;
-
-       GtkSourceCompletionWordsLibraryPrivate *priv;
-};
-
-struct _GtkSourceCompletionWordsLibraryClass {
+struct _GtkSourceCompletionWordsLibraryClass
+{
        GObjectClass parent_class;
 };
 
 GTK_SOURCE_INTERNAL
-GType           gtk_source_completion_words_library_get_type           (void) G_GNUC_CONST;
+G_DECLARE_FINAL_TYPE (GtkSourceCompletionWordsLibrary, gtk_source_completion_words_library, GTK_SOURCE, 
COMPLETION_WORDS_LIBRARY, GObject)
 
 GTK_SOURCE_INTERNAL
-GtkSourceCompletionWordsLibrary *
-                gtk_source_completion_words_library_new                (void);
-
-/* Finding */
+GtkSourceCompletionWordsLibrary  *gtk_source_completion_words_library_new          (void);
 GTK_SOURCE_INTERNAL
-GSequenceIter  *gtk_source_completion_words_library_find               (GtkSourceCompletionWordsLibrary  
*library,
-                                                                        GtkSourceCompletionWordsProposal 
*proposal);
-
+GSequenceIter                    *gtk_source_completion_words_library_find         
(GtkSourceCompletionWordsLibrary  *library,
+                                                                                    
GtkSourceCompletionWordsProposal *proposal);
 GTK_SOURCE_INTERNAL
-GSequenceIter  *gtk_source_completion_words_library_find_first         (GtkSourceCompletionWordsLibrary  
*library,
-                                                                        const gchar                      
*word,
-                                                                        gint                              
len);
-
+GSequenceIter                    *gtk_source_completion_words_library_find_first   
(GtkSourceCompletionWordsLibrary  *library,
+                                                                                    const gchar              
        *word,
+                                                                                    gint                     
         len);
 GTK_SOURCE_INTERNAL
-GSequenceIter  *gtk_source_completion_words_library_find_next          (GSequenceIter                    
*iter,
-                                                                        const gchar                      
*word,
-                                                                        gint                              
len);
-
-/* Getting */
+GSequenceIter                    *gtk_source_completion_words_library_find_next    (GSequenceIter            
        *iter,
+                                                                                    const gchar              
        *word,
+                                                                                    gint                     
         len);
 GTK_SOURCE_INTERNAL
-GtkSourceCompletionWordsProposal *
-                gtk_source_completion_words_library_get_proposal       (GSequenceIter                    
*iter);
-
-/* Adding/removing */
+GtkSourceCompletionWordsProposal *gtk_source_completion_words_library_get_proposal (GSequenceIter            
        *iter);
 GTK_SOURCE_INTERNAL
-GtkSourceCompletionWordsProposal *
-                gtk_source_completion_words_library_add_word           (GtkSourceCompletionWordsLibrary  
*library,
-                                                                        const gchar                      
*word);
-
+GtkSourceCompletionWordsProposal *gtk_source_completion_words_library_add_word     
(GtkSourceCompletionWordsLibrary  *library,
+                                                                                    const gchar              
        *word);
 GTK_SOURCE_INTERNAL
-void            gtk_source_completion_words_library_remove_word        (GtkSourceCompletionWordsLibrary  
*library,
-                                                                        GtkSourceCompletionWordsProposal 
*proposal);
-
+void                              gtk_source_completion_words_library_remove_word  
(GtkSourceCompletionWordsLibrary  *library,
+                                                                                    
GtkSourceCompletionWordsProposal *proposal);
 GTK_SOURCE_INTERNAL
-gboolean        gtk_source_completion_words_library_is_locked          (GtkSourceCompletionWordsLibrary  
*library);
-
+gboolean                          gtk_source_completion_words_library_is_locked    
(GtkSourceCompletionWordsLibrary  *library);
 GTK_SOURCE_INTERNAL
-void            gtk_source_completion_words_library_lock               (GtkSourceCompletionWordsLibrary  
*library);
-
+void                              gtk_source_completion_words_library_lock         
(GtkSourceCompletionWordsLibrary  *library);
 GTK_SOURCE_INTERNAL
-void            gtk_source_completion_words_library_unlock             (GtkSourceCompletionWordsLibrary  
*library);
+void                              gtk_source_completion_words_library_unlock       
(GtkSourceCompletionWordsLibrary  *library);
 
 G_END_DECLS
-
-#endif /* GTK_SOURCE_COMPLETION_WORDS_LIBRARY_H */
diff --git a/gtksourceview/completion-providers/words/gtksourcecompletionwordsproposal.c 
b/gtksourceview/completion-providers/words/gtksourcecompletionwordsproposal.c
index f69ab060..c7b14233 100644
--- a/gtksourceview/completion-providers/words/gtksourcecompletionwordsproposal.c
+++ b/gtksourceview/completion-providers/words/gtksourcecompletionwordsproposal.c
@@ -22,8 +22,9 @@
 
 #include "gtksourcecompletionwordsproposal.h"
 
-struct _GtkSourceCompletionWordsProposalPrivate
+struct _GtkSourceCompletionWordsProposal
 {
+       GObject parent_instance;
        gchar *word;
        gint use_count;
 };
@@ -41,14 +42,13 @@ static void gtk_source_completion_proposal_iface_init (gpointer g_iface, gpointe
 G_DEFINE_TYPE_WITH_CODE (GtkSourceCompletionWordsProposal,
                         gtk_source_completion_words_proposal,
                         G_TYPE_OBJECT,
-                        G_ADD_PRIVATE (GtkSourceCompletionWordsProposal)
                         G_IMPLEMENT_INTERFACE (GTK_SOURCE_TYPE_COMPLETION_PROPOSAL,
                                                gtk_source_completion_proposal_iface_init))
 
 static gchar *
 gtk_source_completion_words_proposal_get_text (GtkSourceCompletionProposal *proposal)
 {
-       return g_strdup (GTK_SOURCE_COMPLETION_WORDS_PROPOSAL(proposal)->priv->word);
+       return g_strdup (GTK_SOURCE_COMPLETION_WORDS_PROPOSAL(proposal)->word);
 }
 
 static void
@@ -68,7 +68,7 @@ gtk_source_completion_words_proposal_finalize (GObject *object)
        GtkSourceCompletionWordsProposal *proposal;
 
        proposal = GTK_SOURCE_COMPLETION_WORDS_PROPOSAL (object);
-       g_free (proposal->priv->word);
+       g_free (proposal->word);
 
        G_OBJECT_CLASS (gtk_source_completion_words_proposal_parent_class)->finalize (object);
 }
@@ -92,8 +92,7 @@ gtk_source_completion_words_proposal_class_init (GtkSourceCompletionWordsProposa
 static void
 gtk_source_completion_words_proposal_init (GtkSourceCompletionWordsProposal *self)
 {
-       self->priv = gtk_source_completion_words_proposal_get_instance_private (self);
-       self->priv->use_count = 1;
+       self->use_count = 1;
 }
 
 GtkSourceCompletionWordsProposal *
@@ -102,7 +101,7 @@ gtk_source_completion_words_proposal_new (const gchar *word)
        GtkSourceCompletionWordsProposal *proposal =
                g_object_new (GTK_SOURCE_TYPE_COMPLETION_WORDS_PROPOSAL, NULL);
 
-       proposal->priv->word = g_strdup (word);
+       proposal->word = g_strdup (word);
        return proposal;
 }
 
@@ -111,7 +110,7 @@ gtk_source_completion_words_proposal_use (GtkSourceCompletionWordsProposal *prop
 {
        g_return_if_fail (GTK_SOURCE_IS_COMPLETION_WORDS_PROPOSAL (proposal));
 
-       g_atomic_int_inc (&proposal->priv->use_count);
+       g_atomic_int_inc (&proposal->use_count);
 }
 
 void
@@ -119,7 +118,7 @@ gtk_source_completion_words_proposal_unuse (GtkSourceCompletionWordsProposal *pr
 {
        g_return_if_fail (GTK_SOURCE_IS_COMPLETION_WORDS_PROPOSAL (proposal));
 
-       if (g_atomic_int_dec_and_test (&proposal->priv->use_count))
+       if (g_atomic_int_dec_and_test (&proposal->use_count))
        {
                g_signal_emit (proposal, signals[UNUSED], 0);
        }
@@ -129,6 +128,6 @@ const gchar *
 gtk_source_completion_words_proposal_get_word (GtkSourceCompletionWordsProposal *proposal)
 {
        g_return_val_if_fail (GTK_SOURCE_IS_COMPLETION_WORDS_PROPOSAL (proposal), NULL);
-       return proposal->priv->word;
+       return proposal->word;
 }
 
diff --git a/gtksourceview/completion-providers/words/gtksourcecompletionwordsproposal.h 
b/gtksourceview/completion-providers/words/gtksourcecompletionwordsproposal.h
index 117eabaa..0273f1da 100644
--- a/gtksourceview/completion-providers/words/gtksourcecompletionwordsproposal.h
+++ b/gtksourceview/completion-providers/words/gtksourcecompletionwordsproposal.h
@@ -28,43 +28,19 @@
 
 G_BEGIN_DECLS
 
-#define GTK_SOURCE_TYPE_COMPLETION_WORDS_PROPOSAL                      
(gtk_source_completion_words_proposal_get_type ())
-#define GTK_SOURCE_COMPLETION_WORDS_PROPOSAL(obj)                      (G_TYPE_CHECK_INSTANCE_CAST ((obj), 
GTK_SOURCE_TYPE_COMPLETION_WORDS_PROPOSAL, GtkSourceCompletionWordsProposal))
-#define GTK_SOURCE_COMPLETION_WORDS_PROPOSAL_CONST(obj)                        (G_TYPE_CHECK_INSTANCE_CAST 
((obj), GTK_SOURCE_TYPE_COMPLETION_WORDS_PROPOSAL, GtkSourceCompletionWordsProposal const))
-#define GTK_SOURCE_COMPLETION_WORDS_PROPOSAL_CLASS(klass)              (G_TYPE_CHECK_CLASS_CAST ((klass), 
GTK_SOURCE_TYPE_COMPLETION_WORDS_PROPOSAL, GtkSourceCompletionWordsProposalClass))
-#define GTK_SOURCE_IS_COMPLETION_WORDS_PROPOSAL(obj)                   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), 
GTK_SOURCE_TYPE_COMPLETION_WORDS_PROPOSAL))
-#define GTK_SOURCE_IS_COMPLETION_WORDS_PROPOSAL_CLASS(klass)           (G_TYPE_CHECK_CLASS_TYPE ((klass), 
GTK_SOURCE_TYPE_COMPLETION_WORDS_PROPOSAL))
-#define GTK_SOURCE_COMPLETION_WORDS_PROPOSAL_GET_CLASS(obj)            (G_TYPE_INSTANCE_GET_CLASS ((obj), 
GTK_SOURCE_TYPE_COMPLETION_WORDS_PROPOSAL, GtkSourceCompletionWordsProposalClass))
-
-typedef struct _GtkSourceCompletionWordsProposal               GtkSourceCompletionWordsProposal;
-typedef struct _GtkSourceCompletionWordsProposalClass          GtkSourceCompletionWordsProposalClass;
-typedef struct _GtkSourceCompletionWordsProposalPrivate                
GtkSourceCompletionWordsProposalPrivate;
-
-struct _GtkSourceCompletionWordsProposal {
-       GObject parent;
-
-       GtkSourceCompletionWordsProposalPrivate *priv;
-};
-
-struct _GtkSourceCompletionWordsProposalClass {
-       GObjectClass parent_class;
-};
+#define GTK_SOURCE_TYPE_COMPLETION_WORDS_PROPOSAL (gtk_source_completion_words_proposal_get_type())
 
 GTK_SOURCE_INTERNAL
-GType           gtk_source_completion_words_proposal_get_type  (void) G_GNUC_CONST;
+G_DECLARE_FINAL_TYPE (GtkSourceCompletionWordsProposal, gtk_source_completion_words_proposal, GTK_SOURCE, 
COMPLETION_WORDS_PROPOSAL, GObject)
 
 GTK_SOURCE_INTERNAL
-GtkSourceCompletionWordsProposal *
-                gtk_source_completion_words_proposal_new       (const gchar                      *word);
-
+GtkSourceCompletionWordsProposal *gtk_source_completion_words_proposal_new      (const gchar                 
     *word);
 GTK_SOURCE_INTERNAL
-const gchar    *gtk_source_completion_words_proposal_get_word  (GtkSourceCompletionWordsProposal *proposal);
-
+const gchar                      *gtk_source_completion_words_proposal_get_word 
(GtkSourceCompletionWordsProposal *proposal);
 GTK_SOURCE_INTERNAL
-void            gtk_source_completion_words_proposal_use       (GtkSourceCompletionWordsProposal *proposal);
-
+void                              gtk_source_completion_words_proposal_use      
(GtkSourceCompletionWordsProposal *proposal);
 GTK_SOURCE_INTERNAL
-void            gtk_source_completion_words_proposal_unuse     (GtkSourceCompletionWordsProposal *proposal);
+void                              gtk_source_completion_words_proposal_unuse    
(GtkSourceCompletionWordsProposal *proposal);
 
 G_END_DECLS
 
diff --git a/gtksourceview/completion-providers/words/gtksourcecompletionwordsutils.c 
b/gtksourceview/completion-providers/words/gtksourcecompletionwordsutils.c
index c76d5583..0ef95bf8 100644
--- a/gtksourceview/completion-providers/words/gtksourcecompletionwordsutils.c
+++ b/gtksourceview/completion-providers/words/gtksourcecompletionwordsutils.c
@@ -21,9 +21,10 @@
 
 #include "config.h"
 
-#include "gtksourcecompletionwordsutils.h"
 #include <string.h>
 
+#include "gtksourcecompletionwordsutils.h"
+
 /* Here, we work on strings. It is more efficient than working with
  * GtkTextIters to traverse the text (~3x faster). Both techniques are equally
  * difficult to implement.
@@ -51,8 +52,8 @@ valid_start_char (gunichar ch)
  */
 static gboolean
 find_next_word (gchar *text,
-               guint *start_idx,
-               guint *end_idx)
+                guint *start_idx,
+                guint *end_idx)
 {
        gchar *cur_char;
 
@@ -102,7 +103,7 @@ find_next_word (gchar *text,
  */
 GSList *
 _gtk_source_completion_words_utils_scan_words (gchar *text,
-                                              guint  minimum_word_size)
+                                               guint  minimum_word_size)
 {
        GSList *words = NULL;
        guint start_idx = 0;
@@ -182,7 +183,7 @@ _gtk_source_completion_words_utils_get_end_word (gchar *text)
  */
 void
 _gtk_source_completion_words_utils_adjust_region (GtkTextIter *start,
-                                                 GtkTextIter *end)
+                                                  GtkTextIter *end)
 {
        g_return_if_fail (gtk_text_iter_compare (start, end) <= 0);
 
@@ -237,7 +238,7 @@ iter_inside_word (const GtkTextIter *iter)
  */
 void
 _gtk_source_completion_words_utils_check_scan_region (const GtkTextIter *start,
-                                                     const GtkTextIter *end)
+                                                      const GtkTextIter *end)
 {
        g_return_if_fail (gtk_text_iter_compare (start, end) <= 0);
 
diff --git a/gtksourceview/completion-providers/words/gtksourcecompletionwordsutils.h 
b/gtksourceview/completion-providers/words/gtksourcecompletionwordsutils.h
index 4fe4ab9a..0c1828f2 100644
--- a/gtksourceview/completion-providers/words/gtksourcecompletionwordsutils.h
+++ b/gtksourceview/completion-providers/words/gtksourcecompletionwordsutils.h
@@ -19,28 +19,22 @@
  * along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef GTK_SOURCE_COMPLETION_WORDS_UTILS_H
-#define GTK_SOURCE_COMPLETION_WORDS_UTILS_H
+#pragma once
 
 #include <gtk/gtk.h>
 
 G_BEGIN_DECLS
 
 G_GNUC_INTERNAL
-GSList         *_gtk_source_completion_words_utils_scan_words          (gchar *text,
-                                                                        guint  minimum_word_size);
-
+GSList *_gtk_source_completion_words_utils_scan_words        (gchar             *text,
+                                                              guint              minimum_word_size);
 G_GNUC_INTERNAL
-gchar          *_gtk_source_completion_words_utils_get_end_word        (gchar *text);
-
+gchar  *_gtk_source_completion_words_utils_get_end_word      (gchar             *text);
 G_GNUC_INTERNAL
-void            _gtk_source_completion_words_utils_adjust_region       (GtkTextIter *start,
-                                                                        GtkTextIter *end);
-
+void    _gtk_source_completion_words_utils_adjust_region     (GtkTextIter       *start,
+                                                              GtkTextIter       *end);
 G_GNUC_INTERNAL
-void            _gtk_source_completion_words_utils_check_scan_region   (const GtkTextIter *start,
-                                                                        const GtkTextIter *end);
+void    _gtk_source_completion_words_utils_check_scan_region (const GtkTextIter *start,
+                                                              const GtkTextIter *end);
 
 G_END_DECLS
-
-#endif /* GTK_SOURCE_COMPLETION_WORDS_UTILS_H */


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