July - Gtk4 Migration (Tavmjong)
15 августа 2023 г. 14:16
Toolbar Refactoring
I started the month working on refactoring toolbar code. Toolbars are the long, narrow widgets that contain buttons or other widgets. Gtk3 has special widget classes for toolbars. These special widgets are removed in Gtk4. They were mostly used to auto-generate drop-down menus when a window was shrunk too small to display the entire toolbar. These drop-down menus were often quite useless (and not particularly discoverable).
There are four toolbars in Inkscape:
- The Command toolbar, usually located at the top on narrow screens or the right on wide screens (it the user hasn't set a preference). This toolbar contains buttons for things like creating a new file or cutting and pasting.
- The Tool selector toolbar, on the left, which contains toggle buttons to switch between tools. This was refactored recently to allow the user to customize this toolbar and to allow it to be more than one button wide.
- The Snap toolbar, in the upper right corner or along the right side. This toolbar was recently rewritten to be contained in a popup. Even more recently, an option was added to allow the user to restore a normal snap toolbar to its original position on the right of the window.
- The Tool options toolbar, near the top of the window. This toolbar is actually many toolbars; which toolbar is shown depends on the which tool is active. These toolbars are being rewritten by a Google Summer of Code student to be more useful when the Inkscape window is narrow (and not to use the Gtk::Toolbar class that isn't available in Gtk4).
So it seems that all the toolbars have received or are receiving a lot of recent love, so what did I do? A lot of refactoring! There was a lot of ancient code sitting around that needed cleanup. Some toolbars were still using the removed Gtk classes. At one time all these toolbars shared common code and could be removed around the window or even "torn off", but as each toolbar was refactored, this shared code wasn't applicable any more or was more complicated than necessary. Each of these toolbars were moved from a shared "class" in one file to individual classes and files.
Input Dialog
Another project was removing the Input dialog and related code. This code needed to be modified due to changes in the Gtk API. In the Gtk2 era, one had to use the Input dialog to enable use of Wacom tablets. In the Gtk3 era, Wacom tablets worked out of the box. It took some time to understand the code (overly complicated and poorly documented) well enough to be confident it wasn't actually useful anymore. There was also a hidden hardware tab in the dialog, only enabled through hand-editing the Inkscape preference file. This tab was also not particularily useful (and partially broken because nobody ever used it). In the Gtk4 era, we will probably create a new Input dialog to allow users to link shortcuts to various tablet buttons or sliders, something Gtk4 offers.
Vacation
I was in the US with family at the end of the month and the beginning of August and I spent what little time I had free mostly monitoring and reviewing code written by others.
Items Worked On:
- Toolbar refactoring.
- Input dialog study and removal.
- Removing SPViewWidget and View::View.
- Removing garbage collection of SPDesktop.
- Removing Gtk::EventBox from the command palette, and other cleanup.
- Creating a StatusBar widget and moving code from the DesktopWidget to it.
- Misc. code cleanup.
- Review/testing other merge requests.