Add 'add_items' and 'add_widgets' methods

This commit is contained in:
Emmanuel Lepage Vallee 2014-12-28 22:23:59 -05:00
parent 75e6357b23
commit 80bdbcca68
4 changed files with 18 additions and 3 deletions

View File

@ -268,7 +268,9 @@ here is the list:
| Name | Description | Arguments | Return |
| ----------------- | -------------------------------------------- | --------------------- | ------ |
| add_item | Add new item to a menu | array of options | item |
| add_items | Add new items to a menu | array of items arrays | array |
| add_widget | Add a new widget instead of an item | a widget, args | --- |
| add_widgets | Add new widgets | array of widgets | --- |
| add_embeded_menu | Add an inline menu to another menu | an "embed" menu | --- |
| add_key_binding | Add a global key binding to a menu | mod array, key | --- |
| add_key_hook | Add a callback when a key is pressed | mod, key, event, func | --- |

View File

@ -117,7 +117,7 @@ local function setup_buttons(data,item,args)
-- Setup sub_menu
if (item.sub_menu_m or item.sub_menu_f) and data.sub_menu_on >= base.event.BUTTON1 and data.sub_menu_on <= base.event.BUTTON3 then
buttons[data.sub_menu_on] = item.widget:set_menu(item.sub_menu_m or item.sub_menu_f,data.sub_menu_on)
item.widget:set_menu(item.sub_menu_m or item.sub_menu_f,data.sub_menu_on)
end
-- Scrool up

View File

@ -200,6 +200,14 @@ local function add_item(data,args)
return item
end
local function add_items(data,items)
local ret = {}
for k,item in ipairs(items) do
ret[k] = data:add_item(item)
end
return ret
end
local function add_widget(data,widget,args)
args = args or {}
@ -237,6 +245,12 @@ local function add_widget(data,widget,args)
end
end
local function add_widgets(data,widgets)
for k,item in ipairs(widgets) do
data:add_widget(item)
end
end
local function add_prefix_widget(data,widget,args)
data:emit_signal("prefix_widget::added",widget,args)
end
@ -356,7 +370,7 @@ local function new(args)
})
internal.private_data = private_data
data.add_item,data.add_widget,data.add_embeded_menu,data._internal,data.add_key_binding = add_item,add_widget,add_embeded_menu,internal,add_key_binding
data.add_prefix_widget,data.add_suffix_widget=add_prefix_widget,add_suffix_widget
data.add_prefix_widget,data.add_suffix_widget,data.add_items,data.add_widgets=add_prefix_widget,add_suffix_widget,add_items,add_widgets
theme.setup_colors(data,args)
-- Getters

View File

@ -242,7 +242,6 @@ local function tagged(c,t)
end
local function new(screen)
print("ICIT",beautiful.tasklist_default_item_margins)
local args = {
select_on = radical.base.event.NEVER ,
disable_markup = true ,