ui/gtk/text.c

changeset 143
d499b29d7cb6
parent 141
cc2170ea05ad
child 161
b1eac0878ce7
equal deleted inserted replaced
142:46448d38885c 143:d499b29d7cb6
120 value->obj = buf; 120 value->obj = buf;
121 if(!value->undomgr) { 121 if(!value->undomgr) {
122 value->undomgr = ui_create_undomgr(); 122 value->undomgr = ui_create_undomgr();
123 } 123 }
124 124
125 g_signal_connect(
126 buf,
127 "changed",
128 G_CALLBACK(ui_textbuf_changed),
129 uitext);
130
125 // register undo manager 131 // register undo manager
126 g_signal_connect( 132 g_signal_connect(
127 buf, 133 buf,
128 "insert-text", 134 "insert-text",
129 G_CALLBACK(ui_textbuf_insert), 135 G_CALLBACK(ui_textbuf_insert),
130 var); 136 var);
131 g_signal_connect( 137 g_signal_connect(
132 buf, 138 buf,
133 "delete-range", 139 "delete-range",
134 G_CALLBACK(ui_textbuf_delete), 140 G_CALLBACK(ui_textbuf_delete),
135 var); 141 var);
136
137 g_signal_connect( 142 g_signal_connect(
138 buf, 143 buf,
139 "mark-set", 144 "mark-set",
140 G_CALLBACK(selection_handler), 145 G_CALLBACK(selection_handler),
141 uitext); 146 uitext);
261 gtk_widget_grab_focus(widget); 266 gtk_widget_grab_focus(widget);
262 } 267 }
263 268
264 269
265 270
271 void ui_textbuf_changed(GtkTextBuffer *textbuffer, UiTextArea *textarea) {
272 UiText *value = textarea->var->value;
273 if(value->observers) {
274 UiEvent e;
275 e.obj = textarea->ctx->obj;
276 e.window = e.obj->window;
277 e.document = textarea->ctx->document;
278 e.eventdata = value;
279 e.intval = 0;
280 ui_notify_evt(value->observers, &e);
281 }
282 }
266 283
267 // undo manager functions 284 // undo manager functions
268 285
269 void ui_textbuf_insert( 286 void ui_textbuf_insert(
270 GtkTextBuffer *textbuffer, 287 GtkTextBuffer *textbuffer,
523 value->get = ui_textfield_get; 540 value->get = ui_textfield_get;
524 value->set = ui_textfield_set; 541 value->set = ui_textfield_set;
525 value->value.ptr = NULL; 542 value->value.ptr = NULL;
526 value->value.free = NULL; 543 value->value.free = NULL;
527 value->obj = GTK_ENTRY(textfield); 544 value->obj = GTK_ENTRY(textfield);
545
546 g_signal_connect(
547 textfield,
548 "changed",
549 G_CALLBACK(ui_textfield_changed),
550 uitext);
528 } 551 }
529 552
530 return textfield; 553 return textfield;
531 } 554 }
532 555
553 void ui_textfield_destroy(GtkWidget *object, UiTextField *textfield) { 576 void ui_textfield_destroy(GtkWidget *object, UiTextField *textfield) {
554 ui_destroy_boundvar(textfield->ctx, textfield->var); 577 ui_destroy_boundvar(textfield->ctx, textfield->var);
555 free(textfield); 578 free(textfield);
556 } 579 }
557 580
581 void ui_textfield_changed(GtkEditable *editable, UiTextField *textfield) {
582 UiString *value = textfield->var->value;
583 if(value->observers) {
584 UiEvent e;
585 e.obj = textfield->ctx->obj;
586 e.window = e.obj->window;
587 e.document = textfield->ctx->document;
588 e.eventdata = value;
589 e.intval = 0;
590 ui_notify_evt(value->observers, &e);
591 }
592 }
593
558 UIWIDGET ui_textfield(UiObject *obj, UiString *value) { 594 UIWIDGET ui_textfield(UiObject *obj, UiString *value) {
559 return create_textfield(obj, 0, FALSE, FALSE, value); 595 return create_textfield(obj, 0, FALSE, FALSE, value);
560 } 596 }
561 597
562 UIWIDGET ui_textfield_nv(UiObject *obj, char *varname) { 598 UIWIDGET ui_textfield_nv(UiObject *obj, char *varname) {

mercurial