[gtksourceview] Gutter: clean-up



commit 8e08dd20c06b931e9ebffae76b71f8ac0a03e522
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Tue Sep 3 15:05:42 2013 +0200

    Gutter: clean-up

 gtksourceview/Makefile.am                    |   12 +++---
 gtksourceview/gtksourcegutter.c              |   10 -----
 gtksourceview/gtksourcegutterrenderer.c      |   47 +++++--------------------
 gtksourceview/gtksourcegutterrendererlines.c |    9 -----
 gtksourceview/gtksourcegutterrenderermarks.c |    1 -
 gtksourceview/gtksourceview.c                |   14 +------
 6 files changed, 18 insertions(+), 75 deletions(-)
---
diff --git a/gtksourceview/Makefile.am b/gtksourceview/Makefile.am
index 0d2f140..735bfb6 100644
--- a/gtksourceview/Makefile.am
+++ b/gtksourceview/Makefile.am
@@ -24,16 +24,16 @@ BUILT_SOURCES =                     \
 libgtksourceview_headers =                     \
        gtksource.h                             \
        gtksourcebuffer.h                       \
-       gtksourcecompletioncontext.h            \
        gtksourcecompletion.h                   \
+       gtksourcecompletioncontext.h            \
        gtksourcecompletioninfo.h               \
        gtksourcecompletionitem.h               \
        gtksourcecompletionproposal.h           \
        gtksourcecompletionprovider.h           \
        gtksourcegutter.h                       \
        gtksourcegutterrenderer.h               \
-       gtksourcegutterrenderertext.h           \
        gtksourcegutterrendererpixbuf.h         \
+       gtksourcegutterrenderertext.h           \
        gtksourcelanguage.h                     \
        gtksourcelanguagemanager.h              \
        gtksourcemark.h                         \
@@ -75,9 +75,11 @@ libgtksourceview_private_c_files = \
        gtksourcecompletionmodel.c      \
        gtksourcecontextengine.c        \
        gtksourceengine.c               \
-       gtksourcepixbufhelper.c         \
+       gtksourcegutterrendererlines.c  \
+       gtksourcegutterrenderermarks.c  \
        gtksourcelanguage-parser-1.c    \
        gtksourcelanguage-parser-2.c    \
+       gtksourcepixbufhelper.c         \
        gtksourceregex.c                \
        gtksourceundomanager.c          \
        gtksourceundomanagerdefault.c   \
@@ -95,10 +97,8 @@ libgtksourceview_c_files = \
        gtksourcecompletionprovider.c   \
        gtksourcegutter.c               \
        gtksourcegutterrenderer.c       \
-       gtksourcegutterrenderertext.c   \
        gtksourcegutterrendererpixbuf.c \
-       gtksourcegutterrendererlines.c  \
-       gtksourcegutterrenderermarks.c  \
+       gtksourcegutterrenderertext.c   \
        gtksourcelanguage.c             \
        gtksourcelanguagemanager.c      \
        gtksourcemark.c                 \
diff --git a/gtksourceview/gtksourcegutter.c b/gtksourceview/gtksourcegutter.c
index 6585b83..5577f4b 100644
--- a/gtksourceview/gtksourcegutter.c
+++ b/gtksourceview/gtksourcegutter.c
@@ -27,8 +27,6 @@
 #include "gtksourcegutterrenderer.h"
 #include "gtksourcegutterrenderer-private.h"
 
-#include <gobject/gvaluecollector.h>
-
 /**
  * SECTION:gutter
  * @Short_description: Gutter object for #GtkSourceView
@@ -245,12 +243,6 @@ renderer_free (Renderer *renderer)
 }
 
 static void
-gtk_source_gutter_finalize (GObject *object)
-{
-       G_OBJECT_CLASS (gtk_source_gutter_parent_class)->finalize (object);
-}
-
-static void
 gtk_source_gutter_dispose (GObject *object)
 {
        GtkSourceGutter *gutter = GTK_SOURCE_GUTTER (object);
@@ -531,7 +523,6 @@ gtk_source_gutter_class_init (GtkSourceGutterClass *klass)
        object_class->set_property = gtk_source_gutter_set_property;
        object_class->get_property = gtk_source_gutter_get_property;
 
-       object_class->finalize = gtk_source_gutter_finalize;
        object_class->dispose = gtk_source_gutter_dispose;
        object_class->constructed = gtk_source_gutter_constructed;
 
@@ -674,7 +665,6 @@ gtk_source_gutter_get_window (GtkSourceGutter *gutter)
  * Since: 3.0
  *
  **/
-
 gboolean
 gtk_source_gutter_insert (GtkSourceGutter         *gutter,
                           GtkSourceGutterRenderer *renderer,
diff --git a/gtksourceview/gtksourcegutterrenderer.c b/gtksourceview/gtksourcegutterrenderer.c
index 508e686..c080b0e 100644
--- a/gtksourceview/gtksourcegutterrenderer.c
+++ b/gtksourceview/gtksourcegutterrenderer.c
@@ -28,7 +28,6 @@
 enum
 {
        ACTIVATE,
-       SIZE_CHANGED,
        QUEUE_DRAW,
        QUERY_TOOLTIP,
        QUERY_DATA,
@@ -95,13 +94,6 @@ set_buffer (GtkSourceGutterRenderer *renderer,
        }
 
        renderer->priv->buffer = buffer;
-
-}
-
-static void
-gtk_source_gutter_renderer_finalize (GObject *object)
-{
-       G_OBJECT_CLASS (gtk_source_gutter_renderer_parent_class)->finalize (object);
 }
 
 static void
@@ -173,24 +165,21 @@ gtk_source_gutter_renderer_dispose (GObject *object)
        G_OBJECT_CLASS (gtk_source_gutter_renderer_parent_class)->dispose (object);
 }
 
-static gboolean
+static void
 set_visible (GtkSourceGutterRenderer *renderer,
              gboolean                 visible)
 {
-       if (renderer->priv->visible == visible)
-       {
-               return FALSE;
-       }
+       visible = visible != FALSE;
 
-       renderer->priv->visible = visible;
-       g_object_notify (G_OBJECT (renderer), "visible");
-
-       gtk_source_gutter_renderer_queue_draw (renderer);
+       if (renderer->priv->visible != visible)
+       {
+               renderer->priv->visible = visible;
+               g_object_notify (G_OBJECT (renderer), "visible");
 
-       return TRUE;
+               gtk_source_gutter_renderer_queue_draw (renderer);
+       }
 }
 
-
 static gboolean
 set_padding (GtkSourceGutterRenderer *renderer,
              gint                    *field,
@@ -459,7 +448,6 @@ gtk_source_gutter_renderer_class_init (GtkSourceGutterRendererClass *klass)
 {
        GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
-       object_class->finalize = gtk_source_gutter_renderer_finalize;
        object_class->dispose = gtk_source_gutter_renderer_dispose;
 
        object_class->get_property = gtk_source_gutter_renderer_get_property;
@@ -1029,14 +1017,7 @@ gtk_source_gutter_renderer_set_visible (GtkSourceGutterRenderer *renderer,
 {
        g_return_if_fail (GTK_SOURCE_IS_GUTTER_RENDERER (renderer));
 
-       if (visible != renderer->priv->visible)
-       {
-               renderer->priv->visible = visible;
-
-               g_object_notify (G_OBJECT (renderer), "visible");
-
-               gtk_source_gutter_renderer_queue_draw (renderer);
-       }
+       set_visible (renderer, visible);
 }
 
 /**
@@ -1322,15 +1303,7 @@ _gtk_source_gutter_renderer_set_view (GtkSourceGutterRenderer *renderer,
        old_view = renderer->priv->view;
 
        renderer->priv->window_type = window_type;
-
-       if (view)
-       {
-               renderer->priv->view = g_object_ref (view);
-       }
-       else
-       {
-               renderer->priv->view = NULL;
-       }
+       renderer->priv->view = view != NULL ? g_object_ref (view) : NULL;
 
        if (GTK_SOURCE_GUTTER_RENDERER_GET_CLASS (renderer)->change_view)
        {
diff --git a/gtksourceview/gtksourcegutterrendererlines.c b/gtksourceview/gtksourcegutterrendererlines.c
index d2dbbcf..581289a 100644
--- a/gtksourceview/gtksourcegutterrendererlines.c
+++ b/gtksourceview/gtksourcegutterrendererlines.c
@@ -31,12 +31,6 @@ struct _GtkSourceGutterRendererLinesPrivate
 
 G_DEFINE_TYPE_WITH_PRIVATE (GtkSourceGutterRendererLines, gtk_source_gutter_renderer_lines, 
GTK_SOURCE_TYPE_GUTTER_RENDERER_TEXT)
 
-static void
-gtk_source_gutter_renderer_lines_finalize (GObject *object)
-{
-       G_OBJECT_CLASS (gtk_source_gutter_renderer_lines_parent_class)->finalize (object);
-}
-
 static GtkTextBuffer *
 get_buffer (GtkSourceGutterRendererLines *renderer)
 {
@@ -315,11 +309,8 @@ gutter_renderer_query_activatable (GtkSourceGutterRenderer *renderer,
 static void
 gtk_source_gutter_renderer_lines_class_init (GtkSourceGutterRendererLinesClass *klass)
 {
-       GObjectClass *object_class = G_OBJECT_CLASS (klass);
        GtkSourceGutterRendererClass *renderer_class = GTK_SOURCE_GUTTER_RENDERER_CLASS (klass);
 
-       object_class->finalize = gtk_source_gutter_renderer_lines_finalize;
-
        renderer_class->query_data = gutter_renderer_query_data;
        renderer_class->query_activatable = gutter_renderer_query_activatable;
        renderer_class->activate = gutter_renderer_activate;
diff --git a/gtksourceview/gtksourcegutterrenderermarks.c b/gtksourceview/gtksourcegutterrenderermarks.c
index af26992..c1e6518 100644
--- a/gtksourceview/gtksourcegutterrenderermarks.c
+++ b/gtksourceview/gtksourcegutterrenderermarks.c
@@ -202,7 +202,6 @@ gutter_renderer_query_data (GtkSourceGutterRenderer *renderer,
        g_object_set (G_OBJECT (renderer),
                      "pixbuf", pixbuf,
                      "xpad", 2,
-                     "ypad", 1,
                      "yalign", 0.5,
                      "xalign", 0.5,
                      "alignment-mode", GTK_SOURCE_GUTTER_RENDERER_ALIGNMENT_MODE_FIRST,
diff --git a/gtksourceview/gtksourceview.c b/gtksourceview/gtksourceview.c
index 381a381..94f4356 100644
--- a/gtksourceview/gtksourceview.c
+++ b/gtksourceview/gtksourceview.c
@@ -2556,18 +2556,14 @@ gtk_source_view_set_show_line_numbers (GtkSourceView *view,
                              "yalign", 0.5,
                              "xalign", 1.0,
                              "xpad", 3,
-                             "visible", show,
                              NULL);
 
                gtk_source_gutter_insert (gutter,
                                          view->priv->line_renderer,
                                          GTK_SOURCE_VIEW_GUTTER_POSITION_LINES);
        }
-       else
-       {
-               gtk_source_gutter_renderer_set_visible (view->priv->line_renderer, show);
-       }
 
+       gtk_source_gutter_renderer_set_visible (view->priv->line_renderer, show);
        view->priv->show_line_numbers = show;
 
        g_object_notify (G_OBJECT (view), "show_line_numbers");
@@ -2634,9 +2630,6 @@ gtk_source_view_set_show_line_marks (GtkSourceView *view,
                gutter = gtk_source_view_get_gutter (view, GTK_TEXT_WINDOW_LEFT);
 
                view->priv->marks_renderer = gtk_source_gutter_renderer_marks_new ();
-               g_object_set (view->priv->marks_renderer,
-                             "visible", show,
-                             NULL);
 
                gtk_source_gutter_insert (gutter,
                                          view->priv->marks_renderer,
@@ -2647,11 +2640,8 @@ gtk_source_view_set_show_line_marks (GtkSourceView *view,
                                  G_CALLBACK (gutter_renderer_marks_activate),
                                  view);
        }
-       else
-       {
-               gtk_source_gutter_renderer_set_visible (view->priv->marks_renderer, show);
-       }
 
+       gtk_source_gutter_renderer_set_visible (view->priv->marks_renderer, show);
        view->priv->show_line_marks = show;
 
        g_object_notify (G_OBJECT (view), "show_line_marks");


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