From 9d2dc4b04c2131d9dee2f76b7ac84eb1d83f05a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Wed, 27 May 2026 18:04:35 +0200 Subject: [PATCH] xfer: contribute "light" theme overrides Add xfer-theme.{c,h} with the xfer plugin contribution to the built-in "light" theme: 7 overrides on xfer.color.* (status_aborted, status_active, status_connecting, status_done, status_failed, status_waiting, text_selected) tuned for a light-background terminal. Same NULL-terminated 2D-array pattern as the irc, fset and buflist contributions; xfer_theme_init() is called once from weechat_plugin_init after xfer_config_init / xfer_config_read. Default option values are NOT changed. --- src/plugins/xfer/CMakeLists.txt | 1 + src/plugins/xfer/xfer-theme.c | 90 +++++++++++++++++++++++++++++++++ src/plugins/xfer/xfer-theme.h | 27 ++++++++++ src/plugins/xfer/xfer.c | 3 ++ 4 files changed, 121 insertions(+) create mode 100644 src/plugins/xfer/xfer-theme.c create mode 100644 src/plugins/xfer/xfer-theme.h diff --git a/src/plugins/xfer/CMakeLists.txt b/src/plugins/xfer/CMakeLists.txt index 214443657..9abccbd79 100644 --- a/src/plugins/xfer/CMakeLists.txt +++ b/src/plugins/xfer/CMakeLists.txt @@ -30,6 +30,7 @@ add_library(xfer MODULE xfer-file.c xfer-file.h xfer-info.c xfer-info.h xfer-network.c xfer-network.h + xfer-theme.c xfer-theme.h xfer-upgrade.c xfer-upgrade.h ) set_target_properties(xfer PROPERTIES PREFIX "") diff --git a/src/plugins/xfer/xfer-theme.c b/src/plugins/xfer/xfer-theme.c new file mode 100644 index 000000000..e9bf7c0d7 --- /dev/null +++ b/src/plugins/xfer/xfer-theme.c @@ -0,0 +1,90 @@ +/* + * SPDX-FileCopyrightText: 2026 Sébastien Helleu + * + * SPDX-License-Identifier: GPL-3.0-or-later + * + * This file is part of WeeChat, the extensible chat client. + * + * WeeChat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * WeeChat is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with WeeChat. If not, see . + */ + +/* xfer contribution to built-in themes. */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include "../weechat-plugin.h" +#include "xfer.h" +#include "xfer-theme.h" + + +/* + * xfer contribution to the "light" theme: option values tuned for a + * light-background terminal. Each row is { option_full_name, value }; + * the table is NULL-terminated. + */ + +const char *xfer_theme_light[][2] = +{ + { "xfer.color.status_aborted", "red" }, + { "xfer.color.status_active", "blue" }, + { "xfer.color.status_connecting", "202" }, + { "xfer.color.status_done", "green" }, + { "xfer.color.status_failed", "red" }, + { "xfer.color.status_waiting", "cyan" }, + { "xfer.color.text_selected", "default" }, + { NULL, NULL }, +}; + +/* + * Registers xfer's contribution to one theme from a NULL-terminated + * table of {option, value} rows. + */ + +void +xfer_theme_register (const char *name, const char *entries[][2]) +{ + struct t_hashtable *overrides; + int i; + + if (!name || !entries) + return; + + overrides = weechat_hashtable_new (32, + WEECHAT_HASHTABLE_STRING, + WEECHAT_HASHTABLE_STRING, + NULL, NULL); + if (!overrides) + return; + + for (i = 0; entries[i][0]; i++) + weechat_hashtable_set (overrides, entries[i][0], entries[i][1]); + + weechat_theme_register (name, overrides); + + weechat_hashtable_free (overrides); +} + +/* + * Registers all built-in theme contributions from xfer. + */ + +void +xfer_theme_init (void) +{ + xfer_theme_register ("light", xfer_theme_light); +} diff --git a/src/plugins/xfer/xfer-theme.h b/src/plugins/xfer/xfer-theme.h new file mode 100644 index 000000000..c9a278283 --- /dev/null +++ b/src/plugins/xfer/xfer-theme.h @@ -0,0 +1,27 @@ +/* + * SPDX-FileCopyrightText: 2026 Sébastien Helleu + * + * SPDX-License-Identifier: GPL-3.0-or-later + * + * This file is part of WeeChat, the extensible chat client. + * + * WeeChat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * WeeChat is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with WeeChat. If not, see . + */ + +#ifndef WEECHAT_PLUGIN_XFER_THEME_H +#define WEECHAT_PLUGIN_XFER_THEME_H + +extern void xfer_theme_init (void); + +#endif /* WEECHAT_PLUGIN_XFER_THEME_H */ diff --git a/src/plugins/xfer/xfer.c b/src/plugins/xfer/xfer.c index 386162dba..29fb78f36 100644 --- a/src/plugins/xfer/xfer.c +++ b/src/plugins/xfer/xfer.c @@ -45,6 +45,7 @@ #include "xfer-file.h" #include "xfer-info.h" #include "xfer-network.h" +#include "xfer-theme.h" #include "xfer-upgrade.h" @@ -1839,6 +1840,8 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) xfer_config_read (); + xfer_theme_init (); + xfer_create_directories (); xfer_command_init ();