From 4fc7f247a8acbe2844bd5cd8b091321522b23b69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Tue, 18 Mar 2014 21:02:24 +0100 Subject: [PATCH] HaikuDepot: Introduce new PackageState' pending' When installing a package, it is set to pending, which removes the Install button from the package info area. When multiple packages are downloaded, theould all be put to pending, right now, they will still offer to be installed, although they are already scheduled for downloading. Requesting a package to be installed when it is already schduled will mess things up later. Godm, I hate this nano bug... --- src/apps/haiku-depot/PackageInfo.cpp | 2 +- src/apps/haiku-depot/PackageInfo.h | 3 ++- src/apps/haiku-depot/PackageListView.cpp | 4 ++++ src/apps/haiku-depot/PackageManager.cpp | 5 +++-- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/apps/haiku-depot/PackageInfo.cpp b/src/apps/haiku-depot/PackageInfo.cpp index 2a752a5f81..4a7ae891bb 100644 --- a/src/apps/haiku-depot/PackageInfo.cpp +++ b/src/apps/haiku-depot/PackageInfo.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2013, Stephan Aßmus . + * Copyright 2013-2014, Stephan Aßmus . * Copyright 2013, Rene Gollent . * All rights reserved. Distributed under the terms of the MIT License. */ diff --git a/src/apps/haiku-depot/PackageInfo.h b/src/apps/haiku-depot/PackageInfo.h index 5cd9a2694f..d57429f67a 100644 --- a/src/apps/haiku-depot/PackageInfo.h +++ b/src/apps/haiku-depot/PackageInfo.h @@ -1,5 +1,5 @@ /* - * Copyright 2013, Stephan Aßmus . + * Copyright 2013-2014, Stephan Aßmus . * All rights reserved. Distributed under the terms of the MIT License. */ #ifndef PACKAGE_INFO_H @@ -193,6 +193,7 @@ enum PackageState { DOWNLOADING = 2, ACTIVATED = 3, UNINSTALLED = 4, + PENDING = 5, }; diff --git a/src/apps/haiku-depot/PackageListView.cpp b/src/apps/haiku-depot/PackageListView.cpp index 780e2b4f3d..9be0d83357 100644 --- a/src/apps/haiku-depot/PackageListView.cpp +++ b/src/apps/haiku-depot/PackageListView.cpp @@ -23,6 +23,8 @@ static const char* skPackageStateAvailable = B_TRANSLATE_MARK("Available"); static const char* skPackageStateUninstalled = B_TRANSLATE_MARK("Uninstalled"); static const char* skPackageStateActive = B_TRANSLATE_MARK("Active"); static const char* skPackageStateInactive = B_TRANSLATE_MARK("Inactive"); +static const char* skPackageStatePending = B_TRANSLATE_MARK( + "Pending" B_UTF8_ELLIPSIS); inline BString @@ -43,6 +45,8 @@ package_state_to_string(PackageInfoRef ref) data.SetToFormat("%3.2f%%", ref->DownloadProgress() * 100.0); return data; } + case PENDING: + return B_TRANSLATE(skPackageStatePending); } return B_TRANSLATE("Unknown"); diff --git a/src/apps/haiku-depot/PackageManager.cpp b/src/apps/haiku-depot/PackageManager.cpp index 80442706ec..b9b1226848 100644 --- a/src/apps/haiku-depot/PackageManager.cpp +++ b/src/apps/haiku-depot/PackageManager.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2013, Haiku, Inc. All Rights Reserved. + * Copyright 2013-2014, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -108,6 +108,7 @@ public: | BPackageManager::B_ADD_REMOTE_REPOSITORIES | BPackageManager::B_REFRESH_REPOSITORIES); PackageInfoRef ref(Package()); + ref->SetState(PENDING); fPackageManager->SetCurrentActionPackage(ref, true); fPackageManager->AddProgressListener(this); const char* packageName = ref->Title().String(); @@ -310,7 +311,7 @@ PackageManager::GetPackageActions(PackageInfoRef package, Model* model) if (state == ACTIVATED || state == INSTALLED) { actionList.Add(PackageActionRef(new UninstallPackageAction( package, model), true)); - } else { + } else if (state == NONE || state == UNINSTALLED) { actionList.Add(PackageActionRef(new InstallPackageAction(package, model), true)); }