style(beautiful: gtk; hotkeys_popup): make new luacheck a bit happier (#3651)

This commit is contained in:
Actionless Loveless 2022-06-30 17:32:45 +02:00 committed by GitHub
parent a5c84896ef
commit 9ca7bb487a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 27 deletions

View File

@ -508,10 +508,10 @@ function widget.new(args)
end
current_column.layout:add(self:_group_label(group))
local function insert_keys(_keys, _add_new_column)
local function insert_keys(ik_keys, ik_add_new_column)
local max_label_width = 0
local joined_labels = ""
for i, key in ipairs(_keys) do
for i, key in ipairs(ik_keys) do
local modifiers = key.mod
if not modifiers or modifiers == "none" then
modifiers = ""
@ -538,7 +538,7 @@ function widget.new(args)
if label_width > max_label_width then
max_label_width = label_width
end
joined_labels = joined_labels .. rendered_hotkey .. (i~=#_keys and "\n" or "")
joined_labels = joined_labels .. rendered_hotkey .. (i~=#ik_keys and "\n" or "")
end
current_column.layout:add(wibox.widget.textbox(joined_labels))
local max_width = max_label_width + self.group_margin
@ -548,7 +548,7 @@ function widget.new(args)
-- +1 for group label:
current_column.height_px = (current_column.height_px or 0) +
gstring.linecount(joined_labels)*line_height + group_label_height
if _add_new_column then
if ik_add_new_column then
table.insert(column_layouts, current_column)
end
end
@ -643,23 +643,23 @@ function widget.new(args)
awful.button({ }, 3, function () widget_obj:hide() end)
}
function widget_obj.page_next(_self)
if _self.current_page == #pages then return end
_self.current_page = _self.current_page + 1
_self.popup:set_widget(pages[_self.current_page])
function widget_obj.page_next(w_self)
if w_self.current_page == #pages then return end
w_self.current_page = w_self.current_page + 1
w_self.popup:set_widget(pages[w_self.current_page])
end
function widget_obj.page_prev(_self)
if _self.current_page == 1 then return end
_self.current_page = _self.current_page - 1
_self.popup:set_widget(pages[_self.current_page])
function widget_obj.page_prev(w_self)
if w_self.current_page == 1 then return end
w_self.current_page = w_self.current_page - 1
w_self.popup:set_widget(pages[w_self.current_page])
end
function widget_obj.show(_self)
_self.popup.visible = true
function widget_obj.show(w_self)
w_self.popup.visible = true
end
function widget_obj.hide(_self)
_self.popup.visible = false
if _self.keygrabber then
awful.keygrabber.stop(_self.keygrabber)
function widget_obj.hide(w_self)
w_self.popup.visible = false
if w_self.keygrabber then
awful.keygrabber.stop(w_self.keygrabber)
end
end

View File

@ -29,35 +29,35 @@ local function convert_gtk_color_to_hex(gtk_color)
convert_gtk_channel_to_hex(gtk_color.alpha)
end
local function lookup_gtk_color_to_hex(_style_context, color_name)
local gtk_color = _style_context:lookup_color(color_name)
local function lookup_gtk_color_to_hex(style_context, color_name)
local gtk_color = style_context:lookup_color(color_name)
if not gtk_color then
return nil
end
return convert_gtk_color_to_hex(gtk_color)
end
local function get_gtk_property(_style_context, property_name)
local state = _style_context:get_state()
local property = _style_context:get_property(property_name, state)
local function get_gtk_property(style_context, property_name)
local state = style_context:get_state()
local property = style_context:get_property(property_name, state)
if not property then
return nil
end
return property.value
end
local function get_gtk_color_property_to_hex(_style_context, property_name)
local function get_gtk_color_property_to_hex(style_context, property_name)
return convert_gtk_color_to_hex(
get_gtk_property(_style_context, property_name)
get_gtk_property(style_context, property_name)
)
end
local function read_gtk_color_properties_from_widget(gtk_widget, properties)
local _style_context = gtk_widget:get_style_context()
local style_context = gtk_widget:get_style_context()
local result = {}
for result_key, style_context_property in pairs(properties) do
result[result_key] = get_gtk_color_property_to_hex(
_style_context, style_context_property
style_context, style_context_property
)
end
return result