Better naming

This commit is contained in:
Ksaper 2023-02-12 18:14:35 +02:00
parent 400bd988a8
commit ee9c8b1283
1 changed files with 25 additions and 25 deletions

View File

@ -89,8 +89,8 @@ local function has_value(tab, val)
return false return false
end end
local function create_app_widget(self, app) local function app_widget(self, app)
local app_widget = nil local widget = nil
if self.app_template == nil then if self.app_template == nil then
local icon = self.app_show_icon == true and local icon = self.app_show_icon == true and
@ -119,7 +119,7 @@ local function create_app_widget(self, app)
markup = app.generic_name ~= "" and "<span weight='300'> <i>(" .. app.generic_name .. ")</i></span>" or "" markup = app.generic_name ~= "" and "<span weight='300'> <i>(" .. app.generic_name .. ")</i></span>" or ""
} or nil } or nil
app_widget = wibox.widget widget = wibox.widget
{ {
widget = wibox.container.background, widget = wibox.container.background,
id = "background_role", id = "background_role",
@ -155,53 +155,53 @@ local function create_app_widget(self, app)
} }
} }
app_widget:connect_signal("mouse::enter", function() widget:connect_signal("mouse::enter", function()
local widget = capi.mouse.current_wibox local widget = capi.mouse.current_wibox
if widget then if widget then
widget.cursor = "hand2" widget.cursor = "hand2"
end end
if app_widget.selected then if widget.selected then
app_widget:get_children_by_id("background_role")[1].bg = self.app_selected_hover_color widget:get_children_by_id("background_role")[1].bg = self.app_selected_hover_color
else else
app_widget:get_children_by_id("background_role")[1].bg = self.app_normal_hover_color widget:get_children_by_id("background_role")[1].bg = self.app_normal_hover_color
end end
end) end)
app_widget:connect_signal("mouse::leave", function() widget:connect_signal("mouse::leave", function()
local widget = capi.mouse.current_wibox local widget = capi.mouse.current_wibox
if widget then if widget then
widget.cursor = "left_ptr" widget.cursor = "left_ptr"
end end
if app_widget.selected then if widget.selected then
app_widget:get_children_by_id("background_role")[1].bg = self.app_selected_color widget:get_children_by_id("background_role")[1].bg = self.app_selected_color
else else
app_widget:get_children_by_id("background_role")[1].bg = self.app_normal_color widget:get_children_by_id("background_role")[1].bg = self.app_normal_color
end end
end) end)
else else
app_widget = self.app_template(app) widget = self.app_template(app)
local icon = app_widget:get_children_by_id("icon_role")[1] local icon = widget:get_children_by_id("icon_role")[1]
if icon then if icon then
icon.image = app.icon icon.image = app.icon
end end
local name = app_widget:get_children_by_id("name_role")[1] local name = widget:get_children_by_id("name_role")[1]
if name then if name then
name.text = app.name name.text = app.name
end end
local generic_name = app_widget:get_children_by_id("generic_name_role")[1] local generic_name = widget:get_children_by_id("generic_name_role")[1]
if generic_name then if generic_name then
generic_name.text = app.generic_name generic_name.text = app.generic_name
end end
local command = app_widget:get_children_by_id("command_role")[1] local command = widget:get_children_by_id("command_role")[1]
if command then if command then
command.text = app.executable command.text = app.executable
end end
end end
app_widget:connect_signal("button::press", function(app, _, __, button) widget:connect_signal("button::press", function(app, _, __, button)
if button == 1 then if button == 1 then
if self._private.active_widget == app or not self.select_before_spawn then if self._private.active_widget == app or not self.select_before_spawn then
app:spawn() app:spawn()
@ -212,7 +212,7 @@ local function create_app_widget(self, app)
end) end)
local _self = self local _self = self
function app_widget:spawn() function widget:spawn()
if app.terminal == true then if app.terminal == true then
awful.spawn.with_shell(AWESOME_SENSIBLE_TERMINAL_PATH .. " -e " .. app.executable) awful.spawn.with_shell(AWESOME_SENSIBLE_TERMINAL_PATH .. " -e " .. app.executable)
else else
@ -224,7 +224,7 @@ local function create_app_widget(self, app)
end end
end end
function app_widget:select() function widget:select()
if _self._private.active_widget then if _self._private.active_widget then
_self._private.active_widget:unselect() _self._private.active_widget:unselect()
end end
@ -245,7 +245,7 @@ local function create_app_widget(self, app)
end end
end end
function app_widget:unselect() function widget:unselect()
self:emit_signal("unselected") self:emit_signal("unselected")
self.selected = false self.selected = false
_self._private.active_widget = nil _self._private.active_widget = nil
@ -263,7 +263,7 @@ local function create_app_widget(self, app)
end end
end end
return app_widget return widget
end end
local function search(self, text) local function search(self, text)
@ -303,7 +303,7 @@ local function search(self, text)
for _, entry in pairs(self._private.matched_entries) do for _, entry in pairs(self._private.matched_entries) do
-- Only add the widgets for apps that are part of the first page -- Only add the widgets for apps that are part of the first page
if #self._private.grid.children + 1 <= self._private.max_apps_per_page then if #self._private.grid.children + 1 <= self._private.max_apps_per_page then
self._private.grid:add(create_app_widget(self, entry)) self._private.grid:add(app_widget(self, entry))
end end
end end
@ -362,7 +362,7 @@ local function page_forward(self, dir)
for index, entry in pairs(self._private.matched_entries) do for index, entry in pairs(self._private.matched_entries) do
-- Only add widgets that are between this range (part of the current page) -- Only add widgets that are between this range (part of the current page)
if index > min_app_index_to_include and index <= max_app_index_to_include then if index > min_app_index_to_include and index <= max_app_index_to_include then
self._private.grid:add(create_app_widget(self, entry)) self._private.grid:add(app_widget(self, entry))
end end
end end
@ -406,7 +406,7 @@ local function page_backward(self, dir)
for index, entry in pairs(self._private.matched_entries) do for index, entry in pairs(self._private.matched_entries) do
-- Only add widgets that are between this range (part of the current page) -- Only add widgets that are between this range (part of the current page)
if index > min_app_index_to_include and index <= max_app_index_to_include then if index > min_app_index_to_include and index <= max_app_index_to_include then
self._private.grid:add(create_app_widget(self, entry)) self._private.grid:add(app_widget(self, entry))
end end
end end
@ -473,7 +473,7 @@ local function reset(self)
for index, entry in pairs(self._private.all_entries) do for index, entry in pairs(self._private.all_entries) do
-- Only add the apps that are part of the first page -- Only add the apps that are part of the first page
if index <= self._private.apps_per_page then if index <= self._private.apps_per_page then
self._private.grid:add(create_app_widget(self, entry)) self._private.grid:add(app_widget(self, entry))
else else
break break
end end