diff --git a/gramps/cli/grampscli.py b/gramps/cli/grampscli.py index 7c1ffa8b7..988e7898d 100644 --- a/gramps/cli/grampscli.py +++ b/gramps/cli/grampscli.py @@ -331,11 +331,11 @@ class CLIManager: recent_files(filename, name) self.file_loaded = True - def do_reg_plugins(self, dbstate, uistate): + def do_reg_plugins(self, dbstate, uistate, rescan=False): """ Register the plugins at initialization time. """ - self._pmgr.reg_plugins(PLUGINS_DIR, dbstate, uistate) + self._pmgr.reg_plugins(PLUGINS_DIR, dbstate, uistate, rescan=rescan) self._pmgr.reg_plugins(USER_PLUGINS, dbstate, uistate, load_on_reg=True) def startcli(errors, argparser): diff --git a/gramps/gen/plug/_manager.py b/gramps/gen/plug/_manager.py index 152b5862d..31f1b5d2f 100644 --- a/gramps/gen/plug/_manager.py +++ b/gramps/gen/plug/_manager.py @@ -104,7 +104,7 @@ class BasePluginManager: self.__scanned_dirs = [] def reg_plugins(self, direct, dbstate=None, uistate=None, - load_on_reg=False): + load_on_reg=False, rescan=False): """ Searches the specified directory, and registers python plugin that are being defined in gpr.py files. @@ -112,6 +112,14 @@ class BasePluginManager: If a relationship calculator for env var LANG is present, it is immediately loaded so it is available for all. """ + if rescan: + self.__import_plugins = [] + self.__export_plugins = [] + self.__docgen_plugins = [] + self.__docgen_names = [] + self.__scanned_dirs = [] + self.__pgr._PluginRegister__plugindata = [] + self.__pgr._PluginRegister__id_to_pdata = {} # if we've already scanned this directory or if the directory does not # exist, we are done. Should only happen in tests. @@ -300,6 +308,8 @@ class BasePluginManager: self.__import_plugins = [] self.__export_plugins = [] self.__docgen_plugins = [] + self.__docgen_names = [] + def reload_plugins(self): """ Reload previously loaded plugins """ diff --git a/gramps/gui/configure.py b/gramps/gui/configure.py index f3c6cc0e7..f9633382f 100644 --- a/gramps/gui/configure.py +++ b/gramps/gui/configure.py @@ -1421,7 +1421,10 @@ class GrampsPreferences(ConfigureDialog): return if len(addon_update_list) > 0: - PluginWindows.UpdateAddons(self.uistate, self.track, addon_update_list) + rescan = PluginWindows.UpdateAddons(self.uistate, self.track, + addon_update_list).rescan + self.uistate.viewmanager.do_reg_plugins(self.dbstate, self.uistate, + rescan=rescan) else: check_types = config.get('behavior.check-for-addon-update-types') OkDialog( @@ -1434,7 +1437,6 @@ class GrampsPreferences(ConfigureDialog): # Dead code for l10n _('new'), _('update') - self.uistate.viewmanager.do_reg_plugins(self.dbstate, self.uistate) def database_backend_changed(self, obj): the_list = obj.get_model() diff --git a/gramps/gui/plug/_windows.py b/gramps/gui/plug/_windows.py index bb03cd334..627e655f2 100644 --- a/gramps/gui/plug/_windows.py +++ b/gramps/gui/plug/_windows.py @@ -1082,6 +1082,7 @@ class UpdateAddons(ManagedWindow): self.set_window(glade.toplevel, None, None) self.window.set_title(self.title) self.setup_configs("interface.updateaddons", 750, 400) + self.rescan = False apply_button = glade.get_object('apply') cancel_button = glade.get_object('cancel') @@ -1137,6 +1138,7 @@ class UpdateAddons(ManagedWindow): self.list.selection.select_iter(pos) self.show() + self.window.run() def build_menu_names(self, obj): return (self.title, " ") @@ -1210,6 +1212,7 @@ class UpdateAddons(ManagedWindow): ", ".join(errors), parent=self.parent_window) if count: + self.rescan = True OkDialog(_("Done downloading and installing addons"), # translators: leave all/any {...} untranslated "%s %s" % (ngettext("{number_of} addon was installed.", diff --git a/gramps/gui/viewmanager.py b/gramps/gui/viewmanager.py index 18d7aa182..b2c202c41 100644 --- a/gramps/gui/viewmanager.py +++ b/gramps/gui/viewmanager.py @@ -344,8 +344,9 @@ class ViewManager(CLIManager): """ Called when add-on updates are available. """ - PluginWindows.UpdateAddons(self.uistate, [], addon_update_list) - self.do_reg_plugins(self.dbstate, self.uistate) + rescan = PluginWindows.UpdateAddons(self.uistate, [], + addon_update_list).rescan + self.do_reg_plugins(self.dbstate, self.uistate, rescan=rescan) def _errordialog(self, title, errormessage): """ @@ -727,14 +728,15 @@ class ViewManager(CLIManager): if not self.dbstate.is_open() and show_manager: self.__open_activate(None) - def do_reg_plugins(self, dbstate, uistate): + def do_reg_plugins(self, dbstate, uistate, rescan=False): """ Register the plugins at initialization time. The plugin status window is opened on an error if the user has requested. """ # registering plugins self.uistate.status_text(_('Registering plugins...')) - error = CLIManager.do_reg_plugins(self, dbstate, uistate) + error = CLIManager.do_reg_plugins(self, dbstate, uistate, + rescan=rescan) # get to see if we need to open the plugin status window if error and config.get('behavior.pop-plugin-status'):