mirror of
https://github.com/reactos/reactos.git
synced 2025-07-28 10:52:20 +00:00
[SETUP:REACTOS] Set the default language and keyboard layout at startup
Retrieve the current ambient language and keyboard layout, that has been chosen in the "General language and keyboard layout selection" dialog when starting the LiveCD. A more robust solution will be developed later.
This commit is contained in:
parent
c0b4db14de
commit
ed7dc31103
2 changed files with 64 additions and 42 deletions
|
@ -25,6 +25,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "reactos.h"
|
#include "reactos.h"
|
||||||
|
#include <winnls.h> // For GetUserDefaultLCID()
|
||||||
|
|
||||||
#define NTOS_MODE_USER
|
#define NTOS_MODE_USER
|
||||||
#include <ndk/obfuncs.h>
|
#include <ndk/obfuncs.h>
|
||||||
|
@ -1401,11 +1402,16 @@ RestartDlgProc(
|
||||||
BOOL LoadSetupData(
|
BOOL LoadSetupData(
|
||||||
IN OUT PSETUPDATA pSetupData)
|
IN OUT PSETUPDATA pSetupData)
|
||||||
{
|
{
|
||||||
BOOL ret = TRUE;
|
pSetupData->PartitionList = CreatePartitionList();
|
||||||
// INFCONTEXT InfContext;
|
if (!pSetupData->PartitionList)
|
||||||
// TCHAR tmp[10];
|
{
|
||||||
// DWORD LineLength;
|
DPRINT1("Could not enumerate available disks; failing installation\n");
|
||||||
// LONG Count;
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
pSetupData->NtOsInstallsList = CreateNTOSInstallationsList(pSetupData->PartitionList);
|
||||||
|
if (!pSetupData->NtOsInstallsList)
|
||||||
|
DPRINT1("Failed to get a list of NTOS installations; continue installation...\n");
|
||||||
|
|
||||||
/* Load the hardware, language and keyboard layout lists */
|
/* Load the hardware, language and keyboard layout lists */
|
||||||
|
|
||||||
|
@ -1415,54 +1421,73 @@ BOOL LoadSetupData(
|
||||||
|
|
||||||
pSetupData->USetupData.LanguageList = CreateLanguageList(pSetupData->USetupData.SetupInf, pSetupData->DefaultLanguage);
|
pSetupData->USetupData.LanguageList = CreateLanguageList(pSetupData->USetupData.SetupInf, pSetupData->DefaultLanguage);
|
||||||
|
|
||||||
pSetupData->PartitionList = CreatePartitionList();
|
/* If not unattended, overwrite language and locale with
|
||||||
|
* the current ones of the running ReactOS instance */
|
||||||
|
if (!IsUnattendedSetup)
|
||||||
|
{
|
||||||
|
LCID LocaleID = GetUserDefaultLCID();
|
||||||
|
|
||||||
pSetupData->NtOsInstallsList = CreateNTOSInstallationsList(pSetupData->PartitionList);
|
StringCchPrintfW(pSetupData->DefaultLanguage,
|
||||||
if (!pSetupData->NtOsInstallsList)
|
_countof(pSetupData->DefaultLanguage),
|
||||||
DPRINT1("Failed to get a list of NTOS installations; continue installation...\n");
|
L"%08lx", LocaleID);
|
||||||
|
|
||||||
|
StringCchPrintfW(pSetupData->USetupData.LocaleID,
|
||||||
|
_countof(pSetupData->USetupData.LocaleID),
|
||||||
|
L"%08lx", LocaleID);
|
||||||
|
}
|
||||||
|
|
||||||
/* new part */
|
/* new part */
|
||||||
pSetupData->SelectedLanguageId = pSetupData->DefaultLanguage;
|
pSetupData->SelectedLanguageId = pSetupData->DefaultLanguage;
|
||||||
wcscpy(pSetupData->DefaultLanguage, pSetupData->USetupData.LocaleID);
|
wcscpy(pSetupData->DefaultLanguage, pSetupData->USetupData.LocaleID); // FIXME: In principle, only when unattended.
|
||||||
pSetupData->USetupData.LanguageId = (LANGID)(wcstol(pSetupData->SelectedLanguageId, NULL, 16) & 0xFFFF);
|
pSetupData->USetupData.LanguageId = (LANGID)(wcstol(pSetupData->SelectedLanguageId, NULL, 16) & 0xFFFF);
|
||||||
|
|
||||||
pSetupData->USetupData.LayoutList = CreateKeyboardLayoutList(pSetupData->USetupData.SetupInf, pSetupData->SelectedLanguageId, pSetupData->DefaultKBLayout);
|
pSetupData->USetupData.LayoutList = CreateKeyboardLayoutList(pSetupData->USetupData.SetupInf,
|
||||||
|
pSetupData->SelectedLanguageId,
|
||||||
|
pSetupData->DefaultKBLayout);
|
||||||
|
|
||||||
#if 0
|
/* If not unattended, overwrite keyboard layout with
|
||||||
// get default for keyboard and language
|
* the current one of the running ReactOS instance */
|
||||||
pSetupData->DefaultKBLayout = -1;
|
if (!IsUnattendedSetup)
|
||||||
pSetupData->DefaultLang = -1;
|
|
||||||
|
|
||||||
// TODO: get defaults from underlaying running system
|
|
||||||
if (SetupFindFirstLine(pSetupData->USetupData.SetupInf, _T("NLS"), _T("DefaultLayout"), &InfContext))
|
|
||||||
{
|
{
|
||||||
SetupGetStringField(&InfContext, 1, tmp, ARRAYSIZE(tmp), &LineLength);
|
C_ASSERT(_countof(pSetupData->DefaultKBLayout) >= KL_NAMELENGTH);
|
||||||
for (Count = 0; Count < pSetupData->KbLayoutCount; Count++)
|
/* If the call fails, keep the default already stored in the buffer */
|
||||||
|
GetKeyboardLayoutNameW(pSetupData->DefaultKBLayout);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Change the default entries in the language and keyboard layout lists */
|
||||||
|
{
|
||||||
|
PGENERIC_LIST LanguageList = pSetupData->USetupData.LanguageList;
|
||||||
|
PGENERIC_LIST LayoutList = pSetupData->USetupData.LayoutList;
|
||||||
|
PGENERIC_LIST_ENTRY ListEntry;
|
||||||
|
|
||||||
|
/* Search for default language */
|
||||||
|
for (ListEntry = GetFirstListEntry(LanguageList); ListEntry;
|
||||||
|
ListEntry = GetNextListEntry(ListEntry))
|
||||||
|
{
|
||||||
|
PCWSTR LocaleId = ((PGENENTRY)GetListEntryData(ListEntry))->Id;
|
||||||
|
if (!wcsicmp(pSetupData->DefaultLanguage, LocaleId))
|
||||||
{
|
{
|
||||||
if (_tcscmp(tmp, pSetupData->pKbLayouts[Count].LayoutId) == 0)
|
DPRINT("found %S in LanguageList\n", LocaleId);
|
||||||
{
|
SetCurrentListEntry(LanguageList, ListEntry);
|
||||||
pSetupData->DefaultKBLayout = Count;
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SetupFindFirstLine(pSetupData->USetupData.SetupInf, _T("NLS"), _T("DefaultLanguage"), &InfContext))
|
/* Search for default layout */
|
||||||
|
for (ListEntry = GetFirstListEntry(LayoutList); ListEntry;
|
||||||
|
ListEntry = GetNextListEntry(ListEntry))
|
||||||
{
|
{
|
||||||
SetupGetStringField(&InfContext, 1, tmp, ARRAYSIZE(tmp), &LineLength);
|
PCWSTR pszLayoutId = ((PGENENTRY)GetListEntryData(ListEntry))->Id;
|
||||||
for (Count = 0; Count < pSetupData->LangCount; Count++)
|
if (!wcsicmp(pSetupData->DefaultKBLayout, pszLayoutId))
|
||||||
{
|
{
|
||||||
if (_tcscmp(tmp, pSetupData->pLanguages[Count].LangId) == 0)
|
DPRINT("Found %S in LayoutList\n", pszLayoutId);
|
||||||
{
|
SetCurrentListEntry(LayoutList, ListEntry);
|
||||||
pSetupData->DefaultLang = Count;
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
}
|
||||||
|
|
||||||
return ret;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
|
@ -1875,15 +1900,16 @@ _tWinMain(HINSTANCE hInst,
|
||||||
goto Quit;
|
goto Quit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Retrieve any supplemental options from the unattend file */
|
||||||
|
CheckUnattendedSetup(&SetupData.USetupData);
|
||||||
|
SetupData.bUnattend = IsUnattendedSetup; // FIXME :-)
|
||||||
|
|
||||||
/* Load extra setup data (HW lists etc...) */
|
/* Load extra setup data (HW lists etc...) */
|
||||||
if (!LoadSetupData(&SetupData))
|
if (!LoadSetupData(&SetupData))
|
||||||
goto Quit;
|
goto Quit;
|
||||||
|
|
||||||
hHotkeyThread = CreateThread(NULL, 0, HotkeyThread, NULL, 0, NULL);
|
hHotkeyThread = CreateThread(NULL, 0, HotkeyThread, NULL, 0, NULL);
|
||||||
|
|
||||||
CheckUnattendedSetup(&SetupData.USetupData);
|
|
||||||
SetupData.bUnattend = IsUnattendedSetup; // FIXME :-)
|
|
||||||
|
|
||||||
/* Cache commonly-used strings */
|
/* Cache commonly-used strings */
|
||||||
LoadStringW(hInst, IDS_ABORTSETUP, SetupData.szAbortMessage, ARRAYSIZE(SetupData.szAbortMessage));
|
LoadStringW(hInst, IDS_ABORTSETUP, SetupData.szAbortMessage, ARRAYSIZE(SetupData.szAbortMessage));
|
||||||
LoadStringW(hInst, IDS_ABORTSETUP2, SetupData.szAbortTitle, ARRAYSIZE(SetupData.szAbortTitle));
|
LoadStringW(hInst, IDS_ABORTSETUP2, SetupData.szAbortTitle, ARRAYSIZE(SetupData.szAbortTitle));
|
||||||
|
|
|
@ -136,10 +136,6 @@ typedef struct _SETUPDATA
|
||||||
|
|
||||||
/* Settings */
|
/* Settings */
|
||||||
LONG DestPartSize; // if partition doesn't exist, size of partition
|
LONG DestPartSize; // if partition doesn't exist, size of partition
|
||||||
LONG FSType; // file system type on partition
|
|
||||||
LONG FormatPart; // type of format the partition
|
|
||||||
|
|
||||||
LONG SelectedLangId; // selected language (table index)
|
|
||||||
|
|
||||||
/* txtsetup.sif data */
|
/* txtsetup.sif data */
|
||||||
// LONG DefaultLang; // default language (table index)
|
// LONG DefaultLang; // default language (table index)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue