Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug 808] Plugins-dont-receive-keboard-signals-on-newly-opened-windows #809

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions terminatorlib/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,14 @@ def prepare_attributes(self):
if not self.available_plugins:
self.available_plugins = {}

def load_plugins(self):
def load_plugins(self, force=False):
"""Load all plugins present in the plugins/ directory in our module"""
if self.done:
if self.done and (not force):
dbg('Already loaded')
return

dbg('loading plugins, force:(%s)' % force)

config = Config()

for plugindir in self.path:
Expand All @@ -93,15 +95,23 @@ def load_plugins(self):
try:
module = __import__(plugin[:-3], None, None, [''])
for item in getattr(module, 'AVAILABLE'):
func = getattr(module, item)
if item not in list(self.available_plugins.keys()):
func = getattr(module, item)
self.available_plugins[item] = func

if item not in config['enabled_plugins']:
dbg('plugin %s not enabled, skipping' % item)
continue
if item not in self.instances:
self.instances[item] = func()
elif force:
#instead of multiple copies of loaded
#plugin objects, unload where plugins
#can clean up and then re-init so there
#is one plugin object
self.instances[item].unload()
self.instances.pop(item, None)
self.instances[item] = func()
except Exception as ex:
err('PluginRegistry::load_plugins: Importing plugin %s \
failed: %s' % (plugin, ex))
Expand Down
11 changes: 11 additions & 0 deletions terminatorlib/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,13 @@ def __init__(self):
dbg('composite_support: %s' % self.composite_support)

self.vte.show()

#force to load for new window/terminal use case loading plugin
#and connecting signals, note the line update_url_matches also
#calls load_plugins, but it won't reload since already loaded

self.load_plugins(force = True)

self.update_url_matches()

self.terminalbox = self.create_terminalbox()
Expand Down Expand Up @@ -285,6 +292,10 @@ def create_terminalbox(self):

return(terminalbox)

def load_plugins(self, force = False):
registry = plugin.PluginRegistry()
registry.load_plugins(force)

def _add_regex(self, name, re):
match = -1
if regex.FLAGS_PCRE2:
Expand Down