Merge pull request #452 from maverick1872/patch-1
feat(calendar): add auto hide functionality
This commit is contained in:
commit
68ddbd9812
|
@ -14,6 +14,8 @@ Calendar widget for Awesome WM - slightly improved version of the `wibox.widget.
|
|||
| radius | 8 | The popup radius |
|
||||
| start_sunday | false | Start the week on Sunday |
|
||||
| week_numbers | false | Show ISO week numbers (Mon = first) |
|
||||
| auto_hide | false | Auto hide the popup after timeout |
|
||||
| timeout | 2 | Auto hide timeout length |
|
||||
|
||||
- themes:
|
||||
|
||||
|
|
|
@ -204,6 +204,23 @@ local function worker(user_args)
|
|||
widget = cal
|
||||
}
|
||||
|
||||
local auto_hide_timer = gears.timer({
|
||||
timeout = user_args.timeout or 2,
|
||||
single_shot = true,
|
||||
callback = function()
|
||||
calendar_widget.toggle()
|
||||
end,
|
||||
})
|
||||
|
||||
popup:connect_signal("mouse::leave", function()
|
||||
if user_args.auto_hide then
|
||||
auto_hide_timer:again()
|
||||
end
|
||||
end)
|
||||
popup:connect_signal("mouse::enter", function()
|
||||
auto_hide_timer:stop()
|
||||
end)
|
||||
|
||||
popup:buttons(
|
||||
awful.util.table.join(
|
||||
awful.button({}, next_month_button, function()
|
||||
|
@ -226,6 +243,7 @@ local function worker(user_args)
|
|||
function calendar_widget.toggle()
|
||||
|
||||
if popup.visible then
|
||||
auto_hide_timer:stop()
|
||||
-- to faster render the calendar refresh it and just hide
|
||||
cal:set_date(nil) -- the new date is not set without removing the old one
|
||||
cal:set_date(os.date('*t'))
|
||||
|
@ -250,6 +268,10 @@ local function worker(user_args)
|
|||
end
|
||||
|
||||
popup.visible = true
|
||||
if user_args.auto_hide then
|
||||
auto_hide_timer:start()
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue