diff --git a/src/main.c b/src/main.c index a97ae83f334875027309cc208b1cb11a415d4918..52342e5e23a43a9f3374b498036550d09d468b1e 100644 --- a/src/main.c +++ b/src/main.c @@ -25,8 +25,8 @@ about_activated (GSimpleAction *simple, GtkApplication *app = GTK_APPLICATION (user_data); GtkWindow *window = gtk_application_get_active_window (app); - const gchar *authors[] = { "Bruce Cowan", NULL }; - const gchar *copyright = "Copyright 2012–" COPYRIGHT_YEAR " Bruce Cowan"; + const char *authors[] = { "Bruce Cowan", NULL }; + const char *copyright = "Copyright 2012–" COPYRIGHT_YEAR " Bruce Cowan"; gtk_show_about_dialog (window, "logo-icon-name", "face-wink", diff --git a/src/rugby-app-window.c b/src/rugby-app-window.c index 116e8d4e00b94c76c54e7e0829d7071c1be69984..bbdd0e8dc9ff727a7c4713dbf00161a4643d663e 100644 --- a/src/rugby-app-window.c +++ b/src/rugby-app-window.c @@ -23,14 +23,14 @@ struct _RugbyAppWindow G_DEFINE_TYPE (RugbyAppWindow, rugby_app_window, GTK_TYPE_APPLICATION_WINDOW) -static inline guint -get_max_tries (guint score) +static inline unsigned +get_max_tries (unsigned score) { return (score % 5 == 1) ? score / UTRY_POINTS - 1 : score / UTRY_POINTS; } -static inline guint -get_max_kicks (guint score) +static inline unsigned +get_max_kicks (unsigned score) { return (score % 3 == 1) ? score / KICK_POINTS : score / KICK_POINTS - 1; } @@ -39,7 +39,7 @@ static void scorespin_value_changed_cb (GtkSpinButton *spin, RugbyAppWindow *self) { - gint score = gtk_spin_button_get_value_as_int (spin); + int score = gtk_spin_button_get_value_as_int (spin); rugby_list_store_set_score (self->store, score); } diff --git a/src/rugby-list-store.c b/src/rugby-list-store.c index f7b2da7e805b378ee222dce02202ae77379bcd55..e8c6279cdf3d692e839e4a6e3d783aa6e34f2e2c 100644 --- a/src/rugby-list-store.c +++ b/src/rugby-list-store.c @@ -14,7 +14,7 @@ struct _RugbyListStore { GObject parent_instance; - guint score; + unsigned score; GPtrArray *items; }; @@ -35,12 +35,12 @@ static GParamSpec *properties[N_PROPS]; // Helper functions -static gint +static int sort_func (gconstpointer a, gconstpointer b) { - gint atries, autries; - gint btries, butries; + int atries, autries; + int btries, butries; g_object_get ((gpointer) a, "tries", &atries, @@ -51,7 +51,7 @@ sort_func (gconstpointer a, "utries", &butries, NULL); - gint trydiff = (btries + butries) - (atries + autries); + int trydiff = (btries + butries) - (atries + autries); // Sort by total tries first, then converted if (trydiff != 0) @@ -69,24 +69,24 @@ notify_score_cb (GObject *gobject, { RugbyListStore *self = RUGBY_LIST_STORE (user_data); - gint max_tries = self->score / TRY_POINTS; - gint max_utries = self->score / UTRY_POINTS; + int max_tries = self->score / TRY_POINTS; + int max_utries = self->score / UTRY_POINTS; - guint old_length = self->items->len; + unsigned old_length = self->items->len; g_ptr_array_remove_range (self->items, 0, self->items->len); - for (gint tries = 0; tries <= max_tries; tries++) + for (int tries = 0; tries <= max_tries; tries++) { - for (gint utries = 0; utries <= max_utries; utries++) + for (int utries = 0; utries <= max_utries; utries++) { - gint left = self->score - (tries * TRY_POINTS) - (utries * UTRY_POINTS); + int left = self->score - (tries * TRY_POINTS) - (utries * UTRY_POINTS); if (left < 0) break; if (left % KICK_POINTS == 0) { - gint kicks = left / KICK_POINTS; + int kicks = left / KICK_POINTS; RugbyPossibility *possibility = rugby_possibility_new (tries, utries, @@ -108,7 +108,7 @@ rugby_list_store_get_item_type (GListModel *list) return RUGBY_TYPE_POSSIBILITY; } -static guint +static unsigned rugby_list_store_get_n_items (GListModel *list) { RugbyListStore *self = RUGBY_LIST_STORE (list); @@ -118,7 +118,7 @@ rugby_list_store_get_n_items (GListModel *list) static gpointer rugby_list_store_get_item (GListModel *list, - guint position) + unsigned position) { RugbyListStore *self = RUGBY_LIST_STORE (list); @@ -149,7 +149,7 @@ rugby_list_store_finalize (GObject *object) static void rugby_list_store_get_property (GObject *object, - guint prop_id, + unsigned prop_id, GValue *value, GParamSpec *pspec) { @@ -167,7 +167,7 @@ rugby_list_store_get_property (GObject *object, static void rugby_list_store_set_property (GObject *object, - guint prop_id, + unsigned prop_id, const GValue *value, GParamSpec *pspec) { @@ -215,7 +215,7 @@ rugby_list_store_init (RugbyListStore *self) // Public functions -guint +unsigned rugby_list_store_get_score (RugbyListStore *self) { g_return_val_if_fail (RUGBY_IS_LIST_STORE (self), 0); @@ -225,7 +225,7 @@ rugby_list_store_get_score (RugbyListStore *self) void rugby_list_store_set_score (RugbyListStore *self, - guint score) + unsigned score) { g_return_if_fail (RUGBY_IS_LIST_STORE (self)); diff --git a/src/rugby-list-store.h b/src/rugby-list-store.h index 9feb712093310bf670a46ba2fe2c26ad6c0d6c12..17345b1bb6366b51277eb192de7c61df2c06128b 100644 --- a/src/rugby-list-store.h +++ b/src/rugby-list-store.h @@ -15,8 +15,8 @@ G_DECLARE_FINAL_TYPE (RugbyListStore, rugby_list_store, RUGBY, LIST_STORE, GObje RugbyListStore * rugby_list_store_new (void); -guint rugby_list_store_get_score (RugbyListStore *self); +unsigned rugby_list_store_get_score (RugbyListStore *self); void rugby_list_store_set_score (RugbyListStore *self, - guint score); + unsigned score); G_END_DECLS diff --git a/src/rugby-possibility-widget.c b/src/rugby-possibility-widget.c index 712003d113183db5f7618a378353a2592535a5b3..cdb25dce42ebbad99b41858e9cc4ac5908ffc136 100644 --- a/src/rugby-possibility-widget.c +++ b/src/rugby-possibility-widget.c @@ -38,7 +38,7 @@ rugby_possibility_widget_dispose (GObject *object) static void rugby_possibility_widget_get_property (GObject *object, - guint prop_id, + unsigned prop_id, GValue *value, GParamSpec *pspec) { @@ -56,7 +56,7 @@ rugby_possibility_widget_get_property (GObject *object, static void rugby_possibility_widget_set_property (GObject *object, - guint prop_id, + unsigned prop_id, const GValue *value, GParamSpec *pspec) { @@ -74,8 +74,8 @@ rugby_possibility_widget_set_property (GObject *object, static void rugby_possibility_widget_get_preferred_height (GtkWidget *widget, - gint *minimum_height, - gint *natural_height) + int *minimum_height, + int *natural_height) { if (minimum_height) *minimum_height = FIXED_HEIGHT; @@ -86,11 +86,11 @@ rugby_possibility_widget_get_preferred_height (GtkWidget *widget, static void render_bar (cairo_t *cr, GtkStyleContext *context, - gdouble x, - gdouble y, - gdouble w, - gdouble h, - const gchar *style) + double x, + double y, + double w, + double h, + const char *style) { gtk_style_context_save (context); gtk_style_context_add_class (context, style); @@ -104,9 +104,9 @@ rugby_possibility_widget_draw (GtkWidget *widget, { RugbyPossibilityWidget *self = RUGBY_POSSIBILITY_WIDGET (widget); - gdouble width = gtk_widget_get_allocated_width (widget); - gdouble height = gtk_widget_get_allocated_height (widget); - gdouble x = 0.0, y = 0.0; + double width = gtk_widget_get_allocated_width (widget); + double height = gtk_widget_get_allocated_height (widget); + double x = 0.0, y = 0.0; GtkStyleContext *context = gtk_widget_get_style_context (widget); gtk_style_context_save (context); @@ -115,19 +115,19 @@ rugby_possibility_widget_draw (GtkWidget *widget, gtk_render_background (context, cr, x, y, width, height); gtk_render_frame (context, cr, x, y, width, height); - gint tries, utries, kicks; + int tries, utries, kicks; g_object_get (self->possibility, "tries", &tries, "utries", &utries, "kicks", &kicks, NULL); - gint score = tries * 7 + utries * 5 + kicks * 3; + int score = tries * 7 + utries * 5 + kicks * 3; gtk_style_context_add_class (context, "fill-block"); // Tries - gdouble w = width / (score / 7.0); + double w = width / (score / 7.0); for (int i = 0; i < tries; i++) { render_bar (cr, context, x, y, w, height, "score-try"); @@ -159,7 +159,7 @@ static void rugby_possibility_widget_constructed (GObject *obj) { RugbyPossibilityWidget *self = RUGBY_POSSIBILITY_WIDGET (obj); - gint tries, utries, kicks; + int tries, utries, kicks; g_autoptr (GString) tooltip = g_string_new (NULL); g_object_get (self->possibility, diff --git a/src/rugby-possibility.c b/src/rugby-possibility.c index 1372a6fdf1a78adf1f65fdf4e77bf1b28278678f..77bae16bcc9731a51529366bf5e0efa8b4c45d96 100644 --- a/src/rugby-possibility.c +++ b/src/rugby-possibility.c @@ -119,4 +119,3 @@ rugby_possibility_new (gint tries, "kicks", kicks, NULL); } - diff --git a/src/rugby-possibility.h b/src/rugby-possibility.h index db3d557e44044b636d2940e7413e2887f37849fb..be6c396aa116d98f359f96657793b20994f704b6 100644 --- a/src/rugby-possibility.h +++ b/src/rugby-possibility.h @@ -14,8 +14,8 @@ G_BEGIN_DECLS G_DECLARE_FINAL_TYPE (RugbyPossibility, rugby_possibility, RUGBY, POSSIBILITY, GObject) -RugbyPossibility * rugby_possibility_new (gint tries, - gint utries, - gint kicks); +RugbyPossibility * rugby_possibility_new (int tries, + int utries, + int kicks); G_END_DECLS