Add a function that adds an entry to a menuq, normalizing a common code

path; from Tiago Cunha.
This commit is contained in:
okan
2014-01-20 18:58:03 +00:00
parent 43ccf4eae0
commit 720b5452aa
6 changed files with 34 additions and 49 deletions

11
group.c
View File

@ -324,15 +324,8 @@ group_menu(struct screen_ctx *sc)
if (TAILQ_EMPTY(&gc->clients))
continue;
mi = xcalloc(1, sizeof(*mi));
if (gc->hidden)
(void)snprintf(mi->text, sizeof(mi->text), "%d: [%s]",
gc->shortcut, sc->group_names[i]);
else
(void)snprintf(mi->text, sizeof(mi->text), "%d: %s",
gc->shortcut, sc->group_names[i]);
mi->ctx = gc;
TAILQ_INSERT_TAIL(&menuq, mi, entry);
menuq_add(&menuq, gc, gc->hidden ? "%d: [%s]" : "%d: %s",
gc->shortcut, sc->group_names[i]);
}
if (TAILQ_EMPTY(&menuq))