[gtksourceview] tag: use g_object_get() instead of having a private getter



commit 31b2b96cd7537ca56e7541840a547c6d62dcdc17
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Wed Jun 1 13:23:03 2016 +0200

    tag: use g_object_get() instead of having a private getter
    
    Use g_object_get() like for any GtkTextTag property.
    
    The getter was added recently to improve performances, but if
    performance is a problem it's better to create a GtkTextTag (not a
    GtkSourceTag) when the GtkSourceTag property is not needed. There is
    anyway the 'if (GTK_SOURCE_IS_TAG (tag))' that prevents g_object_get()
    from being called for simple GtkTextTags.
    
    Besides, "effects_spaces()" was not a good name. There are other
    properties in GtkTextTag that can affect spaces but those were not taken
    into account in the getter. And more properties can be added in the
    future, which would make effects_spaces() misleading.
    
    So, keep things simple and consistent with GtkTextTag.

 gtksourceview/Makefile.am            |    1 -
 gtksourceview/gtksourcetag-private.h |   36 ----------------------------------
 gtksourceview/gtksourcetag.c         |   13 ------------
 gtksourceview/gtksourceview.c        |   17 ++++++++++++---
 4 files changed, 13 insertions(+), 54 deletions(-)
---
diff --git a/gtksourceview/Makefile.am b/gtksourceview/Makefile.am
index bd4f165..1f55fd3 100644
--- a/gtksourceview/Makefile.am
+++ b/gtksourceview/Makefile.am
@@ -115,7 +115,6 @@ libgtksourceview_private_headers =          \
        gtksourcepixbufhelper.h                 \
        gtksourceregex.h                        \
        gtksourcestyle-private.h                \
-       gtksourcetag-private.h                  \
        gtksourcetypes-private.h                \
        gtksourceundomanagerdefault.h           \
        gtksourceview-i18n.h                    \
diff --git a/gtksourceview/gtksourcetag.c b/gtksourceview/gtksourcetag.c
index 8a96b84..b3329f8 100644
--- a/gtksourceview/gtksourcetag.c
+++ b/gtksourceview/gtksourcetag.c
@@ -26,7 +26,6 @@
 #endif
 
 #include "gtksourcetag.h"
-#include "gtksourcetag-private.h"
 
 /**
  * SECTION:tag
@@ -186,15 +185,3 @@ gtk_source_tag_new (const gchar *name)
                             "name", name,
                             NULL);
 }
-
-gboolean
-_gtk_source_tag_effects_spaces (GtkSourceTag *tag)
-{
-       GtkSourceTagPrivate *priv;
-
-       g_return_val_if_fail (GTK_SOURCE_IS_TAG (tag), FALSE);
-
-       priv = gtk_source_tag_get_instance_private (tag);
-
-       return priv->draw_spaces_set && priv->draw_spaces;
-}
diff --git a/gtksourceview/gtksourceview.c b/gtksourceview/gtksourceview.c
index 77fb678..44adc3a 100644
--- a/gtksourceview/gtksourceview.c
+++ b/gtksourceview/gtksourceview.c
@@ -49,7 +49,6 @@
 #include "gtksourcegutterrenderermarks.h"
 #include "gtksourceiter.h"
 #include "gtksourcetag.h"
-#include "gtksourcetag-private.h"
 
 /**
  * SECTION:view
@@ -2453,10 +2452,20 @@ draw_spaces_tag_foreach (GtkTextTag *tag,
                return;
        }
 
-       if (GTK_SOURCE_IS_TAG (tag) &&
-           _gtk_source_tag_effects_spaces (GTK_SOURCE_TAG (tag)))
+       if (GTK_SOURCE_IS_TAG (tag))
        {
-               *found = TRUE;
+               gboolean draw_spaces;
+               gboolean draw_spaces_set;
+
+               g_object_get (tag,
+                             "draw-spaces", &draw_spaces,
+                             "draw-spaces-set", &draw_spaces_set,
+                             NULL);
+
+               if (draw_spaces && draw_spaces_set)
+               {
+                       *found = TRUE;
+               }
        }
 }
 


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