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:
Emmanuel Lepage Vallee 2016-06-29 16:01:14 -04:00
parent 84f19c51a1
commit 1c34c56d0b
5 changed files with 55 additions and 69 deletions

27
bar.lua
View File

@ -8,7 +8,17 @@ local shape = require( "gears.shape" )
local module = {} 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 local internal = data._internal
-- Use a background to make the border work -- Use a background to make the border work
@ -46,21 +56,8 @@ local function setup_drawable(data)
end end
common.setup_item_move_events(data) common.setup_item_move_events(data)
end
local function new(args) return data, data._internal.widget
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
end end
function module.flex(args) function module.flex(args)

View File

@ -638,8 +638,6 @@ local function new(args)
end end
end end
data._internal.setup_drawable(data)
return data return data
end end
return setmetatable(module, { __call = function(_, ...) return new(...) end }) return setmetatable(module, { __call = function(_, ...) return new(...) end })

View File

@ -23,7 +23,17 @@ local function set_visible(i, value)
end end
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 local internal = data._internal
-- Create the layout -- Create the layout
@ -52,27 +62,13 @@ local function setup_drawable(data)
data.get_margins = common.get_margins data.get_margins = common.get_margins
internal.set_visible = set_visible internal.set_visible = set_visible
-- Support remove, swap, insert, append... -- Support remove, swap, insert, append...
common.setup_item_move_events(data) 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 -- Init the style
args.style(ret) args.style(data)
return ret return data
end end
return setmetatable(module, { __call = function(_, ...) return new(...) end }) return setmetatable(module, { __call = function(_, ...) return new(...) end })

View File

@ -104,25 +104,6 @@ local function get_wibox(data, screen)
return w return w
end 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) local function new(args)
args = args or {} args = args or {}
local orientation = (not args.position or args.position == "left" or args.position == "right") and "vertical" or "horizontal" 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 -- The the Radical arguments
args.internal = args.internal or {} args.internal = args.internal or {}
args.internal.orientation = orientation 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.internal.setup_item = args.internal.setup_item or common.setup_item
args.item_style = args.item_style or item_style args.item_style = args.item_style or item_style
args.bg = color("#00000000") --Use the dock bg instead args.bg = color("#00000000") --Use the dock bg instead
@ -162,6 +142,23 @@ local function new(args)
end) end)
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 return ret
end end

View File

@ -4,7 +4,18 @@ local layout = require( "radical.layout" )
local classic_style = require( "radical.style.classic" ) local classic_style = require( "radical.style.classic" )
local common = require( "radical.common" ) 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 local internal = data._internal
-- An embeded menu can only be visible if the parent is -- 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... -- Support remove, swap, insert, append...
common.setup_item_move_events(data) common.setup_item_move_events(data)
end
local function new(args) return data
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
end end
return setmetatable({}, { __call = function(_, ...) return new(...) end }) return setmetatable({}, { __call = function(_, ...) return new(...) end })