When running as a Flatpak the "Open with" submenus currently return no items but still appear as an empty menu. This issue occurs on the Collection, Library and Direct pages. This PR fixes that.
This is effectively the same code repeated three times in different classes as virtually the same code appears 3 times in master.
DRYing is therefore possible but is left for a future PR (unless requested here). Most of the extra lines are due to code style improvements. The only change in logic is to return the number of items added to the submenu and set the sensitivity of the corresponding menu-item accordingly.
Extracted from #675 to reduce diff.
When running as a Flatpak the "Open with" submenus currently return no items but still appear as an empty menu. This issue occurs on the Collection, Library and Direct pages. This PR fixes that.
This is effectively the same code repeated three times in different classes as virtually the same code appears 3 times in master.
DRYing is therefore possible but is left for a future PR (unless requested here). Most of the extra lines are due to code style improvements. The only change in logic is to return the number of items added to the submenu and set the sensitivity of the corresponding menu-item accordingly.