View Single Post
Old 03-18-2021, 07:23 AM   #407
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,509
Karma: 8065348
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by capink View Post
I've played with gui.tags_view.context_menu_handler(action='hide', category='#genre') and it seems to working. Is there something that makes calling this non desirable?
I don't know. The problem is that the method is normally called when the tag browser is visible and a tag node has the focus. I don't know what happens if either isn't true, or more worrying if there are weird corner cases such as the focus being sometimes yanked to the tag browser. Your plugin could check for tag browser visible, but what do you do if it isn't visible? I don't know how to check for focus.

If you want to play with it then this might work. It uses "recount()' which is what calibre uses when the tag browser data has changed.
Code:
tag_browser = gui.tags_view
cats = tag_browser.hidden_categories
# modify cats as needed, adding or removing categories. It is a set()
self.db.new_api.set_pref('tag_browser_hidden_categories', list(cats))
tag_browser.recount()
EDIT: If the above does work then I could add it as a public API, something like
Code:
change_hidden_categories(operation, category_set)

Last edited by chaley; 03-18-2021 at 10:02 AM.
chaley is offline   Reply With Quote