mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -05:00
Moved /SAVE and /RELOAD to fe-common. Print "config saved" and
"config reloaded" messages. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@510 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
511f95ccaf
commit
d9b661a1fb
@ -673,21 +673,6 @@ static void cmd_cd(const char *data)
|
|||||||
g_free(str);
|
g_free(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_reload(const char *data)
|
|
||||||
{
|
|
||||||
char *fname;
|
|
||||||
|
|
||||||
fname = *data != '\0' ? g_strdup(data) :
|
|
||||||
g_strdup_printf("%s/.irssi/config", g_get_home_dir());
|
|
||||||
settings_reread(fname);
|
|
||||||
g_free(fname);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void cmd_save(const char *data)
|
|
||||||
{
|
|
||||||
settings_save(*data != '\0' ? data : NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
void commands_init(void)
|
void commands_init(void)
|
||||||
{
|
{
|
||||||
commands = NULL;
|
commands = NULL;
|
||||||
@ -701,8 +686,6 @@ void commands_init(void)
|
|||||||
|
|
||||||
command_bind("eval", NULL, (SIGNAL_FUNC) cmd_eval);
|
command_bind("eval", NULL, (SIGNAL_FUNC) cmd_eval);
|
||||||
command_bind("cd", NULL, (SIGNAL_FUNC) cmd_cd);
|
command_bind("cd", NULL, (SIGNAL_FUNC) cmd_cd);
|
||||||
command_bind("reload", NULL, (SIGNAL_FUNC) cmd_reload);
|
|
||||||
command_bind("save", NULL, (SIGNAL_FUNC) cmd_save);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void commands_deinit(void)
|
void commands_deinit(void)
|
||||||
@ -714,6 +697,4 @@ void commands_deinit(void)
|
|||||||
|
|
||||||
command_unbind("eval", (SIGNAL_FUNC) cmd_eval);
|
command_unbind("eval", (SIGNAL_FUNC) cmd_eval);
|
||||||
command_unbind("cd", (SIGNAL_FUNC) cmd_cd);
|
command_unbind("cd", (SIGNAL_FUNC) cmd_cd);
|
||||||
command_unbind("reload", (SIGNAL_FUNC) cmd_reload);
|
|
||||||
command_unbind("save", (SIGNAL_FUNC) cmd_save);
|
|
||||||
}
|
}
|
||||||
|
@ -285,7 +285,7 @@ static void init_configfile(void)
|
|||||||
signal(SIGTERM, sig_term);
|
signal(SIGTERM, sig_term);
|
||||||
}
|
}
|
||||||
|
|
||||||
void settings_reread(const char *fname)
|
int settings_reread(const char *fname)
|
||||||
{
|
{
|
||||||
CONFIG_REC *tempconfig;
|
CONFIG_REC *tempconfig;
|
||||||
char *str;
|
char *str;
|
||||||
@ -298,7 +298,7 @@ void settings_reread(const char *fname)
|
|||||||
|
|
||||||
if (tempconfig == NULL) {
|
if (tempconfig == NULL) {
|
||||||
signal_emit("gui dialog", 2, "error", g_strerror(errno));
|
signal_emit("gui dialog", 2, "error", g_strerror(errno));
|
||||||
return;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config_last_error(tempconfig) != NULL) {
|
if (config_last_error(tempconfig) != NULL) {
|
||||||
@ -308,7 +308,7 @@ void settings_reread(const char *fname)
|
|||||||
g_free(str);
|
g_free(str);
|
||||||
|
|
||||||
config_close(tempconfig);
|
config_close(tempconfig);
|
||||||
return;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
config_close(mainconfig);
|
config_close(mainconfig);
|
||||||
@ -316,20 +316,22 @@ void settings_reread(const char *fname)
|
|||||||
|
|
||||||
signal_emit("setup changed", 0);
|
signal_emit("setup changed", 0);
|
||||||
signal_emit("setup reread", 0);
|
signal_emit("setup reread", 0);
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void settings_save(const char *fname)
|
int settings_save(const char *fname)
|
||||||
{
|
{
|
||||||
char *str;
|
char *str;
|
||||||
|
|
||||||
if (config_write(mainconfig, fname, 0660) == 0)
|
if (config_write(mainconfig, fname, 0660) == 0)
|
||||||
return;
|
return TRUE;
|
||||||
|
|
||||||
/* error */
|
/* error */
|
||||||
str = g_strdup_printf(_("Couldn't save configuration file: %s"),
|
str = g_strdup_printf(_("Couldn't save configuration file: %s"),
|
||||||
config_last_error(mainconfig));
|
config_last_error(mainconfig));
|
||||||
signal_emit("gui dialog", 2, "error", str);
|
signal_emit("gui dialog", 2, "error", str);
|
||||||
g_free(str);
|
g_free(str);
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void settings_init(void)
|
void settings_init(void)
|
||||||
|
@ -54,8 +54,8 @@ GSList *settings_get_sorted(void);
|
|||||||
SETTINGS_REC *settings_get_record(const char *key);
|
SETTINGS_REC *settings_get_record(const char *key);
|
||||||
|
|
||||||
/* if `fname' is NULL, the default is used */
|
/* if `fname' is NULL, the default is used */
|
||||||
void settings_reread(const char *fname);
|
int settings_reread(const char *fname);
|
||||||
void settings_save(const char *fname);
|
int settings_save(const char *fname);
|
||||||
|
|
||||||
void settings_init(void);
|
void settings_init(void);
|
||||||
void settings_deinit(void);
|
void settings_deinit(void);
|
||||||
|
@ -227,12 +227,36 @@ static void cmd_unalias(const char *data)
|
|||||||
alias_remove(data);
|
alias_remove(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void cmd_reload(const char *data)
|
||||||
|
{
|
||||||
|
char *fname;
|
||||||
|
|
||||||
|
fname = *data != '\0' ? g_strdup(data) :
|
||||||
|
g_strdup_printf("%s/.irssi/config", g_get_home_dir());
|
||||||
|
if (settings_reread(fname)) {
|
||||||
|
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE,
|
||||||
|
IRCTXT_CONFIG_RELOADED, fname);
|
||||||
|
}
|
||||||
|
g_free(fname);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void cmd_save(const char *data)
|
||||||
|
{
|
||||||
|
if (settings_save(*data != '\0' ? data : NULL)) {
|
||||||
|
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE,
|
||||||
|
IRCTXT_CONFIG_SAVED, *data != '\0' ? data :
|
||||||
|
mainconfig->fname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void fe_settings_init(void)
|
void fe_settings_init(void)
|
||||||
{
|
{
|
||||||
command_bind("set", NULL, (SIGNAL_FUNC) cmd_set);
|
command_bind("set", NULL, (SIGNAL_FUNC) cmd_set);
|
||||||
command_bind("toggle", NULL, (SIGNAL_FUNC) cmd_toggle);
|
command_bind("toggle", NULL, (SIGNAL_FUNC) cmd_toggle);
|
||||||
command_bind("alias", NULL, (SIGNAL_FUNC) cmd_alias);
|
command_bind("alias", NULL, (SIGNAL_FUNC) cmd_alias);
|
||||||
command_bind("unalias", NULL, (SIGNAL_FUNC) cmd_unalias);
|
command_bind("unalias", NULL, (SIGNAL_FUNC) cmd_unalias);
|
||||||
|
command_bind("reload", NULL, (SIGNAL_FUNC) cmd_reload);
|
||||||
|
command_bind("save", NULL, (SIGNAL_FUNC) cmd_save);
|
||||||
|
|
||||||
command_set_options("set", "clear");
|
command_set_options("set", "clear");
|
||||||
}
|
}
|
||||||
@ -243,4 +267,6 @@ void fe_settings_deinit(void)
|
|||||||
command_unbind("toggle", (SIGNAL_FUNC) cmd_toggle);
|
command_unbind("toggle", (SIGNAL_FUNC) cmd_toggle);
|
||||||
command_unbind("alias", (SIGNAL_FUNC) cmd_alias);
|
command_unbind("alias", (SIGNAL_FUNC) cmd_alias);
|
||||||
command_unbind("unalias", (SIGNAL_FUNC) cmd_unalias);
|
command_unbind("unalias", (SIGNAL_FUNC) cmd_unalias);
|
||||||
|
command_unbind("reload", (SIGNAL_FUNC) cmd_reload);
|
||||||
|
command_unbind("save", (SIGNAL_FUNC) cmd_save);
|
||||||
}
|
}
|
||||||
|
@ -121,6 +121,8 @@ FORMAT_REC fecommon_core_formats[] = {
|
|||||||
{ "perl_error", "Perl error: $0", 1, { 0 } },
|
{ "perl_error", "Perl error: $0", 1, { 0 } },
|
||||||
{ "bind_key", "$[10]0 $1 $2", 3, { 0, 0, 0 } },
|
{ "bind_key", "$[10]0 $1 $2", 3, { 0, 0, 0 } },
|
||||||
{ "bind_unknown_id", "Unknown bind action: $0", 1, { 0 } },
|
{ "bind_unknown_id", "Unknown bind action: $0", 1, { 0 } },
|
||||||
|
{ "config_saved", "Saved configuration to file $0", 1, { 0 } },
|
||||||
|
{ "config_reloaded", "Reloaded configuration", 1, { 0 } },
|
||||||
|
|
||||||
{ NULL, NULL, 0 }
|
{ NULL, NULL, 0 }
|
||||||
};
|
};
|
||||||
|
@ -91,8 +91,9 @@ enum {
|
|||||||
IRCTXT_NOT_TOGGLE,
|
IRCTXT_NOT_TOGGLE,
|
||||||
IRCTXT_PERL_ERROR,
|
IRCTXT_PERL_ERROR,
|
||||||
IRCTXT_BIND_KEY,
|
IRCTXT_BIND_KEY,
|
||||||
IRCTXT_BIND_UNKNOWN_ID
|
IRCTXT_BIND_UNKNOWN_ID,
|
||||||
|
IRCTXT_CONFIG_SAVED,
|
||||||
|
IRCTXT_CONFIG_RELOADED
|
||||||
};
|
};
|
||||||
|
|
||||||
extern FORMAT_REC fecommon_core_formats[];
|
extern FORMAT_REC fecommon_core_formats[];
|
||||||
|
Loading…
Reference in New Issue
Block a user