mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-08-07 09:01:38 -04:00
A new API so that plugins are notified before the library is about to change
Fix #1977979 [Private bug](https://bugs.launchpad.net/calibre/+bug/1977979)
This commit is contained in:
parent
d80d0d55a9
commit
609b431c91
@ -324,6 +324,16 @@ class InterfaceAction(QObject):
|
||||
'''
|
||||
pass
|
||||
|
||||
def library_about_to_change(self, olddb, db):
|
||||
'''
|
||||
Called whenever the current library is changed.
|
||||
|
||||
:param olddb: The LibraryDatabase corresponding to the previous library.
|
||||
:param db: The LibraryDatabase corresponding to the new library.
|
||||
|
||||
'''
|
||||
pass
|
||||
|
||||
def library_changed(self, db):
|
||||
'''
|
||||
Called whenever the current library is changed.
|
||||
|
@ -872,6 +872,12 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
|
||||
return
|
||||
else:
|
||||
return
|
||||
for action in self.iactions.values():
|
||||
try:
|
||||
action.library_about_to_change(olddb, db)
|
||||
except Exception:
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
self.library_path = newloc
|
||||
prefs['library_path'] = self.library_path
|
||||
self.book_on_device(None, reset=True)
|
||||
@ -893,7 +899,11 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
|
||||
self.apply_virtual_library(db.new_api.pref('virtual_lib_on_startup'))
|
||||
self.rebuild_vl_tabs()
|
||||
for action in self.iactions.values():
|
||||
action.library_changed(db)
|
||||
try:
|
||||
action.library_changed(db)
|
||||
except Exception:
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
self.library_broker.gui_library_changed(db, olddb)
|
||||
if self.device_connected:
|
||||
self.set_books_in_library(self.booklists(), reset=True)
|
||||
|
Loading…
x
Reference in New Issue
Block a user