From fe3ed50e1da2bb4ced3172e86a3b244a9c3d4f1c Mon Sep 17 00:00:00 2001 From: Federico Angelilli Date: Fri, 17 Nov 2023 17:48:03 +0100 Subject: Add buttons and update draw --- src/state.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'src/state.c') 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 -- cgit v1.2.3