From 1b567cc06a7cae4ed5b005e1c089a03dfa154778 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Fri, 4 Jan 2019 04:39:07 -0500 Subject: [PATCH] notification: Rename text to message There is many "text" and the default text is the title, not the body. --- awesomerc.lua | 12 ++++---- lib/awful/spawn.lua | 6 ++-- lib/naughty/core.lua | 4 +-- lib/naughty/dbus.lua | 4 +-- lib/naughty/layout/legacy.lua | 4 +-- lib/naughty/notification.lua | 29 +++++++++++++++++-- .../text/awful/keygrabber/autostart.lua | 2 +- .../wibox/awidget/prompt/keypress.lua | 2 +- .../examples/wibox/awidget/prompt/simple.lua | 2 +- tests/test-screen-changes.lua | 3 +- 10 files changed, 46 insertions(+), 22 deletions(-) diff --git a/awesomerc.lua b/awesomerc.lua index 0bc0432c..fa584b8a 100644 --- a/awesomerc.lua +++ b/awesomerc.lua @@ -25,9 +25,9 @@ require("awful.hotkeys_popup.keys") -- another config (This code will only ever execute for the fallback config) if awesome.startup_errors then naughty.notification { - preset = naughty.config.presets.critical, - title = "Oops, there were errors during startup!", - text = awesome.startup_errors + preset = naughty.config.presets.critical, + title = "Oops, there were errors during startup!", + message = awesome.startup_errors } end @@ -40,9 +40,9 @@ do in_error = true naughty.notification { - preset = naughty.config.presets.critical, - title = "Oops, an error happened!", - text = tostring(err) + preset = naughty.config.presets.critical, + title = "Oops, an error happened!", + message = tostring(err) } in_error = false diff --git a/lib/awful/spawn.lua b/lib/awful/spawn.lua index 37b634c1..6474d628 100644 --- a/lib/awful/spawn.lua +++ b/lib/awful/spawn.lua @@ -132,17 +132,17 @@ -- -- awful.spawn.with_line_callback(noisy, { -- stdout = function(line) --- naughty.notification { text = "LINE:"..line } +-- naughty.notification { message = "LINE:"..line } -- end, -- stderr = function(line) --- naughty.notification { text = "ERR:"..line} +-- naughty.notification { message = "ERR:"..line} -- end, -- }) -- -- If only the full output is needed, then `easy_async` is the right choice: -- -- awful.spawn.easy_async(noisy, function(stdout, stderr, reason, exit_code) --- naughty.notification { text = stdout } +-- naughty.notification { message = stdout } -- end) -- -- **Default applications**: diff --git a/lib/naughty/core.lua b/lib/naughty/core.lua index 66831015..9eae64c3 100644 --- a/lib/naughty/core.lua +++ b/lib/naughty/core.lua @@ -334,7 +334,7 @@ end --- Replace title and text of an existing notification. -- --- This function is deprecated, use `notification.text = new_text` and +-- This function is deprecated, use `notification.message = new_text` and -- `notification.title = new_title` -- -- @tparam notification notification Notification object, which contents are to be replaced. @@ -533,7 +533,7 @@ end -- @tparam[opt] table args.actions A list of `naughty.action`s. -- @bool[opt=false] args.ignore_suspend If set to true this notification -- will be shown even if notifications are suspended via `naughty.suspend`. --- @usage naughty.notify({ title = "Achtung!", text = "You're idling", timeout = 0 }) +-- @usage naughty.notify({ title = "Achtung!", message = "You're idling", timeout = 0 }) -- @treturn ?table The notification object, or nil in case a notification was -- not displayed. -- @deprecated naughty.notify diff --git a/lib/naughty/dbus.lua b/lib/naughty/dbus.lua index 89ff9b94..8b86cd1b 100644 --- a/lib/naughty/dbus.lua +++ b/lib/naughty/dbus.lua @@ -122,13 +122,13 @@ capi.dbus.connect_signal("org.freedesktop.Notifications", local args = { } if data.member == "Notify" then if text ~= "" then - args.text = text + args.message = text if title ~= "" then args.title = title end else if title ~= "" then - args.text = title + args.message = title else return end diff --git a/lib/naughty/layout/legacy.lua b/lib/naughty/layout/legacy.lua index c46c96eb..0e20f066 100644 --- a/lib/naughty/layout/legacy.lua +++ b/lib/naughty/layout/legacy.lua @@ -135,7 +135,7 @@ local escape_subs = { ['<'] = "<", ['>'] = ">", ['&'] = "&" } -- Cache the markup local function set_escaped_text(self) - local text, title = self.text or "", self.title or "" + local text, title = self.message or "", self.title or "" if title then title = title .. "\n" else title = "" end @@ -291,7 +291,7 @@ function naughty.default_notification_handler(notification, args) end local preset = notification.preset - local text = args.text or preset.text + local text = args.message or args.text or preset.message or preset.text local title = args.title or preset.title local s = get_screen(args.screen or preset.screen or screen.focused()) diff --git a/lib/naughty/notification.lua b/lib/naughty/notification.lua index 83841e75..ac229e40 100644 --- a/lib/naughty/notification.lua +++ b/lib/naughty/notification.lua @@ -20,6 +20,7 @@ local gtable = require("gears.table") local timer = require("gears.timer") local cst = require("naughty.constants") local naughty = require("naughty.core") +local gdebug = require("gears.debug") local notification = {} @@ -309,8 +310,24 @@ function notification:set_timeout(timeout) self._private.timeout = timeout end +function notification:set_text(txt) + gdebug.deprecate( + "The `text` attribute is deprecated, use `message`", + {deprecated_in=5} + ) + self:set_message(txt) +end + +function notification:get_text() + gdebug.deprecate( + "The `text` attribute is deprecated, use `message`", + {deprecated_in=5} + ) + return self:get_message() +end + local properties = { - "text" , "title" , "timeout" , "hover_timeout" , + "message" , "title" , "timeout" , "hover_timeout" , "screen" , "position", "ontop" , "border_width" , "width" , "font" , "icon" , "icon_size" , "fg" , "bg" , "height" , "border_color" , @@ -417,7 +434,7 @@ end -- @tparam[opt] table args.actions A list of `naughty.action`s. -- @bool[opt=false] args.ignore_suspend If set to true this notification -- will be shown even if notifications are suspended via `naughty.suspend`. --- @usage naughty.notify({ title = "Achtung!", text = "You're idling", timeout = 0 }) +-- @usage naughty.notify({ title = "Achtung!", message = "You're idling", timeout = 0 }) -- @treturn ?table The notification object, or nil in case a notification was -- not displayed. -- @function naughty.notification @@ -441,6 +458,14 @@ local function create(args) enable_properties = true, } + if args.text then + gdebug.deprecate( + "The `text` attribute is deprecated, use `message`", + {deprecated_in=5} + ) + args.message = args.text + end + assert(naughty.emit_signal) -- Make sure all signals bubble up n:_connect_everything(naughty.emit_signal) diff --git a/tests/examples/text/awful/keygrabber/autostart.lua b/tests/examples/text/awful/keygrabber/autostart.lua index d8814c66..f490b3e9 100644 --- a/tests/examples/text/awful/keygrabber/autostart.lua +++ b/tests/examples/text/awful/keygrabber/autostart.lua @@ -11,7 +11,7 @@ awful.keygrabber { stop_callback = function(_, _, _, sequence) autostart_works = true --DOC_HIDE assert(sequence == "abc") --DOC_HIDE - naughty.notification {text="The keys were:"..sequence} + naughty.notification {message="The keys were:"..sequence} end, } diff --git a/tests/examples/wibox/awidget/prompt/keypress.lua b/tests/examples/wibox/awidget/prompt/keypress.lua index 23254042..9b8943a3 100644 --- a/tests/examples/wibox/awidget/prompt/keypress.lua +++ b/tests/examples/wibox/awidget/prompt/keypress.lua @@ -15,7 +15,7 @@ local naughty = {} --DOC_HIDE prompt = "Run: ", keypressed_callback = function(mod, key, cmd) --luacheck: no unused args if key == "Shift_L" then - notif = naughty.notification { text = "Shift pressed" } + notif = naughty.notification { message = "Shift pressed" } end end, keyreleased_callback = function(mod, key, cmd) --luacheck: no unused args diff --git a/tests/examples/wibox/awidget/prompt/simple.lua b/tests/examples/wibox/awidget/prompt/simple.lua index 8e64d1fc..df5287c5 100644 --- a/tests/examples/wibox/awidget/prompt/simple.lua +++ b/tests/examples/wibox/awidget/prompt/simple.lua @@ -18,7 +18,7 @@ local naughty = {} --DOC_HIDE textbox = atextbox, exe_callback = function(input) if not input or #input == 0 then return end - naughty.notification { text = "The input was: "..input } + naughty.notification { message = "The input was: "..input } end } end diff --git a/tests/test-screen-changes.lua b/tests/test-screen-changes.lua index c12bc966..7e24e25f 100644 --- a/tests/test-screen-changes.lua +++ b/tests/test-screen-changes.lua @@ -31,8 +31,7 @@ local steps = { fake_screen.selected_tag.layout = max -- Display a notification on the screen-to-be-removed - naughty.notification { text = "test", screen = fake_screen } - + naughty.notification { message = "test", screen = fake_screen } return true end end,