Bookmark bar uses "Bookmark bar" subfolder

* Allows having a lot of bookmarks in the menu, and only the most often
used ones in the bar.
* If the "Bookmark bar" folder doesn't exist, the old behavior (using
the main Bookmarks folder for the bar as well as the menu) is used.
* If none of these exists, the bookmark bar will not be available (just
like the bookmark menu)

Fixes #11092.

We may want to update the default set of bookmark to include some links
in the bar.
This commit is contained in:
Adrien Destugues 2014-08-04 14:59:30 +02:00
parent bcd6a67bc0
commit fedec7b31f

View File

@ -360,7 +360,8 @@ BrowserWindow::BrowserWindow(BRect frame, SettingsMessage* appSettings,
fZoomTextOnly(true),
fShowTabsIfSinglePageOpen(true),
fAutoHideInterfaceInFullscreenMode(false),
fAutoHidePointer(false)
fAutoHidePointer(false),
fBookmarkBar(NULL)
{
// Begin listening to settings changes and read some current values.
fAppSettings->AddListener(BMessenger(this));
@ -494,6 +495,14 @@ BrowserWindow::BrowserWindow(BRect frame, SettingsMessage* appSettings,
BMenu* bookmarkMenu
= new BookmarkMenu(B_TRANSLATE("Bookmarks"), this, &bookmarkRef);
mainMenu->AddItem(bookmarkMenu);
BDirectory barDir(&bookmarkRef);
BEntry bookmarkBar(&barDir, "Bookmark bar");
entry_ref bookmarkBarRef;
if (bookmarkBar.GetRef(&bookmarkBarRef) != B_OK)
bookmarkBarRef = bookmarkRef;
fBookmarkBar = new BookmarkBar("Bookmarks", this, &bookmarkBarRef);
}
// Back, Forward, Stop & Home buttons
@ -600,14 +609,15 @@ BrowserWindow::BrowserWindow(BRect frame, SettingsMessage* appSettings,
.Add(toggleFullscreenButton, 0.0f)
;
fBookmarkBar = new BookmarkBar("Bookmarks", this, &bookmarkRef);
if (fAppSettings->GetValue(kSettingsShowBookmarkBar, true)) {
// We need to hide the bookmark bar and then show it again
// to save the setting and set the menu item label.
fBookmarkBar->Hide();
_ShowBookmarkBar(true);
} else
_ShowBookmarkBar(false);
if (fBookmarkBar) {
if (fAppSettings->GetValue(kSettingsShowBookmarkBar, true)) {
// We need to hide the bookmark bar and then show it again
// to save the setting and set the menu item label.
fBookmarkBar->Hide();
_ShowBookmarkBar(true);
} else
_ShowBookmarkBar(false);
}
fSavePanel = new BFilePanel(B_SAVE_PANEL, new BMessenger(this), NULL, 0,
false);
@ -815,7 +825,8 @@ BrowserWindow::MessageReceived(BMessage* message)
break;
case SHOW_HIDE_BOOKMARK_BAR:
_ShowBookmarkBar(fBookmarkBar->IsHidden());
if (fBookmarkBar)
_ShowBookmarkBar(fBookmarkBar->IsHidden());
break;
case GOTO_URL: