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 |
|
| radius | 8 | The popup radius |
|
||||||
| start_sunday | false | Start the week on Sunday |
|
| start_sunday | false | Start the week on Sunday |
|
||||||
| week_numbers | false | Show ISO week numbers (Mon = first) |
|
| 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:
|
- themes:
|
||||||
|
|
||||||
|
|
|
@ -203,6 +203,23 @@ local function worker(user_args)
|
||||||
border_color = calendar_themes[theme].border,
|
border_color = calendar_themes[theme].border,
|
||||||
widget = cal
|
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(
|
popup:buttons(
|
||||||
awful.util.table.join(
|
awful.util.table.join(
|
||||||
|
@ -226,6 +243,7 @@ local function worker(user_args)
|
||||||
function calendar_widget.toggle()
|
function calendar_widget.toggle()
|
||||||
|
|
||||||
if popup.visible then
|
if popup.visible then
|
||||||
|
auto_hide_timer:stop()
|
||||||
-- to faster render the calendar refresh it and just hide
|
-- 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(nil) -- the new date is not set without removing the old one
|
||||||
cal:set_date(os.date('*t'))
|
cal:set_date(os.date('*t'))
|
||||||
|
@ -250,6 +268,10 @@ local function worker(user_args)
|
||||||
end
|
end
|
||||||
|
|
||||||
popup.visible = true
|
popup.visible = true
|
||||||
|
if user_args.auto_hide then
|
||||||
|
auto_hide_timer:start()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue