From: Rico Tzschichholz Date: Mon, 23 Apr 2018 15:12:03 +0000 (+0200) Subject: codegen: Support automatic properties as GtkChild X-Git-Tag: 0.41.90~161 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ac6758f8f8a73e52fb2bec0fbe7eb3d18fc5a09a;p=thirdparty%2Fvala.git codegen: Support automatic properties as GtkChild https://bugzilla.gnome.org/show_bug.cgi?id=787034 --- diff --git a/codegen/valagtkmodule.vala b/codegen/valagtkmodule.vala index 56c839d8b..bd54f9cd7 100644 --- a/codegen/valagtkmodule.vala +++ b/codegen/valagtkmodule.vala @@ -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); diff --git a/vala/valaproperty.vala b/vala/valaproperty.vala index 81bb84950..1bc54a532 100644 --- a/vala/valaproperty.vala +++ b/vala/valaproperty.vala @@ -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;