Kodi Community Forum
Virtual Python Folders - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26)
+--- Thread: Virtual Python Folders (/showthread.php?tid=27760)

Pages: 1 2 3 4 5 6 7 8 9


- Nuka1195 - 2007-08-19

We need a way to hide the cancel button on progress dialogs. Not necessarily related to this, but there are instances where you should not be allowed to cancel.

There is a script ended message in the log when it exits, but maybe if the script hasn't updated the progressbar after a set time consider in frozen?


- jmarshall - 2007-08-19

We can probably check with the python manager whether something is still running or not, and fail in that case. Also, EndDirectory() could take a bool parameter for failed or succeeded in case something in the script failed that was picked up. That with the addition of the cancel button should be enough I suspect?

So how will the cancel of the script work, other than just requesting python to kill the script? I don't think we can do anything other than this, which isn't exactly a "nice" way to fail.

The labelMasks are what is displayed for label1 and label2 for each item, which can change based on sort criteria. Not sure if this should be determined by XBMC or not - up to you guys.

Cheers,
Jonathan


- Unbehagen - 2007-08-19

jmarshall Wrote:So how will the cancel of the script work, other than just requesting python to kill the script? I don't think we can do anything other than this, which isn't exactly a "nice" way to fail.
What about a python method cancelPressed, that gives true if the user pressed the button? The script would be free to call it and react to a cancel, but will get killed after a grace period. So scripters could call that function after each addItem and react appropriately if they want to. Otherwise, the script will be killed after 1 second or so. What do you think?


- jmarshall - 2007-08-19

Well, setDirectoryItem() could return a bool/int that could return failed if the user cancelled the script. We then give it a grace period of a second or two before killing.

Sounds like an nice and easy solution Smile


- Nuka1195 - 2007-08-19

Yes,
ok = setDirectoryItem()
if not ok: break

This way setDirectory returns False if cancel is pressed or you could return True if canceled.

canceled = setDirectoryItem()
if canceled: break


- Unbehagen - 2007-08-19

That is a good idea, jmarshall.

Just a minor cosmetic thingy: someone should finally rename that method to addDirectoryItem or something. It really isn't a setter method after all. It adds something to some object... I know I did this terrible thing. Sorry for that. Please don't keep that name...


- Nuka1195 - 2007-08-19

http://pastebin.ca/662688

Here's what I came up with for addSortMethod().

I left the one in EndOfDirectory(), thinking addSortMethod() may never be called?

I will add checks for those sort methods that exclude the when sorting.

You just pass a handle and a sortmethod. xbmc.addSortMethod( handle, sortMethod )

I'll finish it if that's acceptable.

addDirectoryItem() sound better to me.


- Unbehagen - 2007-08-19

Nuka1195 Wrote:sortMethod : Integer - Number for sortmethod see FileItem.h.\n
You should probably add those as constants in the xbmc module and add a check for correct parameters.


- jmarshall - 2007-08-19

That's the idea, yeah.

I suggest removing the sort order in EndOfDirectory - if no sort order is specified it should use whatever XBMC has available to it by default IMO.

You'll also need to add the sort by label method in ofcourse, unless we decide that that should always be there (if so, add it first in GetDirectory()).

Also, we don't want CPluginDirectory:: in the .h file (cross-platform compatibility).

And yeah, let's change it to AddDirectoryItem instead of Set, and allow it to return true or false - false means that we want the script to terminate, so scripter should stop processing and call EndDirectory() immediately.

Also, allow EndDirectory() to take in a boolean parameter indicating success or failure.

We can always extend the AddSortMethod() procedure to take in the label masks (optional parameter) at a later date if we decide it is worth it.

Cheers,
Jonathan


- Nuka1195 - 2007-08-19

Ok, I took care of all those JMarshall. My copy and paste skills are lacking.

I'll test some more tomorrow then commit.


- jmarshall - 2007-08-19

Cool - I'll work on the progressbar/cancellability later today.


- jmarshall - 2007-08-19

Number 1 above (cancellability and progress bar) is done and is in SVN now.

Not sure if the "failure" from the script requires a prompt for the reason or not (and if so, whether we need to pass a script into the EndDirectory() function).

Otherwise, I think once Nuka1195 has his changes in, this is almost SVN ready. Ideally the context menu stuff will be done as well before we get it in, but that's more icing on the cake, and I really want some other scripters (Asteron, stanley) to be able to try it out without the hassle of the separate branch.

Revision 9988 has my changes.

Cheers,
Jonathan


- Nuka1195 - 2007-08-19

http://xbmc-scripting.googlecode.com/svn/old/AppleMovieTrailersPlugin.zip

My changes are in, but, the addSortMethod() doesn't work. From the script I added one for each example you had in EndOfDirectory(), and the only one that shows is name. When they were in EndOfDirectory() they worked, so I missed something.

It's late and I'm tired, so if you don't fix this by tomorrow I'll have another look.

Thanks


- Nuka1195 - 2007-08-19

fixed: CPluginDirectory::AddSortMethod, it's == not =, argh

Unbelievable


- jmarshall - 2007-08-19

Changes are fine - have just done some (very) minor cleanup.

IMO we're pretty much ready for trunk now, but it's up to you guys as to whether or not the context menu stuff is done first or not - I don't mind either way.

Ideally we'd have more than one script (i.e. not just AMT) ready to go as examples so that people can get cracking on testing it out straight away.

Cheers,
Jonathan