[gtksourceview/wip/gutter: 2/3] GutterRenderer: minor clean-up



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

    GutterRenderer: minor clean-up

 gtksourceview/gtksourcegutter.c              |    8 ----
 gtksourceview/gtksourcegutterrenderer.c      |   46 ++++++--------------------
 gtksourceview/gtksourcegutterrendererlines.c |    9 -----
 3 files changed, 10 insertions(+), 53 deletions(-)
---
diff --git a/gtksourceview/gtksourcegutter.c b/gtksourceview/gtksourcegutter.c
index 13f548b..91dcd8c 100644
--- a/gtksourceview/gtksourcegutter.c
+++ b/gtksourceview/gtksourcegutter.c
@@ -247,12 +247,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);
@@ -533,7 +527,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;
 
@@ -678,7 +671,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..198e8f4 100644
--- a/gtksourceview/gtksourcegutterrenderer.c
+++ b/gtksourceview/gtksourcegutterrenderer.c
@@ -95,13 +95,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 +166,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 +449,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 +1018,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 +1304,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 32afd54..e1ff46f 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)
 {
@@ -278,11 +272,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;


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