mirror of
https://github.com/irssi/irssi.git
synced 2025-02-02 15:08:01 -05:00
autoload modules from default setting
This commit is contained in:
parent
628ca79e6a
commit
d20d2753da
@ -269,6 +269,7 @@ void core_init(void)
|
||||
settings_add_str("misc", "ignore_signals", "");
|
||||
settings_add_bool("misc", "override_coredump_limit", FALSE);
|
||||
settings_add_bool("misc", "quit_on_hup", FALSE);
|
||||
settings_add_str("misc", "autoload_modules", "perl otr");
|
||||
|
||||
#ifdef HAVE_SYS_RESOURCE_H
|
||||
getrlimit(RLIMIT_CORE, &orig_core_rlimit);
|
||||
|
@ -464,6 +464,7 @@ void fe_common_core_finish_init(void)
|
||||
signal_emit("setup changed", 0);
|
||||
|
||||
autorun_startup();
|
||||
signal_emit("module autoload", 0);
|
||||
autoconnect_servers();
|
||||
}
|
||||
|
||||
|
@ -170,15 +170,25 @@ static void cmd_load(const char *data)
|
||||
char *rootmodule, *submodule;
|
||||
char **module_prefixes;
|
||||
void *free_arg;
|
||||
gboolean silent;
|
||||
GHashTable *optlist;
|
||||
|
||||
g_return_if_fail(data != NULL);
|
||||
|
||||
if (!cmd_get_params(data, &free_arg, 2 , &rootmodule, &submodule))
|
||||
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_OPTIONS, "load", &optlist, &rootmodule,
|
||||
&submodule))
|
||||
return;
|
||||
|
||||
silent = g_hash_table_lookup(optlist, "silent") != NULL;
|
||||
|
||||
if (*rootmodule == '\0')
|
||||
cmd_load_list();
|
||||
else {
|
||||
if (silent) {
|
||||
signal_add_first("module error", (SIGNAL_FUNC) signal_stop);
|
||||
signal_add_first("module loaded", (SIGNAL_FUNC) signal_stop);
|
||||
}
|
||||
|
||||
module_prefixes = module_prefixes_get();
|
||||
if (*submodule == '\0')
|
||||
module_load(rootmodule, module_prefixes);
|
||||
@ -187,6 +197,11 @@ static void cmd_load(const char *data)
|
||||
module_prefixes);
|
||||
}
|
||||
module_prefixes_free(module_prefixes);
|
||||
|
||||
if (silent) {
|
||||
signal_remove("module error", (SIGNAL_FUNC) signal_stop);
|
||||
signal_remove("module loaded", (SIGNAL_FUNC) signal_stop);
|
||||
}
|
||||
}
|
||||
|
||||
cmd_params_free(free_arg);
|
||||
@ -244,6 +259,7 @@ void fe_modules_init(void)
|
||||
|
||||
command_bind("load", NULL, (SIGNAL_FUNC) cmd_load);
|
||||
command_bind("unload", NULL, (SIGNAL_FUNC) cmd_unload);
|
||||
command_set_options("load", "silent");
|
||||
}
|
||||
|
||||
void fe_modules_deinit(void)
|
||||
|
@ -102,6 +102,21 @@ static void sig_settings_userinfo_changed(gpointer changedp)
|
||||
user_settings_changed = GPOINTER_TO_UINT(changedp);
|
||||
}
|
||||
|
||||
static void sig_autoload_modules(void)
|
||||
{
|
||||
char **list, **module;
|
||||
list = g_strsplit_set(settings_get_str("autoload_modules"), " ,", -1);
|
||||
for (module = list; *module != NULL; module++) {
|
||||
char *tmp;
|
||||
if ((tmp = strchr(*module, ':')) != NULL)
|
||||
*tmp = ' ';
|
||||
tmp = g_strdup_printf("-silent %s", *module);
|
||||
signal_emit("command load", 1, tmp);
|
||||
g_free(tmp);
|
||||
}
|
||||
g_strfreev(list);
|
||||
}
|
||||
|
||||
/* redraw irssi's screen.. */
|
||||
void irssi_redraw(void)
|
||||
{
|
||||
@ -159,6 +174,7 @@ static void textui_init(void)
|
||||
|
||||
theme_register(gui_text_formats);
|
||||
signal_add("settings userinfo changed", (SIGNAL_FUNC) sig_settings_userinfo_changed);
|
||||
signal_add("module autoload", (SIGNAL_FUNC) sig_autoload_modules);
|
||||
signal_add_last("gui exit", (SIGNAL_FUNC) sig_exit);
|
||||
}
|
||||
|
||||
@ -262,6 +278,7 @@ static void textui_deinit(void)
|
||||
|
||||
dirty_check(); /* one last time to print any quit messages */
|
||||
signal_remove("settings userinfo changed", (SIGNAL_FUNC) sig_settings_userinfo_changed);
|
||||
signal_remove("module autoload", (SIGNAL_FUNC) sig_autoload_modules);
|
||||
signal_remove("gui exit", (SIGNAL_FUNC) sig_exit);
|
||||
|
||||
lastlog_deinit();
|
||||
|
Loading…
Reference in New Issue
Block a user