feat: add message dialog if unable to remove plugin

This commit is contained in:
0xMRTT 2022-09-22 14:33:02 +02:00
parent 3a708fe173
commit ca630b25db
No known key found for this signature in database
GPG key ID: AC9E06BF3DECB6FB
4 changed files with 22 additions and 3 deletions

View file

@ -40,6 +40,7 @@ if is_local:
)
pkgdatadir = '@PKGDATA_DIR@'
print(pkgdatadir)
localedir = '@LOCALE_DIR@'
sys.dont_write_bytecode = True

View file

@ -22,7 +22,8 @@ configure_file(
'PROJECT_URL': PROJECT_URL,
'BUGTRACKER_URL': BUGTRACKER_URL,
'HELP_URL': HELP_URL,
'TRANSLATE_URL': TRANSLATE_URL
'TRANSLATE_URL': TRANSLATE_URL,
'PKGDATA_DIR': PKGDATA_DIR,
}),
install: true,
install_dir: PY_INSTALLDIR.get_install_dir() / 'gradience',

View file

@ -66,7 +66,19 @@ class GradiencePluginRow(Adw.ActionRow):
USER_PLUGIN_DIR / f"{self.plugin_object.plugin_id}.yapsy-plugin"
)
buglog("remove", plugin_yapsy_file)
os.remove(plugin_yapsy_file)
try:
os.remove(plugin_yapsy_file)
except FileNotFoundError:
error_dialog = Adw.MessageDialog(
#transient_for=self.props.active_window,
heading=_("Unable to remove"),
body=_(
"This is a system plugin, and cannot be removed. "
)
)
error_dialog.add_response("close", _("Close"))
error_dialog.present()
buglog("remove", plugin_yapsy_file)
Gtk.Application.get_default().reload_plugins()
@Gtk.Template.Callback()

View file

@ -34,6 +34,10 @@ SYSTEM_PLUGIN_DIR = os.path.join(
"plugins",
)
print("=======================")
print(pkgdatadir)
print(SYSTEM_PLUGIN_DIR)
class GradiencePluginsList:
"""Represent the plugin group in Advanced"""
@ -54,6 +58,7 @@ class GradiencePluginsList:
def reload(self):
self.pm = PluginManager()
print(SYSTEM_PLUGIN_DIR)
self.pm.setPluginPlaces([USER_PLUGIN_DIR, SYSTEM_PLUGIN_DIR])
self.pm.collectPlugins()
for pluginInfo in self.pm.getAllPlugins():
@ -106,7 +111,7 @@ class GradiencePluginsList:
empty = False
if empty:
row = Adw.ActionRow()
row.set_title(_("No plugins found"))
row.set_title(_("No plugins found."))
group.add(row)
return group