Commit b0f87b71a72876a2b64e6c489e470381894c123f

Thomas de Grivel 2024-12-11T14:27:10

wip kmsg

diff --git a/gtk4/paned.c b/gtk4/paned.c
index aab8308..5a3edb6 100644
--- a/gtk4/paned.c
+++ b/gtk4/paned.c
@@ -14,10 +14,11 @@
 #include <libkc3/sym.h>
 #include "paned.h"
 
-GtkWidget ** kc3_gtk4_paned_new (GtkWidget **ptr,
-                                 const s_sym * const *orientation)
+GtkWidget ** kc3_gtk4_paned_new (const s_sym * const *orientation,
+                                 GtkWidget **dest)
 {
   GtkOrientation o;
+  GtkWidget *tmp;
   if (*orientation == sym_1("horizontal"))
     o = GTK_ORIENTATION_HORIZONTAL;
   else if (*orientation == sym_1("vertical"))
@@ -29,7 +30,44 @@ GtkWidget ** kc3_gtk4_paned_new (GtkWidget **ptr,
              " :horizontal or :vertical."));
     return NULL;
   }
-  if (! (*ptr = gtk_paned_new(o)))
+  if (! (tmp = gtk_paned_new(o)))
     return NULL;
-  return ptr;
+  *dest = tmp;
+  return dest;
+}
+
+void kc3_gtk4_paned_set_end_child (GtkPaned **paned,
+                                   GtkWidget **child)
+{
+  gtk_paned_set_end_child(GTK_PANED(*paned), GTK_WIDGET(*child));
+}
+
+void kc3_gtk4_paned_set_resize_end_child (GtkPaned **paned,
+                                            bool value)
+{
+  gtk_paned_set_resize_end_child(GTK_PANED(*paned), value);
+}
+
+void kc3_gtk4_paned_set_shrink_end_child (GtkPaned **paned,
+                                            bool value)
+{
+  gtk_paned_set_shrink_end_child(GTK_PANED(*paned), value);
+}
+
+void kc3_gtk4_paned_set_resize_start_child (GtkPaned **paned,
+                                            bool value)
+{
+  gtk_paned_set_resize_start_child(GTK_PANED(*paned), value);
+}
+
+void kc3_gtk4_paned_set_shrink_start_child (GtkPaned **paned,
+                                            bool value)
+{
+  gtk_paned_set_shrink_start_child(GTK_PANED(*paned), value);
+}
+
+void kc3_gtk4_paned_set_start_child (GtkPaned **paned,
+                                     GtkWidget **child)
+{
+  gtk_paned_set_end_child(GTK_PANED(*paned), GTK_WIDGET(*child));
 }
diff --git a/gtk4/paned.h b/gtk4/paned.h
index e415c6c..82a9a18 100644
--- a/gtk4/paned.h
+++ b/gtk4/paned.h
@@ -16,7 +16,17 @@
 #include "types.h"
 
 /* Heap-allocation functions. */
-GtkWidget ** kc3_gtk4_paned_new (GtkWidget **ptr,
-                                 const s_sym * const *orientation);
+GtkWidget ** kc3_gtk4_paned_new (const s_sym * const *orientation,
+                                 GtkWidget **dest);
+
+/* Operators. */
+void kc3_gtk4_paned_set_end_child (GtkPaned **paned,
+                                   GtkWidget **child);
+void kc3_gtk4_paned_set_resize_start_child (GtkPaned **paned,
+                                            bool value);
+void kc3_gtk4_paned_set_shrink_start_child (GtkPaned **paned,
+                                            bool value);
+void kc3_gtk4_paned_set_start_child (GtkPaned **paned,
+                                     GtkWidget **child);
 
 #endif /* KC3_GTK4_PANED_H */
diff --git a/gtk4/sources.mk b/gtk4/sources.mk
index 79c4c4d..1cff123 100644
--- a/gtk4/sources.mk
+++ b/gtk4/sources.mk
@@ -6,6 +6,7 @@ HEADERS = \
 	"kc3_glib.h" \
 	"kc3_gtk4.h" \
 	"paned.h" \
+	"text.h" \
 	"types.h" \
 	"window.h" \
 
@@ -15,5 +16,6 @@ SOURCES = \
 	"entry_buffer.c" \
 	"kc3_glib.c" \
 	"paned.c" \
+	"text.c" \
 	"window.c" \
 
diff --git a/gtk4/sources.sh b/gtk4/sources.sh
index 7810aa5..d5c36e4 100644
--- a/gtk4/sources.sh
+++ b/gtk4/sources.sh
@@ -1,3 +1,3 @@
 # sources.sh generated by update_sources
-HEADERS='application.h application_window.h entry_buffer.h kc3_glib.h kc3_gtk4.h paned.h types.h window.h '
-SOURCES='application.c application_window.c entry_buffer.c kc3_glib.c paned.c window.c '
+HEADERS='application.h application_window.h entry_buffer.h kc3_glib.h kc3_gtk4.h paned.h text.h types.h window.h '
+SOURCES='application.c application_window.c entry_buffer.c kc3_glib.c paned.c text.c window.c '
diff --git a/gtk4/text.c b/gtk4/text.c
new file mode 100644
index 0000000..9e3744b
--- /dev/null
+++ b/gtk4/text.c
@@ -0,0 +1,37 @@
+/* kc3
+ * Copyright 2022,2023,2024 kmx.io <contact@kmx.io>
+ *
+ * Permission is hereby granted to use this software granted the above
+ * copyright notice and this permission paragraph are included in all
+ * copies and substantial portions of this software.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
+ * PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
+ * AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
+ * THIS SOFTWARE.
+ */
+#include "text.h"
+
+void kc3_gtk4_text_delete (GtkText **text)
+{
+  g_object_unref(G_OBJECT(*text));
+}
+
+GtkWidget ** kc3_gtk4_text_new (GtkWidget **dest)
+{
+  GtkWidget *tmp;
+  if (! (tmp = gtk_text_new()))
+    return NULL;
+  *dest = tmp;
+  return dest;
+}
+
+GtkWidget ** kc3_gtk4_text_new_with_buffer (GtkEntryBuffer **eb,
+                                            GtkWidget **dest)
+{
+  GtkWidget *tmp;
+  if (! (tmp = gtk_text_new_with_buffer(GTK_ENTRY_BUFFER(*eb))))
+    return NULL;
+  *dest = tmp;
+  return dest;
+}
diff --git a/gtk4/text.h b/gtk4/text.h
new file mode 100644
index 0000000..bc27d17
--- /dev/null
+++ b/gtk4/text.h
@@ -0,0 +1,25 @@
+/* kc3
+ * Copyright 2022,2023,2024 kmx.io <contact@kmx.io>
+ *
+ * Permission is hereby granted to use this software granted the above
+ * copyright notice and this permission paragraph are included in all
+ * copies and substantial portions of this software.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
+ * PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
+ * AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
+ * THIS SOFTWARE.
+ */
+#ifndef KC3_GTK4_TEXT_H
+#define KC3_GTK4_TEXT_H
+
+#include "types.h"
+
+/* Heap-allocation functions, call kc3_gtk4_text_delete
+   after use. */
+void         kc3_gtk4_text_delete (GtkText **app);
+GtkWidget ** kc3_gtk4_text_new (GtkWidget **dest);
+GtkWidget ** kc3_gtk4_text_new_with_buffer (GtkEntryBuffer **eb,
+                                            GtkWidget **dest);
+
+#endif /* KC3_GTK4_TEXT_H */
diff --git a/kmsg/kmsg.kc3 b/kmsg/kmsg.kc3
index 355a22b..cd9481d 100755
--- a/kmsg/kmsg.kc3
+++ b/kmsg/kmsg.kc3
@@ -9,6 +9,16 @@ defmodule Kmsg do
     Gtk4.Window.set_title(window, "Kmsg")
     Gtk4.Window.set_default_size(window, (Uw) 1080, (Uw) 720)
     paned = Gtk4.Paned.new(:horizontal)
+    eb1 = Gtk4.EntryBuffer.new("Test 1")
+    text1 = Gtk4.Text.new_with_buffer(eb1)
+    Gtk4.Paned.set_start_child(paned, text1)
+    Gtk4.Paned.set_resize_start_child(paned, true)
+    Gtk4.Paned.set_shrink_start_child(paned, false)
+    eb2 = Gtk4.EntryBuffer.new("Test 2")
+    text2 = Gtk4.Text.new_with_buffer(eb2)
+    Gtk4.Paned.set_end_child(paned, text2)
+    Gtk4.Paned.set_resize_end_child(paned, true)
+    Gtk4.Paned.set_shrink_end_child(paned, false)
     Gtk4.Window.set_child(window, paned)
     Gtk4.Window.present(window)
   }
diff --git a/lib/kc3/0.1/gtk4/entry_buffer.kc3 b/lib/kc3/0.1/gtk4/entry_buffer.kc3
new file mode 100644
index 0000000..3bea451
--- /dev/null
+++ b/lib/kc3/0.1/gtk4/entry_buffer.kc3
@@ -0,0 +1,7 @@
+defmodule Gtk4.EntryBuffer do
+
+  def new = cfn Ptr "kc3_gtk4_entry_buffer_new" (Str, Result)
+
+  def set_text = cfn Void "kc3_gtk4_entry_buffer_set_text" (Ptr, Str)
+
+end
diff --git a/lib/kc3/0.1/gtk4/paned.kc3 b/lib/kc3/0.1/gtk4/paned.kc3
index 2b32c57..ef38578 100644
--- a/lib/kc3/0.1/gtk4/paned.kc3
+++ b/lib/kc3/0.1/gtk4/paned.kc3
@@ -2,6 +2,26 @@ defmodule Gtk4.Paned do
 
   # new(:horizontal)
   # new(:vertical)
-  def new = cfn Ptr "kc3_gtk4_paned_new" (Result, Sym)
+  def new = cfn Ptr "kc3_gtk4_paned_new" (Sym, Result)
+
+  # set_end_child(paned, child)
+  def set_end_child = cfn Void "kc3_gtk4_paned_set_end_child" (Ptr,
+    Ptr)
+
+  def set_resize_end_child =
+    cfn Void "kc3_gtk4_paned_set_resize_end_child" (Ptr, Bool)
+
+  def set_shrink_end_child =
+    cfn Void "kc3_gtk4_paned_set_shrink_end_child" (Ptr, Bool)
+
+  def set_resize_start_child =
+    cfn Void "kc3_gtk4_paned_set_resize_start_child" (Ptr, Bool)
+
+  def set_shrink_start_child =
+    cfn Void "kc3_gtk4_paned_set_shrink_start_child" (Ptr, Bool)
+
+  # set_start_child(paned, child)
+  def set_start_child = cfn Void "kc3_gtk4_paned_set_start_child" (Ptr,
+    Ptr)
 
 end
diff --git a/lib/kc3/0.1/gtk4/text.kc3 b/lib/kc3/0.1/gtk4/text.kc3
new file mode 100644
index 0000000..9110dfe
--- /dev/null
+++ b/lib/kc3/0.1/gtk4/text.kc3
@@ -0,0 +1,8 @@
+defmodule Gtk4.Text do
+
+  def new = cfn Ptr "kc3_gtk4_text_new" (Result)
+
+  def new_with_buffer = cfn Ptr "kc3_gtk4_text_new_with_buffer" (Ptr,
+    Result)
+
+end