From b1dbbb00416aa09b5a1ab467dbeaaac04d9464fc Mon Sep 17 00:00:00 2001 From: Jajauma Date: Thu, 12 May 2016 00:17:40 +0300 Subject: [PATCH 1/2] naughty: display the client-supplied localized action description in UI According to the Desktop Notification specification document [1] the clients supply actions available along with a notification in a form of a list of pairs where first element is an identifier of an action and the second is a localized message that will be displayed to the user. Up to now the naughty code directly used the action identifier text as a part of the notification layout exposed to the user. This commit makes use of a localized action description for that purpose. 1) https://developer.gnome.org/notification-spec/ --- lib/naughty/dbus.lua | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/lib/naughty/dbus.lua b/lib/naughty/dbus.lua index 9f749f9df..fe0b694c4 100644 --- a/lib/naughty/dbus.lua +++ b/lib/naughty/dbus.lua @@ -137,24 +137,20 @@ capi.dbus.connect_signal("org.freedesktop.Notifications", function (data, appnam if actions then args.actions = {} - local actionid - -- create actions callbacks - for i , v in ipairs(actions) do - if i % 2 == 1 then - actionid = v - elseif actionid == "default" then + for i = 1,#actions,2 do + local action_id = actions[i] + local action_text = actions[i + 1] + + if action_id == "default" then args.run = function() sendActionInvoked(notification.id, "default") naughty.destroy(notification, naughty.notificationClosedReason.dismissedByUser) end - actionid = nil - elseif actionid ~= nil then - local action = actionid - args.actions[actionid] = function() - sendActionInvoked(notification.id, action) + elseif action_id ~= nil and action_text ~= nil then + args.actions[action_text] = function() + sendActionInvoked(notification.id, action_id) naughty.destroy(notification, naughty.notificationClosedReason.dismissedByUser) end - actionid = nil end end end From 4d7e8c804e02aa05b389c973fde198e8f89be578 Mon Sep 17 00:00:00 2001 From: Jajauma Date: Thu, 12 May 2016 00:50:06 +0300 Subject: [PATCH 2/2] naughty: change action markup to emphasize clickability This commit changes the markup applied to the action description text to emphasize the fact that the action zone is actually clickable. Bold is replaced with underline, the Unicode 261B symbol (right pointer) is added as well. --- lib/naughty/core.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/naughty/core.lua b/lib/naughty/core.lua index be2f46ae2..24f7c9606 100644 --- a/lib/naughty/core.lua +++ b/lib/naughty/core.lua @@ -543,7 +543,7 @@ function naughty.notify(args) actionmarginbox:set_widget(actiontextbox) actiontextbox:set_valign("middle") actiontextbox:set_font(font) - actiontextbox:set_markup(string.format('%s', action)) + actiontextbox:set_markup(string.format('☛ %s', action)) -- calculate the height and width local w, h = actiontextbox:get_preferred_size(s) local action_height = h + 2 * margin