#include "modules.h"
#include "signals.h"
#include "servers.h"
+#include "channels.h"
#include "settings.h"
#include "levels.h"
{
g_return_if_fail(window != NULL);
g_return_if_fail(item != NULL);
+ g_return_if_fail(item->window == NULL);
item->window = window;
window->items = g_slist_append(window->items, item);
signal_emit("window item new", 2, window, item);
- if (!automatic || g_slist_length(window->items) == 1) {
+ if (g_slist_length(window->items) == 1 ||
+ (!automatic && settings_get_bool("autofocus_new_items"))) {
window->active = NULL;
window_item_set_active(window, item);
}
window = window_item_window(item);
- if (g_slist_find(window->items, item) == NULL)
+ if (window == NULL)
return;
item->window = NULL;
window = window_item_window(item);
window_item_remove(item);
-
- signal_emit("window item destroy", 2, window, item);
+ item->destroy(item);
}
void window_item_change_server(WI_ITEM_REC *item, void *server)
WI_ITEM_REC *window_item_find_window(WINDOW_REC *window,
void *server, const char *name)
{
+ CHANNEL_REC *channel;
GSList *tmp;
for (tmp = window->items; tmp != NULL; tmp = tmp->next) {
WI_ITEM_REC *rec = tmp->data;
if ((server == NULL || rec->server == server) &&
- g_strcasecmp(name, rec->name) == 0) return rec;
+ g_strcasecmp(name, rec->visible_name) == 0)
+ return rec;
}
+ /* try with channel name too, it's not necessarily
+ same as visible_name (!channels) */
+ channel = channel_find(server, name);
+ if (channel != NULL && window_item_window(channel) == window)
+ return (WI_ITEM_REC *) channel;
+
return NULL;
}
void window_item_create(WI_ITEM_REC *item, int automatic)
{
WINDOW_REC *window;
+ WINDOW_BIND_REC *bind;
GSList *tmp, *sorted;
int clear_waiting, reuse_unused_windows;
g_return_if_fail(item != NULL);
- reuse_unused_windows =
- !settings_get_bool("autoclose_windows") ||
- settings_get_bool("reuse_unused_windows");
+ reuse_unused_windows = settings_get_bool("reuse_unused_windows");
clear_waiting = TRUE;
window = NULL;
WINDOW_REC *rec = tmp->data;
/* is item bound to this window? */
- if (item->server != NULL &&
- window_bind_find(rec, item->server->tag, item->name)) {
- window = rec;
- clear_waiting = FALSE;
- break;
+ if (item->server != NULL) {
+ bind = window_bind_find(rec, item->server->tag,
+ item->visible_name);
+ if (bind != NULL) {
+ if (!bind->sticky)
+ window_bind_destroy(rec, bind);
+ window = rec;
+ clear_waiting = FALSE;
+ break;
+ }
}
/* use this window IF:
if (window == NULL) {
/* create new window to use */
+ if (settings_get_bool("autocreate_split_windows")) {
+ signal_emit("gui window create override", 1,
+ GINT_TO_POINTER(0));
+ }
window = window_create(item, automatic);
} else {
/* use existing window */
if (g_slist_length(window->items) > 1) {
/* default to printing "talking with ...",
you can override it it you wish */
- printformat(item->server, item->name, MSGLEVEL_CLIENTNOTICE,
- TXT_TALKING_WITH, item->name);
+ printformat(item->server, item->visible_name,
+ MSGLEVEL_CLIENTNOTICE,
+ TXT_TALKING_WITH, item->visible_name);
}
}
{
settings_add_bool("lookandfeel", "reuse_unused_windows", FALSE);
settings_add_bool("lookandfeel", "autocreate_windows", TRUE);
+ settings_add_bool("lookandfeel", "autocreate_split_windows", FALSE);
+ settings_add_bool("lookandfeel", "autofocus_new_items", TRUE);
signal_add_last("window item changed", (SIGNAL_FUNC) signal_window_item_changed);
}