Commit Graph

78 Commits

Author SHA1 Message Date
Aire-One 53a880454f fix(w.widget): signal typo and unit test
This is a combination of 2 commits.
* fix(w.widget): emit signal typo
* add(w.widget.base_spec): Unit test for setters signals emittion
2021-06-26 17:26:21 +02:00
Emmanuel Lepage Vallee d373bf2d05 widget: Emit "property::widget"
For consistency.
2021-04-24 23:28:18 -07:00
Aire-One b706aa9bd0 doc(@hidden): Add to wibox.widget.base module 2021-04-02 19:24:07 +02:00
Aire-One 12662d4cb1 doc(@supermodule): wibox.widget.base doc 2021-04-02 19:24:07 +02:00
Lucas Schwiderski 7bc3ec4c35
Fix composite widgets with top level container
When wrapping container widgets to create reusable composite widgets,
`drill` will be called twice on the same widget definition. The first
call happens within the wrapping function and applies the children
widgets fine. The second call happens when the composite widget is used,
but since there are no children widgets defined, the call to
`set_children` sets the existing child to `nil` instead.

Fixes #3213.

Signed-off-by: Lucas Schwiderski <lucas@lschwiderski.de>
2021-03-11 12:32:28 +01:00
Emmanuel Lepage Vallee c220bcce87 widget: Enable properties by default for API level 5. 2020-02-29 19:47:36 -05:00
Emmanuel Lepage Vallee 4c5fd3f222 widget: Fix set_buttons on widgets where properties are disabled.
Fix #3008
2020-02-29 19:47:36 -05:00
Emmanuel Lepage-Vallee 575b0f12dc doc: Remove all type aliases.
They render poorly and serve no purpose.

    #!/bin/bash
    for FILE in $(git ls-files | grep -E "\.(h|c|lua)" | grep -v tests | grep -v spec); do
        sed -i 's/^[ ]*--*[ ]*@client /-- @tparam client /g' $FILE
    done
2020-01-19 20:30:06 -05:00
Jordan Christiansen c09e5b16b7 Correct the name of get_children's return value (#2927)
get_children's return value should not be called "The". That was a
mistake because ldoc requires a name for return values and parameters.
If a name isn't provided, it thinks the first word of the description
is the name.
2019-11-25 17:04:01 -05:00
Emmanuel Lepage Vallee cf0385af80 widget: Add an `:add_button()` method.
This is done now because a lot of code in `lib/` add buttons by manually
extracting buttons from awful.button. Instead of adding ugly code to
prevent using the legacy API, do this.
2019-10-05 22:57:05 -04:00
Emmanuel Lepage Vallee 82db9180b1 widget: Mutualize all set_widget implementation to behave the same
Now always call both check_widget and make_widget_from_value. This
should make it a lot less confusing when randomly trying to create
a widget as all ways to do it slowly converge toward an unified
one.
2019-10-05 22:57:04 -04:00
Emmanuel Lepage Vallee 3d918258e2 widget: Turn `:buttons()` into a normal property. 2019-10-05 18:06:51 -04:00
Emmanuel Lepage Vallee 4cab9f8c38 widget: Return `nil` in case of failure.
Instead of an assert. If there is a "real" error, then a warning is
still printed, but otherwise this relax the requirements.
2019-10-05 18:06:50 -04:00
Uli Schlachter 2aa198a57b wibox.widget.base.place_widget_*: Protect against negative sizes
This commits adds assertions to catch negative width or height.

Would-have-helped-with: https://github.com/awesomeWM/awesome/issues/2799
Signed-off-by: Uli Schlachter <psychon@znc.in>
2019-06-19 18:20:09 +02:00
Emmanuel Lepage Vallee b4ece0f053 doc: Use an explicit tag for all static functions.
This way their name doesn't get mangle by the broken magic. It will also
eventually allow to `error()` in the template when the implicit
`@function` is used.

This commit also fixes a large number of issues found while
proof-reading everything.
2019-06-08 18:14:13 -04:00
Emmanuel Lepage Vallee 02ed7ceed5 widget.base: Allow widgets constructor in the declarative template.
This avoids the boilerplate of having to do:

    {
        widget = awful.widget.mywidget
    }

in the templates.
2019-04-05 21:06:11 -04:00
Emmanuel Lepage Vallée a2cd918603
wibox: Stop monkey-patching the `get_children_by_id` function. (#2513)
Before this commit, it was added by `wibox.widget.base` if
`:setup()` is used. However it doesn't work for the `awful.popup`
because of the extra indirection.

This commit stops the monkey-patching and make sure the function
always exists. This doesn't prevent it from not working and in
the long run this should still be moved into the hierarchy.

However for now it makes the situation a lot more consistent and is a
quick band-aid without too much controversy.

Mitigate #2181
2019-01-01 15:04:47 -05:00
Uli Schlachter a4936c963c Fix 'creating new widgets' link (#2157)
This was broken ever since it was introduced in commit b1e69dba8c.
Yay. :-(

Fixes: https://github.com/awesomeWM/awesome/issues/1373#issuecomment-357891791
Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-01-16 21:15:49 -05:00
Emmanuel Lepage Vallee 7e8f3e9b9b widget: Add a flexible generic constructor
This avoid copy pasting this kind of code in many places.
2017-08-19 22:45:54 -04:00
Uli Schlachter 12bb7f5a9e Improve docs for emit_signal_recursive (#1998)
Signed-off-by: Uli Schlachter <psychon@znc.in>
2017-08-16 13:37:14 +02:00
getzze 59662bc971 wibox.widget.base: do not call set_children if children is nil 2017-04-18 15:00:39 +02:00
Kevin Zander c3461b535c gears: Move awful.util.table to gears.table (#1641)
* Move table functions out of awful.util into new gears.table

* travis: Use v9999 prefix for full requests

Make sure no newly deprecated functions are used

* Move all `awful.util.table.*` calls to `gears.table.*` calls
Move table test functions from awful/util_spec to new gears/table_spec
Change awful.util.subsets call to gears.math.subsets in awful/key.lua
2017-03-08 15:18:33 -05:00
Daniel Hahler fc13b1b4eb doc: s/Wether/Whether/ 2016-11-22 02:40:15 +01:00
Daniel Hahler eed3d7e63a lib/wibox/widget/base.lua: doc fixes 2016-11-22 02:40:15 +01:00
Uli Schlachter 259c4f716f Remove @release @AWESOME_VERSION@ everywhere (#1157)
It does not provide much value. The version number is already known to
ldoc globally in the "description" variable.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-10-09 22:36:20 +02:00
Emmanuel Lepage Vallee 370d333590 widget: Add recursive signals.
This allows to ignore containers and layouts when a signal is sent.
2016-08-20 15:41:12 -04:00
Emmanuel Lepage Vallee 41feec02a5 widget.base: Fix the root get_children_by_id() widget.
If the wibox root widget had an id, it was added to the properties,
but not the get_children_by_id() table
2016-08-01 15:26:29 -04:00
Emmanuel Lepage Vallee 79394c0965 widgets: Apply attributes before adding the widgets
For example, some layouts may place the widgets in a different order
depending on some attreibutes.
2016-07-23 17:24:13 -04:00
Uli Schlachter 0857f6f1b5 Lua: Remove calls to add_signal()
The requirement to call add_signal() was added to catch typos. However, this
requirement became increasingly annoying with property::<name> signals and e.g.
gears.object allowing arbitrary properties to be changed.

All of this ended up in a single commit because tests/examples fails if I first
let add_signal() emit a deprecation warning.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-06-04 18:23:48 +02:00
Emmanuel Lepage Vallee 9630f3c3ed widget: Move the identifier index into _private 2016-05-30 18:00:59 -04:00
Emmanuel Lepage Vallee fdf86ba84d widget: Move height and width into _private 2016-05-30 18:00:59 -04:00
Emmanuel Lepage Vallee c0eabf9d8f widget: Move 'visible' into _private 2016-05-30 18:00:59 -04:00
Emmanuel Lepage Vallee afa17fd8f9 widget: Move 'widget_buttons' into _private 2016-05-30 18:00:59 -04:00
Emmanuel Lepage Vallee c828e56b57 widget: Fix documentation 2016-05-30 18:00:59 -04:00
Emmanuel Lepage Vallee 542070205f widget: Add proper accessors for the 'opacity' property
To avoid collision with the property system and comply with the
API guidelines.
2016-05-30 18:00:59 -04:00
Emmanuel Lepage Vallee c9dd32424f doc: Fix wibox.widget.base documentation
It was set as `module` instead of `class` because ldoc was confused
set shown the methods as functions and functions as methods.

This commit set the explicit section so ldoc don't gress (wrongly)
2016-05-30 18:00:59 -04:00
Emmanuel Lepage Vallee adb2f88383 objects: Add a table for private elements
Provide a standardized place for them rather than having each
widgets use their own conventions.
2016-05-30 18:00:59 -04:00
Emmanuel Lepage Vallee efcbda0a78 widget.base: Add property support 2016-05-30 18:00:59 -04:00
Emmanuel Lepage Vallee e7652a053d tests: Add a new testing framework 2016-03-31 04:45:45 -04:00
Emmanuel Lepage Vallee 78ed3abe1a wibox.widget: Minor enhancements
* Better widget names when using the declarative syntax
 * Add ratio.get_ratio to avoid using the private API
 * Also support `set_widget` when swapping widgets
2016-03-04 04:16:53 -05:00
Emmanuel Lepage Vallée 3be5343e83 Merge pull request #709 from psychon/implement-set-children-sanely
Implement set children sanely
2016-03-03 02:06:58 -05:00
Uli Schlachter 7bf2f17a8a Make gears.widget.{fit,layout}_widget more robust
This commit makes these methods invoke the method on a widget in a protected
context. Thanks to this, e.g. the wibox and other widgets are protected from
errors in a child widget.

Additionally, fit_widget() now assumes 0 if a widget's :fit() method didn't
provide a number.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-02-28 12:11:36 +01:00
Uli Schlachter a78f2359d1 Fix the test case that the previous commit added
Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-02-28 11:10:46 +01:00
Uli Schlachter 1dd63b04de check_widget(): Also check .is_widget entry
Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-02-27 14:01:31 +01:00
Uli Schlachter b1e7d3c22c Call check_widget() in :setup()
I just spent too much time tracking down a bug that happened while drawing a
widget. This is the reason why we should apply sanity checks while widgets are
constructed, so that we get a useful backtrace.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-02-27 13:58:48 +01:00
Uli Schlachter 15e72fb037 Fix luacheck warnings in lib/wibox
Warnings pointing out actual problems are left.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-02-12 09:15:55 +01:00
Emmanuel Lepage Vallee cb896ca87f wibox.widget: Add method to create declarative widgets directly 2016-02-11 03:58:54 -05:00
Emmanuel Lepage Vallee b1e69dba8c doc: Move the new widget documentation to a new file
This will help with discoverability
2016-02-10 01:25:41 -05:00
Emmanuel Lepage Vallee 6a68173ccb widget: Add a new container declaration syntax
This new syntax is inspired by the Awesome widget 3.2-3.4 API. It
allow cleaner widgets declaration. The produced code is usually much
shorted and easier to read than wibox.widget imperative syntax.
2016-02-10 01:09:50 -05:00
Emmanuel Lepage Vallee e36f23171b wibox.widget: Add `set_children` method
Provide a generic method to set the widget content
2016-02-10 01:09:50 -05:00