From 15db7e42d6ab0f019749d89a8463568c4c0a6940 Mon Sep 17 00:00:00 2001 From: "pinkerton%netscape.com" Date: Tue, 30 Apr 2002 14:58:16 +0000 Subject: [PATCH] Indent entries in the folder popup to reflect the hierarchy. from Richard Schreyer (richards9@mac.com) git-svn-id: svn://10.0.0.236/trunk@120301 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/camino/BookmarksService.mm | 15 ++++++++++----- mozilla/camino/src/bookmarks/BookmarksService.mm | 15 ++++++++++----- mozilla/chimera/BookmarksService.mm | 15 ++++++++++----- mozilla/chimera/src/bookmarks/BookmarksService.mm | 15 ++++++++++----- 4 files changed, 40 insertions(+), 20 deletions(-) diff --git a/mozilla/camino/BookmarksService.mm b/mozilla/camino/BookmarksService.mm index 96554b5f810..27db93d6c64 100644 --- a/mozilla/camino/BookmarksService.mm +++ b/mozilla/camino/BookmarksService.mm @@ -814,7 +814,7 @@ void BookmarksService::EnsureToolbarRoot() } static -void RecursiveAddBookmarkConstruct(NSPopUpButton* aPopup, NSMenu* aMenu, int aTagToMatch) +void RecursiveAddBookmarkConstruct(NSPopUpButton* aPopup, NSMenu* aMenu, int aTagToMatch, int depth = 0) { // Get the menu item children. NSArray* children = [aMenu itemArray]; @@ -823,18 +823,23 @@ void RecursiveAddBookmarkConstruct(NSPopUpButton* aPopup, NSMenu* aMenu, int aTa startPosition = 3; int count = [children count]; - for (int i = startPosition; i < count; i++) { + for (int i = startPosition; i < count; ++i) { NSMenuItem* menuItem = [children objectAtIndex: i]; NSMenu* submenu = [menuItem submenu]; if (submenu) { - // This is a folder. Add it to our list and then recur. - [aPopup addItemWithTitle: [menuItem title]]; + // This is a folder. Add it to our list and then recur. Indent it + // the apropriate depth for readability in the menu. + NSMutableString *title = [NSMutableString stringWithString:[menuItem title]]; + for (int j = 0; j <= depth; ++j) + [title insertString:@" " atIndex: 0]; + + [aPopup addItemWithTitle: title]; NSMenuItem* lastItem = [aPopup lastItem]; if ([menuItem tag] == aTagToMatch) [aPopup selectItem: lastItem]; [lastItem setTag: [menuItem tag]]; - RecursiveAddBookmarkConstruct(aPopup, submenu, aTagToMatch); + RecursiveAddBookmarkConstruct(aPopup, submenu, aTagToMatch, depth+1); } } } diff --git a/mozilla/camino/src/bookmarks/BookmarksService.mm b/mozilla/camino/src/bookmarks/BookmarksService.mm index 96554b5f810..27db93d6c64 100644 --- a/mozilla/camino/src/bookmarks/BookmarksService.mm +++ b/mozilla/camino/src/bookmarks/BookmarksService.mm @@ -814,7 +814,7 @@ void BookmarksService::EnsureToolbarRoot() } static -void RecursiveAddBookmarkConstruct(NSPopUpButton* aPopup, NSMenu* aMenu, int aTagToMatch) +void RecursiveAddBookmarkConstruct(NSPopUpButton* aPopup, NSMenu* aMenu, int aTagToMatch, int depth = 0) { // Get the menu item children. NSArray* children = [aMenu itemArray]; @@ -823,18 +823,23 @@ void RecursiveAddBookmarkConstruct(NSPopUpButton* aPopup, NSMenu* aMenu, int aTa startPosition = 3; int count = [children count]; - for (int i = startPosition; i < count; i++) { + for (int i = startPosition; i < count; ++i) { NSMenuItem* menuItem = [children objectAtIndex: i]; NSMenu* submenu = [menuItem submenu]; if (submenu) { - // This is a folder. Add it to our list and then recur. - [aPopup addItemWithTitle: [menuItem title]]; + // This is a folder. Add it to our list and then recur. Indent it + // the apropriate depth for readability in the menu. + NSMutableString *title = [NSMutableString stringWithString:[menuItem title]]; + for (int j = 0; j <= depth; ++j) + [title insertString:@" " atIndex: 0]; + + [aPopup addItemWithTitle: title]; NSMenuItem* lastItem = [aPopup lastItem]; if ([menuItem tag] == aTagToMatch) [aPopup selectItem: lastItem]; [lastItem setTag: [menuItem tag]]; - RecursiveAddBookmarkConstruct(aPopup, submenu, aTagToMatch); + RecursiveAddBookmarkConstruct(aPopup, submenu, aTagToMatch, depth+1); } } } diff --git a/mozilla/chimera/BookmarksService.mm b/mozilla/chimera/BookmarksService.mm index 96554b5f810..27db93d6c64 100644 --- a/mozilla/chimera/BookmarksService.mm +++ b/mozilla/chimera/BookmarksService.mm @@ -814,7 +814,7 @@ void BookmarksService::EnsureToolbarRoot() } static -void RecursiveAddBookmarkConstruct(NSPopUpButton* aPopup, NSMenu* aMenu, int aTagToMatch) +void RecursiveAddBookmarkConstruct(NSPopUpButton* aPopup, NSMenu* aMenu, int aTagToMatch, int depth = 0) { // Get the menu item children. NSArray* children = [aMenu itemArray]; @@ -823,18 +823,23 @@ void RecursiveAddBookmarkConstruct(NSPopUpButton* aPopup, NSMenu* aMenu, int aTa startPosition = 3; int count = [children count]; - for (int i = startPosition; i < count; i++) { + for (int i = startPosition; i < count; ++i) { NSMenuItem* menuItem = [children objectAtIndex: i]; NSMenu* submenu = [menuItem submenu]; if (submenu) { - // This is a folder. Add it to our list and then recur. - [aPopup addItemWithTitle: [menuItem title]]; + // This is a folder. Add it to our list and then recur. Indent it + // the apropriate depth for readability in the menu. + NSMutableString *title = [NSMutableString stringWithString:[menuItem title]]; + for (int j = 0; j <= depth; ++j) + [title insertString:@" " atIndex: 0]; + + [aPopup addItemWithTitle: title]; NSMenuItem* lastItem = [aPopup lastItem]; if ([menuItem tag] == aTagToMatch) [aPopup selectItem: lastItem]; [lastItem setTag: [menuItem tag]]; - RecursiveAddBookmarkConstruct(aPopup, submenu, aTagToMatch); + RecursiveAddBookmarkConstruct(aPopup, submenu, aTagToMatch, depth+1); } } } diff --git a/mozilla/chimera/src/bookmarks/BookmarksService.mm b/mozilla/chimera/src/bookmarks/BookmarksService.mm index 96554b5f810..27db93d6c64 100644 --- a/mozilla/chimera/src/bookmarks/BookmarksService.mm +++ b/mozilla/chimera/src/bookmarks/BookmarksService.mm @@ -814,7 +814,7 @@ void BookmarksService::EnsureToolbarRoot() } static -void RecursiveAddBookmarkConstruct(NSPopUpButton* aPopup, NSMenu* aMenu, int aTagToMatch) +void RecursiveAddBookmarkConstruct(NSPopUpButton* aPopup, NSMenu* aMenu, int aTagToMatch, int depth = 0) { // Get the menu item children. NSArray* children = [aMenu itemArray]; @@ -823,18 +823,23 @@ void RecursiveAddBookmarkConstruct(NSPopUpButton* aPopup, NSMenu* aMenu, int aTa startPosition = 3; int count = [children count]; - for (int i = startPosition; i < count; i++) { + for (int i = startPosition; i < count; ++i) { NSMenuItem* menuItem = [children objectAtIndex: i]; NSMenu* submenu = [menuItem submenu]; if (submenu) { - // This is a folder. Add it to our list and then recur. - [aPopup addItemWithTitle: [menuItem title]]; + // This is a folder. Add it to our list and then recur. Indent it + // the apropriate depth for readability in the menu. + NSMutableString *title = [NSMutableString stringWithString:[menuItem title]]; + for (int j = 0; j <= depth; ++j) + [title insertString:@" " atIndex: 0]; + + [aPopup addItemWithTitle: title]; NSMenuItem* lastItem = [aPopup lastItem]; if ([menuItem tag] == aTagToMatch) [aPopup selectItem: lastItem]; [lastItem setTag: [menuItem tag]]; - RecursiveAddBookmarkConstruct(aPopup, submenu, aTagToMatch); + RecursiveAddBookmarkConstruct(aPopup, submenu, aTagToMatch, depth+1); } } }