Ticket #7712: 0001-Fix-7712-Deskbar-item-sorting-is-not-locale-sensitiv.patch

File 0001-Fix-7712-Deskbar-item-sorting-is-not-locale-sensitiv.patch, 3.3 KB (added by 0xffea, 11 years ago)

New version with global collator

  • src/apps/deskbar/BarApp.cpp

    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.  
    6969#include "Utilities.h"
    7070
    7171
     72BCollator gCollator;
     73
    7274BLocker TBarApp::sSubscriberLock;
    7375BList TBarApp::sBarTeamInfoList;
    7476BList TBarApp::sSubscribers;
  • src/apps/deskbar/BarApp.h

    diff --git a/src/apps/deskbar/BarApp.h b/src/apps/deskbar/BarApp.h
    index 62f16b4..a2ef2b5 100644
    a b All rights reserved.  
    3737
    3838
    3939#include <Application.h>
     40#include <Collator.h>
    4041
    4142#include "BarSettings.h"
    4243
    const int32 kIconCacheCount = (kMaximumIconSize - kMinimumIconSize)  
    7778// update preferences message constant
    7879const uint32 kUpdatePreferences = 'Pref';
    7980
     81extern BCollator gCollator;
     82
    8083/* --------------------------------------------- */
    8184
    8285class BBitmap;
  • src/apps/deskbar/ExpandoMenuBar.cpp

    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,  
    110110int
    111111TExpandoMenuBar::CompareByName(const void* first, const void* second)
    112112{
    113     return strcasecmp((*(static_cast<BarTeamInfo* const*>(first)))->name,
     113    return gCollator.Compare((*(static_cast<BarTeamInfo* const*>(first)))->name,
    114114        (*(static_cast<BarTeamInfo* const*>(second)))->name);
    115115}
    116116
    TExpandoMenuBar::AddTeam(BList* team, BBitmap* icon, char* name,  
    604604        int32 itemCount = CountItems();
    605605        while (i < itemCount) {
    606606            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) {
    608609                AddItem(item, i);
    609610                break;
    610611            }
  • src/apps/deskbar/TeamMenu.cpp

    diff --git a/src/apps/deskbar/TeamMenu.cpp b/src/apps/deskbar/TeamMenu.cpp
    index 4fb8273..5495cd7 100644
    a b TTeamMenu::TTeamMenu()  
    6262int
    6363TTeamMenu::CompareByName(const void* first, const void* second)
    6464{
    65     return strcasecmp((*(static_cast<BarTeamInfo* const*>(first)))->name,
     65    return gCollator.Compare((*(static_cast<BarTeamInfo* const*>(first)))->name,
    6666        (*(static_cast<BarTeamInfo* const*>(second)))->name);
    6767}
    6868
  • src/apps/deskbar/WindowMenu.cpp

    diff --git a/src/apps/deskbar/WindowMenu.cpp b/src/apps/deskbar/WindowMenu.cpp
    index 42279f7..e17ac98 100644
    a b TWindowMenu::AttachedToWindow()  
    140140                    TWindowMenuItem* item
    141141                        = static_cast<TWindowMenuItem*>(ItemAt(addIndex));
    142142                    if (item != NULL
    143                         && strcasecmp(item->FullTitle(), wInfo->name) > 0)
     143                        && gCollator.Compare(item->FullTitle(), wInfo->name) > 0)
    144144                        break;
    145145                }
    146146