mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -05:00
/WINDOW SERVER: added -sticky and -unsticky options. If window server
is sticky, it will never be automatically changed, and it cannot be changed to anything else without -unsticky option. Should be useful for people who want status or msgs windows for each server. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1196 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
54870f51fd
commit
980d6ca3fd
@ -124,6 +124,7 @@ void window_destroy(WINDOW_REC *window)
|
|||||||
g_slist_foreach(window->waiting_channels, (GFunc) g_free, NULL);
|
g_slist_foreach(window->waiting_channels, (GFunc) g_free, NULL);
|
||||||
g_slist_free(window->waiting_channels);
|
g_slist_free(window->waiting_channels);
|
||||||
|
|
||||||
|
g_free_not_null(window->servertag);
|
||||||
g_free_not_null(window->theme_name);
|
g_free_not_null(window->theme_name);
|
||||||
g_free_not_null(window->name);
|
g_free_not_null(window->name);
|
||||||
g_free(window);
|
g_free(window);
|
||||||
@ -396,8 +397,10 @@ static void sig_server_looking(SERVER_REC *server)
|
|||||||
for (tmp = windows; tmp != NULL; tmp = tmp->next) {
|
for (tmp = windows; tmp != NULL; tmp = tmp->next) {
|
||||||
WINDOW_REC *rec = tmp->data;
|
WINDOW_REC *rec = tmp->data;
|
||||||
|
|
||||||
if (rec->active_server == NULL ||
|
if ((rec->servertag == NULL ||
|
||||||
(rec == active_win && rec->items == NULL))
|
g_strcasecmp(rec->servertag, server->tag) == 0) &&
|
||||||
|
(rec->active_server == NULL ||
|
||||||
|
(rec == active_win && rec->items == NULL)))
|
||||||
window_change_server(rec, server);
|
window_change_server(rec, server);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -413,8 +416,10 @@ static void sig_server_disconnected(SERVER_REC *server)
|
|||||||
for (tmp = windows; tmp != NULL; tmp = tmp->next) {
|
for (tmp = windows; tmp != NULL; tmp = tmp->next) {
|
||||||
WINDOW_REC *rec = tmp->data;
|
WINDOW_REC *rec = tmp->data;
|
||||||
|
|
||||||
if (rec->active_server == server)
|
if (rec->active_server == server) {
|
||||||
window_change_server(rec, new_server);
|
window_change_server(rec, rec->servertag != NULL ?
|
||||||
|
NULL : new_server);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ typedef struct {
|
|||||||
GSList *items;
|
GSList *items;
|
||||||
WI_ITEM_REC *active;
|
WI_ITEM_REC *active;
|
||||||
SERVER_REC *active_server;
|
SERVER_REC *active_server;
|
||||||
|
char *servertag; /* active_server must be either NULL or have this tag (unless there's items in this window) */
|
||||||
|
|
||||||
int level; /* message level */
|
int level; /* message level */
|
||||||
GSList *waiting_channels; /* list of "<server tag> <channel>" */
|
GSList *waiting_channels; /* list of "<server tag> <channel>" */
|
||||||
|
@ -34,10 +34,14 @@ FORMAT_REC fecommon_core_formats[] = {
|
|||||||
{ "daychange", "Day changed to $[-2.0]{0} $3 $2", 4, { 1, 1, 1, 0 } },
|
{ "daychange", "Day changed to $[-2.0]{0} $3 $2", 4, { 1, 1, 1, 0 } },
|
||||||
{ "talking_with", "You are now talking with {nick $0}", 1, { 0 } },
|
{ "talking_with", "You are now talking with {nick $0}", 1, { 0 } },
|
||||||
{ "refnum_too_low", "Window number must be greater than 1", 0 },
|
{ "refnum_too_low", "Window number must be greater than 1", 0 },
|
||||||
|
{ "error_server_sticky", "Window's server is sticky and it cannot be changed without -unsticky option", 0 },
|
||||||
|
{ "set_server_sticky", "Window's server set sticky", 1, { 0 } },
|
||||||
|
{ "unset_server_sticky", "Window's server isn't sticky anymore", 1, { 0 } },
|
||||||
{ "window_level", "Window level is now $0", 1, { 0 } },
|
{ "window_level", "Window level is now $0", 1, { 0 } },
|
||||||
{ "windowlist_header", "Ref Name Active item Server Level", 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_line", "$[3]0 %|$[20]1 $[15]2 $[15]3 $4", 5, { 1, 0, 0, 0, 0 } },
|
||||||
{ "windowlist_footer", "", 0 },
|
{ "windowlist_footer", "", 0 },
|
||||||
|
{ "windows_saved", "State of windows saved (/SAVE is still needed to update configuration file)", 0 },
|
||||||
|
|
||||||
/* ---- */
|
/* ---- */
|
||||||
{ NULL, "Server", 0 },
|
{ NULL, "Server", 0 },
|
||||||
|
@ -12,10 +12,14 @@ enum {
|
|||||||
TXT_DAYCHANGE,
|
TXT_DAYCHANGE,
|
||||||
TXT_TALKING_WITH,
|
TXT_TALKING_WITH,
|
||||||
TXT_REFNUM_TOO_LOW,
|
TXT_REFNUM_TOO_LOW,
|
||||||
|
TXT_ERROR_SERVER_STICKY,
|
||||||
|
TXT_SET_SERVER_STICKY,
|
||||||
|
TXT_UNSET_SERVER_STICKY,
|
||||||
TXT_WINDOW_LEVEL,
|
TXT_WINDOW_LEVEL,
|
||||||
TXT_WINDOWLIST_HEADER,
|
TXT_WINDOWLIST_HEADER,
|
||||||
TXT_WINDOWLIST_LINE,
|
TXT_WINDOWLIST_LINE,
|
||||||
TXT_WINDOWLIST_FOOTER,
|
TXT_WINDOWLIST_FOOTER,
|
||||||
|
TXT_WINDOWS_SAVED,
|
||||||
|
|
||||||
TXT_FILL_2,
|
TXT_FILL_2,
|
||||||
|
|
||||||
|
@ -178,25 +178,58 @@ static void cmd_window_level(const char *data)
|
|||||||
g_free(level);
|
g_free(level);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* SYNTAX: WINDOW SERVER <tag> */
|
/* SYNTAX: WINDOW SERVER [-sticky | -unsticky] <tag> */
|
||||||
static void cmd_window_server(const char *data)
|
static void cmd_window_server(const char *data)
|
||||||
{
|
{
|
||||||
|
GHashTable *optlist;
|
||||||
SERVER_REC *server;
|
SERVER_REC *server;
|
||||||
|
char *tag;
|
||||||
|
void *free_arg;
|
||||||
|
|
||||||
g_return_if_fail(data != NULL);
|
if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS,
|
||||||
|
"window server", &optlist, &tag))
|
||||||
|
return;
|
||||||
|
|
||||||
server = server_find_tag(data);
|
if (*tag == '\0' &&
|
||||||
if (server == NULL) {
|
(g_hash_table_lookup(optlist, "sticky") != NULL ||
|
||||||
|
g_hash_table_lookup(optlist, "unsticky") != NULL)) {
|
||||||
|
tag = active_win->active_server->tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*tag == '\0')
|
||||||
|
cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
||||||
|
server = server_find_tag(tag);
|
||||||
|
|
||||||
|
if (g_hash_table_lookup(optlist, "unsticky") != NULL &&
|
||||||
|
active_win->servertag != NULL) {
|
||||||
|
g_free_and_null(active_win->servertag);
|
||||||
printformat_window(active_win, MSGLEVEL_CLIENTNOTICE,
|
printformat_window(active_win, MSGLEVEL_CLIENTNOTICE,
|
||||||
TXT_UNKNOWN_SERVER_TAG, data);
|
TXT_UNSET_SERVER_STICKY, server->tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (active_win->servertag != NULL &&
|
||||||
|
g_hash_table_lookup(optlist, "sticky") == NULL) {
|
||||||
|
printformat_window(active_win, MSGLEVEL_CLIENTERROR,
|
||||||
|
TXT_ERROR_SERVER_STICKY);
|
||||||
|
} else if (server == NULL) {
|
||||||
|
printformat_window(active_win, MSGLEVEL_CLIENTNOTICE,
|
||||||
|
TXT_UNKNOWN_SERVER_TAG, tag);
|
||||||
} else if (active_win->active == NULL) {
|
} else if (active_win->active == NULL) {
|
||||||
window_change_server(active_win, server);
|
window_change_server(active_win, server);
|
||||||
|
if (g_hash_table_lookup(optlist, "sticky") != NULL) {
|
||||||
|
g_free_not_null(active_win->servertag);
|
||||||
|
active_win->servertag = g_strdup(server->tag);
|
||||||
|
printformat_window(active_win, MSGLEVEL_CLIENTNOTICE,
|
||||||
|
TXT_SET_SERVER_STICKY, server->tag);
|
||||||
|
}
|
||||||
printformat_window(active_win, MSGLEVEL_CLIENTNOTICE,
|
printformat_window(active_win, MSGLEVEL_CLIENTNOTICE,
|
||||||
TXT_SERVER_CHANGED,
|
TXT_SERVER_CHANGED,
|
||||||
server->tag, server->connrec->address,
|
server->tag, server->connrec->address,
|
||||||
server->connrec->chatnet == NULL ? "" :
|
server->connrec->chatnet == NULL ? "" :
|
||||||
server->connrec->chatnet);
|
server->connrec->chatnet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cmd_params_free(free_arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_window_item(const char *data, void *server, WI_ITEM_REC *item)
|
static void cmd_window_item(const char *data, void *server, WI_ITEM_REC *item)
|
||||||
@ -446,6 +479,7 @@ void window_commands_init(void)
|
|||||||
command_bind("savewindows", NULL, (SIGNAL_FUNC) cmd_savewindows);
|
command_bind("savewindows", NULL, (SIGNAL_FUNC) cmd_savewindows);
|
||||||
|
|
||||||
command_set_options("window number", "sticky");
|
command_set_options("window number", "sticky");
|
||||||
|
command_set_options("window server", "sticky unsticky");
|
||||||
}
|
}
|
||||||
|
|
||||||
void window_commands_deinit(void)
|
void window_commands_deinit(void)
|
||||||
|
@ -29,6 +29,8 @@
|
|||||||
#include "servers.h"
|
#include "servers.h"
|
||||||
#include "queries.h"
|
#include "queries.h"
|
||||||
|
|
||||||
|
#include "module-formats.h"
|
||||||
|
#include "printtext.h"
|
||||||
#include "themes.h"
|
#include "themes.h"
|
||||||
#include "fe-windows.h"
|
#include "fe-windows.h"
|
||||||
#include "window-items.h"
|
#include "window-items.h"
|
||||||
@ -93,6 +95,7 @@ void windows_restore(void)
|
|||||||
window_set_name(window, config_node_get_str(node, "name", NULL));
|
window_set_name(window, config_node_get_str(node, "name", NULL));
|
||||||
window_set_level(window, level2bits(config_node_get_str(node, "level", "")));
|
window_set_level(window, level2bits(config_node_get_str(node, "level", "")));
|
||||||
|
|
||||||
|
window->servertag = g_strdup(config_node_get_str(node, "servertag", NULL));
|
||||||
window->theme_name = g_strdup(config_node_get_str(node, "theme", NULL));
|
window->theme_name = g_strdup(config_node_get_str(node, "theme", NULL));
|
||||||
if (window->theme_name != NULL)
|
if (window->theme_name != NULL)
|
||||||
window->theme = theme_load(window->theme_name);
|
window->theme = theme_load(window->theme_name);
|
||||||
@ -143,6 +146,8 @@ static void window_save(WINDOW_REC *window, CONFIG_NODE *node)
|
|||||||
|
|
||||||
if (window->name != NULL)
|
if (window->name != NULL)
|
||||||
iconfig_node_set_str(node, "name", window->name);
|
iconfig_node_set_str(node, "name", window->name);
|
||||||
|
if (window->servertag != NULL)
|
||||||
|
iconfig_node_set_str(node, "servertag", window->servertag);
|
||||||
if (window->level != 0) {
|
if (window->level != 0) {
|
||||||
char *level = bits2level(window->level);
|
char *level = bits2level(window->level);
|
||||||
iconfig_node_set_str(node, "level", level);
|
iconfig_node_set_str(node, "level", level);
|
||||||
@ -166,6 +171,8 @@ void windows_save(void)
|
|||||||
|
|
||||||
g_slist_foreach(windows, (GFunc) window_save, node);
|
g_slist_foreach(windows, (GFunc) window_save, node);
|
||||||
signal_emit("windows saved", 0);
|
signal_emit("windows saved", 0);
|
||||||
|
|
||||||
|
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_WINDOWS_SAVED);
|
||||||
}
|
}
|
||||||
|
|
||||||
void window_save_init(void)
|
void window_save_init(void)
|
||||||
|
Loading…
Reference in New Issue
Block a user