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|GtkAppis now derived fromGtk.Application, which replaces the formermain_loopvariable. -
app_nameattribute must be in x.y.z format | Because it is passed toGtk.Applicationas the application id. - Remove
start_loop,start_guiarguments from__init__()| Both are now effectively now assumedTrue, since there isn't really any other way to useGtk.Application. - Rename
run()->run_wrapped()| Becauserun()is already aGtk.Applicationmethod. Userun_wrapped()to gracefully exit on Ctrl+C. - Remove
windowsattribute | Instead of passing all the window classes here, you now create andpresent()windows when needed. - Add
on_activate()method, must be overridden | Create andpresent()the initial window to be shown here. This replaces marking such windows asprimary=True. - Remove
init_gui,load_window,load_window_extract,proto_window| These disappeared with the window lifecycle changes above. - Remove
remove_window()| Equivalent toGtk.Window.close(). - Remove
exit()| Equivalent toGtk.Appplication.quit().
- Remove
-
Window:- Remove
primaryattribute | Initial windows are now created inon_activate(). All windows now keep theGtk.Applicationalive. - Remove
parentvariable,parentargument toinit()| Parent/child windows are now set up using the Gtk functionsset_modal()andset_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 runningGtk.Application. - Remove
pre_exit(),post_exit()| Can be accomplished usingGtk.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 forGtk.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, aGtk.Builder. - Remove
if_widget| Removed along withFakeWidget. - Remove
get_widget_name| Equivalent toGtk.Buildable.get_name().
- Remove
- Remove
ChildWindow| See above on removal ofprimaryattribute. - 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 usingGtk.ListView. - Most of the other deprecations involve
pixmap.py. This is mainly used by theclipartextension for compositing together pixmaps (e.g. to show an icon over an image). This would be better done using widgets (which becomes possible after theGtk.ListViewconversion), 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