GNOME Bugzilla – Bug 570793
Make Gtk2::Orientable implementable by Perl subclasses
Last modified: 2021-07-05 12:22:22 UTC
Once support for interface properties has landed in Glib, we can make Gtk2::Orientable implementable. (I'm starting to feel like I'm talking Java with all those "-able"s.) Emmanuel already wrote the _ADD_INTERFACE xsub: =for apidoc __hide__ =cut void _ADD_INTERFACE (class, const char * target_class) CODE: { static const GInterfaceInfo iface_info = { (GInterfaceInitFunc) NULL, (GInterfaceFinalizeFunc) NULL, (gpointer) NULL }; GType gtype = gperl_object_type_from_package (target_class); g_type_add_interface_static (gtype, GTK_TYPE_ORIENTABLE, &iface_info); }
Adding this could make it implementable now, if a class also made its own properties=>[Glib::ParamSpec->boolean('orientation')] Not sure that's to be recommended though, if the glib interface stuff is going to automatically create the interface properties later on. Depends perhaps what the glib stuff is going to do if it finds the property in question already exists. You'd be inclined to make it an error/warning/log/whatever, but I suppose it could quietly assume the subclass knew what it was doing and omit interface properties already in the subclass (and not in a superclass). Would that be a bit painful? One thing it might allow though is the pspec=>,get=>,set=> style property creation dispatching to individual handler funcs instead of GET_PROPERTY/SET_PROPERTY. properties => [ { pspec => Glib::ParamSpec->override ('orientation', Gtk2::Orientable->find_property('orientation')), get => \&_my_orient_get, set => \&_my_orient_set, } ] Bit tedious to write as well as to implement maybe :-).
Another thing that allowing a subclass to add the property itself could do is allow a different default value in the ParamSpec, if you made an "orientation" property which was the same as in Orientable except for the default_value field. Can you claim to be "Orientable" if your default is not the interface pspec default? You'd like to think so, though I expect prefering the "horizontal" per the interface would be clearest most of the time.
GNOME is going to shut down bugzilla.gnome.org in favor of gitlab.gnome.org. As part of that, we are mass-closing older open tickets in bugzilla.gnome.org which have not seen updates for a longer time (resources are unfortunately quite limited so not every ticket can get handled). If you can still reproduce the situation described in this ticket in a recent and supported software version, then please follow https://wiki.gnome.org/GettingInTouch/BugReportingGuidelines and create a new ticket at https://gitlab.gnome.org/GNOME?utf8=%E2%9C%93&filter=perl- Thank you for your understanding and your help.