From fedec7b31f35176eea75a996c7d33dda2efc3b81 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Mon, 4 Aug 2014 14:59:30 +0200 Subject: [PATCH] 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. --- src/apps/webpositive/BrowserWindow.cpp | 31 +++++++++++++++++--------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/src/apps/webpositive/BrowserWindow.cpp b/src/apps/webpositive/BrowserWindow.cpp index 908c6b831e..ae7712427d 100644 --- a/src/apps/webpositive/BrowserWindow.cpp +++ b/src/apps/webpositive/BrowserWindow.cpp @@ -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: