1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-05 01:03:14 +02:00

core: display path to theme written with /theme save <name>

This commit is contained in:
Sébastien Helleu
2026-07-04 21:20:02 +02:00
parent 867625b65a
commit 1dc651742b
16 changed files with 75 additions and 58 deletions
+2 -2
View File
@@ -23,7 +23,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2026-07-04 20:47+0200\n"
"POT-Creation-Date: 2026-07-04 20:55+0200\n"
"PO-Revision-Date: 2026-05-30 14:01+0200\n"
"Last-Translator: Ondřej Súkup <mimi.vx@gmail.com>\n"
"Language-Team: Czech <weechat-dev@nongnu.org>\n"
@@ -6390,7 +6390,7 @@ msgstr "%s%s: nemůžu parsovat soubor \"%s\""
#, fuzzy, c-format
#| msgid "Option \"%s%s%s\":"
msgid "Theme saved: %s"
msgid "Theme saved to: %s"
msgstr "Volba \"%s%s%s\":"
#, fuzzy, c-format
+2 -2
View File
@@ -26,7 +26,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2026-07-04 20:47+0200\n"
"POT-Creation-Date: 2026-07-04 20:55+0200\n"
"PO-Revision-Date: 2026-06-28 08:28+0200\n"
"Last-Translator: Nils Görs <weechatter@arcor.de>\n"
"Language-Team: German <weechatter@arcor.de>\n"
@@ -7234,7 +7234,7 @@ msgstr "%s%s: Datei \"%s\" Analyse nicht möglich"
#, fuzzy, c-format
#| msgid "Option \"%s%s%s\":"
msgid "Theme saved: %s"
msgid "Theme saved to: %s"
msgstr "Einstellung \"%s%s%s\":"
#, fuzzy, c-format
+2 -2
View File
@@ -24,7 +24,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2026-07-04 20:47+0200\n"
"POT-Creation-Date: 2026-07-04 20:55+0200\n"
"PO-Revision-Date: 2026-06-28 08:46+0200\n"
"Last-Translator: Santiago Forero <santiago@forero.xyz>\n"
"Language-Team: Spanish <weechat-dev@nongnu.org>\n"
@@ -6550,7 +6550,7 @@ msgstr "%s%s: no es posible analizar el archivo \"%s\""
#, fuzzy, c-format
#| msgid "Option \"%s%s%s\":"
msgid "Theme saved: %s"
msgid "Theme saved to: %s"
msgstr "Opción \"%s%s%s\":"
#, fuzzy, c-format
+4 -4
View File
@@ -23,8 +23,8 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2026-07-04 20:47+0200\n"
"PO-Revision-Date: 2026-07-04 20:49+0200\n"
"POT-Creation-Date: 2026-07-04 20:55+0200\n"
"PO-Revision-Date: 2026-07-04 20:56+0200\n"
"Last-Translator: Sébastien Helleu <flashcode@flashtux.org>\n"
"Language-Team: French <flashcode@flashtux.org>\n"
"Language: fr\n"
@@ -7116,8 +7116,8 @@ msgid "%sFailed to save theme \"%s\""
msgstr "%sÉchec de sauvegarde du thème \"%s\""
#, c-format
msgid "Theme saved: %s"
msgstr "Thème sauvegardé : %s"
msgid "Theme saved to: %s"
msgstr "Thème sauvegardé vers: %s"
#, c-format
msgid "%sCannot delete built-in theme \"%s\""
+2 -2
View File
@@ -22,7 +22,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2026-07-04 20:47+0200\n"
"POT-Creation-Date: 2026-07-04 20:55+0200\n"
"PO-Revision-Date: 2026-03-08 08:59+0100\n"
"Last-Translator: Andras Voroskoi <voroskoi@frugalware.org>\n"
"Language-Team: Hungarian <weechat-dev@nongnu.org>\n"
@@ -6054,7 +6054,7 @@ msgid "%sFailed to save theme \"%s\""
msgstr "Nem sikerült a(z) \"%s\" naplófájlt írni\n"
#, fuzzy, c-format
msgid "Theme saved: %s"
msgid "Theme saved to: %s"
msgstr "Felhasználók a %s%s%s szobában: %s["
#, fuzzy, c-format
+2 -2
View File
@@ -22,7 +22,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2026-07-04 20:47+0200\n"
"POT-Creation-Date: 2026-07-04 20:55+0200\n"
"PO-Revision-Date: 2026-05-30 14:02+0200\n"
"Last-Translator: Esteban I. Ruiz Moreno <exio4.com@gmail.com>\n"
"Language-Team: Italian <weechat-dev@nongnu.org>\n"
@@ -6536,7 +6536,7 @@ msgstr "%s%s: impossibile analizzare il file \"%s\""
#, fuzzy, c-format
#| msgid "Option \"%s%s%s\":"
msgid "Theme saved: %s"
msgid "Theme saved to: %s"
msgstr "Opzione \"%s%s%s\":"
#, fuzzy, c-format
+2 -2
View File
@@ -22,7 +22,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2026-07-04 20:47+0200\n"
"POT-Creation-Date: 2026-07-04 20:55+0200\n"
"PO-Revision-Date: 2026-05-30 14:02+0200\n"
"Last-Translator: AYANOKOUZI, Ryuunosuke <i38w7i3@yahoo.co.jp>\n"
"Language-Team: Japanese <weechat-dev@nongnu.org>\n"
@@ -6712,7 +6712,7 @@ msgstr "%s%s: ファイル \"%s\" を解析できません"
#, fuzzy, c-format
#| msgid "Option \"%s%s%s\":"
msgid "Theme saved: %s"
msgid "Theme saved to: %s"
msgstr "オプション \"%s%s%s\":"
#, fuzzy, c-format
+2 -2
View File
@@ -23,7 +23,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2026-07-04 20:47+0200\n"
"POT-Creation-Date: 2026-07-04 20:55+0200\n"
"PO-Revision-Date: 2026-06-28 08:55+0200\n"
"Last-Translator: Krzysztof Korościk <soltys@soltys.info>\n"
"Language-Team: Polish <soltys@soltys.info>\n"
@@ -6895,7 +6895,7 @@ msgstr "%s%s: nie można przetworzyć pliku \"%s\""
#, fuzzy, c-format
#| msgid "Option \"%s%s%s\":"
msgid "Theme saved: %s"
msgid "Theme saved to: %s"
msgstr "Opcja \"%s%s%s\":"
#, fuzzy, c-format
+2 -2
View File
@@ -22,7 +22,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2026-07-04 20:47+0200\n"
"POT-Creation-Date: 2026-07-04 20:55+0200\n"
"PO-Revision-Date: 2026-06-28 08:48+0200\n"
"Last-Translator: Vasco Almeida <vascomalmeida@sapo.pt>\n"
"Language-Team: Portuguese <weechat-dev@nongnu.org>\n"
@@ -6768,7 +6768,7 @@ msgstr "%s%s: não foi possível analisar o ficheiro \"%s\""
#, fuzzy, c-format
#| msgid "Option \"%s%s%s\":"
msgid "Theme saved: %s"
msgid "Theme saved to: %s"
msgstr "Opção \"%s%s%s\":"
#, fuzzy, c-format
+2 -2
View File
@@ -46,7 +46,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2026-07-04 20:47+0200\n"
"POT-Creation-Date: 2026-07-04 20:55+0200\n"
"PO-Revision-Date: 2026-06-28 08:49+0200\n"
"Last-Translator: Érico Nogueira <ericonr@disroot.org>\n"
"Language-Team: Portuguese (Brazil) <weechat-dev@nongnu.org>\n"
@@ -6434,7 +6434,7 @@ msgstr "%s%s: não foi possível interpretar arquivo \"%s\""
#, fuzzy, c-format
#| msgid "Option \"%s%s%s\":"
msgid "Theme saved: %s"
msgid "Theme saved to: %s"
msgstr "Opção \"%s%s%s\":"
#, fuzzy, c-format
+2 -2
View File
@@ -23,7 +23,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2026-07-04 20:47+0200\n"
"POT-Creation-Date: 2026-07-04 20:55+0200\n"
"PO-Revision-Date: 2026-03-08 08:59+0100\n"
"Last-Translator: Aleksey V Zapparov AKA ixti <ixti@member.fsf.org>\n"
"Language-Team: Russian <weechat-dev@nongnu.org>\n"
@@ -6091,7 +6091,7 @@ msgid "%sFailed to save theme \"%s\""
msgstr "Не могу записать лог-файл \"%s\"\n"
#, fuzzy, c-format
msgid "Theme saved: %s"
msgid "Theme saved to: %s"
msgstr "Ники %s%s%s: %s["
#, fuzzy, c-format
+2 -2
View File
@@ -22,7 +22,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2026-07-04 20:47+0200\n"
"POT-Creation-Date: 2026-07-04 20:55+0200\n"
"PO-Revision-Date: 2026-06-28 08:52+0200\n"
"Last-Translator: Ivan Pešić <ivan.pesic@gmail.com>\n"
"Language-Team: Serbian <ivan.pesic@gmail.com>\n"
@@ -6877,7 +6877,7 @@ msgstr "%s%s: није успело парсирање фајла „%s”"
#, fuzzy, c-format
#| msgid "Option \"%s%s%s\":"
msgid "Theme saved: %s"
msgid "Theme saved to: %s"
msgstr "Опција „%s%s%s”:"
#, fuzzy, c-format
+2 -2
View File
@@ -23,7 +23,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2026-07-04 20:47+0200\n"
"POT-Creation-Date: 2026-07-04 20:55+0200\n"
"PO-Revision-Date: 2026-06-28 08:53+0200\n"
"Last-Translator: Emir SARI <emir_sari@icloud.com>\n"
"Language-Team: Turkish <emir_sari@icloud.com>\n"
@@ -6674,7 +6674,7 @@ msgstr "%s%s: \"%s\" dosyası ayrıştırılamıyor"
#, fuzzy, c-format
#| msgid "Option \"%s%s%s\":"
msgid "Theme saved: %s"
msgid "Theme saved to: %s"
msgstr "\"%s%s%s\" seçeneği:"
#, fuzzy, c-format
+2 -2
View File
@@ -23,7 +23,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2026-07-04 20:47+0200\n"
"POT-Creation-Date: 2026-07-04 20:55+0200\n"
"PO-Revision-Date: 2014-08-16 10:27+0200\n"
"Last-Translator: Sébastien Helleu <flashcode@flashtux.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -5649,7 +5649,7 @@ msgid "%sFailed to save theme \"%s\""
msgstr ""
#, c-format
msgid "Theme saved: %s"
msgid "Theme saved to: %s"
msgstr ""
#, c-format
+25 -19
View File
@@ -551,12 +551,12 @@ theme_make_backup_name (void)
* their default (config_file_option_has_changed) are written. If zero,
* every themable option is written (full snapshot).
*
* Return:
* 1: success
* 0: error
* Return path to saved file on success, NULL on error.
*
* Note: result must be freed after use.
*/
int
char *
theme_write_file (const char *name, const char *description, int diff_only)
{
char *path, *dir, *value, *now;
@@ -566,24 +566,26 @@ theme_write_file (const char *name, const char *description, int diff_only)
struct t_config_option *ptr_option;
if (!name || !name[0])
return 0;
return NULL;
path = NULL;
dir = NULL;
string_asprintf (&dir, "%s/themes", weechat_config_dir);
if (!dir)
return 0;
return NULL;
dir_mkdir (dir, 0755);
free (dir);
path = theme_user_file_path (name);
if (!path)
return 0;
return NULL;
file = fopen (path, "w");
free (path);
if (!file)
return 0;
{
free (path);
return NULL;
}
now = theme_format_now ();
fprintf (file, "[info]\n");
@@ -620,7 +622,7 @@ theme_write_file (const char *name, const char *description, int diff_only)
}
fclose (file);
return 1;
return path;
}
/*
@@ -634,19 +636,21 @@ theme_write_file (const char *name, const char *description, int diff_only)
char *
theme_make_backup (void)
{
char *name;
char *name, *path;
name = theme_make_backup_name ();
if (!name)
return NULL;
if (!theme_write_file (
name,
_("Automatic backup written before /theme apply"),
0)) /* full snapshot: backups must round-trip exactly */
path = theme_write_file (
name,
_("Automatic backup written before /theme apply"),
0); /* full snapshot: backups must round-trip exactly */
if (!path)
{
free (name);
return NULL;
}
free (path);
return name;
}
@@ -1129,6 +1133,8 @@ theme_reset (void)
int
theme_save (const char *name, int full)
{
char *path;
if (!name || !name[0])
return WEECHAT_RC_ERROR;
@@ -1152,7 +1158,8 @@ theme_save (const char *name, int full)
return WEECHAT_RC_ERROR;
}
if (!theme_write_file (name, NULL, (full) ? 0 : 1))
path = theme_write_file (name, NULL, (full) ? 0 : 1);
if (!path)
{
gui_chat_printf (NULL,
_("%sFailed to save theme \"%s\""),
@@ -1161,9 +1168,8 @@ theme_save (const char *name, int full)
return WEECHAT_RC_ERROR;
}
gui_chat_printf (NULL,
_("Theme saved: %s"),
name);
gui_chat_printf (NULL, _("Theme saved to: %s"), path);
free (path);
return WEECHAT_RC_OK;
}
+20 -9
View File
@@ -48,8 +48,8 @@ extern struct t_theme *theme_alloc (const char *name);
extern void theme_free (struct t_theme *theme);
extern char *theme_user_file_path (const char *name);
extern char *theme_make_backup_name (void);
extern int theme_write_file (const char *name, const char *description,
int diff_only);
extern char *theme_write_file (const char *name, const char *description,
int diff_only);
extern char *theme_file_strip_quotes (char *value);
extern struct t_theme *theme_file_parse (const char *path);
}
@@ -338,7 +338,7 @@ TEST(CoreTheme, MakeBackupName)
TEST(CoreTheme, WriteFile)
{
char *path, line[8192];
char *path, *expected_path, line[8192];
FILE *file;
int saw_info, saw_name, saw_description, saw_date, saw_weechat;
int saw_options_section, saw_an_option;
@@ -346,14 +346,20 @@ TEST(CoreTheme, WriteFile)
int full_options, diff_options;
/* refuse empty/NULL */
LONGS_EQUAL(0, theme_write_file (NULL, NULL, 0));
LONGS_EQUAL(0, theme_write_file ("", NULL, 0));
POINTERS_EQUAL(NULL, theme_write_file (NULL, NULL, 0));
POINTERS_EQUAL(NULL, theme_write_file ("", NULL, 0));
/* full snapshot: every themable option is written */
LONGS_EQUAL(1, theme_write_file ("test_wrt", "a description", 0));
/* full snapshot: every themable option is written; the returned
path matches the expected theme file path */
expected_path = theme_user_file_path ("test_wrt");
CHECK(expected_path != NULL);
path = theme_user_file_path ("test_wrt");
path = theme_write_file ("test_wrt", "a description", 0);
CHECK(path != NULL);
STRCMP_EQUAL(expected_path, path);
free (path);
path = expected_path;
file = fopen (path, "r");
CHECK(file != NULL);
@@ -417,7 +423,12 @@ TEST(CoreTheme, WriteFile)
/* diff-only snapshot in a freshly initialized config writes very
few (typically zero) [options] entries — never more than the
full snapshot */
LONGS_EQUAL(1, theme_write_file ("test_wrt", NULL, 1));
path = theme_write_file ("test_wrt", NULL, 1);
CHECK(path != NULL);
STRCMP_EQUAL(expected_path, path);
free (path);
path = expected_path;
file = fopen (path, "r");
CHECK(file != NULL);