Overriding base class interface methods requires explicitly re-inheriting from the interface
Submitted by Dimitri Tcaciuc
Link to original bug (#566571)
Description
Please describe the problem: The bug manifests itself when trying to load custom class using gtk.Builder from a definition file.
In my case, the custom class is derived from gtk.Dialog, which already implements gtk.Buildable. I need to detect when the parsing is done, so I'm overriding the gtk.Buildable.parser_finished() method like so:
class MyDialog(gtk.Dialog):
__gtype_name__ = "MyDialog"
def do_parser_finished(self, builder):
print "Parser finished"
However, the method is never called. It -is- called, however, if I directly re-inherit from gtk.Buildable interface:
class MyDialog(gtk.Dialog, gtk.Buildable):
Steps to reproduce: 2. Override do_parser_finished(self, builder) method
- Inherit from a class which already inherits from gtk.Buildable interface
- Declare an instance of that class in a gtk.Builder XML file.
- Load the XML file with gtk.Builder.add_from_file()
Actual results: At the end of add_from_file() method call, the do_parser_finished() should be invoked to indicate the end of parsing, however it doesn't.
Expected results: From what I've been told to on IRC discussion, dynamic override finder should notice when we derive from a class implementing gtk.Buildable and should not require inheriting it second time.
Does this happen every time? To my knowledge, yes
Other information: The test driver code:
builder = gtk.Builder()
builder.add_from_file("test.glade")
dialog = builder.get_object("mydialog-instance")
Test XML file:
<?xml version="1.0"?>
<interface>
<!-- interface-naming-policy project-wide -->
<object class="MyDialog" id="mydialog-instance">
<property name="border_width">5</property>
<property name="type_hint">normal</property>
<property name="has_separator">False</property>
<child internal-child="vbox">
<object class="GtkVBox" id="dialog-vbox1">
<property name="visible">True</property>
<property name="spacing">2</property>
<child>
<placeholder/>
</child>
<child internal-child="action_area">
<object class="GtkHButtonBox" id="dialog-action_area1">
<property name="visible">True</property>
<property name="layout_style">end</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
</object>
</child>
</object>
</interface>