statusbar: check for widget uniqness

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-06-18 17:19:36 +02:00
parent 2a027ef2a9
commit 9959169bb0
2 changed files with 11 additions and 3 deletions

View File

@ -91,7 +91,7 @@ mytasklist:set("text_focus", "<bg color='"..bg_focus.."'/> <span color='"..fg_fo
mytextbox = widget.new({ type = "textbox", name = "mytextbox", align = "right" }) mytextbox = widget.new({ type = "textbox", name = "mytextbox", align = "right" })
-- Set the default text in textbox -- Set the default text in textbox
mytextbox:set("text", "<b><small> awesome " .. AWESOME_VERSION .. " </small></b>") mytextbox:set("text", "<b><small> awesome " .. AWESOME_VERSION .. " </small></b>")
mymenubox = widget.new({ type = "textbox", name = "mytextbox", align = "left" }) mymenubox = widget.new({ type = "textbox", name = "mymenubox", align = "left" })
-- Create an iconbox widget -- Create an iconbox widget
myiconbox = widget.new({ type = "iconbox", name = "myiconbox", align = "left" }) myiconbox = widget.new({ type = "iconbox", name = "myiconbox", align = "left" })
@ -104,7 +104,7 @@ mysystray = widget.new({ type = "systray", name = "mysystray", align = "right" }
-- We need one layoutbox per screen. -- We need one layoutbox per screen.
mylayoutbox = {} mylayoutbox = {}
for s = 1, screen.count() do for s = 1, screen.count() do
mylayoutbox[s] = widget.new({ type = "iconbox", name = "myiconbox", align = "right" }) mylayoutbox[s] = widget.new({ type = "iconbox", name = "mylayoutbox", align = "right" })
mylayoutbox[s]:mouse_add(mouse.new({ }, 1, function () awful.layout.inc(layouts, 1) end)) mylayoutbox[s]:mouse_add(mouse.new({ }, 1, function () awful.layout.inc(layouts, 1) end))
mylayoutbox[s]:mouse_add(mouse.new({ }, 3, function () awful.layout.inc(layouts, -1) end)) mylayoutbox[s]:mouse_add(mouse.new({ }, 3, function () awful.layout.inc(layouts, -1) end))
mylayoutbox[s]:mouse_add(mouse.new({ }, 4, function () awful.layout.inc(layouts, 1) end)) mylayoutbox[s]:mouse_add(mouse.new({ }, 4, function () awful.layout.inc(layouts, 1) end))

View File

@ -360,7 +360,15 @@ luaA_statusbar_widget_add(lua_State *L)
{ {
statusbar_t **sb = luaA_checkudata(L, 1, "statusbar"); statusbar_t **sb = luaA_checkudata(L, 1, "statusbar");
widget_t **widget = luaA_checkudata(L, 2, "widget"); widget_t **widget = luaA_checkudata(L, 2, "widget");
widget_node_t *w = p_new(widget_node_t, 1); widget_node_t *witer, *w = p_new(widget_node_t, 1);
/* check that there is not already a widget with that name in the titlebar */
for(witer = (*sb)->widgets; witer; witer = witer->next)
if(witer->widget == *widget)
luaL_error(L, "widget `%s' is already on statusbar");
else if(!a_strcmp(witer->widget->name, (*widget)->name))
luaL_error(L, "a widget with name `%s' already on statusbar `%s'",
witer->widget->name, (*sb)->name);
(*sb)->need_update = true; (*sb)->need_update = true;
w->widget = *widget; w->widget = *widget;