* fix sorting of languages in ReadOnlyBootPrompt
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39014 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -63,6 +63,18 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
compare_void_list_items(const void* _a, const void* _b)
|
||||||
|
{
|
||||||
|
static BCollator collator;
|
||||||
|
|
||||||
|
LanguageItem* a = *(LanguageItem**)_a;
|
||||||
|
LanguageItem* b = *(LanguageItem**)_b;
|
||||||
|
|
||||||
|
return collator.Compare(a->Text(), b->Text());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
BootPromptWindow::BootPromptWindow()
|
BootPromptWindow::BootPromptWindow()
|
||||||
:
|
:
|
||||||
BWindow(BRect(0, 0, 450, 380), "",
|
BWindow(BRect(0, 0, 450, 380), "",
|
||||||
@@ -268,6 +280,7 @@ BootPromptWindow::_PopulateLanguages()
|
|||||||
// limited to catalogs written for this application, which is on purpose!
|
// limited to catalogs written for this application, which is on purpose!
|
||||||
|
|
||||||
const char* languageString;
|
const char* languageString;
|
||||||
|
LanguageItem* currentItem = NULL;
|
||||||
for (int32 i = 0; installedCatalogs.FindString("langs", i, &languageString)
|
for (int32 i = 0; installedCatalogs.FindString("langs", i, &languageString)
|
||||||
== B_OK; i++) {
|
== B_OK; i++) {
|
||||||
BLanguage* language;
|
BLanguage* language;
|
||||||
@@ -291,16 +304,17 @@ BootPromptWindow::_PopulateLanguages()
|
|||||||
languageString);
|
languageString);
|
||||||
fLanguagesListView->AddItem(item);
|
fLanguagesListView->AddItem(item);
|
||||||
// Select this item if it is the first preferred language
|
// Select this item if it is the first preferred language
|
||||||
if (strcmp(firstPreferredLanguage, languageString) == 0) {
|
if (strcmp(firstPreferredLanguage, languageString) == 0)
|
||||||
fLanguagesListView->Select(
|
currentItem = item;
|
||||||
fLanguagesListView->CountItems() - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
delete language;
|
delete language;
|
||||||
} else
|
} else
|
||||||
printf("failed to get BLanguage for %s\n", languageString);
|
printf("failed to get BLanguage for %s\n", languageString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fLanguagesListView->SortItems(compare_void_list_items);
|
||||||
|
if (currentItem != NULL)
|
||||||
|
fLanguagesListView->Select(fLanguagesListView->IndexOf(currentItem));
|
||||||
fLanguagesListView->ScrollToSelection();
|
fLanguagesListView->ScrollToSelection();
|
||||||
|
|
||||||
// Re-enable sending the selection message.
|
// Re-enable sending the selection message.
|
||||||
|
|||||||
Reference in New Issue
Block a user