From 04d6ca3a49ec52e59a9afdc0dd8d6fea8f2c4d7f Mon Sep 17 00:00:00 2001 From: Nick Hall Date: Thu, 22 Mar 2018 23:02:00 +0000 Subject: [PATCH] Disable family tree manager features when a backend is unavailable If the default backend is unavailable, then reset it to bsddb. --- gramps/cli/clidbman.py | 3 ++- gramps/gui/dbman.py | 12 +++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/gramps/cli/clidbman.py b/gramps/cli/clidbman.py index 7e79a922f..63335f1bd 100644 --- a/gramps/cli/clidbman.py +++ b/gramps/cli/clidbman.py @@ -70,6 +70,7 @@ DEFAULT_TITLE = _("Family Tree") NAME_FILE = "name.txt" BACKEND_FILE = "database.txt" META_NAME = "meta_data.db" +UNAVAILABLE = _('Unavailable') #------------------------------------------------------------------------- # @@ -183,7 +184,7 @@ class CLIDbManager: for plugin in pmgr.get_reg_databases(): if plugin.id == dbid: return plugin._name - return _("Unknown") + return UNAVAILABLE def print_family_tree_summaries(self, database_names=None): """ diff --git a/gramps/gui/dbman.py b/gramps/gui/dbman.py index 03b158276..fb6ae0d1b 100644 --- a/gramps/gui/dbman.py +++ b/gramps/gui/dbman.py @@ -57,7 +57,7 @@ from gramps.gen.const import URL_WIKISTRING, URL_MANUAL_PAGE from .user import User from .dialog import ErrorDialog, QuestionDialog, QuestionDialog2, ICON from .pluginmanager import GuiPluginManager -from gramps.cli.clidbman import CLIDbManager, NAME_FILE, time_val +from gramps.cli.clidbman import CLIDbManager, NAME_FILE, time_val, UNAVAILABLE from .managedwindow import ManagedWindow from .ddtargets import DdTargets from gramps.gen.recentfiles import rename_filename, remove_filename @@ -313,6 +313,12 @@ class DbManager(CLIDbManager, ManagedWindow): self.connect_btn.set_sensitive(False) if _RCS_FOUND: self.rcs_btn.set_sensitive(True) + elif store.get_value(node, BACKEND_COL) == UNAVAILABLE: + self.close_btn.set_sensitive(False) + self.convert_btn.set_sensitive(False) + self.connect_btn.set_sensitive(False) + self.rcs_btn.set_sensitive(False) + self.repair_btn.set_sensitive(False) else: self.close_btn.set_sensitive(False) dbid = config.get('database.backend') @@ -361,6 +367,10 @@ class DbManager(CLIDbManager, ManagedWindow): # Put some help on the buttons: dbid = config.get('database.backend') backend_type = self.get_backend_name_from_dbid(dbid) + if backend_type == UNAVAILABLE: + dbid = 'bsddb' + config.set('database.backend', dbid) + backend_type = self.get_backend_name_from_dbid(dbid) self.new_btn.set_tooltip_text(backend_type) # build the database name column