diff options
| author | Federico Angelilli <code@fedang.net> | 2024-03-14 02:00:21 +0100 |
|---|---|---|
| committer | Federico Angelilli <code@fedang.net> | 2024-03-14 02:00:21 +0100 |
| commit | 93c4dc6893e733f563e70c315537922d55adfab2 (patch) | |
| tree | 245e84a64fed1dd56cc9e91b4fa415384caf9322 /src/state.c | |
| parent | 398fdbaa5c02bbd138c59004053d2e8ad0082ead (diff) | |
Refactor code and start adding shine animation
Diffstat (limited to 'src/state.c')
| -rw-r--r-- | src/state.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/state.c b/src/state.c index 2051652..134e644 100644 --- a/src/state.c +++ b/src/state.c @@ -25,6 +25,21 @@ void state_remove_button(State *state, Button *btn) state->btns = g_list_remove(state->btns, btn); } +static gint align_compare(gconstpointer a, gconstpointer b) +{ + PangoAlignment a_align = CAST(a, Button)->align; + PangoAlignment b_align = CAST(b, Button)->align; + + if (a_align < b_align) return -1; + if (a_align > b_align) return 1; + return 0; +} + +void state_order_button(State *state) +{ + state->btns = g_list_sort(state->btns, align_compare); +} + static gboolean redraw_handler(gpointer data) { State *state = data; @@ -54,21 +69,6 @@ void state_redraw(State *state, bool changed_layout) state->id = g_idle_add_full(G_PRIORITY_HIGH_IDLE, redraw_handler, state, NULL); } -static gint align_compare(gconstpointer a, gconstpointer b) -{ - PangoAlignment a_align = ((Button *)a)->align; - PangoAlignment b_align = ((Button *)b)->align; - - if (a_align < b_align) return -1; - if (a_align > b_align) return 1; - return 0; -} - -void state_order_button(State *state) -{ - state->btns = g_list_sort(state->btns, align_compare); -} - void state_destroy(State *state) { g_list_free_full(state->btns, (void *)button_destroy); |
