notification: Add an `append_actions` method.

The name is self explanatory, it adds more actions to a notification.

One of the use case is adding a snooze/reming_me action. Another one
is "mute similar notifications".
This commit is contained in:
Emmanuel Lepage Vallee 2019-07-17 00:40:40 -04:00
parent e524f93baa
commit 1bd2c1977e
1 changed files with 15 additions and 0 deletions

View File

@ -669,6 +669,21 @@ function notification.set_actions(self, new_actions)
end end
end end
--- Add more actions to the notification.
-- @method append_actions
-- @tparam table new_actions
function notification:append_actions(new_actions)
self._private.actions = self._private.actions or {}
for _, a in ipairs(new_actions or {}) do
a:connect_signal("_changed", self._private.action_cb )
a:connect_signal("invoked" , self._private.invoked_cb)
table.insert(self._private.actions, a)
end
end
--TODO v6: remove this --TODO v6: remove this
local function convert_actions(actions) local function convert_actions(actions)
gdebug.deprecate( gdebug.deprecate(