Major refactoring, address issue #12
This commit is contained in:
parent
b6ba3ad383
commit
fabd52d1a6
|
@ -114,7 +114,7 @@ Item layouts are how widgets (icons, label, prefix) are disposed in the item
|
||||||
|
|
||||||
local m = radical.context {
|
local m = radical.context {
|
||||||
style = radical.style.classic ,
|
style = radical.style.classic ,
|
||||||
item_style = radical.item_style.classic ,
|
item_style = radical.item.style.classic ,
|
||||||
layout = radical.layout.vertical }
|
layout = radical.layout.vertical }
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
4
bar.lua
4
bar.lua
|
@ -9,9 +9,9 @@ local util = require( "awful.util" )
|
||||||
local fkey = require( "radical.widgets.fkey" )
|
local fkey = require( "radical.widgets.fkey" )
|
||||||
local button = require( "awful.button" )
|
local button = require( "awful.button" )
|
||||||
local checkbox = require( "radical.widgets.checkbox" )
|
local checkbox = require( "radical.widgets.checkbox" )
|
||||||
local item_style = require( "radical.item_style.arrow_single" )
|
local item_style = require( "radical.item.style.arrow_single" )
|
||||||
local vertical = require( "radical.layout.vertical" )
|
local vertical = require( "radical.layout.vertical" )
|
||||||
local item_layout= require( "radical.item_layout.horizontal" )
|
local item_layout= require( "radical.item.layout.horizontal" )
|
||||||
|
|
||||||
local capi,module = { mouse = mouse , screen = screen, keygrabber = keygrabber },{}
|
local capi,module = { mouse = mouse , screen = screen, keygrabber = keygrabber },{}
|
||||||
|
|
||||||
|
|
163
base.lua
163
base.lua
|
@ -8,6 +8,8 @@ local util = require( "awful.util" )
|
||||||
local aw_key = require( "awful.key" )
|
local aw_key = require( "awful.key" )
|
||||||
local object = require( "radical.object" )
|
local object = require( "radical.object" )
|
||||||
local vertical = require( "radical.layout.vertical" )
|
local vertical = require( "radical.layout.vertical" )
|
||||||
|
local theme = require( "radical.theme" )
|
||||||
|
local item_mod = require( "radical.item" )
|
||||||
|
|
||||||
local capi = { mouse = mouse, screen = screen , keygrabber = keygrabber, root=root, }
|
local capi = { mouse = mouse, screen = screen , keygrabber = keygrabber, root=root, }
|
||||||
|
|
||||||
|
@ -51,56 +53,18 @@ local module = {
|
||||||
USR9 = 109,
|
USR9 = 109,
|
||||||
USR10 = 110,
|
USR10 = 110,
|
||||||
},
|
},
|
||||||
colors_by_id = {}
|
colors_by_id = theme.colors_by_id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
theme.register_color(module.item_flags.DISABLED , "disabled" , "disabled" , true )
|
||||||
-- Do some magic to cache the highest state
|
theme.register_color(module.item_flags.URGENT , "urgent" , "urgent" , true )
|
||||||
local function return_data(tab, key)
|
theme.register_color(module.item_flags.SELECTED , "focus" , "focus" , true )
|
||||||
return tab._real_table[key]
|
theme.register_color(module.item_flags.PRESSED , "pressed" , "pressed" , true )
|
||||||
end
|
theme.register_color(module.item_flags.HOVERED , "hover" , "hover" , true )
|
||||||
local function change_data(tab, key,value)
|
theme.register_color(module.item_flags.USED , "used" , "used" , true )
|
||||||
if not value and key == rawget(tab,"_current_key") then
|
theme.register_color(module.item_flags.CHECKED , "checked" , "checked" , true )
|
||||||
-- Loop the array to find a new current_key
|
theme.register_color(module.item_flags.ALTERNATE , "alternate" , "alternate" , true )
|
||||||
local win = math.huge
|
theme.register_color(module.item_flags.HIGHLIGHT , "highlight" , "highlight" , true )
|
||||||
for k,v in pairs(tab._real_table) do
|
|
||||||
if k < win and k ~= key then
|
|
||||||
win = k
|
|
||||||
end
|
|
||||||
end
|
|
||||||
rawset(tab,"_current_key",win ~= math.huge and win or nil)
|
|
||||||
elseif value and (rawget(tab,"_current_key") or math.huge) > key then
|
|
||||||
rawset(tab,"_current_key",key)
|
|
||||||
end
|
|
||||||
tab._real_table[key] = value
|
|
||||||
end
|
|
||||||
local function init_state()
|
|
||||||
local mt = {__newindex = change_data,__index=return_data}
|
|
||||||
return setmetatable({_real_table={}},mt)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Util to help match colors to states
|
|
||||||
local theme_colors = {}
|
|
||||||
local function register_color(state_id,name,beautiful_name,allow_fallback)
|
|
||||||
theme_colors[name] = {id=state_id,beautiful_name=beautiful_name,fallback=allow_fallback}
|
|
||||||
module.colors_by_id[state_id] = name
|
|
||||||
end
|
|
||||||
local function setup_colors(data,args)
|
|
||||||
local priv = data._internal.private_data
|
|
||||||
for k,v in pairs(theme_colors) do
|
|
||||||
priv["fg_"..k] = args["fg_"..k] or beautiful["menu_fg_"..v.beautiful_name] or beautiful["fg_"..v.beautiful_name] or (v.fallback and "#ff0000")
|
|
||||||
priv["bg_"..k] = args["bg_"..k] or beautiful["menu_bg_"..v.beautiful_name] or beautiful["bg_"..v.beautiful_name] or (v.fallback and "#00ff00")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
register_color(module.item_flags.DISABLED , "disabled" , "disabled" , true )
|
|
||||||
register_color(module.item_flags.URGENT , "urgent" , "urgent" , true )
|
|
||||||
register_color(module.item_flags.SELECTED , "focus" , "focus" , true )
|
|
||||||
register_color(module.item_flags.PRESSED , "pressed" , "pressed" , true )
|
|
||||||
register_color(module.item_flags.HOVERED , "hover" , "hover" , true )
|
|
||||||
register_color(module.item_flags.USED , "used" , "used" , true )
|
|
||||||
register_color(module.item_flags.CHECKED , "checked" , "checked" , true )
|
|
||||||
register_color(module.item_flags.ALTERNATE , "alternate" , "alternate" , true )
|
|
||||||
register_color(module.item_flags.HIGHLIGHT , "highlight" , "highlight" , true )
|
|
||||||
-- register_color(item_flags.HEADER , ""
|
-- register_color(item_flags.HEADER , ""
|
||||||
-- register_color(item_flags.USR1 , ""
|
-- register_color(item_flags.USR1 , ""
|
||||||
-- register_color(item_flags.USR2 , ""
|
-- register_color(item_flags.USR2 , ""
|
||||||
|
@ -136,21 +100,6 @@ local function filter(data)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function execute_sub_menu(data,item)
|
|
||||||
if (item._private_data.sub_menu_f or item._private_data.sub_menu_m) then
|
|
||||||
local sub_menu = item._private_data.sub_menu_m or item._private_data.sub_menu_f(data,item)
|
|
||||||
if sub_menu and sub_menu.rowcount > 0 then
|
|
||||||
sub_menu.arrow_type = module.arrow_type.NONE
|
|
||||||
sub_menu.parent_item = item
|
|
||||||
sub_menu.parent_geometry = data
|
|
||||||
sub_menu.visible = true
|
|
||||||
item._tmp_menu = sub_menu
|
|
||||||
data._tmp_menu = sub_menu
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
module._execute_sub_menu = execute_sub_menu
|
|
||||||
|
|
||||||
------------------------------------KEYBOARD HANDLING-----------------------------------
|
------------------------------------KEYBOARD HANDLING-----------------------------------
|
||||||
local function activateKeyboard(data)
|
local function activateKeyboard(data)
|
||||||
if not data then return end
|
if not data then return end
|
||||||
|
@ -183,7 +132,7 @@ local function activateKeyboard(data)
|
||||||
|
|
||||||
if (key == 'Return') and data._current_item and data._current_item.button1 then
|
if (key == 'Return') and data._current_item and data._current_item.button1 then
|
||||||
if data.sub_menu_on == module.event.BUTTON1 then
|
if data.sub_menu_on == module.event.BUTTON1 then
|
||||||
execute_sub_menu(data,data._current_item)
|
item_mod.execute_sub_menu(data,data._current_item)
|
||||||
else
|
else
|
||||||
data._current_item.button1()
|
data._current_item.button1()
|
||||||
data.visible = false
|
data.visible = false
|
||||||
|
@ -209,88 +158,8 @@ end
|
||||||
|
|
||||||
---------------------------------ITEM HANDLING----------------------------------
|
---------------------------------ITEM HANDLING----------------------------------
|
||||||
local function add_item(data,args)
|
local function add_item(data,args)
|
||||||
local args = args or {}
|
local item = item_mod(data,args)
|
||||||
local item,set_map,get_map,private_data = object({
|
|
||||||
private_data = {
|
|
||||||
text = args.text or "" ,
|
|
||||||
height = args.height or beautiful.menu_height or 30 ,
|
|
||||||
width = args.width or nil ,
|
|
||||||
icon = args.icon or nil ,
|
|
||||||
prefix = args.prefix or "" ,
|
|
||||||
suffix = args.suffix or "" ,
|
|
||||||
bg = args.bg or nil ,
|
|
||||||
fg = args.fg or data.fg or beautiful.menu_fg_normal or beautiful.fg_normal ,
|
|
||||||
fg_focus = args.fg_focus or data.fg_focus or beautiful.menu_fg_focus or beautiful.fg_focus ,
|
|
||||||
bg_focus = args.bg_focus or data.bg_focus or beautiful.menu_bg_focus or beautiful.bg_focus ,
|
|
||||||
bg_prefix = args.bg_prefix or data.bg_prefix ,
|
|
||||||
sub_menu_m = (args.sub_menu and type(args.sub_menu) == "table" and args.sub_menu.is_menu) and args.sub_menu or nil,
|
|
||||||
sub_menu_f = (args.sub_menu and type(args.sub_menu) == "function") and args.sub_menu or nil ,
|
|
||||||
checkable = args.checkable or (args.checked ~= nil) or false ,
|
|
||||||
checked = args.checked or false ,
|
|
||||||
underlay = args.underlay or nil ,
|
|
||||||
tooltip = args.tooltip or nil ,
|
|
||||||
item_style = args.item_style or nil ,
|
|
||||||
item_layout = args.item_layout or nil ,
|
|
||||||
selected = false ,
|
|
||||||
overlay = args.overlay or data.overlay or nil ,
|
|
||||||
state = init_state() ,
|
|
||||||
},
|
|
||||||
force_private = {
|
|
||||||
visible = true,
|
|
||||||
selected = true,
|
|
||||||
},
|
|
||||||
get_map = {
|
|
||||||
y = function() return (args.y and args.y >= 0) and args.y or data.height - (data.margins.top or data.border_width) - data.item_height end, --Hack around missing :fit call for last item
|
|
||||||
},
|
|
||||||
autogen_getmap = true,
|
|
||||||
autogen_setmap = true,
|
|
||||||
autogen_signals = true,
|
|
||||||
})
|
|
||||||
item._private_data = private_data
|
|
||||||
item._internal = {get_map=get_map,set_map=set_map}
|
|
||||||
|
|
||||||
for i=1,10 do
|
|
||||||
item["button"..i] = args["button"..i]
|
|
||||||
end
|
|
||||||
|
|
||||||
if data.max_items ~= nil and data.rowcount >= data.max_items then-- and (data._start_at or 0)
|
|
||||||
item._hidden = true
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Use _internal to avoid the radical.object trigger
|
|
||||||
data._internal.visible_item_count = (data._internal.visible_item_count or 0) + 1
|
|
||||||
item._internal.f_key = data._internal.visible_item_count
|
|
||||||
|
|
||||||
-- Need to be done before painting
|
|
||||||
data._internal.items[#data._internal.items+1] = {}
|
|
||||||
data._internal.items[#data._internal.items][1] = item
|
|
||||||
data._internal.setup_item(data,item,args)
|
data._internal.setup_item(data,item,args)
|
||||||
|
|
||||||
-- Setters
|
|
||||||
set_map.selected = function(value)
|
|
||||||
private_data.selected = value
|
|
||||||
if value == false then
|
|
||||||
data.item_style(data,item,{})
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local current_item = data._current_item
|
|
||||||
if current_item and current_item ~= item then
|
|
||||||
current_item.state[module.item_flags.SELECTED] = nil
|
|
||||||
if current_item._tmp_menu then
|
|
||||||
current_item._tmp_menu.visible = false
|
|
||||||
current_item._tmp_menu = nil
|
|
||||||
data._tmp_menu = nil
|
|
||||||
end
|
|
||||||
data.item_style(data,current_item,{})
|
|
||||||
current_item.selected = false
|
|
||||||
end
|
|
||||||
if data.sub_menu_on == module.event.SELECTED and current_item ~= item then
|
|
||||||
execute_sub_menu(data,item)
|
|
||||||
end
|
|
||||||
item.state[module.item_flags.SELECTED] = true
|
|
||||||
data.item_style(data,item,{})
|
|
||||||
data._current_item = item
|
|
||||||
end
|
|
||||||
if args.selected == true then
|
if args.selected == true then
|
||||||
item.selected = true
|
item.selected = true
|
||||||
end
|
end
|
||||||
|
@ -389,7 +258,7 @@ local function new(args)
|
||||||
layout = args.layout or nil,
|
layout = args.layout or nil,
|
||||||
screen = args.screen or nil,
|
screen = args.screen or nil,
|
||||||
style = args.style or nil,
|
style = args.style or nil,
|
||||||
item_style = args.item_style or require("radical.item_style.basic"),
|
item_style = args.item_style or require("radical.item.style.basic"),
|
||||||
filter = args.filter ~= false,
|
filter = args.filter ~= false,
|
||||||
show_filter = args.show_filter or false,
|
show_filter = args.show_filter or false,
|
||||||
filter_string = args.filter_string or "",
|
filter_string = args.filter_string or "",
|
||||||
|
@ -433,7 +302,7 @@ local function new(args)
|
||||||
})
|
})
|
||||||
internal.get_map,internal.set_map,internal.private_data = get_map,set_map,private_data
|
internal.get_map,internal.set_map,internal.private_data = get_map,set_map,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_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
|
||||||
setup_colors(data,args)
|
theme.setup_colors(data,args)
|
||||||
set_map.parent_geometry = function(value)
|
set_map.parent_geometry = function(value)
|
||||||
private_data.parent_geometry = value
|
private_data.parent_geometry = value
|
||||||
if data._internal.get_direction then
|
if data._internal.get_direction then
|
||||||
|
|
|
@ -13,6 +13,7 @@ local util = require( "awful.util" )
|
||||||
local layout = require( "radical.layout" )
|
local layout = require( "radical.layout" )
|
||||||
local checkbox = require( "radical.widgets.checkbox" )
|
local checkbox = require( "radical.widgets.checkbox" )
|
||||||
local arrow_style = require( "radical.style.arrow" )
|
local arrow_style = require( "radical.style.arrow" )
|
||||||
|
local item_mod = require("radical.item")
|
||||||
|
|
||||||
local capi,module = { mouse = mouse , screen = screen, keygrabber = keygrabber },{}
|
local capi,module = { mouse = mouse , screen = screen, keygrabber = keygrabber },{}
|
||||||
|
|
||||||
|
@ -184,7 +185,7 @@ local function setup_buttons(data,item,args)
|
||||||
|
|
||||||
-- Click to open sub_menu
|
-- Click to open sub_menu
|
||||||
if not buttons[1] and data.sub_menu_on == base.event.BUTTON1 then
|
if not buttons[1] and data.sub_menu_on == base.event.BUTTON1 then
|
||||||
buttons[1] = function() base._execute_sub_menu(data,item) end
|
buttons[1] = function() item_mod.execute_sub_menu(data,item) end
|
||||||
end
|
end
|
||||||
|
|
||||||
--Hide on right click
|
--Hide on right click
|
||||||
|
|
|
@ -107,7 +107,7 @@ local function new(s)
|
||||||
select_on = radical.base.event.NEVER,
|
select_on = radical.base.event.NEVER,
|
||||||
fg = beautiful.fg_normal,
|
fg = beautiful.fg_normal,
|
||||||
bg_focus = beautiful.taglist_bg_image_selected2 or beautiful.bg_focus,
|
bg_focus = beautiful.taglist_bg_image_selected2 or beautiful.bg_focus,
|
||||||
item_style = radical.item_style.arrow_prefix,
|
item_style = radical.item.style.arrow_prefix,
|
||||||
bg_hover = beautiful.menu_bg_focus
|
bg_hover = beautiful.menu_bg_focus
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,40 +39,40 @@ local function singalMenu()
|
||||||
return sigMenu
|
return sigMenu
|
||||||
end
|
end
|
||||||
sigMenu = radical.context{max_items=10}
|
sigMenu = radical.context{max_items=10}
|
||||||
sigterm = sigMenu:add_item({text="SIGTERM" , button1 = function() util.spawn("kill -s TERM "..module.client.pid);sigMenu.visible = false end,underlay="15"})
|
sigterm = sigMenu:add_item({text="SIGTERM" , button1 = function() util.spawn("kill -s TERM "..module.client.pid);mainMenu.visible = false end,underlay="15"})
|
||||||
sigkill = sigMenu:add_item({text="SIGKILL" , button1 = function() util.spawn("kill -s KILL "..module.client.pid);sigMenu.visible = false end,underlay="9"})
|
sigkill = sigMenu:add_item({text="SIGKILL" , button1 = function() util.spawn("kill -s KILL "..module.client.pid);mainMenu.visible = false end,underlay="9"})
|
||||||
sigint = sigMenu:add_item({text="SIGINT" , button1 = function() util.spawn("kill -s INT "..module.client.pid);sigMenu.visible = false end,underlay="2"})
|
sigint = sigMenu:add_item({text="SIGINT" , button1 = function() util.spawn("kill -s INT "..module.client.pid);mainMenu.visible = false end,underlay="2"})
|
||||||
sigquit = sigMenu:add_item({text="SIGQUIT" , button1 = function() util.spawn("kill -s QUIT "..module.client.pid);sigMenu.visible = false end,underlay="3"})
|
sigquit = sigMenu:add_item({text="SIGQUIT" , button1 = function() util.spawn("kill -s QUIT "..module.client.pid);mainMenu.visible = false end,underlay="3"})
|
||||||
-- sigMenu:add_widget(radical.widgets.separator())
|
-- sigMenu:add_widget(radical.widgets.separator())
|
||||||
sig0 = sigMenu:add_item({text="SIG0" , button1 = function() util.spawn("kill -s 0 "..module.client.pid);sigMenu.visible = false end,underlay=nil})
|
sig0 = sigMenu:add_item({text="SIG0" , button1 = function() util.spawn("kill -s 0 "..module.client.pid);mainMenu.visible = false end,underlay=nil})
|
||||||
sigalrm = sigMenu:add_item({text="SIGALRM" , button1 = function() util.spawn("kill -s ALRM "..module.client.pid);sigMenu.visible = false end,underlay="14"})
|
sigalrm = sigMenu:add_item({text="SIGALRM" , button1 = function() util.spawn("kill -s ALRM "..module.client.pid);mainMenu.visible = false end,underlay="14"})
|
||||||
sighup = sigMenu:add_item({text="SIGHUP" , button1 = function() util.spawn("kill -s HUP "..module.client.pid);sigMenu.visible = false end,underlay="1",tooltip="sdfsdfsdf"})
|
sighup = sigMenu:add_item({text="SIGHUP" , button1 = function() util.spawn("kill -s HUP "..module.client.pid);mainMenu.visible = false end,underlay="1",tooltip="sdfsdfsdf"})
|
||||||
sigpipe = sigMenu:add_item({text="SIGPIPE" , button1 = function() util.spawn("kill -s PIPE "..module.client.pid);sigMenu.visible = false end,underlay="13"})
|
sigpipe = sigMenu:add_item({text="SIGPIPE" , button1 = function() util.spawn("kill -s PIPE "..module.client.pid);mainMenu.visible = false end,underlay="13"})
|
||||||
sigpoll = sigMenu:add_item({text="SIGPOLL" , button1 = function() util.spawn("kill -s POLL "..module.client.pid);sigMenu.visible = false end,underlay=nil})
|
sigpoll = sigMenu:add_item({text="SIGPOLL" , button1 = function() util.spawn("kill -s POLL "..module.client.pid);mainMenu.visible = false end,underlay=nil})
|
||||||
sigprof = sigMenu:add_item({text="SIGPROF" , button1 = function() util.spawn("kill -s PROF "..module.client.pid);sigMenu.visible = false end,underlay="27"})
|
sigprof = sigMenu:add_item({text="SIGPROF" , button1 = function() util.spawn("kill -s PROF "..module.client.pid);mainMenu.visible = false end,underlay="27"})
|
||||||
sigusr1 = sigMenu:add_item({text="SIGUSR1" , button1 = function() util.spawn("kill -s USR1 "..module.client.pid);sigMenu.visible = false end,underlay="10"})
|
sigusr1 = sigMenu:add_item({text="SIGUSR1" , button1 = function() util.spawn("kill -s USR1 "..module.client.pid);mainMenu.visible = false end,underlay="10"})
|
||||||
sigusr2 = sigMenu:add_item({text="SIGUSR2" , button1 = function() util.spawn("kill -s USR2 "..module.client.pid);sigMenu.visible = false end,underlay="12"})
|
sigusr2 = sigMenu:add_item({text="SIGUSR2" , button1 = function() util.spawn("kill -s USR2 "..module.client.pid);mainMenu.visible = false end,underlay="12"})
|
||||||
sigsigvtalrm = sigMenu:add_item({text="SIGVTALRM" , button1 = function() util.spawn("kill -s VTALRM "..module.client.pid);sigMenu.visible = false end,underlay=nil})
|
sigsigvtalrm = sigMenu:add_item({text="SIGVTALRM" , button1 = function() util.spawn("kill -s VTALRM "..module.client.pid);mainMenu.visible = false end,underlay=nil})
|
||||||
sigstkflt = sigMenu:add_item({text="SIGSTKFLT" , button1 = function() util.spawn("kill -s STKFLT "..module.client.pid);sigMenu.visible = false end,underlay=nil})
|
sigstkflt = sigMenu:add_item({text="SIGSTKFLT" , button1 = function() util.spawn("kill -s STKFLT "..module.client.pid);mainMenu.visible = false end,underlay=nil})
|
||||||
sigpwr = sigMenu:add_item({text="SIGPWR" , button1 = function() util.spawn("kill -s PWR "..module.client.pid);sigMenu.visible = false end,underlay=nil})
|
sigpwr = sigMenu:add_item({text="SIGPWR" , button1 = function() util.spawn("kill -s PWR "..module.client.pid);mainMenu.visible = false end,underlay=nil})
|
||||||
sigwinch = sigMenu:add_item({text="SIGWINCH" , button1 = function() util.spawn("kill -s WINCH "..module.client.pid);sigMenu.visible = false end,underlay=nil})
|
sigwinch = sigMenu:add_item({text="SIGWINCH" , button1 = function() util.spawn("kill -s WINCH "..module.client.pid);mainMenu.visible = false end,underlay=nil})
|
||||||
sigchld = sigMenu:add_item({text="SIGCHLD" , button1 = function() util.spawn("kill -s CHLD "..module.client.pid);sigMenu.visible = false end,underlay="17"})
|
sigchld = sigMenu:add_item({text="SIGCHLD" , button1 = function() util.spawn("kill -s CHLD "..module.client.pid);mainMenu.visible = false end,underlay="17"})
|
||||||
sigurg = sigMenu:add_item({text="SIGURG" , button1 = function() util.spawn("kill -s URG "..module.client.pid);sigMenu.visible = false end,underlay=nil})
|
sigurg = sigMenu:add_item({text="SIGURG" , button1 = function() util.spawn("kill -s URG "..module.client.pid);mainMenu.visible = false end,underlay=nil})
|
||||||
sigtstp = sigMenu:add_item({text="SIGTSTP" , button1 = function() util.spawn("kill -s TSTP "..module.client.pid);sigMenu.visible = false end,underlay=nil})
|
sigtstp = sigMenu:add_item({text="SIGTSTP" , button1 = function() util.spawn("kill -s TSTP "..module.client.pid);mainMenu.visible = false end,underlay=nil})
|
||||||
sigttin = sigMenu:add_item({text="SIGTTIN" , button1 = function() util.spawn("kill -s TTIN "..module.client.pid);sigMenu.visible = false end,underlay="21"})
|
sigttin = sigMenu:add_item({text="SIGTTIN" , button1 = function() util.spawn("kill -s TTIN "..module.client.pid);mainMenu.visible = false end,underlay="21"})
|
||||||
sigttou = sigMenu:add_item({text="SIGTTOU" , button1 = function() util.spawn("kill -s TTOU "..module.client.pid);sigMenu.visible = false end,underlay="22"})
|
sigttou = sigMenu:add_item({text="SIGTTOU" , button1 = function() util.spawn("kill -s TTOU "..module.client.pid);mainMenu.visible = false end,underlay="22"})
|
||||||
sigstop = sigMenu:add_item({text="SIGSTOP" , button1 = function() util.spawn("kill -s STOP "..module.client.pid);sigMenu.visible = false end,underlay="17"})
|
sigstop = sigMenu:add_item({text="SIGSTOP" , button1 = function() util.spawn("kill -s STOP "..module.client.pid);mainMenu.visible = false end,underlay="17"})
|
||||||
sigcont = sigMenu:add_item({text="SIGCONT" , button1 = function() util.spawn("kill -s CONT "..module.client.pid);sigMenu.visible = false end,underlay="18"})
|
sigcont = sigMenu:add_item({text="SIGCONT" , button1 = function() util.spawn("kill -s CONT "..module.client.pid);mainMenu.visible = false end,underlay="18"})
|
||||||
sigabrt = sigMenu:add_item({text="SIGABRT" , button1 = function() util.spawn("kill -s ABRT "..module.client.pid);sigMenu.visible = false end,underlay="6"})
|
sigabrt = sigMenu:add_item({text="SIGABRT" , button1 = function() util.spawn("kill -s ABRT "..module.client.pid);mainMenu.visible = false end,underlay="6"})
|
||||||
sigfpe = sigMenu:add_item({text="SIGFPE" , button1 = function() util.spawn("kill -s FPE "..module.client.pid);sigMenu.visible = false end,underlay="8"})
|
sigfpe = sigMenu:add_item({text="SIGFPE" , button1 = function() util.spawn("kill -s FPE "..module.client.pid);mainMenu.visible = false end,underlay="8"})
|
||||||
sigill = sigMenu:add_item({text="SIGILL" , button1 = function() util.spawn("kill -s ILL "..module.client.pid);sigMenu.visible = false end,underlay="4"})
|
sigill = sigMenu:add_item({text="SIGILL" , button1 = function() util.spawn("kill -s ILL "..module.client.pid);mainMenu.visible = false end,underlay="4"})
|
||||||
sigsegv = sigMenu:add_item({text="SIGSEGV" , button1 = function() util.spawn("kill -s SEGV "..module.client.pid);sigMenu.visible = false end,underlay="11"})
|
sigsegv = sigMenu:add_item({text="SIGSEGV" , button1 = function() util.spawn("kill -s SEGV "..module.client.pid);mainMenu.visible = false end,underlay="11"})
|
||||||
sigtrap = sigMenu:add_item({text="SIGTRAP" , button1 = function() util.spawn("kill -s TRAP "..module.client.pid);sigMenu.visible = false end,underlay="5"})
|
sigtrap = sigMenu:add_item({text="SIGTRAP" , button1 = function() util.spawn("kill -s TRAP "..module.client.pid);mainMenu.visible = false end,underlay="5"})
|
||||||
sigsys = sigMenu:add_item({text="SIGSYS" , button1 = function() util.spawn("kill -s SYS "..module.client.pid);sigMenu.visible = false end,underlay="12"})
|
sigsys = sigMenu:add_item({text="SIGSYS" , button1 = function() util.spawn("kill -s SYS "..module.client.pid);mainMenu.visible = false end,underlay="12"})
|
||||||
sigemt = sigMenu:add_item({text="SIGEMT" , button1 = function() util.spawn("kill -s EMT "..module.client.pid);sigMenu.visible = false end,underlay=nil})
|
sigemt = sigMenu:add_item({text="SIGEMT" , button1 = function() util.spawn("kill -s EMT "..module.client.pid);mainMenu.visible = false end,underlay=nil})
|
||||||
sigbus = sigMenu:add_item({text="SIGBUS" , button1 = function() util.spawn("kill -s BUS "..module.client.pid);sigMenu.visible = false end,underlay="7"})
|
sigbus = sigMenu:add_item({text="SIGBUS" , button1 = function() util.spawn("kill -s BUS "..module.client.pid);mainMenu.visible = false end,underlay="7"})
|
||||||
sigxcpu = sigMenu:add_item({text="SIGXCPU" , button1 = function() util.spawn("kill -s XCPU "..module.client.pid);sigMenu.visible = false end,underlay=nil})
|
sigxcpu = sigMenu:add_item({text="SIGXCPU" , button1 = function() util.spawn("kill -s XCPU "..module.client.pid);mainMenu.visible = false end,underlay=nil})
|
||||||
sigxfsz = sigMenu:add_item({text="SIGXFSZ" , button1 = function() util.spawn("kill -s XFSZ "..module.client.pid);sigMenu.visible = false end,underlay=nil})
|
sigxfsz = sigMenu:add_item({text="SIGXFSZ" , button1 = function() util.spawn("kill -s XFSZ "..module.client.pid);mainMenu.visible = false end,underlay=nil})
|
||||||
return sigMenu
|
return sigMenu
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,10 @@ end
|
||||||
local function urgent_callback(c)
|
local function urgent_callback(c)
|
||||||
local val = c.urgent
|
local val = c.urgent
|
||||||
urgent[c] = val and true or nil
|
urgent[c] = val and true or nil
|
||||||
|
local item = instances[c.screen].cache[c]
|
||||||
|
if item then
|
||||||
|
item.state[radical.base.item_flags.URGENT] = val or nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function unmanage_callback(c)
|
local function unmanage_callback(c)
|
||||||
|
|
29
init.lua
29
init.lua
|
@ -42,22 +42,21 @@ base.make_widget = function(...)
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
|
|
||||||
local bar = require( "radical.bar" )
|
local bar = require( "radical.bar" )
|
||||||
|
|
||||||
return {
|
return {
|
||||||
layout = require( "radical.layout" ),
|
layout = require( "radical.layout" ),
|
||||||
object = require( "radical.object" ),
|
object = require( "radical.object" ),
|
||||||
base = require( "radical.base" ),
|
base = require( "radical.base" ),
|
||||||
radial = require( "radical.radial" ),
|
radial = require( "radical.radial" ),
|
||||||
context = require( "radical.context" ),
|
context = require( "radical.context" ),
|
||||||
embed = require( "radical.embed" ),
|
embed = require( "radical.embed" ),
|
||||||
box = require( "radical.box" ),
|
box = require( "radical.box" ),
|
||||||
style = require( "radical.style" ),
|
style = require( "radical.style" ),
|
||||||
item_style = require( "radical.item_style" ),
|
widgets = require( "radical.widgets" ),
|
||||||
widgets = require( "radical.widgets" ),
|
item = require( "radical.item" ),
|
||||||
item_layout = require( "radical.item_layout"),
|
bar = bar,
|
||||||
bar = bar,
|
flexbar = bar.flex,
|
||||||
flexbar = bar.flex,
|
tooltip = tooltip
|
||||||
tooltip = tooltip
|
|
||||||
}
|
}
|
||||||
-- kate: space-indent on; indent-width 2; replace-tabs on;
|
-- kate: space-indent on; indent-width 2; replace-tabs on;
|
||||||
|
|
162
item/init.lua
162
item/init.lua
|
@ -0,0 +1,162 @@
|
||||||
|
local type = type
|
||||||
|
local beautiful = require("beautiful")
|
||||||
|
local theme = require("radical.theme")
|
||||||
|
local object = require("radical.object")
|
||||||
|
|
||||||
|
local module = {
|
||||||
|
-- style = require("radical.item.style"),
|
||||||
|
-- layout = require("radical.item.layout"),
|
||||||
|
arrow_type = {
|
||||||
|
NONE = 0,
|
||||||
|
PRETTY = 1,
|
||||||
|
CENTERED = 2,
|
||||||
|
},
|
||||||
|
event ={
|
||||||
|
NEVER = 0,
|
||||||
|
BUTTON1 = 1,
|
||||||
|
BUTTON2 = 2,
|
||||||
|
BUTTON3 = 3,
|
||||||
|
SELECTED = 100,
|
||||||
|
HOVER = 1000,
|
||||||
|
LEAVE = 1001,
|
||||||
|
},
|
||||||
|
item_flags = {
|
||||||
|
NONE = 999999 ,
|
||||||
|
DISABLED = 1 , -- Cannot be interacted with
|
||||||
|
URGENT = 2 , -- Need attention
|
||||||
|
SELECTED = 3 , -- Single item selected [[FOCUS]]
|
||||||
|
PRESSED = 4 , -- Mouse pressed
|
||||||
|
HOVERED = 5 , -- Mouse hover
|
||||||
|
USED = 6 , -- Common flag
|
||||||
|
CHECKED = 7 , -- When checkbox isn't enough
|
||||||
|
ALTERNATE = 8 ,
|
||||||
|
HIGHLIGHT = 9 ,
|
||||||
|
HEADER = 10,
|
||||||
|
|
||||||
|
-- Implementation defined flags
|
||||||
|
USR1 = 101,
|
||||||
|
USR2 = 102,
|
||||||
|
USR3 = 103,
|
||||||
|
USR4 = 104,
|
||||||
|
USR5 = 105,
|
||||||
|
USR6 = 106,
|
||||||
|
USR7 = 107,
|
||||||
|
USR8 = 108,
|
||||||
|
USR9 = 109,
|
||||||
|
USR10 = 110,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
local function load_async(tab,key)
|
||||||
|
print("here",key)
|
||||||
|
if key == "style" then
|
||||||
|
module.style = require("radical.item.style")
|
||||||
|
return module.style
|
||||||
|
elseif key == "layout" then
|
||||||
|
module.layout = require("radical.item.layout")
|
||||||
|
return module.layout
|
||||||
|
end
|
||||||
|
return rawget(module,key)
|
||||||
|
end
|
||||||
|
|
||||||
|
function module.execute_sub_menu(data,item)
|
||||||
|
if (item._private_data.sub_menu_f or item._private_data.sub_menu_m) then
|
||||||
|
local sub_menu = item._private_data.sub_menu_m or item._private_data.sub_menu_f(data,item)
|
||||||
|
if sub_menu and sub_menu.rowcount > 0 then
|
||||||
|
sub_menu.arrow_type = module.arrow_type.NONE
|
||||||
|
sub_menu.parent_item = item
|
||||||
|
sub_menu.parent_geometry = data
|
||||||
|
sub_menu.visible = true
|
||||||
|
item._tmp_menu = sub_menu
|
||||||
|
data._tmp_menu = sub_menu
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function new_item(data,args)
|
||||||
|
local args = args or {}
|
||||||
|
local item,set_map,get_map,private_data = object({
|
||||||
|
private_data = {
|
||||||
|
text = args.text or "" ,
|
||||||
|
height = args.height or beautiful.menu_height or 30 ,
|
||||||
|
width = args.width or nil ,
|
||||||
|
icon = args.icon or nil ,
|
||||||
|
prefix = args.prefix or "" ,
|
||||||
|
suffix = args.suffix or "" ,
|
||||||
|
bg = args.bg or nil ,
|
||||||
|
fg = args.fg or data.fg or beautiful.menu_fg_normal or beautiful.fg_normal ,
|
||||||
|
fg_focus = args.fg_focus or data.fg_focus or beautiful.menu_fg_focus or beautiful.fg_focus ,
|
||||||
|
bg_focus = args.bg_focus or data.bg_focus or beautiful.menu_bg_focus or beautiful.bg_focus ,
|
||||||
|
bg_prefix = args.bg_prefix or data.bg_prefix ,
|
||||||
|
sub_menu_m = (args.sub_menu and type(args.sub_menu) == "table" and args.sub_menu.is_menu) and args.sub_menu or nil,
|
||||||
|
sub_menu_f = (args.sub_menu and type(args.sub_menu) == "function") and args.sub_menu or nil ,
|
||||||
|
checkable = args.checkable or (args.checked ~= nil) or false ,
|
||||||
|
checked = args.checked or false ,
|
||||||
|
underlay = args.underlay or nil ,
|
||||||
|
tooltip = args.tooltip or nil ,
|
||||||
|
item_style = args.item_style or nil ,
|
||||||
|
item_layout = args.item_layout or nil ,
|
||||||
|
selected = false ,
|
||||||
|
overlay = args.overlay or data.overlay or nil ,
|
||||||
|
state = theme.init_state() ,
|
||||||
|
},
|
||||||
|
force_private = {
|
||||||
|
visible = true,
|
||||||
|
selected = true,
|
||||||
|
},
|
||||||
|
get_map = {
|
||||||
|
y = function() return (args.y and args.y >= 0) and args.y or data.height - (data.margins.top or data.border_width) - data.item_height end, --Hack around missing :fit call for last item
|
||||||
|
},
|
||||||
|
autogen_getmap = true,
|
||||||
|
autogen_setmap = true,
|
||||||
|
autogen_signals = true,
|
||||||
|
})
|
||||||
|
item._private_data = private_data
|
||||||
|
item._internal = {get_map=get_map,set_map=set_map}
|
||||||
|
|
||||||
|
for i=1,10 do
|
||||||
|
item["button"..i] = args["button"..i]
|
||||||
|
end
|
||||||
|
|
||||||
|
if data.max_items ~= nil and data.rowcount >= data.max_items then-- and (data._start_at or 0)
|
||||||
|
item._hidden = true
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Use _internal to avoid the radical.object trigger
|
||||||
|
data._internal.visible_item_count = (data._internal.visible_item_count or 0) + 1
|
||||||
|
item._internal.f_key = data._internal.visible_item_count
|
||||||
|
|
||||||
|
-- Need to be done before painting
|
||||||
|
data._internal.items[#data._internal.items+1] = {}
|
||||||
|
data._internal.items[#data._internal.items][1] = item
|
||||||
|
|
||||||
|
-- Setters
|
||||||
|
set_map.selected = function(value)
|
||||||
|
private_data.selected = value
|
||||||
|
if value == false then
|
||||||
|
data.item_style(data,item,{})
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local current_item = data._current_item
|
||||||
|
if current_item and current_item ~= item then
|
||||||
|
current_item.state[module.item_flags.SELECTED] = nil
|
||||||
|
if current_item._tmp_menu then
|
||||||
|
current_item._tmp_menu.visible = false
|
||||||
|
current_item._tmp_menu = nil
|
||||||
|
data._tmp_menu = nil
|
||||||
|
end
|
||||||
|
data.item_style(data,current_item,{})
|
||||||
|
current_item.selected = false
|
||||||
|
end
|
||||||
|
if data.sub_menu_on == module.event.SELECTED and current_item ~= item then
|
||||||
|
module.execute_sub_menu(data,item)
|
||||||
|
end
|
||||||
|
item.state[module.item_flags.SELECTED] = true
|
||||||
|
data.item_style(data,item,{})
|
||||||
|
data._current_item = item
|
||||||
|
end
|
||||||
|
return item
|
||||||
|
end
|
||||||
|
|
||||||
|
return setmetatable(module, { __call = function(_, ...) return new_item(...) end, __index=load_async})
|
||||||
|
-- kate: space-indent on; indent-width 2; replace-tabs on;
|
|
@ -5,7 +5,7 @@ local cairo = require( "lgi" ).cairo
|
||||||
local wibox = require( "wibox" )
|
local wibox = require( "wibox" )
|
||||||
local checkbox = require( "radical.widgets.checkbox" )
|
local checkbox = require( "radical.widgets.checkbox" )
|
||||||
local fkey = require( "radical.widgets.fkey" )
|
local fkey = require( "radical.widgets.fkey" )
|
||||||
local horizontal = require( "radical.item_layout.horizontal" )
|
local horizontal = require( "radical.item.layout.horizontal" )
|
||||||
|
|
||||||
local module = {}
|
local module = {}
|
||||||
|
|
|
@ -5,7 +5,7 @@ local cairo = require( "lgi" ).cairo
|
||||||
local wibox = require( "wibox" )
|
local wibox = require( "wibox" )
|
||||||
local checkbox = require( "radical.widgets.checkbox" )
|
local checkbox = require( "radical.widgets.checkbox" )
|
||||||
local fkey = require( "radical.widgets.fkey" )
|
local fkey = require( "radical.widgets.fkey" )
|
||||||
local horizontal = require( "radical.item_layout.horizontal" )
|
local horizontal = require( "radical.item.layout.horizontal" )
|
||||||
|
|
||||||
local module = {}
|
local module = {}
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
return {
|
||||||
|
icon = require( "radical.item.layout.icon" ),
|
||||||
|
horizontal = require( "radical.item.layout.horizontal" ),
|
||||||
|
centerred = require( "radical.item.layout.centerred" ),
|
||||||
|
}
|
|
@ -4,7 +4,7 @@ local beautiful = require("beautiful" )
|
||||||
local color = require("gears.color" )
|
local color = require("gears.color" )
|
||||||
local cairo = require("lgi" ).cairo
|
local cairo = require("lgi" ).cairo
|
||||||
local wibox = require("wibox" )
|
local wibox = require("wibox" )
|
||||||
local arrow_alt = require("radical.item_style.arrow_alt")
|
local arrow_alt = require("radical.item.style.arrow_alt")
|
||||||
|
|
||||||
local module = {
|
local module = {
|
||||||
margins = {
|
margins = {
|
|
@ -4,7 +4,7 @@ local beautiful = require("beautiful" )
|
||||||
local color = require("gears.color" )
|
local color = require("gears.color" )
|
||||||
local cairo = require("lgi" ).cairo
|
local cairo = require("lgi" ).cairo
|
||||||
local wibox = require("wibox" )
|
local wibox = require("wibox" )
|
||||||
local arrow_alt = require("radical.item_style.arrow_alt")
|
local arrow_alt = require("radical.item.style.arrow_alt")
|
||||||
|
|
||||||
local module = {
|
local module = {
|
||||||
margins = {
|
margins = {
|
|
@ -0,0 +1,8 @@
|
||||||
|
return {
|
||||||
|
basic = require("radical.item.style.basic" ),
|
||||||
|
classic = require("radical.item.style.classic" ),
|
||||||
|
rounded = require("radical.item.style.rounded" ),
|
||||||
|
arrow_alt = require("radical.item.style.arrow_alt" ),
|
||||||
|
arrow_prefix = require("radical.item.style.arrow_prefix" ),
|
||||||
|
arrow_single = require("radical.item.style.arrow_single" ),
|
||||||
|
}
|
|
@ -1,5 +0,0 @@
|
||||||
return {
|
|
||||||
icon = require( "radical.item_layout.icon" ),
|
|
||||||
horizontal = require( "radical.item_layout.horizontal" ),
|
|
||||||
centerred = require( "radical.item_layout.centerred" ),
|
|
||||||
}
|
|
|
@ -1,8 +0,0 @@
|
||||||
return {
|
|
||||||
basic = require("radical.item_style.basic" ),
|
|
||||||
classic = require("radical.item_style.classic" ),
|
|
||||||
rounded = require("radical.item_style.rounded" ),
|
|
||||||
arrow_alt = require("radical.item_style.arrow_alt" ),
|
|
||||||
arrow_prefix = require("radical.item_style.arrow_prefix" ),
|
|
||||||
arrow_single = require("radical.item_style.arrow_single" ),
|
|
||||||
}
|
|
|
@ -5,7 +5,7 @@ local util = require( "awful.util" )
|
||||||
local button = require( "awful.button" )
|
local button = require( "awful.button" )
|
||||||
local checkbox = require( "radical.widgets.checkbox" )
|
local checkbox = require( "radical.widgets.checkbox" )
|
||||||
local wibox = require( "wibox" )
|
local wibox = require( "wibox" )
|
||||||
local item_layout = require("radical.item_layout.icon")
|
local item_layout = require("radical.item.layout.icon")
|
||||||
local base = nil
|
local base = nil
|
||||||
|
|
||||||
local module = {}
|
local module = {}
|
||||||
|
|
|
@ -5,7 +5,7 @@ local filter = require( "radical.widgets.filter" )
|
||||||
local wibox = require( "wibox" )
|
local wibox = require( "wibox" )
|
||||||
local cairo = require( "lgi" ).cairo
|
local cairo = require( "lgi" ).cairo
|
||||||
local base = nil
|
local base = nil
|
||||||
local horizontal_item_layout= require( "radical.item_layout.horizontal" )
|
local horizontal_item_layout= require( "radical.item.layout.horizontal" )
|
||||||
|
|
||||||
local module = {}
|
local module = {}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
local math = math
|
||||||
|
local beautiful = require( "beautiful" )
|
||||||
|
|
||||||
|
local module = {
|
||||||
|
colors_by_id = {}
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Do some magic to cache the highest state
|
||||||
|
local function return_data(tab, key)
|
||||||
|
return tab._real_table[key]
|
||||||
|
end
|
||||||
|
local function change_data(tab, key,value)
|
||||||
|
if not value and key == rawget(tab,"_current_key") then
|
||||||
|
-- Loop the array to find a new current_key
|
||||||
|
local win = math.huge
|
||||||
|
for k,v in pairs(tab._real_table) do
|
||||||
|
if k < win and k ~= key then
|
||||||
|
win = k
|
||||||
|
end
|
||||||
|
end
|
||||||
|
rawset(tab,"_current_key",win ~= math.huge and win or nil)
|
||||||
|
elseif value and (rawget(tab,"_current_key") or math.huge) > key then
|
||||||
|
rawset(tab,"_current_key",key)
|
||||||
|
end
|
||||||
|
tab._real_table[key] = value
|
||||||
|
end
|
||||||
|
function module.init_state()
|
||||||
|
local mt = {__newindex = change_data,__index=return_data}
|
||||||
|
return setmetatable({_real_table={}},mt)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Util to help match colors to states
|
||||||
|
local theme_colors = {}
|
||||||
|
function module.register_color(state_id,name,beautiful_name,allow_fallback)
|
||||||
|
theme_colors[name] = {id=state_id,beautiful_name=beautiful_name,fallback=allow_fallback}
|
||||||
|
module.colors_by_id[state_id] = name
|
||||||
|
end
|
||||||
|
function module.setup_colors(data,args)
|
||||||
|
local priv = data._internal.private_data
|
||||||
|
for k,v in pairs(theme_colors) do
|
||||||
|
priv["fg_"..k] = args["fg_"..k] or beautiful["menu_fg_"..v.beautiful_name] or beautiful["fg_"..v.beautiful_name] or (v.fallback and "#ff0000")
|
||||||
|
priv["bg_"..k] = args["bg_"..k] or beautiful["menu_bg_"..v.beautiful_name] or beautiful["bg_"..v.beautiful_name] or (v.fallback and "#00ff00")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
return setmetatable(module, { __call = function(_, ...) return new(...) end })
|
||||||
|
-- kate: space-indent on; indent-width 2; replace-tabs on;
|
Loading…
Reference in New Issue