summaryrefslogtreecommitdiff
path: root/src/fe-common/core/fe-channels.c
diff options
context:
space:
mode:
authorEmanuele Giaquinta <exg@irssi.org>2007-06-10 17:15:14 +0000
committerexg <exg@dbcabf3a-b0e7-0310-adc4-f8d773084564>2007-06-10 17:15:14 +0000
commitd51a03ed01d0714ac1cd6a563e92871d8caf0665 (patch)
tree5d438a03f20bf60847b2cf6d1143b3b519bf43fe /src/fe-common/core/fe-channels.c
parentdb0eac61e4a241d5cf24da9c9b82c1e16a16163b (diff)
downloadirssi-d51a03ed01d0714ac1cd6a563e92871d8caf0665.zip
Make -window option of /join and /query accept an optional numeric argument
that specifies the refnum of the window to create the item in, bug #203. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@4549 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/fe-common/core/fe-channels.c')
-rw-r--r--src/fe-common/core/fe-channels.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/src/fe-common/core/fe-channels.c b/src/fe-common/core/fe-channels.c
index a3325ef8..1e9ff267 100644
--- a/src/fe-common/core/fe-channels.c
+++ b/src/fe-common/core/fe-channels.c
@@ -49,9 +49,18 @@ static void signal_channel_created(CHANNEL_REC *channel, void *automatic)
static void signal_channel_created_curwin(CHANNEL_REC *channel)
{
+ WINDOW_REC *window;
+ int refnum;
+
g_return_if_fail(channel != NULL);
- window_item_add(active_win, (WI_ITEM_REC *) channel, FALSE);
+ window = NULL;
+ refnum = GPOINTER_TO_INT(signal_get_user_data());
+ if (refnum > 0)
+ window = window_find_refnum(refnum);
+ if (window == NULL)
+ window = active_win;
+ window_item_add(window, (WI_ITEM_REC *) channel, window != active_win);
}
static void signal_channel_destroyed(CHANNEL_REC *channel)
@@ -115,6 +124,7 @@ static void cmd_wjoin_pre(const char *data, SERVER_REC *server)
GHashTable *optlist;
char *nick;
void *free_arg;
+ char *arg;
if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS |
PARAM_FLAG_UNKNOWN_OPTIONS | PARAM_FLAG_GETREST,
@@ -127,9 +137,11 @@ static void cmd_wjoin_pre(const char *data, SERVER_REC *server)
cmd_params_free(free_arg);
return;
}
- if (g_hash_table_lookup(optlist, "window") != NULL) {
- signal_add("channel created",
- (SIGNAL_FUNC) signal_channel_created_curwin);
+ arg = g_hash_table_lookup(optlist, "window");
+ if (arg != NULL) {
+ int refnum = *arg != '\0' ? atoi(arg) : 0;
+ signal_add_data("channel created",
+ (SIGNAL_FUNC) signal_channel_created_curwin, GINT_TO_POINTER(refnum));
}
cmd_params_free(free_arg);
}
@@ -167,15 +179,18 @@ static void cmd_wjoin_post(const char *data)
GHashTable *optlist;
char *nick;
void *free_arg;
+ char *arg;
if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS |
PARAM_FLAG_UNKNOWN_OPTIONS | PARAM_FLAG_GETREST,
"join", &optlist, &nick))
return;
- if (g_hash_table_lookup(optlist, "window") != NULL) {
- signal_remove("channel created",
- (SIGNAL_FUNC) signal_channel_created_curwin);
+ arg = g_hash_table_lookup(optlist, "window");
+ if (arg != NULL) {
+ int refnum = *arg != '\0' ? atoi(arg) : 0;
+ signal_remove_data("channel created",
+ (SIGNAL_FUNC) signal_channel_created_curwin, GINT_TO_POINTER(refnum));
}
cmd_params_free(free_arg);
}
@@ -650,7 +665,7 @@ void fe_channels_init(void)
command_set_options("channel add", "auto noauto -bots -botcmd");
command_set_options("names", "count ops halfops voices normal");
- command_set_options("join", "window");
+ command_set_options("join", "@window");
}
void fe_channels_deinit(void)