Revision: 15119 http://sourceforge.net/p/skim-app/code/15119 Author: hofman Date: 2025-04-12 15:53:57 +0000 (Sat, 12 Apr 2025) Log Message: ----------- Enable/disable subitems of toolbar items. Only validate toolbar items in lable only mode when they bhave no submenu
Modified Paths: -------------- trunk/SKMainToolbarController.m Modified: trunk/SKMainToolbarController.m =================================================================== --- trunk/SKMainToolbarController.m 2025-04-12 15:37:55 UTC (rev 15118) +++ trunk/SKMainToolbarController.m 2025-04-12 15:53:57 UTC (rev 15119) @@ -129,8 +129,10 @@ - (void)validateVisibleItems { [super validateVisibleItems]; if ([self displayMode] == NSToolbarDisplayModeLabelOnly && [[self delegate] respondsToSelector:@selector(validateToolbarItem:)]) { - for (NSToolbarItem *item in [self visibleItems]) - [item setEnabled:[(id)[self delegate] validateToolbarItem:item]]; + for (NSToolbarItem *item in [self visibleItems]) { + if ([[item menuFormRepresentation] hasSubmenu] == NO) + [item setEnabled:[(id)[self delegate] validateToolbarItem:item]]; + } } } @@ -221,8 +223,10 @@ [item1 setLabels:NSLocalizedString(@"Previous", @"Toolbar item label")]; menuItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Previous", @"Toolbar item label") action:@selector(doGoToPreviousPage:) target:mainController]; [item1 setMenuFormRepresentation:menuItem]; + [item1 setEnabled:[mainController.pdfView canGoToPreviousPage]]; NSToolbarItem *item2 = [[NSToolbarItem alloc] initWithItemIdentifier:@""]; [item2 setLabels:NSLocalizedString(@"Next", @"Toolbar item label")]; + [item2 setEnabled:[mainController.pdfView canGoToNextPage]]; [(NSToolbarItemGroup *)item setSubitems:@[item1, item2]]; menuItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Next", @"Toolbar item label") action:@selector(doGoToNextPage:) target:mainController]; [item2 setMenuFormRepresentation:menuItem]; @@ -295,10 +299,12 @@ [item1 setLabels:NSLocalizedString(@"Back", @"Toolbar item label")]; menuItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Back", @"Menu item title") action:@selector(doGoBack:) target:mainController]; [item1 setMenuFormRepresentation:menuItem]; + [item1 setEnabled:[mainController.pdfView canGoBack]]; NSToolbarItem *item2 = [[NSToolbarItem alloc] initWithItemIdentifier:@""]; [item2 setLabels:NSLocalizedString(@"Forward", @"Toolbar item label")]; menuItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Forward", @"Menu item title") action:@selector(doGoForward:) target:mainController]; [item2 setMenuFormRepresentation:menuItem]; + [item2 setEnabled:[mainController.pdfView canGoForward]]; [(NSToolbarItemGroup *)item setSubitems:@[item1, item2]]; } else if ([identifier isEqualToString:SKDocumentToolbarPageNumberItemIdentifier]) { @@ -1354,6 +1360,9 @@ - (void)handleChangedHistoryNotification:(NSNotification *)notification { [backForwardButton setEnabled:[mainController.pdfView canGoBack] forSegment:0]; [backForwardButton setEnabled:[mainController.pdfView canGoForward] forSegment:1]; + NSArray *subitems = [(NSToolbarItemGroup *)[toolbarItems objectForKey:SKDocumentToolbarBackForwardItemIdentifier] subitems]; + [[subitems objectAtIndex:0] setEnabled:[mainController.pdfView canGoBack]]; + [[subitems objectAtIndex:1] setEnabled:[mainController.pdfView canGoToFirstPage]]; } - (void)handlePageChangedNotification:(NSNotification *)notification { @@ -1367,6 +1376,9 @@ [previousNextFirstLastPageButton setEnabled:[mainController.pdfView canGoToPreviousPage] forSegment:1]; [previousNextFirstLastPageButton setEnabled:[mainController.pdfView canGoToNextPage] forSegment:2]; [previousNextFirstLastPageButton setEnabled:[mainController.pdfView canGoToLastPage] forSegment:3]; + NSArray *subitems = [(NSToolbarItemGroup *)[toolbarItems objectForKey:SKDocumentToolbarPreviousNextItemIdentifier] subitems]; + [[subitems objectAtIndex:0] setEnabled:[mainController.pdfView canGoToPreviousPage]]; + [[subitems objectAtIndex:1] setEnabled:[mainController.pdfView canGoToNextPage]]; } - (void)handleScaleChangedNotification:(NSNotification *)notification { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. _______________________________________________ Skim-app-commit mailing list Skim-app-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/skim-app-commit