[PATCH] New gtk_signal_emitv() function




I don't have CVS access set up at the moment, and would appreciate it if
someone could please apply this to Gtk-1.0.1? It is a guaranteed (well...)
harmless patch that adds a public interface, gtk_signal_emitv(), designed
to let interpreters invoke arbitrary signals with arbitrary arguments.

E.g., this is required to let Perl/Gtk emit a signal just by saying: 

   signal_emit $object "some_signal", "arg1", $arg2+2, 4.0, $a_widget;


--- gtk+-1.0.1/gtk/gtksignal.h.save	Fri May  8 00:23:09 1998
+++ gtk+-1.0.1/gtk/gtksignal.h	Fri May  8 00:26:29 1998
@@ -84,6 +84,9 @@
 void   gtk_signal_emit_by_name		  (GtkObject	       *object,
 					   const gchar	       *name,
 					   ...);
+void   gtk_signal_emitv			  (GtkObject	       *object,
+					   guint		signal_id,
+					   GtkArg	       *args);
 void   gtk_signal_emit_stop		  (GtkObject	       *object,
 					   guint		signal_id);
 void   gtk_signal_emit_stop_by_name	  (GtkObject	       *object,
--- gtk+-1.0.1/gtk/gtksignal.c.save	Fri May  8 00:23:05 1998
+++ gtk+-1.0.1/gtk/gtksignal.c	Fri May  8 00:54:19 1998
@@ -104,7 +104,8 @@
 						GtkHandler    *handler);
 static void         gtk_signal_real_emit       (GtkObject     *object,
 						guint          signal_type,
-						va_list        args);
+						GtkArg        *params,
+						va_list        va_args);
 static GtkHandler*  gtk_signal_get_handlers    (GtkObject     *object,
 						guint          signal_type);
 static guint        gtk_signal_connect_by_type (GtkObject     *object,
@@ -349,7 +350,7 @@
   
   va_start (args, signal_id);
   
-  gtk_signal_real_emit (object, signal_id, args);
+  gtk_signal_real_emit (object, signal_id, NULL, args);
   
   va_end (args);
 }
@@ -374,7 +375,7 @@
     {
       va_start (args, name);
       
-      gtk_signal_real_emit (object, type, args);
+      gtk_signal_real_emit (object, type, NULL, args);
       
       va_end (args);
     }
@@ -386,6 +387,20 @@
 }
 
 void
+gtk_signal_emitv (GtkObject *object,
+		  guint       signal_id,
+		  GtkArg     *args)
+{
+  g_return_if_fail (object != NULL);
+  g_return_if_fail (signal_id >= 1);
+  
+  if (initialize)
+    gtk_signal_init ();
+  
+  gtk_signal_real_emit (object, signal_id, args, NULL);
+}
+
+void
 gtk_signal_emit_stop (GtkObject *object,
 		      guint       signal_id)
 {
@@ -1030,13 +1045,14 @@
 static void
 gtk_signal_real_emit (GtkObject *object,
 		      guint      signal_type,
-		      va_list    args)
+		      GtkArg    *params,
+		      va_list    va_args)
 {
   GtkSignal *signal;
   GtkHandler *handlers;
   GtkHandlerInfo info;
   guchar **signal_func_offset;
-  GtkArg         params[MAX_PARAMS];
+  GtkArg         gtk_args[MAX_PARAMS];
   
   signal = g_hash_table_lookup (signal_hash_table, &signal_type);
   g_return_if_fail (signal != NULL);
@@ -1050,8 +1066,12 @@
       return;
     }
   
-  gtk_params_get (params, signal->nparams, signal->params,
-		  signal->return_val, args);
+  if (!params)
+    {
+      gtk_params_get (gtk_args, signal->nparams, signal->params,
+		      signal->return_val, va_args);
+      params = gtk_args;
+    }
   
   gtk_emission_add (&current_emissions, object, signal_type);
   


-- 
Kenneth Albanowski (kjahds@kjahds.com, CIS: 70705,126)




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]