quality: Port all legacy `:buttons()` to `.buttons`.
This commit is contained in:
parent
fa414a86a3
commit
2c08c2fa39
|
@ -458,10 +458,11 @@ function widget.new(args)
|
|||
height = height,
|
||||
})
|
||||
mywibox:set_widget(pages[1])
|
||||
mywibox:buttons(gtable.join(
|
||||
awful.button({ }, 1, function () widget_obj:hide() end),
|
||||
awful.button({ }, 3, function () widget_obj:hide() end)
|
||||
))
|
||||
|
||||
mywibox.buttons = {
|
||||
awful.button({ }, 1, function () widget_obj:hide() end),
|
||||
awful.button({ }, 3, function () widget_obj:hide() end)
|
||||
}
|
||||
|
||||
function widget_obj.page_next(_self)
|
||||
if _self.current_page == #pages then return end
|
||||
|
|
|
@ -446,13 +446,14 @@ function menu:add(args, index)
|
|||
|
||||
|
||||
-- Create bindings
|
||||
item._background:buttons(gtable.join(
|
||||
item._background.buttons = {
|
||||
button({}, 3, function () self:hide() end),
|
||||
button({}, 1, function ()
|
||||
local num = gtable.hasitem(self.items, item)
|
||||
self:item_enter(num, { mouse = true })
|
||||
self:exec(num, { exec = true, mouse = true })
|
||||
end )))
|
||||
end)
|
||||
}
|
||||
|
||||
|
||||
item._mouse = function ()
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
---------------------------------------------------------------------------
|
||||
-- A simple button widget.
|
||||
-- @usage local button = awful.widget.button()
|
||||
-- button:buttons(gears.table.join(
|
||||
-- button:buttons(),
|
||||
-- awful.button({}, 1, nil, function ()
|
||||
-- print("Mouse was clicked")
|
||||
-- end)
|
||||
-- ))
|
||||
--
|
||||
-- button.buttons = {
|
||||
-- awful.button({}, 1, nil, function ()
|
||||
-- print("Mouse was clicked")
|
||||
-- end)
|
||||
-- }
|
||||
--
|
||||
-- @author Julien Danjou <julien@danjou.info>
|
||||
-- @copyright 2008-2009 Julien Danjou
|
||||
-- @widgetmod awful.widget.button
|
||||
|
|
|
@ -254,7 +254,8 @@ function calendar_popup:attach(widget, position, args)
|
|||
position = position or "tr"
|
||||
args = args or {}
|
||||
if args.on_hover == nil then args.on_hover=true end
|
||||
widget:buttons(gears.table.join(
|
||||
|
||||
widget.buttons = {
|
||||
abutton({ }, 1, function ()
|
||||
if not self.visible or self._calendar_clicked_on then
|
||||
self:call_calendar(0, position)
|
||||
|
@ -264,7 +265,8 @@ function calendar_popup:attach(widget, position, args)
|
|||
end),
|
||||
abutton({ }, 4, function () self:call_calendar(-1) end),
|
||||
abutton({ }, 5, function () self:call_calendar( 1) end)
|
||||
))
|
||||
}
|
||||
|
||||
if args.on_hover then
|
||||
widget:connect_signal("mouse::enter", function ()
|
||||
if not self._calendar_clicked_on then
|
||||
|
@ -330,18 +332,19 @@ local function get_cal_wibox(caltype, args)
|
|||
}
|
||||
ret:set_widget(widget)
|
||||
|
||||
ret:buttons(gears.table.join(
|
||||
abutton({ }, 1, function ()
|
||||
ret.visible=false
|
||||
ret._calendar_clicked_on=false
|
||||
end),
|
||||
abutton({ }, 3, function ()
|
||||
ret.visible=false
|
||||
ret._calendar_clicked_on=false
|
||||
end),
|
||||
abutton({ }, 4, function () ret:call_calendar(-1) end),
|
||||
abutton({ }, 5, function () ret:call_calendar( 1) end)
|
||||
))
|
||||
ret.buttons = {
|
||||
abutton({ }, 1, function ()
|
||||
ret.visible=false
|
||||
ret._calendar_clicked_on=false
|
||||
end),
|
||||
abutton({ }, 3, function ()
|
||||
ret.visible=false
|
||||
ret._calendar_clicked_on=false
|
||||
end),
|
||||
abutton({ }, 4, function () ret:call_calendar(-1) end),
|
||||
abutton({ }, 5, function () ret:call_calendar( 1) end)
|
||||
}
|
||||
|
||||
return ret
|
||||
end
|
||||
|
||||
|
|
|
@ -129,7 +129,7 @@ function common.list_update(w, buttons, label, data, objects, args)
|
|||
cache = (args and args.widget_template) and
|
||||
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
|
||||
cache.create_callback(cache.primary, o, i, objects)
|
||||
|
|
|
@ -8,7 +8,6 @@ local capi = {awesome = awesome}
|
|||
local setmetatable = setmetatable
|
||||
local textbox = require("wibox.widget.textbox")
|
||||
local button = require("awful.button")
|
||||
local gtable = require("gears.table")
|
||||
local widget_base = require("wibox.widget.base")
|
||||
local gdebug = require("gears.debug")
|
||||
|
||||
|
@ -295,9 +294,9 @@ function keyboardlayout.new()
|
|||
function () update_status(self) end);
|
||||
|
||||
-- Mouse bindings
|
||||
self:buttons(
|
||||
gtable.join(button({ }, 1, self.next_layout))
|
||||
)
|
||||
self.buttons = {
|
||||
button({ }, 1, self.next_layout)
|
||||
}
|
||||
|
||||
return self
|
||||
end
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
---------------------------------------------------------------------------
|
||||
|
||||
local setmetatable = setmetatable
|
||||
local gtable = require("gears.table")
|
||||
local spawn = require("awful.spawn")
|
||||
local wbutton = require("awful.widget.button")
|
||||
local button = require("awful.button")
|
||||
|
@ -22,14 +21,12 @@ function launcher.new(args)
|
|||
local w = wbutton(args)
|
||||
if not w then return end
|
||||
|
||||
local b
|
||||
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
|
||||
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
|
||||
|
||||
w:buttons(b)
|
||||
return w
|
||||
end
|
||||
|
||||
|
|
|
@ -31,7 +31,6 @@ local screen = require("awful.screen")
|
|||
local button = require("awful.button")
|
||||
local beautiful = require("beautiful")
|
||||
local surface = require("gears.surface")
|
||||
local gtable = require("gears.table")
|
||||
local wibox = require("wibox")
|
||||
local gfs = require("gears.filesystem")
|
||||
local timer = require("gears.timer")
|
||||
|
@ -446,14 +445,11 @@ function naughty.default_notification_handler(notification, args)
|
|||
local action_height = h + 2 * margin
|
||||
local action_width = w + 2 * margin
|
||||
|
||||
actionmarginbox:buttons(gtable.join(
|
||||
button({ }, 1, function()
|
||||
action:invoke(notification)
|
||||
end),
|
||||
button({ }, 3, function()
|
||||
action:invoke(notification)
|
||||
end)
|
||||
))
|
||||
actionmarginbox.buttons = {
|
||||
button({ }, 1, function() action:invoke(notification) end),
|
||||
button({ }, 3, function() action:invoke(notification) end),
|
||||
}
|
||||
|
||||
actionslayout:add(actionmarginbox)
|
||||
|
||||
actions_total_height = actions_total_height + action_height
|
||||
|
@ -584,10 +580,12 @@ function naughty.default_notification_handler(notification, args)
|
|||
notification.box:set_widget(completelayout)
|
||||
|
||||
-- Setup the mouse events
|
||||
layout:buttons(gtable.join(button({}, 1, nil, run),
|
||||
button({}, 3, nil, function()
|
||||
die(naughty.notification_closed_reason.dismissed_by_user)
|
||||
end)))
|
||||
layout.buttons = {
|
||||
button({}, 1, nil, run),
|
||||
button({}, 3, nil, function()
|
||||
die(naughty.notification_closed_reason.dismissed_by_user)
|
||||
end),
|
||||
}
|
||||
|
||||
-- insert the notification to the table
|
||||
table.insert(current_notifications[s][notification.position], notification)
|
||||
|
|
|
@ -7,29 +7,29 @@ local gtable = require("gears.table")
|
|||
-- Create a titlebar and return a table with references to its member widgets.
|
||||
local function create_titlebar(c)
|
||||
local parts = {}
|
||||
local buttons = gtable.join(
|
||||
local buttons = {
|
||||
awful.button({ }, 1, function()
|
||||
client.focus = c
|
||||
c:raise()
|
||||
awful.mouse.client.move(c)
|
||||
end),
|
||||
awful.button({ }, 3, function()
|
||||
client.focus = c
|
||||
c:raise()
|
||||
awful.mouse.client.resize(c)
|
||||
end)
|
||||
)
|
||||
client.focus = c
|
||||
c:raise()
|
||||
awful.mouse.client.resize(c)
|
||||
end)
|
||||
}
|
||||
|
||||
-- Widgets that are aligned to the left
|
||||
parts.icon = awful.titlebar.widget.iconwidget(c)
|
||||
local left_layout = wibox.layout.fixed.horizontal(parts.icon)
|
||||
left_layout:buttons(buttons)
|
||||
left_layout.buttons = buttons
|
||||
|
||||
-- The title goes in the middle
|
||||
parts.title = awful.titlebar.widget.titlewidget(c)
|
||||
parts.title:set_align("center")
|
||||
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.maximized_button = awful.titlebar.widget.maximizedbutton(c)
|
||||
|
|
Loading…
Reference in New Issue