ui/gtk/text.c

changeset 143
d499b29d7cb6
parent 141
cc2170ea05ad
child 161
b1eac0878ce7
--- a/ui/gtk/text.c	Sat Nov 11 08:34:06 2017 +0100
+++ b/ui/gtk/text.c	Sat Nov 11 11:59:06 2017 +0100
@@ -122,6 +122,12 @@
             value->undomgr = ui_create_undomgr();
         }
         
+        g_signal_connect(
+                buf,
+                "changed",
+                G_CALLBACK(ui_textbuf_changed),
+                uitext);
+        
         // register undo manager
         g_signal_connect(
                 buf,
@@ -132,8 +138,7 @@
                 buf,
                 "delete-range",
                 G_CALLBACK(ui_textbuf_delete),
-                var);
-        
+                var); 
         g_signal_connect(
                 buf,
                 "mark-set",
@@ -263,6 +268,18 @@
 
 
 
+void ui_textbuf_changed(GtkTextBuffer *textbuffer, UiTextArea *textarea) {
+    UiText *value = textarea->var->value;
+    if(value->observers) {
+        UiEvent e;
+        e.obj = textarea->ctx->obj;
+        e.window = e.obj->window;
+        e.document = textarea->ctx->document;
+        e.eventdata = value;
+        e.intval = 0;
+        ui_notify_evt(value->observers, &e);
+    }
+}
 
 // undo manager functions
 
@@ -525,6 +542,12 @@
         value->value.ptr = NULL;
         value->value.free = NULL;
         value->obj = GTK_ENTRY(textfield);
+        
+        g_signal_connect(
+                textfield,
+                "changed",
+                G_CALLBACK(ui_textfield_changed),
+                uitext);
     }
     
     return textfield;
@@ -555,6 +578,19 @@
     free(textfield);
 }
 
+void ui_textfield_changed(GtkEditable *editable, UiTextField *textfield) {
+    UiString *value = textfield->var->value;
+    if(value->observers) {
+        UiEvent e;
+        e.obj = textfield->ctx->obj;
+        e.window = e.obj->window;
+        e.document = textfield->ctx->document;
+        e.eventdata = value;
+        e.intval = 0;
+        ui_notify_evt(value->observers, &e);
+    }
+}
+
 UIWIDGET ui_textfield(UiObject *obj, UiString *value) {
     return create_textfield(obj, 0, FALSE, FALSE, value);
 }

mercurial