From e356b712e9dbb8ba9e6c53fbfa362fba2f8e8330 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20H=C3=B6ppner?= <0xffea@gmail.com>
Date: Thu, 27 Feb 2014 22:20:47 +0800
Subject: [PATCH] Fix #7712: Deskbar item sorting is not locale-sensitive
---
src/apps/deskbar/BarApp.cpp | 2 ++
src/apps/deskbar/BarApp.h | 3 +++
src/apps/deskbar/ExpandoMenuBar.cpp | 5 +++--
src/apps/deskbar/TeamMenu.cpp | 2 +-
src/apps/deskbar/WindowMenu.cpp | 2 +-
5 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/src/apps/deskbar/BarApp.cpp b/src/apps/deskbar/BarApp.cpp
index 5e61ec7..1979ab9 100644
a
|
b
|
All rights reserved.
|
69 | 69 | #include "Utilities.h" |
70 | 70 | |
71 | 71 | |
| 72 | BCollator gCollator; |
| 73 | |
72 | 74 | BLocker TBarApp::sSubscriberLock; |
73 | 75 | BList TBarApp::sBarTeamInfoList; |
74 | 76 | BList TBarApp::sSubscribers; |
diff --git a/src/apps/deskbar/BarApp.h b/src/apps/deskbar/BarApp.h
index 62f16b4..a2ef2b5 100644
a
|
b
|
All rights reserved.
|
37 | 37 | |
38 | 38 | |
39 | 39 | #include <Application.h> |
| 40 | #include <Collator.h> |
40 | 41 | |
41 | 42 | #include "BarSettings.h" |
42 | 43 | |
… |
… |
const int32 kIconCacheCount = (kMaximumIconSize - kMinimumIconSize)
|
77 | 78 | // update preferences message constant |
78 | 79 | const uint32 kUpdatePreferences = 'Pref'; |
79 | 80 | |
| 81 | extern BCollator gCollator; |
| 82 | |
80 | 83 | /* --------------------------------------------- */ |
81 | 84 | |
82 | 85 | class BBitmap; |
diff --git a/src/apps/deskbar/ExpandoMenuBar.cpp b/src/apps/deskbar/ExpandoMenuBar.cpp
index 2cb1994..785e6c9 100644
a
|
b
|
TExpandoMenuBar::TExpandoMenuBar(BRect frame, const char* name,
|
110 | 110 | int |
111 | 111 | TExpandoMenuBar::CompareByName(const void* first, const void* second) |
112 | 112 | { |
113 | | return strcasecmp((*(static_cast<BarTeamInfo* const*>(first)))->name, |
| 113 | return gCollator.Compare((*(static_cast<BarTeamInfo* const*>(first)))->name, |
114 | 114 | (*(static_cast<BarTeamInfo* const*>(second)))->name); |
115 | 115 | } |
116 | 116 | |
… |
… |
TExpandoMenuBar::AddTeam(BList* team, BBitmap* icon, char* name,
|
604 | 604 | int32 itemCount = CountItems(); |
605 | 605 | while (i < itemCount) { |
606 | 606 | teamItem = dynamic_cast<TTeamMenuItem*>(ItemAt(i)); |
607 | | if (teamItem != NULL && strcasecmp(teamItem->Name(), name) > 0) { |
| 607 | if (teamItem != NULL |
| 608 | && gCollator.Compare(teamItem->Name(), name) > 0) { |
608 | 609 | AddItem(item, i); |
609 | 610 | break; |
610 | 611 | } |
diff --git a/src/apps/deskbar/TeamMenu.cpp b/src/apps/deskbar/TeamMenu.cpp
index 4fb8273..5495cd7 100644
a
|
b
|
TTeamMenu::TTeamMenu()
|
62 | 62 | int |
63 | 63 | TTeamMenu::CompareByName(const void* first, const void* second) |
64 | 64 | { |
65 | | return strcasecmp((*(static_cast<BarTeamInfo* const*>(first)))->name, |
| 65 | return gCollator.Compare((*(static_cast<BarTeamInfo* const*>(first)))->name, |
66 | 66 | (*(static_cast<BarTeamInfo* const*>(second)))->name); |
67 | 67 | } |
68 | 68 | |
diff --git a/src/apps/deskbar/WindowMenu.cpp b/src/apps/deskbar/WindowMenu.cpp
index 42279f7..e17ac98 100644
a
|
b
|
TWindowMenu::AttachedToWindow()
|
140 | 140 | TWindowMenuItem* item |
141 | 141 | = static_cast<TWindowMenuItem*>(ItemAt(addIndex)); |
142 | 142 | if (item != NULL |
143 | | && strcasecmp(item->FullTitle(), wInfo->name) > 0) |
| 143 | && gCollator.Compare(item->FullTitle(), wInfo->name) > 0) |
144 | 144 | break; |
145 | 145 | } |
146 | 146 | |