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

View File

@ -6,17 +6,10 @@
---------------------------------------------------------------------------
-- Grab environment we need
local math = math
local type = type
local ipairs = ipairs
local pairs = pairs
local pcall = pcall
local setmetatable = setmetatable
local capi = { button = button }
local util = require("awful.util")
local wibox = require("wibox")
local imagebox = require("wibox.widget.imagebox")
local textbox = require("wibox.widget.textbox")
local dpi = require("beautiful").xresources.apply_dpi
--- Common utilities for awful widgets
@ -29,7 +22,7 @@ local common = {}
function common.create_buttons(buttons, object)
if buttons then
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
-- press and release events, and will propagate them the the
-- 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",
"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 values = data[_graph].values
@ -91,7 +91,7 @@ function graph.draw(_graph, context, cr, width, height)
if data[_graph].scale then
for _, v in ipairs(values) do
for __, sv in ipairs(v) do
for _, sv in ipairs(v) do
if sv > max_value then
max_value = sv
end
@ -169,7 +169,7 @@ end
local function add_value(_graph, value, group)
if not _graph then return end
local value = value or 0
value = value or 0
local values = data[_graph].values
local max_value = data[_graph].max_value
value = math.max(0, value)
@ -243,7 +243,7 @@ end
-- key to set graph geometry.
-- @return A graph widget.
function graph.new(args)
local args = args or {}
args = args or {}
local width = args.width or 100
local height = args.height or 20

View File

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

View File

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

View File

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

View File

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

View File

@ -11,7 +11,6 @@
local capi = { screen = screen,
awesome = awesome,
client = client }
local type = type
local setmetatable = setmetatable
local pairs = pairs
local ipairs = ipairs
@ -53,7 +52,8 @@ function taglist.taglist_label(t, args)
local fg_color = nil
local bg_image
local icon
local bg_resize = false
-- TODO: Re-implement bg_resize
local bg_resize = false -- luacheck: ignore
local is_selected = false
local cls = t:clients()
@ -117,7 +117,7 @@ end
local function taglist_update(s, w, buttons, filter, data, style, update_function)
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
table.insert(tags, t)
end
@ -211,25 +211,21 @@ end
--- Filtering function to include all nonempty tags on the screen.
-- @param t The tag.
-- @param args unused list of extra arguments.
-- @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
end
--- Filtering function to include selected tags on the screen.
-- @param t The tag.
-- @param args unused list of extra arguments.
-- @return true if t is not empty, else false
function taglist.filter.selected(t, args)
function taglist.filter.selected(t)
return t.selected
end
--- Filtering function to include all tags on the screen.
-- @param t The tag.
-- @param args unused list of extra arguments.
-- @return true
function taglist.filter.all(t, args)
function taglist.filter.all()
return true
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_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 bg = nil
local text = ""
local name = ""
local bg_image = nil
local bg
local bg_image
-- symbol to use to indicate certain client properties
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.
if not focused and capi.client.focus and capi.client.focus.skip_taskbar
and client.get_transient_for_matching(capi.client.focus,
function(c)
return not c.skip_taskbar
function(cl)
return not cl.skip_taskbar
end) == c then
focused = true
end
@ -120,7 +120,7 @@ end
local function tasklist_update(s, w, buttons, filter, data, style, update_function)
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
or c.type == "splash" or c.type == "dock" or c.type == "desktop")
and filter(c, s) then
@ -245,10 +245,8 @@ function tasklist.new(screen, filter, buttons, style, update_function, base_widg
end
--- Filtering function to include all clients.
-- @param c The client.
-- @param screen The screen we are drawing on.
-- @return true
function tasklist.filter.allscreen(c, screen)
function tasklist.filter.allscreen()
return true
end
@ -271,7 +269,7 @@ function tasklist.filter.currenttags(c, screen)
-- Include sticky client too
if c.sticky then return true end
local tags = tag.gettags(screen)
for k, t in ipairs(tags) do
for _, t in ipairs(tags) do
if t.selected then
local ctags = c:tags()
for _, v in ipairs(ctags) do
@ -296,7 +294,7 @@ function tasklist.filter.minimizedcurrenttags(c, screen)
-- Include sticky client
if c.sticky then return true end
local tags = tag.gettags(screen)
for k, t in ipairs(tags) do
for _, t in ipairs(tags) do
-- Select only minimized clients
if t.selected then
local ctags = c:tags()

View File

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