From 1bd2c1977e52f983e7319e47c69d557c077c492d Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Wed, 17 Jul 2019 00:40:40 -0400 Subject: [PATCH] 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". --- lib/naughty/notification.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/naughty/notification.lua b/lib/naughty/notification.lua index b1a89b08c..985c1589f 100644 --- a/lib/naughty/notification.lua +++ b/lib/naughty/notification.lua @@ -669,6 +669,21 @@ function notification.set_actions(self, new_actions) 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 local function convert_actions(actions) gdebug.deprecate(