awesomewm/modules/ibus/popup.lua

112 lines
2.3 KiB
Lua
Raw Normal View History

local popup = {}
local util = req_rel(..., "util")
2021-08-01 07:24:26 -07:00
popup.widget = wibox.widget {
2021-08-01 07:24:26 -07:00
homogeneous = false,
vertical_homogeneous = true,
horizontal_homogeneous = false,
vertical_spacing = beautiful.dpi(10),
horizontal_spacing = beautiful.dpi(0),
min_cols_size = beautiful.dpi(20),
min_rows_size = beautiful.dpi(20),
layout = wibox.layout.grid
}
for k, l in pairs(config.ibus.language_list) do
2021-08-01 07:24:26 -07:00
l["widget_checkbox"] = wibox.widget {
checked = false,
border_width = beautiful.dpi(3),
paddings = beautiful.dpi(4),
margins = beautiful.dpi(5),
color = beautiful.color.bar.active,
border_color = beautiful.color.bar.inactive,
widget = wibox.widget.checkbox,
forced_height = beautiful.dpi(30),
forced_width = beautiful.dpi(30),
shape = gears.shape.circle,
}
2022-03-19 10:59:04 -07:00
l["widget_text"] = wibox.widget {
{
2023-08-21 19:00:27 -07:00
markup = "" .. l["title"] .. "",
2022-03-19 10:59:04 -07:00
align = "left",
valign = "center",
2023-08-21 19:00:27 -07:00
font = config.core.font.normal_large,
2022-03-19 10:59:04 -07:00
widget = wibox.widget.textbox
},
layout = wibox.container.background,
}
l["widget_text"].bg = "#00000000"
popup.widget:add_widget_at(l["widget_text"], k, 1, 1, 1)
--popup.widget:add_widget_at(l["widget_checkbox"], k, 1, 1, 1)
--popup.widget:add_widget_at(l["widget_text"], k, 2, 0, 1)
2021-08-01 07:24:26 -07:00
end
popup.update = function()
-- Update checkmarks
for _, l in pairs(config.ibus.language_list) do
if (util.current_engine == l["ibus_engine"]) then
2022-03-19 10:59:04 -07:00
l["widget_text"].bg = "#FF0000"
else
l["widget_text"].bg = "#00000000"
end
l["widget_checkbox"].checked = (util.current_engine == l["ibus_engine"])
2021-08-01 07:24:26 -07:00
end
-- Show popup
popup.popup.screen = awful.screen.focused()
popup.popup.visible = true
popup.popup_timer:again()
2021-08-01 07:24:26 -07:00
end
popup.popup = awful.popup {
2021-08-01 07:24:26 -07:00
widget = {
{
popup.widget,
2021-08-01 07:24:26 -07:00
margins = 10,
widget = wibox.container.margin
},
bg = "#000000",
opacity = 1,
widget = wibox.container.background
},
border_color = "#000000",
border_width = 0,
opacity = 1,
type = "menu",
ontop = true,
visible = false,
hide_on_right_click = true,
2022-03-19 10:59:04 -07:00
shape = gears.shape.rectangle,
2021-08-01 07:24:26 -07:00
placement = function(d)
return awful.placement.bottom_right(
d,
{
honor_workarea = true
}
)
2021-08-01 07:24:26 -07:00
end,
}
popup.popup_timer = gears.timer {
2021-08-01 07:24:26 -07:00
timeout = 1,
autostart = false,
call_now = false,
single_shot = true,
callback = function()
popup.popup.visible = false
2021-08-01 07:24:26 -07:00
end
}
return popup