hrev48089 adds 2 changesets to branch 'master' old head: 8efd5b761352ca5ba3b5118895c40eedb1cf692b new head: 9303787b1a749039a88318f3f74a5c84d82e3c8b overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=9303787+%5E8efd5b7 ---------------------------------------------------------------------------- 7102f0d: HaikuDepot: Disable package action button... ... after scheduling the respective package action. 9303787: HaikuDepot: Show ratings in other languages with empty comments [ Stephan Aßmus <superstippi@xxxxxx> ] ---------------------------------------------------------------------------- 1 file changed, 59 insertions(+), 29 deletions(-) src/apps/haikudepot/ui/PackageInfoView.cpp | 88 +++++++++++++++++--------- ############################################################################ Commit: 7102f0d09b44ea73baaf40953a2be3d5cbc548ad URL: http://cgit.haiku-os.org/haiku/commit/?id=7102f0d Author: Stephan Aßmus <superstippi@xxxxxx> Date: Sat Oct 25 10:12:29 2014 UTC HaikuDepot: Disable package action button... ... after scheduling the respective package action. ---------------------------------------------------------------------------- diff --git a/src/apps/haikudepot/ui/PackageInfoView.cpp b/src/apps/haikudepot/ui/PackageInfoView.cpp index c562e3e..4b8eeaf 100644 --- a/src/apps/haikudepot/ui/PackageInfoView.cpp +++ b/src/apps/haikudepot/ui/PackageInfoView.cpp @@ -624,35 +624,8 @@ public: { switch (message->what) { case MSG_PACKAGE_ACTION: - { - int32 index; - if (message->FindInt32("index", &index) == B_OK) { - const PackageActionRef& action - = fPackageActions.ItemAt(index); - if (action.Get() != NULL) { - PackageActionList actions; - actions.Add(action); - status_t result = fPackageActionHandler - ->SchedulePackageActions(actions); - if (result != B_OK) { - fprintf(stderr, "Failed to schedule action: " - "%s '%s': %s\n", action->Label(), - action->Package()->Title().String(), - strerror(result)); - BString message(B_TRANSLATE("The package action " - "could not be scheduled: %Error%")); - message.ReplaceAll("%Error%", strerror(result)); - BAlert* alert = new(std::nothrow) BAlert( - B_TRANSLATE("Package action failed"), - message, B_TRANSLATE("OK"), NULL, NULL, - B_WIDTH_AS_USUAL, B_WARNING_ALERT); - if (alert != NULL) - alert->Go(); - } - } - } + _RunPackageAction(message); break; - } default: BView::MessageReceived(message); @@ -761,6 +734,60 @@ public: } private: + void _RunPackageAction(BMessage* message) + { + int32 index; + if (message->FindInt32("index", &index) != B_OK) + return; + + const PackageActionRef& action = fPackageActions.ItemAt(index); + if (action.Get() == NULL) + return; + + PackageActionList actions; + actions.Add(action); + status_t result + = fPackageActionHandler->SchedulePackageActions(actions); + + if (result != B_OK) { + fprintf(stderr, "Failed to schedule action: " + "%s '%s': %s\n", action->Label(), + action->Package()->Title().String(), + strerror(result)); + BString message(B_TRANSLATE("The package action " + "could not be scheduled: %Error%")); + message.ReplaceAll("%Error%", strerror(result)); + BAlert* alert = new(std::nothrow) BAlert( + B_TRANSLATE("Package action failed"), + message, B_TRANSLATE("OK"), NULL, NULL, + B_WIDTH_AS_USUAL, B_WARNING_ALERT); + if (alert != NULL) + alert->Go(); + } else { + // Find the button for this action and disable it. + // Actually search the matching button instead of just using + // fButtons.ItemAt((fButtons.CountItems() - 1) - index) to + // make this robust against for example changing the order of + // buttons from right -> left to left -> right... + for (int32 i = 0; i < fButtons.CountItems(); i++) { + BButton* button = (BButton*)fButtons.ItemAt(index); + if (button == NULL) + continue; + BMessage* buttonMessage = button->Message(); + if (buttonMessage == NULL) + continue; + int32 buttonIndex; + if (buttonMessage->FindInt32("index", &buttonIndex) != B_OK) + continue; + if (buttonIndex == index) { + button->SetEnabled(false); + break; + } + } + } + } + +private: BGroupLayout* fLayout; PackageActionList fPackageActions; PackageActionHandler* fPackageActionHandler; ############################################################################ Revision: hrev48089 Commit: 9303787b1a749039a88318f3f74a5c84d82e3c8b URL: http://cgit.haiku-os.org/haiku/commit/?id=9303787 Author: Stephan Aßmus <superstippi@xxxxxx> Date: Sat Oct 25 14:31:08 2014 UTC HaikuDepot: Show ratings in other languages with empty comments ---------------------------------------------------------------------------- diff --git a/src/apps/haikudepot/ui/PackageInfoView.cpp b/src/apps/haikudepot/ui/PackageInfoView.cpp index 4b8eeaf..0578c9c 100644 --- a/src/apps/haikudepot/ui/PackageInfoView.cpp +++ b/src/apps/haikudepot/ui/PackageInfoView.cpp @@ -1265,7 +1265,10 @@ public: // TODO: Sort by age or usefullness rating for (int i = count - 1; i >= 0; i--) { const UserRating& rating = userRatings.ItemAtFast(i); - if (fPreferredLanguages.CountItems() > 0 + // Prevent ratings from showing that have a comment which + // is in another language + if (!rating.Comment().IsEmpty() + && fPreferredLanguages.CountItems() > 0 && !fPreferredLanguages.Contains(rating.Language())) { continue; }