mirror of
https://github.com/GradienceTeam/Gradience.git
synced 2024-07-04 18:27:52 +00:00
feat: add plugin deletion
This commit is contained in:
parent
ce236c0182
commit
ffd626dd43
|
@ -811,6 +811,7 @@ This app is written in Python and uses GTK 4 and libadwaita.
|
|||
self.global_errors + plugins_errors)
|
||||
|
||||
def reload_plugins(self):
|
||||
self.plugins_list.reload()
|
||||
buglog("reload plugins")
|
||||
self.win.content_plugins.remove(self.plugins_group)
|
||||
self.win.content_plugins.remove(self.custom_css_group)
|
||||
|
|
|
@ -20,6 +20,16 @@ from gi.repository import Gtk, Adw
|
|||
|
||||
from .modules.utils import buglog
|
||||
from .constants import rootdir
|
||||
from pathlib import Path
|
||||
import os
|
||||
|
||||
USER_PLUGIN_DIR = Path(
|
||||
os.path.join(
|
||||
os.environ.get("XDG_DATA_HOME", os.environ["HOME"] + "/.local/share"),
|
||||
"gradience",
|
||||
"plugins",
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@Gtk.Template(resource_path=f"{rootdir}/ui/plugin_row.ui")
|
||||
|
@ -52,7 +62,9 @@ class GradiencePluginRow(Adw.ActionRow):
|
|||
|
||||
@Gtk.Template.Callback()
|
||||
def on_remove_plugin_clicked(self, *_args):
|
||||
print("delete")
|
||||
plugin_yapsy_file = USER_PLUGIN_DIR / f"{self.plugin_object.plugin_id}.yapsy-plugin"
|
||||
buglog("remove", plugin_yapsy_file)
|
||||
os.remove(plugin_yapsy_file)
|
||||
Gtk.Application.get_default().reload_plugins()
|
||||
|
||||
@Gtk.Template.Callback()
|
||||
|
|
|
@ -39,16 +39,20 @@ class GradiencePluginsList:
|
|||
|
||||
self.check_if_plugin_dir_exists()
|
||||
|
||||
self.app = self.win.get_application()
|
||||
self.enabled_plugins = set(self.app.settings.get_value("enabled-plugins").unpack())
|
||||
self.rows = {}
|
||||
|
||||
self.reload()
|
||||
|
||||
def reload(self):
|
||||
self.pm = PluginManager()
|
||||
|
||||
self.pm.setPluginPlaces(
|
||||
[
|
||||
USER_PLUGIN_DIR,
|
||||
]
|
||||
)
|
||||
self.pm.collectPlugins()
|
||||
self.rows = {}
|
||||
|
||||
for pluginInfo in self.pm.getAllPlugins():
|
||||
pluginInfo.plugin_object.activate()
|
||||
|
||||
|
@ -57,6 +61,7 @@ class GradiencePluginsList:
|
|||
self.app.settings.get_value("enabled-plugins").unpack()
|
||||
)
|
||||
|
||||
(feat: add plugin deletion)
|
||||
def save_enabled_plugins(self):
|
||||
self.app.settings.set_value(
|
||||
"enabled-plugins", GLib.Variant("as", list(self.enabled_plugins))
|
||||
|
|
Loading…
Reference in a new issue