aboutsummaryrefslogtreecommitdiff
path: root/src/dwm.c
diff options
context:
space:
mode:
authorFederico Angelilli <code@fedang.net>2024-02-08 12:40:56 +0100
committerFederico Angelilli <code@fedang.net>2024-02-08 12:40:56 +0100
commita81b8b36afad38e93ab2051e26d21d6125a46eca (patch)
treecfa3ff11138783f7a85c6658a3f3284269e9a366 /src/dwm.c
parent09505cb480274bdc154c1b4ae3dd6988e56b4368 (diff)
Add dwm tags
Diffstat (limited to 'src/dwm.c')
-rw-r--r--src/dwm.c17
1 files changed, 16 insertions, 1 deletions
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);