quality: Port all legacy `:buttons()` to `.buttons`.

This commit is contained in:
Emmanuel Lepage Vallee 2018-12-28 03:06:03 -05:00
parent fa414a86a3
commit 2c08c2fa39
9 changed files with 57 additions and 58 deletions

View File

@ -458,10 +458,11 @@ function widget.new(args)
height = height, height = height,
}) })
mywibox:set_widget(pages[1]) mywibox:set_widget(pages[1])
mywibox:buttons(gtable.join(
mywibox.buttons = {
awful.button({ }, 1, function () widget_obj:hide() end), awful.button({ }, 1, function () widget_obj:hide() end),
awful.button({ }, 3, function () widget_obj:hide() end) awful.button({ }, 3, function () widget_obj:hide() end)
)) }
function widget_obj.page_next(_self) function widget_obj.page_next(_self)
if _self.current_page == #pages then return end if _self.current_page == #pages then return end

View File

@ -446,13 +446,14 @@ function menu:add(args, index)
-- Create bindings -- Create bindings
item._background:buttons(gtable.join( item._background.buttons = {
button({}, 3, function () self:hide() end), button({}, 3, function () self:hide() end),
button({}, 1, function () button({}, 1, function ()
local num = gtable.hasitem(self.items, item) local num = gtable.hasitem(self.items, item)
self:item_enter(num, { mouse = true }) self:item_enter(num, { mouse = true })
self:exec(num, { exec = true, mouse = true }) self:exec(num, { exec = true, mouse = true })
end ))) end)
}
item._mouse = function () item._mouse = function ()

View File

@ -1,12 +1,12 @@
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
-- A simple button widget. -- A simple button widget.
-- @usage local button = awful.widget.button() --
-- button:buttons(gears.table.join( -- button.buttons = {
-- button:buttons(),
-- awful.button({}, 1, nil, function () -- awful.button({}, 1, nil, function ()
-- print("Mouse was clicked") -- print("Mouse was clicked")
-- end) -- end)
-- )) -- }
--
-- @author Julien Danjou <julien@danjou.info> -- @author Julien Danjou <julien@danjou.info>
-- @copyright 2008-2009 Julien Danjou -- @copyright 2008-2009 Julien Danjou
-- @widgetmod awful.widget.button -- @widgetmod awful.widget.button

View File

@ -254,7 +254,8 @@ function calendar_popup:attach(widget, position, args)
position = position or "tr" position = position or "tr"
args = args or {} args = args or {}
if args.on_hover == nil then args.on_hover=true end if args.on_hover == nil then args.on_hover=true end
widget:buttons(gears.table.join(
widget.buttons = {
abutton({ }, 1, function () abutton({ }, 1, function ()
if not self.visible or self._calendar_clicked_on then if not self.visible or self._calendar_clicked_on then
self:call_calendar(0, position) self:call_calendar(0, position)
@ -264,7 +265,8 @@ function calendar_popup:attach(widget, position, args)
end), end),
abutton({ }, 4, function () self:call_calendar(-1) end), abutton({ }, 4, function () self:call_calendar(-1) end),
abutton({ }, 5, function () self:call_calendar( 1) end) abutton({ }, 5, function () self:call_calendar( 1) end)
)) }
if args.on_hover then if args.on_hover then
widget:connect_signal("mouse::enter", function () widget:connect_signal("mouse::enter", function ()
if not self._calendar_clicked_on then if not self._calendar_clicked_on then
@ -330,7 +332,7 @@ local function get_cal_wibox(caltype, args)
} }
ret:set_widget(widget) ret:set_widget(widget)
ret:buttons(gears.table.join( ret.buttons = {
abutton({ }, 1, function () abutton({ }, 1, function ()
ret.visible=false ret.visible=false
ret._calendar_clicked_on=false ret._calendar_clicked_on=false
@ -341,7 +343,8 @@ local function get_cal_wibox(caltype, args)
end), end),
abutton({ }, 4, function () ret:call_calendar(-1) end), abutton({ }, 4, function () ret:call_calendar(-1) end),
abutton({ }, 5, function () ret:call_calendar( 1) end) abutton({ }, 5, function () ret:call_calendar( 1) end)
)) }
return ret return ret
end end

View File

@ -129,7 +129,7 @@ function common.list_update(w, buttons, label, data, objects, args)
cache = (args and args.widget_template) and cache = (args and args.widget_template) and
custom_template(args) or default_template() custom_template(args) or default_template()
cache.primary:buttons(common.create_buttons(buttons, o)) cache.primary.buttons = {common.create_buttons(buttons, o)}
if cache.create_callback then if cache.create_callback then
cache.create_callback(cache.primary, o, i, objects) cache.create_callback(cache.primary, o, i, objects)

View File

@ -8,7 +8,6 @@ local capi = {awesome = awesome}
local setmetatable = setmetatable local setmetatable = setmetatable
local textbox = require("wibox.widget.textbox") local textbox = require("wibox.widget.textbox")
local button = require("awful.button") local button = require("awful.button")
local gtable = require("gears.table")
local widget_base = require("wibox.widget.base") local widget_base = require("wibox.widget.base")
local gdebug = require("gears.debug") local gdebug = require("gears.debug")
@ -295,9 +294,9 @@ function keyboardlayout.new()
function () update_status(self) end); function () update_status(self) end);
-- Mouse bindings -- Mouse bindings
self:buttons( self.buttons = {
gtable.join(button({ }, 1, self.next_layout)) button({ }, 1, self.next_layout)
) }
return self return self
end end

View File

@ -5,7 +5,6 @@
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
local setmetatable = setmetatable local setmetatable = setmetatable
local gtable = require("gears.table")
local spawn = require("awful.spawn") local spawn = require("awful.spawn")
local wbutton = require("awful.widget.button") local wbutton = require("awful.widget.button")
local button = require("awful.button") local button = require("awful.button")
@ -22,14 +21,12 @@ function launcher.new(args)
local w = wbutton(args) local w = wbutton(args)
if not w then return end if not w then return end
local b
if args.command then if args.command then
b = gtable.join(w:buttons(), button({}, 1, nil, function () spawn(args.command) end)) w:add_button(button({}, 1, nil, function () spawn(args.command) end))
elseif args.menu then elseif args.menu then
b = gtable.join(w:buttons(), button({}, 1, nil, function () args.menu:toggle() end)) w:add_button(button({}, 1, nil, function () args.menu:toggle() end))
end end
w:buttons(b)
return w return w
end end

View File

@ -31,7 +31,6 @@ local screen = require("awful.screen")
local button = require("awful.button") local button = require("awful.button")
local beautiful = require("beautiful") local beautiful = require("beautiful")
local surface = require("gears.surface") local surface = require("gears.surface")
local gtable = require("gears.table")
local wibox = require("wibox") local wibox = require("wibox")
local gfs = require("gears.filesystem") local gfs = require("gears.filesystem")
local timer = require("gears.timer") local timer = require("gears.timer")
@ -446,14 +445,11 @@ function naughty.default_notification_handler(notification, args)
local action_height = h + 2 * margin local action_height = h + 2 * margin
local action_width = w + 2 * margin local action_width = w + 2 * margin
actionmarginbox:buttons(gtable.join( actionmarginbox.buttons = {
button({ }, 1, function() button({ }, 1, function() action:invoke(notification) end),
action:invoke(notification) button({ }, 3, function() action:invoke(notification) end),
end), }
button({ }, 3, function()
action:invoke(notification)
end)
))
actionslayout:add(actionmarginbox) actionslayout:add(actionmarginbox)
actions_total_height = actions_total_height + action_height actions_total_height = actions_total_height + action_height
@ -584,10 +580,12 @@ function naughty.default_notification_handler(notification, args)
notification.box:set_widget(completelayout) notification.box:set_widget(completelayout)
-- Setup the mouse events -- Setup the mouse events
layout:buttons(gtable.join(button({}, 1, nil, run), layout.buttons = {
button({}, 1, nil, run),
button({}, 3, nil, function() button({}, 3, nil, function()
die(naughty.notification_closed_reason.dismissed_by_user) die(naughty.notification_closed_reason.dismissed_by_user)
end))) end),
}
-- insert the notification to the table -- insert the notification to the table
table.insert(current_notifications[s][notification.position], notification) table.insert(current_notifications[s][notification.position], notification)

View File

@ -7,7 +7,7 @@ local gtable = require("gears.table")
-- Create a titlebar and return a table with references to its member widgets. -- Create a titlebar and return a table with references to its member widgets.
local function create_titlebar(c) local function create_titlebar(c)
local parts = {} local parts = {}
local buttons = gtable.join( local buttons = {
awful.button({ }, 1, function() awful.button({ }, 1, function()
client.focus = c client.focus = c
c:raise() c:raise()
@ -18,18 +18,18 @@ local function create_titlebar(c)
c:raise() c:raise()
awful.mouse.client.resize(c) awful.mouse.client.resize(c)
end) end)
) }
-- Widgets that are aligned to the left -- Widgets that are aligned to the left
parts.icon = awful.titlebar.widget.iconwidget(c) parts.icon = awful.titlebar.widget.iconwidget(c)
local left_layout = wibox.layout.fixed.horizontal(parts.icon) local left_layout = wibox.layout.fixed.horizontal(parts.icon)
left_layout:buttons(buttons) left_layout.buttons = buttons
-- The title goes in the middle -- The title goes in the middle
parts.title = awful.titlebar.widget.titlewidget(c) parts.title = awful.titlebar.widget.titlewidget(c)
parts.title:set_align("center") parts.title:set_align("center")
local middle_layout = wibox.layout.flex.horizontal(parts.title) local middle_layout = wibox.layout.flex.horizontal(parts.title)
middle_layout:buttons(buttons) middle_layout.buttons = buttons
parts.floating_button = awful.titlebar.widget.floatingbutton(c) parts.floating_button = awful.titlebar.widget.floatingbutton(c)
parts.maximized_button = awful.titlebar.widget.maximizedbutton(c) parts.maximized_button = awful.titlebar.widget.maximizedbutton(c)