From d5a2fe007242a349a8a4738b47b6216f78b0ea78 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Wed, 6 Mar 2019 22:20:14 -0500 Subject: [PATCH] awful.widget: Add an helper to set a property on all template widgets With this helper, it becomes possible to avoid manually setting common properties such as the client in the tasklist of tag in the taglist when the children widgets of the template have a set_+property_name. --- lib/awful/widget/common.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/awful/widget/common.lua b/lib/awful/widget/common.lua index 043cece4..35dbfb7c 100644 --- a/lib/awful/widget/common.lua +++ b/lib/awful/widget/common.lua @@ -91,6 +91,19 @@ local function default_template() } end +-- Find all the childrens (without the hierarchy) and set a property. +function common._set_common_property(widget, property, value) + if widget["set_"..property] then + widget["set_"..property](widget, value) + end + + if widget.get_children then + for _, w in ipairs(widget:get_children()) do + common._set_common_property(w, property, value) + end + end +end + --- Common update method. -- @param w The widget. -- @tab buttons