Originally Posted by kiwidude
Excellent, thanks for the heads up Kovid. I wasn't sure where field_metadata fit into the picture until I found that tag_view.py rebuilds the list of user categories in field_metadata when it's model is refreshed. Sound just what I was after, thanks.
Ok, discovered a fly in the ointment but perhaps you know a workaround. It seems the context menus are only built once at application startup, rather than every time you right-click.
Problem (1) is that means if you add a new user category you won't see it in the menu until you restart. Not the end of the world given how rare you would add new ones.
However the bigger problem (2) is that it "appears" that in the genesis method of the user action I don't have access to the model? I've tried a number of permutations such as self.model(), self.gui.model(), self.gui.library_view.model() but keep getting hit with AttributeError:'xxx' object has no attribute 'model'.
I would presume that the model has not been initialised at the time the menus are created? Is there a plan B or is this approach scuppered? Apologies for being dense.