.mingw-defaults: &mingw-defaults
stage: build_and_test
tags:
- - win32
+ - win32-ps
artifacts:
paths:
- coverage/
+3.36.1 - 2020-05-06
+-------------------
+
+* tests: Fix failing tests with pytest 5.4.0+
+* Gtk: Add override to make sure both TreeModelSort.new_with_model and
+ TreeModel.sort_new_with_model exist independend of the gtk version
+* Gtk.Template: Fix initialisation order errors with Widgets getting created from C
+ (potentially through other templates) :issue:`257` :issue:`386` :issue:`341` :mr:`140` (:user:`Jean Felder <jfelder>`)
+* Gtk.Template: Fix errors when calling init_template() multiple times :mr:`140` (:user:`Jean Felder <jfelder>`)
+
+
3.36.0 - 2020-03-08
-------------------
def init_template(self, cls, base_init_template):
- self.init_template = lambda s: None
+ self.init_template = lambda: None
if self.__class__ is not cls:
raise TypeError(
GObject *object = (GObject *) instance;
PyObject *wrapper, *result;
PyGILState_STATE state;
+ gboolean needs_init = FALSE;
wrapper = g_object_get_qdata(object, pygobject_wrapper_key);
if (wrapper == NULL) {
* will take the ref */
pygobject_ref_float ((PyGObject *) wrapper);
- result = PyObject_CallMethod (wrapper, "__init__", NULL);
+ needs_init = TRUE;
+ }
+
+ /* XXX: used for Gtk.Template */
+ if (PyObject_HasAttrString ((PyObject*) Py_TYPE (wrapper), "__dontuse_ginstance_init__")) {
+ result = PyObject_CallMethod (wrapper, "__dontuse_ginstance_init__", NULL);
if (result == NULL)
PyErr_Print ();
else
Py_DECREF (result);
}
- /* XXX: used for Gtk.Template */
- if (PyObject_HasAttrString ((PyObject*) Py_TYPE (wrapper), "__dontuse_ginstance_init__")) {
- result = PyObject_CallMethod (wrapper, "__dontuse_ginstance_init__", NULL);
+ if (needs_init) {
+ result = PyObject_CallMethod (wrapper, "__init__", NULL);
if (result == NULL)
PyErr_Print ();
else
raise IndexError("could not find tree path '%s'" % key)
return aiter
+ def sort_new_with_model(self):
+ super_object = super(TreeModel, self)
+ if hasattr(super_object, "sort_new_with_model"):
+ return super_object.sort_new_with_model()
+ else:
+ return TreeModelSort.new_with_model(self)
+
def _coerce_path(self, path):
if isinstance(path, Gtk.TreePath):
return path
arg_names=('model',),
category=PyGTKDeprecationWarning)
+ if not hasattr(Gtk.TreeModelSort, "new_with_model"):
+ @classmethod
+ def new_with_model(self, child_model):
+ return TreeModel.sort_new_with_model(child_model)
+
TreeModelSort = override(TreeModelSort)
__all__.append('TreeModelSort')
project('pygobject', 'c',
- version : '3.36.0',
+ version : '3.36.1',
meson_version : '>= 0.46.0',
default_options : [ 'warning_level=1',
'buildtype=debugoptimized'])
from distutils.spawn import find_executable
-PYGOBJECT_VERSION = "3.36.0"
+PYGOBJECT_VERSION = "3.36.1"
GLIB_VERSION_REQUIRED = "2.48.0"
GI_VERSION_REQUIRED = "1.46.0"
PYCAIRO_VERSION_REQUIRED = "1.11.1"
class TestGLib(unittest.TestCase):
- @pytest.mark.xfail(strict=True)
+ @pytest.mark.xfail()
def test_pytest_capture_error_in_closure(self):
# this test is supposed to fail
ml = GLib.MainLoop()
child = child.get_children()[0]
assert isinstance(child, Gtk.Label)
assert child.props.label == "foo"
+
+
+def test_template_hierarchy():
+ testlabel = """
+ <interface>
+ <template class="TestLabel" parent="GtkLabel">
+ </template>
+ </interface>
+ """
+ @Gtk.Template(string=testlabel)
+ class TestLabel(Gtk.Label):
+
+ __gtype_name__ = "TestLabel"
+
+ def __init__(self):
+ super(TestLabel, self).__init__()
+ self.props.label = "TestLabel"
+
+ testbox = """
+ <interface>
+ <template class="TestBox" parent="GtkBox">
+ <child>
+ <object class="TestLabel" id="_testlabel"/>
+ </child>
+ </template>
+ </interface>
+ """
+ @Gtk.Template(string=testbox)
+ class TestBox(Gtk.Box):
+
+ __gtype_name__ = "TestBox"
+
+ _testlabel = Gtk.Template.Child()
+
+ def __init__(self):
+ super(TestBox, self).__init__()
+
+ assert isinstance(self._testlabel, TestLabel)
+
+ window = """
+ <interface>
+ <template class="MyWindow" parent="GtkWindow">
+ <property name="title">"Hellow World"</property>
+ <child>
+ <object class="TestBox" id="_testbox">
+ <child>
+ <object class="TestLabel" id="_testlabel"/>
+ </child>
+ </object>
+ </child>
+ </template>
+ </interface>
+ """
+ @Gtk.Template(string=window)
+ class MyWindow(Gtk.Window):
+
+ __gtype_name__ = "MyWindow"
+
+ _testbox = Gtk.Template.Child()
+ _testlabel = Gtk.Template.Child()
+
+ def __init__(self):
+ super(MyWindow, self).__init__()
+
+ assert isinstance(self._testbox, TestBox)
+ assert isinstance(self._testlabel, TestLabel)
+ assert len(self._testbox.get_children()) == 2
+
+ win = MyWindow()
+ assert isinstance(win, MyWindow)
+
+
+def test_multiple_init_template_calls():
+ xml = """
+ <interface>
+ <template class="MyBox" parent="GtkBox">
+ <child>
+ <object class="GtkLabel" id="_label"/>
+ </child>
+ </template>
+ </interface>
+ """
+ @Gtk.Template(string=xml)
+ class MyBox(Gtk.Box):
+
+ __gtype_name__ = "MyBox"
+
+ _label = Gtk.Template.Child()
+
+ def __init__(self):
+ super(MyBox, self).__init__()
+ self._label.props.label = "awesome label"
+
+ my_box = MyBox()
+ assert isinstance(my_box, MyBox)
+ assert len(my_box.get_children()) == 1
+
+ my_box.init_template()
+ assert isinstance(my_box, MyBox)
+ assert len(my_box.get_children()) == 1
@ignore_gi_deprecation_warnings
@unittest.skipUnless(Gtk, 'Gtk not available')
class TestTreeModel(unittest.TestCase):
+
+ def test_tree_model_sort_new_with_model_old(self):
+ # https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/1134
+ model = Gtk.TreeStore(int)
+ sort_model = model.sort_new_with_model()
+ assert isinstance(sort_model, Gtk.TreeModelSort)
+ assert sort_model.get_model() == model
+
+ def test_tree_model_sort_new_with_model_new(self):
+ # https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/1134
+ model = Gtk.TreeStore(int)
+ sort_model = Gtk.TreeModelSort.new_with_model(child_model=model)
+ assert isinstance(sort_model, Gtk.TreeModelSort)
+ assert sort_model.get_model() == model
+
def test_tree_model_sort(self):
self.assertEqual(Gtk.TreeModelSort, gi.overrides.Gtk.TreeModelSort)
model = Gtk.TreeStore(int, bool)