mirror of
https://github.com/profanity-im/profanity.git
synced 2025-01-03 14:57:42 -05:00
Allow reloading all plugins with /plugin reload
This commit is contained in:
parent
448bef247b
commit
9a0111c10a
@ -1981,13 +1981,13 @@ static struct cmd_t command_defs[] =
|
|||||||
"/plugins",
|
"/plugins",
|
||||||
"/plugins unload <plugin>",
|
"/plugins unload <plugin>",
|
||||||
"/plugins load <plugin>",
|
"/plugins load <plugin>",
|
||||||
"/plugins reload <plugin>")
|
"/plugins reload [<plugin>]")
|
||||||
CMD_DESC(
|
CMD_DESC(
|
||||||
"Manage plugins. Passing no arguments lists currently loaded plugins.")
|
"Manage plugins. Passing no arguments lists currently loaded plugins.")
|
||||||
CMD_ARGS(
|
CMD_ARGS(
|
||||||
{ "load <plugin>", "Load a plugin." },
|
{ "load <plugin>", "Load a plugin." },
|
||||||
{ "reload <plugin>", "Reload a plugin." },
|
{ "unload <plugin>", "Unload a plugin." },
|
||||||
{ "unload <plugin>", "Unload a plugin." })
|
{ "reload [<plugin>]", "Reload a plugin, passing no argument will reload all plugins" })
|
||||||
CMD_EXAMPLES(
|
CMD_EXAMPLES(
|
||||||
"/plugin load browser.py",
|
"/plugin load browser.py",
|
||||||
"/plugin unload say.py",
|
"/plugin unload say.py",
|
||||||
|
@ -6053,14 +6053,15 @@ cmd_plugins(ProfWin *window, const char *const command, gchar **args)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
} else if (g_strcmp0(args[0], "reload") == 0) {
|
} else if (g_strcmp0(args[0], "reload") == 0) {
|
||||||
if (args[1] == NULL) {
|
if (args[1] == NULL) {
|
||||||
cons_bad_cmd_usage(command);
|
plugins_reload_all();
|
||||||
return TRUE;
|
cons_show("Reloaded all plugins");
|
||||||
}
|
|
||||||
gboolean res = plugins_reload(args[1]);
|
|
||||||
if (res) {
|
|
||||||
cons_show("Reloaded plugin: %s", args[1]);
|
|
||||||
} else {
|
} else {
|
||||||
cons_show("Failed to reload plugin: %s", args[1]);
|
gboolean res = plugins_reload(args[1]);
|
||||||
|
if (res) {
|
||||||
|
cons_show("Reloaded plugin: %s", args[1]);
|
||||||
|
} else {
|
||||||
|
cons_show("Failed to reload plugin: %s", args[1]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -187,6 +187,27 @@ plugins_unload(const char *const name)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
plugins_reload_all(void)
|
||||||
|
{
|
||||||
|
GList *plugin_names = g_hash_table_get_keys(plugins);
|
||||||
|
GList *plugin_names_dup = NULL;
|
||||||
|
GList *curr = plugin_names;
|
||||||
|
while (curr) {
|
||||||
|
plugin_names_dup = g_list_append(plugin_names_dup, strdup(curr->data));
|
||||||
|
curr = g_list_next(curr);
|
||||||
|
}
|
||||||
|
g_list_free(plugin_names);
|
||||||
|
|
||||||
|
curr = plugin_names_dup;
|
||||||
|
while (curr) {
|
||||||
|
plugins_reload(curr->data);
|
||||||
|
curr = g_list_next(curr);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_list_free_full(plugin_names_dup, free);
|
||||||
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
plugins_reload(const char *const name)
|
plugins_reload(const char *const name)
|
||||||
{
|
{
|
||||||
|
@ -108,6 +108,7 @@ void plugins_shutdown(void);
|
|||||||
gboolean plugins_load(const char *const name);
|
gboolean plugins_load(const char *const name);
|
||||||
gboolean plugins_unload(const char *const name);
|
gboolean plugins_unload(const char *const name);
|
||||||
gboolean plugins_reload(const char *const name);
|
gboolean plugins_reload(const char *const name);
|
||||||
|
void plugins_reload_all(void);
|
||||||
|
|
||||||
void plugins_on_start(void);
|
void plugins_on_start(void);
|
||||||
void plugins_on_shutdown(void);
|
void plugins_on_shutdown(void);
|
||||||
|
Loading…
Reference in New Issue
Block a user