awesomeWM / awesome

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

gears.shape.radial_progress(): attempt to call method 'move_to' (a nil value) #958

Closed r3lgar closed 8 years ago

r3lgar commented 8 years ago

Try to test gears.shape.radial_progress()

local fixed = require("wibox.layout.fixed")
local shape = require("gears.shape")
local progressbar = require("wibox.widget.progressbar")

function radial_progress_test()
    local widget = fixed.horizontal()
    widget:add(margin(shape.radial_progress(prg, 24, 24, .3),1,1,4,4))
    return widget
end

stderr:

stack traceback:
    /usr/share/awesome/lib/gears/shape.lua:397: in function 'radial_progress'
    /home/funeralismatic/.config/awesome/shape_tests.lua: in function 'radial_progress_test'
    /home/funeralismatic/.config/awesome/rc.lua:402: in function 'func'
    /usr/share/awesome/lib/awful/screen.lua:380: in function 'connect_for_each_screen'
    /home/funeralismatic/.config/awesome/rc.lua:380: in main chunk
error: /usr/share/awesome/lib/gears/shape.lua:397: attempt to call method 'move_to' (a nil value)
Elv13 commented 8 years ago

Look like your prg isn't a Cairo context, also, this function doesn't return anything, so your code looks wrong. You can take a look at the examples in the documentation or the unit tests (they are the same, the official documentation example are auto-generated using the unit tests)

http://new.awesomewm.org/apidoc/libraries/gears.shape.html https://github.com/awesomeWM/awesome/blob/master/tests/examples/gears/shape/radial_progress.lua

Here is my "radial_progressbar" widget code: https://gist.github.com/Elv13/2ef20b71f3a9a37020c1dcc25a7126a1

r3lgar commented 8 years ago

You can take a look at the examples in the documentation

I am.

Look like your prg isn't a Cairo context

I don't understand how it works. With wibox.container.background it work. Is wibox.widget.progressbar hasn't a Cairo context?

Can I manipulate percent in another function?

Elv13 commented 8 years ago

Is wibox.widget.progressbar hasn't a Cairo context?

Widgets are not Cairo context, so this unfortunately wont really work (it would be cool if it did). For now, use the widget I added in the last link. As there seem to be interest in having this kind of visualization, I will brake my words and submit it to Awesome (I said I would not submit any new code until 3.6... Whatever, it cannot cause regressions and I use it since 2011, so it works fine by now). It will be a new container, extending the progressbar isn't really a good idea as they would share almost nothing beside the percent property.

r3lgar commented 8 years ago

Cairo (and lgi) is too complicated for me. I am interested, but I don't understand how it works. %)

Elv13 commented 8 years ago

Let's start by some doc https://github.com/awesomeWM/awesome/pull/959

Elv13 commented 8 years ago

http://new.awesomewm.org/apidoc/documentation/16-using-cairo.md.html

r3lgar commented 8 years ago

Oh, thank you, guys.

psychon commented 8 years ago

Can this be closed? Somehow this started with some broken code and then turned into "let's write some docs" and now I'm confused.

Elv13 commented 8 years ago

Can this be closed?

I guess so. To "fix" this, I would need to upstream my widget that does exactly what @funeralismatic want (see the gist above). However the code isn't good enough for you and I don't want to spend time on this and/or push new code until 3.6 is released.

Better just use the gist above for now and wait for 3.7 "merge window" to open before trying to upstream it.

Elv13 commented 8 years ago

@funeralismatic I upstreamed the widget, see: http://new.awesomewm.org/apidoc/classes/wibox.container.radialprogressbar.html