mirror of
https://github.com/weechat/weechat.git
synced 2026-07-05 17:23:15 +02:00
core: always write all options in theme files
Theme files saved with /theme save and automatic backups now always contain every themable option (full snapshot), so a theme file is self-contained and round-trips exactly regardless of the current configuration. The diff-only mode and the "-full" argument of /theme save are removed.
This commit is contained in:
+7
-11
@@ -7345,14 +7345,11 @@ COMMAND_CALLBACK(theme)
|
||||
return theme_reset ();
|
||||
}
|
||||
|
||||
/* "/theme save <name> [-full]": write a user theme file */
|
||||
/* "/theme save <name>": write a user theme file */
|
||||
if (string_strcmp (argv[1], "save") == 0)
|
||||
{
|
||||
COMMAND_MIN_ARGS(3, "save");
|
||||
return theme_save (argv[2],
|
||||
((argc >= 4)
|
||||
&& (string_strcmp (argv[3], "-full") == 0))
|
||||
? 1 : 0);
|
||||
return theme_save (argv[2]);
|
||||
}
|
||||
|
||||
/* "/theme rename <old> <new>": rename a user theme file */
|
||||
@@ -10093,7 +10090,7 @@ command_init (void)
|
||||
N_("[list [-backups]]"
|
||||
" || apply <name>"
|
||||
" || reset"
|
||||
" || save <name> [-full]"
|
||||
" || save <name>"
|
||||
" || rename <old> <new>"
|
||||
" || del <name>"
|
||||
" || info <name>"),
|
||||
@@ -10109,10 +10106,9 @@ command_init (void)
|
||||
N_("raw[reset]: reset every themable option to its default "
|
||||
"value (restores the original look shipped with WeeChat)"),
|
||||
N_("raw[save]: save current themable options to a file "
|
||||
"<name>.theme in directory \"themes\"; by default only "
|
||||
"options whose value differs from their default are "
|
||||
"written, use \"-full\" to write every themable option; "
|
||||
"the name must not match a built-in theme or start with "
|
||||
"<name>.theme in directory \"themes\"; every themable "
|
||||
"option is written, so the file is self-contained; the "
|
||||
"name must not match a built-in theme or start with "
|
||||
"\"backup-\""),
|
||||
N_("raw[rename]: rename a user theme file"),
|
||||
N_("raw[del]: delete a user theme file"),
|
||||
@@ -10133,7 +10129,7 @@ command_init (void)
|
||||
"list -backups"
|
||||
" || apply %(theme_themes_all)"
|
||||
" || reset"
|
||||
" || save %(theme_themes_user) -full"
|
||||
" || save %(theme_themes_user)"
|
||||
" || rename %(theme_themes_files)"
|
||||
" || del %(theme_themes_user)"
|
||||
" || info %(theme_themes_all)",
|
||||
|
||||
+12
-18
@@ -543,13 +543,12 @@ theme_make_backup_name (void)
|
||||
* Write a snapshot of themable options to a .theme file at
|
||||
* "<weechat_config_dir>/themes/<name>.theme".
|
||||
*
|
||||
* The themes directory is created if missing. The file contains an
|
||||
* [info] section (name, description, date, weechat version) followed by
|
||||
* an [options] section.
|
||||
* The themes directory is created if missing.
|
||||
*
|
||||
* If "diff_only" is non-zero, only options whose value differs from
|
||||
* their default (config_file_option_has_changed) are written. If zero,
|
||||
* every themable option is written (full snapshot).
|
||||
* The file contains an [info] section (name, description, date, weechat version)
|
||||
* followed by an [options] section. Every themable option is always
|
||||
* written (full snapshot), so a theme file is self-contained and round-trips
|
||||
* exactly, regardless of the current configuration.
|
||||
*
|
||||
* Return path to saved file on success, NULL on error.
|
||||
*
|
||||
@@ -557,7 +556,7 @@ theme_make_backup_name (void)
|
||||
*/
|
||||
|
||||
char *
|
||||
theme_write_file (const char *name, const char *description, int diff_only)
|
||||
theme_write_file (const char *name, const char *description)
|
||||
{
|
||||
char *path, *dir, *value, *now;
|
||||
FILE *file;
|
||||
@@ -608,8 +607,6 @@ theme_write_file (const char *name, const char *description, int diff_only)
|
||||
{
|
||||
if (!ptr_option->themable)
|
||||
continue;
|
||||
if (diff_only && !config_file_option_has_changed (ptr_option))
|
||||
continue;
|
||||
value = config_file_option_value_to_string (
|
||||
ptr_option, 0, 0, 1);
|
||||
fprintf (file, "%s.%s.%s = %s\n",
|
||||
@@ -641,10 +638,7 @@ theme_make_backup (void)
|
||||
name = theme_make_backup_name ();
|
||||
if (!name)
|
||||
return NULL;
|
||||
path = theme_write_file (
|
||||
name,
|
||||
_("Automatic backup"),
|
||||
0); /* full snapshot: backups must round-trip exactly */
|
||||
path = theme_write_file (name, _("Automatic backup"));
|
||||
if (!path)
|
||||
{
|
||||
free (name);
|
||||
@@ -1122,16 +1116,16 @@ theme_reset (void)
|
||||
* Save the current themable options to a user theme file.
|
||||
*
|
||||
* Refuse names that match a built-in theme (registered via API) or
|
||||
* that start with "backup-" (reserved for automatic backups). If
|
||||
* "full" is non-zero, every themable option is written; otherwise
|
||||
* only options whose value differs from their default are written.
|
||||
* that start with "backup-" (reserved for automatic backups). Every
|
||||
* themable option is written (full snapshot), so the file is
|
||||
* self-contained and round-trips exactly.
|
||||
*
|
||||
* Return WEECHAT_RC_OK on success, WEECHAT_RC_ERROR on validation or
|
||||
* I/O failure.
|
||||
*/
|
||||
|
||||
int
|
||||
theme_save (const char *name, int full)
|
||||
theme_save (const char *name)
|
||||
{
|
||||
char *path;
|
||||
|
||||
@@ -1158,7 +1152,7 @@ theme_save (const char *name, int full)
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
path = theme_write_file (name, NULL, (full) ? 0 : 1);
|
||||
path = theme_write_file (name, NULL);
|
||||
if (!path)
|
||||
{
|
||||
gui_chat_printf (NULL,
|
||||
|
||||
@@ -70,7 +70,7 @@ extern const char *theme_get_override (struct t_theme *theme,
|
||||
extern struct t_arraylist *theme_list (void);
|
||||
extern int theme_apply (const char *name);
|
||||
extern int theme_reset (void);
|
||||
extern int theme_save (const char *name, int full);
|
||||
extern int theme_save (const char *name);
|
||||
extern int theme_rename (const char *old_name, const char *new_name);
|
||||
extern int theme_delete (const char *name);
|
||||
extern char *theme_make_backup (void);
|
||||
|
||||
Reference in New Issue
Block a user