diff --git a/gramps/cli/arghandler.py b/gramps/cli/arghandler.py index 3a99a8415..275053d14 100644 --- a/gramps/cli/arghandler.py +++ b/gramps/cli/arghandler.py @@ -152,15 +152,11 @@ class ArgHandler(object): def __init__(self, dbstate, parser, sessionmanager, errorfunc=None, gui=False): - from .user import User - self.dbstate = dbstate self.sm = sessionmanager self.errorfunc = errorfunc self.gui = gui - self.user = User(error=self.__error, - auto_accept=parser.auto_accept, - quiet=parser.quiet) + self.user = sessionmanager.user if self.gui: self.actions = [] self.list = False diff --git a/gramps/cli/grampscli.py b/gramps/cli/grampscli.py index 6b9240da3..03cfe04ef 100644 --- a/gramps/cli/grampscli.py +++ b/gramps/cli/grampscli.py @@ -213,7 +213,7 @@ class CLIManager(object): Aim is to manage a dbstate on which to work (load, unload), and interact with the plugin session """ - def __init__(self, dbstate, setloader): + def __init__(self, dbstate, setloader, user): self.dbstate = dbstate if setloader: self.db_loader = CLIDbLoader(self.dbstate) @@ -221,6 +221,7 @@ class CLIManager(object): self.db_loader = None self.file_loaded = False self._pmgr = BasePluginManager.get_instance() + self.user = user def open_activate(self, path): """ @@ -335,8 +336,14 @@ def startcli(errors, argparser): #we need to keep track of the db state dbstate = DbState() + #we need a manager for the CLI session - climanager = CLIManager(dbstate, True) + from .user import User + user=User(error=self.__error, + auto_accept=argparser.auto_accept, + quiet=argparser.quiet) + climanager = CLIManager(dbstate, setloader=True, user=user) + #load the plugins climanager.do_reg_plugins(dbstate, uistate=None) # handle the arguments diff --git a/gramps/gen/merge/diff.py b/gramps/gen/merge/diff.py index ac5f4a0aa..8b3f2c947 100644 --- a/gramps/gen/merge/diff.py +++ b/gramps/gen/merge/diff.py @@ -43,7 +43,7 @@ def import_as_dict(filename, user=None): user = User() db = DictionaryDb() dbstate = DbState() - climanager = CLIManager(dbstate, False) # do not load db_loader + climanager = CLIManager(dbstate, setloader=False, user=user) climanager.do_reg_plugins(dbstate, None) pmgr = BasePluginManager.get_instance() (name, ext) = os.path.splitext(os.path.basename(filename)) diff --git a/gramps/gui/grampsgui.py b/gramps/gui/grampsgui.py index a0b634ef7..83fd3f7fa 100644 --- a/gramps/gui/grampsgui.py +++ b/gramps/gui/grampsgui.py @@ -272,7 +272,8 @@ See the Gramps README documentation for installation prerequisites, typically located in /usr/share/doc/gramps.""") % glocale.lang) dbstate = DbState() - self.vm = ViewManager(dbstate, config.get("interface.view-categories")) + self.vm = ViewManager(dbstate, + config.get("interface.view-categories")) self.vm.init_interface() #act based on the given arguments diff --git a/gramps/gui/viewmanager.py b/gramps/gui/viewmanager.py index aec579a73..c9846d02f 100644 --- a/gramps/gui/viewmanager.py +++ b/gramps/gui/viewmanager.py @@ -273,13 +273,13 @@ class ViewManager(CLIManager): """ - def __init__(self, dbstate, view_category_order): + def __init__(self, dbstate, view_category_order, user = None): """ The viewmanager is initialised with a dbstate on which GRAMPS is working, and a fixed view_category_order, which is the order in which the view categories are accessible in the sidebar. """ - CLIManager.__init__(self, dbstate, False) + CLIManager.__init__(self, dbstate, setloader=False, user=user) if _GTKOSXAPPLICATION: self.macapp = QuartzApp.Application() @@ -304,7 +304,11 @@ class ViewManager(CLIManager): self.show_toolbar = config.get('interface.toolbar-on') self.fullscreen = config.get('interface.fullscreen') - self.__build_main_window() + self.__build_main_window() # sets self.uistate + if self.user is None: + self.user = User(error=ErrorDialog, + callback=self.uistate.pulse_progressbar, + uistate=self.uistate) self.__connect_signals() if _GTKOSXAPPLICATION: self.macapp.ready() @@ -1317,17 +1321,11 @@ class ViewManager(CLIManager): self.uistate.push_message(self.dbstate, _("Making backup...")) if include.get_active(): from gramps.plugins.export.exportpkg import PackageWriter - writer = PackageWriter(self.dbstate.db, filename, - User(error=ErrorDialog, - callback=self.uistate.pulse_progressbar, - uistate=self.uistate)) + writer = PackageWriter(self.dbstate.db, filename, self.user) writer.export() else: from gramps.plugins.export.exportxml import XmlWriter - writer = XmlWriter(self.dbstate.db, - User(error=ErrorDialog, - callback=self.uistate.pulse_progressbar, - uistate=self.uistate), + writer = XmlWriter(self.dbstate.db, self.user, strip_photos=0, compress=1) writer.write(filename) self.uistate.set_busy_cursor(False) diff --git a/gramps/guiQML/viewmanager.py b/gramps/guiQML/viewmanager.py index 2164fc399..5385eb159 100644 --- a/gramps/guiQML/viewmanager.py +++ b/gramps/guiQML/viewmanager.py @@ -78,16 +78,21 @@ class ViewManager(CLIManager): """ Manages main widget by holding what state it is in. """ - def __init__(self, dbstate): + def __init__(self, dbstate, user = None): """ The viewmanager is initialised with a dbstate on which GRAMPS is working. """ self.__centralview = None - CLIManager.__init__(self, dbstate, False) + CLIManager.__init__(self, dbstate, setloader=False, user=user) self.db_loader = CLIDbLoader(self.dbstate) #there is one DeclarativeEngine for global settings self.__build_main_window() + from .questiondialog import ErrorDialog + if self.user is None: + self.user = User(error=ErrorDialog, + callback=self.uistate.pulse_progressbar, + uistate=self.uistate) def __build_main_window(self): """