Skip to content

Commit

Permalink
awesomeWM#3539: tooltips texts - review comments implemented.
Browse files Browse the repository at this point in the history
  • Loading branch information
raven2cz committed Jul 6, 2022
1 parent de6b073 commit 7a962d2
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 36 deletions.
91 changes: 69 additions & 22 deletions lib/awful/titlebar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,21 @@ local capi = {
local titlebar = {
widget = {},
enable_tooltip = true,
fallback_name = '<unknown>',
tooltip_messages = {
close = "Close",
minimize = "Minimize",
maximized_active = "Unmaximize",
maximized_inactive = "Maximize",
floating_active = "Tiling",
floating_inactive = "Floating",
ontop_active = "NotOnTop",
ontop_inactive = "OnTop",
sticky_active = "NotSticky",
sticky_inactive = "Sticky",
}
fallback_name = '<unknown>'
}

local default_tooltip_messages = {
close = "Close",
minimize = "Minimize",
maximized_active = "Unmaximize",
maximized_inactive = "Maximize",
floating_active = "Tiling",
floating_inactive = "Floating",
ontop_active = "NotOnTop",
ontop_inactive = "OnTop",
sticky_active = "NotSticky",
sticky_inactive = "Sticky"
}

--- Show tooltips when hover on titlebar buttons.
-- @tfield[opt=true] boolean awful.titlebar.enable_tooltip
Expand Down Expand Up @@ -459,6 +459,51 @@ local titlebar = {
-- @tparam gears.surface|string path
-- @see gears.surface

--- Add tooltip texts for titlebar buttons: active, inactive, plain
-- @beautiful beautiful.titlebar_tooltip_messages
-- @tparam table tooltips Key-Value syntax: key is button name, value is tooltip text.
-- See default usage in variable `default_tooltip_messages` in titlebar component.
-- @see awful.titlebar
-- @usage -- Configure titlebar button tooltip texts in your theme.
-- theme.titlebar_tooltip_messages = {
-- close = "Close",
-- minimize = "Minimize",
-- maximized_active = "Unmaximize",
-- maximized_inactive = "Maximize",
-- floating_active = "Tiling",
-- floating_inactive = "Floating",
-- ontop_active = "NotOnTop",
-- ontop_inactive = "OnTop",
-- sticky_active = "NotSticky",
-- sticky_inactive = "Sticky"
-- }
--

--- Titlebar buttons tooltips, tooltip parameter `delay_show`
-- @beautiful beautiful.titlebar_tooltip_delay_show
-- @tparam integer delay See documentation for awful.tooltip `delay_show`
-- @see awful.tooltip

--- Titlebar buttons tooltips, tooltip parameter `margins_leftright`
-- @beautiful beautiful.titlebar_tooltip_margins_leftright
-- @tparam integer margin See documentation for awful.tooltip `margins_leftright`
-- @see awful.tooltip

--- Titlebar buttons tooltips, tooltip parameter `margins_topbottom`
-- @beautiful beautiful.titlebar_tooltip_margins_topbottom
-- @tparam integer margin See documentation for awful.tooltip `margins_topbottom`
-- @see awful.tooltip

--- Titlebar buttons tooltips, tooltip parameter `timeout`
-- @beautiful beautiful.titlebar_tooltip_timeout
-- @tparam number timeout See documentation for awful.tooltip `timeout`
-- @see awful.tooltip

--- Titlebar buttons tooltips, tooltip parameter `align`
-- @beautiful beautiful.titlebar_tooltip_align
-- @tparam string align See documentation for awful.tooltip `align`
-- @see awful.tooltip

--- Set a declarative widget hierarchy description.
-- See [The declarative layout system](../documentation/03-declarative-layout.md.html)
-- @param args An array containing the widgets disposition
Expand Down Expand Up @@ -769,11 +814,11 @@ function titlebar.widget.button(c, name, selector, action)
if titlebar.enable_tooltip then
ret._private.tooltip = atooltip({
objects = {ret},
delay_show = 1.0,
margins_leftright = 12,
margins_topbottom = 6,
timeout = 0.25,
align = "bottom_right"
delay_show = beautiful["titlebar_tooltip_delay_show"] or 1.0,
margins_leftright = beautiful["titlebar_tooltip_margins_leftright"],
margins_topbottom = beautiful["titlebar_tooltip_margins_topbottom"],
timeout = beautiful["titlebar_tooltip_timeout"],
align = beautiful["titlebar_tooltip_align"]
})
end

Expand Down Expand Up @@ -801,10 +846,12 @@ function titlebar.widget.button(c, name, selector, action)
state = "_" .. state
end
-- try select user defined tooltip texts according to state
local tooltip_msgs = beautiful["titlebar_tooltip_messages"] or titlebar.tooltip_messages
if tooltip_msgs then
tooltip_text = tooltip_msgs[name .. "_" .. img] or tooltip_msgs[name] or name
end
local tooltip_msgs = beautiful["titlebar_tooltip_messages"] or default_tooltip_messages
tooltip_text = tooltip_msgs[name .. "_" .. img]
or tooltip_msgs[name]
or default_tooltip_messages[name .. "_" .. img]
or default_tooltip_messages[name]
or name
-- First try with a prefix based on the client's focus state,
-- then try again without that prefix if nothing was found,
-- and finally, try a fallback for compatibility with Awesome 3.5 themes
Expand Down
14 changes: 0 additions & 14 deletions themes/default/theme.lua
Original file line number Diff line number Diff line change
Expand Up @@ -97,20 +97,6 @@ theme.titlebar_maximized_button_focus_inactive = themes_path.."default/titlebar
theme.titlebar_maximized_button_normal_active = themes_path.."default/titlebar/maximized_normal_active.png"
theme.titlebar_maximized_button_focus_active = themes_path.."default/titlebar/maximized_focus_active.png"

-- Define custom titlebar tooltips
theme.titlebar_tooltip_messages = {
close = "Close",
minimize = "Minimize",
maximized_active = "Unmaximize",
maximized_inactive = "Maximize",
floating_active = "Tiling",
floating_inactive = "Floating",
ontop_active = "NotOnTop",
ontop_inactive = "OnTop",
sticky_active = "NotSticky",
sticky_inactive = "Sticky",
}

theme.wallpaper = themes_path.."default/background.png"

-- You can use your own layout icons like this:
Expand Down

0 comments on commit 7a962d2

Please sign in to comment.