From 9cf717b994abbb7bae96b5e1c26621d9cd295be6 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sat, 14 Mar 2020 20:21:35 -0400 Subject: [PATCH] naughty: Replace request::icon by request::action_icon. It wasn't a good idea to use ::icon because sometime the notification themselves needs to request assistance for their icons. --- lib/naughty/core.lua | 13 +++++++++++-- lib/naughty/dbus.lua | 2 +- tests/test-naughty-legacy.lua | 7 +++---- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/lib/naughty/core.lua b/lib/naughty/core.lua index 7a03d6309..6f0db7ffb 100644 --- a/lib/naughty/core.lua +++ b/lib/naughty/core.lua @@ -561,9 +561,18 @@ naughty.connect_signal("request::screen", naughty.default_screen_handler) -- If an icon is found, the handler must set the `icon` property on the `action` -- object to a path or a `gears.surface`. -- --- @signal request::icon +-- There is no implementation by default. To use the XDG-icon, the common +-- implementation will be: +-- +-- naughty.connect_signal("request::action_icon", function(a, context, hints) +-- a.icon = menubar.utils.lookup_icon(hints.id) +-- end) +-- +-- @signal request::action_icon -- @tparam naughty.action action The action. --- @tparam string icon_name The icon name. +-- @tparam string context The context. +-- @tparam table hints +-- @tparam string args.id The action id. This will often by the (XDG) icon name. --- Emitted when the screen is not defined or being removed. -- @signal request::screen diff --git a/lib/naughty/dbus.lua b/lib/naughty/dbus.lua index ce7faea22..aa4e8b279 100644 --- a/lib/naughty/dbus.lua +++ b/lib/naughty/dbus.lua @@ -173,7 +173,7 @@ function notif_methods.Notify(sender, object_path, interface, method, parameters -- and `naughty` doesn't depend on `menubar`, so delegate the -- icon "somewhere" using a request. if hints["action-icons"] and action_id ~= "" then - naughty.emit_signal("request::icon", a, action_id) + naughty.emit_signal("request::action_icon", a, "dbus", {id = action_id}) end a:connect_signal("invoked", function() diff --git a/tests/test-naughty-legacy.lua b/tests/test-naughty-legacy.lua index 945ca7798..7fc043a90 100644 --- a/tests/test-naughty-legacy.lua +++ b/tests/test-naughty-legacy.lua @@ -892,10 +892,9 @@ local icon_requests = {} table.insert(steps, function() assert(#active == 0) - naughty.connect_signal("request::icon", function(a, icon_name) - icon_requests[icon_name] = a - - a.icon = icon_name == "list-add" and small_icon or big_icon + naughty.connect_signal("request::action_icon", function(a, context, hints) + icon_requests[hints.id] = a + a.icon = hints.id == "list-add" and small_icon or big_icon end) local hints = {