summaryrefslogtreecommitdiff
path: root/gi
Commit message (Collapse)AuthorAgeFilesLines
* Bump up the requirement to gobject-introspectionEmmanuele Bassi2023-05-132-10/+0
| | | | | We now require 1.60.0, to unconditionally use the GI_CHECK_VERSION version check macro.
* gi: Replace deprecated FFI closure APIEmmanuele Bassi2023-05-132-0/+34
| | | | | | This is a reimplemented fc776c2058e11da5c3a4cebeea7f313057bc079f with the proper fix for the regression introduced by that commit which required a revert.
* Add inequality comparison to Gdk.{Color,RGBA}Mazhar Hussain2023-03-281-0/+10
| | | | | Otherwise the default implementation of __ne__ (which has wrong behavior) is used instead of inverting the result of __eq__.
* Allow Gdk.{Color,RGBA} instances to be compared with other objectsMazhar Hussain2023-03-281-0/+4
| | | | | | For example, `Gdk.RGBA() == None` should return False instead of raising a TypeError Fixes https://gitlab.gnome.org/GNOME/pygobject/-/issues/414
* Port to Py_TRASHCAN_BEGINChristoph Reiter2023-01-272-2/+10
| | | | | | | | | | | Py_TRASHCAN_SAFE_BEGIN and Py_TRASHCAN_SAFE_END are deprecated since Python 3.11 and result in a deprecation warning when building against Python 3.11. This follows the suggested migration to Py_TRASHCAN_BEGIN and Py_TRASHCAN_END in https://docs.python.org/3/whatsnew/3.11.html Py_TRASHCAN_BEGIN only exists since Python 3.8, while we still support 3.7, so also use the suggested macro to support older Python versions.
* IntrospectionModule: handle two threads loading type at same timeRay Strode2022-10-151-52/+58
| | | | | | | | | | | If two threads are trying to load a type at exactly the same time, it's possible for two wrappers to get generated for the type. One thread will end up with the wrapper that's not blessed as the "real" one and future calls will fail. The blessed wrapper will be incomplete, and so future calls from it will fail as well. This commit adds a lock to ensure the two threads don't stomp on each others toes.
* Revert "pygi: Fix girepository deprecation warnings"Christoph Reiter2022-08-081-14/+0
| | | | | | | This reverts commit fc776c2058e11da5c3a4cebeea7f313057bc079f. This might have caused a regression, see #535. Until we know more revert this for now.
* pygi: Fix girepository deprecation warningsNirbheek Chauhan2022-07-311-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | These functions were deprecated in gobject-introspection 1.72 GI_CHECK_VERSION was added after gobject-introspection 1.58, and we require 1.56. ../gi/pygi-closure.c: In function ‘_pygi_invoke_closure_free’: ../gi/pygi-closure.c:635:5: warning: ‘g_callable_info_free_closure’ is deprecated: Use 'g_callable_info_destroy_closure' instead [-Wdeprecated-declarations] 635 | g_callable_info_free_closure (invoke_closure->info, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from ../gi/pygi-closure.h:22, from ../gi/pygi-closure.c:20: /usr/include/gobject-introspection-1.0/girffi.h:106:15: note: declared here 106 | void g_callable_info_free_closure (GICallableInfo *callable_info, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../gi/pygi-closure.c: In function ‘_pygi_make_native_closure’: ../gi/pygi-closure.c:674:9: warning: ‘g_callable_info_prepare_closure’ is deprecated: Use 'g_callable_info_create_closure' instead [-Wdeprecated-declarations] 674 | g_callable_info_prepare_closure (info, &closure->cif, _pygi_closure_handle, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/gobject-introspection-1.0/girffi.h:100:15: note: declared here 100 | ffi_closure * g_callable_info_prepare_closure (GICallableInfo *callable_info, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* interface: Fix leak when overriding GInterfaceInfoThibault Saunier2022-04-142-3/+10
| | | | | | | | When the interface is being registered by PyGObject and again through an override, the first one is being leaks, free it at this point. We need to copy the GInterfaceInfo to set on the GType QData as we do not own it.
* hashtable: Fix refcount of key/value in error case when marshallingBenjamin Berg2022-03-281-2/+0
| | | | | | | PyList_GET_ITEM only returns a borrowed reference. In the unlikely event of an error converting the key or value, the reference would be unintentionally decremented. This could cause random failures later on (and was indeed causing the PyPy test to fail randomly later on).
* gi: Fix GArray length calculation for other item sizesBenjamin Berg2022-03-282-4/+28
|
* Fix type checkArjan Molenaar2022-03-281-2/+1
| | | | Check for required type, instead of negating invalid type.
* Instead of printing an error, raise an exceptionArjan Molenaar2022-03-281-3/+5
|
* Make warning a crtitical for unknown argument typesArjan Molenaar2022-03-281-1/+1
|
* Check object type before Python objects are createdArjan Molenaar2022-03-281-1/+5
|
* Add extra safeguard in gimoduleArjan Molenaar2022-03-281-1/+5
| | | | Why does a g_instance_init() function only handle GObjects?
* Only create function _construct_target_list for GTK2/3Arjan Molenaar2022-03-271-14/+14
| | | | It's not used in GTK 4.
* Do not override Treeview.enable_model_drag_xx for GTK4Arjan Molenaar2022-03-271-10/+12
| | | | Those methods require a Gdk.ContentFormats object.
* info: Show which type/object callables are bound tobenzea/vfunc-bound-descrBenjamin Berg2022-03-271-0/+28
|
* Gtk.Template: Accept PathLike objects as a filenameAndrej Shadura2022-03-271-1/+2
| | | | | | | | | | | | | An attempt to pass a Path object as a filename results in a TypeError: "Must be bytes, not PosixPath". A simple way to accept Path objects would be unconditionally turning them into strings, but since native paths may be bytes as well, this might break applications relying on being able to bytes-based filename. Instead, convert the path into an appropriate representation (string or bytes) using os.fspath(). It internally tests whether the path is a PathLike object and does the right thing. Signed-off-by: Andrej Shadura <andrew.shadura@collabora.co.uk>
* Call PyEval_InitThreads() with PyPy for Python 3.9Christoph Reiter2022-03-271-1/+2
| | | | | | In theory it should no longer be needed, but PyPy hasn't updated this part of their implementation yet, and not initing threads will lead to crashes due to missing GIL init.
* gimodule: fix floating state of python objects created with g_object_newMathieu Duponchelle2021-12-061-3/+12
| | | | | | | | | | If C code calls g_object_new() for a GInitiallyUnowned subclass implemented in python, the expectation is to receive a floating reference. The solution is used is the same picked for 5efe2e5c8458d9f4d72329ea1209d96b5ebecfb4, this is simply a special case that was omitted at the time.
* Use quark variable for class on gtypeArjan Molenaar2021-09-191-1/+1
|
* replace gpointer by more specific typesArjan Molenaar2021-09-192-6/+4
|
* Do not error out for unknown scopesEmmanuele Bassi2021-09-191-2/+4
| | | | | | If gobject-introspection adds a new scope that we do not handle, we should definitely not error out. Printing out a critical warning and asking to file an issue should be enough.
* Implement DynamicImporter.find_spec()Miro Hrončok2021-09-191-5/+10
| | | | | | | | | | | | | | | | | | | | | | On Python 3.10, the code raised an ImportWarning: ImportWarning: DynamicImporter.find_spec() not found; falling back to find_module() See https://docs.python.org/3.10/whatsnew/3.10.html#deprecated > Starting in this release, there will be a concerted effort to begin cleaning > up old import semantics that were kept for Python 2.7 compatibility. > Specifically, find_loader()/find_module() (superseded by find_spec()), > load_module() (superseded by exec_module()), module_repr() > (which the import system takes care of for you), > the __package__ attribute (superseded by __spec__.parent), > the __loader__ attribute (superseded by __spec__.loader), > and the __cached__ attribute (superseded by __spec__.cached) > will slowly be removed (as well as other classes and methods in importlib). > ImportWarning and/or DeprecationWarning will be raised as appropriate to help > identify code which needs updating during this transition. Fixes https://gitlab.gnome.org/GNOME/pygobject/-/issues/473
* gtk overrides: restore Gtk.ListStore.insert_with_valuesv with newer gtk4Christoph Reiter2021-09-191-1/+8
| | | | | | | | It got renamed in gtk 4.1.0, see https://gitlab.gnome.org/GNOME/gtk/-/commit/a1216599ff6b39bca3e936fbf To avoid an API break and make porting easier provide both versions for all users. Fixes #467
* Fix some small memory leaksDavid King2021-08-232-1/+5
| | | | | | Found by Coverity. https://bugzilla.redhat.com/show_bug.cgi?id=1938851
* Expose GObject.Object.run_dispose()Christoph Reiter2021-04-271-1/+0
| | | | | | | | | | Up until now this raised an exception "This method is currently unsupported.". With Gtk.Widget.destroy() gone in gtk4 and that method often being used to remove references to other objects and breaking cycles this is the next best thing on a lower level and should make porting a bit easier. Fixes #470
* Fix regression in marshalling partial() objectsChristoph Reiter2021-03-302-3/+6
| | | | | | | | | | | | In a4880dbc4575fadc0e3 a special case for partial() was added to handle gtk4 template callbacks. This in turn broken normal usage of partial objects. To work around that add a special marker in the gtk template code for now until we find a better fix. Also adds a test so this doesn't happen again. Fixes #464
* gtk overrides: Add support for builder scopeJean Felder2020-12-063-49/+69
| | | | | | | | | This is a follow of the previous commit which fixes template support in GTK4 by adding GtkBuilerScope. It is extended to support a scope object (it can be a python object or a dictionnary). This scope object is used to define the scope the builder should operate in. A new GtkBuilder constructor is introduced to be able to define this scope object.
* Gtk.Template: Fix template support for GTK4Jean Felder2020-12-062-4/+74
| | | | | | | | | | | | | | | Gtk.Widget.set_connect_func() does not exist anymore and signals are automatically connected. Instead, a GtkBuilderScope needs to be used to create GtkBuilder's closure functions. pygobject closure support is extended to support functools.partial. This is used to create a GtkBuilder closure function with an object different from the current object. See MR https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/1204 and https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/1230 Closes: #380
* gtk: Add override for Gtk.CustomSorter.set_sort_funcJean Felder2020-12-063-16/+39
| | | | | | | | | | This function use CompareDataFunc which works with pointers and doesn't know anything about GObjects. The same logic as in Gio.List.sort and Gio.List.insert_sorted is used. An associated unit_test is also added.
* gtk overrides: Make GTK4 widgets iterableJean Felder2020-11-211-0/+10
| | | | | | | | | | GTK4 removed the Gtk.Container interface, and added API on Gtk.Widget to iterate over children instead. Making Widgets iterable allows to easily loop over the children and check is a widget is a child of an other one. A new test is also added.
* overrides: Remove various overrides for gtk4ebassi/gtk4-overridesChristoph Reiter2020-11-151-246/+172
| | | | | | Basically everything where we hav a transition path that works for both gtk3 and 4. We'll need to add new deprecation warnings for gtk3 once things have settled down.
* Clean up Widget overridesChristoph Reiter2020-11-151-10/+11
|
* tests: various fixes for gtk4Christoph Reiter2020-11-151-4/+7
| | | | skip template/builder tests for now as they require larger changes
* gtk4: Remove overrides for PanedChristoph Reiter2020-11-151-8/+8
| | | | pack1/2 are gone
* flake8 fixesChristoph Reiter2020-11-151-7/+0
|
* Clean up version checks some moreChristoph Reiter2020-11-152-10/+10
|
* Drop the GtkButton override for GTK4Emmanuele Bassi2020-11-151-35/+36
| | | | | We don't need to override anything, once we drop the deprecated compatibility layer for pygtk.
* Add GTK4 override for GtkDialogEmmanuele Bassi2020-11-151-73/+105
| | | | | Drop all the deprecated compatibility layer for pygtk, and the inheritance from GtkContainer.
* Remove Container from GTK4 overridesEmmanuele Bassi2020-11-151-49/+100
| | | | The Container class does not exist any more.
* Simplify the version check for GTK2, GTK3, and GTK4Emmanuele Bassi2020-11-151-9/+12
| | | | Similar to what the Gdk.py overrides do.
* Don't assume Py_TYPE being a macroTomas Hrnciar2020-11-1114-14/+18
| | | | | | Py_TYPE was changed to a function in Python 3.10. Suggested approach is to use Py_SET_TYPE macro instead, see: https://docs.python.org/3.10/whatsnew/3.10.html.
* gtk overrides: Remove Container use for GTK4wip/mschraal/gtk4-container-removalMarinus Schraal2020-10-071-16/+17
|
* Replace PyUnicode_GET_SIZE() usage with PyUnicode_GET_LENGTH()Christoph Reiter2020-10-061-1/+1
| | | | | | | PyUnicode_GET_SIZE() is deprecated and actually wrong in case wchar_t is not 4 bytes and high code points, use PyUnicode_GET_LENGTH() instead. Fixes a deprecation warning with Python 3.9
* Don't call PyEval_InitThreads() with Python 3.9+Christoph Reiter2020-10-061-0/+4
| | | | | | The GIL is now created by Python at initialization time no matter what. PyEval_InitThreads() triggers a deprecation warning and will be removed in 3.10 so don't use it with 3.9+.
* meson: Make the `pycairo` option a featureThibault Saunier2020-06-031-1/+1
| | | | So user have more control on whether to build it or not
* get/set_focus_on_click: Fix return value, add a test and document why the ↵Christoph Reiter2020-04-171-9/+11
| | | | | | | override is there Also make it conditional on the Gtk.Widget method existing since that was only added with gtk 3.20 and we support 3.18+.