2008-01-03 12:39:28 +01:00
|
|
|
/*
|
|
|
|
* tasklist.c - task list widget
|
|
|
|
*
|
|
|
|
* Copyright © 2008 Julien Danjou <julien@danjou.info>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2008-07-31 15:51:28 +02:00
|
|
|
#include "client.h"
|
2008-01-03 12:39:28 +01:00
|
|
|
#include "widget.h"
|
2008-06-09 21:43:09 +02:00
|
|
|
#include "tag.h"
|
2008-09-21 20:39:23 +02:00
|
|
|
#include "wibox.h"
|
2008-06-05 06:12:04 +02:00
|
|
|
#include "common/markup.h"
|
2008-06-23 14:12:01 +02:00
|
|
|
#include "common/tokenize.h"
|
2008-01-03 12:39:28 +01:00
|
|
|
|
2008-05-24 08:59:27 +02:00
|
|
|
extern awesome_t globalconf;
|
2008-01-03 12:39:28 +01:00
|
|
|
|
2008-07-28 15:56:22 +02:00
|
|
|
/** Link a client and a label */
|
|
|
|
typedef struct
|
2008-02-06 20:03:18 +01:00
|
|
|
{
|
2008-07-28 15:56:22 +02:00
|
|
|
/** A client */
|
|
|
|
client_t *client;
|
|
|
|
/** The client label */
|
|
|
|
char *label;
|
|
|
|
/** The client label len */
|
|
|
|
size_t label_len;
|
|
|
|
} client_label_t;
|
|
|
|
|
|
|
|
/** Delete a client label.
|
|
|
|
* \param l The client label.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
client_label_wipe(client_label_t *l)
|
|
|
|
{
|
|
|
|
p_delete(&l->label);
|
|
|
|
}
|
|
|
|
|
|
|
|
DO_ARRAY(client_label_t, client_label, client_label_wipe)
|
|
|
|
|
|
|
|
typedef struct tasklist_object_data_t tasklist_object_data_t;
|
|
|
|
/** Link an object with a client label array and other infos */
|
|
|
|
struct tasklist_object_data_t
|
|
|
|
{
|
|
|
|
/** The object */
|
2008-09-21 10:13:21 +02:00
|
|
|
wibox_t *object;
|
2008-07-28 15:56:22 +02:00
|
|
|
/** The box width for each client */
|
|
|
|
int box_width;
|
|
|
|
/** The client label array for the object */
|
|
|
|
client_label_array_t client_labels;
|
|
|
|
/** This is a list */
|
|
|
|
tasklist_object_data_t *prev, *next;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
tasklist_object_data_delete(tasklist_object_data_t **l)
|
|
|
|
{
|
|
|
|
client_label_array_wipe(&(*l)->client_labels);
|
|
|
|
p_delete(l);
|
|
|
|
}
|
|
|
|
|
|
|
|
DO_SLIST(tasklist_object_data_t, tasklist_object_data, tasklist_object_data_delete)
|
2008-02-06 20:03:18 +01:00
|
|
|
|
2008-06-25 17:47:51 +02:00
|
|
|
/** The tasklist private data structure. */
|
2008-01-03 12:39:28 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
2008-03-21 16:50:17 +01:00
|
|
|
bool show_icons;
|
2008-08-11 10:12:12 +02:00
|
|
|
luaA_ref label;
|
2008-07-28 15:56:22 +02:00
|
|
|
tasklist_object_data_t *objects_data;
|
2008-09-15 16:32:05 +02:00
|
|
|
bool invert;
|
2008-06-14 22:55:17 +02:00
|
|
|
} tasklist_data_t;
|
2008-01-03 12:39:28 +01:00
|
|
|
|
2008-07-28 15:56:22 +02:00
|
|
|
/** Get an object data by its object.
|
|
|
|
* \param od The object data list.
|
|
|
|
* \param p The object.
|
|
|
|
* \return A object data or NULL if not found.
|
2008-06-25 17:47:51 +02:00
|
|
|
*/
|
2008-07-28 15:56:22 +02:00
|
|
|
static tasklist_object_data_t *
|
2008-09-21 10:13:21 +02:00
|
|
|
tasklist_object_data_getbyobj(tasklist_object_data_t *od, wibox_t *p)
|
2008-02-06 20:03:18 +01:00
|
|
|
{
|
2008-07-28 15:56:22 +02:00
|
|
|
tasklist_object_data_t *o;
|
2008-02-06 20:03:18 +01:00
|
|
|
|
2008-07-28 15:56:22 +02:00
|
|
|
for(o = od; o; o = o->next)
|
|
|
|
if(o->object == p)
|
|
|
|
return o;
|
|
|
|
|
|
|
|
return NULL;
|
2008-02-06 20:03:18 +01:00
|
|
|
}
|
|
|
|
|
2008-09-15 16:32:05 +02:00
|
|
|
/** Draw an item in a tasklist widget.
|
|
|
|
* \param ctx The draw context, must be the same used to draw the tasklist
|
|
|
|
* \param w Tasklist widget node
|
|
|
|
* \param odata Tasklist object data
|
|
|
|
* \param width_mod Width modification of the item
|
|
|
|
* \param pos Position to draw the item at
|
|
|
|
* \param i Item to draw
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
tasklist_draw_item(draw_context_t *ctx,
|
|
|
|
widget_node_t *w,
|
|
|
|
tasklist_object_data_t *odata,
|
|
|
|
int width_mod, int pos, int i) {
|
|
|
|
draw_parser_data_t pdata, *parser_data;
|
2008-09-17 16:38:38 +02:00
|
|
|
image_t *image;
|
2008-09-15 16:32:05 +02:00
|
|
|
area_t area;
|
|
|
|
tasklist_data_t *d = w->widget->data;
|
|
|
|
int icon_width = 0;
|
|
|
|
|
|
|
|
if(d->show_icons)
|
|
|
|
{
|
|
|
|
draw_parser_data_init(&pdata);
|
|
|
|
|
|
|
|
/* Actually look for the proper background color, since
|
|
|
|
* otherwise the background statusbar color is used instead */
|
|
|
|
if(draw_text_markup_expand(&pdata,
|
|
|
|
odata->client_labels.tab[i].label,
|
|
|
|
odata->client_labels.tab[i].label_len))
|
|
|
|
{
|
|
|
|
parser_data = &pdata;
|
|
|
|
if(pdata.has_bg_color)
|
|
|
|
{
|
|
|
|
/* draw a background for icons */
|
|
|
|
area.x = w->area.x + pos;
|
|
|
|
area.y = w->area.y;
|
|
|
|
area.height = ctx->height;
|
|
|
|
area.width = odata->box_width;
|
|
|
|
draw_rectangle(ctx, area, 1.0, true, &pdata.bg_color);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
parser_data = NULL;
|
|
|
|
|
2008-09-11 15:26:56 +02:00
|
|
|
if(odata->client_labels.tab[i].client->icon)
|
2008-09-15 16:32:05 +02:00
|
|
|
{
|
2008-09-17 16:38:38 +02:00
|
|
|
image = odata->client_labels.tab[i].client->icon;
|
2008-09-15 16:32:05 +02:00
|
|
|
icon_width = ((double) ctx->height / (double) image->height) * image->width;
|
2008-09-11 14:49:42 +02:00
|
|
|
draw_image(ctx, w->area.x + odata->box_width * i,
|
2008-09-15 16:32:05 +02:00
|
|
|
w->area.y, ctx->height, image);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
parser_data = NULL;
|
|
|
|
|
|
|
|
area.x = w->area.x + icon_width + pos;
|
|
|
|
area.y = w->area.y;
|
|
|
|
area.width = odata->box_width - icon_width + width_mod;
|
|
|
|
area.height = ctx->height;
|
|
|
|
|
|
|
|
draw_text(ctx, globalconf.font, area,
|
|
|
|
odata->client_labels.tab[i].label,
|
|
|
|
odata->client_labels.tab[i].label_len,
|
|
|
|
parser_data);
|
|
|
|
draw_parser_data_wipe(parser_data);
|
|
|
|
}
|
|
|
|
|
2008-06-25 17:47:51 +02:00
|
|
|
/** Draw a tasklist widget.
|
|
|
|
* \param ctx The draw context.
|
|
|
|
* \param screen The screen number.
|
|
|
|
* \param w The widget node we are called from.
|
|
|
|
* \param offset The offset to draw at.
|
|
|
|
* \param used The already used width.
|
|
|
|
* \param p A pointer to the object we're drawing onto.
|
2008-07-29 16:51:21 +02:00
|
|
|
* \return The widget width.
|
2008-06-25 17:47:51 +02:00
|
|
|
*/
|
2008-01-03 12:39:28 +01:00
|
|
|
static int
|
2008-06-02 12:18:17 +02:00
|
|
|
tasklist_draw(draw_context_t *ctx, int screen,
|
2008-06-03 16:08:33 +02:00
|
|
|
widget_node_t *w,
|
2008-09-21 20:39:23 +02:00
|
|
|
int offset, int used, wibox_t *p)
|
2008-01-03 12:39:28 +01:00
|
|
|
{
|
2008-04-11 11:35:11 +02:00
|
|
|
client_t *c;
|
2008-06-14 22:55:17 +02:00
|
|
|
tasklist_data_t *d = w->widget->data;
|
2008-09-15 16:32:05 +02:00
|
|
|
int i = 0, box_width_rest = 0, pos = 0;
|
2008-07-28 15:56:22 +02:00
|
|
|
tasklist_object_data_t *odata;
|
2008-01-03 12:39:28 +01:00
|
|
|
|
2008-06-03 16:08:33 +02:00
|
|
|
if(used >= ctx->width)
|
2008-05-20 15:39:47 +02:00
|
|
|
return (w->area.width = 0);
|
2008-01-22 17:52:12 +01:00
|
|
|
|
2008-07-28 15:56:22 +02:00
|
|
|
if(!(odata = tasklist_object_data_getbyobj(d->objects_data, p)))
|
|
|
|
{
|
|
|
|
odata = p_new(tasklist_object_data_t, 1);
|
|
|
|
odata->object = p;
|
|
|
|
tasklist_object_data_list_push(&d->objects_data, odata);
|
|
|
|
}
|
2008-01-04 22:05:52 +01:00
|
|
|
|
2008-07-28 15:56:22 +02:00
|
|
|
client_label_array_wipe(&odata->client_labels);
|
|
|
|
client_label_array_init(&odata->client_labels);
|
2008-01-03 12:39:28 +01:00
|
|
|
|
|
|
|
for(c = globalconf.clients; c; c = c->next)
|
2008-09-05 01:40:10 +02:00
|
|
|
if(!c->skiptb
|
2008-09-06 13:52:05 +02:00
|
|
|
&& !c->ishidden
|
2008-09-05 01:40:10 +02:00
|
|
|
&& c->type != WINDOW_TYPE_SPLASH
|
|
|
|
&& c->type != WINDOW_TYPE_DOCK
|
|
|
|
&& c->type != WINDOW_TYPE_DESKTOP)
|
2008-01-03 12:39:28 +01:00
|
|
|
{
|
2008-07-09 12:12:52 +02:00
|
|
|
/* push client */
|
|
|
|
luaA_client_userdata_new(globalconf.L, c);
|
2008-07-28 15:56:22 +02:00
|
|
|
/* push screen we're at */
|
|
|
|
lua_pushnumber(globalconf.L, screen + 1);
|
2008-07-09 12:12:52 +02:00
|
|
|
/* call label function with client as argument and wait for one
|
|
|
|
* result */
|
2008-07-29 11:03:57 +02:00
|
|
|
if(luaA_dofunction(globalconf.L, d->label, 2, 1))
|
2008-07-10 09:56:23 +02:00
|
|
|
{
|
2008-07-29 11:03:57 +02:00
|
|
|
/* If we got a string as returned value, we got something to write:
|
|
|
|
* a label. So we store it in a client_label_t structure, pushed
|
|
|
|
* into the client_label_array_t which is owned by the object. */
|
|
|
|
if(lua_isstring(globalconf.L, -1))
|
|
|
|
{
|
|
|
|
client_label_t cl;
|
|
|
|
cl.client = c;
|
|
|
|
cl.label = a_strdup(lua_tolstring(globalconf.L, -1, &cl.label_len));
|
|
|
|
client_label_array_append(&odata->client_labels, cl);
|
|
|
|
}
|
|
|
|
|
|
|
|
lua_pop(globalconf.L, 1);
|
2008-07-10 09:56:23 +02:00
|
|
|
}
|
2008-07-28 15:56:22 +02:00
|
|
|
}
|
2008-03-14 08:35:06 +01:00
|
|
|
|
2008-07-28 15:56:22 +02:00
|
|
|
if(!odata->client_labels.len)
|
|
|
|
return (w->area.width = 0);
|
|
|
|
|
|
|
|
odata->box_width = (ctx->width - used) / odata->client_labels.len;
|
|
|
|
/* compute how many pixel we left empty */
|
|
|
|
box_width_rest = (ctx->width - used) % odata->client_labels.len;
|
2008-06-22 17:45:45 +02:00
|
|
|
|
2008-07-28 15:56:22 +02:00
|
|
|
w->area.x = widget_calculate_offset(ctx->width,
|
|
|
|
0, offset, w->widget->align);
|
2008-03-14 08:35:06 +01:00
|
|
|
|
2008-07-28 15:56:22 +02:00
|
|
|
w->area.y = 0;
|
2008-07-10 17:10:15 +02:00
|
|
|
|
2008-09-15 16:32:05 +02:00
|
|
|
if(d->invert)
|
|
|
|
for(i = odata->client_labels.len - 1; i >= 0; i--)
|
2008-07-28 15:56:22 +02:00
|
|
|
{
|
2008-09-15 16:32:05 +02:00
|
|
|
/* if we're on last elem, it has the last pixels left. */
|
|
|
|
if (i == 0)
|
|
|
|
tasklist_draw_item(ctx, w, odata, 0, pos, i);
|
2008-07-10 17:10:15 +02:00
|
|
|
else
|
2008-09-15 16:32:05 +02:00
|
|
|
tasklist_draw_item(ctx, w, odata, box_width_rest, pos, i);
|
|
|
|
pos += odata->box_width;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
for(i = 0; i < odata->client_labels.len; i++)
|
|
|
|
{
|
|
|
|
/* if we're on last elem, it has the last pixels left. */
|
|
|
|
if(i != odata->client_labels.len - 1)
|
|
|
|
tasklist_draw_item(ctx, w, odata, 0, pos , i);
|
|
|
|
else
|
|
|
|
tasklist_draw_item(ctx, w, odata, box_width_rest, pos, i);
|
|
|
|
pos += odata->box_width;
|
2008-01-03 12:39:28 +01:00
|
|
|
}
|
|
|
|
|
2008-06-03 16:08:33 +02:00
|
|
|
w->area.width = ctx->width - used;
|
|
|
|
w->area.height = ctx->height;
|
2008-01-03 12:39:28 +01:00
|
|
|
|
2008-05-20 15:39:47 +02:00
|
|
|
return w->area.width;
|
2008-01-03 12:39:28 +01:00
|
|
|
}
|
|
|
|
|
2008-06-04 19:21:21 +02:00
|
|
|
/** Handle button click on tasklist.
|
|
|
|
* \param w The widget node.
|
|
|
|
* \param ev The button press event.
|
|
|
|
* \param screen The screen where the click was.
|
|
|
|
* \param object The object we're onto.
|
|
|
|
*/
|
2008-01-03 12:39:28 +01:00
|
|
|
static void
|
2008-08-12 13:23:10 +02:00
|
|
|
tasklist_button(widget_node_t *w,
|
|
|
|
xcb_button_press_event_t *ev,
|
|
|
|
int screen,
|
2008-09-21 20:39:23 +02:00
|
|
|
wibox_t *object)
|
2008-01-03 12:39:28 +01:00
|
|
|
{
|
2008-06-14 22:55:17 +02:00
|
|
|
tasklist_data_t *d = w->widget->data;
|
2008-07-28 15:56:22 +02:00
|
|
|
int ci = 0;
|
|
|
|
tasklist_object_data_t *odata;
|
2008-08-12 13:23:10 +02:00
|
|
|
button_array_t *barr = &w->widget->buttons;
|
2008-01-03 12:39:28 +01:00
|
|
|
|
2008-07-28 15:56:22 +02:00
|
|
|
odata = tasklist_object_data_getbyobj(d->objects_data, object);
|
2008-02-13 06:53:08 +01:00
|
|
|
|
2008-07-28 15:56:22 +02:00
|
|
|
if(!odata || !odata->client_labels.len)
|
2008-05-20 15:39:47 +02:00
|
|
|
return;
|
2008-01-03 12:39:28 +01:00
|
|
|
|
2008-09-15 16:32:05 +02:00
|
|
|
if (!d->invert)
|
|
|
|
ci = (ev->event_x - w->area.x) / odata->box_width;
|
|
|
|
else
|
|
|
|
ci = odata->client_labels.len - 1 - (ev->event_x - w->area.x) / odata->box_width;
|
2008-06-03 11:40:50 +02:00
|
|
|
|
2008-08-12 13:23:10 +02:00
|
|
|
for(int i = 0; i < barr->len; i++)
|
|
|
|
if(ev->detail == barr->tab[i]->button
|
|
|
|
&& XUTIL_MASK_CLEAN(ev->state) == barr->tab[i]->mod)
|
2008-07-28 15:56:22 +02:00
|
|
|
{
|
2008-09-21 20:39:23 +02:00
|
|
|
luaA_wibox_userdata_new(globalconf.L, object);
|
2008-07-28 15:56:22 +02:00
|
|
|
luaA_client_userdata_new(globalconf.L, odata->client_labels.tab[ci].client);
|
2008-08-12 13:23:10 +02:00
|
|
|
luaA_dofunction(globalconf.L,
|
|
|
|
ev->response_type == XCB_BUTTON_PRESS ?
|
|
|
|
barr->tab[i]->press : barr->tab[i]->release,
|
|
|
|
2, 0);
|
2008-07-28 15:56:22 +02:00
|
|
|
}
|
2008-05-20 15:39:47 +02:00
|
|
|
}
|
2008-01-07 11:20:24 +01:00
|
|
|
|
2008-07-28 16:03:38 +02:00
|
|
|
/** Tasklist widget.
|
2008-07-01 15:27:41 +02:00
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \param token The key token.
|
2008-06-25 17:47:51 +02:00
|
|
|
* \return The number of elements pushed on stack.
|
2008-07-10 09:31:29 +02:00
|
|
|
* \luastack
|
|
|
|
* \lfield show_icons Show icons near client title.
|
|
|
|
* \lfield label Function used to get the string to display as the window title.
|
2008-07-28 16:03:38 +02:00
|
|
|
* It gets the client and a screen number as argument, and must return a string.
|
2008-06-25 17:47:51 +02:00
|
|
|
*/
|
|
|
|
static int
|
2008-07-01 15:27:41 +02:00
|
|
|
luaA_tasklist_index(lua_State *L, awesome_token_t token)
|
2008-05-20 15:39:47 +02:00
|
|
|
{
|
2008-06-25 17:47:51 +02:00
|
|
|
widget_t **widget = luaA_checkudata(L, 1, "widget");
|
|
|
|
tasklist_data_t *d = (*widget)->data;
|
2008-05-20 15:39:47 +02:00
|
|
|
|
2008-07-01 15:27:41 +02:00
|
|
|
switch(token)
|
2008-05-20 15:39:47 +02:00
|
|
|
{
|
2008-06-27 22:15:54 +02:00
|
|
|
case A_TK_SHOW_ICONS:
|
|
|
|
lua_pushboolean(L, d->show_icons);
|
|
|
|
return 1;
|
2008-07-09 12:12:52 +02:00
|
|
|
case A_TK_LABEL:
|
|
|
|
lua_rawgeti(L, LUA_REGISTRYINDEX, d->label);
|
|
|
|
return 1;
|
2008-09-15 16:32:05 +02:00
|
|
|
case A_TK_INVERT:
|
|
|
|
lua_pushboolean(L, d->invert);
|
|
|
|
return 1;
|
2008-06-25 17:47:51 +02:00
|
|
|
default:
|
2008-06-27 22:15:54 +02:00
|
|
|
return 0;
|
2008-06-25 17:47:51 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-06-27 22:15:54 +02:00
|
|
|
/** Newindex function for tasklist widget.
|
2008-07-01 15:27:41 +02:00
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \param token The key token.
|
2008-06-25 17:47:51 +02:00
|
|
|
* \return The number of elements pushed on stack.
|
|
|
|
*/
|
|
|
|
static int
|
2008-07-01 15:27:41 +02:00
|
|
|
luaA_tasklist_newindex(lua_State *L, awesome_token_t token)
|
2008-06-25 17:47:51 +02:00
|
|
|
{
|
|
|
|
widget_t **widget = luaA_checkudata(L, 1, "widget");
|
|
|
|
tasklist_data_t *d = (*widget)->data;
|
|
|
|
|
2008-07-01 15:27:41 +02:00
|
|
|
switch(token)
|
2008-06-25 17:47:51 +02:00
|
|
|
{
|
2008-06-27 22:15:54 +02:00
|
|
|
case A_TK_SHOW_ICONS:
|
|
|
|
d->show_icons = luaA_checkboolean(L, 3);
|
|
|
|
break;
|
2008-07-09 12:12:52 +02:00
|
|
|
case A_TK_LABEL:
|
2008-08-12 13:23:10 +02:00
|
|
|
luaA_registerfct(L, 3, &d->label);
|
2008-07-09 12:12:52 +02:00
|
|
|
break;
|
2008-09-15 16:32:05 +02:00
|
|
|
case A_TK_INVERT:
|
|
|
|
d->invert = luaA_checkboolean(L, 3);
|
|
|
|
break;
|
2008-06-27 22:15:54 +02:00
|
|
|
default:
|
|
|
|
return 0;
|
2008-06-25 17:47:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
widget_invalidate_bywidget(*widget);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Destructor for the tasklist widget.
|
|
|
|
* \param widget The widget to destroy.
|
|
|
|
*/
|
2008-06-14 22:55:17 +02:00
|
|
|
static void
|
|
|
|
tasklist_destructor(widget_t *widget)
|
|
|
|
{
|
|
|
|
tasklist_data_t *d = widget->data;
|
2008-07-28 15:56:22 +02:00
|
|
|
tasklist_object_data_list_wipe(&d->objects_data);
|
2008-06-14 22:55:17 +02:00
|
|
|
p_delete(&d);
|
|
|
|
}
|
|
|
|
|
2008-07-29 11:50:40 +02:00
|
|
|
/** Tasklist detach function.
|
|
|
|
* \param widget The widget which is detaching.
|
|
|
|
* \param object The object we are leaving.
|
|
|
|
*/
|
|
|
|
static void
|
2008-09-21 10:13:21 +02:00
|
|
|
tasklist_detach(widget_t *widget, wibox_t *object)
|
2008-07-29 11:50:40 +02:00
|
|
|
{
|
|
|
|
tasklist_data_t *d = widget->data;
|
|
|
|
tasklist_object_data_t *od;
|
2008-07-29 12:03:01 +02:00
|
|
|
|
2008-07-29 11:50:40 +02:00
|
|
|
if((od = tasklist_object_data_getbyobj(d->objects_data, object)))
|
|
|
|
{
|
|
|
|
tasklist_object_data_list_detach(&d->objects_data, od);
|
|
|
|
tasklist_object_data_delete(&od);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-06-25 17:47:51 +02:00
|
|
|
/** Create a new widget tasklist.
|
|
|
|
* \param align The widget alignment, which is flex anyway.
|
|
|
|
* \return A brand new tasklist widget.
|
|
|
|
*/
|
2008-04-11 11:26:37 +02:00
|
|
|
widget_t *
|
2008-05-20 15:39:47 +02:00
|
|
|
tasklist_new(alignment_t align __attribute__ ((unused)))
|
2008-01-03 12:39:28 +01:00
|
|
|
{
|
2008-04-11 11:26:37 +02:00
|
|
|
widget_t *w;
|
2008-06-14 22:55:17 +02:00
|
|
|
tasklist_data_t *d;
|
2008-01-03 12:39:28 +01:00
|
|
|
|
2008-04-11 11:26:37 +02:00
|
|
|
w = p_new(widget_t, 1);
|
2008-05-20 15:39:47 +02:00
|
|
|
widget_common_new(w);
|
2008-01-03 12:39:28 +01:00
|
|
|
w->draw = tasklist_draw;
|
2008-08-12 13:23:10 +02:00
|
|
|
w->button = tasklist_button;
|
2008-05-20 15:39:47 +02:00
|
|
|
w->align = AlignFlex;
|
2008-06-25 17:47:51 +02:00
|
|
|
w->index = luaA_tasklist_index;
|
2008-06-27 22:15:54 +02:00
|
|
|
w->newindex = luaA_tasklist_newindex;
|
2008-06-14 22:55:17 +02:00
|
|
|
w->data = d = p_new(tasklist_data_t, 1);
|
|
|
|
w->destructor = tasklist_destructor;
|
2008-07-29 11:50:40 +02:00
|
|
|
w->detach = tasklist_detach;
|
2008-07-28 15:56:22 +02:00
|
|
|
|
2008-05-20 15:39:47 +02:00
|
|
|
d->show_icons = true;
|
2008-07-09 12:12:52 +02:00
|
|
|
d->label = LUA_REFNIL;
|
2008-09-15 16:32:05 +02:00
|
|
|
d->invert = false;
|
2008-01-03 16:05:39 +01:00
|
|
|
|
2008-01-07 18:12:38 +01:00
|
|
|
/* Set cache property */
|
2008-07-29 12:03:01 +02:00
|
|
|
w->cache_flags = WIDGET_CACHE_CLIENTS | WIDGET_CACHE_TAGS;
|
2008-01-07 18:12:38 +01:00
|
|
|
|
2008-01-03 12:39:28 +01:00
|
|
|
return w;
|
|
|
|
}
|
|
|
|
|
|
|
|
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|