mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -05:00
/LOAD without parameters prints loaded modules
GLib warnings/criticals are now printed with printformat(), not into standard output messing up the screen. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1096 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
c2da48ebe0
commit
d6ee17e8cd
@ -194,10 +194,36 @@ void fe_common_core_deinit(void)
|
||||
signal_remove("channel destroyed", (SIGNAL_FUNC) sig_channel_destroyed);
|
||||
}
|
||||
|
||||
void glog_func(const char *log_domain, GLogLevelFlags log_level,
|
||||
const char *message)
|
||||
{
|
||||
const char *reason;
|
||||
|
||||
switch (log_level) {
|
||||
case G_LOG_LEVEL_WARNING:
|
||||
reason = "warning";
|
||||
break;
|
||||
case G_LOG_LEVEL_CRITICAL:
|
||||
reason = "critical";
|
||||
break;
|
||||
default:
|
||||
reason = "error";
|
||||
break;
|
||||
}
|
||||
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTERROR,
|
||||
TXT_GLIB_ERROR, reason, message);
|
||||
}
|
||||
|
||||
void fe_common_core_finish_init(void)
|
||||
{
|
||||
WINDOW_REC *window;
|
||||
|
||||
g_log_set_handler(G_LOG_DOMAIN,
|
||||
(GLogLevelFlags) (G_LOG_LEVEL_CRITICAL |
|
||||
G_LOG_LEVEL_WARNING),
|
||||
(GLogFunc) glog_func, NULL);
|
||||
|
||||
signal_emit("irssi init read settings", 0);
|
||||
|
||||
#ifdef SIGPIPE
|
||||
|
@ -27,38 +27,59 @@
|
||||
|
||||
#include "printtext.h"
|
||||
|
||||
static void sig_module_error(void *number, const char *module, const char *data)
|
||||
static void sig_module_error(void *number, const char *module,
|
||||
const char *data)
|
||||
{
|
||||
switch (GPOINTER_TO_INT(number)) {
|
||||
case MODULE_ERROR_ALREADY_LOADED:
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, TXT_MODULE_ALREADY_LOADED, module);
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTERROR,
|
||||
TXT_MODULE_ALREADY_LOADED, module);
|
||||
break;
|
||||
case MODULE_ERROR_LOAD:
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, TXT_MODULE_LOAD_ERROR, module, data);
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTERROR,
|
||||
TXT_MODULE_LOAD_ERROR, module, data);
|
||||
break;
|
||||
case MODULE_ERROR_INVALID:
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, TXT_MODULE_INVALID, module);
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTERROR,
|
||||
TXT_MODULE_INVALID, module);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void sig_module_loaded(MODULE_REC *rec)
|
||||
{
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_MODULE_LOADED, rec->name);
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE,
|
||||
TXT_MODULE_LOADED, rec->name);
|
||||
}
|
||||
|
||||
static void sig_module_unloaded(MODULE_REC *rec)
|
||||
{
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_MODULE_UNLOADED, rec->name);
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE,
|
||||
TXT_MODULE_UNLOADED, rec->name);
|
||||
}
|
||||
|
||||
static void cmd_load_list(void)
|
||||
{
|
||||
GSList *tmp;
|
||||
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_MODULE_HEADER);
|
||||
for (tmp = modules; tmp != NULL; tmp = tmp->next) {
|
||||
MODULE_REC *rec = tmp->data;
|
||||
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE,
|
||||
TXT_MODULE_LINE, rec->name);
|
||||
}
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_MODULE_FOOTER);
|
||||
}
|
||||
|
||||
/* SYNTAX: LOAD <module> */
|
||||
static void cmd_load(const char *data)
|
||||
{
|
||||
g_return_if_fail(data != NULL);
|
||||
if (*data == '\0') cmd_return_error(CMDERR_NOT_ENOUGH_PARAMS);
|
||||
|
||||
module_load(data);
|
||||
if (*data == '\0')
|
||||
cmd_load_list();
|
||||
else
|
||||
module_load(data);
|
||||
}
|
||||
|
||||
/* SYNTAX: UNLOAD <module> */
|
||||
|
@ -150,6 +150,9 @@ FORMAT_REC fecommon_core_formats[] = {
|
||||
/* ---- */
|
||||
{ NULL, "Modules", 0 },
|
||||
|
||||
{ "module_header", "Loaded modules:", 0, },
|
||||
{ "module_line", " $0", 1, { 0 } },
|
||||
{ "module_footer", "", 0, },
|
||||
{ "module_already_loaded", "Module {hilight $0} already loaded", 1, { 0 } },
|
||||
{ "module_load_error", "Error loading module {hilight $0}: $1", 2, { 0, 0 } },
|
||||
{ "module_invalid", "{hilight $0} isn't Irssi module", 1, { 0 } },
|
||||
@ -203,6 +206,7 @@ FORMAT_REC fecommon_core_formats[] = {
|
||||
{ "config_saved", "Saved configuration to file $0", 1, { 0 } },
|
||||
{ "config_reloaded", "Reloaded configuration", 1, { 0 } },
|
||||
{ "config_modified", "Configuration file was modified since irssi was last started - do you want to overwrite the possible changes?", 1, { 0 } },
|
||||
{ "glib_error", "{error GLib $0} $1", 2, { 0, 0 } },
|
||||
|
||||
{ NULL, NULL, 0 }
|
||||
};
|
||||
|
@ -120,6 +120,9 @@ enum {
|
||||
|
||||
TXT_FILL_9,
|
||||
|
||||
TXT_MODULE_HEADER,
|
||||
TXT_MODULE_LINE,
|
||||
TXT_MODULE_FOOTER,
|
||||
TXT_MODULE_ALREADY_LOADED,
|
||||
TXT_MODULE_LOAD_ERROR,
|
||||
TXT_MODULE_INVALID,
|
||||
@ -168,7 +171,8 @@ enum {
|
||||
TXT_BIND_UNKNOWN_ID,
|
||||
TXT_CONFIG_SAVED,
|
||||
TXT_CONFIG_RELOADED,
|
||||
TXT_CONFIG_MODIFIED
|
||||
TXT_CONFIG_MODIFIED,
|
||||
TXT_GLIB_ERROR
|
||||
};
|
||||
|
||||
extern FORMAT_REC fecommon_core_formats[];
|
||||
|
Loading…
Reference in New Issue
Block a user