tests: Test the new naughty.widgets

This commit also add some "magic" comments to existing tests so they
render correctly. Note that some older commits predates these "magic"
comments, which is why they are not there.
This commit is contained in:
Emmanuel Lepage Vallee 2017-08-13 02:54:03 -04:00
parent 9be03b528c
commit c97cb5c282
25 changed files with 891 additions and 26 deletions

View File

@ -0,0 +1,31 @@
--DOC_GEN_IMAGE --DOC_NO_USAGE
require("_default_look") --DOC_HIDE
local awful = {wibar = require("awful.wibar")} --DOC_HIDE
local naughty = require("naughty") --DOC_HIDE
screen[1]._resize {width = 640, height = 240} --DOC_HIDE
local some_wibar = awful.wibar {position = "bottom", height = 48, visible = true} --DOC_HIDE
--DOC_NEWLINE
-- A notification popup using the default widget_template.
naughty.connect_signal("request::display", function(n)
naughty.layout.box {notification = n}
end)
--DOC_NEWLINE
-- Notifications as widgets for any `wibox`/`awful.wibar`/`awful.popup`
some_wibar.widget = naughty.list.notifications {}
--DOC_NEWLINE
for _, color in ipairs {"#ff0000", "#00ff00", "#0000ff"} do
naughty.notification {
title = "A ".. color .." notification",
bg = color,
}
end
require("gears.timer").run_delayed_calls_now()

View File

@ -0,0 +1,32 @@
--DOC_GEN_IMAGE --DOC_NO_USAGE
require("_default_look") --DOC_HIDE
local awful = {wibar = require("awful.wibar")} --DOC_HIDE
local naughty = require("naughty") --DOC_HIDE
screen[1]._resize {width = 640, height = 240} --DOC_HIDE
local some_wibar = awful.wibar {position = "bottom", height = 48, visible = true} --DOC_HIDE
--DOC_NEWLINE
-- A notification popup using the default widget_template.
naughty.connect_signal("request::display", function(n)
naughty.layout.box {notification = n}
end)
--DOC_NEWLINE
-- Notifications as widgets for any `wibox`/`awful.wibar`/`awful.popup`
some_wibar.widget = naughty.list.notifications {}
--DOC_NEWLINE
for bw, color in ipairs {"#ff0000", "#00ff00", "#0000ff"} do
naughty.notification {
title = "A ".. color .." notification",
border_color = color,
border_width = bw*2,
}
end
require("gears.timer").run_delayed_calls_now()

View File

@ -0,0 +1,37 @@
--DOC_HIDE --DOC_GEN_IMAGE --DOC_NO_USAGE
local naughty = require("naughty") --DOC_HIDE
screen[1]._resize {width = 640, height = 480} --DOC_HIDE
require("_date") --DOC_HIDE
require("_default_look") --DOC_HIDE
local function ever_longer_messages(iter) --DOC_HIDE
local ret = "content! " --DOC_HIDE
for _=1, iter do --DOC_HIDE
ret = ret.."more! " --DOC_HIDE
end --DOC_HIDE
return ret --DOC_HIDE
end --DOC_HIDE
--DOC_NEWLINE
naughty.connect_signal("request::display", function(n) --DOC_HIDE
naughty.layout.box {notification = n} --DOC_HIDE
end) --DOC_HIDE
--DOC_NEWLINE
for _, pos in ipairs {
"top_left" , "top_middle" , "top_right",
"bottom_left", "bottom_middle", "bottom_right",
} do
for i=1, 3 do
naughty.notification {
position = pos,
title = pos .. " " .. i,
message = ever_longer_messages(i)
}
end
end
--DOC_HIDE vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

View File

@ -0,0 +1,4 @@
====================VVVVVV table: 0x5602abbcedd0

View File

@ -1,4 +1,5 @@
--DOC_HIDE_ALL
--DOC_GEN_IMAGE
local naughty = require("naughty") --DOC_HIDE
for _, pos in ipairs {
@ -13,7 +14,7 @@ for _, pos in ipairs {
naughty.notify {
title = pos,
position = pos,
text = "",
message = "",
}
end

View File

@ -0,0 +1,32 @@
--DOC_GEN_IMAGE --DOC_NO_USAGE
require("_default_look") --DOC_HIDE
local awful = {wibar = require("awful.wibar")} --DOC_HIDE
local naughty = require("naughty") --DOC_HIDE
screen[1]._resize {width = 640, height = 240} --DOC_HIDE
local some_wibar = awful.wibar {position = "bottom", height = 48, visible = true} --DOC_HIDE
--DOC_NEWLINE
-- A notification popup using the default widget_template.
naughty.connect_signal("request::display", function(n)
naughty.layout.box {notification = n}
end)
--DOC_NEWLINE
-- Notifications as widgets for any `wibox`/`awful.wibar`/`awful.popup`
some_wibar.widget = naughty.list.notifications {}
--DOC_NEWLINE
for _, color in ipairs {"#ff0000", "#00ff00", "#0000ff"} do
naughty.notification {
title = "A ".. color .." notification",
message = "Message",
fg = color,
}
end
require("gears.timer").run_delayed_calls_now()

View File

@ -0,0 +1,30 @@
--DOC_HIDE --DOC_GEN_IMAGE --DOC_NO_USAGE
local naughty = require("naughty") --DOC_HIDE
screen[1]._resize {width = 640, height = 480} --DOC_HIDE
require("_date") --DOC_HIDE
require("_default_look") --DOC_HIDE
naughty.connect_signal("request::display", function(n) --DOC_HIDE
naughty.layout.box {notification = n} --DOC_HIDE
end) --DOC_HIDE
--DOC_NEWLINE
for _, pos in ipairs {
"top_left" , "top_middle" , "top_right",
"bottom_left", "bottom_middle", "bottom_right",
} do
for i=1, 2 do
naughty.notification {
position = pos,
title = pos .. " " .. i,
width = 50*i,
height = 50*i,
message = "This is a very, very, very, "..
"very, very very long message",
}
end
end
--DOC_HIDE vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

View File

@ -0,0 +1,40 @@
--DOC_GEN_IMAGE --DOC_NO_USAGE
require("_default_look") --DOC_HIDE
local awful = {wibar = require("awful.wibar")} --DOC_HIDE
local wibox = require("wibox") --DOC_HIDE
local naughty = require("naughty") --DOC_HIDE
local beautiful = require("beautiful") --DOC_HIDE
screen[1]._resize {width = 640, height = 240} --DOC_HIDE
local some_wibar = awful.wibar {position = "bottom", height = 48, visible = true} --DOC_HIDE
--DOC_NEWLINE
-- A notification popup using the default widget_template.
naughty.connect_signal("request::display", function(n)
naughty.layout.box {notification = n}
end)
--DOC_NEWLINE
-- Notifications as widgets for any `wibox`/`awful.wibar`/`awful.popup`
some_wibar.widget = naughty.list.notifications {
base_layout = wibox.widget {
spacing = beautiful.notification_spacing,
layout = wibox.layout.fixed.horizontal
},
}
--DOC_NEWLINE
for margin = 10, 20, 5 do
naughty.notification {
title = "A notification",
margin = margin,
border_width = 1,
border_color = "#ff0000",
}
end
require("gears.timer").run_delayed_calls_now()

View File

@ -0,0 +1,129 @@
--DOC_GEN_IMAGE
--DOC_NO_USAGE
require("_date") --DOC_HIDE
require("_default_look") --DOC_HIDE
local awful = require("awful") --DOC_HIDE
local gears = require("gears") --DOC_HIDE
local wibox = require("wibox") --DOC_HIDE
local beautiful = require("beautiful") --DOC_HIDE
local naughty = require("naughty") --DOC_HIDE
screen[1]._resize {width = 640, height = 240} --DOC_HIDE
--DOC_HIDE Give some context, otherwise it doesn't look like a screen
local c = client.gen_fake {hide_first=true} --DOC_HIDE
c:geometry { x = 50, y = 45, height = 100, width = 250} --DOC_HIDE
c._old_geo = {c:geometry()} --DOC_HIDE
c:set_label("A client") --DOC_HIDE
c:emit_signal("request::titlebars", "rules", {})--DOC_HIDE
beautiful.notification_icon_size = 48 --DOC_HIDE
beautiful.notification_action_label_only = true --DOC_HIDE
--DOC_NEWLINE
-- This awful.wibar will be placed at the bottom and contain the notifications.
local notif_wb = awful.wibar {
position = "bottom",
height = 48,
visible = #naughty.active > 0,
}
--DOC_NEWLINE
notif_wb:setup {
nil,
{
base_layout = wibox.widget {
spacing_widget = wibox.widget {
orientation = "vertical",
span_ratio = 0.5,
widget = wibox.widget.separator,
},
forced_height = 30,
spacing = 3,
layout = wibox.layout.flex.horizontal
},
widget_template = {
{
naughty.widget.icon,
{
naughty.widget.title,
naughty.widget.message,
{
layout = wibox.widget {
-- Adding the `wibox.widget` allows to share a
-- single instance for all spacers.
spacing_widget = wibox.widget {
orientation = "vertical",
span_ratio = 0.9,
widget = wibox.widget.separator,
},
spacing = 3,
layout = wibox.layout.flex.horizontal
},
widget = naughty.list.widgets,
},
layout = wibox.layout.align.vertical
},
spacing = 10,
fill_space = true,
layout = wibox.layout.fixed.horizontal
},
margins = 5,
widget = wibox.container.margin
},
widget = naughty.list.notifications,
},
-- Add a button to dismiss all notifications, because why not.
{
{
text = "Dismiss all",
align = "center",
valign = "center",
widget = wibox.widget.textbox
},
buttons = gears.table.join(
awful.button({ }, 1, function() naughty.destroy_all_notifications() end)
),
forced_width = 75,
shape = gears.shape.rounded_bar,
shape_border_width = 1,
shape_border_color = beautiful.bg_highlight,
widget = wibox.container.background
},
layout = wibox.layout.align.horizontal
}
--DOC_NEWLINE
-- We don't want to have that bar all the time, only when there is content.
naughty.connect_signal("property::active", function()
notif_wb.visible = #naughty.active > 0
end)
--DOC_HIDE The delayed make sure the legacy popup gets disabled in time
gears.timer.run_delayed_calls_now()--DOC_HIDE
for i=1, 3 do --DOC_HIDE
naughty.notification { --DOC_HIDE
title = "A notification "..i, --DOC_HIDE
text = "Be notified! "..i, --DOC_HIDE
icon = i%2 == 1 and beautiful.awesome_icon, --DOC_HIDE
timeout = 999, --DOC_HIDE
actions = { --DOC_HIDE
naughty.action { --DOC_HIDE
name = "Accept "..i, --DOC_HIDE
icon = beautiful.awesome_icon, --DOC_HIDE
}, --DOC_HIDE
naughty.action { --DOC_HIDE
name = "Refuse", --DOC_HIDE
icon = beautiful.awesome_icon, --DOC_HIDE
}, --DOC_HIDE
} --DOC_HIDE
} --DOC_HIDE
end --DOC_HIDE
require("gears.timer").run_delayed_calls_now()

View File

@ -0,0 +1,42 @@
--DOC_GEN_IMAGE --DOC_NO_USAGE
require("_default_look") --DOC_HIDE
local gears = {shape = require("gears.shape")} --DOC_HIDE
local awful = {wibar = require("awful.wibar")} --DOC_HIDE
local naughty = require("naughty") --DOC_HIDE
screen[1]._resize {width = 640, height = 240} --DOC_HIDE
local some_wibar = awful.wibar {position = "bottom", height = 48, visible = true} --DOC_HIDE
--DOC_NEWLINE
-- A notification popup using the default widget_template.
naughty.connect_signal("request::display", function(n)
naughty.layout.box {notification = n}
end)
--DOC_NEWLINE
-- Notifications as widgets for any `wibox`/`awful.wibar`/`awful.popup`
some_wibar.widget = naughty.list.notifications {}
--DOC_NEWLINE
local shapes = {
gears.shape.octogon,
gears.shape.rounded_rect,
gears.shape.rounded_bar
}
--DOC_NEWLINE
for idx=1, 3 do
naughty.notification {
title = "A notification",
border_color = "#0000ff",
border_width = idx*2,
shape = shapes[idx],
}
end
require("gears.timer").run_delayed_calls_now()

View File

@ -5,6 +5,7 @@
require("_date")
local awful = require("awful")
local gears = require("gears")
local naughty = require("naughty")
local wibox = require("wibox")
local beautiful = require("beautiful") --DOC_HIDE
local look = require("_default_look")
@ -136,6 +137,7 @@ local function create_info(text, x, y, width, height)
text = text,
align = "center",
ellipsize = "none",
wrap = "word",
widget = wibox.widget.textbox
},
margins = 10,
@ -170,17 +172,29 @@ local function create_line(x1, y1, x2, y2)
}, {x=x1, y=y1})
end
create_info("awful.wibar", 200, 50, 100, 30)
naughty.connect_signal("request::display", function(n)
naughty.layout.box {notification = n}
end)
naughty.notification {
title = "A notification",
message = "With a message! ....",
position = "top_middle",
}
create_info("awful.wibar", 100, 50, 100, 30)
create_info("awful.titlebar", 250, 350, 100, 30)
create_info("awful.tooltip", 30, 130, 100, 30)
create_info("awful.popup", 450, 240, 100, 30)
create_info("naughty.layout.box", 255, 110, 130, 30)
create_info("Standard `wibox`", 420, 420, 130, 30)
create_line(250, 10, 250, 55)
create_line(150, 10, 150, 55)
create_line(75, 100, 75, 135)
create_line(545, 432, 575, 432)
create_line(500, 165, 500, 245)
create_line(390, 250, 450, 250)
create_line(190, 365, 255, 365)
create_line(320, 60, 320, 110)
--DOC_HIDE vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

View File

@ -1,5 +1,6 @@
--DOC_NO_USAGE
--DOC_HIDE_ALL
--DOC_GEN_IMAGE
-- local naughty = require("naughty")
dbus.notify_send(

View File

@ -1,3 +1,4 @@
--DOC_GEN_IMAGE
local beautiful = require("beautiful") --DOC_HIDE
@ -5,7 +6,9 @@ local text = [[An <b>important</b>
<i>notification</i>
]]
require("naughty").notify {
--DOC_NEWLINE
require("naughty").notification {
title = "Hello world!",
text = text,
icon = beautiful.icon,

View File

@ -1,4 +1,5 @@
--DOC_HIDE_ALL
--DOC_GEN_IMAGE
-- local naughty = require("naughty")
dbus.notify_send(

View File

@ -1,31 +1,36 @@
--DOC_GEN_IMAGE --DOC_NO_USAGE
local beautiful = require("beautiful") --DOC_HIDE
local gears = {shape=require("gears.shape")} --DOC_HIDE
local naughty = require("naughty") --DOC_HIDE
local text = [[An <b>important</b>
<i>notification</i>
]]
local text = [[An <b>important</b>
<i>notification</i>
]]
local shapes = {
gears.shape.rounded_rect,
gears.shape.hexagon,
gears.shape.octogon,
function(cr, w, h)
return gears.shape.infobubble(cr, w, h, 20, 10, w/2 - 10)
end
}
--DOC_NEWLINE
for _, s in ipairs(shapes) do
naughty.notify {
title = "Hello world!",
text = text,
icon = beautiful.icon,
shape = s,
border_width = 3,
border_color = beautiful.bg_highlight,
margin = 15,
}
end
local shapes = {
gears.shape.rounded_rect,
gears.shape.hexagon,
gears.shape.octogon,
function(cr, w, h)
return gears.shape.infobubble(cr, w, h, 20, 10, w/2 - 10)
end
}
--DOC_NEWLINE
for _, s in ipairs(shapes) do
naughty.notify {
title = "Hello world!",
text = text,
icon = beautiful.icon,
shape = s,
border_width = 3,
border_color = beautiful.bg_highlight,
margin = 15,
}
end
--DOC_HIDE vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

View File

@ -1,3 +1,4 @@
--DOC_GEN_IMAGE
local file_path, image_path = ...
require("_common_template")(...)
local wibox = require("wibox")

View File

@ -0,0 +1,62 @@
--DOC_GEN_IMAGE
local parent = ... --DOC_HIDE --DOC_NO_USAGE
local naughty = { --DOC_HIDE
list = {actions = require("naughty.list.actions")}, --DOC_HIDE
notification = require("naughty.notification"), --DOC_HIDE
action = require("naughty.action") --DOC_HIDE
} --DOC_HIDE
local gears = {shape = require("gears.shape")} --DOC_HIDE
local wibox = require("wibox") --DOC_HIDE
local beautiful = require("beautiful") --DOC_HIDE
local notif = naughty.notification { --DOC_HIDE
title = "A notification", --DOC_HIDE
message = "This notification has actions!", --DOC_HIDE
actions = { --DOC_HIDE
naughty.action { --DOC_HIDE
name = "Accept", --DOC_HIDE
}, --DOC_HIDE
naughty.action { --DOC_HIDE
name = "Refuse", --DOC_HIDE
}, --DOC_HIDE
naughty.action { --DOC_HIDE
name = "Ignore", --DOC_HIDE
}, --DOC_HIDE
} --DOC_HIDE
} --DOC_HIDE
--DOC_NEWLINE
parent:add( wibox.container.background(--DOC_HIDE
wibox.widget {
notification = notif,
base_layout = wibox.widget {
spacing = 3,
spacing_widget = wibox.widget {
orientation = "horizontal",
widget = wibox.widget.separator,
},
layout = wibox.layout.fixed.vertical
},
widget_template = {
{
{
{
id = "text_role",
widget = wibox.widget.textbox
},
widget = wibox.container.place
},
shape = gears.shape.rounded_rect,
shape_border_width = 2,
shape_border_color = beautiful.bg_normal,
forced_height = 30,
widget = wibox.container.background,
},
margins = 4,
widget = wibox.container.margin,
},
forced_width = 100, --DOC_HIDE
widget = naughty.list.actions,
}
,beautiful.bg_normal)) --DOC_HIDE

View File

@ -0,0 +1,68 @@
--DOC_GEN_IMAGE
local parent = ... --DOC_HIDE --DOC_NO_USAGE
local naughty = { --DOC_HIDE
list = {actions = require("naughty.list.actions")}, --DOC_HIDE
notification = require("naughty.notification"), --DOC_HIDE
action = require("naughty.action") --DOC_HIDE
} --DOC_HIDE
local wibox = require("wibox") --DOC_HIDE
local beautiful = require("beautiful") --DOC_HIDE
local notif = naughty.notification { --DOC_HIDE
title = "A notification", --DOC_HIDE
message = "This notification has actions!", --DOC_HIDE
actions = { --DOC_HIDE
naughty.action { --DOC_HIDE
name = "Accept", --DOC_HIDE
icon = beautiful.awesome_icon, --DOC_HIDE
}, --DOC_HIDE
naughty.action { --DOC_HIDE
name = "Refuse", --DOC_HIDE
icon = beautiful.awesome_icon, --DOC_HIDE
}, --DOC_HIDE
naughty.action { --DOC_HIDE
name = "Ignore", --DOC_HIDE
icon = beautiful.awesome_icon, --DOC_HIDE
}, --DOC_HIDE
} --DOC_HIDE
} --DOC_HIDE
--DOC_NEWLINE
parent:add( wibox.container.background(--DOC_HIDE
wibox.widget {
notification = notif,
forced_width = 250, --DOC_HIDE
base_layout = wibox.widget {
spacing = 3,
spacing_widget = wibox.widget {
orientation = "vertical",
widget = wibox.widget.separator,
},
layout = wibox.layout.flex.horizontal
},
widget_template = {
{
{
{
id = "icon_role",
forced_height = 16,
forced_width = 16,
widget = wibox.widget.imagebox
},
{
id = "text_role",
widget = wibox.widget.textbox
},
spacing = 5,
layout = wibox.layout.fixed.horizontal
},
id = "background_role",
widget = wibox.container.background,
},
margins = 4,
widget = wibox.container.margin,
},
widget = naughty.list.actions,
}
,beautiful.bg_normal)) --DOC_HIDE

View File

@ -0,0 +1,34 @@
--DOC_GEN_IMAGE
local parent = ... --DOC_HIDE --DOC_NO_USAGE
local naughty = { --DOC_HIDE
list = {actions = require("naughty.list.actions")}, --DOC_HIDE
notification = require("naughty.notification"), --DOC_HIDE
action = require("naughty.action") --DOC_HIDE
} --DOC_HIDE
local wibox = require("wibox") --DOC_HIDE
local beautiful = require("beautiful") --DOC_HIDE
local notif = naughty.notification {
title = "A notification",
message = "This notification has actions!",
actions = {
naughty.action {
name = "Accept",
},
naughty.action {
name = "Refuse",
},
naughty.action {
name = "Ignore",
},
}
}
--DOC_NEWLINE
parent:add( wibox.container.background(--DOC_HIDE
wibox.widget {
notification = notif,
widget = naughty.list.actions,
}
,beautiful.bg_normal)) --DOC_HIDE

View File

@ -0,0 +1,63 @@
--DOC_GEN_IMAGE
local parent = ... --DOC_HIDE --DOC_NO_USAGE
local naughty = { --DOC_HIDE
list = {actions = require("naughty.list.actions")}, --DOC_HIDE
notification = require("naughty.notification"), --DOC_HIDE
action = require("naughty.action") --DOC_HIDE
} --DOC_HIDE
local gears = {shape = require("gears.shape")} --DOC_HIDE
local wibox = require("wibox") --DOC_HIDE
local beautiful = require("beautiful") --DOC_HIDE
local notif = naughty.notification { --DOC_HIDE
title = "A notification", --DOC_HIDE
message = "This notification has actions!", --DOC_HIDE
actions = { --DOC_HIDE
naughty.action { --DOC_HIDE
name = "Accept", --DOC_HIDE
icon = beautiful.awesome_icon, --DOC_HIDE
}, --DOC_HIDE
naughty.action { --DOC_HIDE
name = "Refuse", --DOC_HIDE
icon = beautiful.awesome_icon, --DOC_HIDE
selected = true, --DOC_HIDE
}, --DOC_HIDE
naughty.action { --DOC_HIDE
name = "Ignore", --DOC_HIDE
icon = beautiful.awesome_icon, --DOC_HIDE
}, --DOC_HIDE
} --DOC_HIDE
} --DOC_HIDE
--DOC_NEWLINE
parent:add( wibox.container.margin(--DOC_HIDE
wibox.widget {
notification = notif,
forced_width = 250, --DOC_HIDE
base_layout = wibox.widget {
spacing = 3,
spacing_widget = wibox.widget {
orientation = "vertical",
widget = wibox.widget.separator,
},
layout = wibox.layout.flex.horizontal
},
style = {
underline_normal = false,
underline_selected = true,
shape_normal = gears.shape.octogon,
shape_selected = gears.shape.hexagon,
shape_border_width_normal = 2,
shape_border_width_selected = 4,
icon_size_normal = 16,
icon_size_selected = 24,
shape_border_color_normal = "#0000ff",
shape_border_color_selected = "#ff0000",
bg_normal = "#ffff00",
bg_selected = "#00ff00",
},
forced_height = beautiful.get_font_height(beautiful.font) * 2.5,
widget = naughty.list.actions,
}
,0,0,5,5)) --DOC_HIDE

View File

@ -0,0 +1,107 @@
--DOC_GEN_IMAGE --DOC_HIDE_ALL
local parent = ...
local naughty = require("naughty")
local wibox = require("wibox")
local beautiful = require("beautiful")
local def = require("naughty.widget._default")
local acommon = require("awful.widget.common")
local aplace = require("awful.placement")
local gears = require("gears")
beautiful.notification_bg = beautiful.bg_normal
local notif = naughty.notification {
title = "A notification",
message = "This notification has actions!",
icon = beautiful.awesome_icon,
actions = {
naughty.action {
name = "Accept",
icon = beautiful.awesome_icon,
},
naughty.action {
name = "Refuse",
icon = beautiful.awesome_icon,
},
naughty.action {
name = "Ignore",
icon = beautiful.awesome_icon,
},
}
}
local default = wibox.widget(def)
acommon._set_common_property(default, "notification", notif)
local w, h = default:fit({dpi=96}, 9999, 9999)
default.forced_width = w + 25
default.forced_height = h
local canvas = wibox.layout.manual()
canvas.forced_width = w + 150
canvas.forced_height = h + 100
canvas:add_at(default, aplace.centered)
local function create_info(text, x, y, width, height)
canvas:add_at(wibox.widget {
{
{
text = text,
align = "center",
ellipsize = "none",
wrap = "word",
widget = wibox.widget.textbox
},
top = 2,
bottom = 2,
left = 10,
right = 10,
widget = wibox.container.margin
},
forced_width = width,
forced_height = height,
shape = gears.shape.rectangle,
shape_border_width = 1,
shape_border_color = beautiful.border_color,
bg = "#ffff0055",
widget = wibox.container.background
}, {x = x, y = y})
end
local function create_line(x1, y1, x2, y2)
return canvas:add_at(wibox.widget {
fit = function()
return x2-x1+6, y2-y1+6
end,
draw = function(_, _, cr)
cr:set_source_rgb(0,0,0)
cr:set_line_width(1)
cr:arc(1.5, 1.5, 1.5, 0, math.pi*2)
cr:arc(x2-x1+1.5, y2-y1+1.5, 1.5, 0, math.pi*2)
cr:fill()
cr:move_to(1.5,1.5)
cr:line_to(x2-x1+1.5, y2-y1+1.5)
cr:stroke()
end,
layout = wibox.widget.base.make_widget,
}, {x=x1, y=y1})
end
create_info("naughty.widget.background", 10, canvas.forced_height - 30, nil, nil)
create_line(80, canvas.forced_height-55, 80, canvas.forced_height - 30)
create_info("naughty.list.actions", 170, canvas.forced_height - 30, nil, nil)
create_line(200, canvas.forced_height-105, 200, canvas.forced_height - 30)
create_info("naughty.widget.icon", 20, 25, nil, nil)
create_line(80, 40, 80, 60)
create_info("naughty.widget.title", 90, 4, nil, nil)
create_line(140, 20, 140, 60)
create_info("naughty.widget.message", 150, 25, nil, nil)
create_line(210, 40, 210, 75)
parent:add(canvas)

View File

@ -0,0 +1,22 @@
--DOC_GEN_IMAGE
local parent = ... --DOC_HIDE
local naughty = { --DOC_HIDE
widget = { icon = require("naughty.widget.icon")}, --DOC_HIDE
notification = require("naughty.notification")} --DOC_HIDE
local wibox = require("wibox") --DOC_HIDE
local beautiful = require("beautiful") --DOC_HIDE
local notif = naughty.notification {
title = "A notification",
message = "This notification has actions!",
icon = beautiful.awesome_icon,
}
--DOC_NEWLINE
parent:add( --DOC_HIDE
wibox.widget {
notification = notif,
widget = naughty.widget.icon,
}
) --DOC_HIDE

View File

@ -0,0 +1,62 @@
--DOC_GEN_IMAGE
local parent = ... --DOC_HIDE_ALL
local naughty = {
widget = { icon = require("naughty.widget.icon")},
notification = require("naughty.notification"),
}
local wibox = require("wibox")
local beautiful = require("beautiful")
local notif = naughty.notification {
title = "A notification",
text = "This notification has actions!",
icon = beautiful.awesome_icon,
actions = {
["Accept"] = function() end,
["Refuse"] = function() end,
["Ignore"] = function() end,
}
}
local icons = {}
for _, strategy in ipairs {"resize", "scale", "center" } do
table.insert(icons, wibox.widget {
{
{
resize_strategy = strategy,
notification = notif,
widget = naughty.widget.icon,
},
bg = beautiful.bg_normal,
widget = wibox.container.background
},
valign = "top",
halign = "left",
widget = wibox.container.place
})
end
parent:add(
wibox.widget {
{
markup = "<b>resize:</b>",
widget = wibox.widget.textbox,
},
{
markup = "<b>scale:</b>",
widget = wibox.widget.textbox,
},
{
markup = "<b>center:</b>",
widget = wibox.widget.textbox,
},
icons[1],
icons[2],
icons[3],
forced_num_rows = 2,
forced_num_cols = 3,
spacing = 5,
widget = wibox.layout.grid,
}
)

View File

@ -0,0 +1,22 @@
--DOC_GEN_IMAGE
local parent = ... --DOC_HIDE
local naughty = { --DOC_HIDE
widget = { message = require("naughty.widget.message")}, --DOC_HIDE
notification = require("naughty.notification")} --DOC_HIDE
local wibox = require("wibox") --DOC_HIDE
local beautiful = require("beautiful") --DOC_HIDE
local notif = naughty.notification {
title = "A notification",
message = "This notification no actions!",
icon = beautiful.awesome_icon,
}
--DOC_NEWLINE
parent:add( --DOC_HIDE
wibox.widget {
notification = notif,
widget = naughty.widget.message,
}
) --DOC_HIDE

View File

@ -0,0 +1,22 @@
--DOC_GEN_IMAGE
local parent = ... --DOC_HIDE
local naughty = { --DOC_HIDE
widget = { title = require("naughty.widget.title")}, --DOC_HIDE
notification = require("naughty.notification")} --DOC_HIDE
local wibox = require("wibox") --DOC_HIDE
local beautiful = require("beautiful") --DOC_HIDE
local notif = naughty.notification {
title = "A notification",
message = "This notification no actions!",
icon = beautiful.awesome_icon,
}
--DOC_NEWLINE
parent:add( --DOC_HIDE
wibox.widget {
notification = notif,
widget = naughty.widget.title,
}
) --DOC_HIDE