summaryrefslogtreecommitdiff
path: root/src/fe-common
diff options
context:
space:
mode:
Diffstat (limited to 'src/fe-common')
-rw-r--r--src/fe-common/core/fe-channels.c12
-rw-r--r--src/fe-common/core/fe-exec.c41
-rw-r--r--src/fe-common/core/fe-queries.c12
-rw-r--r--src/fe-common/core/window-items.c5
4 files changed, 18 insertions, 52 deletions
diff --git a/src/fe-common/core/fe-channels.c b/src/fe-common/core/fe-channels.c
index e25c3dc8..8e6ec57b 100644
--- a/src/fe-common/core/fe-channels.c
+++ b/src/fe-common/core/fe-channels.c
@@ -74,16 +74,6 @@ static void signal_channel_destroyed(CHANNEL_REC *channel)
window_auto_destroy(window);
}
-static void signal_window_item_destroy(WINDOW_REC *window, WI_ITEM_REC *item)
-{
- CHANNEL_REC *channel;
-
- g_return_if_fail(window != NULL);
-
- channel = CHANNEL(item);
- if (channel != NULL) channel_destroy(channel);
-}
-
static void sig_disconnected(SERVER_REC *server)
{
WINDOW_REC *window;
@@ -576,7 +566,6 @@ 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 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);
@@ -599,7 +588,6 @@ 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 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);
diff --git a/src/fe-common/core/fe-exec.c b/src/fe-common/core/fe-exec.c
index bc8f4691..e0a1b0ca 100644
--- a/src/fe-common/core/fe-exec.c
+++ b/src/fe-common/core/fe-exec.c
@@ -38,6 +38,21 @@
static GSList *processes;
static int signal_exec_input;
+static void exec_wi_destroy(EXEC_WI_REC *rec)
+{
+ g_return_if_fail(rec != NULL);
+
+ if (rec->destroying) return;
+ rec->destroying = TRUE;
+
+ if (window_item_window((WI_ITEM_REC *) rec) != NULL)
+ window_item_destroy((WI_ITEM_REC *) rec);
+
+ MODULE_DATA_DEINIT(rec);
+ g_free(rec->name);
+ g_free(rec);
+}
+
static EXEC_WI_REC *exec_wi_create(WINDOW_REC *window, PROCESS_REC *rec)
{
EXEC_WI_REC *item;
@@ -47,6 +62,7 @@ static EXEC_WI_REC *exec_wi_create(WINDOW_REC *window, PROCESS_REC *rec)
item = g_new0(EXEC_WI_REC, 1);
item->type = module_get_uniq_id_str("WINDOW ITEM TYPE", "EXEC");
+ item->destroy = (void (*) (WI_ITEM_REC *)) exec_wi_destroy;
item->name = rec->name != NULL ?
g_strdup_printf("%%%s", rec->name) :
g_strdup_printf("%%%d", rec->id);
@@ -60,21 +76,6 @@ static EXEC_WI_REC *exec_wi_create(WINDOW_REC *window, PROCESS_REC *rec)
return item;
}
-static void exec_wi_destroy(EXEC_WI_REC *rec)
-{
- g_return_if_fail(rec != NULL);
-
- if (rec->destroying) return;
- rec->destroying = TRUE;
-
- if (window_item_window((WI_ITEM_REC *) rec) != NULL)
- window_item_destroy((WI_ITEM_REC *) rec);
-
- MODULE_DATA_DEINIT(rec);
- g_free(rec->name);
- g_free(rec);
-}
-
static int process_get_new_id(void)
{
PROCESS_REC *rec;
@@ -590,14 +591,6 @@ static void sig_window_destroyed(WINDOW_REC *window)
}
}
-static void sig_window_item_destroyed(WINDOW_REC *window, EXEC_WI_REC *item)
-{
- if (IS_EXEC_WI(item)) {
- item->process->target_item = NULL;
- exec_wi_destroy(item);
- }
-}
-
static void event_text(const char *data, SERVER_REC *server, EXEC_WI_REC *item)
{
if (!IS_EXEC_WI(item)) return;
@@ -616,7 +609,6 @@ void fe_exec_init(void)
signal_add("pidwait", (SIGNAL_FUNC) sig_pidwait);
signal_add("exec input", (SIGNAL_FUNC) sig_exec_input);
signal_add("window destroyed", (SIGNAL_FUNC) sig_window_destroyed);
- signal_add("window item destroy", (SIGNAL_FUNC) sig_window_item_destroyed);
signal_add_first("send text", (SIGNAL_FUNC) event_text);
}
@@ -636,6 +628,5 @@ void fe_exec_deinit(void)
signal_remove("pidwait", (SIGNAL_FUNC) sig_pidwait);
signal_remove("exec input", (SIGNAL_FUNC) sig_exec_input);
signal_remove("window destroyed", (SIGNAL_FUNC) sig_window_destroyed);
- signal_remove("window item destroy", (SIGNAL_FUNC) sig_window_item_destroyed);
signal_remove("send text", (SIGNAL_FUNC) event_text);
}
diff --git a/src/fe-common/core/fe-queries.c b/src/fe-common/core/fe-queries.c
index 4adf4945..dba01817 100644
--- a/src/fe-common/core/fe-queries.c
+++ b/src/fe-common/core/fe-queries.c
@@ -120,16 +120,6 @@ static void signal_window_item_server_changed(WINDOW_REC *window,
}
}
-static void signal_window_item_destroy(WINDOW_REC *window, WI_ITEM_REC *item)
-{
- QUERY_REC *query;
-
- g_return_if_fail(window != NULL);
-
- query = QUERY(item);
- if (query != NULL) query_destroy(query);
-}
-
static void sig_server_connected(SERVER_REC *server)
{
GSList *tmp;
@@ -349,7 +339,6 @@ void fe_queries_init(void)
signal_add("query server changed", (SIGNAL_FUNC) signal_query_server_changed);
signal_add("query nick changed", (SIGNAL_FUNC) signal_query_nick_changed);
signal_add("window item server changed", (SIGNAL_FUNC) signal_window_item_server_changed);
- 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);
@@ -371,7 +360,6 @@ void fe_queries_deinit(void)
signal_remove("query server changed", (SIGNAL_FUNC) signal_query_server_changed);
signal_remove("query nick changed", (SIGNAL_FUNC) signal_query_nick_changed);
signal_remove("window item server changed", (SIGNAL_FUNC) signal_window_item_server_changed);
- 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);
diff --git a/src/fe-common/core/window-items.c b/src/fe-common/core/window-items.c
index d7726521..fef32a5f 100644
--- a/src/fe-common/core/window-items.c
+++ b/src/fe-common/core/window-items.c
@@ -66,7 +66,7 @@ void window_item_remove(WI_ITEM_REC *item)
window = window_item_window(item);
- if (g_slist_find(window->items, item) == NULL)
+ if (window == NULL)
return;
item->window = NULL;
@@ -86,8 +86,7 @@ void window_item_destroy(WI_ITEM_REC *item)
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)