Some improbements to the bookmark bar

- Resolve symlinks to bookmarks so we display the icons for those
- Adjust the minimal height of the bar to make space for icons (if you
  use a tiny font size)
- Do not allow the bookmark bar to show when it is empty
This commit is contained in:
Adrien Destugues
2016-11-06 09:56:45 +01:00
parent 156b6cd596
commit a02a1bb4e6
2 changed files with 16 additions and 5 deletions
+10 -4
View File
@@ -45,7 +45,7 @@ BookmarkBar::AttachedToWindow()
// Enumerate initial directory content
BDirectory dir(&fNodeRef);
BEntry bookmark;
while (dir.GetNextEntry(&bookmark) == B_OK) {
while (dir.GetNextEntry(&bookmark, true) == B_OK) {
node_ref ref;
if (bookmark.GetNodeRef(&ref) == B_OK)
_AddItem(ref.node, &bookmark);
@@ -72,7 +72,7 @@ BookmarkBar::MessageReceived(BMessage* message)
message->FindString("name", &name);
ref.set_name(name);
BEntry entry(&ref);
BEntry entry(&ref, true);
if (entry.InitCheck() == B_OK)
_AddItem(inode, &entry);
break;
@@ -88,7 +88,7 @@ BookmarkBar::MessageReceived(BMessage* message)
ref.set_name(name);
if (fItemsMap[inode] == NULL) {
BEntry entry(&ref);
BEntry entry(&ref, true);
_AddItem(inode, &entry);
break;
} else {
@@ -177,6 +177,10 @@ BookmarkBar::MinSize()
// We only need space to show the "more" button.
size.width = 32;
// We need enough vertical space to show bookmark icons.
if (size.height < 20)
size.height = 20;
return size;
}
@@ -214,7 +218,9 @@ BookmarkBar::_AddItem(ino_t inode, BEntry* entry)
item = new IconMenuItem(name, message, &info, B_MINI_ICON);
}
BMenuBar::AddItem(item, CountItems() - 1);
int32 count = CountItems();
BMenuBar::AddItem(item, count - 1);
fItemsMap[inode] = item;
// Move the item to the "more" menu if it overflows.
+6 -1
View File
@@ -508,7 +508,8 @@ BrowserWindow::BrowserWindow(BRect frame, SettingsMessage* appSettings,
fBookmarkBarMenuItem->SetEnabled(true);
} else
fBookmarkBarMenuItem->SetEnabled(false);
}
} else
fBookmarkBarMenuItem->SetEnabled(false);
// Back, Forward, Stop & Home buttons
fBackButton = new BIconButton("Back", NULL, new BMessage(GO_BACK));
@@ -2648,6 +2649,10 @@ BrowserWindow::_HandlePageSourceResult(const BMessage* message)
void
BrowserWindow::_ShowBookmarkBar(bool show)
{
// It is not allowed to show the bookmark bar when it is empty
if (show && fBookmarkBar->CountItems() <= 1)
return;
fBookmarkBarMenuItem->SetMarked(show);
if (fBookmarkBar == NULL || fBookmarkBar->IsHidden() != show)