shithub: choc

Download patch

ref: 58978769f5a0da03a35e6cca91be8d9cbea60f3b
parent: e9376daee45b53ec5a027244c3561fdbd6818fe6
author: Simon Howard <fraggle@gmail.com>
date: Thu Aug 31 14:09:25 EDT 2006

Allow multiple callbacks for the same signal on widgets

Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 572

--- a/textscreen/txt_widget.c
+++ b/textscreen/txt_widget.c
@@ -69,18 +69,6 @@
 
     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 @@
 
     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;
         }
     }
 }