Commit 2cc3e8b4aaec5fe2b842d3b7ad461da1783aec1f

Thomas de Grivel 2024-12-12T19:44:21

fix kmsg

diff --git a/gtk4/frame.c b/gtk4/frame.c
index e2ec152..bdec3f5 100644
--- a/gtk4/frame.c
+++ b/gtk4/frame.c
@@ -19,11 +19,16 @@ void kc3_gtk4_frame_delete (GtkFrame **frame)
   g_object_unref(*frame);
 }
 
-GtkWidget ** kc3_gtk4_frame_new (GtkWidget **dest)
+GtkWidget ** kc3_gtk4_frame_new (GtkWidget **dest, const s_str *label)
 {
+  const char *l;
   GtkWidget *tmp;
-  if (! (tmp = gtk_frame_new(NULL)))
+  l = (label && label->size) ? label->ptr.pchar : NULL;
+  if (! (tmp = gtk_frame_new(l))) {
+    err_puts("kc3_gtk4_frame_new: error");
+    assert(! "kc3_gtk4_frame_new: error");
     return NULL;
+  }
   *dest = tmp;
   return dest;
 }
diff --git a/gtk4/frame.h b/gtk4/frame.h
index 99658bb..9abab09 100644
--- a/gtk4/frame.h
+++ b/gtk4/frame.h
@@ -18,7 +18,7 @@
 /* Heap-allocation functions, call kc3_gtk4_frame_delete
    after use. */
 void         kc3_gtk4_frame_delete (GtkFrame **app);
-GtkWidget ** kc3_gtk4_frame_new (GtkWidget **dest);
+GtkWidget ** kc3_gtk4_frame_new (GtkWidget **dest, const s_str *label);
 
 /* Operators. */
 
diff --git a/gtk4/paned.c b/gtk4/paned.c
index 78f8842..b68020f 100644
--- a/gtk4/paned.c
+++ b/gtk4/paned.c
@@ -89,6 +89,6 @@ GtkPaned ** kc3_gtk4_paned_set_shrink_start_child (GtkPaned **paned,
 GtkPaned ** kc3_gtk4_paned_set_start_child (GtkPaned **paned,
                                             GtkWidget **child)
 {
-  gtk_paned_set_end_child(GTK_PANED(*paned), GTK_WIDGET(*child));
+  gtk_paned_set_start_child(GTK_PANED(*paned), GTK_WIDGET(*child));
   return paned;
 }
diff --git a/kmsg/kmsg.kc3 b/kmsg/kmsg.kc3
index 197abd9..fd86f83 100755
--- a/kmsg/kmsg.kc3
+++ b/kmsg/kmsg.kc3
@@ -3,25 +3,31 @@
 defmodule Kmsg do
 
   require Gtk4
+  require Gtk4.Application
+  require Gtk4.ApplicationWindow
+  require Gtk4.Frame
+  require Gtk4.Paned
+  require Gtk4.Widget
+  require Gtk4.Window
 
   def activate = fn (app) {
     window = Gtk4.ApplicationWindow.new(app)
     Gtk4.Window.set_title(window, "Kmsg")
     Gtk4.Window.set_default_size(window, (Uw) 640, (Uw) 480)
     paned = Gtk4.Paned.new(:horizontal)
-    Gtk4.Widget.set_size_request(paned, 200, -1);
+    Gtk4.Widget.set_size_request(paned, 200, 200);
     frame1 = Gtk4.Frame.new("Frame 1")
     Gtk4.Paned.set_start_child(paned, frame1)
     Gtk4.Paned.set_resize_start_child(paned, true)
     Gtk4.Paned.set_shrink_start_child(paned, false)
-    Gtk4.Widget.set_size_request(frame1, 50, -1)
-    frame2 = Gtk4.Frame.new("Frame 2" )
+    Gtk4.Widget.set_size_request(frame1, 50, 50)
+    frame2 = Gtk4.Frame.new("Frame 2")
     Gtk4.Paned.set_end_child(paned, frame2)
     Gtk4.Paned.set_resize_end_child(paned, false)
     Gtk4.Paned.set_shrink_end_child(paned, false)
-    Gtk4.Widget.set_size_request(frame2, 50, -1)
-    Gtk4.Paned.set_position(paned, 192);
+    Gtk4.Widget.set_size_request(frame2, 50, 50)
     Gtk4.Window.set_child(window, paned)
+    Gtk4.Paned.set_position(paned, 240);
     Gtk4.Window.present(window)
   }
 
@@ -33,6 +39,7 @@ defmodule Kmsg do
     status = Gtk4.Application.run(app)
     puts("Kmsg.main: exiting: #{inspect(status)}")
     Gtk4.Application.delete(app)
+    status
   }
 
 end
diff --git a/lib/kc3/0.1/list.kc3 b/lib/kc3/0.1/list.kc3
index 9ae723c..9bd3315 100644
--- a/lib/kc3/0.1/list.kc3
+++ b/lib/kc3/0.1/list.kc3
@@ -32,6 +32,8 @@ defmodule List do
     end
   }
 
+  def first = fn ([a | _]) { a }
+
   def has? = cfn Bool "list_has" (List, Tag, Result)
 
   def join = fn {