aboutsummaryrefslogtreecommitdiff
path: root/src/state.c
diff options
context:
space:
mode:
authorFederico Angelilli <code@fedang.net>2023-11-17 17:48:03 +0100
committerFederico Angelilli <code@fedang.net>2023-11-17 17:48:03 +0100
commitfe3ed50e1da2bb4ced3172e86a3b244a9c3d4f1c (patch)
treed78e5535144910508eb0c629253f386f16dcffe5 /src/state.c
parent032af5aeb9bd80b933672ca4b5360c33baa8d42e (diff)
Add buttons and update draw
Diffstat (limited to 'src/state.c')
-rw-r--r--src/state.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/state.c b/src/state.c
index bb31fa6..c2f2a4a 100644
--- a/src/state.c
+++ b/src/state.c
@@ -4,18 +4,25 @@
State *state_create(Window *win, Drawable *draw)
{
- State *state = g_malloc(sizeof(State));
- g_assert_nonnull(state);
+ State *state = g_malloc(sizeof(State));
+ g_assert_nonnull(state);
- state->win = win;
- state->draw = draw;
+ state->win = win;
+ state->draw = draw;
+ state->btns = NULL;
- return state;
+ return state;
+}
+
+void state_add_button(State *state, Button *btn)
+{
+ state->btns = g_list_append(state->btns, btn);
}
void state_destroy(State *state)
{
- g_free(state);
+ g_list_free_full(state->btns, (void *)button_destroy);
+ g_free(state);
}
// vim: ts=4 sw=4 et