From b57b001f99f48f18f1646f97dcc5d2b5b8498913 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Fri, 24 Jun 2016 16:53:47 -0400 Subject: [PATCH] quality: Fix more luacheck warnings And remove unmaintained and broken files --- item/init.lua | 19 +++-- item/layout/icon.lua | 27 ++++--- item/layout/notification.lua | 8 +- item/style/arrow_3d.lua | 9 +-- item/style/arrow_alt.lua | 137 ----------------------------------- item/style/arrow_prefix.lua | 5 +- item/style/arrow_single.lua | 1 - item/style/basic.lua | 6 +- item/style/classic.lua | 1 - item/style/holo.lua | 2 +- item/style/init.lua | 4 +- item/style/line_3d.lua | 6 +- item/style/slice_prefix.lua | 3 +- item/style/subtle.lua | 91 ----------------------- layout/grid.lua | 6 +- layout/horizontal.lua | 11 +-- layout/vertical.lua | 4 +- menu_template.lua.tmpl | 87 ---------------------- object.lua | 5 +- smart_wibox.lua | 3 - style/arrow.lua | 20 ++--- style/classic.lua | 2 +- style/grouped_3d.lua | 4 +- theme/init.lua | 3 +- tooltip.lua | 12 +-- widgets/checkbox.lua | 4 +- widgets/filter.lua | 2 +- widgets/fkey.lua | 1 - widgets/header.lua | 6 +- widgets/infoshapes.lua | 26 +++---- widgets/piechart.lua | 2 +- widgets/scroll.lua | 1 - widgets/separator.lua | 2 - widgets/table.lua | 24 +++--- 34 files changed, 86 insertions(+), 458 deletions(-) delete mode 100644 item/style/arrow_alt.lua delete mode 100644 item/style/subtle.lua delete mode 100644 menu_template.lua.tmpl diff --git a/item/init.lua b/item/init.lua index 1270b67..eda653a 100644 --- a/item/init.lua +++ b/item/init.lua @@ -1,7 +1,7 @@ local type = type -local capi = {timer = timer} local beautiful = require("beautiful") local theme = require("radical.theme") +local timer = require("gears.timer") local object = require("radical.object") local module = { @@ -98,7 +98,7 @@ end -- end local function new_item(data,args) - local args = args or {} + args = args or {} local item,private_data = object({ private_data = { text = args.text or "" , @@ -203,16 +203,15 @@ local function new_item(data,args) text_w:set_markup(text) end - if data.auto_resize then - local fit_w,fit_h = text_w:get_preferred_size() - local is_largest = item == data._internal.largest_item_h - - --TODO find new largest is item is smaller +--TODO find new largest is item is smaller +-- if data.auto_resize then +-- local fit_w,fit_h = text_w:get_preferred_size() +-- local is_largest = item == data._internal.largest_item_h -- if not data._internal.largest_item_h_v or data._internal.largest_item_h_v < fit_h then -- data._internal.largest_item_h =item -- data._internal.largest_item_h_v = fit_h -- end - end +-- end item._private_data.text = text end @@ -248,8 +247,8 @@ local function new_item(data,args) main_timer.timeout = 1.5 main_timer:connect_signal("timeout",function() item._internal._is_long_hover = true - item:emit_signal("long::hover",item,mod,geo) - data:emit_signal("long::hover",item,mod,geo) + item:emit_signal("long::hover",item,{},geo) + data:emit_signal("long::hover",item,{},geo) --TODO mouse::enter should have modifiers main_timer:stop() end) end diff --git a/item/layout/icon.lua b/item/layout/icon.lua index 40eecac..1e637ad 100644 --- a/item/layout/icon.lua +++ b/item/layout/icon.lua @@ -3,7 +3,6 @@ local beautiful = require( "beautiful" ) local color = require( "gears.color" ) local wibox = require( "wibox" ) local checkbox = require( "radical.widgets.checkbox" ) -local horizontal = require( "radical.item.layout.horizontal" ) local util = require( "awful.util" ) local margins2 = require( "radical.margins" ) local common = require( "radical.item.common" ) @@ -29,7 +28,7 @@ local function icon_fit(data,...) end local function icon_draw(self, context, cr, width, height) - local w,h = wibox.widget.imagebox.fit(self,context,width,height) + local w = wibox.widget.imagebox.fit(self,context,width,height) cr:save() cr:translate((width-w)/2,0) wibox.widget.imagebox.draw(self, context, cr, width, height) @@ -37,8 +36,10 @@ local function icon_draw(self, context, cr, width, height) end local function create_item(item,data,args) + local pref, subArrow, ck = nil, nil, nil + if data.fkeys_prefix == true then - local pref = wibox.widget.textbox() + pref = wibox.widget.textbox() function pref:draw(context, cr, width, height) cr:set_source(color(beautiful.fg_normal)) @@ -54,7 +55,7 @@ local function create_item(item,data,args) local has_children = item._private_data.sub_menu_f or item._private_data.sub_menu_m if has_children then - local subArrow = wibox.widget.imagebox() --TODO, make global + subArrow = wibox.widget.imagebox() --TODO, make global function subArrow:fit(context, w, h) return subArrow._image:get_width(),item.height @@ -69,20 +70,18 @@ local function create_item(item,data,args) else return wibox.container.background.fit(box,context, w,h) end - - return 0,0 end if item.checkable then - function item.get_checked(data,item) - if type(item._private_data.checked) == "function" then - return item._private_data.checked() + function item.get_checked(_, i) + if type(i._private_data.checked) == "function" then + return i._private_data.checked() else - return item._private_data.checked + return i._private_data.checked end end - local ck = wibox.widget.imagebox() + ck = wibox.widget.imagebox() ck:set_image(item.checked and checkbox.checked() or checkbox.unchecked()) function item:set_checked(value) @@ -95,7 +94,7 @@ local function create_item(item,data,args) { { { - data.fkeys_prefix and pref or nil, + pref or nil, args.prefix_widget , icon, { @@ -110,8 +109,8 @@ local function create_item(item,data,args) -- Suffix -- Widgets - has_children and subArrow or nil , - item.checkable and ck or nil , + subArrow or nil , + ck or nil , args.suffix_widget , -- Attributes diff --git a/item/layout/notification.lua b/item/layout/notification.lua index e46a574..e54b7e0 100644 --- a/item/layout/notification.lua +++ b/item/layout/notification.lua @@ -6,19 +6,13 @@ local common = require( "radical.item.common" ) local module = {} --- Force the width or compute the minimum space -local function align_fit(box,context,w,h) - if box._item.width then return box._item.width - box._data.item_style.margins.LEFT - box._data.item_style.margins.RIGHT,h end - return box.first:fit(context,w,h)+wibox.widget.textbox.fit(box.second,context,w,h)+box.third:fit(context,w,h),h -end - -- Create the actual widget local function create_item(item,data,args) -- Background local bg = wibox.container.background() -- Margins - local m = wibox.container.margin(la) + local m = wibox.container.margin() local mrgns = margins2(m,(item.item_style or data.item_style).margins) item.get_margins = function() return mrgns diff --git a/item/style/arrow_3d.lua b/item/style/arrow_3d.lua index 89d453a..4d69439 100644 --- a/item/style/arrow_3d.lua +++ b/item/style/arrow_3d.lua @@ -1,8 +1,5 @@ local setmetatable = setmetatable -local print = print -local pairs = pairs local color = require( "gears.color" ) -local base = require( "radical.base" ) local theme = require( "radical.theme" ) local module = { @@ -27,8 +24,6 @@ local c1 = color("#474e56dd") local c2 = color("#5b646cdd") local c3 = color("#212429dd") local c4 = color("#3b4249dd") -local padding = 1 -local p2 = 2 local function widget_draw23(self, context, cr, width, height) cr:save() @@ -70,9 +65,7 @@ local function new_set_bg(self,bg) self.radical_bg = color(bg) end -local function draw(item,args) - local args = args or {} - +local function draw(item) if not item.widget._overlay_init and not item.widget._draw then item.widget.__drawbasic = item.widget.draw item.widget.draw = widget_draw23 diff --git a/item/style/arrow_alt.lua b/item/style/arrow_alt.lua deleted file mode 100644 index 86bc216..0000000 --- a/item/style/arrow_alt.lua +++ /dev/null @@ -1,137 +0,0 @@ -local setmetatable = setmetatable -local print = print -local debug=debug -local ipairs = ipairs -local math = math -local base = require( "radical.base" ) -local beautiful = require("beautiful") -local color = require("gears.color") -local cairo = require("lgi").cairo -local wibox = require("wibox") -local theme = require( "radical.theme" ) - -local module = { - margins = { - TOP = 2, - BOTTOM = 2, - RIGHT = 20, - LEFT = 3 - }, - need_full_repaint = true -} - -local hcode = {"#7777ff","#ff7777","#77ff77","#77ffff","#ffff77"} - -local end_cache = {} -module.get_end_arrow = function(args) - local args = args or {} - local default_height = beautiful.default_height or 16 - local bgt = type(args.bg_color) - local width,height = (args.width or default_height/2+1),args.height or default_height - local img = cairo.ImageSurface(cairo.Format.ARGB32, width+(args.padding or 0), height) - local cr = cairo.Context(img) - cr:set_source(color(args.bg_color or beautiful.bg_normal)) - cr:set_antialias(cairo.ANTIALIAS_NONE) - cr:new_path() - if (args.direction == "left") then - cr:move_to(0,width+(args.padding or 0)) - cr:line_to(0,height/2) - cr:line_to(width+(args.padding or 0),height) - cr:line_to(0,height) - cr:line_to(0,0) - cr:line_to(width+(args.padding or 0),0) - else - cr:line_to(width+(args.padding or 0),0) - cr:line_to(width+(args.padding or 0),height) - cr:line_to(0,height) - cr:line_to(width-1,height/2) - cr:line_to(0,0) - end - cr:close_path() - cr:fill() - return img -end - -local beg_cache = {} -module.get_beg_arrow = function(args) - local args = args or {} - local default_height = beautiful.default_height or 16 - local bgt = type(args.bg_color) - local width,height = (args.width or default_height/2+1)+(args.padding or 0),args.height or default_height - local img = cairo.ImageSurface(cairo.Format.ARGB32, width, height) - local cr = cairo.Context(img) - cr:set_source(color(args.bg_color or beautiful.fg_normal)) - cr:set_antialias(cairo.ANTIALIAS_NONE) - cr:new_path() - if (args.direction == "left") then - cr:move_to(0,width) - cr:line_to(0,height/2) - cr:line_to(width,height) - cr:line_to(width,0) - else - cr:line_to(width,height/2) - cr:line_to(0,height) - cr:line_to(0,0) - end - cr:close_path() - cr:fill() - return img -end - -local function draw_real(self, context, cr, width, height) --- wibox.container.background.draw(self, context, cr, width, height) - cr:save() - - -- This item style require negative padding, this is a little dangerous to - -- do as it can corrupt area outside of the widget - local col = self._item.bg_prefix or beautiful.icon_grad or beautiful.fg_normal - cr:set_source(color(self.background)) - cr:move_to(-height/2-2,0) - cr:line_to(width-height+2,0) - cr:rel_line_to(height*.6,height/2) - cr:line_to(width-height+2,height) - cr:line_to(-height*.6,height) - cr:line_to(0,height/2) - cr:close_path() - cr:reset_clip() - cr:fill() - cr:restore() - - if self._draw then - self._draw(self, context, cr, width, height) - end - - if self.widget.draw then - self.widget:draw(context, cr, width, height) - end -end - -local function draw(item,args) - local args = args or {} - if item.widget.draw ~= draw_real then - item.widget._draw = item.widget.draw - item.widget.draw = draw_real - item.widget:emit_signal("widget::updated") - end - - local color_idx = math.mod(item.f_key,#hcode) + 1 - local next_idx = color_idx + 1 > #hcode and 1 or (color_idx + 1) - - local state = item.state or {} - local current_state = state._current_key or nil - local state_name = base.colors_by_id[current_state] - - if current_state == base.item_flags.SELECTED or (item._tmp_menu) then - item.widget:set_fg(item["fg_focus"]) - item.widget:set_bg(args.color) - elseif state_name then --TODO untested, most likely broken - item.widget:set_bg(args.color or item["bg_"..state_name]) - item.widget:set_fg( item["fg_"..state_name]) - else - item.widget:set_bg(args.color or hcode[color_idx]) - item.widget:set_fg(item["fg_normal"]) - end -end - -return setmetatable(module, { __call = function(_, ...) return draw(...) end }) --- kate: space-indent on; indent-width 2; replace-tabs on; diff --git a/item/style/arrow_prefix.lua b/item/style/arrow_prefix.lua index 421f4e9..d6af833 100644 --- a/item/style/arrow_prefix.lua +++ b/item/style/arrow_prefix.lua @@ -1,7 +1,6 @@ local setmetatable = setmetatable local beautiful = require( "beautiful" ) local color = require( "gears.color" ) -local wibox = require( "wibox" ) local theme = require( "radical.theme" ) local shape = require( "gears.shape" ) @@ -48,9 +47,7 @@ local function suffix_fit(box,context,w,h) return width + h/2 + h/6,height end -local function draw(item,args) - local args = args or {} - +local function draw(item) if not item.widget._overlay_init then item.widget._overlay_init = true end diff --git a/item/style/arrow_single.lua b/item/style/arrow_single.lua index a301491..e0909c7 100644 --- a/item/style/arrow_single.lua +++ b/item/style/arrow_single.lua @@ -1,5 +1,4 @@ local setmetatable = setmetatable -local wibox = require("wibox" ) local theme = require( "radical.theme" ) local shape = require( "gears.shape" ) diff --git a/item/style/basic.lua b/item/style/basic.lua index 333dc2b..e8826f4 100644 --- a/item/style/basic.lua +++ b/item/style/basic.lua @@ -1,9 +1,5 @@ local setmetatable = setmetatable -local print = print -local pairs=pairs -local base = require( "radical.base" ) -local wibox = require("wibox" ) -local theme = require( "radical.theme" ) +local theme = require( "radical.theme" ) local module = { margins = { diff --git a/item/style/classic.lua b/item/style/classic.lua index bb93b4e..7a75892 100644 --- a/item/style/classic.lua +++ b/item/style/classic.lua @@ -1,6 +1,5 @@ local setmetatable = setmetatable local color = require( "gears.color" ) -local wibox = require( "wibox" ) local theme = require( "radical.theme" ) local module = { diff --git a/item/style/holo.lua b/item/style/holo.lua index e2fb5f6..8e184dd 100644 --- a/item/style/holo.lua +++ b/item/style/holo.lua @@ -34,7 +34,7 @@ local function after_draw_children_bottom(self, context, cr, width, height) end local function draw(item,args) - local args = args or {} + args = args or {} item.widget.draw = widget_draw item.widget.before_draw_children = args.pos == "top" diff --git a/item/style/init.lua b/item/style/init.lua index 3b9c2df..d47ecba 100644 --- a/item/style/init.lua +++ b/item/style/init.lua @@ -5,7 +5,7 @@ local unpack = unpack or table.unpack -- Create a generic item_style local function generic(_, args) - local args = args or {} + args = args or {} args.margins = args.margins or { TOP = 0, @@ -30,12 +30,10 @@ end return setmetatable({ basic = require("radical.item.style.basic" ), classic = require("radical.item.style.classic" ), - subtle = require("radical.item.style.subtle" ), rounded_shadow = rounded.shadow , rounded = rounded , holo = holo , holo_top = holo.top , - arrow_alt = require("radical.item.style.arrow_alt" ), arrow_prefix = require("radical.item.style.arrow_prefix" ), arrow_single = require("radical.item.style.arrow_single" ), arrow_3d = require("radical.item.style.arrow_3d" ), diff --git a/item/style/line_3d.lua b/item/style/line_3d.lua index f559d46..2df6f0c 100644 --- a/item/style/line_3d.lua +++ b/item/style/line_3d.lua @@ -22,9 +22,7 @@ local function after_draw_children(self, context, cr, width, height) cr:fill() end -local function draw(item,args) - local args = args or {} - +local function draw(item) if not item.widget._overlay_init then item.widget.after_draw_children = after_draw_children item.widget._overlay_init = true @@ -32,7 +30,7 @@ local function draw(item,args) -- Build the 2 item border colors, this item_style doesn't support gradient -- or patterns item.widget.col1 = color(item.item_border_color or item.border_color or beautiful.border_color) - local s,r,g,b,a = item.widget.col1:get_rgba() + local _,r,g,b,a = item.widget.col1:get_rgba() r,g,b = r-.2,g-.2,b-.2 item.widget.col2 = cairo.Pattern.create_rgba(r,g,b,a) end diff --git a/item/style/slice_prefix.lua b/item/style/slice_prefix.lua index 92bde38..ad7fd05 100644 --- a/item/style/slice_prefix.lua +++ b/item/style/slice_prefix.lua @@ -41,8 +41,7 @@ local function suffix_fit(box,context,w,h) return width + h/2 + h/6,height end -local function draw(item,args) - local args = args or {} +local function draw(item) if not item.widget._overlay_init then item.widget._drawprefix = item.widget.draw diff --git a/item/style/subtle.lua b/item/style/subtle.lua deleted file mode 100644 index 82cadc6..0000000 --- a/item/style/subtle.lua +++ /dev/null @@ -1,91 +0,0 @@ -local setmetatable = setmetatable -local math = math -local base = require( "radical.base" ) -local color = require( "gears.color" ) -local cairo = require( "lgi" ).cairo -local theme = require( "radical.theme" ) -local print = print - -local module = { - margins = { - TOP = 4, - BOTTOM = 4, - RIGHT = 4, - LEFT = 4 - } -} - -local state_cache = {} - -local function gen(w,h,bg_color,border_color) - cr:save() - local img = cairo.ImageSurface(cairo.Format.ARGB32, w,h) - local cr = cairo.Context(img) - local rad = corner_radius or 3 - cr:set_source(color(bg_color)) - local radius = 3 - cr:arc(radius,radius,radius,math.pi,3*(math.pi/2)) - cr:arc(w-radius,radius,radius,3*(math.pi/2),math.pi*2) - cr:line_to(w,h) - cr:arc(radius,h-radius,radius,math.pi/2,math.pi) - cr:close_path() - cr:clip() - cr:paint_with_alpha(0.3) - cr:reset_clip() - cr:move_to(w,h-6) - cr:line_to(w,h) - cr:line_to(w-6,h) - cr:fill() - cr:restore() - return cairo.Pattern.create_for_surface(img) -end - -local function before_draw_children(self, context, cr, width, height) - - local state = self._item.state or {} - local current_state = state._current_key or "" - if not state_cache[current_state] then - state_cache[current_state] = {} - end - local cache = state_cache[current_state] - local hash = width+1234*height - - local cached = cache[hash] - - --Generate the pixmap - if not cached then - local state_name = current_state == "" and "bg" or "bg_"..(base.colors_by_id[current_state] or "") - cached = gen(width,height,self._item[state_name],bc) - cache[hash] = cached - end - - if current_state ~= self._last_state then - self:set_bg(cached) - self._last_state = current_state - end -end - -local function draw(item,args) - local args = args or {} - - if not item.widget._overlay_init then - item.widget.before_draw_children = before_draw_children - item.widget._overlay_init = true - item.widget._item = item - end - - local state = item.state or {} - local current_state = state._current_key or nil - local state_name = base.colors_by_id[current_state] - - if current_state == base.item_flags.SELECTED or (item._tmp_menu) then - item.widget:set_fg(item["fg_focus"]) - elseif state_name then - item.widget:set_fg( item["fg_"..state_name]) - else - item.widget:set_fg(item["fg_normal"]) - end -end - -return setmetatable(module, { __call = function(_, ...) return draw(...) end }) --- kate: space-indent on; indent-width 2; replace-tabs on; diff --git a/layout/grid.lua b/layout/grid.lua index c7febc3..1c356e2 100644 --- a/layout/grid.lua +++ b/layout/grid.lua @@ -1,5 +1,4 @@ local setmetatable = setmetatable -local print = print local ipairs = ipairs local math = math local wibox = require( "wibox" ) @@ -49,7 +48,6 @@ local function item_fit(data,item,...) end local function new(data) - local counter = 0 local mode = data.column ~= nil local rows = {} local l = wibox.layout.fixed[mode and "horizontal" or "vertical"]() @@ -63,13 +61,13 @@ local function new(data) local r1,r2 = data.item_height*math.ceil(data.rowcount/constraint),data.item_height*constraint return (mode and r2 or r1),(mode and r1 or r2) end - l.add = function(l,item) + l.add = function(_, it) for k,v in ipairs(rows) do v:reset() end local rc = data.rowcount+1 for i=1,rc do - rows[((i-1)%constraint)+1]:add((rc == i and item.widget or data.items[i].widget)) + rows[((i-1)%constraint)+1]:add((rc == i and it.widget or data.items[i].widget)) end return true end diff --git a/layout/horizontal.lua b/layout/horizontal.lua index c59d631..a063ecf 100644 --- a/layout/horizontal.lua +++ b/layout/horizontal.lua @@ -36,13 +36,7 @@ local function new(data) } -- Hack fit - local new_fit - new_fit = function(self,context,w,h,force_values) --TODO use the context instead of extra argument - -- Get the original fit, the function need to be replaced to avoir a stack overflow - real_l.fit = real_l._fit - local result,r2 = self:get_preferred_size(context, force_values and w, force_values and h) - real_l.fit = new_fit - + function real_l.fit(self,context) local w,h if data.auto_resize and data._internal.largest_item_h then w,h = data.rowcount*(data.item_width or data.default_width),data._internal.largest_item_h_v > data.item_height and data._internal.largest_item_h_v or data.item_height @@ -53,9 +47,6 @@ local function new(data) return w,h end - real_l._fit = real_l.fit - real_l.fit = new_fit - return real_l end diff --git a/layout/vertical.lua b/layout/vertical.lua index 008b143..7d3f36a 100644 --- a/layout/vertical.lua +++ b/layout/vertical.lua @@ -39,8 +39,8 @@ local function compute_geo(data,width,height,force_values) local visblerow = data.visible_row_count - local sw,sh = data._internal.suf_l:get_preferred_size() - local pw,ph = data._internal.pref_l:get_preferred_size() + local _,sh = data._internal.suf_l:get_preferred_size() + local _,ph = data._internal.pref_l:get_preferred_size() if not data._internal.has_widget then return w, visblerow*data.item_height + ph + sh else diff --git a/menu_template.lua.tmpl b/menu_template.lua.tmpl deleted file mode 100644 index 750da0a..0000000 --- a/menu_template.lua.tmpl +++ /dev/null @@ -1,87 +0,0 @@ -local base = require( "radical.base" ) -local print = print -local unpack = unpack -local setmetatable = setmetatable -local color = require( "gears.color" ) -local wibox = require( "wibox" ) -local beautiful = require( "beautiful" ) -local cairo = require( "lgi" ).cairo -local awful = require( "awful" ) -local util = require( "awful.util" ) -local button = require( "awful.button" ) -local checkbox = require( "radical.widgets.checkbox" ) - -local capi,module = { mouse = mouse , screen = screen, keygrabber = keygrabber },{} - -local function get_direction(data) - return "left" -- Nothing to do -end - -local function set_position(self) - return --Nothing to do -end - -local function setup_drawable(data) - local internal = data._internal - local get_map,set_map,private_data = internal.get_map,internal.set_map,internal.private_data - - --Init --- internal.w = wibox({}) - internal.margin = wibox.container.margin() - if not data.layout then - data.layout = layout.vertical - end - internal.layout = wibox.layout.fixed.horizontal() --data.layout(data) --TODO fix - internal.margin:set_widget(internal.layout) - - --Getters - get_map.wibox = function() return nil end -- Will this break? - get_map.x = function() return 0 end - get_map.y = function() return 0 end - get_map.width = function() return 500 end - get_map.height = function() return 40 end - get_map.visible = function() return private_data.visible end - get_map.direction = function() return private_data.direction end - get_map.margins = function() - local ret = {left=data.border_width,right=data.border_width,top=data.style.margins.TOP,bottom=data.style.margins.BOTTOM} - if data.arrow_type ~= base.arrow_type.NONE then - ret[data.direction] = ret[data.direction]+13 - end - return ret - end - - --Setters - function internal:set_visible(value) - -- TODO - end - -end - -local function setup_item(data,item,args) - -- Add widgets - local tb = wibox.widget.textbox() - data._internal.layout:add(tb) - item.widget = tb - tb:set_text("bob") -end - -local function new(args) - local args = args or {} - args.internal = args.internal or {} - args.internal.get_direction = args.internal.get_direction or get_direction - args.internal.set_position = args.internal.set_position or set_position - args.internal.setup_drawable = args.internal.setup_drawable or setup_drawable - args.internal.setup_item = args.internal.setup_item or setup_item - args.style = args.style or arrow_style - local ret = base(args) - ret:connect_signal("clear::menu",function(_,vis) - ret._internal.layout:reset() - end) - ret:connect_signal("_hidden::changed",function(_,item) - item.widget:emit_signal("widget::updated") - end) - return ret -end - -return setmetatable(module, { __call = function(_, ...) return new(...) end }) --- kate: space-indent on; indent-width 2; replace-tabs on; diff --git a/object.lua b/object.lua index a894821..4b58b8e 100644 --- a/object.lua +++ b/object.lua @@ -5,7 +5,8 @@ local rawget = rawget local pairs = pairs local function setup_object(args) - local data,args,private_data,signals = {},args or {},private_data or {},{} + args = args or {} + local data,signals = {},{} local private_data = args.private_data or {} function data:connect_signal(name,func) @@ -73,4 +74,4 @@ local function setup_object(args) setmetatable(data, { __index = return_data, __newindex = catch_changes, __len = function() return #data + #private_data end, }) return data,private_data end -return setmetatable({}, { __call = function(_, ...) return setup_object(...) end }) \ No newline at end of file +return setmetatable({}, { __call = function(_, ...) return setup_object(...) end }) diff --git a/smart_wibox.lua b/smart_wibox.lua index 8754503..ae6cb7f 100644 --- a/smart_wibox.lua +++ b/smart_wibox.lua @@ -9,15 +9,12 @@ -- @release @AWESOME_VERSION@ -- @module radical.smart_wibox --------------------------------------------------------------------------- -local capi = {mouse = mouse, screen = screen} local wibox = require( "wibox" ) local util = require( "awful.util" ) local surface = require( "gears.surface" ) local glib = require( "lgi" ).GLib local beautiful = require( "beautiful" ) local color = require( "gears.color" ) -local screen = require( "awful.screen" ) -local mouse = require( "awful.mouse" ) local placement = require( "awful.placement" ) local unpack = unpack or table.unpack diff --git a/style/arrow.lua b/style/arrow.lua index 9f498a5..387779b 100644 --- a/style/arrow.lua +++ b/style/arrow.lua @@ -2,7 +2,6 @@ local setmetatable = setmetatable local unpack = unpack or table.unpack local beautiful = require( "beautiful" ) local color = require( "gears.color" ) -local cairo = require( "lgi" ).cairo local base = require( "radical.base" ) local shape = require( "gears.shape" ) @@ -89,16 +88,16 @@ local function update_margins(data, pos) end -- Generate a rounded cairo path with the arrow -local function draw_roundedrect_path(cr, width, height, radius, data, direction) +local function draw_roundedrect_path(cr, width, height, rad, data, direction) direction = direction or "right" if data.arrow_type == base.arrow_type.NONE then if direction == "left" then - data._internal.w:set_yoffset(-radius) + data._internal.w:set_yoffset(-rad) elseif direction == "right" then - data._internal.w:set_yoffset(radius) + data._internal.w:set_yoffset(rad) end - return shape.rounded_rect(cr, width, height, radius) + return shape.rounded_rect(cr, width, height, rad) end local angle, swap = angles[direction], swaps[direction] @@ -118,12 +117,11 @@ local function draw_roundedrect_path(cr, width, height, radius, data, direction) gen_arrow_x(data, data.direction, width, height) -- Forward to the real shape - local ax = swap and width - (data._arrow_x or 20)-arrow_height - radius or (data._arrow_x or 20) - s(cr, width, height, radius, arrow_height, ax) + local ax = swap and width - (data._arrow_x or 20)-arrow_height - rad or (data._arrow_x or 20) + s(cr, width, height, rad, arrow_height, ax) end -local function draw(data,args) - local args = args or {} +local function draw(data) if not data._internal.arrow_setup then data._internal.w:set_shape_border_width(data.border_width or 1) @@ -140,12 +138,10 @@ local function draw(data,args) -- if dir then -- data._internal.w:set_shape(function(cr, w, h) draw_roundedrect_path(cr, w, h, radius, data, data._internal.w.position) end) -- end - update_margins(data, dir) + update_margins(data, nil) data._internal.arrow_setup = true end - - return w,w2 end return setmetatable(module, { __call = function(_, ...) return draw(...) end }) diff --git a/style/classic.lua b/style/classic.lua index 495a369..0af6a32 100644 --- a/style/classic.lua +++ b/style/classic.lua @@ -7,7 +7,7 @@ local module = { TOP = 0 , BOTTOM = 0 , LEFT = 0 , - BOTTOM = 0 , + RIGHT = 0 , } } diff --git a/style/grouped_3d.lua b/style/grouped_3d.lua index ec82215..ed0ec50 100644 --- a/style/grouped_3d.lua +++ b/style/grouped_3d.lua @@ -1,14 +1,12 @@ local setmetatable = setmetatable -local base = require( "radical.base" ) local color = require( "gears.color" ) -local shape = require( "gears.shape" ) local module = { margins = { TOP = 0 , BOTTOM = 0 , LEFT = 0 , - BOTTOM = 0 , + RIGHT = 0 , } } diff --git a/theme/init.lua b/theme/init.lua index 9aa67ed..95cd390 100644 --- a/theme/init.lua +++ b/theme/init.lua @@ -74,7 +74,8 @@ end local theme_colors = {} local function load_section(data,priv,section,args) - local bg,fg,args = section.."_bg_", section.."_fg_",args or {} + args = args or {} + local bg,fg = section.."_bg_", section.."_fg_" for k,v in pairs(theme_colors) do priv[bg..k] = args[bg..v.beautiful_name] or beautiful["menu_"..bg..v.beautiful_name] or beautiful[bg..v.beautiful_name] priv[fg..k] = args[fg..v.beautiful_name] or beautiful["menu_"..fg..v.beautiful_name] or beautiful[fg..v.beautiful_name] diff --git a/tooltip.lua b/tooltip.lua index 5b1e9f2..5c7f1f0 100644 --- a/tooltip.lua +++ b/tooltip.lua @@ -2,7 +2,6 @@ local setmetatable,math = setmetatable,math local beautiful = require( "beautiful" ) local surface = require( "gears.surface" ) local wibox = require( "wibox" ) -local cairo = require( "lgi" ).cairo local object = require( "radical.object" ) local shape = require( "gears.shape" ) local capi = { screen = screen , @@ -91,7 +90,9 @@ end local function new(widget,text, args) - local args,data = args or {},object({ + args = args or {} + + local data = object({ private_data = { }, autogen_getmap = true, @@ -114,7 +115,7 @@ local function new(widget,text, args) function data:hide() hide_tooltip() end function data:showToolTip(show,args2) - local args2 = args2 or args or {} + args2 = args2 or args or {} args.direction = args.direction or get_direction(args2) local vertical,textw = (args.direction == "left") or (args.direction == "right"),wibox.widget.textbox() @@ -151,10 +152,11 @@ local function new(widget,text, args) end end end - widget:connect_signal("mouse::enter" , function(widget,geometry) data:showToolTip( true , {parent=geometry}) end) + widget:connect_signal("mouse::enter" , function(_,geometry) data:showToolTip( true , {parent=geometry}) end) widget:connect_signal("mouse::leave" , hide_tooltip) widget:connect_signal("button::press" , hide_tooltip) - data.set_text = set_text + data.set_text = set_text + data.set_markup = set_markup data._args = args return data end diff --git a/widgets/checkbox.lua b/widgets/checkbox.lua index 665dd7d..2bfc844 100644 --- a/widgets/checkbox.lua +++ b/widgets/checkbox.lua @@ -1,5 +1,3 @@ -local setmetatable = setmetatable -local print = print local color = require("gears.color") local cairo = require( "lgi" ).cairo @@ -96,4 +94,4 @@ function module.unchecked() return notcheckedI end -return setmetatable(module, { __call = function(_, ...) return new(...) end }) +return module diff --git a/widgets/filter.lua b/widgets/filter.lua index a17d6f2..59b066b 100644 --- a/widgets/filter.lua +++ b/widgets/filter.lua @@ -8,7 +8,7 @@ local function set_data(self, data) local info = self:get_children_by_id("infoshapes" )[1] local tb = self:get_children_by_id("filter_text")[1] - function self:fit(context,width,height) + function self.fit(_,context,width,height) return width,data.item_height end diff --git a/widgets/fkey.lua b/widgets/fkey.lua index 2ff04e6..32c7714 100644 --- a/widgets/fkey.lua +++ b/widgets/fkey.lua @@ -1,5 +1,4 @@ local setmetatable = setmetatable -local print = print local color = require( "gears.color" ) local cairo = require( "lgi" ).cairo local pango = require( "lgi" ).Pango diff --git a/widgets/header.lua b/widgets/header.lua index 91276e0..4f71709 100644 --- a/widgets/header.lua +++ b/widgets/header.lua @@ -1,7 +1,4 @@ local setmetatable = setmetatable -local print = print -local color = require("gears.color") -local cairo = require( "lgi" ).cairo local wibox = require("wibox") local beautiful = require( "beautiful" ) @@ -9,13 +6,12 @@ local beautiful = require( "beautiful" ) local module = {} local function new(data,text,args) - local args = args or {} + args = args or {} local bg = wibox.container.background() local infoHeader = wibox.widget.textbox() infoHeader:set_font("") infoHeader:set_markup( " ".. text .." " ) local l = wibox.layout.align.horizontal() - print("\n\n\nAAAAAAAAAA",l.set_first, l.set_left) l:set_left(infoHeader) bg:set_widget(l) bg:set_bg(data.bg_header) diff --git a/widgets/infoshapes.lua b/widgets/infoshapes.lua index b471816..2fb2f94 100644 --- a/widgets/infoshapes.lua +++ b/widgets/infoshapes.lua @@ -13,7 +13,7 @@ local infoshape = { mt = {} } local default_shape = shape.rounded_bar -local default_font_description = nil +-- local default_font_description = nil local pango_l = {} @@ -56,11 +56,11 @@ local function get_group_extents(self, group, height) end -- Add the shape to the context -local function draw_shape2(self, infoshape, cr, width, height, ...) - local shape = infoshape.shape or self._default_shape or default_shape +local function draw_shape2(self, is, cr, width, height, ...) + local s = is.shape or self._default_shape or default_shape - if shape then - shape(cr, width, height, ...) + if s then + s(cr, width, height, ...) end end @@ -121,7 +121,7 @@ end local function draw_section_common(self, context, cr, width, height, section) cr:translate(0, padding) for k, v in ipairs(section) do - local w, h = draw_shape(self, cr, width, height, v) + local w = draw_shape(self, cr, width, height, v) cr:translate(w + (self._padding or 2) + height, 0) end end @@ -163,7 +163,7 @@ end -- Support multiple align modes function infoshape:layout(context, width, height) if self.widget then - local w, h = self.widget:fit(context, width, height) + local w = self.widget:fit(context, width, height) if not self._align or self._align == "left" then --TODO use base.fit_widget return { base.place_widget_at(self.widget, 0, 0, w, height) } else @@ -230,7 +230,7 @@ end -- @treturn A unique identifier key -- function infoshape:add_infoshape(args) - local args = args or {} + args = args or {} local align = args.align or "right" local layer = args.layer or "below" if not self["_"..layer] then @@ -263,8 +263,8 @@ function infoshape:set_infoshapes(args) end --TODO fallback beautiful -function infoshape:set_shape(shape) - self._default_shape = shape +function infoshape:set_shape(s) + self._default_shape = s end --TODO fallback beautiful @@ -277,9 +277,9 @@ function infoshape:set_shape_border_width(col) self._shape_border_width = col end -function infoshape:set_default_font_description(desc) - default_font_description = desc -end +-- function infoshape:set_default_font_description(desc) +-- default_font_description = desc +-- end --TODO set default bg --TODO set default fg diff --git a/widgets/piechart.lua b/widgets/piechart.lua index 0503a3b..5f8c5a5 100644 --- a/widgets/piechart.lua +++ b/widgets/piechart.lua @@ -77,7 +77,7 @@ end local function new(data) if not colors then colors = {color(beautiful.fg_normal),color(beautiful.bg_alternate),color(beautiful.fg_focus),color(beautiful.bg_highlight)} end local im = wibox.widget.imagebox() - im._data,im.draw,im.set_data = dummy_dataset,draw,set_data + im.draw,im.set_data = draw,set_data im._cache = {} return im end diff --git a/widgets/scroll.lua b/widgets/scroll.lua index 58420a1..7177a9e 100644 --- a/widgets/scroll.lua +++ b/widgets/scroll.lua @@ -5,7 +5,6 @@ local button = require( "awful.button" ) local beautiful = require( "beautiful" ) local shape = require( "gears.shape" ) local surface = require( "gears.surface" ) -local theme = require( "radical.theme" ) local module = {} diff --git a/widgets/separator.lua b/widgets/separator.lua index 8d06302..8640652 100644 --- a/widgets/separator.lua +++ b/widgets/separator.lua @@ -1,7 +1,5 @@ local setmetatable = setmetatable -local print = print local color = require( "gears.color") -local cairo = require( "lgi" ).cairo local wibox = require( "wibox" ) local beautiful = require( "beautiful" ) diff --git a/widgets/table.lua b/widgets/table.lua index e729da6..e13f237 100644 --- a/widgets/table.lua +++ b/widgets/table.lua @@ -2,7 +2,6 @@ local wibox = require("wibox") local beautiful = require("beautiful") local color = require("gears.color") local ipairs = ipairs -local print = print local function textbox_draw(self, context, cr, width, height) cr:save() @@ -15,11 +14,11 @@ local function textbox_draw(self, context, cr, width, height) wibox.widget.textbox.draw(self, context, cr, width, height) end -local function create_textbox(context,col_c,col,has_v_header,row_height) +local function create_textbox(col_c,col,has_v_header,row_height) local t = wibox.widget.textbox() t.fit = function(s,context,w2,h) - local fw,fh = wibox.widget.textbox.fit(s,context,w2,h) + local _,fh = wibox.widget.textbox.fit(s,context,w2,h) return (w2/(col_c+2 - col)),row_height or fh end t.draw = textbox_draw @@ -27,19 +26,19 @@ local function create_textbox(context,col_c,col,has_v_header,row_height) return t end -local function create_h_header(main_l,cols,context,args) +local function create_h_header(main_l,cols,args) if args.h_header then local bg = wibox.container.background() local row_l = wibox.layout.fixed.horizontal() bg:set_bg(beautiful.menu_table_bg_header or beautiful.menu_bg_header or beautiful.fg_normal) bg:set_widget(row_l) if args.v_header then - local t = create_textbox(context,cols,1,args.v_header ~= nil,args.row_height) + local t = create_textbox(cols,1,args.v_header ~= nil,args.row_height) t:set_markup("--") row_l:add(t) end for i=1,cols do - local t = create_textbox(context,cols,i+1,args.v_header ~= nil,args.row_height) + local t = create_textbox(cols,i+1,args.v_header ~= nil,args.row_height) t:set_markup("".. (args.h_header[i] or "-") .."") row_l:add(t) end @@ -48,8 +47,7 @@ local function create_h_header(main_l,cols,context,args) end local function new(content,args) - local args = args or {} - local rows = #content + args = args or {} local cols = 0 for k,v in ipairs(content) do if #v > cols then @@ -57,18 +55,18 @@ local function new(content,args) end end local main_l = wibox.layout.fixed.vertical() - local w =200 + main_l.fit = function(self,context,width,height) - w = width return wibox.layout.fixed.fit(self,context,width,height) end - create_h_header(main_l,cols,w,args) + + create_h_header(main_l,cols,args) local j,widgets =1,{} for k,v in ipairs(content) do local row_l,row_w = wibox.layout.fixed.horizontal(),{} if args.v_header then - local t = create_textbox(w,cols,1,args.v_header ~= nil,args.row_height) + local t = create_textbox(cols,1,args.v_header ~= nil,args.row_height) t:set_markup("".. (args.v_header[j] or "-") .."") local bg = wibox.container.background() bg:set_bg(beautiful.menu_table_bg_header or beautiful.menu_bg_header or beautiful.fg_normal) @@ -76,7 +74,7 @@ local function new(content,args) row_l:add(bg) end for i=1,cols do - local t = create_textbox(w,cols,i+1,args.v_header ~= nil,args.row_height) + local t = create_textbox(cols,i+1,args.v_header ~= nil,args.row_height) t:set_text(v[i]) row_l:add(t) row_w[#row_w+1] =t