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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "widget.h"
|
|
|
|
#include "client.h"
|
|
|
|
#include "focus.h"
|
2008-01-03 19:21:36 +01:00
|
|
|
#include "ewmh.h"
|
2008-06-09 21:43:09 +02:00
|
|
|
#include "tag.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-02-06 20:03:18 +01:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
ShowFocus,
|
2008-06-09 21:43:09 +02:00
|
|
|
ShowTags,
|
2008-02-06 20:03:18 +01:00
|
|
|
ShowAll,
|
2008-04-28 15:29:21 +02:00
|
|
|
} showclient_t;
|
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-04-28 15:29:21 +02:00
|
|
|
showclient_t show;
|
2008-03-21 16:50:17 +01:00
|
|
|
bool show_icons;
|
2008-04-28 12:23:10 +02:00
|
|
|
char *text_normal, *text_urgent, *text_focus;
|
2008-06-14 22:55:17 +02:00
|
|
|
} tasklist_data_t;
|
2008-01-03 12:39:28 +01:00
|
|
|
|
2008-06-25 17:47:51 +02:00
|
|
|
struct tasklist_hook_data
|
|
|
|
{
|
|
|
|
draw_context_t *ctx;
|
|
|
|
area_t *area;
|
|
|
|
};
|
|
|
|
|
|
|
|
/** Check if a client is visible according to the showclient type paramater.
|
|
|
|
* \param c The client.
|
|
|
|
* \param screen The screen number.
|
|
|
|
* \param show The show parameters.
|
|
|
|
* \return True if the client is visible, false otherwise.
|
|
|
|
*/
|
2008-03-21 16:50:17 +01:00
|
|
|
static inline bool
|
2008-04-28 15:29:21 +02:00
|
|
|
tasklist_isvisible(client_t *c, int screen, showclient_t show)
|
2008-02-06 20:03:18 +01:00
|
|
|
{
|
2008-02-12 10:29:41 +01:00
|
|
|
if(c->skip || c->skiptb)
|
2008-03-21 16:50:17 +01:00
|
|
|
return false;
|
2008-02-06 20:03:18 +01:00
|
|
|
|
|
|
|
switch(show)
|
|
|
|
{
|
|
|
|
case ShowAll:
|
2008-06-09 21:43:09 +02:00
|
|
|
return (c->screen == screen);
|
|
|
|
case ShowTags:
|
2008-04-07 20:34:42 +02:00
|
|
|
return client_isvisible(c, screen);
|
2008-02-06 20:03:18 +01:00
|
|
|
case ShowFocus:
|
2008-06-09 21:43:09 +02:00
|
|
|
return (c == focus_get_current_client(screen));
|
2008-02-06 20:03:18 +01:00
|
|
|
}
|
2008-03-21 16:50:17 +01:00
|
|
|
return false;
|
2008-02-06 20:03:18 +01:00
|
|
|
}
|
|
|
|
|
2008-06-25 17:47:51 +02:00
|
|
|
/** Called when a markup element is found.
|
|
|
|
* \param p The markup parser data.
|
|
|
|
* \param elem The element name.
|
|
|
|
* \param names The attributes names.
|
|
|
|
* \param values The attributes values.
|
|
|
|
*/
|
2008-06-22 17:45:45 +02:00
|
|
|
static void
|
|
|
|
tasklist_markup_on_elem(markup_parser_data_t *p, const char *elem,
|
|
|
|
const char **names, const char **values)
|
|
|
|
{
|
|
|
|
struct tasklist_hook_data *data = p->priv;
|
|
|
|
draw_context_t *ctx = data->ctx;
|
|
|
|
|
2008-06-23 14:14:47 +02:00
|
|
|
assert(!a_strcmp(elem, "bg"));
|
2008-06-23 13:09:42 +02:00
|
|
|
for(; *names; names++, values++)
|
2008-06-22 17:45:45 +02:00
|
|
|
if(!a_strcmp(*names, "color"))
|
|
|
|
{
|
|
|
|
xcolor_t bg_color;
|
|
|
|
xcolor_new(ctx->connection, ctx->phys_screen, *values, &bg_color);
|
|
|
|
draw_rectangle(ctx, *data->area, 1.0, true, bg_color);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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-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-06-25 17:47:51 +02:00
|
|
|
int offset, int used, void *p __attribute__ ((unused)))
|
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-03-14 09:37:25 +01:00
|
|
|
area_t area;
|
2008-04-28 12:23:10 +02:00
|
|
|
char *text;
|
2008-06-22 17:45:45 +02:00
|
|
|
int n = 0, i = 0, box_width = 0, icon_width = 0, box_width_rest = 0;
|
2008-06-18 09:29:57 +02:00
|
|
|
netwm_icon_t *icon;
|
2008-06-17 09:21:26 +02:00
|
|
|
draw_image_t *image;
|
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-01-03 12:39:28 +01:00
|
|
|
for(c = globalconf.clients; c; c = c->next)
|
2008-06-02 12:18:17 +02:00
|
|
|
if(tasklist_isvisible(c, screen, d->show))
|
2008-01-03 12:39:28 +01:00
|
|
|
n++;
|
2008-02-13 06:53:08 +01:00
|
|
|
|
2008-01-03 12:39:28 +01:00
|
|
|
if(!n)
|
2008-05-20 15:39:47 +02:00
|
|
|
return (w->area.width = 0);
|
2008-01-03 12:39:28 +01:00
|
|
|
|
2008-06-03 16:08:33 +02:00
|
|
|
box_width = (ctx->width - used) / n;
|
2008-01-20 16:25:06 +01:00
|
|
|
/* compute how many pixel we left empty */
|
2008-06-03 16:08:33 +02:00
|
|
|
box_width_rest = (ctx->width - used) % n;
|
2008-01-03 12:39:28 +01:00
|
|
|
|
2008-06-03 16:08:33 +02:00
|
|
|
w->area.x = widget_calculate_offset(ctx->width,
|
2008-05-20 15:39:47 +02:00
|
|
|
0, offset, w->widget->align);
|
2008-01-04 22:05:52 +01:00
|
|
|
|
2008-05-20 15:39:47 +02:00
|
|
|
w->area.y = 0;
|
2008-01-03 12:39:28 +01:00
|
|
|
|
|
|
|
for(c = globalconf.clients; c; c = c->next)
|
2008-06-02 12:18:17 +02:00
|
|
|
if(tasklist_isvisible(c, screen, d->show))
|
2008-01-03 12:39:28 +01:00
|
|
|
{
|
2008-01-03 19:21:36 +01:00
|
|
|
icon_width = 0;
|
|
|
|
|
2008-04-29 11:42:16 +02:00
|
|
|
if(globalconf.focus->client == c)
|
2008-04-28 12:23:10 +02:00
|
|
|
text = d->text_focus;
|
2008-04-29 11:42:16 +02:00
|
|
|
else if(c->isurgent)
|
|
|
|
text = d->text_urgent;
|
2008-03-18 09:13:43 +01:00
|
|
|
else
|
2008-04-28 12:23:10 +02:00
|
|
|
text = d->text_normal;
|
|
|
|
|
|
|
|
text = client_markup_parse(c, text, a_strlen(text));
|
2008-03-14 08:35:06 +01:00
|
|
|
|
2008-01-03 19:21:36 +01:00
|
|
|
if(d->show_icons)
|
|
|
|
{
|
2008-06-22 17:45:45 +02:00
|
|
|
static char const * const elements[] = { "bg", NULL };
|
|
|
|
struct tasklist_hook_data data = { .ctx = ctx, .area = &area };
|
2008-06-25 17:47:51 +02:00
|
|
|
markup_parser_data_t pdata =
|
2008-06-23 13:09:42 +02:00
|
|
|
{
|
2008-06-22 17:45:45 +02:00
|
|
|
.elements = elements,
|
|
|
|
.on_element = &tasklist_markup_on_elem,
|
|
|
|
.priv = &data,
|
|
|
|
};
|
|
|
|
|
2008-01-17 15:47:08 +01:00
|
|
|
/* draw a background for icons */
|
2008-05-20 15:39:47 +02:00
|
|
|
area.x = w->area.x + box_width * i;
|
|
|
|
area.y = w->area.y;
|
2008-06-03 16:08:33 +02:00
|
|
|
area.height = ctx->height;
|
2008-01-17 15:47:08 +01:00
|
|
|
area.width = box_width;
|
2008-03-14 08:35:06 +01:00
|
|
|
|
2008-06-05 06:12:04 +02:00
|
|
|
/* Actually look for the proper background color, since
|
|
|
|
* otherwise the background statusbar color is used instead */
|
2008-06-25 17:47:51 +02:00
|
|
|
markup_parser_data_init(&pdata);
|
|
|
|
markup_parse(&pdata, text, a_strlen(text));
|
|
|
|
markup_parser_data_wipe(&pdata);
|
2008-06-05 06:12:04 +02:00
|
|
|
|
2008-06-17 09:21:26 +02:00
|
|
|
if((image = draw_image_new(c->icon_path)))
|
2008-01-12 22:59:13 +01:00
|
|
|
{
|
2008-06-17 09:21:26 +02:00
|
|
|
icon_width = ((double) ctx->height / (double) image->height) * image->width;
|
|
|
|
draw_image(ctx, w->area.x + box_width * i,
|
|
|
|
w->area.y, ctx->height, image);
|
|
|
|
draw_image_delete(&image);
|
2008-01-12 22:59:13 +01:00
|
|
|
}
|
2008-01-03 19:21:36 +01:00
|
|
|
|
|
|
|
if(!icon_width && (icon = ewmh_get_window_icon(c->win)))
|
|
|
|
{
|
2008-06-03 16:08:33 +02:00
|
|
|
icon_width = ((double) ctx->height / (double) icon->height)
|
2008-01-03 19:21:36 +01:00
|
|
|
* icon->width;
|
2008-06-02 12:18:17 +02:00
|
|
|
draw_image_from_argb_data(ctx,
|
2008-05-20 15:39:47 +02:00
|
|
|
w->area.x + box_width * i,
|
|
|
|
w->area.y,
|
2008-01-03 19:21:36 +01:00
|
|
|
icon->width, icon->height,
|
2008-06-03 16:08:33 +02:00
|
|
|
ctx->height, icon->image);
|
2008-01-04 15:59:17 +01:00
|
|
|
p_delete(&icon->image);
|
2008-01-03 19:21:36 +01:00
|
|
|
p_delete(&icon);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-20 15:39:47 +02:00
|
|
|
area.x = w->area.x + icon_width + box_width * i;
|
|
|
|
area.y = w->area.y;
|
2008-01-12 23:47:03 +01:00
|
|
|
area.width = box_width - icon_width;
|
2008-06-03 16:08:33 +02:00
|
|
|
area.height = ctx->height;
|
2008-01-20 16:25:06 +01:00
|
|
|
|
|
|
|
/* if we're on last elem, it has the last pixels left */
|
|
|
|
if(i == n - 1)
|
|
|
|
area.width += box_width_rest;
|
|
|
|
|
2008-06-23 13:09:42 +02:00
|
|
|
draw_text(ctx, globalconf.font, area, text, NULL);
|
2008-01-12 23:47:03 +01:00
|
|
|
|
2008-04-28 12:23:10 +02:00
|
|
|
p_delete(&text);
|
|
|
|
|
2008-05-25 17:42:20 +02:00
|
|
|
if(c->isfloating || c->ismax)
|
2008-06-02 12:18:17 +02:00
|
|
|
draw_circle(ctx, w->area.x + icon_width + box_width * i,
|
2008-05-20 15:39:47 +02:00
|
|
|
w->area.y,
|
|
|
|
(globalconf.font->height + 2) / 4,
|
2008-06-02 12:18:17 +02:00
|
|
|
c->ismax, ctx->fg);
|
2008-01-03 12:39:28 +01:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
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.
|
|
|
|
* \param type The type object.
|
|
|
|
*/
|
2008-01-03 12:39:28 +01:00
|
|
|
static void
|
2008-06-03 11:40:50 +02:00
|
|
|
tasklist_button_press(widget_node_t *w,
|
|
|
|
xcb_button_press_event_t *ev,
|
|
|
|
int screen,
|
2008-06-04 19:21:21 +02:00
|
|
|
void *object,
|
|
|
|
awesome_type_t type)
|
2008-01-03 12:39:28 +01:00
|
|
|
{
|
2008-05-23 13:35:46 +02:00
|
|
|
button_t *b;
|
2008-05-26 16:17:57 +02:00
|
|
|
client_t *c;
|
2008-06-14 22:55:17 +02:00
|
|
|
tasklist_data_t *d = w->widget->data;
|
2008-01-18 09:49:04 +01:00
|
|
|
int n = 0, box_width = 0, i, ci = 0;
|
2008-01-03 12:39:28 +01:00
|
|
|
|
2008-05-20 15:39:47 +02:00
|
|
|
for(c = globalconf.clients; c; c = c->next)
|
2008-06-03 11:40:50 +02:00
|
|
|
if(tasklist_isvisible(c, screen, d->show))
|
2008-05-20 15:39:47 +02:00
|
|
|
n++;
|
2008-02-13 06:53:08 +01:00
|
|
|
|
2008-05-20 15:39:47 +02:00
|
|
|
if(!n)
|
|
|
|
return;
|
2008-01-03 12:39:28 +01:00
|
|
|
|
2008-05-20 15:39:47 +02:00
|
|
|
box_width = w->area.width / n;
|
2008-01-03 12:39:28 +01:00
|
|
|
|
2008-06-03 11:40:50 +02:00
|
|
|
ci = (ev->event_x - w->area.x) / box_width;
|
|
|
|
|
2008-05-20 15:39:47 +02:00
|
|
|
/* found first visible client */
|
|
|
|
for(c = globalconf.clients;
|
2008-06-03 11:40:50 +02:00
|
|
|
c && !tasklist_isvisible(c, screen, d->show);
|
2008-05-20 15:39:47 +02:00
|
|
|
c = c->next);
|
|
|
|
/* found ci-th visible client */
|
|
|
|
for(i = 0; c ; c = c->next)
|
2008-06-03 11:40:50 +02:00
|
|
|
if(tasklist_isvisible(c, screen, d->show))
|
2008-05-20 15:39:47 +02:00
|
|
|
if(i++ >= ci)
|
2008-01-04 19:12:07 +01:00
|
|
|
break;
|
2008-05-20 15:39:47 +02:00
|
|
|
|
|
|
|
if(c)
|
|
|
|
for(b = w->widget->buttons; b; b = b->next)
|
|
|
|
if(ev->detail == b->button && CLEANMASK(ev->state) == b->mod && b->fct)
|
2008-01-10 07:04:51 +01:00
|
|
|
{
|
2008-06-18 18:31:35 +02:00
|
|
|
luaA_pushpointer(globalconf.L, object, type);
|
|
|
|
luaA_client_userdata_new(globalconf.L, c);
|
2008-06-04 19:21:21 +02:00
|
|
|
luaA_dofunction(globalconf.L, b->fct, 2);
|
2008-01-10 07:04:51 +01:00
|
|
|
}
|
2008-05-20 15:39:47 +02:00
|
|
|
}
|
2008-01-07 11:20:24 +01:00
|
|
|
|
2008-06-25 17:47:51 +02:00
|
|
|
/** Set the tasklist show attribute.
|
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \return The number of elements pushed on stack.
|
2008-06-26 17:13:02 +02:00
|
|
|
* \luastack
|
2008-06-25 17:47:51 +02:00
|
|
|
* \lvalue A widget.
|
|
|
|
* \lparam A string: tags, focus or all.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
luaA_tasklist_show_set(lua_State *L)
|
2008-05-20 15:39:47 +02:00
|
|
|
{
|
2008-06-25 17:47:51 +02:00
|
|
|
size_t len;
|
|
|
|
widget_t **widget = luaA_checkudata(L, 1, "widget");
|
|
|
|
tasklist_data_t *d = (*widget)->data;
|
|
|
|
const char *buf = luaL_checklstring(L, 2, &len);
|
2008-05-20 15:39:47 +02:00
|
|
|
|
2008-06-25 17:47:51 +02:00
|
|
|
switch(a_tokenize(buf, len))
|
2008-05-20 15:39:47 +02:00
|
|
|
{
|
2008-06-25 17:47:51 +02:00
|
|
|
case A_TK_TAGS:
|
|
|
|
d->show = ShowTags;
|
2008-06-23 14:12:01 +02:00
|
|
|
break;
|
2008-06-25 17:47:51 +02:00
|
|
|
case A_TK_FOCUS:
|
|
|
|
d->show = ShowFocus;
|
2008-06-23 14:12:01 +02:00
|
|
|
break;
|
2008-06-25 17:47:51 +02:00
|
|
|
case A_TK_ALL:
|
|
|
|
d->show = ShowAll;
|
2008-06-23 14:12:01 +02:00
|
|
|
break;
|
2008-06-25 17:47:51 +02:00
|
|
|
default:
|
2008-06-23 14:12:01 +02:00
|
|
|
break;
|
2008-06-25 17:47:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
widget_invalidate_bywidget(*widget);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Select if icons must be shown.
|
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \return The number of elements pushed on stack.
|
|
|
|
* \luastack
|
|
|
|
* \lvalue A widget.
|
|
|
|
* \lparam A boolean, true to see icons, false otherwise.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
luaA_tasklist_showicons_set(lua_State *L)
|
|
|
|
{
|
|
|
|
widget_t **widget = luaA_checkudata(L, 1, "widget");
|
|
|
|
tasklist_data_t *d = (*widget)->data;
|
|
|
|
|
|
|
|
d->show_icons = luaA_checkboolean(L, 2);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Set text format string in case of a client is either normal, focused or has
|
|
|
|
* urgency hint.
|
|
|
|
* \param L The Lua VM state.
|
|
|
|
* \return The number of elements pushed on stack.
|
2008-06-26 17:13:02 +02:00
|
|
|
* \luastack
|
2008-06-25 17:47:51 +02:00
|
|
|
* \lvalue A widget.
|
|
|
|
* \lparam A table with keys to change: `normal', `focus' and `urgent'.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
luaA_tasklist_text_set(lua_State *L)
|
|
|
|
{
|
|
|
|
widget_t **widget = luaA_checkudata(L, 1, "widget");
|
|
|
|
tasklist_data_t *d = (*widget)->data;
|
|
|
|
const char *buf;
|
|
|
|
|
|
|
|
luaA_checktable(L, 2);
|
|
|
|
|
|
|
|
if((buf = luaA_getopt_string(L, 2, "normal", NULL)))
|
|
|
|
{
|
|
|
|
p_delete(&d->text_normal);
|
|
|
|
d->text_normal = a_strdup(buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
if((buf = luaA_getopt_string(L, 2, "focus", NULL)))
|
|
|
|
{
|
|
|
|
p_delete(&d->text_focus);
|
|
|
|
d->text_focus = a_strdup(buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
if((buf = luaA_getopt_string(L, 2, "urgent", NULL)))
|
|
|
|
{
|
|
|
|
p_delete(&d->text_urgent);
|
|
|
|
d->text_urgent = a_strdup(buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
widget_invalidate_bywidget(*widget);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Index function for tasklist widget.
|
|
|
|
* \lparam L The Lua VM state.
|
|
|
|
* \return The number of elements pushed on stack.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
luaA_tasklist_index(lua_State *L)
|
|
|
|
{
|
|
|
|
size_t len;
|
|
|
|
const char *attr = luaL_checklstring(L, 2, &len);
|
|
|
|
|
|
|
|
switch(a_tokenize(attr, len))
|
|
|
|
{
|
|
|
|
case A_TK_TEXT_SET:
|
|
|
|
lua_pushcfunction(L, luaA_tasklist_text_set);
|
|
|
|
return 1;
|
|
|
|
case A_TK_SHOWICONS_SET:
|
|
|
|
lua_pushcfunction(L, luaA_tasklist_showicons_set);
|
|
|
|
case A_TK_SHOW_SET:
|
|
|
|
lua_pushcfunction(L, luaA_tasklist_show_set);
|
2008-06-23 14:12:01 +02:00
|
|
|
default:
|
2008-06-25 17:47:51 +02:00
|
|
|
return 0;
|
2008-06-23 14:12:01 +02:00
|
|
|
}
|
2008-01-03 12:39:28 +01:00
|
|
|
}
|
|
|
|
|
2008-06-25 17:47:51 +02:00
|
|
|
/** 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;
|
|
|
|
|
|
|
|
p_delete(&d->text_normal);
|
|
|
|
p_delete(&d->text_focus);
|
|
|
|
p_delete(&d->text_urgent);
|
|
|
|
p_delete(&d);
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
w->button_press = tasklist_button_press;
|
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-14 22:55:17 +02:00
|
|
|
w->data = d = p_new(tasklist_data_t, 1);
|
|
|
|
w->destructor = tasklist_destructor;
|
2008-01-03 12:39:28 +01:00
|
|
|
|
2008-05-20 15:39:47 +02:00
|
|
|
d->text_normal = a_strdup(" <title/> ");
|
|
|
|
d->text_focus = a_strdup(" <title/> ");
|
|
|
|
d->text_urgent = a_strdup(" <title/> ");
|
|
|
|
d->show_icons = true;
|
2008-06-09 21:43:09 +02:00
|
|
|
d->show = ShowTags;
|
2008-01-03 16:05:39 +01:00
|
|
|
|
2008-01-07 18:12:38 +01:00
|
|
|
/* Set cache property */
|
2008-05-13 16:48:33 +02:00
|
|
|
w->cache_flags = WIDGET_CACHE_CLIENTS;
|
2008-01-07 18:12:38 +01:00
|
|
|
|
2008-01-03 12:39:28 +01:00
|
|
|
return w;
|
|
|
|
}
|
|
|
|
|
2008-06-26 23:32:33 +02:00
|
|
|
/* This is used for building documentation. */
|
|
|
|
static const struct luaL_reg awesome_tasklist_meta[] __attribute__ ((unused)) =
|
|
|
|
{
|
|
|
|
{ "text_set", luaA_tasklist_text_set },
|
|
|
|
{ "showicons_set", luaA_tasklist_showicons_set },
|
|
|
|
{ "show_set", luaA_tasklist_show_set }
|
|
|
|
};
|
|
|
|
|
2008-01-03 12:39:28 +01:00
|
|
|
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|