HaikuDepot: Fix Open Button Name

The "open" button on an installed package is currently missing the
name of the application to launch.

Fixes #19147

Change-Id: I24cca3c5f1f4f11f81e99e4223042a0081c7babf
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8434
Haiku-Format: Haiku-format Bot <no-reply+haikuformatbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
This commit is contained in:
Andrew Lindesay 2024-10-05 22:42:02 +13:00 committed by waddlesplash
parent 0076659590
commit f597685760
4 changed files with 26 additions and 12 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2013-2021, Haiku, Inc. All Rights Reserved.
* Copyright 2013-2024, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
@ -78,6 +78,24 @@ DeskbarLink::Link() const
}
const BString
DeskbarLink::Title() const
{
BString result = "???";
if (!fLink.IsEmpty()) {
int32 lastSlash = fLink.FindLast('/');
if (lastSlash != B_ERROR)
fLink.CopyInto(result, lastSlash + 1, (fLink.Length() - lastSlash) - 1);
else
result = fLink;
}
return result;
}
status_t
DeskbarLink::Archive(BMessage* into, bool deep) const
{

View File

@ -3,7 +3,7 @@
* Copyright 2011, Ingo Weinhold, <ingo_weinhold@gmx.de>
* Copyright 2013, Rene Gollent, <rene@gollent.com>
* Copyright 2017, Julian Harnath <julian.harnath@rwth-aachen.de>.
* Copyright 2021, Andrew Lindesay <apl@lindesay.co.nz>.
* Copyright 2021-2024, Andrew Lindesay <apl@lindesay.co.nz>.
*
* All rights reserved. Distributed under the terms of the MIT License.
*
@ -30,6 +30,7 @@ public:
const BString Path() const;
const BString Link() const;
const BString Title() const;
bool operator==(const DeskbarLink& other);
bool operator!=(const DeskbarLink& other);

View File

@ -57,10 +57,8 @@ public:
virtual status_t HandleEntry(BPackageEntry* entry)
{
BString path = MakePath(entry);
if (path.FindFirst("data/deskbar/menu") == 0
&& entry->SymlinkPath() != NULL) {
HDINFO("found deskbar entry: %s -> %s",
path.String(), entry->SymlinkPath());
if (path.FindFirst("data/deskbar/menu") == 0 && entry->SymlinkPath() != NULL) {
HDINFO("found deskbar entry: %s -> %s", path.String(), entry->SymlinkPath());
fDeskbarLinks.push_back(DeskbarLink(path, entry->SymlinkPath()));
}
return B_OK;

View File

@ -179,8 +179,7 @@ PackageManager::_CollectPackageActionsForActivatedOrInstalled(
// Add OpenPackageActions for each deskbar link found in the
// package
std::vector<DeskbarLink> foundLinks;
if (OpenPackageProcess::FindAppToLaunch(package, foundLinks)
&& foundLinks.size() < 4) {
if (OpenPackageProcess::FindAppToLaunch(package, foundLinks) && foundLinks.size() < 4) {
std::vector<DeskbarLink>::const_iterator it;
for (it = foundLinks.begin(); it != foundLinks.end(); it++) {
const DeskbarLink& aLink = *it;
@ -219,12 +218,10 @@ PackageManager::_CreateInstallPackageAction(const PackageInfoRef& package)
PackageActionRef
PackageManager::_CreateOpenPackageAction(const PackageInfoRef& package,
const DeskbarLink& link)
PackageManager::_CreateOpenPackageAction(const PackageInfoRef& package, const DeskbarLink& link)
{
BPath linkPath(link.Link());
BString title = B_TRANSLATE("Open %DeskbarLink%");
title.ReplaceAll("%DeskbarLink%", linkPath.Leaf());
title.ReplaceAll("%DeskbarLink%", link.Title());
BMessage deskbarLinkMessage;
if (link.Archive(&deskbarLinkMessage) != B_OK)