diff options
author | Timo Sirainen <cras@irssi.org> | 2000-12-02 06:08:31 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2000-12-02 06:08:31 +0000 |
commit | 0cb6db26d98c76b7965b0b9ddf2ed2e2892257cb (patch) | |
tree | 027f83ada5df4842db50c0cd334e9fb7a66bf700 /src | |
parent | 800ee1ea9a7278ae0fa57d7db710398ede74fe59 (diff) | |
download | irssi-0cb6db26d98c76b7965b0b9ddf2ed2e2892257cb.zip |
/WINDOW ITEM GOTO <name> - sets <name> window item active in current window
/WINDOW ITEM MOVE <number>|<name> - moves window item to another window
/JOIN #already_joined_channel - same as /WINDOW ITEM MOVE <name>
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@916 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src')
-rw-r--r-- | src/fe-common/core/fe-channels.c | 18 | ||||
-rw-r--r-- | src/fe-common/core/window-commands.c | 32 | ||||
-rw-r--r-- | src/fe-common/core/window-items.c | 31 | ||||
-rw-r--r-- | src/fe-common/core/window-items.h | 2 |
4 files changed, 77 insertions, 6 deletions
diff --git a/src/fe-common/core/fe-channels.c b/src/fe-common/core/fe-channels.c index bbe281f1..3d2fd644 100644 --- a/src/fe-common/core/fe-channels.c +++ b/src/fe-common/core/fe-channels.c @@ -114,15 +114,27 @@ static void cmd_wjoin_pre(const char *data) if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS | PARAM_FLAG_UNKNOWN_OPTIONS | PARAM_FLAG_GETREST, "join", &optlist, &nick)) - return; + return; if (g_hash_table_lookup(optlist, "window") != NULL) { signal_add("channel created", (SIGNAL_FUNC) signal_channel_created_curwin); - } + } cmd_params_free(free_arg); } +static void cmd_join(const char *data, SERVER_REC *server) +{ + CHANNEL_REC *channel; + + if (strchr(data, ' ') != NULL || strchr(data, ',') != NULL) + return; + + channel = channel_find(server, data); + if (channel != NULL) + window_item_set_active(active_win, (WI_ITEM_REC *) channel); +} + static void cmd_wjoin_post(const char *data) { GHashTable *optlist; @@ -287,6 +299,7 @@ void fe_channels_init(void) signal_add_last("server disconnected", (SIGNAL_FUNC) sig_disconnected); command_bind_first("join", NULL, (SIGNAL_FUNC) cmd_wjoin_pre); + command_bind("join", NULL, (SIGNAL_FUNC) cmd_join); command_bind_last("join", NULL, (SIGNAL_FUNC) cmd_wjoin_post); command_bind("channel", NULL, (SIGNAL_FUNC) cmd_channel); command_bind("channel add", NULL, (SIGNAL_FUNC) cmd_channel_add); @@ -306,6 +319,7 @@ void fe_channels_deinit(void) signal_remove("server disconnected", (SIGNAL_FUNC) sig_disconnected); command_unbind("join", (SIGNAL_FUNC) cmd_wjoin_pre); + command_unbind("join", (SIGNAL_FUNC) cmd_join); command_unbind("join", (SIGNAL_FUNC) cmd_wjoin_post); command_unbind("channel", (SIGNAL_FUNC) cmd_channel); command_unbind("channel add", (SIGNAL_FUNC) cmd_channel_add); diff --git a/src/fe-common/core/window-commands.c b/src/fe-common/core/window-commands.c index c716e1d9..48fe865e 100644 --- a/src/fe-common/core/window-commands.c +++ b/src/fe-common/core/window-commands.c @@ -212,6 +212,34 @@ static void cmd_window_item_next(void) window_item_next(active_win); } +/* SYNTAX: WINDOW ITEM GOTO <name> */ +static void cmd_window_item_goto(const char *data, SERVER_REC *server) +{ + WI_ITEM_REC *item; + + item = window_item_find_window(active_win, server, data); + if (item != NULL) + window_item_set_active(active_win, item); +} + +/* SYNTAX: WINDOW ITEM MOVE <number>|<name> */ +static void cmd_window_item_move(const char *data, SERVER_REC *server, + WI_ITEM_REC *item) +{ + WINDOW_REC *window; + + if (is_numeric(data, '\0')) { + /* move current window item to specified window */ + window = window_find_refnum(atoi(data)); + } else { + /* move specified window item to current window */ + item = window_item_find(server, data); + window = active_win; + } + if (window != NULL && item != NULL) + window_item_set_active(window, item); +} + /* SYNTAX: WINDOW NUMBER <number> */ static void cmd_window_number(const char *data) { @@ -403,6 +431,8 @@ void window_commands_init(void) 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); + command_bind("window item goto", NULL, (SIGNAL_FUNC) cmd_window_item_goto); + command_bind("window item move", NULL, (SIGNAL_FUNC) cmd_window_item_move); command_bind("window number", NULL, (SIGNAL_FUNC) cmd_window_number); command_bind("window name", NULL, (SIGNAL_FUNC) cmd_window_name); command_bind("window move", NULL, (SIGNAL_FUNC) cmd_window_move); @@ -429,6 +459,8 @@ void window_commands_deinit(void) 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); + command_unbind("window item goto", (SIGNAL_FUNC) cmd_window_item_goto); + command_unbind("window item move", (SIGNAL_FUNC) cmd_window_item_move); command_unbind("window number", (SIGNAL_FUNC) cmd_window_number); command_unbind("window name", (SIGNAL_FUNC) cmd_window_name); command_unbind("window move", (SIGNAL_FUNC) cmd_window_move); diff --git a/src/fe-common/core/window-items.c b/src/fe-common/core/window-items.c index 086ee884..3931a175 100644 --- a/src/fe-common/core/window-items.c +++ b/src/fe-common/core/window-items.c @@ -43,8 +43,6 @@ void window_add_item(WINDOW_REC *window, WI_ITEM_REC *item, int automatic) window->active_server = item->server; } - signal_emit("gui window item init", 1, item); - if (!automatic || settings_get_bool("window_auto_change")) { if (automatic) signal_emit("window changed automatic", 1, window); @@ -99,9 +97,33 @@ void window_item_change_server(WI_ITEM_REC *item, void *server) if (window->active == item) window_change_server(window, item->server); } +static void window_item_move(WINDOW_REC *window, WI_ITEM_REC *item) +{ + WINDOW_REC *oldwin; + + /* remove from old window */ + oldwin = window_item_window(item); + oldwin->items = g_slist_remove(oldwin->items, item); + window->items = g_slist_append(window->items, item); + + MODULE_DATA_SET(item, window); + + if (oldwin->active == item) { + window_item_set_active(oldwin, oldwin->items == NULL ? NULL : + oldwin->items->data); + } + + signal_emit("window item moved", 2, window, item); +} + void window_item_set_active(WINDOW_REC *window, WI_ITEM_REC *item) { - g_return_if_fail(window != NULL); + g_return_if_fail(window != NULL); + + if (item != NULL && window_item_window(item) != window) { + /* move item to different window */ + window_item_move(window, item); + } if (window->active != item) { window->active = item; @@ -180,7 +202,8 @@ void window_item_next(WINDOW_REC *window) window_item_set_active(window, next); } -static WI_ITEM_REC *window_item_find_window(WINDOW_REC *window, void *server, const char *name) +WI_ITEM_REC *window_item_find_window(WINDOW_REC *window, + void *server, const char *name) { GSList *tmp; diff --git a/src/fe-common/core/window-items.h b/src/fe-common/core/window-items.h index 0ed052ea..1ebece9c 100644 --- a/src/fe-common/core/window-items.h +++ b/src/fe-common/core/window-items.h @@ -22,6 +22,8 @@ void window_item_next(WINDOW_REC *window); /* Find wanted window item by name. `server' can be NULL. */ WI_ITEM_REC *window_item_find(void *server, const char *name); +WI_ITEM_REC *window_item_find_window(WINDOW_REC *window, + void *server, const char *name); void window_items_init(void); void window_items_deinit(void); |