1
0
mirror of https://github.com/irssi/irssi.git synced 2024-10-27 05:20:20 -04:00

Support for "immortal" windows, that can't be closed until explicitly set to

mortal with /WINDOW IMMORTAL OFF. Status and msgs windows are immortal by
default.


git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2422 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2002-02-10 14:59:36 +00:00 committed by cras
parent 59c5bb100a
commit 9bb16705a5
7 changed files with 69 additions and 7 deletions

View File

@ -292,12 +292,14 @@ static void create_windows(void)
window_set_level(window, MSGLEVEL_ALL ^
(settings_get_bool("use_msgs_window") ?
(MSGLEVEL_MSGS|MSGLEVEL_DCCMSGS) : 0));
window_set_immortal(window, TRUE);
}
if (settings_get_bool("use_msgs_window")) {
window = window_create(NULL, TRUE);
window_set_name(window, "(msgs)");
window_set_level(window, MSGLEVEL_MSGS|MSGLEVEL_DCCMSGS);
window_set_immortal(window, TRUE);
}
if (windows == NULL) {

View File

@ -135,7 +135,7 @@ void window_auto_destroy(WINDOW_REC *window)
{
if (settings_get_bool("autoclose_windows") && windows->next != NULL &&
window->items == NULL && window->bound_items == NULL &&
window->level == 0)
window->level == 0 && !window->immortal)
window_destroy(window);
}
@ -218,6 +218,14 @@ void window_set_level(WINDOW_REC *window, int level)
signal_emit("window level changed", 1, window);
}
void window_set_immortal(WINDOW_REC *window, int immortal)
{
g_return_if_fail(window != NULL);
window->immortal = immortal;
signal_emit("window immortal changed", 1, window);
}
/* return active item's name, or if none is active, window's name */
char *window_get_active_name(WINDOW_REC *window)
{

View File

@ -31,6 +31,7 @@ struct _WINDOW_REC {
int level; /* message level */
GSList *bound_items; /* list of WINDOW_BIND_RECs */
unsigned int immortal:1;
unsigned int sticky_refnum:1;
unsigned int destroying:1;
@ -65,6 +66,7 @@ void window_set_refnum(WINDOW_REC *window, int refnum);
void window_set_name(WINDOW_REC *window, const char *name);
void window_set_history(WINDOW_REC *window, const char *name);
void window_set_level(WINDOW_REC *window, int level);
void window_set_immortal(WINDOW_REC *window, int immortal);
/* return active item's name, or if none is active, window's name */
char *window_get_active_name(WINDOW_REC *window);

View File

@ -39,6 +39,9 @@ FORMAT_REC fecommon_core_formats[] = {
{ "unset_server_sticky", "Window's server isn't sticky anymore", 0 },
{ "window_name_not_unique", "Window names must be unique", 1, { 0 } },
{ "window_level", "Window level is now $0", 1, { 0 } },
{ "window_set_immortal", "Window is now immortal", 0 },
{ "window_unset_immortal", "Window isn't immortal anymore", 0 },
{ "window_immortal_error", "Window is immortal, if you really want to close it, say /WINDOW IMMORTAL OFF", 0 },
{ "windowlist_header", "Ref Name Active item Server Level", 0 },
{ "windowlist_line", "$[3]0 %|$[20]1 $[15]2 $[15]3 $4", 5, { 1, 0, 0, 0, 0 } },
{ "windowlist_footer", "", 0 },
@ -50,6 +53,7 @@ FORMAT_REC fecommon_core_formats[] = {
{ "window_info_refnum_sticky", "Window : {hilight #$0 (sticky)}", 1, { 1 } },
{ "window_info_name", "Name : $0", 1, { 0 } },
{ "window_info_history", "History : $0", 1, { 0 } },
{ "window_info_immortal", "Immortal: yes", 0 },
{ "window_info_size", "Size : $0x$1", 2, { 1, 1 } },
{ "window_info_level", "Level : $0", 1, { 0 } },
{ "window_info_server", "Server : $0", 1, { 0 } },

View File

@ -17,6 +17,9 @@ enum {
TXT_UNSET_SERVER_STICKY,
TXT_WINDOW_NAME_NOT_UNIQUE,
TXT_WINDOW_LEVEL,
TXT_WINDOW_SET_IMMORTAL,
TXT_WINDOW_UNSET_IMMORTAL,
TXT_WINDOW_IMMORTAL_ERROR,
TXT_WINDOWLIST_HEADER,
TXT_WINDOWLIST_LINE,
TXT_WINDOWLIST_FOOTER,
@ -28,6 +31,7 @@ enum {
TXT_WINDOW_INFO_REFNUM_STICKY,
TXT_WINDOW_INFO_NAME,
TXT_WINDOW_INFO_HISTORY,
TXT_WINDOW_INFO_IMMORTAL,
TXT_WINDOW_INFO_SIZE,
TXT_WINDOW_INFO_LEVEL,
TXT_WINDOW_INFO_SERVER,

View File

@ -94,16 +94,22 @@ static void cmd_window_info(WINDOW_REC *win)
TXT_WINDOW_INFO_NAME, win->name);
}
/* Window width / height */
printformat_window(win, MSGLEVEL_CLIENTCRAP, TXT_WINDOW_INFO_SIZE,
win->width, win->height);
/* Window immortality */
if (win->immortal) {
printformat_window(win, MSGLEVEL_CLIENTCRAP,
TXT_WINDOW_INFO_IMMORTAL);
}
/* Window history name */
if (win->history_name != NULL) {
printformat_window(win, MSGLEVEL_CLIENTCRAP,
TXT_WINDOW_INFO_HISTORY, win->history_name);
}
/* Window width / height */
printformat_window(win, MSGLEVEL_CLIENTCRAP, TXT_WINDOW_INFO_SIZE,
win->width, win->height);
/* Window level */
levelstr = win->level == 0 ?
g_strdup("NONE") : bits2level(win->level);
@ -209,8 +215,14 @@ static void cmd_window_close(const char *data)
while (destroys != NULL) {
WINDOW_REC *rec = destroys->data;
if (windows->next != NULL)
window_destroy(rec);
if (windows->next != NULL) {
if (!rec->immortal)
window_destroy(rec);
else {
printformat_window(rec, MSGLEVEL_CLIENTERROR,
TXT_WINDOW_IMMORTAL_ERROR);
}
}
destroys = g_slist_remove(destroys, rec);
}
@ -329,6 +341,33 @@ static void cmd_window_level(const char *data)
g_free(level);
}
/* SYNTAX: WINDOW IMMORTAL on|off|toggle */
static void cmd_window_immortal(const char *data)
{
int set;
if (g_strcasecmp(data, "ON") == 0)
set = TRUE;
else if (g_strcasecmp(data, "OFF") == 0)
set = FALSE;
else if (g_strcasecmp(data, "TOGGLE") == 0)
set = !active_win->immortal;
else {
printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, TXT_NOT_TOGGLE);
return;
}
if (set) {
window_set_immortal(active_win, TRUE);
printformat_window(active_win, MSGLEVEL_CLIENTNOTICE,
TXT_WINDOW_SET_IMMORTAL);
} else {
window_set_immortal(active_win, FALSE);
printformat_window(active_win, MSGLEVEL_CLIENTNOTICE,
TXT_WINDOW_UNSET_IMMORTAL);
}
}
/* SYNTAX: WINDOW SERVER [-sticky | -unsticky] <tag> */
static void cmd_window_server(const char *data)
{
@ -697,6 +736,7 @@ void window_commands_init(void)
command_bind("window next", NULL, (SIGNAL_FUNC) cmd_window_next);
command_bind("window last", NULL, (SIGNAL_FUNC) cmd_window_last);
command_bind("window level", NULL, (SIGNAL_FUNC) cmd_window_level);
command_bind("window immortal", NULL, (SIGNAL_FUNC) cmd_window_immortal);
command_bind("window item", NULL, (SIGNAL_FUNC) cmd_window_item);
command_bind("window item prev", NULL, (SIGNAL_FUNC) cmd_window_item_prev);
command_bind("window item next", NULL, (SIGNAL_FUNC) cmd_window_item_next);
@ -735,6 +775,7 @@ void window_commands_deinit(void)
command_unbind("window next", (SIGNAL_FUNC) cmd_window_next);
command_unbind("window last", (SIGNAL_FUNC) cmd_window_last);
command_unbind("window level", (SIGNAL_FUNC) cmd_window_level);
command_unbind("window immortal", (SIGNAL_FUNC) cmd_window_immortal);
command_unbind("window item", (SIGNAL_FUNC) cmd_window_item);
command_unbind("window item prev", (SIGNAL_FUNC) cmd_window_item_prev);
command_unbind("window item next", (SIGNAL_FUNC) cmd_window_item_next);

View File

@ -36,6 +36,7 @@ static void perl_window_fill_hash(HV *hv, WINDOW_REC *window)
hv_store(hv, "servertag", 9, new_pv(window->servertag), 0);
hv_store(hv, "level", 5, newSViv(window->level), 0);
hv_store(hv, "immortal", 8, newSViv(window->immortal), 0);
hv_store(hv, "sticky_refnum", 13, newSViv(window->sticky_refnum), 0);
hv_store(hv, "data_level", 10, newSViv(window->data_level), 0);