Commit 36790b91 authored by Cedric Roux's avatar Cedric Roux

T: add function label_set_text

parent e5ef3b3e
......@@ -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);
......
......@@ -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 */
......
......@@ -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);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment