Fix luacheck warnings in lib/awful/widget/

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2016-02-07 15:12:22 +01:00
parent c455e1f90e
commit 99a4184224
10 changed files with 32 additions and 51 deletions

View File

@ -6,13 +6,11 @@
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
local setmetatable = setmetatable local setmetatable = setmetatable
local type = type
local abutton = require("awful.button") local abutton = require("awful.button")
local imagebox = require("wibox.widget.imagebox") local imagebox = require("wibox.widget.imagebox")
local widget = require("wibox.widget.base") local widget = require("wibox.widget.base")
local surface = require("gears.surface") local surface = require("gears.surface")
local cairo = require("lgi").cairo local cairo = require("lgi").cairo
local capi = { mouse = mouse }
local button = { mt = {} } local button = { mt = {} }
@ -31,13 +29,13 @@ function button.new(args)
local img_release local img_release
local img_press local img_press
w.set_image = function(w, image) function w:set_image(image)
img_release = surface.load(image) img_release = surface.load(image)
img_press = img_release:create_similar(cairo.Content.COLOR_ALPHA, img_release.width, img_release.height) img_press = img_release:create_similar(cairo.Content.COLOR_ALPHA, img_release.width, img_release.height)
local cr = cairo.Context(img_press) local cr = cairo.Context(img_press)
cr:set_source_surface(img_release, 2, 2) cr:set_source_surface(img_release, 2, 2)
cr:paint() cr:paint()
orig_set_image(w, img_release) orig_set_image(self, img_release)
end end
w:set_image(args.image) w:set_image(args.image)
w:buttons(abutton({}, 1, function () orig_set_image(w, img_press) end, function () orig_set_image(w, img_release) end)) w:buttons(abutton({}, 1, function () orig_set_image(w, img_press) end, function () orig_set_image(w, img_release) end))

View File

@ -6,17 +6,10 @@
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
-- Grab environment we need -- Grab environment we need
local math = math
local type = type local type = type
local ipairs = ipairs local ipairs = ipairs
local pairs = pairs
local pcall = pcall
local setmetatable = setmetatable
local capi = { button = button } local capi = { button = button }
local util = require("awful.util")
local wibox = require("wibox") local wibox = require("wibox")
local imagebox = require("wibox.widget.imagebox")
local textbox = require("wibox.widget.textbox")
local dpi = require("beautiful").xresources.apply_dpi local dpi = require("beautiful").xresources.apply_dpi
--- Common utilities for awful widgets --- Common utilities for awful widgets
@ -29,7 +22,7 @@ local common = {}
function common.create_buttons(buttons, object) function common.create_buttons(buttons, object)
if buttons then if buttons then
local btns = {} local btns = {}
for kb, b in ipairs(buttons) do for _, b in ipairs(buttons) do
-- Create a proxy button object: it will receive the real -- Create a proxy button object: it will receive the real
-- press and release events, and will propagate them the the -- press and release events, and will propagate them the the
-- button object the user provided, but with the object as -- button object the user provided, but with the object as

View File

@ -69,7 +69,7 @@ local properties = { "width", "height", "border_color", "stack",
"stack_colors", "color", "background_color", "stack_colors", "color", "background_color",
"max_value", "scale" } "max_value", "scale" }
function graph.draw(_graph, context, cr, width, height) function graph.draw(_graph, _, cr, width, height)
local max_value = data[_graph].max_value local max_value = data[_graph].max_value
local values = data[_graph].values local values = data[_graph].values
@ -91,7 +91,7 @@ function graph.draw(_graph, context, cr, width, height)
if data[_graph].scale then if data[_graph].scale then
for _, v in ipairs(values) do for _, v in ipairs(values) do
for __, sv in ipairs(v) do for _, sv in ipairs(v) do
if sv > max_value then if sv > max_value then
max_value = sv max_value = sv
end end
@ -169,7 +169,7 @@ end
local function add_value(_graph, value, group) local function add_value(_graph, value, group)
if not _graph then return end if not _graph then return end
local value = value or 0 value = value or 0
local values = data[_graph].values local values = data[_graph].values
local max_value = data[_graph].max_value local max_value = data[_graph].max_value
value = math.max(0, value) value = math.max(0, value)
@ -243,7 +243,7 @@ end
-- key to set graph geometry. -- key to set graph geometry.
-- @return A graph widget. -- @return A graph widget.
function graph.new(args) function graph.new(args)
local args = args or {} args = args or {}
local width = args.width or 100 local width = args.width or 100
local height = args.height or 20 local height = args.height or 20

View File

@ -7,7 +7,6 @@
local capi = {awesome = awesome} local capi = {awesome = awesome}
local setmetatable = setmetatable local setmetatable = setmetatable
local os = os
local textbox = require("wibox.widget.textbox") local textbox = require("wibox.widget.textbox")
local button = require("awful.button") local button = require("awful.button")
local util = require("awful.util") local util = require("awful.util")
@ -264,8 +263,7 @@ function keyboardlayout.new()
update_layout(self); update_layout(self);
self.next_layout = function() self.next_layout = function()
new_layout = (self._current + 1) % (#self._layout + 1) self.set_layout((self._current + 1) % (#self._layout + 1))
self.set_layout(new_layout)
end end
self.set_layout = function(group_number) self.set_layout = function(group_number)

View File

@ -8,8 +8,6 @@
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
local setmetatable = setmetatable local setmetatable = setmetatable
local ipairs = ipairs
local button = require("awful.button")
local layout = require("awful.layout") local layout = require("awful.layout")
local tooltip = require("awful.tooltip") local tooltip = require("awful.tooltip")
local tag = require("awful.tag") local tag = require("awful.tag")
@ -21,9 +19,9 @@ local layoutbox = { mt = {} }
local boxes = nil local boxes = nil
local function update(w, screen) local function update(w, screen)
local layout = layout.getname(layout.get(screen)) local name = layout.getname(layout.get(screen))
w._layoutbox_tooltip:set_text(layout or "[no name]") w._layoutbox_tooltip:set_text(name or "[no name]")
w:set_image(layout and beautiful["layout_" .. layout]) w:set_image(name and beautiful["layout_" .. name])
end end
local function update_from_tag(t) local function update_from_tag(t)
@ -39,7 +37,7 @@ end
-- @param screen The screen number that the layout will be represented for. -- @param screen The screen number that the layout will be represented for.
-- @return An imagebox widget configured as a layoutbox. -- @return An imagebox widget configured as a layoutbox.
function layoutbox.new(screen) function layoutbox.new(screen)
local screen = screen or 1 screen = screen or 1
-- Do we already have the update callbacks registered? -- Do we already have the update callbacks registered?
if boxes == nil then if boxes == nil then

View File

@ -71,7 +71,7 @@ local properties = { "width", "height", "border_color",
"vertical", "value", "max_value", "vertical", "value", "max_value",
"ticks", "ticks_gap", "ticks_size" } "ticks", "ticks_gap", "ticks_size" }
function progressbar.draw(pbar, context, cr, width, height) function progressbar.draw(pbar, _, cr, width, height)
local ticks_gap = data[pbar].ticks_gap or 1 local ticks_gap = data[pbar].ticks_gap or 1
local ticks_size = data[pbar].ticks_size or 4 local ticks_size = data[pbar].ticks_size or 4
@ -161,7 +161,7 @@ end
--- Set the progressbar value. --- Set the progressbar value.
-- @param value The progress bar value between 0 and 1. -- @param value The progress bar value between 0 and 1.
function progressbar:set_value(value) function progressbar:set_value(value)
local value = value or 0 value = value or 0
local max_value = data[self].max_value local max_value = data[self].max_value
data[self].value = math.min(max_value, math.max(0, value)) data[self].value = math.min(max_value, math.max(0, value))
self:emit_signal("widget::redraw_needed") self:emit_signal("widget::redraw_needed")
@ -200,7 +200,7 @@ end
-- key to set progressbar geometry. -- key to set progressbar geometry.
-- @return A progressbar widget. -- @return A progressbar widget.
function progressbar.new(args) function progressbar.new(args)
local args = args or {} args = args or {}
local width = args.width or 100 local width = args.width or 100
local height = args.height or 20 local height = args.height or 20

View File

@ -42,7 +42,7 @@ end
-- @param args Arguments table. "prompt" is the prompt to use. -- @param args Arguments table. "prompt" is the prompt to use.
-- @return A launcher widget. -- @return A launcher widget.
function widgetprompt.new(args) function widgetprompt.new(args)
local args = args or {} args = args or {}
local widget = textbox() local widget = textbox()
local promptbox = widget_base.make_widget(widget) local promptbox = widget_base.make_widget(widget)

View File

@ -11,7 +11,6 @@
local capi = { screen = screen, local capi = { screen = screen,
awesome = awesome, awesome = awesome,
client = client } client = client }
local type = type
local setmetatable = setmetatable local setmetatable = setmetatable
local pairs = pairs local pairs = pairs
local ipairs = ipairs local ipairs = ipairs
@ -53,7 +52,8 @@ function taglist.taglist_label(t, args)
local fg_color = nil local fg_color = nil
local bg_image local bg_image
local icon local icon
local bg_resize = false -- TODO: Re-implement bg_resize
local bg_resize = false -- luacheck: ignore
local is_selected = false local is_selected = false
local cls = t:clients() local cls = t:clients()
@ -117,7 +117,7 @@ end
local function taglist_update(s, w, buttons, filter, data, style, update_function) local function taglist_update(s, w, buttons, filter, data, style, update_function)
local tags = {} local tags = {}
for k, t in ipairs(tag.gettags(s)) do for _, t in ipairs(tag.gettags(s)) do
if not tag.getproperty(t, "hide") and filter(t) then if not tag.getproperty(t, "hide") and filter(t) then
table.insert(tags, t) table.insert(tags, t)
end end
@ -211,25 +211,21 @@ end
--- Filtering function to include all nonempty tags on the screen. --- Filtering function to include all nonempty tags on the screen.
-- @param t The tag. -- @param t The tag.
-- @param args unused list of extra arguments.
-- @return true if t is not empty, else false -- @return true if t is not empty, else false
function taglist.filter.noempty(t, args) function taglist.filter.noempty(t)
return #t:clients() > 0 or t.selected return #t:clients() > 0 or t.selected
end end
--- Filtering function to include selected tags on the screen. --- Filtering function to include selected tags on the screen.
-- @param t The tag. -- @param t The tag.
-- @param args unused list of extra arguments.
-- @return true if t is not empty, else false -- @return true if t is not empty, else false
function taglist.filter.selected(t, args) function taglist.filter.selected(t)
return t.selected return t.selected
end end
--- Filtering function to include all tags on the screen. --- Filtering function to include all tags on the screen.
-- @param t The tag.
-- @param args unused list of extra arguments.
-- @return true -- @return true
function taglist.filter.all(t, args) function taglist.filter.all()
return true return true
end end

View File

@ -48,10 +48,10 @@ local function tasklist_label(c, args, tb)
local font_focus = args.font_focus or theme.tasklist_font_focus or theme.font_focus or font or "" local font_focus = args.font_focus or theme.tasklist_font_focus or theme.font_focus or font or ""
local font_minimized = args.font_minimized or theme.tasklist_font_minimized or theme.font_minimized or font or "" local font_minimized = args.font_minimized or theme.tasklist_font_minimized or theme.font_minimized or font or ""
local font_urgent = args.font_urgent or theme.tasklist_font_urgent or theme.font_urgent or font or "" local font_urgent = args.font_urgent or theme.tasklist_font_urgent or theme.font_urgent or font or ""
local bg = nil
local text = "" local text = ""
local name = "" local name = ""
local bg_image = nil local bg
local bg_image
-- symbol to use to indicate certain client properties -- symbol to use to indicate certain client properties
local sticky = args.sticky or theme.tasklist_sticky or "" local sticky = args.sticky or theme.tasklist_sticky or ""
@ -89,8 +89,8 @@ local function tasklist_label(c, args, tb)
-- is considered to be focused, if the real client has skip_taskbar. -- is considered to be focused, if the real client has skip_taskbar.
if not focused and capi.client.focus and capi.client.focus.skip_taskbar if not focused and capi.client.focus and capi.client.focus.skip_taskbar
and client.get_transient_for_matching(capi.client.focus, and client.get_transient_for_matching(capi.client.focus,
function(c) function(cl)
return not c.skip_taskbar return not cl.skip_taskbar
end) == c then end) == c then
focused = true focused = true
end end
@ -120,7 +120,7 @@ end
local function tasklist_update(s, w, buttons, filter, data, style, update_function) local function tasklist_update(s, w, buttons, filter, data, style, update_function)
local clients = {} local clients = {}
for k, c in ipairs(capi.client.get()) do for _, c in ipairs(capi.client.get()) do
if not (c.skip_taskbar or c.hidden if not (c.skip_taskbar or c.hidden
or c.type == "splash" or c.type == "dock" or c.type == "desktop") or c.type == "splash" or c.type == "dock" or c.type == "desktop")
and filter(c, s) then and filter(c, s) then
@ -245,10 +245,8 @@ function tasklist.new(screen, filter, buttons, style, update_function, base_widg
end end
--- Filtering function to include all clients. --- Filtering function to include all clients.
-- @param c The client.
-- @param screen The screen we are drawing on.
-- @return true -- @return true
function tasklist.filter.allscreen(c, screen) function tasklist.filter.allscreen()
return true return true
end end
@ -271,7 +269,7 @@ function tasklist.filter.currenttags(c, screen)
-- Include sticky client too -- Include sticky client too
if c.sticky then return true end if c.sticky then return true end
local tags = tag.gettags(screen) local tags = tag.gettags(screen)
for k, t in ipairs(tags) do for _, t in ipairs(tags) do
if t.selected then if t.selected then
local ctags = c:tags() local ctags = c:tags()
for _, v in ipairs(ctags) do for _, v in ipairs(ctags) do
@ -296,7 +294,7 @@ function tasklist.filter.minimizedcurrenttags(c, screen)
-- Include sticky client -- Include sticky client
if c.sticky then return true end if c.sticky then return true end
local tags = tag.gettags(screen) local tags = tag.gettags(screen)
for k, t in ipairs(tags) do for _, t in ipairs(tags) do
-- Select only minimized clients -- Select only minimized clients
if t.selected then if t.selected then
local ctags = c:tags() local ctags = c:tags()

View File

@ -27,8 +27,8 @@ end
-- @param timeout How often update the time. Default is 60. -- @param timeout How often update the time. Default is 60.
-- @return A textbox widget. -- @return A textbox widget.
function textclock.new(format, timeout) function textclock.new(format, timeout)
local format = format or " %a %b %d, %H:%M " format = format or " %a %b %d, %H:%M "
local timeout = timeout or 60 timeout = timeout or 60
local w = textbox() local w = textbox()
local t local t