mirror of
https://github.com/irssi/irssi.git
synced 2024-11-03 04:27:19 -05:00
/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
This commit is contained in:
parent
800ee1ea9a
commit
0cb6db26d9
@ -123,6 +123,18 @@ static void cmd_wjoin_pre(const char *data)
|
||||
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);
|
||||
|
@ -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);
|
||||
|
@ -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,10 +97,34 @@ 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);
|
||||
|
||||
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;
|
||||
if (item != NULL) window_change_server(window, window->active_server);
|
||||
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user