taglist: remove show_empty attribute

This is doable in Lua.

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-07-28 11:21:39 +02:00
parent f543fe89ba
commit 88891a21e8
1 changed files with 2 additions and 35 deletions

View File

@ -53,27 +53,10 @@ DO_SLIST(taglist_drawn_area_t, taglist_drawn_area, taglist_drawn_area_delete);
/** Taglist widget private data */ /** Taglist widget private data */
typedef struct typedef struct
{ {
bool show_empty;
taglist_drawn_area_t *drawn_area; taglist_drawn_area_t *drawn_area;
luaA_function label; luaA_function label;
} taglist_data_t; } taglist_data_t;
/** Check if at least one client is tagged with tag number t.
* \param t The tag to check.
* \return True if the tag has a client, false otherwise.
*/
static bool
tag_isoccupied(tag_t *t)
{
client_t *c;
for(c = globalconf.clients; c; c = c->next)
if(!c->skip && is_client_tagged(c, t))
return true;
return false;
}
/** Draw a taglist. /** Draw a taglist.
* \param ctx The draw context. * \param ctx The draw context.
* \param screen The screen we're drawing for. * \param screen The screen we're drawing for.
@ -136,8 +119,7 @@ taglist_draw(draw_context_t *ctx, int screen, widget_node_t *w,
if(pdata[i].bg_image) if(pdata[i].bg_image)
area.width = MAX(area.width, pdata[i].bg_resize ? w->area.height : pdata[i].bg_image->width); area.width = MAX(area.width, pdata[i].bg_resize ? w->area.height : pdata[i].bg_image->width);
if(data->show_empty || tag->selected || tag_isoccupied(tag)) w->area.width += area.width;
w->area.width += area.width;
area_array_append(&tda->areas, area); area_array_append(&tda->areas, area);
} }
@ -148,15 +130,8 @@ taglist_draw(draw_context_t *ctx, int screen, widget_node_t *w,
for(int i = 0; i < tags->len; i++) for(int i = 0; i < tags->len; i++)
{ {
tag_t *tag = tags->tab[i];
area_t *r = &tda->areas.tab[i]; area_t *r = &tda->areas.tab[i];
if(!data->show_empty && !tag->selected && !tag_isoccupied(tag))
{
draw_parser_data_wipe(&pdata[i]);
continue;
}
r->x = w->area.x + prev_width; r->x = w->area.x + prev_width;
prev_width += r->width; prev_width += r->width;
draw_text(ctx, globalconf.font, *r, text[i], len[i], &pdata[i]); draw_text(ctx, globalconf.font, *r, text[i], len[i], &pdata[i]);
@ -196,8 +171,7 @@ taglist_button_press(widget_node_t *w,
tag_t *tag = tags->tab[i]; tag_t *tag = tags->tab[i];
area_t *area = &tda->areas.tab[i]; area_t *area = &tda->areas.tab[i];
if(ev->event_x >= AREA_LEFT(*area) if(ev->event_x >= AREA_LEFT(*area)
&& ev->event_x < AREA_RIGHT(*area) && ev->event_x < AREA_RIGHT(*area))
&& (data->show_empty || tag->selected || tag_isoccupied(tag)) )
{ {
luaA_pushpointer(globalconf.L, object, type); luaA_pushpointer(globalconf.L, object, type);
luaA_tag_userdata_new(globalconf.L, tag); luaA_tag_userdata_new(globalconf.L, tag);
@ -220,9 +194,6 @@ luaA_taglist_index(lua_State *L, awesome_token_t token)
switch(token) switch(token)
{ {
case A_TK_SHOW_EMPTY:
lua_pushboolean(L, d->show_empty);
return 1;
case A_TK_LABEL: case A_TK_LABEL:
lua_rawgeti(L, LUA_REGISTRYINDEX, d->label); lua_rawgeti(L, LUA_REGISTRYINDEX, d->label);
return 1; return 1;
@ -244,9 +215,6 @@ luaA_taglist_newindex(lua_State *L, awesome_token_t token)
switch(token) switch(token)
{ {
case A_TK_SHOW_EMPTY:
d->show_empty = luaA_checkboolean(L, 3);
break;
case A_TK_LABEL: case A_TK_LABEL:
luaA_registerfct(L, &d->label); luaA_registerfct(L, &d->label);
break; break;
@ -291,7 +259,6 @@ taglist_new(alignment_t align)
w->destructor = taglist_destructor; w->destructor = taglist_destructor;
w->data = d = p_new(taglist_data_t, 1); w->data = d = p_new(taglist_data_t, 1);
d->show_empty = true;
d->label = LUA_REFNIL; d->label = LUA_REFNIL;
/* Set cache property */ /* Set cache property */