diff --git a/src/main.c b/src/main.c index a783419efb449e56eb5e9e5ccd7437d1764fd07d..e309cb5901801bd158f7aeee18568ca90ddcadda 100644 --- a/src/main.c +++ b/src/main.c @@ -3,17 +3,20 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ -#include <gtk/gtk.h> - #include "config.h" + #include "rugby-app-window.h" +static GtkWidget *window = NULL; + static void on_activate (GApplication *app, gpointer user_data) { - RugbyAppWindow *win = rugby_app_window_new (GTK_APPLICATION (app)); - gtk_window_present (GTK_WINDOW (win)); + if (!window) + window = GTK_WIDGET (rugby_app_window_new (GTK_APPLICATION (app))); + + gtk_window_present (GTK_WINDOW (window)); } static void diff --git a/src/rugby-app-window.c b/src/rugby-app-window.c index 26ed1b86e7629bd672c3abb6b4e67f52491650db..9200cdaa61651eab6be30dce1da238bbc37a8225 100644 --- a/src/rugby-app-window.c +++ b/src/rugby-app-window.c @@ -3,10 +3,9 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ -#include <gtk/gtk.h> - #include "config.h" #include "rugby-app-window.h" + #include "rugby-list-store.h" #include "rugby-possibility.h" #include "rugby-possibility-widget.h" @@ -27,7 +26,6 @@ scorespin_value_changed_cb (GtkSpinButton *spin, RugbyAppWindow *self) { int score = gtk_spin_button_get_value_as_int (spin); - rugby_list_store_set_score (self->store, score); } @@ -73,8 +71,8 @@ rugby_app_window_class_init (RugbyAppWindowClass *klass) gtk_widget_class_set_template_from_resource (widget_class, "/uk/me/bcowan/rugby/interface.ui"); - gtk_widget_class_bind_template_child (widget_class, RugbyAppWindow, listbox); + gtk_widget_class_bind_template_child (widget_class, RugbyAppWindow, listbox); gtk_widget_class_bind_template_callback (widget_class, scorespin_value_changed_cb); } diff --git a/src/rugby-list-store.c b/src/rugby-list-store.c index c1034813f38a753842e069e3189319abf9912a09..95b1f1fa74268e53f45c85c284b1663fb19bfd19 100644 --- a/src/rugby-list-store.c +++ b/src/rugby-list-store.c @@ -2,9 +2,9 @@ * SPDX-FileCopyrightText: 2018 Bruce Cowan <bruce@bcowan.me.uk> * SPDX-License-Identifier: GPL-3.0-or-later */ - #include "config.h" #include "rugby-list-store.h" + #include "rugby-possibility.h" #include <gio/gio.h> @@ -13,8 +13,8 @@ struct _RugbyListStore { GObject parent_instance; - unsigned score; GPtrArray *items; + int score; }; static void rugby_list_store_list_model_iface_init (GListModelInterface *iface); @@ -157,7 +157,7 @@ rugby_list_store_get_property (GObject *object, switch (prop_id) { case PROP_SCORE: - g_value_set_uint (value, rugby_list_store_get_score (self)); + g_value_set_int (value, rugby_list_store_get_score (self)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -175,7 +175,7 @@ rugby_list_store_set_property (GObject *object, switch (prop_id) { case PROP_SCORE: - rugby_list_store_set_score (self, g_value_get_uint (value)); + rugby_list_store_set_score (self, g_value_get_int (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -191,11 +191,11 @@ rugby_list_store_class_init (RugbyListStoreClass *klass) object_class->get_property = rugby_list_store_get_property; object_class->set_property = rugby_list_store_set_property; - properties[PROP_SCORE] = g_param_spec_uint ("score", - "Score", - "Score of the match", - 0, 200, 0, - G_PARAM_READWRITE); + properties[PROP_SCORE] = g_param_spec_int ("score", + "Score", + "Score of the match", + 0, 200, 0, + G_PARAM_READWRITE); g_object_class_install_properties (object_class, N_PROPS, @@ -214,7 +214,7 @@ rugby_list_store_init (RugbyListStore *self) // Public functions -unsigned +int rugby_list_store_get_score (RugbyListStore *self) { g_return_val_if_fail (RUGBY_IS_LIST_STORE (self), 0); @@ -224,7 +224,7 @@ rugby_list_store_get_score (RugbyListStore *self) void rugby_list_store_set_score (RugbyListStore *self, - unsigned score) + int 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 d0966a93975b08d48407227d101df334538c8e35..0f420db9ce72f16ed5c24502a11b03c14e0a087b 100644 --- a/src/rugby-list-store.h +++ b/src/rugby-list-store.h @@ -14,8 +14,8 @@ G_DECLARE_FINAL_TYPE (RugbyListStore, rugby_list_store, RUGBY, LIST_STORE, GObje RugbyListStore * rugby_list_store_new (void); -unsigned rugby_list_store_get_score (RugbyListStore *self); +int rugby_list_store_get_score (RugbyListStore *self); void rugby_list_store_set_score (RugbyListStore *self, - unsigned score); + int score); G_END_DECLS diff --git a/src/rugby-possibility-widget.c b/src/rugby-possibility-widget.c index 173d0e7ef6f21aaf504c32e3710318d9583d7ce9..c1503775e2c87761b8c4709b4cc1668964cd8f02 100644 --- a/src/rugby-possibility-widget.c +++ b/src/rugby-possibility-widget.c @@ -3,6 +3,7 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ +#include "config.h" #include "rugby-possibility-widget.h" struct _RugbyPossibilityWidget @@ -112,7 +113,6 @@ rugby_possibility_widget_draw (GtkWidget *widget, gtk_style_context_add_class (context, "possibility"); gtk_render_background (context, cr, x, y, width, height); - gtk_render_frame (context, cr, x, y, width, height); int tries, utries, kicks; diff --git a/src/rugby-possibility.c b/src/rugby-possibility.c index ed4c6ae009e25ae3275d90d9d46ed1aa55a7567b..0cadfbbdef57c1f9090976ec14def04044bfb7f7 100644 --- a/src/rugby-possibility.c +++ b/src/rugby-possibility.c @@ -3,6 +3,7 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ +#include "config.h" #include "rugby-possibility.h" struct _RugbyPossibility