1
0
mirror of https://github.com/irssi/irssi.git synced 2024-10-27 05:20:20 -04:00

emit "window item moved" instead of "window item remove" and "window item new" when a window item is moved to another window

git-svn-id: file:///var/www/svn.irssi.org/SVN/irssi/trunk@5012 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Wouter Coekaerts 2009-02-13 18:57:55 +00:00 committed by coekie
parent 859d434c60
commit 4ea8f3141e

View File

@ -32,7 +32,7 @@
#include "window-items.h"
#include "printtext.h"
void window_item_add(WINDOW_REC *window, WI_ITEM_REC *item, int automatic)
static void window_item_add_signal(WINDOW_REC *window, WI_ITEM_REC *item, int automatic, int send_signal)
{
g_return_if_fail(window != NULL);
g_return_if_fail(item != NULL);
@ -52,7 +52,8 @@ void window_item_add(WINDOW_REC *window, WI_ITEM_REC *item, int automatic)
}
window->items = g_slist_append(window->items, item);
signal_emit("window item new", 2, window, item);
if (send_signal)
signal_emit("window item new", 2, window, item);
if (g_slist_length(window->items) == 1 ||
(!automatic && settings_get_bool("autofocus_new_items"))) {
@ -61,7 +62,12 @@ void window_item_add(WINDOW_REC *window, WI_ITEM_REC *item, int automatic)
}
}
void window_item_remove(WI_ITEM_REC *item)
void window_item_add(WINDOW_REC *window, WI_ITEM_REC *item, int automatic)
{
window_item_add_signal(window, item, automatic, TRUE);
}
static void window_item_remove_signal(WI_ITEM_REC *item, int emit_signal)
{
WINDOW_REC *window;
@ -80,7 +86,13 @@ void window_item_remove(WI_ITEM_REC *item)
window->items->data);
}
signal_emit("window item remove", 2, window, item);
if (emit_signal)
signal_emit("window item remove", 2, window, item);
}
void window_item_remove(WI_ITEM_REC *item)
{
window_item_remove_signal(item, TRUE);
}
void window_item_destroy(WI_ITEM_REC *item)
@ -107,12 +119,18 @@ void window_item_change_server(WI_ITEM_REC *item, void *server)
void window_item_set_active(WINDOW_REC *window, WI_ITEM_REC *item)
{
WINDOW_REC *old_window;
g_return_if_fail(window != NULL);
if (item != NULL && window_item_window(item) != window) {
if (item != NULL) {
old_window = window_item_window(item);
if (old_window != window) {
/* move item to different window */
window_item_remove(item);
window_item_add(window, item, FALSE);
window_item_remove_signal(item, FALSE);
window_item_add_signal(window, item, FALSE, FALSE);
signal_emit("window item moved", 3, window, item, old_window);
}
}
if (window->active != item) {