Added menu organization hooks

This commit is contained in:
Kyle J Cardoza 2023-09-20 12:52:01 -04:00
parent 81b59ad0a0
commit a9f33627f1
3 changed files with 29 additions and 0 deletions

View file

@ -1531,6 +1531,18 @@ withRepeatedImage: (NSImage*)image
- (NSString *) proposedTitle: (NSString *)title
forMenuItem: (NSMenuItem *)menuItem;
/**
* Used to determine whether or not the theme handles organizing the app's main
* menu. The default implementation returns NO.
*/
- (BOOL) organizesMainMenu;
/**
* Used by the theme to organize the main menu. The default implementation does
* nothing, because it will never be called.
*/
- (void) organizeMainMenu: (NSMenu *)menu;
@end
@interface GSTheme (OpenSavePanels)

View file

@ -199,5 +199,14 @@
return title;
}
- (BOOL) organizesMainMenu
{
return NO;
}
- (void) organizeMainMenu: (NSMenu *)menu
{
// Do nothing, just return.
}
@end

View file

@ -265,6 +265,8 @@ static BOOL menuBarVisible = YES;
NSString *servicesString = _(@"Services");
int i;
if ([self _isMain])
{
NSString *appTitle;
@ -280,6 +282,12 @@ static BOOL menuBarVisible = YES;
appItem = [self itemWithTitle: appTitle];
appMenu = [appItem submenu];
if ([[GSTheme theme] organizesMainMenu])
{
[[GSTheme theme] organizeMainMenu: self];
return;
}
if (_menu.horizontal == YES)
{
NSMutableArray *itemsToMove;