From 69c864f8d50367c3fcebf523451080bd46cf6e42 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Wed, 27 Jun 2001 21:16:43 +0000 Subject: Added -delete option to /WINDOW THEME. /WINDOW THEME without parameters prints the active theme. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1576 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/fe-common/core/module-formats.c | 5 +++- src/fe-common/core/module-formats.h | 3 +++ src/fe-common/core/window-commands.c | 45 ++++++++++++++++++++++++++++-------- 3 files changed, 43 insertions(+), 10 deletions(-) (limited to 'src/fe-common') diff --git a/src/fe-common/core/module-formats.c b/src/fe-common/core/module-formats.c index 5f4448c1..6e84a9ce 100644 --- a/src/fe-common/core/module-formats.c +++ b/src/fe-common/core/module-formats.c @@ -193,7 +193,10 @@ FORMAT_REC fecommon_core_formats[] = { { "theme_save_failed", "Error saving theme to $0: $1", 2, { 0, 0 } }, { "theme_not_found", "Theme {hilight $0} not found", 1, { 0 } }, { "theme_changed", "Using now theme {hilight $0} ($1)", 2, { 0, 0 } }, - { "window_theme_changed", "Using theme {hilight $0} ($1) in this window", 2, { 0, 0 } }, + { "window_theme", "Using theme {hilight $0} in this window", 2, { 0, 0 } }, + { "window_theme_default", "No theme is set for this window", 0 }, + { "window_theme_changed", "Using now theme {hilight $0} ($1) in this window", 2, { 0, 0 } }, + { "window_theme_removed", "Removed theme from this window", 0 }, { "format_title", "%:[{hilight $0}] - [{hilight $1}]%:", 2, { 0, 0 } }, { "format_subtitle", "[{hilight $0}]", 1, { 0 } }, { "format_item", "$0 = $1", 2, { 0, 0 } }, diff --git a/src/fe-common/core/module-formats.h b/src/fe-common/core/module-formats.h index c43d330d..de7177f1 100644 --- a/src/fe-common/core/module-formats.h +++ b/src/fe-common/core/module-formats.h @@ -161,7 +161,10 @@ enum { TXT_THEME_SAVE_FAILED, TXT_THEME_NOT_FOUND, TXT_THEME_CHANGED, + TXT_WINDOW_THEME, + TXT_WINDOW_THEME_DEFAULT, TXT_WINDOW_THEME_CHANGED, + TXT_WINDOW_THEME_REMOVED, TXT_FORMAT_TITLE, TXT_FORMAT_SUBTITLE, TXT_FORMAT_ITEM, diff --git a/src/fe-common/core/window-commands.c b/src/fe-common/core/window-commands.c index 29ed437b..99af8e77 100644 --- a/src/fe-common/core/window-commands.c +++ b/src/fe-common/core/window-commands.c @@ -463,23 +463,49 @@ static void cmd_window_list(void) printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, TXT_WINDOWLIST_FOOTER); } -/* SYNTAX: WINDOW THEME */ +/* SYNTAX: WINDOW THEME [-delete] [] */ static void cmd_window_theme(const char *data) { THEME_REC *theme; + GHashTable *optlist; + char *name; + void *free_arg; + + if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS, + "window theme", &optlist, &name)) + return; - g_free_not_null(active_win->theme_name); - active_win->theme_name = g_strdup(data); + if (g_hash_table_lookup(optlist, "delete") != NULL) { + g_free_and_null(active_win->theme_name); - active_win->theme = theme = theme_load(data); - if (theme != NULL) { printformat_window(active_win, MSGLEVEL_CLIENTNOTICE, - TXT_WINDOW_THEME_CHANGED, - theme->name, theme->path); + TXT_WINDOW_THEME_REMOVED); + } else if (*name == '\0') { + if (active_win->theme == NULL) { + printformat_window(active_win, MSGLEVEL_CLIENTNOTICE, + TXT_WINDOW_THEME_DEFAULT); + } else { + theme = active_win->theme; + printformat_window(active_win, MSGLEVEL_CLIENTNOTICE, + TXT_WINDOW_THEME, + theme->name, theme->path); + } } else { - printformat_window(active_win, MSGLEVEL_CLIENTNOTICE, - TXT_THEME_NOT_FOUND, data); + g_free_not_null(active_win->theme_name); + active_win->theme_name = g_strdup(data); + + active_win->theme = theme = theme_load(data); + if (theme != NULL) { + printformat_window(active_win, MSGLEVEL_CLIENTNOTICE, + TXT_WINDOW_THEME_CHANGED, + theme->name, theme->path); + } else { + printformat_window(active_win, MSGLEVEL_CLIENTNOTICE, + TXT_THEME_NOT_FOUND, data); + } } + + cmd_params_free(free_arg); } static void cmd_layout(const char *data, SERVER_REC *server, WI_ITEM_REC *item) @@ -538,6 +564,7 @@ void window_commands_init(void) command_set_options("window number", "sticky"); command_set_options("window server", "sticky unsticky"); + command_set_options("window theme", "delete"); } void window_commands_deinit(void) -- cgit v1.2.3