base: Remove setup_drawable callback
As this was the last step in the base constructor, it could be done in each menu type without the callback and extra code. The only reason this existed was to allow menu "sub classes" that override this function. However, since this was rewritten, it was no longer used, so for the sake of simplicity, I remove this feature.
This commit is contained in:
parent
84f19c51a1
commit
1c34c56d0b
27
bar.lua
27
bar.lua
|
@ -8,7 +8,17 @@ local shape = require( "gears.shape" )
|
|||
|
||||
local module = {}
|
||||
|
||||
local function setup_drawable(data)
|
||||
local function new(args)
|
||||
args = args or {}
|
||||
args.border_width = args.border_width or 0
|
||||
args.internal = args.internal or {}
|
||||
args.internal.setup_item = args.internal.setup_item or common.setup_item
|
||||
args.item_style = args.item_style or item_style
|
||||
args.item_layout = args.item_layout or item_layout
|
||||
args.sub_menu_on = args.sub_menu_on or base.event.BUTTON1
|
||||
|
||||
local data = base(args)
|
||||
|
||||
local internal = data._internal
|
||||
|
||||
-- Use a background to make the border work
|
||||
|
@ -46,21 +56,8 @@ local function setup_drawable(data)
|
|||
end
|
||||
|
||||
common.setup_item_move_events(data)
|
||||
end
|
||||
|
||||
local function new(args)
|
||||
args = args or {}
|
||||
args.border_width = args.border_width or 0
|
||||
args.internal = args.internal or {}
|
||||
args.internal.setup_drawable = args.internal.setup_drawable or setup_drawable
|
||||
args.internal.setup_item = args.internal.setup_item or common.setup_item
|
||||
args.item_style = args.item_style or item_style
|
||||
args.item_layout = args.item_layout or item_layout
|
||||
args.sub_menu_on = args.sub_menu_on or base.event.BUTTON1
|
||||
|
||||
local ret = base(args)
|
||||
|
||||
return ret,ret._internal.widget
|
||||
return data, data._internal.widget
|
||||
end
|
||||
|
||||
function module.flex(args)
|
||||
|
|
2
base.lua
2
base.lua
|
@ -638,8 +638,6 @@ local function new(args)
|
|||
end
|
||||
end
|
||||
|
||||
data._internal.setup_drawable(data)
|
||||
|
||||
return data
|
||||
end
|
||||
return setmetatable(module, { __call = function(_, ...) return new(...) end })
|
||||
|
|
30
context.lua
30
context.lua
|
@ -23,7 +23,17 @@ local function set_visible(i, value)
|
|||
end
|
||||
end
|
||||
|
||||
local function setup_drawable(data)
|
||||
local function new(args)
|
||||
args = args or {}
|
||||
args.internal = args.internal or {}
|
||||
args.internal.setup_item = args.internal.setup_item or common.setup_item
|
||||
args.style = args.style or beautiful.menu_default_style or arrow_style
|
||||
local data = base(args)
|
||||
|
||||
data:connect_signal("parent_geometry::changed", function()
|
||||
args.internal.w:move_by_parent(data.parent_geometry, "widget")
|
||||
end)
|
||||
|
||||
local internal = data._internal
|
||||
|
||||
-- Create the layout
|
||||
|
@ -52,27 +62,13 @@ local function setup_drawable(data)
|
|||
data.get_margins = common.get_margins
|
||||
internal.set_visible = set_visible
|
||||
|
||||
|
||||
-- Support remove, swap, insert, append...
|
||||
common.setup_item_move_events(data)
|
||||
end
|
||||
|
||||
local function new(args)
|
||||
args = args or {}
|
||||
args.internal = args.internal or {}
|
||||
args.internal.setup_drawable = args.internal.setup_drawable or setup_drawable
|
||||
args.internal.setup_item = args.internal.setup_item or common.setup_item
|
||||
args.style = args.style or beautiful.menu_default_style or arrow_style
|
||||
local ret = base(args)
|
||||
|
||||
ret:connect_signal("parent_geometry::changed", function()
|
||||
args.internal.w:move_by_parent(ret.parent_geometry, "widget")
|
||||
end)
|
||||
|
||||
-- Init the style
|
||||
args.style(ret)
|
||||
args.style(data)
|
||||
|
||||
return ret
|
||||
return data
|
||||
end
|
||||
|
||||
return setmetatable(module, { __call = function(_, ...) return new(...) end })
|
||||
|
|
37
dock.lua
37
dock.lua
|
@ -104,25 +104,6 @@ local function get_wibox(data, screen)
|
|||
return w
|
||||
end
|
||||
|
||||
local function setup_drawable(data)
|
||||
local internal = data._internal
|
||||
|
||||
-- Create the layout
|
||||
internal.layout = data.layout(data)
|
||||
|
||||
-- Getters
|
||||
data.get_visible = function() return true end
|
||||
data.get_margins = common.get_margins
|
||||
|
||||
function data:set_visible(value)
|
||||
if internal.w then
|
||||
internal.w.visible = value or false
|
||||
end
|
||||
end
|
||||
|
||||
common.setup_item_move_events(data)
|
||||
end
|
||||
|
||||
local function new(args)
|
||||
args = args or {}
|
||||
local orientation = (not args.position or args.position == "left" or args.position == "right") and "vertical" or "horizontal"
|
||||
|
@ -131,7 +112,6 @@ local function new(args)
|
|||
-- The the Radical arguments
|
||||
args.internal = args.internal or {}
|
||||
args.internal.orientation = orientation
|
||||
args.internal.setup_drawable = args.internal.setup_drawable or setup_drawable
|
||||
args.internal.setup_item = args.internal.setup_item or common.setup_item
|
||||
args.item_style = args.item_style or item_style
|
||||
args.bg = color("#00000000") --Use the dock bg instead
|
||||
|
@ -162,6 +142,23 @@ local function new(args)
|
|||
end)
|
||||
end
|
||||
|
||||
local internal = ret._internal
|
||||
|
||||
-- Create the layout
|
||||
internal.layout = ret.layout(ret)
|
||||
|
||||
-- Getters
|
||||
ret.get_visible = function() return true end
|
||||
ret.get_margins = common.get_margins
|
||||
|
||||
function ret:set_visible(value)
|
||||
if internal.w then
|
||||
internal.w.visible = value or false
|
||||
end
|
||||
end
|
||||
|
||||
common.setup_item_move_events(ret)
|
||||
|
||||
return ret
|
||||
end
|
||||
|
||||
|
|
28
embed.lua
28
embed.lua
|
@ -4,7 +4,18 @@ local layout = require( "radical.layout" )
|
|||
local classic_style = require( "radical.style.classic" )
|
||||
local common = require( "radical.common" )
|
||||
|
||||
local function setup_drawable(data)
|
||||
local function new(args)
|
||||
args = args or {}
|
||||
args.internal = args.internal or {}
|
||||
args.internal.setup_item = args.internal.setup_item or common.setup_item
|
||||
args.style = args.style or classic_style
|
||||
local data = base(args)
|
||||
|
||||
data:connect_signal("clear::menu",function(_,vis)
|
||||
local l = data._internal.content_layout or data._internal.layout
|
||||
l:reset()
|
||||
end)
|
||||
|
||||
local internal = data._internal
|
||||
|
||||
-- An embeded menu can only be visible if the parent is
|
||||
|
@ -30,21 +41,8 @@ local function setup_drawable(data)
|
|||
|
||||
-- Support remove, swap, insert, append...
|
||||
common.setup_item_move_events(data)
|
||||
end
|
||||
|
||||
local function new(args)
|
||||
args = args or {}
|
||||
args.internal = args.internal or {}
|
||||
args.internal.setup_drawable = args.internal.setup_drawable or setup_drawable
|
||||
args.internal.setup_item = args.internal.setup_item or common.setup_item
|
||||
args.style = args.style or classic_style
|
||||
local ret = base(args)
|
||||
ret:connect_signal("clear::menu",function(_,vis)
|
||||
local l = ret._internal.content_layout or ret._internal.layout
|
||||
l:reset()
|
||||
end)
|
||||
|
||||
return ret
|
||||
return data
|
||||
end
|
||||
|
||||
return setmetatable({}, { __call = function(_, ...) return new(...) end })
|
||||
|
|
Loading…
Reference in New Issue