112 lines
2.3 KiB
Lua
112 lines
2.3 KiB
Lua
local popup = {}
|
|
local util = req_rel(..., "util")
|
|
|
|
|
|
popup.widget = wibox.widget {
|
|
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
|
|
|
|
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,
|
|
}
|
|
|
|
l["widget_text"] = wibox.widget {
|
|
{
|
|
markup = "<b>" .. l["title"] .. "</b>",
|
|
align = "left",
|
|
valign = "center",
|
|
font = "Comfortaa 16",
|
|
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)
|
|
end
|
|
|
|
popup.update = function()
|
|
-- Update checkmarks
|
|
for _, l in pairs(config.ibus.language_list) do
|
|
if (util.current_engine == l["ibus_engine"]) then
|
|
l["widget_text"].bg = "#FF0000"
|
|
else
|
|
l["widget_text"].bg = "#00000000"
|
|
end
|
|
l["widget_checkbox"].checked = (util.current_engine == l["ibus_engine"])
|
|
end
|
|
|
|
-- Show popup
|
|
popup.popup.screen = awful.screen.focused()
|
|
popup.popup.visible = true
|
|
popup.popup_timer:again()
|
|
end
|
|
|
|
|
|
popup.popup = awful.popup {
|
|
widget = {
|
|
{
|
|
popup.widget,
|
|
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,
|
|
|
|
shape = gears.shape.rectangle,
|
|
placement = function(d)
|
|
return awful.placement.bottom_right(
|
|
d,
|
|
{
|
|
honor_workarea = true
|
|
}
|
|
)
|
|
end,
|
|
}
|
|
|
|
popup.popup_timer = gears.timer {
|
|
timeout = 1,
|
|
autostart = false,
|
|
call_now = false,
|
|
single_shot = true,
|
|
|
|
callback = function()
|
|
popup.popup.visible = false
|
|
end
|
|
}
|
|
|
|
|
|
return popup
|