Commit graph

5 commits

Author SHA1 Message Date
Jehan
ce776c947d app, menus: progressively move to action group logics. 2023-04-12 22:07:09 +02:00
Jehan
228af9c3c1 app: only update the menu items which changed.
As a further optimization (even though the big slowness situation is
mostly resolved anyway by a previous commit), let's not rebuild whole
submenus when only a few items were added or removed.

1. First make so that the action "visible" property is only notified
   when the visibility actually changes. This way, we can trust that the
   visibility of the item and of the related action are properly synced.
2. Now when an action which is part of a model changes its visibility,
   we trigger the proper "items-changed" only for the added or removed
   item. This replaces the old procedure of removing then adding
   everything (i.e. a full reset).
3. Add some utilities in gimpwidgets-utils (out of gimpmenushell.c).
   This cleans up some code and also fixes some bugs which were
   reimplementing (badly) some code I already implemented (right) in a
   static function.
4. Fix adding new actions in sub-sub… menus. Previous code was only
   showing the direct parent, not up to the root menu (this could happen
   for plug-in procedure items in particular).
2023-04-12 22:07:09 +02:00
Jehan
6bed6e1ef8 app: properly remove action from the application when no longer used.
When an action is removed from a group, we verify if it's not in any group
anymore. If so, we remove it from the GimpApp action map.

This fixes some CRITICALs happening when some actions were dynamically deleted
and re-created, in particular the "windows-display-XXXX" actions.
2023-04-12 22:07:09 +02:00
Jehan
60e80b28da app: fix creating submenus for plug-ins.
This got broken since the new GimpMenuModel implementation.
2023-04-12 22:07:09 +02:00
Jehan
1637dd1cd4 app: new GimpMenuModel object, which is our own implementation of GMenuModel.
Since GAction don't have labels or visibility, it is up to every application to
fill the GMenuModel with such infos. In my previous implementation, I was simply
handling these in GimpMenuShell subclasses (GimpMenu, GimpToolbar and
GimpMenuBar) since we need them for tooltip support (unavailable from GMenu).

Nevertheless there are cases where we want to use GTK API directly with a
GMenuModel, in particular with gtk_application_set_menubar(). This is necessary
to handle the macOS specific code path, where we don't want our usual menu bar.
This OS has its own display of a software menu bar, directly in the desktop GUI.
See !558 for some screenshots of this.

So this commit moves around some code away from GimpMenuShell subclasses into
the new GimpMenuModel class. Now we use this new class instead of simpler GMenu
objects. It handles syncing with GimpAction-s, auto-updating labels, visibility
and sensitivity, as well as adding custom items (plug-in actions, recently
opened files, opened images, etc.).
2023-04-12 22:07:09 +02:00