From 21978546ebaa53200540c624e6d277f36edf63eb Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Fri, 17 Apr 2009 18:08:52 +0200 Subject: [PATCH] lib: fix libs to use new awful.button Signed-off-by: Julien Danjou --- lib/awful/menu.lua.in | 8 ++++---- lib/awful/titlebar.lua.in | 24 +++++++++++------------- lib/awful/widget/button.lua.in | 6 +++--- lib/awful/widget/launcher.lua.in | 11 +++++------ lib/naughty.lua.in | 8 ++++---- 5 files changed, 27 insertions(+), 30 deletions(-) diff --git a/lib/awful/menu.lua.in b/lib/awful/menu.lua.in index 18c7e07a4..63dad2615 100644 --- a/lib/awful/menu.lua.in +++ b/lib/awful/menu.lua.in @@ -12,7 +12,7 @@ local type = type local wibox = wibox local image = image local widget = widget -local button = button +local button = require("awful.button") local capi = { screen = screen, @@ -176,10 +176,10 @@ local function add_item(data, num, item_info) }) -- Create bindings - local bindings = { + local bindings = util.table.join( button({}, 1, function () item_enter(data, num); exec(data, num) end), button({}, 3, function () hide(data) end) - } + ) -- Create the item label widget local label = widget({ type = "textbox", align = "left" }) @@ -370,4 +370,4 @@ function new(menu, parent, num) data.toggle = toggle return data -end \ No newline at end of file +end diff --git a/lib/awful/titlebar.lua.in b/lib/awful/titlebar.lua.in index bf6e4ac30..cdc8feb28 100644 --- a/lib/awful/titlebar.lua.in +++ b/lib/awful/titlebar.lua.in @@ -13,9 +13,9 @@ local capi = { wibox = wibox, widget = widget, - button = button, client = client, } +local button = require("awful.button") local beautiful = require("beautiful") local hooks = require("awful.hooks") local util = require("awful.util") @@ -63,12 +63,11 @@ function add(c, args) end -- Redirect relevant events to the client the titlebar belongs to - local bts = - { - capi.button({ }, 1, function (t) capi.client.focus = t.client t.client:raise() mouse.client.move(t.client) end), - capi.button({ args.modkey }, 1, function (t) mouse.client.move(t.client) end), - capi.button({ args.modkey }, 3, function (t) mouse.client.resize(t.client) end) - } + local bts = util.tablejoin( + button({ }, 1, function (t) capi.client.focus = t.client t.client:raise() mouse.client.move(t.client) end), + button({ args.modkey }, 1, function (t) mouse.client.move(t.client) end), + button({ args.modkey }, 3, function (t) mouse.client.resize(t.client) end) + ) title:buttons(bts) local appicon = capi.widget({ type = "imagebox", align = "left" }) @@ -146,12 +145,11 @@ end -- @param theme The theme from beautifull. Used to get the image paths -- @param state The state the button is associated to. Containse path the action and info about the image local function button_new(c, name, modkey, theme, state) - local bts = - { - capi.button({ }, 1, nil, state.action), - capi.button({ modkey }, 1, function (t) mouse.client.move(t.client) end), - capi.button({ modkey }, 3, function (t) mouse.client.resize(t.client) end) - } + local bts = util.table.join( + button({ }, 1, nil, state.action), + button({ modkey }, 1, function (t) mouse.client.move(t.client) end), + button({ modkey }, 3, function (t) mouse.client.resize(t.client) end) + ) -- get the image path from the theme. Only return a button if we find an image local img diff --git a/lib/awful/widget/button.lua.in b/lib/awful/widget/button.lua.in index 2e5bd3457..df5f9c767 100644 --- a/lib/awful/widget/button.lua.in +++ b/lib/awful/widget/button.lua.in @@ -6,10 +6,10 @@ local setmetatable = setmetatable local type = type +local button = require("awful.button") local capi = { image = image, widget = widget, - mouse = mouse, - button = button } + mouse = mouse } module("awful.widget.button") @@ -32,7 +32,7 @@ function new(_, args) args.type = "imagebox" local w = capi.widget(args) w.image = img_release - w:buttons({ capi.button({}, 1, function () w.image = img_press end, function () w.image = img_release end) }) + w:buttons(button({}, 1, function () w.image = img_press end, function () w.image = img_release end)) function w.mouse_leave(s) w.image = img_release end function w.mouse_enter(s) if capi.mouse.coords().buttons[1] then w.image = img_press end end return w diff --git a/lib/awful/widget/launcher.lua.in b/lib/awful/widget/launcher.lua.in index 1ad63c931..8ac628c9f 100644 --- a/lib/awful/widget/launcher.lua.in +++ b/lib/awful/widget/launcher.lua.in @@ -5,9 +5,9 @@ --------------------------------------------------------------------------- local setmetatable = setmetatable -local capi = { button = button } local util = require("awful.util") -local button = require("awful.widget.button") +local wbutton = require("awful.widget.button") +local button = require("awful.button") module("awful.widget.launcher") @@ -17,14 +17,13 @@ module("awful.widget.launcher") -- @return A launcher widget. local function new(_, args) if not args.command and not args.menu then return end - local w = button(args) + local w = wbutton(args) if not w then return end - local b = w:buttons() if args.command then - b[#b + 1] = capi.button({}, 1, nil, function () util.spawn(args.command) end) + b = util.table.join(w:buttons(), button({}, 1, nil, function () util.spawn(args.command) end)) elseif args.menu then - b[#b + 1] = capi.button({}, 1, nil, function () args.menu:toggle() end) + b = util.table.join(w:buttons(), button({}, 1, nil, function () args.menu:toggle() end)) end w:buttons(b) diff --git a/lib/naughty.lua.in b/lib/naughty.lua.in index d763ed04f..e17b68a24 100644 --- a/lib/naughty.lua.in +++ b/lib/naughty.lua.in @@ -14,7 +14,8 @@ local tostring = tostring local hooks = require("awful.hooks") local string = string local widget = widget -local button = button +local button = require("awful.button") +local util = require("awful.util") local capi = { screen = screen } local bt = require("beautiful") local screen = screen @@ -328,8 +329,7 @@ function notify(args) -- create textbox local textbox = widget({ type = "textbox", align = "flex" }) - textbox:buttons({ button({ }, 1, run), - button({ }, 3, die) }) + textbox:buttons(util.table.join(button({ }, 1, run), button({ }, 3, die))) textbox:margin({ right = config.margin, left = config.margin }) textbox.text = string.format('%s%s', font, title, text) if hover_timeout then textbox.mouse_enter = hover_destroy end @@ -345,7 +345,7 @@ function notify(args) -- if we have an icon, use it if icon then iconbox = widget({ type = "imagebox", align = "left" }) - iconbox:buttons({ button({ }, 1, run), button({ }, 3, die) }) + iconbox:buttons(util.join(button({ }, 1, run), button({ }, 3, die))) local img if type(icon) == "string" then img = image(icon)