453 mgr->cur = elm; |
453 mgr->cur = elm; |
454 } |
454 } |
455 } |
455 } |
456 |
456 |
457 |
457 |
458 UIWIDGET ui_textfield(UiObject *obj, UiString *value) { |
458 static UIWIDGET create_textfield(UiObject *obj, int width, UiBool frameless, UiBool password, UiString *value) { |
459 return ui_textfield_w(obj, 0, value); |
|
460 } |
|
461 |
|
462 UIWIDGET ui_textfield_w(UiObject *obj, int width, UiString *value) { |
|
463 GtkWidget *textfield = gtk_entry_new(); |
459 GtkWidget *textfield = gtk_entry_new(); |
464 if(width > 0) { |
460 if(width > 0) { |
465 gtk_entry_set_width_chars(GTK_ENTRY(textfield), width); |
461 gtk_entry_set_width_chars(GTK_ENTRY(textfield), width); |
|
462 } |
|
463 if(frameless) { |
|
464 // TODO: gtk2legacy workaroud |
|
465 gtk_entry_set_has_frame(GTK_ENTRY(textfield), FALSE); |
|
466 } |
|
467 if(password) { |
|
468 gtk_entry_set_visibility(GTK_ENTRY(textfield), FALSE); |
466 } |
469 } |
467 |
470 |
468 UiContainer *ct = uic_get_current_container(obj); |
471 UiContainer *ct = uic_get_current_container(obj); |
469 ct->add(ct, textfield, FALSE); |
472 ct->add(ct, textfield, FALSE); |
470 |
473 |
482 } |
485 } |
483 |
486 |
484 return textfield; |
487 return textfield; |
485 } |
488 } |
486 |
489 |
487 UIWIDGET ui_textfield_nv(UiObject *obj, char *varname) { |
490 static UIWIDGET create_textfield_nv(UiObject *obj, int width, UiBool frameless, UiBool password, char *varname) { |
488 return ui_textfield_wnv(obj, 0, varname); |
|
489 } |
|
490 |
|
491 UIWIDGET ui_textfield_wnv(UiObject *obj, int width, char *varname) { |
|
492 UiVar *var = uic_connect_var(obj->ctx, varname, UI_VAR_STRING); |
491 UiVar *var = uic_connect_var(obj->ctx, varname, UI_VAR_STRING); |
493 if(var) { |
492 if(var) { |
494 UiString *value = var->value; |
493 UiString *value = var->value; |
495 return ui_textfield_w(obj, width, value); |
494 return create_textfield(obj, width, frameless, password, value); |
496 } else { |
495 } else { |
497 // TODO: error |
496 // TODO: error |
498 } |
497 } |
499 return NULL; |
498 return NULL; |
|
499 } |
|
500 |
|
501 UIWIDGET ui_textfield(UiObject *obj, UiString *value) { |
|
502 return create_textfield(obj, 0, FALSE, FALSE, value); |
|
503 } |
|
504 |
|
505 UIWIDGET ui_textfield_w(UiObject *obj, int width, UiString *value) { |
|
506 return create_textfield(obj, width, FALSE, FALSE, value); |
|
507 } |
|
508 |
|
509 UIWIDGET ui_frameless_textfield(UiObject *obj, UiString *value) { |
|
510 return create_textfield(obj, 0, TRUE, FALSE, value); |
|
511 } |
|
512 |
|
513 UIWIDGET ui_passwordfield(UiObject *obj, UiString *value) { |
|
514 return create_textfield(obj, 0, FALSE, TRUE, value); |
|
515 } |
|
516 |
|
517 UIWIDGET ui_passwordfield_w(UiObject *obj, int width, UiString *value) { |
|
518 return create_textfield(obj, width, FALSE, TRUE, value); |
|
519 } |
|
520 |
|
521 UIWIDGET ui_textfield_nv(UiObject *obj, char *varname) { |
|
522 return create_textfield_nv(obj, 0, FALSE, FALSE, varname); |
|
523 } |
|
524 |
|
525 UIWIDGET ui_textfield_wnv(UiObject *obj, int width, char *varname) { |
|
526 return create_textfield_nv(obj, width, FALSE, FALSE, varname); |
|
527 } |
|
528 |
|
529 UIWIDGET ui_frameless_textfield_nv(UiObject *obj, char *varname) { |
|
530 return create_textfield_nv(obj, 0, TRUE, FALSE, varname); |
|
531 } |
|
532 |
|
533 UIWIDGET ui_passwordfield_nv(UiObject *obj, char *varname) { |
|
534 return create_textfield_nv(obj, 0, FALSE, TRUE, varname); |
|
535 } |
|
536 |
|
537 UIWIDGET ui_passwordfield_wnv(UiObject *obj, int width, char *varname) { |
|
538 return create_textfield_nv(obj, width, FALSE, TRUE, varname); |
500 } |
539 } |
501 |
540 |
502 char* ui_textfield_get(UiString *str) { |
541 char* ui_textfield_get(UiString *str) { |
503 if(str->value) { |
542 if(str->value) { |
504 g_free(str->value); |
543 g_free(str->value); |