Deskbar: item sorting is not locale-sensitive

Fix using a global BCollator defined in BarApp.

Called static CompareByName() method in TTeamMenu instead of
duplicating code, made method public.

This comes from a patch by 0xffea for GSoC 2014.

A locale aware version of NaturalCompare in WindowMenuItem.cpp
is still needed.

Fixes #7712

Signed-off-by: John Scipione <[email protected]>
This commit is contained in:
0xffea
2016-08-22 15:14:09 -07:00
committed by John Scipione
parent ca45c75350
commit bd6dcb363f
5 changed files with 10 additions and 12 deletions
+2
View File
@@ -70,6 +70,8 @@ All rights reserved.
#include "tracker_private.h"
BCollator gCollator;
BLocker TBarApp::sSubscriberLock;
BList TBarApp::sBarTeamInfoList;
BList TBarApp::sSubscribers;
+3
View File
@@ -36,6 +36,7 @@ All rights reserved.
#define BAR_APP_H
#include <Collator.h>
#include <Server.h>
#include "BarSettings.h"
@@ -76,6 +77,8 @@ const int32 kIconCacheCount = (kMaximumIconSize - kMinimumIconSize)
// update preferences message constant
const uint32 kUpdatePreferences = 'Pref';
extern BCollator gCollator;
/* --------------------------------------------- */
class BBitmap;
+2 -9
View File
@@ -63,6 +63,7 @@ All rights reserved.
#include "ResourceSet.h"
#include "ShowHideMenuItem.h"
#include "StatusView.h"
#include "TeamMenu.h"
#include "TeamMenuItem.h"
#include "WindowMenu.h"
#include "WindowMenuItem.h"
@@ -111,14 +112,6 @@ TExpandoMenuBar::TExpandoMenuBar(TBarView* barView, bool vertical)
}
int
TExpandoMenuBar::CompareByName(const void* first, const void* second)
{
return strcasecmp((*(static_cast<BarTeamInfo* const*>(first)))->name,
(*(static_cast<BarTeamInfo* const*>(second)))->name);
}
void
TExpandoMenuBar::AttachedToWindow()
{
@@ -489,7 +482,7 @@ TExpandoMenuBar::BuildItems()
}
if (settings->sortRunningApps)
fTeamList.SortItems(CompareByName);
fTeamList.SortItems(TTeamMenu::CompareByName);
int32 teamCount = fTeamList.CountItems();
for (int32 i = 0; i < teamCount; i++) {
+3 -2
View File
@@ -65,7 +65,8 @@ TTeamMenu::TTeamMenu()
int
TTeamMenu::CompareByName(const void* first, const void* second)
{
return strcasecmp((*(static_cast<BarTeamInfo* const*>(first)))->name,
return gCollator.Compare(
(*(static_cast<BarTeamInfo* const*>(first)))->name,
(*(static_cast<BarTeamInfo* const*>(second)))->name);
}
@@ -88,7 +89,7 @@ TTeamMenu::AttachedToWindow()
float width = gMinimumWindowWidth - iconSize - 4;
if (settings->sortRunningApps)
teamList.SortItems(CompareByName);
teamList.SortItems(TTeamMenu::CompareByName);
int32 count = teamList.CountItems();
for (int32 i = 0; i < count; i++) {
-1
View File
@@ -51,7 +51,6 @@ public:
void AttachedToWindow();
void DetachedFromWindow();
private:
static int CompareByName(const void* first,
const void* second);
};