From 49774ef29ee2a7866947fe15cc333d619cc51fe9 Mon Sep 17 00:00:00 2001 From: Bruce Cowan <bruce@bcowan.eu> Date: Mon, 1 Jan 2018 13:28:30 +0000 Subject: [PATCH] Tabs -> 4 spaces --- data/rugby.css | 8 +- src/rugby-cell-renderer-score.c | 322 ++++++++++++++++---------------- src/rugby-score-store.c | 128 ++++++------- src/rugby-score-store.h | 10 +- src/rugby-scoring.c | 4 +- src/rugby.c | 10 +- 6 files changed, 241 insertions(+), 241 deletions(-) diff --git a/data/rugby.css b/data/rugby.css index c1bcb67..1652a3f 100644 --- a/data/rugby.css +++ b/data/rugby.css @@ -1,11 +1,11 @@ .cell.level-cell.fill-block { - border-radius: 10px; + border-radius: 10px; } .cell.level-cell.fill-block.score-try { - /* Scarlet red */ + /* Scarlet red */ background-image: linear-gradient(to top, #a40000, #cc0000); @@ -13,7 +13,7 @@ .cell.level-cell.fill-block.score-utry { - /* Chameleon */ + /* Chameleon */ background-image: linear-gradient(to top, #4e9a06, #73d216); @@ -21,7 +21,7 @@ .cell.level-cell.fill-block.score-kick { - /* Butter */ + /* Butter */ background-image: linear-gradient(to top, #c4a000, #edd400); diff --git a/src/rugby-cell-renderer-score.c b/src/rugby-cell-renderer-score.c index 2bf767e..345a7cf 100644 --- a/src/rugby-cell-renderer-score.c +++ b/src/rugby-cell-renderer-score.c @@ -3,19 +3,19 @@ enum { - PROP_0, - PROP_TRIES, - PROP_UTRIES, - PROP_KICKS + PROP_0, + PROP_TRIES, + PROP_UTRIES, + PROP_KICKS }; struct _RugbyCellRendererScore { - GtkCellRenderer parent_instance; + GtkCellRenderer parent_instance; - gint tries; - gint utries; - gint kicks; + gint tries; + gint utries; + gint kicks; }; /* Style classes for the different types of score */ @@ -33,21 +33,21 @@ rugby_cell_renderer_score_set_property (GObject *object, { RugbyCellRendererScore *score = RUGBY_CELL_RENDERER_SCORE (object); - switch (prop_id) - { - case PROP_TRIES: - score->tries = g_value_get_int (value); - break; - case PROP_UTRIES: - score->utries = g_value_get_int (value); - break; - case PROP_KICKS: - score->kicks = g_value_get_int (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } + switch (prop_id) + { + case PROP_TRIES: + score->tries = g_value_get_int (value); + break; + case PROP_UTRIES: + score->utries = g_value_get_int (value); + break; + case PROP_KICKS: + score->kicks = g_value_get_int (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } } static void @@ -56,23 +56,23 @@ rugby_cell_renderer_score_get_property (GObject *object, GValue *value, GParamSpec *pspec) { - RugbyCellRendererScore *score = RUGBY_CELL_RENDERER_SCORE (object); - - switch (prop_id) - { - case PROP_TRIES: - g_value_set_int (value, score->tries); - break; - case PROP_UTRIES: - g_value_set_int (value, score->utries); - break; - case PROP_KICKS: - g_value_set_int (value, score->kicks); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } + RugbyCellRendererScore *score = RUGBY_CELL_RENDERER_SCORE (object); + + switch (prop_id) + { + case PROP_TRIES: + g_value_set_int (value, score->tries); + break; + case PROP_UTRIES: + g_value_set_int (value, score->utries); + break; + case PROP_KICKS: + g_value_set_int (value, score->kicks); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } } #define FIXED_WIDTH 400 @@ -84,16 +84,16 @@ rugby_cell_renderer_score_get_preferred_width (GtkCellRenderer *cell, gint *minimum_width, gint *natural_width) { - gint xpad; - gint width; + gint xpad; + gint width; - gtk_cell_renderer_get_padding (cell, &xpad, NULL); - width = xpad * 2 + FIXED_WIDTH; + gtk_cell_renderer_get_padding (cell, &xpad, NULL); + width = xpad * 2 + FIXED_WIDTH; - if (minimum_width) - *minimum_width = width; - if (natural_width) - *natural_width = width; + if (minimum_width) + *minimum_width = width; + if (natural_width) + *natural_width = width; } static void @@ -102,16 +102,16 @@ rugby_cell_renderer_score_get_preferred_height (GtkCellRenderer *cell, gint *minimum_height, gint *natural_height) { - gint ypad; - gint height; + gint ypad; + gint height; - gtk_cell_renderer_get_padding (cell, NULL, &ypad); - height = ypad * 2 + FIXED_HEIGHT; + gtk_cell_renderer_get_padding (cell, NULL, &ypad); + height = ypad * 2 + FIXED_HEIGHT; - if (minimum_height) - *minimum_height = height; - if (natural_height) - *natural_height = height; + if (minimum_height) + *minimum_height = height; + if (natural_height) + *natural_height = height; } static void @@ -123,24 +123,24 @@ render_bar (GtkStyleContext *context, gdouble height, RugbyScoreType type) { - gtk_style_context_save (context); - - switch (type) - { - case RUGBY_SCORE_TYPE_TRY: - gtk_style_context_add_class (context, RUGBY_STYLE_CLASS_TRY); - break; - case RUGBY_SCORE_TYPE_UTRY: - gtk_style_context_add_class (context, RUGBY_STYLE_CLASS_UTRY); - break; - case RUGBY_SCORE_TYPE_KICK: - gtk_style_context_add_class (context, RUGBY_STYLE_CLASS_KICK); - break; - } - - gtk_render_background (context, cr, x, y, width, height); - - gtk_style_context_restore (context); + gtk_style_context_save (context); + + switch (type) + { + case RUGBY_SCORE_TYPE_TRY: + gtk_style_context_add_class (context, RUGBY_STYLE_CLASS_TRY); + break; + case RUGBY_SCORE_TYPE_UTRY: + gtk_style_context_add_class (context, RUGBY_STYLE_CLASS_UTRY); + break; + case RUGBY_SCORE_TYPE_KICK: + gtk_style_context_add_class (context, RUGBY_STYLE_CLASS_KICK); + break; + } + + gtk_render_background (context, cr, x, y, width, height); + + gtk_style_context_restore (context); } static void @@ -151,107 +151,107 @@ rugby_cell_renderer_score_render (GtkCellRenderer *cell, const GdkRectangle *cell_area, GtkCellRendererState flags) { - RugbyCellRendererScore *score = RUGBY_CELL_RENDERER_SCORE (cell); - GtkStyleContext *context; - gint xpad, ypad; - gdouble x, y, total_w, w, h; - GtkBorder border; - gint tries, utries, kicks; - gint total; - gint i; - - context = gtk_widget_get_style_context (widget); - - gtk_cell_renderer_get_padding (cell, &xpad, &ypad); - x = cell_area->x + xpad; - y = cell_area->y + ypad; - total_w = cell_area->width - xpad * 2; - h = cell_area->height - ypad * 2; - - gtk_style_context_save (context); - gtk_style_context_add_class (context, "level-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; - total = tries * TRY_POINTS + utries * UTRY_POINTS + kicks * KICK_POINTS; - - gtk_style_context_get_border (context, GTK_STATE_FLAG_NORMAL, &border); - x += border.left; - y += border.top; - total_w -= border.left + border.right; - h -= border.top + border.bottom; - - gtk_style_context_add_class (context, "fill-block"); - - w = total_w / (total / 7.0); - for (i = 0; i < tries; i++) - { - render_bar (context, cr, x, y, w, h, RUGBY_SCORE_TYPE_TRY); - x += w; - } - - w = total_w / (total / 5.0); - for (i = 0; i < utries; i++) - { - render_bar (context, cr, x, y, w, h, RUGBY_SCORE_TYPE_UTRY); - x += w; - } - - w = total_w / (total / 3.0); - for (i = 0; i < kicks; i++) - { - render_bar (context, cr, x, y, w, h, RUGBY_SCORE_TYPE_KICK); - x += w; - } - - gtk_style_context_restore (context); + RugbyCellRendererScore *score = RUGBY_CELL_RENDERER_SCORE (cell); + GtkStyleContext *context; + gint xpad, ypad; + gdouble x, y, total_w, w, h; + GtkBorder border; + gint tries, utries, kicks; + gint total; + gint i; + + context = gtk_widget_get_style_context (widget); + + gtk_cell_renderer_get_padding (cell, &xpad, &ypad); + x = cell_area->x + xpad; + y = cell_area->y + ypad; + total_w = cell_area->width - xpad * 2; + h = cell_area->height - ypad * 2; + + gtk_style_context_save (context); + gtk_style_context_add_class (context, "level-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; + total = tries * TRY_POINTS + utries * UTRY_POINTS + kicks * KICK_POINTS; + + gtk_style_context_get_border (context, GTK_STATE_FLAG_NORMAL, &border); + x += border.left; + y += border.top; + total_w -= border.left + border.right; + h -= border.top + border.bottom; + + gtk_style_context_add_class (context, "fill-block"); + + w = total_w / (total / 7.0); + for (i = 0; i < tries; i++) + { + render_bar (context, cr, x, y, w, h, RUGBY_SCORE_TYPE_TRY); + x += w; + } + + w = total_w / (total / 5.0); + for (i = 0; i < utries; i++) + { + render_bar (context, cr, x, y, w, h, RUGBY_SCORE_TYPE_UTRY); + x += w; + } + + w = total_w / (total / 3.0); + for (i = 0; i < kicks; i++) + { + render_bar (context, cr, x, y, w, h, RUGBY_SCORE_TYPE_KICK); + x += w; + } + + gtk_style_context_restore (context); } static void rugby_cell_renderer_score_class_init (RugbyCellRendererScoreClass *klass) { - GObjectClass *obj_class = G_OBJECT_CLASS (klass); - GtkCellRendererClass *cell_class = GTK_CELL_RENDERER_CLASS (klass); - - obj_class->get_property = rugby_cell_renderer_score_get_property; - obj_class->set_property = rugby_cell_renderer_score_set_property; - - cell_class->get_preferred_width = rugby_cell_renderer_score_get_preferred_width; - cell_class->get_preferred_height = rugby_cell_renderer_score_get_preferred_height; - cell_class->render = rugby_cell_renderer_score_render; - - g_object_class_install_property (obj_class, PROP_TRIES, - g_param_spec_int ("tries", "Tries", "Number of tries", - 0, 50, 0, - G_PARAM_READWRITE)); - - g_object_class_install_property (obj_class, PROP_UTRIES, - g_param_spec_int ("utries", "Unconverted Tries", "Number of Unconverted Tries", - 0, 50, 0, - G_PARAM_READWRITE)); - - g_object_class_install_property (obj_class, PROP_KICKS, - g_param_spec_int ("kicks", "Kicks", "Number of kicks", - 0, 50, 0, - G_PARAM_READWRITE)); + GObjectClass *obj_class = G_OBJECT_CLASS (klass); + GtkCellRendererClass *cell_class = GTK_CELL_RENDERER_CLASS (klass); + + obj_class->get_property = rugby_cell_renderer_score_get_property; + obj_class->set_property = rugby_cell_renderer_score_set_property; + + cell_class->get_preferred_width = rugby_cell_renderer_score_get_preferred_width; + cell_class->get_preferred_height = rugby_cell_renderer_score_get_preferred_height; + cell_class->render = rugby_cell_renderer_score_render; + + g_object_class_install_property (obj_class, PROP_TRIES, + g_param_spec_int ("tries", "Tries", "Number of tries", + 0, 50, 0, + G_PARAM_READWRITE)); + + g_object_class_install_property (obj_class, PROP_UTRIES, + g_param_spec_int ("utries", "Unconverted Tries", "Number of Unconverted Tries", + 0, 50, 0, + G_PARAM_READWRITE)); + + g_object_class_install_property (obj_class, PROP_KICKS, + g_param_spec_int ("kicks", "Kicks", "Number of kicks", + 0, 50, 0, + G_PARAM_READWRITE)); } static void rugby_cell_renderer_score_init (RugbyCellRendererScore *score) { - score->tries = 0; - score->utries = 0; - score->kicks = 0; + score->tries = 0; + score->utries = 0; + score->kicks = 0; - gtk_cell_renderer_set_padding (GTK_CELL_RENDERER (score), 2, 2); + gtk_cell_renderer_set_padding (GTK_CELL_RENDERER (score), 2, 2); } GtkCellRenderer * rugby_cell_renderer_score_new (void) { - return g_object_new (RUGBY_TYPE_CELL_RENDERER_SCORE, NULL); + return g_object_new (RUGBY_TYPE_CELL_RENDERER_SCORE, NULL); } diff --git a/src/rugby-score-store.c b/src/rugby-score-store.c index e17933f..f85a53c 100644 --- a/src/rugby-score-store.c +++ b/src/rugby-score-store.c @@ -3,24 +3,24 @@ enum { - FINISHED, - LAST_SIGNAL + FINISHED, + LAST_SIGNAL }; enum { - PROP_0, - PROP_SCORE, - PROP_LAST + PROP_0, + PROP_SCORE, + PROP_LAST }; static GParamSpec *pspecs[PROP_LAST]; struct _RugbyScoreStore { - GtkListStore parent_instance; + GtkListStore parent_instance; - gint score; + gint score; }; G_DEFINE_TYPE (RugbyScoreStore, rugby_score_store, GTK_TYPE_LIST_STORE) @@ -33,17 +33,17 @@ rugby_score_store_set_property (GObject *object, const GValue *value, GParamSpec *pspec) { - RugbyScoreStore *store = RUGBY_SCORE_STORE (object); - - switch (prop_id) - { - case PROP_SCORE: - rugby_score_store_set_score (store, g_value_get_int (value)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } + RugbyScoreStore *store = RUGBY_SCORE_STORE (object); + + switch (prop_id) + { + case PROP_SCORE: + rugby_score_store_set_score (store, g_value_get_int (value)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } } static void @@ -52,40 +52,40 @@ rugby_score_store_get_property (GObject *object, GValue *value, GParamSpec *pspec) { - RugbyScoreStore *store = RUGBY_SCORE_STORE (object); - - switch (prop_id) - { - case PROP_SCORE: - g_value_set_int (value, rugby_score_store_get_score (store)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } + RugbyScoreStore *store = RUGBY_SCORE_STORE (object); + + switch (prop_id) + { + case PROP_SCORE: + g_value_set_int (value, rugby_score_store_get_score (store)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } } static void rugby_score_store_class_init (RugbyScoreStoreClass *klass) { - GObjectClass *obj_class = G_OBJECT_CLASS (klass); - - obj_class->get_property = rugby_score_store_get_property; - obj_class->set_property = rugby_score_store_set_property; - - pspecs[PROP_SCORE] = g_param_spec_int ("score", "Score", "The score", - 0, 200, 0, - G_PARAM_READWRITE); - g_object_class_install_property (obj_class, PROP_SCORE, pspecs[PROP_SCORE]); - - signals[FINISHED] = - g_signal_new ("finished", - G_TYPE_FROM_CLASS (obj_class), - G_SIGNAL_RUN_LAST, - 0, - NULL, NULL, NULL, - G_TYPE_NONE, 1, - G_TYPE_INT); + GObjectClass *obj_class = G_OBJECT_CLASS (klass); + + obj_class->get_property = rugby_score_store_get_property; + obj_class->set_property = rugby_score_store_set_property; + + pspecs[PROP_SCORE] = g_param_spec_int ("score", "Score", "The score", + 0, 200, 0, + G_PARAM_READWRITE); + g_object_class_install_property (obj_class, PROP_SCORE, pspecs[PROP_SCORE]); + + signals[FINISHED] = + g_signal_new ("finished", + G_TYPE_FROM_CLASS (obj_class), + G_SIGNAL_RUN_LAST, + 0, + NULL, NULL, NULL, + G_TYPE_NONE, 1, + G_TYPE_INT); } static void @@ -125,16 +125,16 @@ populate_store_foreach (gpointer data, static void populate_store (RugbyScoreStore *self) { - GtkListStore *store = GTK_LIST_STORE (self); + GtkListStore *store = GTK_LIST_STORE (self); - g_autoptr(GPtrArray) possibilities = NULL; + g_autoptr(GPtrArray) possibilities = NULL; - /* Clear the store */ - gtk_list_store_clear (store); + /* Clear the store */ + gtk_list_store_clear (store); - possibilities = rugby_scoring_get_possibilities (self->score); + possibilities = rugby_scoring_get_possibilities (self->score); if (possibilities->len == 0) - return; + return; g_ptr_array_foreach (possibilities, populate_store_foreach, store); @@ -144,35 +144,35 @@ populate_store (RugbyScoreStore *self) static void rugby_score_store_init (RugbyScoreStore *store) { - GType types[] = { G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_STRING }; + 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 (store), RUGBY_SCORE_STORE_COLUMNS, types); + store->score = 0; } RugbyScoreStore * rugby_score_store_new (void) { - return g_object_new (RUGBY_TYPE_SCORE_STORE, NULL); + return g_object_new (RUGBY_TYPE_SCORE_STORE, NULL); } gint rugby_score_store_get_score (RugbyScoreStore *store) { - g_return_val_if_fail (RUGBY_IS_SCORE_STORE (store), 0); + g_return_val_if_fail (RUGBY_IS_SCORE_STORE (store), 0); - return store->score; + return store->score; } void rugby_score_store_set_score (RugbyScoreStore *store, gint score) { - g_return_if_fail (RUGBY_IS_SCORE_STORE (store)); - g_return_if_fail (score >= 0 && score <= 200); + g_return_if_fail (RUGBY_IS_SCORE_STORE (store)); + g_return_if_fail (score >= 0 && score <= 200); - store->score = score; - g_object_notify_by_pspec (G_OBJECT (store), pspecs[PROP_SCORE]); + store->score = score; + g_object_notify_by_pspec (G_OBJECT (store), pspecs[PROP_SCORE]); - populate_store (store); + populate_store (store); } diff --git a/src/rugby-score-store.h b/src/rugby-score-store.h index 2528556..e1ce4ed 100644 --- a/src/rugby-score-store.h +++ b/src/rugby-score-store.h @@ -7,11 +7,11 @@ G_BEGIN_DECLS enum { - RUGBY_SCORE_STORE_TRIES, - RUGBY_SCORE_STORE_UTRIES, - RUGBY_SCORE_STORE_KICKS, - RUGBY_SCORE_STORE_TOOLTIP, - RUGBY_SCORE_STORE_COLUMNS + RUGBY_SCORE_STORE_TRIES, + RUGBY_SCORE_STORE_UTRIES, + RUGBY_SCORE_STORE_KICKS, + RUGBY_SCORE_STORE_TOOLTIP, + RUGBY_SCORE_STORE_COLUMNS }; #define RUGBY_TYPE_SCORE_STORE rugby_score_store_get_type () diff --git a/src/rugby-scoring.c b/src/rugby-scoring.c index 0d647e7..4de58a2 100644 --- a/src/rugby-scoring.c +++ b/src/rugby-scoring.c @@ -49,11 +49,11 @@ rugby_scoring_get_possibilities (gint score) gint rugby_scoring_get_max_tries (gint score) { - return (score % 5 == 1) ? score / UTRY_POINTS - 1 : score / UTRY_POINTS; + return (score % 5 == 1) ? score / UTRY_POINTS - 1 : score / UTRY_POINTS; } gint rugby_scoring_get_max_kicks (gint score) { - return (score % 3 == 1) ? score / KICK_POINTS : score / KICK_POINTS - 1; + return (score % 3 == 1) ? score / KICK_POINTS : score / KICK_POINTS - 1; } diff --git a/src/rugby.c b/src/rugby.c index a7759df..850404d 100644 --- a/src/rugby.c +++ b/src/rugby.c @@ -4,11 +4,11 @@ int main (int argc, char **argv) { - RugbyApplication *app; - gint retval; + RugbyApplication *app; + gint retval; - app = rugby_application_new (); - retval = g_application_run (G_APPLICATION (app), argc, argv); + app = rugby_application_new (); + retval = g_application_run (G_APPLICATION (app), argc, argv); - return retval; + return retval; } -- GitLab