From 7a6b20e449910d19920c4e593ec4ce81270e78eb Mon Sep 17 00:00:00 2001
From: Bruce Cowan <bruce@bcowan.eu>
Date: Mon, 1 Jan 2018 13:36:16 +0000
Subject: [PATCH] Consistently use 'self' to refer to object

Only when it is the of the same type as class
---
 src/rugby-cell-renderer-score.c | 34 ++++++++++++++++-----------------
 src/rugby-score-store.c         | 30 ++++++++++++++---------------
 2 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/src/rugby-cell-renderer-score.c b/src/rugby-cell-renderer-score.c
index 345a7cf..ba593d9 100644
--- a/src/rugby-cell-renderer-score.c
+++ b/src/rugby-cell-renderer-score.c
@@ -31,18 +31,18 @@ rugby_cell_renderer_score_set_property (GObject      *object,
                                         const GValue *value,
                                         GParamSpec   *pspec)
 {
-    RugbyCellRendererScore *score = RUGBY_CELL_RENDERER_SCORE (object);
+    RugbyCellRendererScore *self = RUGBY_CELL_RENDERER_SCORE (object);
 
     switch (prop_id)
     {
         case PROP_TRIES:
-            score->tries = g_value_get_int (value);
+            self->tries = g_value_get_int (value);
             break;
         case PROP_UTRIES:
-            score->utries = g_value_get_int (value);
+            self->utries = g_value_get_int (value);
             break;
         case PROP_KICKS:
-            score->kicks = g_value_get_int (value);
+            self->kicks = g_value_get_int (value);
             break;
         default:
             G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -56,18 +56,18 @@ rugby_cell_renderer_score_get_property (GObject    *object,
                                         GValue     *value,
                                         GParamSpec *pspec)
 {
-    RugbyCellRendererScore *score = RUGBY_CELL_RENDERER_SCORE (object);
+    RugbyCellRendererScore *self = RUGBY_CELL_RENDERER_SCORE (object);
 
     switch (prop_id)
     {
         case PROP_TRIES:
-            g_value_set_int (value, score->tries);
+            g_value_set_int (value, self->tries);
             break;
         case PROP_UTRIES:
-            g_value_set_int (value, score->utries);
+            g_value_set_int (value, self->utries);
             break;
         case PROP_KICKS:
-            g_value_set_int (value, score->kicks);
+            g_value_set_int (value, self->kicks);
             break;
         default:
             G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -151,7 +151,7 @@ rugby_cell_renderer_score_render (GtkCellRenderer      *cell,
                                   const GdkRectangle   *cell_area,
                                   GtkCellRendererState  flags)
 {
-    RugbyCellRendererScore *score = RUGBY_CELL_RENDERER_SCORE (cell);
+    RugbyCellRendererScore *self = RUGBY_CELL_RENDERER_SCORE (cell);
     GtkStyleContext *context;
     gint xpad, ypad;
     gdouble x, y, total_w, w, h;
@@ -174,9 +174,9 @@ rugby_cell_renderer_score_render (GtkCellRenderer      *cell,
     gtk_render_background (context, cr, x, y, total_w, h);
     gtk_render_frame (context, cr, x, y, total_w, h);
 
-    tries = score->tries;
-    utries = score->utries;
-    kicks = score->kicks;
+    tries = self->tries;
+    utries = self->utries;
+    kicks = self->kicks;
     total = tries * TRY_POINTS + utries * UTRY_POINTS + kicks * KICK_POINTS;
 
     gtk_style_context_get_border (context, GTK_STATE_FLAG_NORMAL, &border);
@@ -241,13 +241,13 @@ rugby_cell_renderer_score_class_init (RugbyCellRendererScoreClass *klass)
 }
 
 static void
-rugby_cell_renderer_score_init (RugbyCellRendererScore *score)
+rugby_cell_renderer_score_init (RugbyCellRendererScore *self)
 {
-    score->tries = 0;
-    score->utries = 0;
-    score->kicks = 0;
+    self->tries = 0;
+    self->utries = 0;
+    self->kicks = 0;
 
-    gtk_cell_renderer_set_padding (GTK_CELL_RENDERER (score), 2, 2);
+    gtk_cell_renderer_set_padding (GTK_CELL_RENDERER (self), 2, 2);
 }
 
 GtkCellRenderer *
diff --git a/src/rugby-score-store.c b/src/rugby-score-store.c
index f85a53c..c139773 100644
--- a/src/rugby-score-store.c
+++ b/src/rugby-score-store.c
@@ -33,12 +33,12 @@ rugby_score_store_set_property (GObject      *object,
                                 const GValue *value,
                                 GParamSpec   *pspec)
 {
-    RugbyScoreStore *store = RUGBY_SCORE_STORE (object);
+    RugbyScoreStore *self = RUGBY_SCORE_STORE (object);
 
     switch (prop_id)
     {
         case PROP_SCORE:
-            rugby_score_store_set_score (store, g_value_get_int (value));
+            rugby_score_store_set_score (self, g_value_get_int (value));
             break;
         default:
             G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -52,12 +52,12 @@ rugby_score_store_get_property (GObject    *object,
                                 GValue     *value,
                                 GParamSpec *pspec)
 {
-    RugbyScoreStore *store = RUGBY_SCORE_STORE (object);
+    RugbyScoreStore *self = RUGBY_SCORE_STORE (object);
 
     switch (prop_id)
     {
         case PROP_SCORE:
-            g_value_set_int (value, rugby_score_store_get_score (store));
+            g_value_set_int (value, rugby_score_store_get_score (self));
             break;
         default:
             G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -142,12 +142,12 @@ populate_store (RugbyScoreStore *self)
 }
 
 static void
-rugby_score_store_init (RugbyScoreStore *store)
+rugby_score_store_init (RugbyScoreStore *self)
 {
     GType types[] = { G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_STRING };
 
-    gtk_list_store_set_column_types (GTK_LIST_STORE (store), RUGBY_SCORE_STORE_COLUMNS, types);
-    store->score = 0;
+    gtk_list_store_set_column_types (GTK_LIST_STORE (self), RUGBY_SCORE_STORE_COLUMNS, types);
+    self->score = 0;
 }
 
 RugbyScoreStore *
@@ -157,22 +157,22 @@ rugby_score_store_new (void)
 }
 
 gint
-rugby_score_store_get_score (RugbyScoreStore *store)
+rugby_score_store_get_score (RugbyScoreStore *self)
 {
-    g_return_val_if_fail (RUGBY_IS_SCORE_STORE (store), 0);
+    g_return_val_if_fail (RUGBY_IS_SCORE_STORE (self), 0);
 
-    return store->score;
+    return self->score;
 }
 
 void
-rugby_score_store_set_score (RugbyScoreStore *store,
+rugby_score_store_set_score (RugbyScoreStore *self,
                              gint             score)
 {
-    g_return_if_fail (RUGBY_IS_SCORE_STORE (store));
+    g_return_if_fail (RUGBY_IS_SCORE_STORE (self));
     g_return_if_fail (score >= 0 && score <= 200);
 
-    store->score = score;
-    g_object_notify_by_pspec (G_OBJECT (store), pspecs[PROP_SCORE]);
+    self->score = score;
+    g_object_notify_by_pspec (G_OBJECT (self), pspecs[PROP_SCORE]);
 
-    populate_store (store);
+    populate_store (self);
 }
-- 
GitLab