static int mod_hidden(glw_view_eval_context_t *ec, const token_attrib_t *a, struct token *t) { int v = 0; if(t->type == TOKEN_INT) v = t->t_int; else if(t->type == TOKEN_FLOAT) v = t->t_float > 0.5; else if(t->type == TOKEN_VOID) v = 0; else return glw_view_seterr(ec->ei, t, "Invalid assignment for attribute %s", a->name); if(v) glw_hide(ec->w); else glw_unhide(ec->w); return 0; }
static void caption_set_internal(glw_text_bitmap_t *gtb, const char *str, int type) { int len; int flags = 0; if(gtb->gtb_caption && !strcmp(str ?: "", gtb->gtb_caption) && type == gtb->gtb_type) return; free(gtb->gtb_caption); gtb->gtb_caption = strdup(str ?: ""); gtb->gtb_type = type; assert(gtb->gtb_type == 0 || gtb->gtb_type == 1); if(gtb->w.glw_flags2 & GLW2_AUTOHIDE) { if(str == NULL || *str == 0) glw_hide(>b->w); else glw_unhide(>b->w); } if(gtb->gtb_type == PROP_STR_RICH) flags |= TEXT_PARSE_TAGS | TEXT_PARSE_HTML_ENTETIES; free(gtb->gtb_uc_buffer); gtb->gtb_uc_buffer = text_parse(gtb->gtb_caption ?: "", &len, flags, NULL, 0, 0); gtb->gtb_uc_len = gtb->gtb_uc_size = len; if(gtb->w.glw_class == &glw_text) { gtb->gtb_edit_ptr = gtb->gtb_uc_len; gtb->gtb_update_cursor = 1; } gtb_update_epilogue(gtb, GTB_UPDATE_REALIZE); }