Port all "old" `widget_template` to use `wibox.template`.
This doesn't actually use `set_property`, but it at least covert the old table to `wibox.template` object. Future cleanup can take care of the code duplication.
This commit is contained in:
parent
7aab54ed19
commit
8fc30ae693
|
@ -88,6 +88,9 @@ This document was last updated at commit v4.3-197-g9085ed631.
|
||||||
* Pango 1.44 is now the oldest recommended Pango version. Older versions are
|
* Pango 1.44 is now the oldest recommended Pango version. Older versions are
|
||||||
still supported, but will lack the ability to use some textbox properties,
|
still supported, but will lack the ability to use some textbox properties,
|
||||||
mainly `wibox.widget.textbox.line_spacing_factor`.
|
mainly `wibox.widget.textbox.line_spacing_factor`.
|
||||||
|
* Passing a widget to any `widget_template` property now prints an error. It
|
||||||
|
wasn't working before, but wasn't printing an error. Replace `wibox.widget`
|
||||||
|
with `wibox.template` in your widget definition.
|
||||||
|
|
||||||
<a name="v43"></a>
|
<a name="v43"></a>
|
||||||
# Awesome window manager framework version 4.3 changes
|
# Awesome window manager framework version 4.3 changes
|
||||||
|
|
|
@ -126,7 +126,7 @@ local type_fallback_description = {
|
||||||
"string An [XFT string](https://wiki.archlinux.org/title/X_Logical_Font_Description), such as `\"-*-dejavu sans mono-medium-r-normal--*-80-*-*-*-*-iso10646-1\"`.",
|
"string An [XFT string](https://wiki.archlinux.org/title/X_Logical_Font_Description), such as `\"-*-dejavu sans mono-medium-r-normal--*-80-*-*-*-*-iso10646-1\"`.",
|
||||||
|
|
||||||
},
|
},
|
||||||
template = {
|
["wibox.template"] = {
|
||||||
"table A table containing a widget tree definition. WARNING: This is really a table"..
|
"table A table containing a widget tree definition. WARNING: This is really a table"..
|
||||||
" and **NOT** a widget object. Use the `widget = come.class.here` to define the "..
|
" and **NOT** a widget object. Use the `widget = come.class.here` to define the "..
|
||||||
" topmost class rather than construct an instance."
|
" topmost class rather than construct an instance."
|
||||||
|
@ -165,6 +165,7 @@ local type_name_linting = {
|
||||||
["double"] = "number",
|
["double"] = "number",
|
||||||
["float"] = "number",
|
["float"] = "number",
|
||||||
["bool"] = "boolean",
|
["bool"] = "boolean",
|
||||||
|
["template"] = "wibox.template",
|
||||||
}
|
}
|
||||||
|
|
||||||
local metadata_tags = {
|
local metadata_tags = {
|
||||||
|
|
|
@ -17,7 +17,6 @@ local capi = { button = button }
|
||||||
local wibox = require("wibox")
|
local wibox = require("wibox")
|
||||||
local gdebug = require("gears.debug")
|
local gdebug = require("gears.debug")
|
||||||
local dpi = require("beautiful").xresources.apply_dpi
|
local dpi = require("beautiful").xresources.apply_dpi
|
||||||
local base = require("wibox.widget.base")
|
|
||||||
|
|
||||||
--- Common utilities for awful widgets
|
--- Common utilities for awful widgets
|
||||||
local common = {}
|
local common = {}
|
||||||
|
|
|
@ -190,7 +190,7 @@ local layoutlist = {}
|
||||||
--- The delegate widget template.
|
--- The delegate widget template.
|
||||||
--
|
--
|
||||||
-- @property widget_template
|
-- @property widget_template
|
||||||
-- @tparam[opt=nil] template|nil widget_template
|
-- @tparam[opt=nil] wibox.template|nil widget_template
|
||||||
-- @propemits true false
|
-- @propemits true false
|
||||||
|
|
||||||
--- The layoutlist screen.
|
--- The layoutlist screen.
|
||||||
|
@ -362,7 +362,7 @@ function layoutlist:get_count()
|
||||||
end
|
end
|
||||||
|
|
||||||
function layoutlist:set_widget_template(widget_template)
|
function layoutlist:set_widget_template(widget_template)
|
||||||
self._private.widget_template = widget_template
|
self._private.widget_template = wibox.template.make_from_value(widget_template)
|
||||||
|
|
||||||
-- Remove the existing instances
|
-- Remove the existing instances
|
||||||
self._private.data = setmetatable({}, { __mode = 'k' })
|
self._private.data = setmetatable({}, { __mode = 'k' })
|
||||||
|
|
|
@ -56,6 +56,7 @@ local gstring = require("gears.string")
|
||||||
local gdebug = require("gears.debug")
|
local gdebug = require("gears.debug")
|
||||||
local base = require("wibox.widget.base")
|
local base = require("wibox.widget.base")
|
||||||
local gtable = require("gears.table")
|
local gtable = require("gears.table")
|
||||||
|
local wtemplate = require("wibox.template")
|
||||||
|
|
||||||
local function get_screen(s)
|
local function get_screen(s)
|
||||||
return s and capi.screen[s]
|
return s and capi.screen[s]
|
||||||
|
@ -525,7 +526,7 @@ end
|
||||||
--- A templete used to genetate the individual tag widgets.
|
--- A templete used to genetate the individual tag widgets.
|
||||||
--
|
--
|
||||||
-- @property widget_template
|
-- @property widget_template
|
||||||
-- @tparam[opt=nil] template|nil widget_template
|
-- @tparam[opt=nil] wibox.template|nil widget_template
|
||||||
|
|
||||||
for _, prop in ipairs { "filter", "update_function", "widget_template", "source", "screen" } do
|
for _, prop in ipairs { "filter", "update_function", "widget_template", "source", "screen" } do
|
||||||
taglist["set_"..prop] = function(self, value)
|
taglist["set_"..prop] = function(self, value)
|
||||||
|
@ -545,6 +546,16 @@ for _, prop in ipairs { "filter", "update_function", "widget_template", "source"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function taglist:set_widget_template(widget_template)
|
||||||
|
self._private.widget_template = wtemplate.make_from_value(widget_template)
|
||||||
|
|
||||||
|
self._do_taglist_update()
|
||||||
|
|
||||||
|
self:emit_signal("widget::layout_changed")
|
||||||
|
self:emit_signal("widget::redraw_needed")
|
||||||
|
self:emit_signal("property::widget_template", self._private.widget_template)
|
||||||
|
end
|
||||||
|
|
||||||
--- Create a new taglist widget. The last two arguments (update_function
|
--- Create a new taglist widget. The last two arguments (update_function
|
||||||
-- and layout) serve to customize the layout of the taglist (eg. to
|
-- and layout) serve to customize the layout of the taglist (eg. to
|
||||||
-- make it vertical). For that, you will need to copy the
|
-- make it vertical). For that, you will need to copy the
|
||||||
|
@ -561,7 +572,7 @@ end
|
||||||
-- is wibox.layout.fixed.horizontal().
|
-- is wibox.layout.fixed.horizontal().
|
||||||
-- @tparam[opt=awful.widget.taglist.source.for_screen] function args.source The
|
-- @tparam[opt=awful.widget.taglist.source.for_screen] function args.source The
|
||||||
-- function used to generate the list of tag.
|
-- function used to generate the list of tag.
|
||||||
-- @tparam[opt] table args.widget_template A custom widget to be used for each tag
|
-- @tparam[opt] wibox.template args.widget_template A custom widget to be used for each tag
|
||||||
-- @tparam[opt={}] table args.style The style overrides default theme.
|
-- @tparam[opt={}] table args.style The style overrides default theme.
|
||||||
-- @tparam[opt=beautiful.taglist_fg_focus] string|pattern args.style.fg_focus
|
-- @tparam[opt=beautiful.taglist_fg_focus] string|pattern args.style.fg_focus
|
||||||
-- @tparam[opt=beautiful.taglist_bg_focus] string|pattern args.style.bg_focus
|
-- @tparam[opt=beautiful.taglist_bg_focus] string|pattern args.style.bg_focus
|
||||||
|
@ -658,7 +669,7 @@ function taglist.new(args, filter, buttons, style, update_function, base_widget)
|
||||||
buttons = args.buttons,
|
buttons = args.buttons,
|
||||||
filter = args.filter,
|
filter = args.filter,
|
||||||
update_function = args.update_function,
|
update_function = args.update_function,
|
||||||
widget_template = args.widget_template,
|
widget_template = wtemplate.make_from_value(args.widget_template),
|
||||||
source = args.source,
|
source = args.source,
|
||||||
screen = screen
|
screen = screen
|
||||||
})
|
})
|
||||||
|
|
|
@ -95,6 +95,7 @@ local wmargin = require("wibox.container.margin")
|
||||||
local wtextbox = require("wibox.widget.textbox")
|
local wtextbox = require("wibox.widget.textbox")
|
||||||
local clienticon = require("awful.widget.clienticon")
|
local clienticon = require("awful.widget.clienticon")
|
||||||
local wbackground = require("wibox.container.background")
|
local wbackground = require("wibox.container.background")
|
||||||
|
local wtemplate = require("wibox.template")
|
||||||
local gtable = require("gears.table")
|
local gtable = require("gears.table")
|
||||||
|
|
||||||
local function get_screen(s)
|
local function get_screen(s)
|
||||||
|
@ -678,7 +679,7 @@ end
|
||||||
-- @DOC_sequences_client_tasklist_widget_template1_EXAMPLE@
|
-- @DOC_sequences_client_tasklist_widget_template1_EXAMPLE@
|
||||||
--
|
--
|
||||||
-- @property widget_template
|
-- @property widget_template
|
||||||
-- @tparam[opt=nil] template|nil widget_template
|
-- @tparam[opt=nil] wibox.template|nil widget_template
|
||||||
-- @propemits true false
|
-- @propemits true false
|
||||||
|
|
||||||
--- A function to gather the clients to display.
|
--- A function to gather the clients to display.
|
||||||
|
@ -794,7 +795,7 @@ function tasklist:set_screen(value)
|
||||||
end
|
end
|
||||||
|
|
||||||
function tasklist:set_widget_template(widget_template)
|
function tasklist:set_widget_template(widget_template)
|
||||||
self._private.widget_template = widget_template
|
self._private.widget_template = wtemplate.make_from_value(widget_template)
|
||||||
|
|
||||||
-- Remove the existing instances
|
-- Remove the existing instances
|
||||||
self._private.data = setmetatable({}, { __mode = 'k' })
|
self._private.data = setmetatable({}, { __mode = 'k' })
|
||||||
|
@ -803,7 +804,7 @@ function tasklist:set_widget_template(widget_template)
|
||||||
|
|
||||||
self:emit_signal("widget::layout_changed")
|
self:emit_signal("widget::layout_changed")
|
||||||
self:emit_signal("widget::redraw_needed")
|
self:emit_signal("widget::redraw_needed")
|
||||||
self:emit_signal("property::widget_template", widget_template)
|
self:emit_signal("property::widget_template", self._private.widget_template)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Create a new tasklist widget.
|
--- Create a new tasklist widget.
|
||||||
|
@ -824,7 +825,7 @@ end
|
||||||
-- is `wibox.layout.flex.horizontal`.
|
-- is `wibox.layout.flex.horizontal`.
|
||||||
-- @tparam[opt=awful.widget.tasklist.source.all_clients] function args.source The
|
-- @tparam[opt=awful.widget.tasklist.source.all_clients] function args.source The
|
||||||
-- function used to generate the list of client.
|
-- function used to generate the list of client.
|
||||||
-- @tparam[opt] table args.widget_template A custom widget to be used for each client
|
-- @tparam[opt] wibox.template args.widget_template A custom widget to be used for each client
|
||||||
-- @tparam[opt={}] table args.style The style overrides default theme.
|
-- @tparam[opt={}] table args.style The style overrides default theme.
|
||||||
-- @tparam[opt=beautiful.tasklist_fg_normal] string|pattern args.style.fg_normal
|
-- @tparam[opt=beautiful.tasklist_fg_normal] string|pattern args.style.fg_normal
|
||||||
-- @tparam[opt=beautiful.tasklist_bg_normal] string|pattern args.style.bg_normal
|
-- @tparam[opt=beautiful.tasklist_bg_normal] string|pattern args.style.bg_normal
|
||||||
|
@ -922,7 +923,7 @@ function tasklist.new(args, filter, buttons, style, update_function, base_widget
|
||||||
buttons = args.buttons,
|
buttons = args.buttons,
|
||||||
style = args.style or {},
|
style = args.style or {},
|
||||||
screen = screen,
|
screen = screen,
|
||||||
widget_template = args.widget_template,
|
widget_template = wtemplate.make_from_value(args.widget_template),
|
||||||
source = args.source,
|
source = args.source,
|
||||||
data = setmetatable({}, { __mode = 'k' })
|
data = setmetatable({}, { __mode = 'k' })
|
||||||
})
|
})
|
||||||
|
|
|
@ -209,7 +209,7 @@ end)
|
||||||
-- }
|
-- }
|
||||||
--
|
--
|
||||||
-- @property widget_template
|
-- @property widget_template
|
||||||
-- @tparam[opt=nil] template|nil widget_template
|
-- @tparam[opt=nil] wibox.template|nil widget_template
|
||||||
-- @usebeautiful beautiful.notification_max_width The maximum width for the
|
-- @usebeautiful beautiful.notification_max_width The maximum width for the
|
||||||
-- resulting widget.
|
-- resulting widget.
|
||||||
|
|
||||||
|
@ -324,7 +324,7 @@ end
|
||||||
--
|
--
|
||||||
-- @constructorfct naughty.layout.box
|
-- @constructorfct naughty.layout.box
|
||||||
-- @tparam[opt=nil] table args
|
-- @tparam[opt=nil] table args
|
||||||
-- @tparam table args.widget_template A widget definition template which will
|
-- @tparam wibox.template args.widget_template A widget definition template which will
|
||||||
-- be instantiated for each box.
|
-- be instantiated for each box.
|
||||||
-- @tparam naughty.notification args.notification The notification object.
|
-- @tparam naughty.notification args.notification The notification object.
|
||||||
-- @tparam string args.position The position. See `naughty.notification.position`.
|
-- @tparam string args.position The position. See `naughty.notification.position`.
|
||||||
|
@ -364,7 +364,9 @@ local function new(args)
|
||||||
|
|
||||||
local ret = popup(new_args)
|
local ret = popup(new_args)
|
||||||
ret._private.notification = {}
|
ret._private.notification = {}
|
||||||
ret._private.widget_template = args.widget_template
|
ret._private.widget_template = wibox.template.make_from_value(
|
||||||
|
args.widget_template
|
||||||
|
)
|
||||||
ret._private.position = args.position
|
ret._private.position = args.position
|
||||||
|
|
||||||
gtable.crush(ret, box, true)
|
gtable.crush(ret, box, true)
|
||||||
|
|
|
@ -203,7 +203,7 @@ local actionlist = {}
|
||||||
|
|
||||||
--- The actionlist parent notification.
|
--- The actionlist parent notification.
|
||||||
-- @property widget_template
|
-- @property widget_template
|
||||||
-- @tparam[opt=nil] template|nil widget_template
|
-- @tparam[opt=nil] wibox.template|nil widget_template
|
||||||
-- @propemits true false
|
-- @propemits true false
|
||||||
|
|
||||||
--- A table with values to override each `beautiful.notification_action` values.
|
--- A table with values to override each `beautiful.notification_action` values.
|
||||||
|
@ -271,7 +271,7 @@ function actionlist:set_base_layout(layout)
|
||||||
end
|
end
|
||||||
|
|
||||||
function actionlist:set_widget_template(widget_template)
|
function actionlist:set_widget_template(widget_template)
|
||||||
self._private.widget_template = widget_template
|
self._private.widget_template = wibox.template.make_from_value(widget_template)
|
||||||
|
|
||||||
-- Remove the existing instances
|
-- Remove the existing instances
|
||||||
self._private.data = {}
|
self._private.data = {}
|
||||||
|
@ -280,7 +280,7 @@ function actionlist:set_widget_template(widget_template)
|
||||||
|
|
||||||
self:emit_signal("widget::layout_changed")
|
self:emit_signal("widget::layout_changed")
|
||||||
self:emit_signal("widget::redraw_needed")
|
self:emit_signal("widget::redraw_needed")
|
||||||
self:emit_signal("property::widget_template", widget_template)
|
self:emit_signal("property::widget_template", self._private.widget_template)
|
||||||
end
|
end
|
||||||
|
|
||||||
function actionlist:set_style(style)
|
function actionlist:set_style(style)
|
||||||
|
|
|
@ -182,7 +182,7 @@ local notificationlist = {}
|
||||||
|
|
||||||
--- The notificationlist parent notification.
|
--- The notificationlist parent notification.
|
||||||
-- @property widget_template
|
-- @property widget_template
|
||||||
-- @tparam[opt=nil] template|nil widget_template
|
-- @tparam[opt=nil] wibox.template|nil widget_template
|
||||||
-- @propertydefault The default template displays the icon, title, message and
|
-- @propertydefault The default template displays the icon, title, message and
|
||||||
-- actions.
|
-- actions.
|
||||||
-- @propemits true false
|
-- @propemits true false
|
||||||
|
@ -208,7 +208,7 @@ local notificationlist = {}
|
||||||
-- @usebeautiful beautiful.notification_bgimage_selected Fallback.
|
-- @usebeautiful beautiful.notification_bgimage_selected Fallback.
|
||||||
|
|
||||||
function notificationlist:set_widget_template(widget_template)
|
function notificationlist:set_widget_template(widget_template)
|
||||||
self._private.widget_template = widget_template
|
self._private.widget_template = wibox.template.make_from_value(widget_template)
|
||||||
|
|
||||||
-- Remove the existing instances
|
-- Remove the existing instances
|
||||||
self._private.data = {}
|
self._private.data = {}
|
||||||
|
@ -217,7 +217,7 @@ function notificationlist:set_widget_template(widget_template)
|
||||||
|
|
||||||
self:emit_signal("widget::layout_changed")
|
self:emit_signal("widget::layout_changed")
|
||||||
self:emit_signal("widget::redraw_needed")
|
self:emit_signal("widget::redraw_needed")
|
||||||
self:emit_signal("property::widget_template", widget_template)
|
self:emit_signal("property::widget_template", self._private.widget_template)
|
||||||
end
|
end
|
||||||
|
|
||||||
function notificationlist:set_style(style)
|
function notificationlist:set_style(style)
|
||||||
|
@ -289,7 +289,7 @@ end
|
||||||
-- @tparam gears.color|string args.style.fg_selected
|
-- @tparam gears.color|string args.style.fg_selected
|
||||||
-- @tparam gears.surface|string args.style.bgimage_normal
|
-- @tparam gears.surface|string args.style.bgimage_normal
|
||||||
-- @tparam gears.surface|string args.style.bgimage_selected
|
-- @tparam gears.surface|string args.style.bgimage_selected
|
||||||
-- @tparam[opt] table args.widget_template A custom widget to be used for each
|
-- @tparam[opt] wibox.template args.widget_template A custom widget to be used for each
|
||||||
-- notifications.
|
-- notifications.
|
||||||
-- @treturn widget The notification list widget.
|
-- @treturn widget The notification list widget.
|
||||||
-- @constructorfct naughty.list.notifications
|
-- @constructorfct naughty.list.notifications
|
||||||
|
|
|
@ -24,6 +24,7 @@ local cst = require("naughty.constants")
|
||||||
local naughty = require("naughty.core")
|
local naughty = require("naughty.core")
|
||||||
local gdebug = require("gears.debug")
|
local gdebug = require("gears.debug")
|
||||||
local pcommon = require("awful.permissions._common")
|
local pcommon = require("awful.permissions._common")
|
||||||
|
local wtemplate = require("wibox.template")
|
||||||
|
|
||||||
local notification = {}
|
local notification = {}
|
||||||
|
|
||||||
|
@ -514,7 +515,7 @@ local notification = {}
|
||||||
-- off with a specialized notification widget.
|
-- off with a specialized notification widget.
|
||||||
--
|
--
|
||||||
-- @property widget_template
|
-- @property widget_template
|
||||||
-- @tparam[opt=nil] template|nil widget_template
|
-- @tparam[opt=nil] wibox.template|nil widget_template
|
||||||
-- @propertydefault The default template as the icon, title, message and actions.
|
-- @propertydefault The default template as the icon, title, message and actions.
|
||||||
-- @propemits true false
|
-- @propemits true false
|
||||||
|
|
||||||
|
@ -857,6 +858,21 @@ function notification:append_actions(new_actions)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function notification:set_widget_template(value)
|
||||||
|
self._private.widget_template = wtemplate.make_from_value(value)
|
||||||
|
self:emit_signal("property::widget_template", value)
|
||||||
|
|
||||||
|
-- When a notification is updated over dbus or by setting a property,
|
||||||
|
-- it is usually convenient to reset the timeout.
|
||||||
|
local reset = ((not self.suspended) or self._private.ignore_suspend)
|
||||||
|
and self.auto_reset_timeout ~= false
|
||||||
|
and naughty.auto_reset_timeout
|
||||||
|
|
||||||
|
if reset then
|
||||||
|
self:reset_timeout()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function notification:set_screen(s)
|
function notification:set_screen(s)
|
||||||
assert(not self._private.screen)
|
assert(not self._private.screen)
|
||||||
|
|
||||||
|
|
|
@ -164,7 +164,7 @@ end
|
||||||
-- will still be honored.
|
-- will still be honored.
|
||||||
--
|
--
|
||||||
-- @property template
|
-- @property template
|
||||||
-- @tparam[opt=nil] template|nil template The new widget to use as a
|
-- @tparam[opt=nil] table|nil template The new widget to use as a
|
||||||
-- template.
|
-- template.
|
||||||
-- @emits widget::redraw_needed
|
-- @emits widget::redraw_needed
|
||||||
-- @emits widget::layout_changed
|
-- @emits widget::layout_changed
|
||||||
|
|
Loading…
Reference in New Issue