diff options
author | Timo Sirainen <cras@irssi.org> | 2000-10-15 19:21:21 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2000-10-15 19:21:21 +0000 |
commit | a2cac63e56d88101cd101f0e37c4b8c741467599 (patch) | |
tree | 7334640e8f7fc0a17e381d676b3a807b21bc0355 /src/fe-common | |
parent | 228c1d7f366c0d103b00188a7945797068e4c741 (diff) | |
download | irssi-a2cac63e56d88101cd101f0e37c4b8c741467599.zip |
Irssi won't automatically overwrite configuration files if they're
changed while irssi is running:
- /SAVE asks whether to save it or not
- autosave at quit saves it to config.autosave file
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@762 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/fe-common')
-rw-r--r-- | src/fe-common/core/fe-settings.c | 32 | ||||
-rw-r--r-- | src/fe-common/core/module-formats.c | 1 | ||||
-rw-r--r-- | src/fe-common/core/module-formats.h | 3 |
3 files changed, 31 insertions, 5 deletions
diff --git a/src/fe-common/core/fe-settings.c b/src/fe-common/core/fe-settings.c index 4c2bf823..4d8266dd 100644 --- a/src/fe-common/core/fe-settings.c +++ b/src/fe-common/core/fe-settings.c @@ -245,14 +245,38 @@ static void cmd_reload(const char *data) g_free(fname); } +static void settings_save_fe(const char *fname) +{ + if (settings_save(fname)) { + printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, + IRCTXT_CONFIG_SAVED, fname); + } +} + +static void settings_save_confirm(const char *line, char *fname) +{ + if (toupper(*line) == 'Y') + settings_save_fe(fname); + g_free(fname); +} + /* SYNTAX: SAVE [<file>] */ 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); + if (*data == '\0') + data = mainconfig->fname; + + if (!irssi_config_is_changed(data)) { + settings_save_fe(data); + return; } + + printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, + IRCTXT_CONFIG_MODIFIED, data); + signal_emit("gui entry redirect", 4, + settings_save_confirm, + _("Overwrite config (y/N)?"), + GINT_TO_POINTER(FALSE), g_strdup(data)); } void fe_settings_init(void) diff --git a/src/fe-common/core/module-formats.c b/src/fe-common/core/module-formats.c index ee4c99d8..ec555ecb 100644 --- a/src/fe-common/core/module-formats.c +++ b/src/fe-common/core/module-formats.c @@ -202,6 +202,7 @@ FORMAT_REC fecommon_core_formats[] = { { "bind_unknown_id", "Unknown bind action: $0", 1, { 0 } }, { "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 } }, { NULL, NULL, 0 } }; diff --git a/src/fe-common/core/module-formats.h b/src/fe-common/core/module-formats.h index 01390a15..362b9074 100644 --- a/src/fe-common/core/module-formats.h +++ b/src/fe-common/core/module-formats.h @@ -167,7 +167,8 @@ enum { IRCTXT_BIND_KEY, IRCTXT_BIND_UNKNOWN_ID, IRCTXT_CONFIG_SAVED, - IRCTXT_CONFIG_RELOADED + IRCTXT_CONFIG_RELOADED, + IRCTXT_CONFIG_MODIFIED }; extern FORMAT_REC fecommon_core_formats[]; |