diff --git a/gtk4/entry.c b/gtk4/entry.c
index 8cd5b42..2cff3ac 100644
--- a/gtk4/entry.c
+++ b/gtk4/entry.c
@@ -23,3 +23,20 @@ GtkWidget ** kc3_gtk4_entry_new (GtkWidget **dest)
*dest = tmp;
return dest;
}
+
+s_str * kc3_gtk4_entry_get_text (GtkEntry **entry, s_str *dest)
+{
+ GtkEntryBuffer *buffer;
+ const char *s;
+ if (! (buffer = gtk_entry_get_buffer(GTK_ENTRY(*entry)))) {
+ err_puts("kc3_gtk4_entry_get_text: gtk_entry_get_buffer");
+ assert(! "kc3_gtk4_entry_get_text: gtk_entry_get_buffer");
+ return NULL;
+ }
+ if (! (s = gtk_entry_buffer_get_text(buffer))) {
+ err_puts("kc3_gtk4_entry_get_text: gtk_entry_buffer_get_text");
+ assert(! "kc3_gtk4_entry_get_text: gtk_entry_buffer_get_text");
+ return NULL;
+ }
+ return str_init_1_alloc(dest, s);
+}
diff --git a/gtk4/text_view.c b/gtk4/text_view.c
index 894b63f..00d9699 100644
--- a/gtk4/text_view.c
+++ b/gtk4/text_view.c
@@ -10,8 +10,32 @@
* AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
* THIS SOFTWARE.
*/
+#include <libkc3/kc3.h>
#include "text_view.h"
+s_str * kc3_gtk4_text_view_get_text (GtkTextView **text_view,
+ s_str *dest)
+{
+ GtkTextBuffer *buffer;
+ GtkTextIter end;
+ char *s;
+ GtkTextIter start;
+ assert(text_view);
+ assert(dest);
+ if (! (buffer = gtk_text_view_get_buffer(*text_view))) {
+ err_puts("kc3_gtk4_text_view_get_text: gtk_text_view_get_buffer");
+ assert(! "kc3_gtk4_text_view_get_text: gtk_text_view_get_buffer");
+ return NULL;
+ }
+ gtk_text_buffer_get_bounds(buffer, &start, &end);
+ if (! (s = gtk_text_buffer_get_text(buffer, &start, &end, false))) {
+ err_puts("kc3_gtk4_text_view_get_text: gtk_text_buffer_get_text");
+ assert(! "kc3_gtk4_text_view_get_text: gtk_text_buffer_get_text");
+ return NULL;
+ }
+ return str_init_1_alloc(dest, s);
+}
+
GtkWidget ** kc3_gtk4_text_view_new (GtkWidget **dest)
{
GtkWidget *tmp;
@@ -30,3 +54,17 @@ GtkWidget ** kc3_gtk4_text_view_new_with_buffer (GtkWidget **dest,
*dest = tmp;
return dest;
}
+
+void kc3_gtk4_text_view_set_text (GtkTextView **text_view,
+ s_str *text)
+{
+ GtkTextBuffer *buffer;
+ assert(text_view);
+ assert(dest);
+ if (! (buffer = gtk_text_view_get_buffer(*text_view))) {
+ err_puts("kc3_gtk4_text_view_set_text: gtk_text_view_get_buffer");
+ assert(! "kc3_gtk4_text_view_set_text: gtk_text_view_get_buffer");
+ return;
+ }
+ gtk_text_buffer_set_text(buffer, text->ptr.pchar, text->size);
+}
diff --git a/gtk4/text_view.h b/gtk4/text_view.h
index 4478aad..1e7eb88 100644
--- a/gtk4/text_view.h
+++ b/gtk4/text_view.h
@@ -20,4 +20,8 @@ GtkWidget ** kc3_gtk4_text_view_new (GtkWidget **dest);
GtkWidget ** kc3_gtk4_text_view_new_with_buffer (GtkWidget **dest,
GtkTextBuffer **tb);
+/* Operators. */
+s_str * kc3_gtk4_text_view_get_text (GtkTextView **text_view,
+ s_str *dest);
+
#endif /* KC3_GTK4_TEXT_VIEW_H */
diff --git a/lib/kc3/0.1/gtk4/text_view.kc3 b/lib/kc3/0.1/gtk4/text_view.kc3
index 50719bb..fc96eef 100644
--- a/lib/kc3/0.1/gtk4/text_view.kc3
+++ b/lib/kc3/0.1/gtk4/text_view.kc3
@@ -5,4 +5,6 @@ defmodule Gtk4.TextView do
def new_with_buffer = cfn Ptr "kc3_gtk4_text_view_new_with_buffer"
(Result, Ptr)
+ def get_text = cfn Str "kc3_gtk4_text_view_get_text" (Ptr, Result)
+
end