From 769248295583cbb19c55f67f195b63e27b077926 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 17 Aug 2010 16:16:22 -0600 Subject: [PATCH] Do not allow library to be changed when device is connected/jobs are running --- src/calibre/gui2/actions/choose_library.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/calibre/gui2/actions/choose_library.py b/src/calibre/gui2/actions/choose_library.py index 7bdbcf748a..29e508aff2 100644 --- a/src/calibre/gui2/actions/choose_library.py +++ b/src/calibre/gui2/actions/choose_library.py @@ -137,6 +137,8 @@ class ChooseLibraryAction(InterfaceAction): self.qaction.setEnabled(enabled) def switch_requested(self, location): + if not self.change_library_allowed(): + return loc = location.replace('/', os.sep) exists = self.gui.library_view.model().db.exists_at(loc) if not exists: @@ -164,9 +166,23 @@ class ChooseLibraryAction(InterfaceAction): a.setWhatsThis(tooltip) def choose_library(self, *args): + if not self.change_library_allowed(): + return from calibre.gui2.dialogs.choose_library import ChooseLibrary db = self.gui.library_view.model().db c = ChooseLibrary(db, self.gui.library_moved, self.gui) c.exec_() + def change_library_allowed(self): + if self.gui.device_connected: + warning_dialog(self.gui, _('Not allowed'), + _('You cannot change libraries when a device is' + ' connected.'), show=True) + return False + if self.gui.job_manager.has_jobs(): + warning_dialog(self.gui, _('Not allowed'), + _('You cannot change libraries while jobs' + ' are running.'), show=True) + return False + return True