Quote:
Originally Posted by capink
This custom action seems to be working even when the tag browser has no focus and also when it is hidden
|
I am adding API to do the task. Could you test it? It works for me.
Add this at line 438 of gui2.tag_browser.ui
Code:
def change_tb_category_visibility(self, category, operation):
'''
Hide or show categories in the tag browser. 'category' is the lookup key
to show or hide. Set operation == 'show' or 'hide' as needed.
'''
if category not in self.tags_view.model().categories:
raise ValueError(_('change_tb_category_visibility: category %s does not exist') % category)
cats = self.tags_view.hidden_categories
if operation == 'hide':
cats.add(category)
elif operation == 'show':
cats.discard(category)
else:
raise ValueError(_('change_tb_category_visibility: invalid operation %s') % operation)
self.library_view.model().db.new_api.set_pref('tag_browser_hidden_categories', list(cats))
self.tags_view.recount()
Change the code of your module at line 212 as follows:
Code:
#tag_browser.context_menu_handler(action=visibility, category=category_key)
# if visibility == 'show':
# hidden_categories.discard(category_key)
# else:
# hidden_categories.add(category_key)
# db.new_api.set_pref('tag_browser_hidden_categories', list(hidden_categories))
# tag_browser.recount()
gui.change_tb_category_visibility(category_key, visibility)
As you can see, the code that changed the hidden categories and the calls into the tag browser were replaced by
Code:
gui.change_tb_category_visibility(category_key, visibility)