[gtk/wip/otte/listview: 25/158] builder: Allow text content in <lookup>



commit 50ee1042fb1c1d0420041c4a436f5eabc4f9acff
Author: Benjamin Otte <otte redhat com>
Date:   Mon Nov 25 08:06:45 2019 +0100

    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.

 gtk/gtkbuilderparser.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
---
diff --git a/gtk/gtkbuilderparser.c b/gtk/gtkbuilderparser.c
index 0ed54c6b74..1462231549 100644
--- a/gtk/gtkbuilderparser.c
+++ b/gtk/gtkbuilderparser.c
@@ -1929,6 +1929,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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]