2022-08-11 08:16:44 +00:00
|
|
|
# plugins_list.py
|
|
|
|
#
|
|
|
|
# Change the look of Adwaita, with ease
|
2022-08-15 23:23:21 +00:00
|
|
|
# Copyright (C) 2022 Gradience Team
|
2022-08-11 08:16:44 +00:00
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
2022-08-11 16:39:52 +00:00
|
|
|
#
|
2022-08-11 08:16:44 +00:00
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
2022-08-11 16:39:52 +00:00
|
|
|
#
|
2022-08-11 08:16:44 +00:00
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
2022-08-23 17:38:09 +00:00
|
|
|
import sys
|
2022-08-10 16:24:28 +00:00
|
|
|
import os
|
|
|
|
import importlib
|
2022-08-13 16:30:41 +00:00
|
|
|
import pkgutil
|
2022-08-23 17:38:09 +00:00
|
|
|
|
2022-08-19 12:44:02 +00:00
|
|
|
from gi.repository import Gtk, Adw, Gio, Gdk
|
2022-09-01 14:06:04 +00:00
|
|
|
import pluggy
|
2022-08-11 16:39:52 +00:00
|
|
|
|
2022-08-23 17:38:09 +00:00
|
|
|
from pathlib import Path
|
|
|
|
from .modules.utils import buglog
|
|
|
|
from .plugin_row import GradiencePluginRow
|
2022-08-19 13:06:34 +00:00
|
|
|
|
2022-08-17 21:35:59 +00:00
|
|
|
|
2022-08-19 12:32:02 +00:00
|
|
|
class GradiencePluginsList:
|
2022-09-01 14:06:04 +00:00
|
|
|
def __init__(self, win):
|
|
|
|
|
|
|
|
self.win = win
|
|
|
|
|
|
|
|
self.plugins = win.settings.get_list("plugins-enabled")
|
|
|
|
buglog(self.plugins)
|
2022-08-10 16:24:28 +00:00
|
|
|
|
2022-08-10 15:51:55 +00:00
|
|
|
def load_all_custom_settings(self, settings):
|
|
|
|
for plugin_id, plugin in self.plugins.items():
|
2022-08-13 16:30:41 +00:00
|
|
|
plugin.load_custom_settings(settings)
|
2022-08-10 15:51:55 +00:00
|
|
|
|
|
|
|
def get_all_custom_settings_for_preset(self):
|
|
|
|
custom_settings = {}
|
|
|
|
for plugin_id, plugin in self.plugins.items():
|
2022-08-11 16:39:52 +00:00
|
|
|
custom_settings[plugin_id] = plugin.get_custom_settings_for_preset()
|
2022-08-19 12:44:02 +00:00
|
|
|
|
|
|
|
def to_group(self):
|
|
|
|
group = Adw.PreferencesGroup()
|
|
|
|
group.set_title(_("Plugins"))
|
2022-08-19 12:45:50 +00:00
|
|
|
group.set_description(
|
|
|
|
_("Plugins add additional features to Gradience, plugins are made by Gradience community and can make issues."))
|
2022-08-19 13:30:42 +00:00
|
|
|
if self.plugins:
|
|
|
|
for plugin_id, plugin in self.plugins.items():
|
|
|
|
row = GradiencePluginRow(plugin.title, plugin_id)
|
2022-08-19 18:49:02 +00:00
|
|
|
self.rows[plugin_id] = row
|
2022-08-19 13:30:42 +00:00
|
|
|
group.add(row)
|
2022-08-19 12:44:02 +00:00
|
|
|
else:
|
|
|
|
row = Adw.ActionRow()
|
|
|
|
row.set_title(_("No plugins found"))
|
|
|
|
group.add(row)
|
|
|
|
return group
|