diff --git a/common/utils/T/tracer/gui/gui.h b/common/utils/T/tracer/gui/gui.h index 27e6603042fa24d928933031d822609b5115f084..0eebae91ba90ca7b321b921accc47ee0b72a7b18 100644 --- a/common/utils/T/tracer/gui/gui.h +++ b/common/utils/T/tracer/gui/gui.h @@ -39,6 +39,7 @@ widget *new_space(gui *gui, int width, int height); widget *new_image(gui *gui, unsigned char *data, int length); void label_set_clickable(gui *gui, widget *label, int clickable); +void label_set_text(gui *gui, widget *label, char *text); void container_set_child_growable(gui *_gui, widget *_this, widget *child, int growable); diff --git a/common/utils/T/tracer/gui/gui_defs.h b/common/utils/T/tracer/gui/gui_defs.h index ec72bb0e2bb14e8951f8bf7e5d3acda960109de8..938641178c7cd4220e8f329bf479097ae575ab83 100644 --- a/common/utils/T/tracer/gui/gui_defs.h +++ b/common/utils/T/tracer/gui/gui_defs.h @@ -141,7 +141,7 @@ struct button_widget { struct label_widget { struct widget common; - const char *t; + char *t; int color; int width; /* as given by the graphic's backend */ int height; /* as given by the graphic's backend */ diff --git a/common/utils/T/tracer/gui/label.c b/common/utils/T/tracer/gui/label.c index f649fa520147cb1bde0099bd9bab2f1330813423..02efabfaf30d8ce58d62c02d9b7b88063bc836ce 100644 --- a/common/utils/T/tracer/gui/label.c +++ b/common/utils/T/tracer/gui/label.c @@ -81,3 +81,21 @@ void label_set_clickable(gui *_g, widget *_this, int clickable) gunlock(g); } + +void label_set_text(gui *_g, widget *_this, char *text) +{ + struct gui *g = _g; + struct label_widget *this = _this; + + glock(g); + + free(this->t); + this->t = strdup(text); if (this->t == NULL) OOM; + + x_text_get_dimensions(g->x, DEFAULT_FONT, text, + &this->width, &this->height, &this->baseline); + + send_event(g, REPACK, this->common.id); + + gunlock(g); +}