Commit 196c5e594d4b3895b3c5a214e680a3ab70347f56

Jeremy JEANNE 2024-12-11T08:36:49

wip signal connect

diff --git a/gtk4/kc3_glib.c b/gtk4/kc3_glib.c
index a1a965a..dca6d85 100644
--- a/gtk4/kc3_glib.c
+++ b/gtk4/kc3_glib.c
@@ -10,6 +10,7 @@
  * AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
  * THIS SOFTWARE.
  */
+#include <libkc3/kc3.h>
 #include "kc3_glib.h"
 
 bool g_kc3_g_main_stop = false;
@@ -25,3 +26,25 @@ void kc3_g_main (void)
   while (! g_kc3_g_main_stop)
     g_main_context_iteration(NULL, TRUE);
 }
+
+void kc3_g_signal_callback (GObject *object, s_callable *callback)
+{
+  s_list *arguments;
+  s_tag tag;
+  if (! (arguments = list_new_ptr(object, NULL)))
+    return;
+  eval_callable_call(callback, arguments, &tag);
+  tag_clean(&tag);
+  list_delete_all(arguments);
+}
+
+void kc3_g_signal_connect (GObject **instance, const s_str *signal,
+			   s_callable *callback)
+{
+  assert(instance);
+  assert(signal);
+  assert(callback);
+  g_signal_connect(*instance, signal->ptr.pchar,
+		   G_CALLBACK(kc3_g_signal_callback),
+		   callback);
+}
diff --git a/gtk4/kc3_glib.h b/gtk4/kc3_glib.h
index 7c38c4b..f39f315 100644
--- a/gtk4/kc3_glib.h
+++ b/gtk4/kc3_glib.h
@@ -19,5 +19,7 @@ extern bool g_kc3_g_main_stop;
 
 void   kc3_g_main (void);
 bool * kc3_g_main_context_iteration (bool *dest);
+void   kc3_g_signal_connect (GObject **instance, const s_str *signal,
+			     s_callable *callback);
 
 #endif /* KC3_GLIB_H */