View Single Post
Old 12-21-2020, 03:45 PM   #161
capink
Wizard
capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.
 
Posts: 1,203
Karma: 1995558
Join Date: Aug 2015
Device: Kindle
Quote:
Originally Posted by ownedbycats View Post
I tested it. It worked as expected.

I wonder if there might be a way to set a chain so that it appears greyed-out in the menu if multiple books are selected. Some actions don't work well on multiple books and it would prevent misclicks.
Coming in the next release, will be template based solution to enable/disable chains. Will also solve your problem about device not connected. See discussion below.

Quote:
Originally Posted by capink View Post
@chaley: I have implemented the changes, and they are working OK. The modifications you made to templates have simplified things for me, and the global variables opened up some new possibilities as well.

I am getting a lit bit greedy here, but after implementing the conditional execution for actions, I am now thinking about a similar thing but for the whole chain, since I can pass some state variables (number of selected books ... etc), and if conditions are not met, the chain action and menu entry would be disabled.

I started building a simple widget based on your template tester, with some extra things like datatype and comparison operator. Then, I started to wonder if I can leverage the template tab (in the search dialog), since it already contains similar functionality. If this tab can not be used, can I at least return a string like:

Code:
template:"program: globals(selection_count)#@#:n:>1"
and pass a mi object along with the above string to some function in calibre that would return True/False, or do I have to re-implement this myself (I might end up using this for conditional execution of actions and scrap the two column solution I've already implemented).

I did have a look and I found a create_template_tab function, which might be useful for building the widget, but I don't know what to do beyond that.
capink is offline   Reply With Quote