Avoid deprecation warnings 4: GtkUIManager and GtkAction
Follows !24 (merged).
Fixes #58 (closed), #61 (closed).
This MR replaces GtkUIManager
and GtkAction
with GtkBuilder
and GAction
, hence it also replaces GtkMenu
with GMenu
(all of this by the surrounding use of GtkApplication
and GActionMap
).
There are a few uses left for GtkMenu
(for contextual menus and status bar tooltips), but all the rest has been removed, so that this MR should be a significant step in the transition to GTK+ 4. Note also that GtkToolbar
will have to be replaced at that time.
The first commit is a step that I wanted to keep in the commit history of the MR: the old code has been kept, so that there are two menubars: the old one and the new one. This is handy to compare them in the same window, and it could be useful thereafter, e.g. in case of regression, to be able to build from this commit to retrieve this state.
The second and third commits do the same for the toolbar. The second commit is only kept as a reminder: see !25 (comment 15349) and !25 (comment 15371).
The fourth commit removes the old code and replaces the contextual menus: see !25 (comment 15380). There is no more trace of GtkUIManager
, and no more trace of GtkAction
except in commented code.
The fifth and sixth last commits restore the tooltips display in the status bar: see !25 (comment 15650) and !25 (comment 15864).
There is only one icon left that I wasn't able to recover: I don't know how to apply icons to submenus, either by hand or via the GtkBuilder
XML file. I put a TODO for that, and others for certain perspectives that are beyond the scope of this MR.
Merge request reports
Activity
mentioned in merge request !24 (merged)
added 1 commit
- 6319c41c - Add the new menubar while keeping the old one
mentioned in issue #58 (closed)
- Resolved by Gaël Bonithon
Very nice, you got it to work without XfceGtkActionEntry ! For thunar I failed to go the straight way.
I guess there is not much you can do about the reserved space for checkboxes on the left of each item ?
added 1 commit
- 43ae9888 - Add the new toolbar while keeping the old one
Same as above for the toolbar this time: the two toolbars can be compared in the same window.
One little thing I couldn't reproduce: when the toolbar style is set to "text only" and one clicks on the right to show the hidden items, they only appear as labels, not as menu items (with icons and checkboxes).
Maybe it's due to the fact that
GAction
, unlikeGtkAction
, doesn't handle icons or other "presentational information" (see https://wiki.gnome.org/HowDoI/GAction). So if one sets "text only", one has "text only". Anyway, it's not a big problem I think.Edited by Gaël Bonithonmentioned in issue #61 (closed)
Maybe it wasn't such a good idea to use the gtkbuilder to create the toolbar actually
Unless I miss something, there is no simple way to instantiate multiple toolbars from a single (builder - ui file) pair. But we need one toolbar per window, so the only thing to do seems to instantiate as many builders as windows, that is to add the builder as a window attribute rather than as an application attribute.
But I find it ugly, because the builder is much more naturally an application attribute (from which it is able to instantiate multiple menubars, by the way). So finally, I preferred to create the toolbar by hand, which is easier to master.
That said, I kept the second commit in the MR history, so that we can build from it in the future, because again, I might be missing something here…
Edited by Gaël BonithonHere we are!
This commit removes the old code, and replaces also the contextual menus (tab menu, textview menu, languages menu on the status bar) with their equivalent created from the gtkbuilder.
These are not things easy to compare in the same window, that's why I did not put them in a separate commit. Furthermore, these menus are essentially submenus of the menubar, which has its own commit.
I used GtkMenu here by simplicity, and after all, this is not a deprecated object in GTK+ 3, but this will have to be replaced when switching to GTK+ 4. By the way, the same applies to GtkToolbar.
Edited by Gaël Bonithon