From 1dc651742bcdba1e0f0a9c18b3d648b0adbeeee5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Sat, 4 Jul 2026 21:20:02 +0200 Subject: [PATCH] core: display path to theme written with /theme save --- po/cs.po | 4 +-- po/de.po | 4 +-- po/es.po | 4 +-- po/fr.po | 8 +++--- po/hu.po | 4 +-- po/it.po | 4 +-- po/ja.po | 4 +-- po/pl.po | 4 +-- po/pt.po | 4 +-- po/pt_BR.po | 4 +-- po/ru.po | 4 +-- po/sr.po | 4 +-- po/tr.po | 4 +-- po/weechat.pot | 4 +-- src/core/core-theme.c | 44 ++++++++++++++++------------- tests/unit/core/test-core-theme.cpp | 29 +++++++++++++------ 16 files changed, 75 insertions(+), 58 deletions(-) diff --git a/po/cs.po b/po/cs.po index 95cdc5c17..6e828bed2 100644 --- a/po/cs.po +++ b/po/cs.po @@ -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 \n" "Language-Team: Czech \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 diff --git a/po/de.po b/po/de.po index e4a29dd13..46a68d5b6 100644 --- a/po/de.po +++ b/po/de.po @@ -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 \n" "Language-Team: German \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 diff --git a/po/es.po b/po/es.po index fafa32b63..02b09fc45 100644 --- a/po/es.po +++ b/po/es.po @@ -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 \n" "Language-Team: Spanish \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 diff --git a/po/fr.po b/po/fr.po index b78f4e024..d30a6dc7b 100644 --- a/po/fr.po +++ b/po/fr.po @@ -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 \n" "Language-Team: French \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\"" diff --git a/po/hu.po b/po/hu.po index 6f28c9118..54d354389 100644 --- a/po/hu.po +++ b/po/hu.po @@ -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 \n" "Language-Team: Hungarian \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 diff --git a/po/it.po b/po/it.po index bd4836136..c2f4376df 100644 --- a/po/it.po +++ b/po/it.po @@ -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 \n" "Language-Team: Italian \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 diff --git a/po/ja.po b/po/ja.po index 82182b09d..7270bee99 100644 --- a/po/ja.po +++ b/po/ja.po @@ -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 \n" "Language-Team: Japanese \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 diff --git a/po/pl.po b/po/pl.po index fb6eb96d7..70f66b8dd 100644 --- a/po/pl.po +++ b/po/pl.po @@ -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 \n" "Language-Team: Polish \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 diff --git a/po/pt.po b/po/pt.po index c381f8cc9..ce8075fec 100644 --- a/po/pt.po +++ b/po/pt.po @@ -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 \n" "Language-Team: Portuguese \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 diff --git a/po/pt_BR.po b/po/pt_BR.po index fb8c2d47f..0a7413f76 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -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 \n" "Language-Team: Portuguese (Brazil) \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 diff --git a/po/ru.po b/po/ru.po index 84ca35b62..50e43e7af 100644 --- a/po/ru.po +++ b/po/ru.po @@ -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 \n" "Language-Team: Russian \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 diff --git a/po/sr.po b/po/sr.po index f55d7ebc5..29cc17824 100644 --- a/po/sr.po +++ b/po/sr.po @@ -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ć \n" "Language-Team: Serbian \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 diff --git a/po/tr.po b/po/tr.po index c404351ae..856efdd39 100644 --- a/po/tr.po +++ b/po/tr.po @@ -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 \n" "Language-Team: Turkish \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 diff --git a/po/weechat.pot b/po/weechat.pot index 4daff38fc..7b1ea483c 100644 --- a/po/weechat.pot +++ b/po/weechat.pot @@ -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 \n" "Language-Team: weechat-dev \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 diff --git a/src/core/core-theme.c b/src/core/core-theme.c index e2bcd2f33..4a05cabd5 100644 --- a/src/core/core-theme.c +++ b/src/core/core-theme.c @@ -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; } diff --git a/tests/unit/core/test-core-theme.cpp b/tests/unit/core/test-core-theme.cpp index 7f483288f..3861aeb76 100644 --- a/tests/unit/core/test-core-theme.cpp +++ b/tests/unit/core/test-core-theme.cpp @@ -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);