]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Support automatic properties as GtkChild
authorRico Tzschichholz <ricotz@ubuntu.com>
Mon, 23 Apr 2018 15:12:03 +0000 (17:12 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Mon, 23 Apr 2018 17:19:33 +0000 (19:19 +0200)
https://bugzilla.gnome.org/show_bug.cgi?id=787034

codegen/valagtkmodule.vala
vala/valaproperty.vala

index 56c839d8b5d5b0d9c15334f1ed25fc8eb5160154..bd54f9cd70abdff1c4a6fe86242a29b5a88d526b 100644 (file)
@@ -259,8 +259,8 @@ public class Vala.GtkModule : GSignalModule {
        }
 
        public override void visit_property (Property prop) {
-               if (prop.get_attribute ("GtkChild") != null) {
-                       Report.error (prop.source_reference, "Annotating properties with [GtkChild] is not yet supported");
+               if (prop.get_attribute ("GtkChild") != null && prop.field == null) {
+                       Report.error (prop.source_reference, "[GtkChild] is only allowed on automatic properties");
                }
 
                base.visit_property (prop);
index 81bb84950788ce02e36cd1365c61afd3060cce59..1bc54a5325bd0e24934991b32f46dd7ed0e69fa8 100644 (file)
@@ -118,6 +118,11 @@ public class Vala.Property : Symbol, Lockable {
                                                _field = new Field ("_%s".printf (name), property_type.copy (), initializer, source_reference);
                                                _field.access = SymbolAccessibility.PRIVATE;
                                                _field.binding = binding;
+                                               // apply gtk-child attribute to backing field for gtk-template support
+                                               if (get_attribute ("GtkChild") != null) {
+                                                       _field.set_attribute_string ("GtkChild", "name", get_attribute_string ("GtkChild", "name", name));
+                                                       _field.set_attribute_bool ("GtkChild", "internal", get_attribute_bool ("GtkChild", "internal"));
+                                               }
                                        }
                                }
                                _field_checked = true;