Skip to content
Snippets Groups Projects
Commit 5533f5b7 authored by Bruce Cowan's avatar Bruce Cowan
Browse files

Various small changes

* Represent window if it already exists
* Always include config.h
* Make RugbyListScore:score not unsigned
* Remove drawing frame because it doesn't do anything
parent aaa030d6
No related branches found
No related tags found
No related merge requests found
Pipeline #2669 passed
...@@ -3,17 +3,20 @@ ...@@ -3,17 +3,20 @@
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
*/ */
#include <gtk/gtk.h>
#include "config.h" #include "config.h"
#include "rugby-app-window.h" #include "rugby-app-window.h"
static GtkWidget *window = NULL;
static void static void
on_activate (GApplication *app, on_activate (GApplication *app,
gpointer user_data) gpointer user_data)
{ {
RugbyAppWindow *win = rugby_app_window_new (GTK_APPLICATION (app)); if (!window)
gtk_window_present (GTK_WINDOW (win)); window = GTK_WIDGET (rugby_app_window_new (GTK_APPLICATION (app)));
gtk_window_present (GTK_WINDOW (window));
} }
static void static void
......
...@@ -3,10 +3,9 @@ ...@@ -3,10 +3,9 @@
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
*/ */
#include <gtk/gtk.h>
#include "config.h" #include "config.h"
#include "rugby-app-window.h" #include "rugby-app-window.h"
#include "rugby-list-store.h" #include "rugby-list-store.h"
#include "rugby-possibility.h" #include "rugby-possibility.h"
#include "rugby-possibility-widget.h" #include "rugby-possibility-widget.h"
...@@ -27,7 +26,6 @@ scorespin_value_changed_cb (GtkSpinButton *spin, ...@@ -27,7 +26,6 @@ scorespin_value_changed_cb (GtkSpinButton *spin,
RugbyAppWindow *self) RugbyAppWindow *self)
{ {
int 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); rugby_list_store_set_score (self->store, score);
} }
...@@ -73,8 +71,8 @@ rugby_app_window_class_init (RugbyAppWindowClass *klass) ...@@ -73,8 +71,8 @@ rugby_app_window_class_init (RugbyAppWindowClass *klass)
gtk_widget_class_set_template_from_resource (widget_class, gtk_widget_class_set_template_from_resource (widget_class,
"/uk/me/bcowan/rugby/interface.ui"); "/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); gtk_widget_class_bind_template_callback (widget_class, scorespin_value_changed_cb);
} }
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* SPDX-FileCopyrightText: 2018 Bruce Cowan <bruce@bcowan.me.uk> * SPDX-FileCopyrightText: 2018 Bruce Cowan <bruce@bcowan.me.uk>
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
*/ */
#include "config.h" #include "config.h"
#include "rugby-list-store.h" #include "rugby-list-store.h"
#include "rugby-possibility.h" #include "rugby-possibility.h"
#include <gio/gio.h> #include <gio/gio.h>
...@@ -13,8 +13,8 @@ struct _RugbyListStore ...@@ -13,8 +13,8 @@ struct _RugbyListStore
{ {
GObject parent_instance; GObject parent_instance;
unsigned score;
GPtrArray *items; GPtrArray *items;
int score;
}; };
static void rugby_list_store_list_model_iface_init (GListModelInterface *iface); static void rugby_list_store_list_model_iface_init (GListModelInterface *iface);
...@@ -157,7 +157,7 @@ rugby_list_store_get_property (GObject *object, ...@@ -157,7 +157,7 @@ rugby_list_store_get_property (GObject *object,
switch (prop_id) switch (prop_id)
{ {
case PROP_SCORE: 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; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
...@@ -175,7 +175,7 @@ rugby_list_store_set_property (GObject *object, ...@@ -175,7 +175,7 @@ rugby_list_store_set_property (GObject *object,
switch (prop_id) switch (prop_id)
{ {
case PROP_SCORE: 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; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
...@@ -191,11 +191,11 @@ rugby_list_store_class_init (RugbyListStoreClass *klass) ...@@ -191,11 +191,11 @@ rugby_list_store_class_init (RugbyListStoreClass *klass)
object_class->get_property = rugby_list_store_get_property; object_class->get_property = rugby_list_store_get_property;
object_class->set_property = rugby_list_store_set_property; object_class->set_property = rugby_list_store_set_property;
properties[PROP_SCORE] = g_param_spec_uint ("score", properties[PROP_SCORE] = g_param_spec_int ("score",
"Score", "Score",
"Score of the match", "Score of the match",
0, 200, 0, 0, 200, 0,
G_PARAM_READWRITE); G_PARAM_READWRITE);
g_object_class_install_properties (object_class, g_object_class_install_properties (object_class,
N_PROPS, N_PROPS,
...@@ -214,7 +214,7 @@ rugby_list_store_init (RugbyListStore *self) ...@@ -214,7 +214,7 @@ rugby_list_store_init (RugbyListStore *self)
// Public functions // Public functions
unsigned int
rugby_list_store_get_score (RugbyListStore *self) rugby_list_store_get_score (RugbyListStore *self)
{ {
g_return_val_if_fail (RUGBY_IS_LIST_STORE (self), 0); g_return_val_if_fail (RUGBY_IS_LIST_STORE (self), 0);
...@@ -224,7 +224,7 @@ rugby_list_store_get_score (RugbyListStore *self) ...@@ -224,7 +224,7 @@ rugby_list_store_get_score (RugbyListStore *self)
void void
rugby_list_store_set_score (RugbyListStore *self, rugby_list_store_set_score (RugbyListStore *self,
unsigned score) int score)
{ {
g_return_if_fail (RUGBY_IS_LIST_STORE (self)); g_return_if_fail (RUGBY_IS_LIST_STORE (self));
......
...@@ -14,8 +14,8 @@ G_DECLARE_FINAL_TYPE (RugbyListStore, rugby_list_store, RUGBY, LIST_STORE, GObje ...@@ -14,8 +14,8 @@ G_DECLARE_FINAL_TYPE (RugbyListStore, rugby_list_store, RUGBY, LIST_STORE, GObje
RugbyListStore * rugby_list_store_new (void); 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, void rugby_list_store_set_score (RugbyListStore *self,
unsigned score); int score);
G_END_DECLS G_END_DECLS
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
*/ */
#include "config.h"
#include "rugby-possibility-widget.h" #include "rugby-possibility-widget.h"
struct _RugbyPossibilityWidget struct _RugbyPossibilityWidget
...@@ -112,7 +113,6 @@ rugby_possibility_widget_draw (GtkWidget *widget, ...@@ -112,7 +113,6 @@ rugby_possibility_widget_draw (GtkWidget *widget,
gtk_style_context_add_class (context, "possibility"); gtk_style_context_add_class (context, "possibility");
gtk_render_background (context, cr, x, y, width, height); gtk_render_background (context, cr, x, y, width, height);
gtk_render_frame (context, cr, x, y, width, height);
int tries, utries, kicks; int tries, utries, kicks;
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
*/ */
#include "config.h"
#include "rugby-possibility.h" #include "rugby-possibility.h"
struct _RugbyPossibility struct _RugbyPossibility
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment