GNOME Bugzilla – Bug 786932
Let the "type-func" override the object's "class" attribute when getting the GType
Last modified: 2017-08-30 19:09:56 UTC
When both "class" and "type-func" attributes are present, the parser currently ignores the latter in favour of the former. That's odd because "class" is specified as mandatory in the rnc/rng files [1]. So, by its very nature, the "type-func" attribute should be the preferred way to get the GType when both are present. I think that, depending on the order of the attributes, this was possible before commit 287ba6b94b290. This has consequences for Vala [2]. For GTK+ template classes, the Vala compiler ensures that all [GtkChild] class members in Vala have a matching XML object with the right type. However, it doesn't know about "type-func". So, if only the "type-func" attribute is used, then it will fail to compile because it won't know about the XML object. See vala/codegen/valagtkmodule.vala It seems easier to fix this in GtkBuilder than to teach valac to get the type from the "type-func". But I know little about Vala, so I might be wrong. Chances are pretty high that nobody uses "class" and "type-func" together, because if they did, their "type-func" was being happily ignored so far. So, it will be nice to have this in gtk3 too. [1] The parser doesn't enforce that (bug 786931). [2] https://bugs.webkit.org/show_bug.cgi?id=175937#c16
Created attachment 358612 [details] [review] GtkBuilder: Prefer "type-func" over "class" when looking for the GType
Review of attachment 358612 [details] [review]: Makes sense to me. Thanks for adding tests. Do we have any documentation that needs updating for this change ?
Umm... documentation? Doesn't look like it needs updating. The type-func attribute is mentioned in only two places - the GtkBuilder description and GtkBuilderError:GTK_BUILDER_ERROR_INVALID_TYPE_FUNCTION. Both look fine to me. Thanks for the review.
Comment on attachment 358612 [details] [review] GtkBuilder: Prefer "type-func" over "class" when looking for the GType Pushed to master and gtk-3-22.