Port inkex.gui to GTK4 and trim API

What does the merge request do?

Port inkex.gui to GTK4 and trim API, since much of the custom functionality now has more standard alternatives in GTK.

Implementation notes

API changes (click to expand)
  • GtkApp:
    • Remove main_loop | GtkApp is now derived from Gtk.Application, which replaces the former main_loop variable.
    • app_name attribute must be in x.y.z format | Because it is passed to Gtk.Application as the application id.
    • Remove start_loop, start_gui arguments from __init__() | Both are now effectively now assumed True, since there isn't really any other way to use Gtk.Application.
    • Rename run() -> run_wrapped() | Because run() is already a Gtk.Application method. Use run_wrapped() to gracefully exit on Ctrl+C.
    • Remove windows attribute | Instead of passing all the window classes here, you now create and present() windows when needed.
    • Add on_activate() method, must be overridden | Create and present() the initial window to be shown here. This replaces marking such windows as primary=True.
    • Remove init_gui, load_window, load_window_extract, proto_window | These disappeared with the window lifecycle changes above.
    • Remove remove_window() | Equivalent to Gtk.Window.close().
    • Remove exit() | Equivalent to Gtk.Appplication.quit().
  • Window:
    • Remove primary attribute | Initial windows are now created in on_activate(). All windows now keep the Gtk.Application alive.
    • Remove parent variable, parent argument to init() | Parent/child windows are now set up using the Gtk functions set_modal() and set_transient_for().
    • Remove extract() | Not necessary; you don't need to load a window from a ui file just to extract a widget - you can simply load just that widget.
    • Remove init() | Functionality merged into __init__(), since __init__() is now always called with a running Gtk.Application.
    • Remove pre_exit(), post_exit() | Can be accomplished using Gtk.Window::close-request.
    • Remove replace() | It's not possible to even implement this in GTK4 because of container changes. It has to be done on a per-widget basis.
    • Rename exit() -> close() | Matches the fact this is simply a wrapper for Gtk.Window.close().
    • Remove load_widgets() | Whatever was in here can now be done in __init__() after calling the superclass __init__().
    • Remove dead, args, wid, load_window, load_widgets, destroy | These disappeared with the window lifecycle changes.
    • Rename w_tree -> builder | Since that's what it is, a Gtk.Builder.
    • Remove if_widget | Removed along with FakeWidget.
    • Remove get_widget_name | Equivalent to Gtk.Buildable.get_name().
  • Remove ChildWindow | See above on removal of primary attribute.
  • Remove FakeWidget
  • Remove PROPS, protect()
  • Deprecations are not dealt with, so extensions will spam warnings, and eventually break in GTK5.
  • Many deprecations involve listview.py, which needs reimplementing using Gtk.ListView.
  • Most of the other deprecations involve pixmap.py. This is mainly used by the clipart extension for compositing together pixmaps (e.g. to show an icon over an image). This would be better done using widgets (which becomes possible after the Gtk.ListView conversion), then direct manipulation of pixmaps could disappear.

Summary for release notes

<!-- Non-technical summary. Explain this change for interested users, not developers. -->

Users shouldn't know or care about this, otherwise I have failed!

Checklist

  • Add unit tests (if applicable)
  • Changes to inkex/ are well documented
  • Clean merge request history
Edited by PBS

Merge request reports

Loading