2022-07-16 14:13:03 -07:00
|
|
|
local popup = {}
|
|
|
|
local util = req_rel(..., "util")
|
2021-08-01 07:24:26 -07:00
|
|
|
|
|
|
|
|
2022-07-16 14:13:03 -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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-07-16 19:06:55 -07:00
|
|
|
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 {
|
|
|
|
{
|
|
|
|
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"
|
|
|
|
|
2022-07-16 14:13:03 -07:00
|
|
|
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
|
|
|
|
|
2022-07-16 14:13:03 -07:00
|
|
|
popup.update = function()
|
|
|
|
-- Update checkmarks
|
2022-07-16 19:06:55 -07:00
|
|
|
for _, l in pairs(config.ibus.language_list) do
|
2022-07-16 14:13:03 -07:00
|
|
|
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
|
2022-07-16 14:13:03 -07:00
|
|
|
l["widget_checkbox"].checked = (util.current_engine == l["ibus_engine"])
|
2021-08-01 07:24:26 -07:00
|
|
|
end
|
|
|
|
|
2022-07-16 14:13:03 -07:00
|
|
|
-- 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
|
|
|
|
|
2022-07-16 14:13:03 -07:00
|
|
|
|
|
|
|
popup.popup = awful.popup {
|
2021-08-01 07:24:26 -07:00
|
|
|
widget = {
|
|
|
|
{
|
2022-07-16 14:13:03 -07:00
|
|
|
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)
|
2022-07-16 14:13:03 -07:00
|
|
|
return awful.placement.bottom_right(
|
|
|
|
d,
|
|
|
|
{
|
|
|
|
honor_workarea = true
|
|
|
|
}
|
|
|
|
)
|
2021-08-01 07:24:26 -07:00
|
|
|
end,
|
|
|
|
}
|
|
|
|
|
2022-07-16 14:13:03 -07:00
|
|
|
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()
|
2022-07-16 14:13:03 -07:00
|
|
|
popup.popup.visible = false
|
2021-08-01 07:24:26 -07:00
|
|
|
end
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-07-16 14:13:03 -07:00
|
|
|
return popup
|