Commit 387672d9 authored by Philipp Hörist's avatar Philipp Hörist

PluginManager: Refactor loading plugins

- Auto enable all plugins in the base folder, this allows package
maintainers to ship plugins

- Give plugins in the user folder priority over plugins in the base
folder
parent 8913d83a
Pipeline #5826 passed with stages
in 5 minutes and 35 seconds
......@@ -42,12 +42,12 @@ def get(key: str) -> str:
return _paths[key]
def get_plugin_dirs() -> List[str]:
def get_plugin_dirs() -> List[Path]:
if gajim.IS_FLATPAK:
return ['/app/plugins',
_paths['PLUGINS_BASE']]
return [_paths['PLUGINS_BASE'],
_paths['PLUGINS_USER']]
return [Path(_paths['PLUGINS_BASE']),
Path('/app/plugins')]
return [Path(_paths['PLUGINS_BASE']),
Path(_paths['PLUGINS_USER'])]
def get_paths(type_: PathType) -> Generator[str, None, None]:
......
......@@ -1901,11 +1901,7 @@ class Interface:
self.avatar_storage = AvatarStorage()
cfg_was_read = parser.read()
if not cfg_was_read:
# enable plugin_installer by default when creating config file
app.config.set_per('plugins', 'plugin_installer', 'active', True)
parser.read()
# Load CSS files
app.load_css_config()
......
......@@ -30,7 +30,6 @@ from gi.repository import GdkPixbuf
from gi.repository import Gdk
from gajim.common import app
from gajim.common import configpaths
from gajim.common import ged
from gajim.common.exceptions import PluginsystemError
from gajim.common.helpers import open_uri
......@@ -167,8 +166,7 @@ class PluginsWindow(Gtk.ApplicationWindow, EventHelper):
self._ui.description.set_text(plugin.description)
self._ui.uninstall_plugin_button.set_sensitive(
configpaths.get('PLUGINS_USER') in plugin.__path__)
self._ui.uninstall_plugin_button.set_sensitive(True)
self._ui.configure_plugin_button.set_sensitive(
plugin.config_dialog is not None)
......
......@@ -27,7 +27,9 @@ from typing import List
import logging
import functools
from pathlib import Path
from gajim.common import configpaths
from gajim.plugins import plugins_i18n
from gajim.gtk.util import Builder
......@@ -121,3 +123,9 @@ def get_builder(file_name: str, widgets: List[str] = None) -> Builder:
widgets,
domain=plugins_i18n.DOMAIN,
gettext_=plugins_i18n._)
def is_shipped_plugin(path):
base = Path(configpaths.get('PLUGINS_BASE'))
plugin_parent = Path(path).parent
return base.samefile(plugin_parent)
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment