1
0
mirror of https://github.com/irssi/irssi.git synced 2025-02-02 15:08:01 -05:00

window_[add|remove]_item -> window_item_[add|remove]

added window_item_destroy(), window_item_remove() doesn't destroy the
item anymore

window_find_item()'s first parameter changed from WINDOW_REC to SERVER_REC


git-svn-id: http://svn.irssi.org/repos/irssi/trunk@922 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2000-12-02 19:08:21 +00:00 committed by cras
parent ed550c01d1
commit df94b9a44c
10 changed files with 62 additions and 58 deletions

View File

@ -46,7 +46,7 @@ static void signal_channel_created_curwin(CHANNEL_REC *channel)
{
g_return_if_fail(channel != NULL);
window_add_item(active_win, (WI_ITEM_REC *) channel, FALSE);
window_item_add(active_win, (WI_ITEM_REC *) channel, FALSE);
}
static void signal_channel_destroyed(CHANNEL_REC *channel)
@ -57,7 +57,7 @@ static void signal_channel_destroyed(CHANNEL_REC *channel)
window = window_item_window((WI_ITEM_REC *) channel);
if (window != NULL) {
window_remove_item(window, (WI_ITEM_REC *) channel);
window_item_destroy(window, (WI_ITEM_REC *) channel);
if (window->items == NULL && windows->next != NULL &&
(!channel->joined || channel->left) &&
@ -67,7 +67,7 @@ static void signal_channel_destroyed(CHANNEL_REC *channel)
}
}
static void signal_window_item_removed(WINDOW_REC *window, WI_ITEM_REC *item)
static void signal_window_item_destroy(WINDOW_REC *window, WI_ITEM_REC *item)
{
CHANNEL_REC *channel;
@ -294,7 +294,7 @@ void fe_channels_init(void)
signal_add("channel created", (SIGNAL_FUNC) signal_channel_created);
signal_add("channel destroyed", (SIGNAL_FUNC) signal_channel_destroyed);
signal_add_last("window item remove", (SIGNAL_FUNC) signal_window_item_removed);
signal_add_last("window item destroy", (SIGNAL_FUNC) signal_window_item_destroy);
signal_add_last("window item changed", (SIGNAL_FUNC) signal_window_item_changed);
signal_add_last("server disconnected", (SIGNAL_FUNC) sig_disconnected);
@ -314,7 +314,7 @@ void fe_channels_deinit(void)
{
signal_remove("channel created", (SIGNAL_FUNC) signal_channel_created);
signal_remove("channel destroyed", (SIGNAL_FUNC) signal_channel_destroyed);
signal_remove("window item remove", (SIGNAL_FUNC) signal_window_item_removed);
signal_remove("window item destroy", (SIGNAL_FUNC) signal_window_item_destroy);
signal_remove("window item changed", (SIGNAL_FUNC) signal_window_item_changed);
signal_remove("server disconnected", (SIGNAL_FUNC) sig_disconnected);

View File

@ -503,7 +503,7 @@ static int sig_autoremove(void)
return 1;
}
static void sig_window_item_remove(WINDOW_REC *window, WI_ITEM_REC *item)
static void sig_window_item_destroy(WINDOW_REC *window, WI_ITEM_REC *item)
{
LOG_REC *log;
@ -595,7 +595,7 @@ void fe_log_init(void)
command_bind("window log", NULL, (SIGNAL_FUNC) cmd_window_log);
command_bind("window logfile", NULL, (SIGNAL_FUNC) cmd_window_logfile);
signal_add_first("print text stripped", (SIGNAL_FUNC) sig_printtext_stripped);
signal_add("window item remove", (SIGNAL_FUNC) sig_window_item_remove);
signal_add("window item destroy", (SIGNAL_FUNC) sig_window_item_destroy);
signal_add("window refnum changed", (SIGNAL_FUNC) sig_window_refnum_changed);
signal_add("log locked", (SIGNAL_FUNC) sig_log_locked);
signal_add("log create failed", (SIGNAL_FUNC) sig_log_create_failed);
@ -620,7 +620,7 @@ void fe_log_deinit(void)
command_unbind("window log", (SIGNAL_FUNC) cmd_window_log);
command_unbind("window logfile", (SIGNAL_FUNC) cmd_window_logfile);
signal_remove("print text stripped", (SIGNAL_FUNC) sig_printtext_stripped);
signal_remove("window item remove", (SIGNAL_FUNC) sig_window_item_remove);
signal_remove("window item destroy", (SIGNAL_FUNC) sig_window_item_destroy);
signal_remove("window refnum changed", (SIGNAL_FUNC) sig_window_refnum_changed);
signal_remove("log locked", (SIGNAL_FUNC) sig_log_locked);
signal_remove("log create failed", (SIGNAL_FUNC) sig_log_create_failed);

View File

@ -65,7 +65,7 @@ static void signal_query_created_curwin(QUERY_REC *query)
{
g_return_if_fail(query != NULL);
window_add_item(active_win, (WI_ITEM_REC *) query, FALSE);
window_item_add(active_win, (WI_ITEM_REC *) query, FALSE);
}
static void signal_query_destroyed(QUERY_REC *query)
@ -76,7 +76,7 @@ static void signal_query_destroyed(QUERY_REC *query)
window = window_item_window((WI_ITEM_REC *) query);
if (window != NULL) {
window_remove_item(window, (WI_ITEM_REC *) query);
window_item_destroy(window, (WI_ITEM_REC *) query);
if (window->items == NULL && windows->next != NULL &&
!query->unwanted && settings_get_bool("autoclose_windows"))
@ -84,7 +84,7 @@ static void signal_query_destroyed(QUERY_REC *query)
}
}
static void signal_window_item_removed(WINDOW_REC *window, WI_ITEM_REC *item)
static void signal_window_item_destroy(WINDOW_REC *window, WI_ITEM_REC *item)
{
QUERY_REC *query;
@ -289,7 +289,7 @@ void fe_queries_init(void)
signal_add("query created", (SIGNAL_FUNC) signal_query_created);
signal_add("query destroyed", (SIGNAL_FUNC) signal_query_destroyed);
signal_add_last("window item remove", (SIGNAL_FUNC) signal_window_item_removed);
signal_add_last("window item destroy", (SIGNAL_FUNC) signal_window_item_destroy);
signal_add("server connected", (SIGNAL_FUNC) sig_server_connected);
signal_add("window changed", (SIGNAL_FUNC) sig_window_changed);
signal_add_first("message private", (SIGNAL_FUNC) sig_message_private);
@ -308,7 +308,7 @@ void fe_queries_deinit(void)
signal_remove("query created", (SIGNAL_FUNC) signal_query_created);
signal_remove("query destroyed", (SIGNAL_FUNC) signal_query_destroyed);
signal_remove("window item remove", (SIGNAL_FUNC) signal_window_item_removed);
signal_remove("window item destroy", (SIGNAL_FUNC) signal_window_item_destroy);
signal_remove("server connected", (SIGNAL_FUNC) sig_server_connected);
signal_remove("window changed", (SIGNAL_FUNC) sig_window_changed);
signal_remove("message private", (SIGNAL_FUNC) sig_message_private);

View File

@ -74,7 +74,7 @@ WINDOW_REC *window_create(WI_ITEM_REC *item, int automatic)
windows = g_slist_prepend(windows, rec);
signal_emit("window created", 2, rec, GINT_TO_POINTER(automatic));
if (item != NULL) window_add_item(rec, item, automatic);
if (item != NULL) window_item_add(rec, item, automatic);
if (windows->next == NULL || !automatic || settings_get_bool("window_auto_change")) {
if (automatic && windows->next != NULL)
signal_emit("window changed automatic", 1, rec);
@ -113,7 +113,7 @@ void window_destroy(WINDOW_REC *window)
}
while (window->items != NULL)
window_remove_item(window, window->items->data);
window_item_destroy(window, window->items->data);
windows_pack(window->refnum);
@ -276,7 +276,7 @@ WINDOW_REC *window_find_name(const char *name)
return NULL;
}
WINDOW_REC *window_find_item(WINDOW_REC *window, const char *name)
WINDOW_REC *window_find_item(SERVER_REC *server, const char *name)
{
WINDOW_REC *rec;
WI_ITEM_REC *item;
@ -286,10 +286,9 @@ WINDOW_REC *window_find_item(WINDOW_REC *window, const char *name)
rec = window_find_name(name);
if (rec != NULL) return rec;
item = window == NULL ? NULL :
window_item_find(window->active_server, name);
if (item == NULL && (window == NULL ||
window->active_server != NULL)) {
item = server == NULL ? NULL :
window_item_find(server, name);
if (item == NULL && server == NULL) {
/* not found from the active server - any server? */
item = window_item_find(NULL, name);
}
@ -300,8 +299,8 @@ WINDOW_REC *window_find_item(WINDOW_REC *window, const char *name)
/* still nothing? maybe user just left the # in front of
channel, try again with it.. */
chan = g_strdup_printf("#%s", name);
item = window == NULL ? NULL :
window_item_find(window->active_server, chan);
item = server == NULL ? NULL :
window_item_find(server, chan);
if (item == NULL) item = window_item_find(NULL, chan);
g_free(chan);
}

View File

@ -62,7 +62,7 @@ WINDOW_REC *window_find_level(void *server, int level);
WINDOW_REC *window_find_closest(void *server, const char *name, int level);
WINDOW_REC *window_find_refnum(int refnum);
WINDOW_REC *window_find_name(const char *name);
WINDOW_REC *window_find_item(WINDOW_REC *window, const char *name);
WINDOW_REC *window_find_item(SERVER_REC *server, const char *name);
int window_refnum_prev(int refnum, int wrap);
int window_refnum_next(int refnum, int wrap);

View File

@ -127,7 +127,7 @@ static void cmd_window_goto(const char *data)
if (g_strcasecmp(data, "active") == 0)
window = window_highest_activity(active_win);
else
window = window_find_item(active_win, data);
window = window_find_item(active_win->active_server, data);
if (window != NULL)
window_set_active(window);

View File

@ -31,7 +31,7 @@
#include "window-items.h"
#include "printtext.h"
void window_add_item(WINDOW_REC *window, WI_ITEM_REC *item, int automatic)
void window_item_add(WINDOW_REC *window, WI_ITEM_REC *item, int automatic)
{
g_return_if_fail(window != NULL);
g_return_if_fail(item != NULL);
@ -58,7 +58,7 @@ void window_add_item(WINDOW_REC *window, WI_ITEM_REC *item, int automatic)
}
}
void window_remove_item(WINDOW_REC *window, WI_ITEM_REC *item)
void window_item_remove(WINDOW_REC *window, WI_ITEM_REC *item)
{
g_return_if_fail(window != NULL);
g_return_if_fail(item != NULL);
@ -77,6 +77,13 @@ void window_remove_item(WINDOW_REC *window, WI_ITEM_REC *item)
signal_emit("window item remove", 2, window, item);
}
void window_item_destroy(WINDOW_REC *window, WI_ITEM_REC *item)
{
window_item_remove(window, item);
signal_emit("window item destroy", 2, window, item);
}
WINDOW_REC *window_item_window(WI_ITEM_REC *item)
{
g_return_val_if_fail(item != NULL, NULL);
@ -97,32 +104,14 @@ 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);
window_item_remove(window_item_window(item), item);
window_item_add(window, item, FALSE);
}
if (window->active != item) {
@ -299,7 +288,7 @@ void window_item_create(WI_ITEM_REC *item, int automatic)
window = window_create(item, automatic);
} else {
/* use existing window */
window_add_item(window, item, automatic);
window_item_add(window, item, automatic);
}
if (clear_waiting) {

View File

@ -3,10 +3,12 @@
#include "fe-windows.h"
/* Add/remove window item from `window' */
void window_add_item(WINDOW_REC *window, WI_ITEM_REC *item, int automatic);
void window_remove_item(WINDOW_REC *window, WI_ITEM_REC *item);
/* Find a window for `item' and call window_add_item(). */
/* Add/remove/destroy window item from `window' */
void window_item_add(WINDOW_REC *window, WI_ITEM_REC *item, int automatic);
void window_item_remove(WINDOW_REC *window, WI_ITEM_REC *item);
void window_item_destroy(WINDOW_REC *window, WI_ITEM_REC *item);
/* Find a window for `item' and call window_item_add(). */
void window_item_create(WI_ITEM_REC *item, int automatic);
WINDOW_REC *window_item_window(WI_ITEM_REC *item);

View File

@ -588,7 +588,7 @@ static void cmd_window_hide(const char *data)
else if (is_numeric(data, 0))
window = window_find_refnum(atoi(data));
else
window = window_find_item(active_win, data);
window = window_find_item(active_win->active_server, data);
if (window == NULL) return;
if (!is_window_visible(window)) return;
@ -610,7 +610,7 @@ static void cmd_window_show(const char *data)
window = is_numeric(data, 0) ?
window_find_refnum(atoi(data)) :
window_find_item(active_win, data);
window_find_item(active_win->active_server, data);
if (window == NULL) return;
if (is_window_visible(window)) return;

View File

@ -130,7 +130,7 @@ window_find_closest(server, name, level)
#*******************************
MODULE = Irssi PACKAGE = Irssi::Window
MODULE = Irssi PACKAGE = Irssi::Window PREFIX=window_
#*******************************
void
@ -184,13 +184,18 @@ CODE:
signal_emit("send command", 3, cmd, server, item);
void
window_add_item(window, item, automatic)
window_item_add(window, item, automatic)
Irssi::Window window
Irssi::Windowitem item
int automatic
void
window_remove_item(window, item)
window_item_remove(window, item)
Irssi::Window window
Irssi::Windowitem item
void
window_item_destroy(window, item)
Irssi::Window window
Irssi::Windowitem item
@ -240,10 +245,19 @@ window_get_active_name(window)
Irssi::Window window
Irssi::Window
window_find_item(window, name)
Irssi::Window window
window_find_item(server, name)
Irssi::Server server
char *name
Irssi::Windowitem
window_item_find(window, server, name)
Irssi::Window window
Irssi::Server server
char *name
CODE:
RETVAL = window_item_find_window(window, server, name);
OUTPUT:
RETVAL
#*******************************
MODULE = Irssi PACKAGE = Irssi::Windowitem