ui/gtk/text.c

changeset 94
d51e334c1439
parent 90
2019fdbaadfd
child 121
1cc365c34125
equal deleted inserted replaced
93:5223de7979e2 94:d51e334c1439
454 } 454 }
455 } 455 }
456 456
457 457
458 UIWIDGET ui_textfield(UiObject *obj, UiString *value) { 458 UIWIDGET ui_textfield(UiObject *obj, UiString *value) {
459 return ui_textfield_w(obj, 0, value);
460 }
461
462 UIWIDGET ui_textfield_w(UiObject *obj, int width, UiString *value) {
459 GtkWidget *textfield = gtk_entry_new(); 463 GtkWidget *textfield = gtk_entry_new();
464 if(width > 0) {
465 gtk_entry_set_width_chars(GTK_ENTRY(textfield), width);
466 }
467
460 UiContainer *ct = uic_get_current_container(obj); 468 UiContainer *ct = uic_get_current_container(obj);
461 ct->add(ct, textfield, FALSE); 469 ct->add(ct, textfield, FALSE);
462 470
463 if(value) { 471 if(value) {
464 if(value->value) { 472 if(value->value) {
475 483
476 return textfield; 484 return textfield;
477 } 485 }
478 486
479 UIWIDGET ui_textfield_nv(UiObject *obj, char *varname) { 487 UIWIDGET ui_textfield_nv(UiObject *obj, char *varname) {
488 return ui_textfield_wnv(obj, 0, varname);
489 }
490
491 UIWIDGET ui_textfield_wnv(UiObject *obj, int width, char *varname) {
480 UiVar *var = uic_connect_var(obj->ctx, varname, UI_VAR_STRING); 492 UiVar *var = uic_connect_var(obj->ctx, varname, UI_VAR_STRING);
481 if(var) { 493 if(var) {
482 UiString *value = var->value; 494 UiString *value = var->value;
483 return ui_textfield(obj, value); 495 return ui_textfield_w(obj, width, value);
484 } else { 496 } else {
485 // TODO: error 497 // TODO: error
486 } 498 }
487 return NULL; 499 return NULL;
488 } 500 }

mercurial