awesomeWM / awesome

awesome window manager
https://awesomewm.org/
GNU General Public License v2.0
6.39k stars 597 forks source link

Question about wibox.widget.textbox:set_font(font) and other similar methods #2476

Open Sorky opened 6 years ago

Sorky commented 6 years ago

@psychon

What do you (and others) think of...

function textbox:set_font(font)
    self._private.layout:set_font_description(beautiful.get_font(font))
    self:emit_signal("widget::redraw_needed")
    self:emit_signal("widget::layout_changed")
 -- vvvvv
    return self  
 -- ^^^^^
end

To allow...

local textbox = wibox.widget.textbox( "Hi" ):set_font( font )

PS: This method doesn't seem to appear in the doco

psychon commented 6 years ago

I don't mind that.

PS: This method doesn't seem to appear in the doco

It is documented as a property and not a method: https://awesomewm.org/doc/api/classes/wibox.widget.textbox.html#wibox.widget.textbox.font

Sorky commented 6 years ago

I was able to do local textbox = wibox.widget.textbox( "Hi" ) textbox.font = font and local textbox = wibox.widget.textbox( "Hi" ) textbox:set_font( font )

Same? Surely the method is additional in this case? Causes a refresh? Which is better?

Ryuno-Ki commented 6 years ago

Reminds me on jQuery way of writing …

Sorky commented 6 years ago

Just like lua string methods

Elv13 commented 6 years ago

Just like lua string methods

No. Lua string return a new string, not a reference to the old string.

Sorky commented 6 years ago

I see it as an object to work with - new/old/reference/whatever