foxygit / doom Log in
commit 58978769f5a0da03a35e6cca91be8d9cbea60f3b
Author:     Simon Howard <fraggle@gmail.com>
AuthorDate: Thu Aug 31 18:09:25 2006 +0000
Commit:     Simon Howard <fraggle@gmail.com>
CommitDate: Thu Aug 31 18:09:25 2006 +0000

    Allow multiple callbacks for the same signal on widgets

    Subversion-branch: /trunk/chocolate-doom
    Subversion-revision: 572
---
 textscreen/txt_widget.c | 16 +++-------------
 1 file changed, 3 insertions(+), 13 deletions(-)

diff --git a/textscreen/txt_widget.c b/textscreen/txt_widget.c
index 3ca92c9a..1e2f0734 100644
--- a/textscreen/txt_widget.c
+++ b/textscreen/txt_widget.c
@@ -69,18 +69,6 @@ void TXT_SignalConnect(TXT_UNCAST_ARG(widget),

     table = widget->callback_table;

-    for (i=0; i<table->num_callbacks; ++i)
-    {
-        if (!strcmp(signal_name, table->callbacks[i].signal_name))
-        {
-            // Replace existing signal
-
-            table->callbacks[i].func = func;
-            table->callbacks[i].user_data = user_data;
-            break;
-        }
-    }
-
     // Add a new callback to the table

     table->callbacks
@@ -102,12 +90,14 @@ void TXT_EmitSignal(TXT_UNCAST_ARG(widget), char *signal_name)

     table = widget->callback_table;

+    // Search the table for all callbacks with this name and invoke
+    // the functions.
+
     for (i=0; i<table->num_callbacks; ++i)
     {
         if (!strcmp(table->callbacks[i].signal_name, signal_name))
         {
             table->callbacks[i].func(widget, table->callbacks[i].user_data);
-            break;
         }
     }
 }