Index: vapigen/valagidlparser.vala =================================================================== --- vapigen/valagidlparser.vala (revision 602) +++ vapigen/valagidlparser.vala (working copy) @@ -148,11 +148,30 @@ } else if (ns.name == "GLib" && type_name.has_prefix ("G")) { return type_name.offset (1); } else { + + var attributes = get_attributes (type_name); + if (attributes != null) { + foreach (string attr in attributes) { + var nv = attr.split ("=", 2); + if (nv[0] == "name") { + return eval(nv[1]); + } + } + } + + string best_match = null; + foreach (string name in ns.get_cprefixes ()) { if (type_name.has_prefix (name)) { - return type_name.offset (name.len ()); + if (best_match == null || name.len() > best_match.len()) + best_match = name; } } + + if (best_match != null) + { + return type_name.offset (best_match.len ());; + } } return type_name;