diff options
author | Benjamin Otte <otte@redhat.com> | 2019-11-25 08:06:45 +0100 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2020-05-30 19:26:44 -0400 |
commit | 713a6676ff3789235b7e5ab0d15f9e3376af0972 (patch) | |
tree | 964cd4d0b7210257fe123cbb6b6abc345e026d8e | |
parent | 448a88e4f5dc2117a1e2aa4de5a10abbe57b1587 (diff) | |
download | gtk+-713a6676ff3789235b7e5ab0d15f9e3376af0972.tar.gz |
builder: Allow text content in <lookup>
<lookup>foo</lookup>
is now short for
<lookup>
<constant>foo</constant>
</lookup>
ie it looks up the object with the given name so it can then do a
property lookup with it.
This is the most common operation, so it's a nice shortcut.
-rw-r--r-- | gtk/gtkbuilderparser.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/gtk/gtkbuilderparser.c b/gtk/gtkbuilderparser.c index 28247b0da7..0b98d68ae6 100644 --- a/gtk/gtkbuilderparser.c +++ b/gtk/gtkbuilderparser.c @@ -1961,6 +1961,27 @@ text (GtkBuildableParseContext *context, g_string_append_len (expr_info->constant.text, text, text_len); } + else if (strcmp (gtk_buildable_parse_context_get_element (context), "lookup") == 0) + { + ExpressionInfo *expr_info = (ExpressionInfo *) info; + + while (g_ascii_isspace (*text) && text_len > 0) + { + text++; + text_len--; + } + while (text_len > 0 && g_ascii_isspace (text[text_len - 1])) + text_len--; + if (expr_info->property.expression == NULL && text_len > 0) + { + ExpressionInfo *constant = g_slice_new0 (ExpressionInfo); + constant->tag_type = TAG_EXPRESSION; + constant->expression_type = EXPRESSION_CONSTANT; + constant->constant.type = G_TYPE_INVALID; + constant->constant.text = g_string_new_len (text, text_len); + expr_info->property.expression = constant; + } + } } static void |