130 lines
2.7 KiB
Lua
130 lines
2.7 KiB
Lua
local language = {}
|
|
|
|
|
|
language.language_list = conf.ibus_language_list
|
|
|
|
|
|
language.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(language.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"
|
|
|
|
language.widget:add_widget_at(l["widget_text"], k, 1, 1, 1)
|
|
--language.widget:add_widget_at(l["widget_checkbox"], k, 1, 1, 1)
|
|
--language.widget:add_widget_at(l["widget_text"], k, 2, 0, 1)
|
|
end
|
|
|
|
language.next = function()
|
|
if (language.popup.visible) then
|
|
wrapper.ibus.next(function()
|
|
language.update_checks()
|
|
end)
|
|
else
|
|
language.update_checks()
|
|
end
|
|
|
|
language.show_popup()
|
|
end
|
|
|
|
language.set = function(idx)
|
|
wrapper.ibus.set(idx, function()
|
|
language.update_checks()
|
|
end)
|
|
language.show_popup()
|
|
end
|
|
|
|
language.update_checks = function()
|
|
for _, l in pairs(language.language_list) do
|
|
if (wrapper.ibus.current_engine == l["ibus_engine"]) then
|
|
l["widget_text"].bg = "#FF0000"
|
|
else
|
|
l["widget_text"].bg = "#00000000"
|
|
end
|
|
l["widget_checkbox"].checked = (wrapper.ibus.current_engine == l["ibus_engine"])
|
|
end
|
|
end
|
|
|
|
language.show_popup = function()
|
|
language.popup.screen = awful.screen.focused()
|
|
language.popup.visible = true
|
|
|
|
language.popup_timer:again()
|
|
end
|
|
|
|
language.popup = awful.popup {
|
|
widget = {
|
|
{
|
|
language.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,
|
|
}
|
|
|
|
language.popup_timer = gears.timer {
|
|
timeout = 1,
|
|
autostart = false,
|
|
call_now = false,
|
|
single_shot = true,
|
|
|
|
callback = function()
|
|
language.popup.visible = false
|
|
end
|
|
}
|
|
|
|
|
|
return language
|