Quote:
Originally Posted by Terisa de morgan
Asking again, sorry  I haven't found information about this. Is it possible to define an action that allows to select the column you want to modify in runtime, not changing configuration? I would like to edit different custom columns and I would like to define an action for every column.
|
I am not sure I totally understand what you want. But there are two possible solutions for this:
- Create a chain that have multiple actions to edit the custom columns you want. And set a condition on the actions, that will only evaluate to true for the actively selected column in Calibre's book details.
Code:
python:
def evaluate(book, context):
from calibre.gui2.ui import get_gui
gui = get_gui()
index = gui.library_view.currentIndex()
if gui.grid_view_button.isChecked():
column_name = ''
else:
model = index.model()
column_map = model.column_map
column_name = column_map[index.column()]
return column_name
This template returns the name of the actively selected column in the book view. Use it with every action in the chain to match the custom column name of each particular column.
Note: For some reason, this template does not work if you have a double panned view.
- Use Chain Variants to create multiple menu entries for the same chain (you can put them all in submenu). Each custom column will have an associated menu entry which you can click at runtime. You will also need to put a condition separately for each action to make sure the variant argument matches the custom column of the action.