From 4ea8f3141eaf162838ba2b602e81cf8c5ac7d258 Mon Sep 17 00:00:00 2001 From: Wouter Coekaerts Date: Fri, 13 Feb 2009 18:57:55 +0000 Subject: [PATCH] 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 --- src/fe-common/core/window-items.c | 32 ++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/src/fe-common/core/window-items.c b/src/fe-common/core/window-items.c index 3c80b466..26fae34f 100644 --- a/src/fe-common/core/window-items.c +++ b/src/fe-common/core/window-items.c @@ -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) {