Ported awful.widget to lua 5.2
Tested with lua 5.1: all good Signed-off-by: Arvydas Sidorenko <asido4@gmail.com> Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
997de2726c
commit
c3ebfd99fc
|
@ -71,7 +71,7 @@ layouts =
|
|||
|
||||
-- {{{ Tags
|
||||
-- Define a tag table which hold all screen tags.
|
||||
tags = {}
|
||||
local tags = {}
|
||||
for s = 1, screen.count() do
|
||||
-- Each screen has its own tag table.
|
||||
tags[s] = awful.tag({ 1, 2, 3, 4, 5, 6, 7, 8, 9 }, s, layouts[1])
|
||||
|
@ -283,7 +283,7 @@ clientkeys = awful.util.table.join(
|
|||
-- Compute the maximum number of digit we need, limited to 9
|
||||
keynumber = 0
|
||||
for s = 1, screen.count() do
|
||||
keynumber = math.min(9, math.max(#tags[s], keynumber));
|
||||
keynumber = math.min(9, math.max(#tags[s], keynumber))
|
||||
end
|
||||
|
||||
-- Bind all key numbers to tags.
|
||||
|
|
|
@ -12,13 +12,14 @@ local surface = require("gears.surface")
|
|||
local cairo = require("lgi").cairo
|
||||
local capi = { mouse = mouse }
|
||||
|
||||
module("awful.widget.button")
|
||||
-- awful.widget.button
|
||||
local button = { mt = {} }
|
||||
|
||||
--- Create a button widget. When clicked, the image is deplaced to make it like
|
||||
-- a real button.
|
||||
-- @param args Widget arguments. "image" is the image to display.
|
||||
-- @return A textbox widget configured as a button.
|
||||
function new(args)
|
||||
function button.new(args)
|
||||
if not args or not args.image then return end
|
||||
local img_release = surface.load(args.image)
|
||||
local img_press = cairo.ImageSurface(cairo.Format.ARGB32, img_release.width, img_release.height)
|
||||
|
@ -32,6 +33,10 @@ function new(args)
|
|||
return w
|
||||
end
|
||||
|
||||
setmetatable(_M, { __call = function(_, ...) return new(...) end })
|
||||
function button.mt:__call(...)
|
||||
return button.new(...)
|
||||
end
|
||||
|
||||
return setmetatable(button, button.mt)
|
||||
|
||||
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
||||
|
|
|
@ -13,7 +13,8 @@ local color = require("gears.color")
|
|||
local base = require("wibox.widget.base")
|
||||
|
||||
--- A graph widget.
|
||||
module("awful.widget.graph")
|
||||
-- awful.widget.graph
|
||||
local graph = { mt = {} }
|
||||
|
||||
local data = setmetatable({}, { __mode = "k" })
|
||||
|
||||
|
@ -66,27 +67,27 @@ local properties = { "width", "height", "border_color", "stack",
|
|||
"stack_colors", "color", "background_color",
|
||||
"max_value", "scale" }
|
||||
|
||||
function draw(graph, wibox, cr, width, height)
|
||||
local max_value = data[graph].max_value
|
||||
local values = data[graph].values
|
||||
function graph.draw(_graph, wibox, cr, width, height)
|
||||
local max_value = data[_graph].max_value
|
||||
local values = data[_graph].values
|
||||
|
||||
cr:set_line_width(1)
|
||||
|
||||
-- Draw the background first
|
||||
cr:set_source(color(data[graph].background_color or "#000000aa"))
|
||||
cr:set_source(color(data[_graph].background_color or "#000000aa"))
|
||||
cr:paint()
|
||||
|
||||
-- Account for the border width
|
||||
cr:save()
|
||||
if data[graph].border_color then
|
||||
if data[_graph].border_color then
|
||||
cr:translate(1, 1)
|
||||
width, height = width - 2, height - 2
|
||||
end
|
||||
|
||||
-- Draw a stacked graph
|
||||
if data[graph].stack then
|
||||
if data[_graph].stack then
|
||||
|
||||
if data[graph].scale then
|
||||
if data[_graph].scale then
|
||||
for _, v in ipairs(values) do
|
||||
for __, sv in ipairs(v) do
|
||||
if sv > max_value then
|
||||
|
@ -100,8 +101,8 @@ function draw(graph, wibox, cr, width, height)
|
|||
local rel_i = 0
|
||||
local rel_x = i + 0.5
|
||||
|
||||
if data[graph].stack_colors then
|
||||
for idx, col in ipairs(data[graph].stack_colors) do
|
||||
if data[_graph].stack_colors then
|
||||
for idx, col in ipairs(data[_graph].stack_colors) do
|
||||
local stack_values = values[idx]
|
||||
if stack_values and i < #stack_values then
|
||||
local value = stack_values[#stack_values - i] + rel_i
|
||||
|
@ -115,7 +116,7 @@ function draw(graph, wibox, cr, width, height)
|
|||
end
|
||||
end
|
||||
else
|
||||
if data[graph].scale then
|
||||
if data[_graph].scale then
|
||||
for _, v in ipairs(values) do
|
||||
if v > max_value then
|
||||
max_value = v
|
||||
|
@ -134,7 +135,7 @@ function draw(graph, wibox, cr, width, height)
|
|||
cr:line_to(i + 0.5, height)
|
||||
end
|
||||
end
|
||||
cr:set_source(color(data[graph].color or "#ff0000"))
|
||||
cr:set_source(color(data[_graph].color or "#ff0000"))
|
||||
cr:stroke()
|
||||
end
|
||||
|
||||
|
@ -144,88 +145,88 @@ function draw(graph, wibox, cr, width, height)
|
|||
cr:restore()
|
||||
|
||||
-- Draw the border last so that it overlaps already drawn values
|
||||
if data[graph].border_color then
|
||||
if data[_graph].border_color then
|
||||
-- We decremented these by two above
|
||||
width, height = width + 2, height + 2
|
||||
|
||||
-- Draw the border
|
||||
cr:rectangle(0.5, 0.5, width - 1, height - 1)
|
||||
cr:set_source(color(data[graph].border_color or "#ffffff"))
|
||||
cr:set_source(color(data[_graph].border_color or "#ffffff"))
|
||||
cr:stroke()
|
||||
end
|
||||
end
|
||||
|
||||
function fit(graph, width, height)
|
||||
return data[graph].width, data[graph].height
|
||||
function graph.fit(_graph, width, height)
|
||||
return data[_graph].width, data[_graph].height
|
||||
end
|
||||
|
||||
--- Add a value to the graph
|
||||
-- @param graph The graph.
|
||||
-- @param value The value between 0 and 1.
|
||||
-- @param group The stack color group index.
|
||||
local function add_value(graph, value, group)
|
||||
if not graph then return end
|
||||
local function add_value(_graph, value, group)
|
||||
if not _graph then return end
|
||||
|
||||
local value = value or 0
|
||||
local values = data[graph].values
|
||||
local max_value = data[graph].max_value
|
||||
local values = data[_graph].values
|
||||
local max_value = data[_graph].max_value
|
||||
value = math.max(0, value)
|
||||
if not data[graph].scale then
|
||||
if not data[_graph].scale then
|
||||
value = math.min(max_value, value)
|
||||
end
|
||||
|
||||
if data[graph].stack and group then
|
||||
if not data[graph].values[group]
|
||||
or type(data[graph].values[group]) ~= "table"
|
||||
if data[_graph].stack and group then
|
||||
if not data[_graph].values[group]
|
||||
or type(data[_graph].values[group]) ~= "table"
|
||||
then
|
||||
data[graph].values[group] = {}
|
||||
data[_graph].values[group] = {}
|
||||
end
|
||||
values = data[graph].values[group]
|
||||
values = data[_graph].values[group]
|
||||
end
|
||||
table.insert(values, value)
|
||||
|
||||
local border_width = 0
|
||||
if data[graph].border_color then border_width = 2 end
|
||||
if data[_graph].border_color then border_width = 2 end
|
||||
|
||||
-- Ensure we never have more data than we can draw
|
||||
while #values > data[graph].width - border_width do
|
||||
while #values > data[_graph].width - border_width do
|
||||
table.remove(values, 1)
|
||||
end
|
||||
|
||||
graph:emit_signal("widget::updated")
|
||||
return graph
|
||||
_graph:emit_signal("widget::updated")
|
||||
return _graph
|
||||
end
|
||||
|
||||
|
||||
--- Set the graph height.
|
||||
-- @param graph The graph.
|
||||
-- @param height The height to set.
|
||||
function set_height(graph, height)
|
||||
function graph.set_height(_graph, height)
|
||||
if height >= 5 then
|
||||
data[graph].height = height
|
||||
graph:emit_signal("widget::updated")
|
||||
data[_graph].height = height
|
||||
_graph:emit_signal("widget::updated")
|
||||
end
|
||||
return graph
|
||||
return _graph
|
||||
end
|
||||
|
||||
--- Set the graph width.
|
||||
-- @param graph The graph.
|
||||
-- @param width The width to set.
|
||||
function set_width(graph, width)
|
||||
function graph.set_width(_graph, width)
|
||||
if width >= 5 then
|
||||
data[graph].width = width
|
||||
graph:emit_signal("widget::updated")
|
||||
data[_graph].width = width
|
||||
_graph:emit_signal("widget::updated")
|
||||
end
|
||||
return graph
|
||||
return _graph
|
||||
end
|
||||
|
||||
-- Build properties function
|
||||
for _, prop in ipairs(properties) do
|
||||
if not _M["set_" .. prop] then
|
||||
_M["set_" .. prop] = function(graph, value)
|
||||
data[graph][prop] = value
|
||||
graph:emit_signal("widget::updated")
|
||||
return graph
|
||||
if not graph["set_" .. prop] then
|
||||
graph["set_" .. prop] = function(_graph, value)
|
||||
data[_graph][prop] = value
|
||||
_graph:emit_signal("widget::updated")
|
||||
return _graph
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -234,7 +235,7 @@ end
|
|||
-- @param args Standard widget() arguments. You should add width and height
|
||||
-- key to set graph geometry.
|
||||
-- @return A graph widget.
|
||||
function new(args)
|
||||
function graph.new(args)
|
||||
local args = args or {}
|
||||
|
||||
local width = args.width or 100
|
||||
|
@ -242,22 +243,26 @@ function new(args)
|
|||
|
||||
if width < 5 or height < 5 then return end
|
||||
|
||||
local graph = base.make_widget()
|
||||
local _graph = base.make_widget()
|
||||
|
||||
data[graph] = { width = width, height = height, values = {}, max_value = 1 }
|
||||
data[_graph] = { width = width, height = height, values = {}, max_value = 1 }
|
||||
|
||||
-- Set methods
|
||||
graph.add_value = add_value
|
||||
graph.draw = draw
|
||||
graph.fit = fit
|
||||
_graph.add_value = add_value
|
||||
_graph.draw = graph.draw
|
||||
_graph.fit = graph.fit
|
||||
|
||||
for _, prop in ipairs(properties) do
|
||||
graph["set_" .. prop] = _M["set_" .. prop]
|
||||
_graph["set_" .. prop] = _M["set_" .. prop]
|
||||
end
|
||||
|
||||
return graph
|
||||
return _graph
|
||||
end
|
||||
|
||||
setmetatable(_M, { __call = function(_, ...) return new(...) end })
|
||||
function graph.mt:__call(...)
|
||||
return graph.new(...)
|
||||
end
|
||||
|
||||
return setmetatable(graph, graph.mt)
|
||||
|
||||
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
||||
|
|
|
@ -4,17 +4,20 @@
|
|||
-- @release @AWESOME_VERSION@
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
require("awful.widget.taglist")
|
||||
require("awful.widget.tasklist")
|
||||
require("awful.widget.button")
|
||||
require("awful.widget.launcher")
|
||||
require("awful.widget.prompt")
|
||||
require("awful.widget.progressbar")
|
||||
require("awful.widget.graph")
|
||||
require("awful.widget.layoutbox")
|
||||
require("awful.widget.textclock")
|
||||
|
||||
--- Widget module for awful
|
||||
module("awful.widget")
|
||||
-- awful.widget
|
||||
|
||||
return
|
||||
{
|
||||
taglist = require("awful.widget.taglist");
|
||||
tasklist = require("awful.widget.tasklist");
|
||||
button = require("awful.widget.button");
|
||||
launcher = require("awful.widget.launcher");
|
||||
prompt = require("awful.widget.prompt");
|
||||
progressbar = require("awful.widget.progressbar");
|
||||
graph = require("awful.widget.graph");
|
||||
layoutbox = require("awful.widget.layoutbox");
|
||||
textclock = require("awful.widget.textclock");
|
||||
}
|
||||
|
||||
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
||||
|
|
|
@ -9,13 +9,14 @@ local util = require("awful.util")
|
|||
local wbutton = require("awful.widget.button")
|
||||
local button = require("awful.button")
|
||||
|
||||
module("awful.widget.launcher")
|
||||
-- awful.widget.launcher
|
||||
local launcher = { mt = {} }
|
||||
|
||||
--- Create a button widget which will launch a command.
|
||||
-- @param args Standard widget table arguments, plus image for the image path
|
||||
-- and command for the command to run on click, or either menu to create menu.
|
||||
-- @return A launcher widget.
|
||||
function new(args)
|
||||
function launcher.new(args)
|
||||
if not args.command and not args.menu then return end
|
||||
local w = wbutton(args)
|
||||
if not w then return end
|
||||
|
@ -31,6 +32,10 @@ function new(args)
|
|||
return w
|
||||
end
|
||||
|
||||
setmetatable(_M, { __call = function (_, ...) return new(...) end })
|
||||
function launcher.mt:__call(...)
|
||||
return launcher.new(...)
|
||||
end
|
||||
|
||||
return setmetatable(launcher, launcher.mt)
|
||||
|
||||
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
||||
|
|
|
@ -13,7 +13,8 @@ local beautiful = require("beautiful")
|
|||
local imagebox = require("wibox.widget.imagebox")
|
||||
|
||||
--- Layoutbox widget.
|
||||
module("awful.widget.layoutbox")
|
||||
-- awful.widget.layoutbox
|
||||
local layoutbox = { mt = {} }
|
||||
|
||||
local function update(w, screen)
|
||||
local layout = layout.getname(layout.get(screen))
|
||||
|
@ -24,7 +25,7 @@ end
|
|||
-- symbol of the current tag.
|
||||
-- @param screen The screen number that the layout will be represented for.
|
||||
-- @return An imagebox widget configured as a layoutbox.
|
||||
function new(screen)
|
||||
function layoutbox.new(screen)
|
||||
local screen = screen or 1
|
||||
local w = imagebox()
|
||||
update(w, screen)
|
||||
|
@ -39,6 +40,10 @@ function new(screen)
|
|||
return w
|
||||
end
|
||||
|
||||
setmetatable(_M, { __call = function(_, ...) return new(...) end })
|
||||
function layoutbox.mt:__call(...)
|
||||
return layoutbox.new(...)
|
||||
end
|
||||
|
||||
return setmetatable(layoutbox, layoutbox.mt)
|
||||
|
||||
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
||||
|
|
|
@ -11,7 +11,8 @@ local base = require("wibox.widget.base")
|
|||
local color = require("gears.color")
|
||||
|
||||
--- A progressbar widget.
|
||||
module("awful.widget.progressbar")
|
||||
-- awful.widget.progressbar
|
||||
local progressbar = { mt = {} }
|
||||
|
||||
local data = setmetatable({}, { __mode = "k" })
|
||||
|
||||
|
@ -69,7 +70,7 @@ local properties = { "width", "height", "border_color",
|
|||
"vertical", "value", "max_value",
|
||||
"ticks", "ticks_gap", "ticks_size" }
|
||||
|
||||
function draw(pbar, wibox, cr, width, height)
|
||||
function progressbar.draw(pbar, wibox, cr, width, height)
|
||||
local ticks_gap = data[pbar].ticks_gap or 1
|
||||
local ticks_size = data[pbar].ticks_size or 4
|
||||
|
||||
|
@ -152,14 +153,14 @@ function draw(pbar, wibox, cr, width, height)
|
|||
end
|
||||
end
|
||||
|
||||
function fit(pbar, width, height)
|
||||
function progressbar.fit(pbar, width, height)
|
||||
return data[pbar].width, data[pbar].height
|
||||
end
|
||||
|
||||
--- Set the progressbar value.
|
||||
-- @param pbar The progress bar.
|
||||
-- @param value The progress bar value between 0 and 1.
|
||||
function set_value(pbar, value)
|
||||
function progressbar.set_value(pbar, value)
|
||||
local value = value or 0
|
||||
local max_value = data[pbar].max_value
|
||||
data[pbar].value = math.min(max_value, math.max(0, value))
|
||||
|
@ -170,25 +171,25 @@ end
|
|||
--- Set the progressbar height.
|
||||
-- @param progressbar The progressbar.
|
||||
-- @param height The height to set.
|
||||
function set_height(progressbar, height)
|
||||
data[progressbar].height = height
|
||||
progressbar:emit_signal("widget::updated")
|
||||
return progressbar
|
||||
function progressbar.set_height(_progressbar, height)
|
||||
data[_progressbar].height = height
|
||||
_progressbar:emit_signal("widget::updated")
|
||||
return _progressbar
|
||||
end
|
||||
|
||||
--- Set the progressbar width.
|
||||
-- @param progressbar The progressbar.
|
||||
-- @param width The width to set.
|
||||
function set_width(progressbar, width)
|
||||
data[progressbar].width = width
|
||||
progressbar:emit_signal("widget::updated")
|
||||
return progressbar
|
||||
function progressbar.set_width(_progressbar, width)
|
||||
data[_progressbar].width = width
|
||||
_progressbar:emit_signal("widget::updated")
|
||||
return _progressbar
|
||||
end
|
||||
|
||||
-- Build properties function
|
||||
for _, prop in ipairs(properties) do
|
||||
if not _M["set_" .. prop] then
|
||||
_M["set_" .. prop] = function(pbar, value)
|
||||
if not progressbar["set_" .. prop] then
|
||||
progressbar["set_" .. prop] = function(pbar, value)
|
||||
data[pbar][prop] = value
|
||||
pbar:emit_signal("widget::updated")
|
||||
return pbar
|
||||
|
@ -200,7 +201,7 @@ end
|
|||
-- @param args Standard widget() arguments. You should add width and height
|
||||
-- key to set progressbar geometry.
|
||||
-- @return A progressbar widget.
|
||||
function new(args)
|
||||
function progressbar.new(args)
|
||||
local args = args or {}
|
||||
local width = args.width or 100
|
||||
local height = args.height or 20
|
||||
|
@ -213,15 +214,19 @@ function new(args)
|
|||
|
||||
-- Set methods
|
||||
for _, prop in ipairs(properties) do
|
||||
pbar["set_" .. prop] = _M["set_" .. prop]
|
||||
pbar["set_" .. prop] = progressbar["set_" .. prop]
|
||||
end
|
||||
|
||||
pbar.draw = draw
|
||||
pbar.fit = fit
|
||||
pbar.draw = progressbar.draw
|
||||
pbar.fit = progressbar.fit
|
||||
|
||||
return pbar
|
||||
end
|
||||
|
||||
setmetatable(_M, { __call = function(_, ...) return new(...) end })
|
||||
function progressbar.mt:__call(...)
|
||||
return progressbar.new(...)
|
||||
end
|
||||
|
||||
return setmetatable(progressbar, progressbar.mt)
|
||||
|
||||
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
||||
|
|
|
@ -13,7 +13,8 @@ local widget_base = require("wibox.widget.base")
|
|||
local textbox = require("wibox.widget.textbox")
|
||||
local type = type
|
||||
|
||||
module("awful.widget.prompt")
|
||||
-- awful.widget.prompt
|
||||
local widgetprompt = { mt = {} }
|
||||
|
||||
--- Run method for promptbox.
|
||||
-- @param promptbox The promptbox to run.
|
||||
|
@ -33,7 +34,7 @@ end
|
|||
--- Create a prompt widget which will launch a command.
|
||||
-- @param args Arguments table. "prompt" is the prompt to use.
|
||||
-- @return A launcher widget.
|
||||
function new(args)
|
||||
function widgetprompt.new(args)
|
||||
local args = args or {}
|
||||
local widget = textbox()
|
||||
local promptbox = widget_base.make_widget(widget)
|
||||
|
@ -45,6 +46,10 @@ function new(args)
|
|||
return promptbox
|
||||
end
|
||||
|
||||
setmetatable(_M, { __call = function (_, ...) return new(...) end })
|
||||
function widgetprompt.mt:__call(...)
|
||||
return widgetprompt.new(...)
|
||||
end
|
||||
|
||||
return setmetatable(widgetprompt, widgetprompt.mt)
|
||||
|
||||
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
||||
|
|
|
@ -21,11 +21,11 @@ local fixed = require("wibox.layout.fixed")
|
|||
local surface = require("gears.surface")
|
||||
|
||||
--- Taglist widget module for awful
|
||||
module("awful.widget.taglist")
|
||||
-- awful.widget.taglist
|
||||
local taglist = { mt = {} }
|
||||
taglist.filter = {}
|
||||
|
||||
filter = {}
|
||||
|
||||
function taglist_label(t, args)
|
||||
function taglist.taglist_label(t, args)
|
||||
if not args then args = {} end
|
||||
local theme = beautiful.get()
|
||||
local fg_focus = args.fg_focus or theme.taglist_fg_focus or theme.fg_focus
|
||||
|
@ -108,7 +108,7 @@ local function taglist_update(s, w, buttons, filter, data, style)
|
|||
end
|
||||
end
|
||||
|
||||
local function label(c) return taglist_label(c, style) end
|
||||
local function label(c) return taglist.taglist_label(c, style) end
|
||||
|
||||
common.list_update(w, buttons, label, data, tags)
|
||||
end
|
||||
|
@ -116,7 +116,7 @@ end
|
|||
--- Get the tag object the given widget appears on.
|
||||
-- @param widget The widget the look for.
|
||||
-- @return The tag object.
|
||||
function gettag(widget)
|
||||
function taglist.gettag(widget)
|
||||
return common.tagwidgets[widget]
|
||||
end
|
||||
|
||||
|
@ -133,7 +133,7 @@ end
|
|||
-- squares_unsel Optional: a user provided image for unselected squares.
|
||||
-- squares_resize Optional: true or false to resize squares.
|
||||
-- font The font.
|
||||
function new(screen, filter, buttons, style)
|
||||
function taglist.new(screen, filter, buttons, style)
|
||||
local w = fixed.horizontal()
|
||||
|
||||
local data = setmetatable({}, { __mode = 'k' })
|
||||
|
@ -172,7 +172,7 @@ end
|
|||
-- @param t The tag.
|
||||
-- @param screen The screen we are drawing on.
|
||||
-- @return true if t is not empty, else false
|
||||
function filter.noempty(t, args)
|
||||
function taglist.filter.noempty(t, args)
|
||||
return #t:clients() > 0 or t.selected
|
||||
end
|
||||
|
||||
|
@ -180,10 +180,14 @@ end
|
|||
-- @param t The tag.
|
||||
-- @param screen The screen we are drawing on.
|
||||
-- @return true
|
||||
function filter.all(t, args)
|
||||
function taglist.filter.all(t, args)
|
||||
return true
|
||||
end
|
||||
|
||||
setmetatable(_M, { __call = function(_, ...) return new(...) end })
|
||||
function taglist.mt:__call(...)
|
||||
return taglist.new(...)
|
||||
end
|
||||
|
||||
return setmetatable(taglist, taglist.mt)
|
||||
|
||||
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
||||
|
|
|
@ -18,10 +18,11 @@ local tag = require("awful.tag")
|
|||
local flex = require("wibox.layout.flex")
|
||||
|
||||
--- Tasklist widget module for awful
|
||||
module("awful.widget.tasklist")
|
||||
-- awful.widget.tasklist
|
||||
local tasklist = { mt = {} }
|
||||
|
||||
-- Public structures
|
||||
filter = {}
|
||||
tasklist.filter = {}
|
||||
|
||||
local function tasklist_label(c, args)
|
||||
if not args then args = {} end
|
||||
|
@ -110,7 +111,7 @@ end
|
|||
-- maximized_horizontal Symbol to use for clients that have been horizontally maximized.
|
||||
-- maximized_vertical Symbol to use for clients that have been vertically maximized.
|
||||
-- font The font.
|
||||
function new(screen, filter, buttons, style)
|
||||
function tasklist.new(screen, filter, buttons, style)
|
||||
local w = flex.horizontal()
|
||||
|
||||
local data = setmetatable({}, { __mode = 'k' })
|
||||
|
@ -144,7 +145,7 @@ end
|
|||
-- @param c The client.
|
||||
-- @param screen The screen we are drawing on.
|
||||
-- @return true
|
||||
function filter.allscreen(c, screen)
|
||||
function tasklist.filter.allscreen(c, screen)
|
||||
return true
|
||||
end
|
||||
|
||||
|
@ -152,7 +153,7 @@ end
|
|||
-- @param c The client.
|
||||
-- @param screen The screen we are drawing on.
|
||||
-- @return true if c is on screen, false otherwise
|
||||
function filter.alltags(c, screen)
|
||||
function tasklist.filter.alltags(c, screen)
|
||||
-- Only print client on the same screen as this widget
|
||||
return c.screen == screen
|
||||
end
|
||||
|
@ -161,7 +162,7 @@ end
|
|||
-- @param c The client.
|
||||
-- @param screen The screen we are drawing on.
|
||||
-- @return true if c is in a selected tag on screen, false otherwise
|
||||
function filter.currenttags(c, screen)
|
||||
function tasklist.filter.currenttags(c, screen)
|
||||
-- Only print client on the same screen as this widget
|
||||
if c.screen ~= screen then return false end
|
||||
-- Include sticky client too
|
||||
|
@ -184,7 +185,7 @@ end
|
|||
-- @param c The client.
|
||||
-- @param screen The screen we are drawing on.
|
||||
-- @return true if c is in a selected tag on screen and is minimized, false otherwise
|
||||
function filter.minimizedcurrenttags(c, screen)
|
||||
function tasklist.filter.minimizedcurrenttags(c, screen)
|
||||
-- Only print client on the same screen as this widget
|
||||
if c.screen ~= screen then return false end
|
||||
-- Include sticky client
|
||||
|
@ -210,11 +211,15 @@ end
|
|||
-- @param c The client.
|
||||
-- @param screen The screen we are drawing on.
|
||||
-- @return true if c is focused on screen, false otherwise
|
||||
function filter.focused(c, screen)
|
||||
function tasklist.filter.focused(c, screen)
|
||||
-- Only print client on the same screen as this widget
|
||||
return c.screen == screen and capi.client.focus == c
|
||||
end
|
||||
|
||||
setmetatable(_M, { __call = function(_, ...) return new(...) end })
|
||||
function tasklist.mt:__call(...)
|
||||
return tasklist.new(...)
|
||||
end
|
||||
|
||||
return setmetatable(tasklist, tasklist.mt)
|
||||
|
||||
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
||||
|
|
|
@ -10,13 +10,14 @@ local textbox = require("wibox.widget.textbox")
|
|||
local capi = { timer = timer }
|
||||
|
||||
--- Text clock widget.
|
||||
module("awful.widget.textclock")
|
||||
-- awful.widget.textclock
|
||||
local textclock = { mt = {} }
|
||||
|
||||
--- Create a textclock widget. It draws the time it is in a textbox.
|
||||
-- @param format The time format. Default is " %a %b %d, %H:%M ".
|
||||
-- @param timeout How often update the time. Default is 60.
|
||||
-- @return A textbox widget.
|
||||
function new(format, timeout)
|
||||
function textclock.new(format, timeout)
|
||||
local format = format or " %a %b %d, %H:%M "
|
||||
local timeout = timeout or 60
|
||||
|
||||
|
@ -28,6 +29,10 @@ function new(format, timeout)
|
|||
return w
|
||||
end
|
||||
|
||||
setmetatable(_M, { __call = function(_, ...) return new(...) end })
|
||||
function textclock.mt:__call(...)
|
||||
return textclock.new(...)
|
||||
end
|
||||
|
||||
return setmetatable(textclock, textclock.mt)
|
||||
|
||||
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
||||
|
|
Loading…
Reference in New Issue