quality: Begin to fix luacheck warnings

This commit is contained in:
Emmanuel Lepage Vallee 2016-06-24 02:02:40 -04:00
parent 6244ed7c26
commit 2d0a957506
22 changed files with 160 additions and 233 deletions

View File

@ -34,7 +34,8 @@ local function setup_drawable(data)
--Getters --Getters
data.get_visible = function() return true end data.get_visible = function() return true end
data.get_margins = common.get_margins data.get_margins = common.get_margins
function data:get_widget()
function data.get_widget()
return internal.widget return internal.widget
end end
@ -48,7 +49,7 @@ local function setup_drawable(data)
end end
local function new(args) local function new(args)
local args = args or {} args = args or {}
args.border_width = args.border_width or 0 args.border_width = args.border_width or 0
args.internal = args.internal or {} args.internal = args.internal or {}
args.internal.setup_drawable = args.internal.setup_drawable or setup_drawable args.internal.setup_drawable = args.internal.setup_drawable or setup_drawable
@ -63,14 +64,12 @@ local function new(args)
end end
function module.flex(args) function module.flex(args)
local args = args or {} args = args or {}
args.internal = args.internal or {} args.internal = args.internal or {}
args.internal.layout_func = wibox.layout.flex.horizontal() args.internal.layout_func = wibox.layout.flex.horizontal()
local data = new(args) local data = new(args)
function data._internal.text_fit(self,width,height) return width,height end
return data,data._internal.margin return data,data._internal.margin
end end

View File

@ -1,13 +1,10 @@
local setmetatable = setmetatable local setmetatable = setmetatable
local pairs,ipairs = pairs, ipairs local pairs,ipairs = pairs, ipairs
local type,string = type,string
local print,unpack = print, unpack
local table = table local table = table
local beautiful = require( "beautiful" ) local beautiful = require( "beautiful" )
local util = require( "awful.util" ) local util = require( "awful.util" )
local aw_key = require( "awful.key" ) local aw_key = require( "awful.key" )
local object = require( "radical.object" ) local object = require( "radical.object" )
local vertical = require( "radical.layout.vertical" )
local theme = require( "radical.theme" ) local theme = require( "radical.theme" )
local item_mod = require( "radical.item" ) local item_mod = require( "radical.item" )
local common = require( "radical.common" ) local common = require( "radical.common" )
@ -121,16 +118,15 @@ end
------------------------------------KEYBOARD HANDLING----------------------------------- ------------------------------------KEYBOARD HANDLING-----------------------------------
local function activateKeyboard(data) local function activateKeyboard(data)
if not data then return end if not data then return end
if not data or grabKeyboard == true then return end
if (not (data._internal.private_data.enable_keyboard == false)) and data.visible == true then if (not (data._internal.private_data.enable_keyboard == false)) and data.visible == true then
capi.keygrabber.run(function(mod, key, event) capi.keygrabber.run(function(mod, key, event)
for k,v in pairs(data._internal.filter_hooks or {}) do --TODO modkeys for k,v in pairs(data._internal.filter_hooks or {}) do --TODO modkeys
if (k.key == "Mod4" or k.key == "Mod1") and (key == "End" or key == "Super_L" or key == "Alt_L") then if (k.key == "Mod4" or k.key == "Mod1") and (key == "End" or key == "Super_L" or key == "Alt_L") then
local found = false for _,v3 in ipairs(mod) do
for k3,v3 in ipairs(mod) do for _,v4 in ipairs({"Mod4","Mod1"})do
for k4,v4 in ipairs({"Mod4","Mod1"})do
if v3 == v4 and event == k.event then if v3 == v4 and event == k.event then
local retval,self = v(data,mod) local _,self = v(data,mod)
if self and type(self) == "table" then if self and type(self) == "table" then
data = self data = self
end end
@ -260,7 +256,7 @@ local function add_widget(data,widget,args)
end end
local function add_widgets(data,widgets) local function add_widgets(data,widgets)
for k,item in ipairs(widgets) do for _,item in ipairs(widgets) do
data:add_widget(item) data:add_widget(item)
end end
end end
@ -277,7 +273,7 @@ end
local function get_widget_fit_sum(data) local function get_widget_fit_sum(data)
local h,w = 0,0 local h,w = 0,0
-- TODO query this from the layout itself -- TODO query this from the layout itself
for k,v in ipairs(data._internal.widgets) do for _,v in ipairs(data._internal.widgets) do
local fw,fh = v.widget:get_preferred_size() local fw,fh = v.widget:get_preferred_size()
w,h = w + fw,h + fh w,h = w + fw,h + fh
end end
@ -286,7 +282,7 @@ end
local function get_widget_fit_height_sum(data) local function get_widget_fit_height_sum(data)
-- TODO query this from the layout itself -- TODO query this from the layout itself
local w,h = get_widget_fit_sum(data) local _,h = get_widget_fit_sum(data)
return h return h
end end
@ -308,7 +304,7 @@ end
---------------------------------MENU HANDLING---------------------------------- ---------------------------------MENU HANDLING----------------------------------
local function new(args) local function new(args)
local args = args or {} args = args or {}
local internal = args.internal or {} local internal = args.internal or {}
if not internal.items then internal.items = {} end if not internal.items then internal.items = {} end
if not internal.widgets then internal.widgets = {} end if not internal.widgets then internal.widgets = {} end
@ -398,7 +394,7 @@ local function new(args)
-- Getters -- Getters
data.get_is_menu = function(_) return true end data.get_is_menu = function(_) return true end
data.get_margin = function(_) return {left=0,bottom=0,right=0,left=0} end data.get_margin = function(_) return {top=0,bottom=0,right=0,left=0} end
data.get_items = function(_) return internal.items end data.get_items = function(_) return internal.items end
data.get_rowcount = function(_) return #internal.items end data.get_rowcount = function(_) return #internal.items end
data.get_visible_row_count = get_visible_row_count data.get_visible_row_count = get_visible_row_count
@ -437,7 +433,7 @@ local function new(args)
end end
end end
data.add_colors_group = function(data,section) data.add_colors_group = function(_,section)
theme.add_section(data,section,args) theme.add_section(data,section,args)
end end
@ -481,11 +477,9 @@ local function new(args)
end end
--Repaint when appearance properties change --Repaint when appearance properties change
for k,v in ipairs({"bg","fg","border_color","border_width","item_height","width","arrow_type"}) do for _,v in ipairs({"bg","fg","border_color","border_width","item_height","width","arrow_type"}) do
data:connect_signal(v.."::changed",function() data:connect_signal(v.."::changed",function()
if data.visible and data.style then if not (data.visible and data.style) then
-- data.style(data)
else
data.has_changed = true data.has_changed = true
end end
end) end)
@ -629,11 +623,6 @@ local function new(args)
end end
end end
if private_data.layout then
local f = private_data.layout.setup_key_hooks or common.setup_key_hooks
f(value, data)
end
data._internal.setup_drawable(data) data._internal.setup_drawable(data)
return data return data

View File

@ -5,7 +5,7 @@ local shape = require( "gears.shape" )
local placement = require( "awful.placement" ) local placement = require( "awful.placement" )
local function new(args) local function new(args)
local args = args or {} args = args or {}
args.internal = args.internal or {} args.internal = args.internal or {}
args.arrow_type = base.arrow_type.NONE args.arrow_type = base.arrow_type.NONE

View File

@ -156,10 +156,6 @@ function module.setup_item_move_events(data)
data._internal.suf_l:add(widget) data._internal.suf_l:add(widget)
end) end)
data._internal.text_fit = function(self, context, width, height)
return width,height
end
data:connect_signal("clear::menu",function(_,vis) data:connect_signal("clear::menu",function(_,vis)
l:reset() l:reset()
end) end)

View File

@ -58,7 +58,7 @@ local function setup_drawable(data)
end end
local function new(args) local function new(args)
local args = args or {} args = args or {}
args.internal = args.internal or {} args.internal = args.internal or {}
args.internal.setup_drawable = args.internal.setup_drawable or setup_drawable args.internal.setup_drawable = args.internal.setup_drawable or setup_drawable
args.internal.setup_item = args.internal.setup_item or common.setup_item args.internal.setup_item = args.internal.setup_item or common.setup_item

View File

@ -13,6 +13,7 @@ local shape = require( "gears.shape" )
local common = require( "radical.common" ) local common = require( "radical.common" )
local smart_wibox = require( "radical.smart_wibox" ) local smart_wibox = require( "radical.smart_wibox" )
local aplace = require( "awful.placement" ) local aplace = require( "awful.placement" )
local timer = require( "gears.timer" )
local default_radius = 10 local default_radius = 10
local rad = beautiful.dock_corner_radius or default_radius local rad = beautiful.dock_corner_radius or default_radius
@ -25,17 +26,14 @@ local max_size = {height={},width={}}
local function get_max_size(data,screen) local function get_max_size(data,screen)
local dir = "left" local dir = "left"
local w_or_h = ((dir == "left" or dir == "right") and "height" or "width") local w_or_h = ((dir == "left" or dir == "right") and "height" or "width")
local x_or_y = w_or_h == "height" and "y" or "x"
local res = max_size[w_or_h][screen] local res = max_size[w_or_h][screen]
if not res then if not res then
local full,wa = capi.screen[screen].geometry[w_or_h],capi.screen[screen].workarea
local top,bottom = wa[x_or_y],full-(wa.y+wa[w_or_h])
local biggest = top > bottom and top or bottom
--res = full - biggest*2 - 52 -- 26px margins
local margin = beautiful.dock_margin or 52 local margin = beautiful.dock_margin or 52
res = wa[w_or_h] - margin res = capi.screen[screen].workarea[w_or_h] - margin
max_size[w_or_h][screen] = res max_size[w_or_h][screen] = res
end end
return res return res
end end
@ -125,7 +123,7 @@ local function setup_drawable(data)
end end
local function new(args) local function new(args)
local args = args or {} args = args or {}
local orientation = (not args.position or args.position == "left" or args.position == "right") and "vertical" or "horizontal" local orientation = (not args.position or args.position == "left" or args.position == "right") and "vertical" or "horizontal"
local length_inv = orientation == "vertical" and "width" or "height" local length_inv = orientation == "vertical" and "width" or "height"
@ -142,7 +140,7 @@ local function new(args)
args.internal = args.internal or {} args.internal = args.internal or {}
args.internal.layout_func = orientation == "vertical" and vertical or horizontal args.internal.layout_func = orientation == "vertical" and vertical or horizontal
args.layout = args.layout or args.internal.layout_func args.layout = args.layout or args.internal.layout_func
args.item_style = args.item_style or item.style args.item_style = args.item_style
args.item_layout = args.item_layout or item_layout args.item_layout = args.item_layout or item_layout
args[length_inv] = args[length_inv] or 40 args[length_inv] = args[length_inv] or 40

View File

@ -33,7 +33,7 @@ local function setup_drawable(data)
end end
local function new(args) local function new(args)
local args = args or {} args = args or {}
args.internal = args.internal or {} args.internal = args.internal or {}
args.internal.setup_drawable = args.internal.setup_drawable or setup_drawable args.internal.setup_drawable = args.internal.setup_drawable or setup_drawable
args.internal.setup_item = args.internal.setup_item or common.setup_item args.internal.setup_item = args.internal.setup_item or common.setup_item

View File

@ -39,7 +39,7 @@ local function mouse_leave(w)
end end
local function create_hot_corner(corner, s) local function create_hot_corner(corner, s)
local s = s or 1 s = s or 1
local size = corners_geo[corner] ( local size = corners_geo[corner] (
capi.screen[s].geometry, capi.screen[s].geometry,

View File

@ -1,4 +1,4 @@
local setmetatable,type = setmetatable, type local setmetatable = setmetatable
local ipairs, pairs = ipairs, pairs local ipairs, pairs = ipairs, pairs
local button = require( "awful.button" ) local button = require( "awful.button" )
local beautiful = require( "beautiful" ) local beautiful = require( "beautiful" )
@ -149,7 +149,7 @@ local function new(args)
local pref_bg = wibox.container.background() local pref_bg = wibox.container.background()
local pref_l = wibox.layout.align.horizontal() local pref_l = wibox.layout.align.horizontal()
pref_bg.fit = function(s,c,w,h) pref_bg.fit = function(s,c,w,h)
local w2,h2 = wibox.container.background.fit(s,c,w,h) local w2 = wibox.container.background.fit(s,c,w,h)
return w2,currentMenu.item_height return w2,currentMenu.item_height
end end
pref_bg:set_bg(currentMenu.bg_alternate) pref_bg:set_bg(currentMenu.bg_alternate)
@ -223,7 +223,6 @@ local function new(args)
checkable = (not auto_release) and v.screen == scr, checkable = (not auto_release) and v.screen == scr,
checked = v.screen == scr and (not auto_release and is_in_tag(t,v)) or nil, checked = v.screen == scr and (not auto_release and is_in_tag(t,v)) or nil,
button1 = function(a,b,c,d,no_hide) button1 = function(a,b,c,d,no_hide)
local t = focusTag[v] or v:tags()[1]
if t and t.selected == false and not util.table.hasitem(v:tags(),capi.screen[v.screen].selected_tag) then if t and t.selected == false and not util.table.hasitem(v:tags(),capi.screen[v.screen].selected_tag) then
lock_history = true lock_history = true
tag.viewonly(t) tag.viewonly(t)

View File

@ -7,7 +7,6 @@ local capi = { client = client, mouse = mouse, screen = screen}
local module = {} local module = {}
local function is_checked(m,i) local function is_checked(m,i)
local t = i._tag
return true return true
end end
@ -23,9 +22,9 @@ local function toggle_tag(i,m)
end end
local function new(args) local function new(args)
local args = args or {} args = args or {}
local t,auto_release = tag.selected(capi.client.focus and capi.client.focus.screen or capi.mouse.screen),args.auto_release local auto_release = args.auto_release
local currentMenu = radical.box({filter = true, show_filter=not auto_release, autodiscard = true, local currentMenu = radical.box({filter = true, show_filter=not auto_release, autodiscard = true,
disable_markup=true,fkeys_prefix=not auto_release,width=(((capi.screen[capi.client.focus and capi.client.focus.screen or capi.mouse.screen]).geometry.width)/2), disable_markup=true,fkeys_prefix=not auto_release,width=(((capi.screen[capi.client.focus and capi.client.focus.screen or capi.mouse.screen]).geometry.width)/2),
icon_transformation = beautiful.alttab_icon_transformation,filter_underlay="Use [Shift] and [Control] to toggle clients",filter_underlay_color=beautiful.menu_bg_normal, icon_transformation = beautiful.alttab_icon_transformation,filter_underlay="Use [Shift] and [Control] to toggle clients",filter_underlay_color=beautiful.menu_bg_normal,
@ -50,4 +49,4 @@ local function new(args)
end end
return setmetatable(module, { __call = function(_, ...) return new(...) end }) return setmetatable(module, { __call = function(_, ...) return new(...) end })
-- kate: space-indent on; indent-width 2; replace-tabs on; -- kate: space-indent on; indent-width 2; replace-tabs on;

View File

@ -1,61 +1,51 @@
local radical = require("radical") local radical = require("radical")
local capi = { screen = screen, } local type = type
local type,math = type,math
local awful = require( "awful" )
local cairo = require( "lgi" ).cairo local cairo = require( "lgi" ).cairo
local surface = require("gears.surface") local surface = require("gears.surface")
local shape = require("gears.shape") local shape = require("gears.shape")
local util = require("awful.util") local util = require("awful.util")
local module = {} local module = {}
local function createTagList(aScreen)
local tagList = radical.context {}
for _, v in ipairs(capi.screen[aScreen].tags) do
tagList:add_item({text = v.name,icon=v.icon})
end
return tagList
end
local sigMenu = nil local sigMenu = nil
function module.signals() function module.signals()
if sigMenu then if sigMenu then
return sigMenu return sigMenu
end end
sigMenu = radical.context{max_items=10} sigMenu = radical.context{max_items=10}
sigterm = sigMenu:add_item({text="SIGTERM" , button1 = function() util.spawn("kill -s TERM "..module.client.pid);mainMenu.visible = false end,infoshapes = {{text="15"}}}) sigMenu:add_item({text="SIGTERM" , button1 = function() util.spawn("kill -s TERM "..module.client.pid);sigMenu.visible = false end,infoshapes = {{text="15"}}})
sigkill = sigMenu:add_item({text="SIGKILL" , button1 = function() util.spawn("kill -s KILL "..module.client.pid);mainMenu.visible = false end,infoshapes = {{text="9"}}}) sigMenu:add_item({text="SIGKILL" , button1 = function() util.spawn("kill -s KILL "..module.client.pid);sigMenu.visible = false end,infoshapes = {{text="9"}}})
sigint = sigMenu:add_item({text="SIGINT" , button1 = function() util.spawn("kill -s INT "..module.client.pid);mainMenu.visible = false end,infoshapes = {{text="2"}}}) sigMenu:add_item({text="SIGINT" , button1 = function() util.spawn("kill -s INT "..module.client.pid);sigMenu.visible = false end,infoshapes = {{text="2"}}})
sigquit = sigMenu:add_item({text="SIGQUIT" , button1 = function() util.spawn("kill -s QUIT "..module.client.pid);mainMenu.visible = false end,infoshapes = {{text="3"}}}) sigMenu:add_item({text="SIGQUIT" , button1 = function() util.spawn("kill -s QUIT "..module.client.pid);sigMenu.visible = false end,infoshapes = {{text="3"}}})
-- sigMenu:add_widget(radical.widgets.separator()) -- sigMenu:add_widget(radical.widgets.separator())
sig0 = sigMenu:add_item({text="SIG0" , button1 = function() util.spawn("kill -s 0 "..module.client.pid);mainMenu.visible = false end,infoshapes = { }}) sigMenu:add_item({text="SIG0" , button1 = function() util.spawn("kill -s 0 "..module.client.pid);sigMenu.visible = false end,infoshapes = { }})
sigalrm = sigMenu:add_item({text="SIGALRM" , button1 = function() util.spawn("kill -s ALRM "..module.client.pid);mainMenu.visible = false end,infoshapes = {{text="14"}}}) sigMenu:add_item({text="SIGALRM" , button1 = function() util.spawn("kill -s ALRM "..module.client.pid);sigMenu.visible = false end,infoshapes = {{text="14"}}})
sighup = sigMenu:add_item({text="SIGHUP" , button1 = function() util.spawn("kill -s HUP "..module.client.pid);mainMenu.visible = false end,infoshapes = {{text="1"}},tooltip="sdfsdfsdf"}) sigMenu:add_item({text="SIGHUP" , button1 = function() util.spawn("kill -s HUP "..module.client.pid);sigMenu.visible = false end,infoshapes = {{text="1"}},tooltip="sdfsdfsdf"})
sigpipe = sigMenu:add_item({text="SIGPIPE" , button1 = function() util.spawn("kill -s PIPE "..module.client.pid);mainMenu.visible = false end,infoshapes = {{text="13"}}}) sigMenu:add_item({text="SIGPIPE" , button1 = function() util.spawn("kill -s PIPE "..module.client.pid);sigMenu.visible = false end,infoshapes = {{text="13"}}})
sigpoll = sigMenu:add_item({text="SIGPOLL" , button1 = function() util.spawn("kill -s POLL "..module.client.pid);mainMenu.visible = false end,infoshapes = {}}) sigMenu:add_item({text="SIGPOLL" , button1 = function() util.spawn("kill -s POLL "..module.client.pid);sigMenu.visible = false end,infoshapes = {}})
sigprof = sigMenu:add_item({text="SIGPROF" , button1 = function() util.spawn("kill -s PROF "..module.client.pid);mainMenu.visible = false end,infoshapes = {{text="27"}}}) sigMenu:add_item({text="SIGPROF" , button1 = function() util.spawn("kill -s PROF "..module.client.pid);sigMenu.visible = false end,infoshapes = {{text="27"}}})
sigusr1 = sigMenu:add_item({text="SIGUSR1" , button1 = function() util.spawn("kill -s USR1 "..module.client.pid);mainMenu.visible = false end,infoshapes = {{text="10"}}}) sigMenu:add_item({text="SIGUSR1" , button1 = function() util.spawn("kill -s USR1 "..module.client.pid);sigMenu.visible = false end,infoshapes = {{text="10"}}})
sigusr2 = sigMenu:add_item({text="SIGUSR2" , button1 = function() util.spawn("kill -s USR2 "..module.client.pid);mainMenu.visible = false end,infoshapes = {{text="12"}}}) sigMenu:add_item({text="SIGUSR2" , button1 = function() util.spawn("kill -s USR2 "..module.client.pid);sigMenu.visible = false end,infoshapes = {{text="12"}}})
sigsigvtalrm = sigMenu:add_item({text="SIGVTALRM" , button1 = function() util.spawn("kill -s VTALRM "..module.client.pid);mainMenu.visible = false end,infoshapes = {}}) sigMenu:add_item({text="SIGVTALRM" , button1 = function() util.spawn("kill -s VTALRM "..module.client.pid);sigMenu.visible = false end,infoshapes = {}})
sigstkflt = sigMenu:add_item({text="SIGSTKFLT" , button1 = function() util.spawn("kill -s STKFLT "..module.client.pid);mainMenu.visible = false end,infoshapes = {}}) sigMenu:add_item({text="SIGSTKFLT" , button1 = function() util.spawn("kill -s STKFLT "..module.client.pid);sigMenu.visible = false end,infoshapes = {}})
sigpwr = sigMenu:add_item({text="SIGPWR" , button1 = function() util.spawn("kill -s PWR "..module.client.pid);mainMenu.visible = false end,infoshapes = {}}) sigMenu:add_item({text="SIGPWR" , button1 = function() util.spawn("kill -s PWR "..module.client.pid);sigMenu.visible = false end,infoshapes = {}})
sigwinch = sigMenu:add_item({text="SIGWINCH" , button1 = function() util.spawn("kill -s WINCH "..module.client.pid);mainMenu.visible = false end,infoshapes = {}}) sigMenu:add_item({text="SIGWINCH" , button1 = function() util.spawn("kill -s WINCH "..module.client.pid);sigMenu.visible = false end,infoshapes = {}})
sigchld = sigMenu:add_item({text="SIGCHLD" , button1 = function() util.spawn("kill -s CHLD "..module.client.pid);mainMenu.visible = false end,infoshapes = {{text="17"}}}) sigMenu:add_item({text="SIGCHLD" , button1 = function() util.spawn("kill -s CHLD "..module.client.pid);sigMenu.visible = false end,infoshapes = {{text="17"}}})
sigurg = sigMenu:add_item({text="SIGURG" , button1 = function() util.spawn("kill -s URG "..module.client.pid);mainMenu.visible = false end,infoshapes = {}}) sigMenu:add_item({text="SIGURG" , button1 = function() util.spawn("kill -s URG "..module.client.pid);sigMenu.visible = false end,infoshapes = {}})
sigtstp = sigMenu:add_item({text="SIGTSTP" , button1 = function() util.spawn("kill -s TSTP "..module.client.pid);mainMenu.visible = false end,infoshapes = {}}) sigMenu:add_item({text="SIGTSTP" , button1 = function() util.spawn("kill -s TSTP "..module.client.pid);sigMenu.visible = false end,infoshapes = {}})
sigttin = sigMenu:add_item({text="SIGTTIN" , button1 = function() util.spawn("kill -s TTIN "..module.client.pid);mainMenu.visible = false end,infoshapes = {{text="21"}}}) sigMenu:add_item({text="SIGTTIN" , button1 = function() util.spawn("kill -s TTIN "..module.client.pid);sigMenu.visible = false end,infoshapes = {{text="21"}}})
sigttou = sigMenu:add_item({text="SIGTTOU" , button1 = function() util.spawn("kill -s TTOU "..module.client.pid);mainMenu.visible = false end,infoshapes = {{text="22"}}}) sigMenu:add_item({text="SIGTTOU" , button1 = function() util.spawn("kill -s TTOU "..module.client.pid);sigMenu.visible = false end,infoshapes = {{text="22"}}})
sigstop = sigMenu:add_item({text="SIGSTOP" , button1 = function() util.spawn("kill -s STOP "..module.client.pid);mainMenu.visible = false end,infoshapes = {{text="17"}}}) sigMenu:add_item({text="SIGSTOP" , button1 = function() util.spawn("kill -s STOP "..module.client.pid);sigMenu.visible = false end,infoshapes = {{text="17"}}})
sigcont = sigMenu:add_item({text="SIGCONT" , button1 = function() util.spawn("kill -s CONT "..module.client.pid);mainMenu.visible = false end,infoshapes = {{text="18"}}}) sigMenu:add_item({text="SIGCONT" , button1 = function() util.spawn("kill -s CONT "..module.client.pid);sigMenu.visible = false end,infoshapes = {{text="18"}}})
sigabrt = sigMenu:add_item({text="SIGABRT" , button1 = function() util.spawn("kill -s ABRT "..module.client.pid);mainMenu.visible = false end,infoshapes = {{text="6"}}}) sigMenu:add_item({text="SIGABRT" , button1 = function() util.spawn("kill -s ABRT "..module.client.pid);sigMenu.visible = false end,infoshapes = {{text="6"}}})
sigfpe = sigMenu:add_item({text="SIGFPE" , button1 = function() util.spawn("kill -s FPE "..module.client.pid);mainMenu.visible = false end,infoshapes = {{text="8"}}}) sigMenu:add_item({text="SIGFPE" , button1 = function() util.spawn("kill -s FPE "..module.client.pid);sigMenu.visible = false end,infoshapes = {{text="8"}}})
sigill = sigMenu:add_item({text="SIGILL" , button1 = function() util.spawn("kill -s ILL "..module.client.pid);mainMenu.visible = false end,infoshapes = {{text="4"}}}) sigMenu:add_item({text="SIGILL" , button1 = function() util.spawn("kill -s ILL "..module.client.pid);sigMenu.visible = false end,infoshapes = {{text="4"}}})
sigsegv = sigMenu:add_item({text="SIGSEGV" , button1 = function() util.spawn("kill -s SEGV "..module.client.pid);mainMenu.visible = false end,infoshapes = {{text="11"}}}) sigMenu:add_item({text="SIGSEGV" , button1 = function() util.spawn("kill -s SEGV "..module.client.pid);sigMenu.visible = false end,infoshapes = {{text="11"}}})
sigtrap = sigMenu:add_item({text="SIGTRAP" , button1 = function() util.spawn("kill -s TRAP "..module.client.pid);mainMenu.visible = false end,infoshapes = {{text="5"}}}) sigMenu:add_item({text="SIGTRAP" , button1 = function() util.spawn("kill -s TRAP "..module.client.pid);sigMenu.visible = false end,infoshapes = {{text="5"}}})
sigsys = sigMenu:add_item({text="SIGSYS" , button1 = function() util.spawn("kill -s SYS "..module.client.pid);mainMenu.visible = false end,infoshapes = {{text="12"}}}) sigMenu:add_item({text="SIGSYS" , button1 = function() util.spawn("kill -s SYS "..module.client.pid);sigMenu.visible = false end,infoshapes = {{text="12"}}})
sigemt = sigMenu:add_item({text="SIGEMT" , button1 = function() util.spawn("kill -s EMT "..module.client.pid);mainMenu.visible = false end,infoshapes = {}}) sigMenu:add_item({text="SIGEMT" , button1 = function() util.spawn("kill -s EMT "..module.client.pid);sigMenu.visible = false end,infoshapes = {}})
sigbus = sigMenu:add_item({text="SIGBUS" , button1 = function() util.spawn("kill -s BUS "..module.client.pid);mainMenu.visible = false end,infoshapes = {{text="7"}}}) sigMenu:add_item({text="SIGBUS" , button1 = function() util.spawn("kill -s BUS "..module.client.pid);sigMenu.visible = false end,infoshapes = {{text="7"}}})
sigxcpu = sigMenu:add_item({text="SIGXCPU" , button1 = function() util.spawn("kill -s XCPU "..module.client.pid);mainMenu.visible = false end,infoshapes = {}}) sigMenu:add_item({text="SIGXCPU" , button1 = function() util.spawn("kill -s XCPU "..module.client.pid);sigMenu.visible = false end,infoshapes = {}})
sigxfsz = sigMenu:add_item({text="SIGXFSZ" , button1 = function() util.spawn("kill -s XFSZ "..module.client.pid);mainMenu.visible = false end,infoshapes = {}}) sigMenu:add_item({text="SIGXFSZ" , button1 = function() util.spawn("kill -s XFSZ "..module.client.pid);sigMenu.visible = false end,infoshapes = {}})
return sigMenu return sigMenu
end end

View File

@ -2,8 +2,6 @@ local radical = require("radical")
local capi = { screen = screen, client=client} local capi = { screen = screen, client=client}
local awful = require( "awful" ) local awful = require( "awful" )
local beautiful = require("beautiful") local beautiful = require("beautiful")
local suits = require("awful.layout.suit")
local wibox = require("wibox")
local tag_list = nil local tag_list = nil
local module = {} local module = {}
@ -32,7 +30,7 @@ local function createTagList(aScreen,args)
end end
function module.listTags(args, menu) function module.listTags(args, menu)
local args = args or {} args = args or {}
if capi.screen.count() == 1 or args.screen then if capi.screen.count() == 1 or args.screen then
return createTagList(args.screen or 1,args or {}) return createTagList(args.screen or 1,args or {})
else else
@ -48,7 +46,8 @@ function module.layouts(menu,layouts)
local cur = awful.layout.get(capi.client.focus and capi.client.focus.screen) local cur = awful.layout.get(capi.client.focus and capi.client.focus.screen)
local screenSelect = menu or radical.context {} local screenSelect = menu or radical.context {}
local layouts = layouts or awful.layout.layouts layouts = layouts or awful.layout.layouts
for i, layout_real in ipairs(layouts) do for i, layout_real in ipairs(layouts) do
local layout2 = awful.layout.getname(layout_real) local layout2 = awful.layout.getname(layout_real)
local is_current = cur and ((layout_real == cur) or (layout_real.name == cur.name)) local is_current = cur and ((layout_real == cur) or (layout_real.name == cur.name))
@ -68,8 +67,7 @@ end
-- Widget to replace the default awesome layoutbox -- Widget to replace the default awesome layoutbox
function module.layout_item(menu,args) function module.layout_item(menu,args)
local args = args or {} args = args or {}
local ib = wibox.widget.imagebox()
local screen = args.screen or 1 local screen = args.screen or 1
local sub_menu = nil local sub_menu = nil

View File

@ -1,14 +1,8 @@
-- This file provide extensions -- This file provide extensions
local capi = { screen = screen, client=client} local capi = { screen = screen, client=client}
local setmetatable = setmetatable
local ipairs,pairs = ipairs,pairs local ipairs,pairs = ipairs,pairs
local type = type
local radical = require( "radical" ) local radical = require( "radical" )
local beautiful = require( "beautiful" )
local awful = require( "awful" )
local util = require( "awful.util" )
local wibox = require( "wibox" )
local taglist = nil local taglist = nil
local module = {} local module = {}
@ -116,5 +110,5 @@ function module.add(name,f)
end end
end end
return setmetatable(module, { __call = function(_, ...) return new(...) end }) return module
-- kate: space-indent on; indent-width 2; replace-tabs on; -- kate: space-indent on; indent-width 2; replace-tabs on;

View File

@ -11,7 +11,6 @@ local radical = require( "radical" )
local tag = require( "awful.tag" ) local tag = require( "awful.tag" )
local beautiful = require( "beautiful" ) local beautiful = require( "beautiful" )
local color = require( "gears.color" ) local color = require( "gears.color" )
local client = require( "awful.client" )
local wibox = require( "wibox" ) local wibox = require( "wibox" )
local awful = require( "awful" ) local awful = require( "awful" )
local theme = require( "radical.theme") local theme = require( "radical.theme")
@ -39,10 +38,10 @@ local cache = setmetatable({}, { __mode = 'k' })
module.buttons = { [1] = function(t) t:view_only() end, module.buttons = { [1] = function(t) t:view_only() end,
[2] = awful.tag.viewtoggle, [2] = awful.tag.viewtoggle,
[3] = function(t,menu,item,button_id,mod,geo) [3] = function(t,menu,item,button_id,mod,geo)
local menu = tag_menu(t) local m = tag_menu(t)
menu.parent_geometry = geo m.parent_geometry = geo
menu.visible = true m.visible = true
menu._internal.w:move_by_parent(geo, "cursor") m._internal.w:move_by_parent(geo, "cursor")
end, end,
[4] = function(t) awful.tag.viewnext(t.screen) end, [4] = function(t) awful.tag.viewnext(t.screen) end,
[5] = function(t) awful.tag.viewprev(t.screen) end, [5] = function(t) awful.tag.viewprev(t.screen) end,
@ -111,7 +110,6 @@ local function create_item(t,s)
end) end)
end end
item.tw = tw item.tw = tw
if tag.getproperty(t,"clone_of") then if tag.getproperty(t,"clone_of") then
@ -119,7 +117,7 @@ local function create_item(t,s)
end end
-- menu:move(item,index) -- menu:move(item,index)
menu:connect_signal("button::press",function(menu,item,button_id,mod,geo) menu:connect_signal("button::press",function(_,_,button_id,mod,geo)
if module.buttons and module.buttons[button_id] then if module.buttons and module.buttons[button_id] then
if item.tag[1] then if item.tag[1] then
assert(type(item.tag[1]) == "tag") assert(type(item.tag[1]) == "tag")

View File

@ -1,11 +1,8 @@
local setmetatable = setmetatable local setmetatable = setmetatable
local io = io local io = io
local ipairs = ipairs
local tag = require( "awful.tag" )
local menu = require( "radical.context" ) local menu = require( "radical.context" )
local beautiful = require( "beautiful" ) local beautiful = require( "beautiful" )
local com_tag = require( "radical.impl.common.tag" ) local com_tag = require( "radical.impl.common.tag" )
local awful = require("awful")
local radical = require("radical") local radical = require("radical")
local extensions = require("radical.impl.taglist.extensions") local extensions = require("radical.impl.taglist.extensions")
local capi = { screen = screen } local capi = { screen = screen }
@ -38,24 +35,24 @@ local function gen_icon(col,height)
return img return img
end end
local function set_color(aTag,col) local function set_color(t,col)
local pat = col local pat = col
if beautiful.taglist_custom_color then if beautiful.taglist_custom_color then
pat = beautiful.taglist_custom_color(pat) pat = beautiful.taglist_custom_color(pat)
end end
local idx,name = tag_list.register_color(pat) local idx,name = tag_list.register_color(pat)
local item = tag_list.item(aTag) local item = tag_list.item(t)
item["bg_"..name] = pat item["bg_"..name] = pat
item.state[idx] = true item.state[idx] = true
end end
local function color_menu(aTag) local function color_menu(t)
if not tag_list then if not tag_list then
tag_list = require("radical.impl.taglist") tag_list = require("radical.impl.taglist")
end end
local m = radical.context {layout=radical.layout.grid,column=6} local m = radical.context {layout=radical.layout.grid,column=6}
m:add_item{icon=gen_icon("#ff0000",m.item_height-4), item_layout = radical.item.layout.icon, button1 = function() set_color(aTag,"#ff0000") end} m:add_item{icon=gen_icon("#ff0000",m.item_height-4), item_layout = radical.item.layout.icon, button1 = function() set_color(t,"#ff0000") end}
m:add_item{icon=gen_icon("#00ff00",m.item_height-4), item_layout = radical.item.layout.icon, button1 = function() set_color(aTag,"#00ff00") end} m:add_item{icon=gen_icon("#00ff00",m.item_height-4), item_layout = radical.item.layout.icon, button1 = function() set_color(t,"#00ff00") end}
m:add_item{icon=gen_icon("#0000ff",m.item_height-4), item_layout = radical.item.layout.icon} m:add_item{icon=gen_icon("#0000ff",m.item_height-4), item_layout = radical.item.layout.icon}
m:add_item{icon=gen_icon("#ff00ff",m.item_height-4), item_layout = radical.item.layout.icon} m:add_item{icon=gen_icon("#ff00ff",m.item_height-4), item_layout = radical.item.layout.icon}
m:add_item{icon=gen_icon("#ffff00",m.item_height-4), item_layout = radical.item.layout.icon} m:add_item{icon=gen_icon("#ffff00",m.item_height-4), item_layout = radical.item.layout.icon}
@ -86,35 +83,22 @@ local function new(t)
aTagMenu:add_item({text = "Rename", button1 = function() --[[shifty.rename(aTag)]] end}) aTagMenu:add_item({text = "Rename", button1 = function() --[[shifty.rename(aTag)]] end})
aTagMenu:add_item({text = "Close applications and remove", button1 = function() aTagMenu:add_item({text = "Close applications and remove", button1 = function()
for i=1, #aTag:clients() do for i=1, #aTag:clients() do
aTag:clients()[i]:kill() aTag:clients()[i]:kill()
end end
-- shifty.del(aTag) end})
end})
if capi.screen.count() > 1 then if capi.screen.count() > 1 then
local screenMenu = menu() local screenMenu = menu()
aTagMenu:add_item({text = "Screen",sub_menu = screenMenu}) aTagMenu:add_item({text = "Screen",sub_menu = screenMenu})
for i=1,capi.screen.count() do for i=1,capi.screen.count() do
screenMenu:add_item({text = "Screen "..i, checked = aTag.screen == i,button1 = function() tag_to_screen(aTag,i) end}) screenMenu:add_item({text = "Screen "..i, checked = aTag.screen == i,button1 = function() --[[tag_to_screen(aTag,i)]] end})
end end
end end
aTagMenu:add_item({text = "Set color", sub_menu = function() return color_menu(aTag) end}) aTagMenu:add_item({text = "Set color", sub_menu = function() return color_menu(aTag) end})
aTagMenu:add_item({text = "Merge With", sub_menu = function() return com_tag.listTags() end}) aTagMenu:add_item({text = "Merge With", sub_menu = function() return com_tag.listTags() end})
function createTagList(aScreen)
local tagList = menu()
local count = 0
for _, v in ipairs(capi.screen[aScreen].tags) do
tagList:add_item({text = v.name})
count = count + 1
end
return tagList
end
aTagMenu:add_item({text = "<b>Save settings</b>"}) aTagMenu:add_item({text = "<b>Save settings</b>"})
local mainMenu2 = menu{layout=radical.layout.grid,column=6,} local mainMenu2 = menu{layout=radical.layout.grid,column=6,}

View File

@ -1,16 +1,14 @@
-- This module try to track tags relative index -- This module try to track tags relative index
-- It will emit signals the widget can rely on -- It will emit signals the widget can rely on
local capi = {tag=tag,screen=screen} local capi = {tag=tag,screen=screen}
local tag = require( "awful.tag" )
local object = require( "radical.object" ) local object = require( "radical.object" )
local awful = require("awful")
local cache = {} local cache = {}
local init = false local init = false
local screen_cache = setmetatable({}, { __mode = 'k' })--TODO this suck local screen_cache = setmetatable({}, { __mode = 'k' })--TODO this suck
local function reload(t,s) local function reload(t,s)
local s = s or t.screen or screen_cache[t] s = s or t.screen or screen_cache[t]
local tracker = cache[s] local tracker = cache[s]
if not tracker then return end if not tracker then return end
@ -51,9 +49,8 @@ end]]--
local function new(s) local function new(s)
if cache[s] then return cache[s] end if cache[s] then return cache[s] end
local tracker,private_data = object({ local tracker = object({
private_data = { private_data = {
widget = widget,
selected = false, selected = false,
}, },
autogen_getmap = true, autogen_getmap = true,

View File

@ -1,11 +1,7 @@
local capi = { screen = screen, }
local setmetatable = setmetatable local setmetatable = setmetatable
local ipairs,pairs = ipairs,pairs
local type = type
local radical = require( "radical" ) local radical = require( "radical" )
local beautiful = require( "beautiful" ) local beautiful = require( "beautiful" )
local awful = require( "awful" ) local awful = require( "awful" )
local util = require( "awful.util" )
local wibox = require( "wibox" ) local wibox = require( "wibox" )
local listTags = require( "radical.impl.common.tag" ).listTags local listTags = require( "radical.impl.common.tag" ).listTags
local singalMenu = require( "radical.impl.common.client" ).signals local singalMenu = require( "radical.impl.common.client" ).signals
@ -60,7 +56,7 @@ local function new(screen, args)
return mainMenu return mainMenu
end end
mainMenu = radical.context() mainMenu = radical.context()
local itemVisible,itemVSticky,itemVFloating,itemMaximized,itemMoveToTag,itemSendSignal,itemRenice,itemNewTag,itemLayer,itemClose local itemVisible,itemVSticky,itemVFloating,itemMaximized
itemVisible = mainMenu:add_item{ itemVisible = mainMenu:add_item{
text = "Visible", text = "Visible",
@ -94,23 +90,23 @@ local function new(screen, args)
itemMaximized.checked = module.client.fullscreen itemMaximized.checked = module.client.fullscreen
end end
} }
itemMoveToTag = mainMenu:add_item{text="Move to tag" , sub_menu = function() return listTags() end,} mainMenu:add_item{text="Move to tag" , sub_menu = function() return listTags() end,}
itemSendSignal = mainMenu:add_item{text="Send Signal" , sub_menu = singalMenu() ,} mainMenu:add_item{text="Send Signal" , sub_menu = singalMenu() ,}
itemRenice = mainMenu:add_item{text="Renice" , checked = true , button1 = function() end,} mainMenu:add_item{text="Renice" , checked = true , button1 = function() end,}
itemNewTag = mainMenu:add_item{text="Move to a new Tag" , button1 = function() mainMenu:add_item{text="Move to a new Tag" , button1 = function()
local t = createNewTag() local t = createNewTag()
module.client:tags({t}) module.client:tags({t})
awful.tag.viewonly(t) awful.tag.viewonly(t)
mainMenu.visible = false mainMenu.visible = false
end} end}
itemLayer = mainMenu:add_item({text="Layer" , sub_menu=layerMenu(), button1 = function() end}) mainMenu:add_item({text="Layer" , sub_menu=layerMenu(), button1 = function() end})
mainMenu:add_item{text="Add widgets",sub_menu=function() return extensions.extensions_menu(module.client) end} mainMenu:add_item{text="Add widgets",sub_menu=function() return extensions.extensions_menu(module.client) end}
mainMenu:add_widget(radical.widgets.separator()) mainMenu:add_widget(radical.widgets.separator())
local ib = wibox.widget.imagebox() local ib = wibox.widget.imagebox()
ib:set_image(beautiful.titlebar_close_button_normal) ib:set_image(beautiful.titlebar_close_button_normal)
itemClose = mainMenu:add_item({text="Close",suffix_widget = ib, button1 = function() if module.client ~= nil then module.client:kill();mainMenu.visible=false end end}) mainMenu:add_item({text="Close",suffix_widget = ib, button1 = function() if module.client ~= nil then module.client:kill();mainMenu.visible=false end end})
return mainMenu return mainMenu
end end

View File

@ -1,14 +1,8 @@
-- This file provide extensions -- This file provide extensions
local capi = { screen = screen, client=client} local capi = { screen = screen, client=client}
local setmetatable = setmetatable
local ipairs,pairs = ipairs,pairs local ipairs,pairs = ipairs,pairs
local type = type
local radical = require( "radical" ) local radical = require( "radical" )
local beautiful = require( "beautiful" )
local awful = require( "awful" )
local util = require( "awful.util" )
local wibox = require( "wibox" )
local tasklist = nil local tasklist = nil
local module = {} local module = {}
@ -32,7 +26,7 @@ end
local per_m,per_glob,per_class,per_this = nil local per_m,per_glob,per_class,per_this = nil
local function persistence_menu(ext,position) local function persistence_menu(ext,position)
local position=position
if not tasklist then if not tasklist then
tasklist = require("radical.impl.tasklist") tasklist = require("radical.impl.tasklist")
end end
@ -139,5 +133,5 @@ function module.add(name,f)
end end
end end
return setmetatable(module, { __call = function(_, ...) return new(...) end }) return module
-- kate: space-indent on; indent-width 2; replace-tabs on; -- kate: space-indent on; indent-width 2; replace-tabs on;

View File

@ -7,7 +7,6 @@
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
local capi = {client = client,tag=tag,screen=screen} local capi = {client = client,tag=tag,screen=screen}
local rawset = rawset
local radical = require( "radical" ) local radical = require( "radical" )
local tag = require( "awful.tag" ) local tag = require( "awful.tag" )
local beautiful = require( "beautiful" ) local beautiful = require( "beautiful" )
@ -44,10 +43,10 @@ module.buttons = {
end, end,
[3] = function(c,menu,item,button_id,mod, geo) [3] = function(c,menu,item,button_id,mod, geo)
client_menu.client = c client_menu.client = c
local menu = client_menu() local m = client_menu()
-- menu.parent_geometry = geo -- menu.parent_geometry = geo
menu.visible = not menu.visible m.visible = not m.visible
menu._internal.w:move_by_parent(nil, "cursor") m._internal.w:move_by_parent(nil, "cursor")
end, end,
[4] = function(c,menu,item,button_id,mod, geo) [4] = function(c,menu,item,button_id,mod, geo)
client.focus.byidx(1) client.focus.byidx(1)
@ -60,10 +59,6 @@ module.buttons = {
} }
local function display_screenshot(c,geo,visible) local function display_screenshot(c,geo,visible)
if not visible and prev_menu then
prev_menu.visible = false
return
end
if not c then return end if not c then return end
local dgeo = geo.drawable.drawable:geometry() local dgeo = geo.drawable.drawable:geometry()
@ -85,7 +80,7 @@ local function sticky_callback(c)
sticky[c] = val and true or nil sticky[c] = val and true or nil
local menu = instances[capi.screen[c.screen]].menu local menu = instances[capi.screen[c.screen]].menu
local is_in_tag = false local is_in_tag = false
for _,t in ipairs(tag.selectedlist(k)) do for _,t in ipairs(tag.selectedlist(c.screen)) do
for k2,v2 in ipairs(c:tags()) do for k2,v2 in ipairs(c:tags()) do
if v2 == t then if v2 == t then
is_in_tag = true is_in_tag = true
@ -263,7 +258,6 @@ end
-- Reload the tag -- Reload the tag
local function tag_screen_changed(t) local function tag_screen_changed(t)
if not t.selected then return end if not t.selected then return end
local screen = t.screen
load_clients(t) load_clients(t)
end end
@ -340,7 +334,7 @@ local function new(screen)
load_clients(screen.selected_tag) load_clients(screen.selected_tag)
menu:connect_signal("button::press",function(menu,item,button_id,mod,geo) menu:connect_signal("button::press",function(_,item,button_id,mod,geo)
if module.buttons and module.buttons[button_id] then if module.buttons and module.buttons[button_id] then
module.buttons[button_id](item.client,menu,item,button_id,mod,geo) module.buttons[button_id](item.client,menu,item,button_id,mod,geo)
end end
@ -353,8 +347,8 @@ local function new(screen)
return menu,menu._internal.widget return menu,menu._internal.widget
end end
function module.item(client) function module.item(c)
return _cache[client] return _cache[c]
end end
-- Global callbacks -- Global callbacks

View File

@ -25,13 +25,14 @@ end
-- @tparam[opt=widget] The position mode (see `radical.placement`) -- @tparam[opt=widget] The position mode (see `radical.placement`)
local function set_menu(self,menu, event, button_id, mode) local function set_menu(self,menu, event, button_id, mode)
if not menu then return end if not menu then return end
local event = event or "button::pressed"
local button_id = button_id or 1 event = event or "button::pressed"
button_id = button_id or 1
mode = mode or "widget" mode = mode or "widget"
local function trigger(_, geo) local function trigger(_, geo)
local geo = geo or _ geo = geo or _
local m = menu local m = menu
if self._data and self._data.is_menu then if self._data and self._data.is_menu then
@ -55,7 +56,7 @@ local function set_menu(self,menu, event, button_id, mode)
end end
if event == "button::pressed" then if event == "button::pressed" then
local current,bt = self:buttons(),aw_button({},b,trigger) local current,bt = self:buttons(),aw_button({},button_id,trigger)
for k, v in pairs(bt) do for k, v in pairs(bt) do
current[type(k) == "number" and (#current+1) or k] = v current[type(k) == "number" and (#current+1) or k] = v
end end
@ -63,11 +64,11 @@ local function set_menu(self,menu, event, button_id, mode)
self:connect_signal(event, trigger) self:connect_signal(event, trigger)
end end
self._menu = menu self._menu = menu
return bt return button_id
end end
local function get_preferred_size(self, context, width, height) local function get_preferred_size(self, context, width, height)
local context = context or 1 context = context or 1
if type(context) == "number" then if type(context) == "number" then
context = {dpi=beautiful.xresources.get_dpi(context)} context = {dpi=beautiful.xresources.get_dpi(context)}

View File

@ -35,7 +35,7 @@ function module.setup_fkey(item,data)
item._internal.f_key = value item._internal.f_key = value
data:remove_key_hook("F"..value) data:remove_key_hook("F"..value)
data:add_key_hook({}, "F"..value , "press", function() data:add_key_hook({}, "F"..value , "press", function()
item.button1(data,menu) item.button1(data)
data.visible = false data.visible = false
end) end)
end end
@ -48,13 +48,13 @@ end
-- Proxy all events to the parent -- Proxy all events to the parent
function module.setup_event(data,item,widget) function module.setup_event(data,item,widget)
local widget = widget or item.widget widget = widget or item.widget
-- Setup data signals -- Setup data signals
widget:connect_signal("button::press",function(_,__,___,id,mod,geo) widget:connect_signal("button::press",function(_,__,___,id,mod,geo)
local mods_invert = {} local mods_invert = {}
for k,v in ipairs(mod) do for k,v in ipairs(mod) do
mods_invert[v] = i mods_invert[v] = k
end end
item.state[4] = true item.state[4] = true
@ -64,7 +64,7 @@ function module.setup_event(data,item,widget)
widget:connect_signal("button::release",function(wdg,__,___,id,mod,geo) widget:connect_signal("button::release",function(wdg,__,___,id,mod,geo)
local mods_invert = {} local mods_invert = {}
for k,v in ipairs(mod) do for k,v in ipairs(mod) do
mods_invert[v] = i mods_invert[v] = k
end end
item.state[4] = nil item.state[4] = nil
data:emit_signal("button::release",item,id,mods_invert,geo) data:emit_signal("button::release",item,id,mods_invert,geo)

View File

@ -1,7 +1,4 @@
local setmetatable = setmetatable local setmetatable = setmetatable
local print = print
local color = require( "gears.color" )
local cairo = require( "lgi" ).cairo
local wibox = require( "wibox" ) local wibox = require( "wibox" )
local util = require( "awful.util" ) local util = require( "awful.util" )
local button = require( "awful.button" ) local button = require( "awful.button" )
@ -9,7 +6,6 @@ local beautiful = require( "beautiful" )
local shape = require( "gears.shape" ) local shape = require( "gears.shape" )
local surface = require( "gears.surface" ) local surface = require( "gears.surface" )
local theme = require( "radical.theme" ) local theme = require( "radical.theme" )
local rad_item = require( "radical.item" )
local module = {} local module = {}
@ -32,54 +28,59 @@ local function init()
end end
function module.up() function module.up()
if not isinit then
init()
end
return arr_up return arr_up
end end
function module.down() function module.down()
if not isinit then
init()
end
return arr_down return arr_down
end end
local function new(data) local function new(data)
local scroll_w = {} if not isinit then
scroll_w.visible = false init()
for k,v in ipairs({"up","down"}) do
local ib = wibox.widget.imagebox()
ib:set_image(module[v]())
ib.fit = function(tb,context,width,height)
if scroll_w.visible == false then
return 0,0
end
return width,data.item_height
end end
ib.draw = function(self, context, cr, width, height)
if width > 0 and height > 0 then local scroll_w = {}
cr:set_source_surface(self._private.image, width/2 - self._private.image:get_width()/2, 0) scroll_w.visible = false
end for k,v in ipairs {"up","down"} do
cr:paint() local ib = wibox.widget.imagebox()
ib:set_image(module[v]())
ib.fit = function(tb,context,width,height) --TODO if the align container ever get upstream, use it
if scroll_w.visible == false then
return 0,0
end
return width,data.item_height
end
ib.draw = function(self, context, cr, width, height)
if width > 0 and height > 0 then
cr:set_source_surface(
self._private.image, width/2 - self._private.image:get_width()/2, 0
)
end
cr:paint()
end
scroll_w[v] = wibox.container.background()
scroll_w[v]:set_widget(ib)
scroll_w[v]:connect_signal("mouse::enter",function()
scroll_w[v]:set_bg(data.bg_focus)
end)
scroll_w[v]:connect_signal("mouse::leave",function()
scroll_w[v]:set_bg(data.bg_highlight)
end)
scroll_w[v]:buttons( util.table.join( button({ }, 1, function()
data["scroll_"..v](data)
end) ))
scroll_w[v]:set_bg(data.bg_highlight)
end end
scroll_w[v] = wibox.container.background() return scroll_w
scroll_w[v]:set_widget(ib)
scroll_w[v].visible = true
data.item_style({widget=scroll_w[v]},{color=data.bg_highlight})
scroll_w[v]:connect_signal("mouse::enter",function()
--FIXME once the theme use a metatable chain, this should start working again
theme.update_colors({widget=scroll_w[v]},rad_item.item_flags.HOVER)
end)
scroll_w[v]:connect_signal("mouse::leave",function()
theme.update_colors({widget=scroll_w[v]},rad_item.item_flags.NONE)
end)
scroll_w[v]:buttons( util.table.join( button({ }, 1, function()
data["scroll_"..v](data)
end) ))
end
return scroll_w
end end
return setmetatable(module, { __call = function(_, ...) return new(...) end }) return setmetatable(module, { __call = function(_, ...) return new(...) end })
-- kate: space-indent on; indent-width 2; replace-tabs on; -- kate: space-indent on; indent-width 4; replace-tabs on;