diff options
author | Timo Sirainen <cras@irssi.org> | 2002-09-14 23:14:04 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2002-09-14 23:14:04 +0000 |
commit | a83366069fd5e31a123bd402a92d25ad62fed11e (patch) | |
tree | 55f47e0443b586da81e9b4965eb137c3bb19bab8 /src/fe-common/core | |
parent | 930dd40815f09378369d02d5a77e0597eb5f7620 (diff) | |
download | irssi-a83366069fd5e31a123bd402a92d25ad62fed11e.zip |
window->active_server used to hold non-connected servers, but that was
removed before because it created several problems, especially with scripts.
however that change made /server and /disconnect annoying to use with
non-connected servers.
so, now we have window->connect_server as well. either active_server or
connect_server is set, but never both. commands that can deal properly with
non-connected servers can now use the connect_server, while everyone else
happily thinks that no server is active.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2921 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/fe-common/core')
-rw-r--r-- | src/fe-common/core/fe-windows.c | 28 | ||||
-rw-r--r-- | src/fe-common/core/fe-windows.h | 1 | ||||
-rw-r--r-- | src/fe-common/core/window-commands.c | 2 |
3 files changed, 28 insertions, 3 deletions
diff --git a/src/fe-common/core/fe-windows.c b/src/fe-common/core/fe-windows.c index 91153814..6d894b9a 100644 --- a/src/fe-common/core/fe-windows.c +++ b/src/fe-common/core/fe-windows.c @@ -161,11 +161,30 @@ void window_set_active(WINDOW_REC *window) void window_change_server(WINDOW_REC *window, void *server) { + SERVER_REC *active, *connect; + if (server != NULL && SERVER(server)->disconnected) return; - window->active_server = server; - signal_emit("window server changed", 2, window, server); + if (server == NULL) { + active = connect = NULL; + } else if (SERVER(server)->connected) { + active = server; + connect = NULL; + } else { + active = NULL; + connect = server; + } + + if (window->connect_server != connect) { + window->connect_server = connect; + signal_emit("window connect changed", 2, window, connect); + } + + if (window->active_server != active) { + window->active_server = active; + signal_emit("window server changed", 2, window, active); + } } void window_set_refnum(WINDOW_REC *window, int refnum) @@ -519,7 +538,8 @@ static void sig_server_disconnected(SERVER_REC *server) for (tmp = windows; tmp != NULL; tmp = tmp->next) { WINDOW_REC *rec = tmp->data; - if (rec->active_server == server) { + if (rec->active_server == server || + rec->connect_server == server) { window_change_server(rec, rec->servertag != NULL ? NULL : new_server); } @@ -609,6 +629,7 @@ void windows_init(void) settings_add_str("lookandfeel", "window_default_level", "NONE"); read_settings(); + signal_add("server looking", (SIGNAL_FUNC) sig_server_connected); signal_add("server connected", (SIGNAL_FUNC) sig_server_connected); signal_add("server disconnected", (SIGNAL_FUNC) sig_server_disconnected); signal_add("server connect failed", (SIGNAL_FUNC) sig_server_disconnected); @@ -620,6 +641,7 @@ void windows_deinit(void) if (daytag != -1) g_source_remove(daytag); if (daycheck == 1) signal_remove("print text", (SIGNAL_FUNC) sig_print_text); + signal_remove("server looking", (SIGNAL_FUNC) sig_server_connected); signal_remove("server connected", (SIGNAL_FUNC) sig_server_connected); signal_remove("server disconnected", (SIGNAL_FUNC) sig_server_disconnected); signal_remove("server connect failed", (SIGNAL_FUNC) sig_server_disconnected); diff --git a/src/fe-common/core/fe-windows.h b/src/fe-common/core/fe-windows.h index 64aaddd4..58c316ef 100644 --- a/src/fe-common/core/fe-windows.h +++ b/src/fe-common/core/fe-windows.h @@ -26,6 +26,7 @@ struct _WINDOW_REC { GSList *items; WI_ITEM_REC *active; SERVER_REC *active_server; + SERVER_REC *connect_server; char *servertag; /* active_server must be either NULL or have this tag (unless there's items in this window) */ int level; /* message level */ diff --git a/src/fe-common/core/window-commands.c b/src/fe-common/core/window-commands.c index 26ec2286..43629423 100644 --- a/src/fe-common/core/window-commands.c +++ b/src/fe-common/core/window-commands.c @@ -393,6 +393,8 @@ static void cmd_window_server(const char *data) if (*tag == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); server = server_find_tag(tag); + if (server == NULL) + server = server_find_lookup_tag(tag); if (g_hash_table_lookup(optlist, "unsticky") != NULL && active_win->servertag != NULL) { |