From a81b8b36afad38e93ab2051e26d21d6125a46eca Mon Sep 17 00:00:00 2001 From: Federico Angelilli Date: Thu, 8 Feb 2024 12:40:56 +0100 Subject: Add dwm tags --- src/dwm.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/dwm.c') diff --git a/src/dwm.c b/src/dwm.c index 1ac0271..990f269 100644 --- a/src/dwm.c +++ b/src/dwm.c @@ -277,12 +277,27 @@ static void change_tag_action(Button *btn) { ButtonSimple *sbtn = CAST(btn, ButtonSimple); - g_assert(sbtn->text[0] >= 1 && sbtn->text[0] <= 9); int n = sbtn->text[0] - '0'; + g_assert(n >= 1 && n <= 9); log_debug("Toggled tag %d",n ); } +void dwm_register_tags(DwmIpc *dwm, Color color, Color selected, Color text_color, Color line_color) +{ + dwm->color = color; + dwm->selected = selected; + + // Tags button + for (int i = 0; i < 9; ++i) { + char text[] = { '1' + i, '\0' }; + dwm->tags[i] = button_simple_create(PANGO_ALIGN_LEFT, color, line_color); + button_simple_set_text(dwm->tags[i], g_strdup(text), text_color); + button_simple_set_action(dwm->tags[i], change_tag_action, dwm->state); + state_add_button(dwm->state, dwm->tags[i]); + } +} + void dwm_destroy(DwmIpc *dwm) { g_source_destroy((GSource *)dwm); -- cgit v1.2.3