mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-14 08:17:13 +03:00
Add a tab to the Settings dialog. Users can directly open the plugins folder. Can also disable plugins by adding ".disabled" to the end of their folder name.
This commit is contained in:
parent
2810b61bda
commit
bc657f55fe
13
plug.py
13
plug.py
@ -19,12 +19,17 @@ def find_plugins():
|
||||
:return:
|
||||
"""
|
||||
found = dict()
|
||||
disabled = list()
|
||||
plug_folders = os.listdir(config.plugin_dir)
|
||||
for name in plug_folders:
|
||||
if name.endswith(".disabled"):
|
||||
name, discard = name.rsplit(".", 1)
|
||||
disabled.append(name)
|
||||
continue
|
||||
loadfile = os.path.join(config.plugin_dir, name, "load.py")
|
||||
if os.path.isfile(loadfile):
|
||||
found[name] = loadfile
|
||||
return found
|
||||
return found, disabled
|
||||
|
||||
|
||||
def load_plugins():
|
||||
@ -32,10 +37,14 @@ def load_plugins():
|
||||
Load all found plugins
|
||||
:return:
|
||||
"""
|
||||
found = find_plugins()
|
||||
found, disabled = find_plugins()
|
||||
imp.acquire_lock()
|
||||
for plugname in disabled:
|
||||
sys.stdout.write("plugin {} disabled\n".format(plugname))
|
||||
|
||||
for plugname in found:
|
||||
try:
|
||||
sys.stdout.write("loading plugin {}\n".format(plugname))
|
||||
with open(found[plugname], "rb") as plugfile:
|
||||
plugmod = imp.load_module(plugname, plugfile, found[plugname],
|
||||
(".py", "r", imp.PY_SOURCE))
|
||||
|
32
prefs.py
32
prefs.py
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
from os.path import dirname, expanduser, expandvars, exists, isdir, join, normpath
|
||||
from sys import platform
|
||||
|
||||
@ -306,6 +306,36 @@ class PreferencesDialog(tk.Toplevel):
|
||||
|
||||
notebook.add(themeframe, text=_('Appearance')) # Tab heading in settings
|
||||
|
||||
# Plugin settings and info
|
||||
plugsframe = nb.Frame(notebook)
|
||||
plugsframe.columnconfigure(1, weight=1)
|
||||
plugdir = config.plugin_dir
|
||||
|
||||
plugnames, disabled_plugins = plug.find_plugins()
|
||||
|
||||
nb.Label(plugsframe, text=_('Plugins Folder:')).grid(padx=PADX, sticky=tk.W)
|
||||
nb.Label(plugsframe, text=plugdir).grid(padx=PADX, sticky=tk.W)
|
||||
if platform == "win32":
|
||||
nb.Button(plugsframe, text="Open",
|
||||
command=lambda: os.startfile(plugdir)).grid(padx=PADX, sticky=tk.W)
|
||||
|
||||
nb.Label(plugsframe, text=_("Tip: You can disable a plugin by\nadding '.disabled' to it's folder name")).grid(
|
||||
padx=PADX, pady=10, sticky=tk.NSEW)
|
||||
|
||||
if len(plugnames):
|
||||
ttk.Separator(plugsframe, orient=tk.HORIZONTAL).grid(columnspan=3, padx=PADX, pady=PADY * 8, sticky=tk.EW)
|
||||
nb.Label(plugsframe, text=_('Enabled Plugins:')).grid(padx=PADX, sticky=tk.W)
|
||||
for plugname in plugnames:
|
||||
nb.Label(plugsframe, text=plugname).grid(padx=PADX + 5, sticky=tk.W)
|
||||
if len(disabled_plugins):
|
||||
ttk.Separator(plugsframe, orient=tk.HORIZONTAL).grid(columnspan=3, padx=PADX, pady=PADY * 8, sticky=tk.EW)
|
||||
nb.Label(plugsframe, text=_('Disabled Plugins:')).grid(padx=PADX, sticky=tk.W)
|
||||
for plugname in disabled_plugins:
|
||||
nb.Label(plugsframe, text=plugname).grid(padx=PADX + 5, sticky=tk.W)
|
||||
|
||||
notebook.add(plugsframe, text=_('Plugins'))
|
||||
|
||||
|
||||
if platform=='darwin':
|
||||
self.protocol("WM_DELETE_WINDOW", self.apply) # close button applies changes
|
||||
else:
|
||||
|
Loading…
x
Reference in New Issue
Block a user