Author: dchapyshev
Date: Wed May 14 10:51:53 2008
New Revision: 33515
URL:
http://svn.reactos.org/svn/reactos?rev=33515&view=rev
Log:
- Implement "Set Default" button
- Added checking whether there was already layout
Modified:
trunk/reactos/dll/cpl/input/add.c
trunk/reactos/dll/cpl/input/input.h
trunk/reactos/dll/cpl/input/lang/bg-BG.rc
trunk/reactos/dll/cpl/input/lang/de-DE.rc
trunk/reactos/dll/cpl/input/lang/el-GR.rc
trunk/reactos/dll/cpl/input/lang/en-US.rc
trunk/reactos/dll/cpl/input/lang/es-ES.rc
trunk/reactos/dll/cpl/input/lang/fr-FR.rc
trunk/reactos/dll/cpl/input/lang/it-IT.rc
trunk/reactos/dll/cpl/input/lang/pl-PL.rc
trunk/reactos/dll/cpl/input/lang/ru-RU.rc
trunk/reactos/dll/cpl/input/lang/sk-SK.rc
trunk/reactos/dll/cpl/input/lang/uk-UA.rc
trunk/reactos/dll/cpl/input/resource.h
trunk/reactos/dll/cpl/input/settings.c
Modified: trunk/reactos/dll/cpl/input/add.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/input/add.c?rev=33…
==============================================================================
--- trunk/reactos/dll/cpl/input/add.c [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/input/add.c [iso-8859-1] Wed May 14 10:51:53 2008
@@ -74,7 +74,7 @@
{
TCHAR NewLayout[CCH_ULONG_DEC + 1], Lang[MAX_PATH],
LangID[CCH_LAYOUT_ID + 1], Layout[MAX_PATH],
- SubPath[CCH_LAYOUT_ID + 1];
+ SubPath[CCH_LAYOUT_ID + 1], szMessage[MAX_PATH];
INT iLayout, iLang;
HKEY hKey, hSubKey;
DWORD cValues;
@@ -92,10 +92,20 @@
iLang = SendMessage(hLangList, CB_GETCURSEL, 0, 0);
lcid = SendMessage(hLangList, CB_GETITEMDATA, iLang, 0);
+ pts = (PTSTR) SendMessage(hLayoutList, CB_GETITEMDATA, iLayout, 0);
GetLocaleInfo(MAKELCID(lcid, SORT_DEFAULT), LOCALE_ILANGUAGE, Lang,
sizeof(Lang) / sizeof(TCHAR));
wsprintf(LangID, _T("0000%s"), Lang);
+ if (IsLayoutExists(pts, LangID))
+ {
+ LoadString(hApplet, IDS_LAYOUT_EXISTS2, szMessage, sizeof(szMessage) /
sizeof(TCHAR));
+ MessageBox(hwndDlg, szMessage, NULL, MB_OK | MB_ICONINFORMATION);
+
+ RegCloseKey(hKey);
+ return;
+ }
+
if (GetLayoutName(LangID, Layout))
{
if ((SendMessage(hLayoutList, CB_SELECTSTRING, (WPARAM) -1,
(LPARAM)Layout) != CB_ERR)&&
@@ -105,8 +115,6 @@
}
else SubPath[0] = '\0';
}
-
- pts = (PTSTR) SendMessage(hLayoutList, CB_GETITEMDATA, iLayout, 0);
if (_tcslen(SubPath) != 0)
{
Modified: trunk/reactos/dll/cpl/input/input.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/input/input.h?rev=…
==============================================================================
--- trunk/reactos/dll/cpl/input/input.h [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/input/input.h [iso-8859-1] Wed May 14 10:51:53 2008
@@ -41,6 +41,8 @@
GetLayoutName(LPCTSTR szLCID, LPTSTR szName);
VOID
UpdateLayoutsList(VOID);
+BOOL
+IsLayoutExists(LPTSTR szLayoutID, LPTSTR szLangID);
/* keysettings.c */
INT_PTR CALLBACK
Modified: trunk/reactos/dll/cpl/input/lang/bg-BG.rc
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/input/lang/bg-BG.r…
==============================================================================
--- trunk/reactos/dll/cpl/input/lang/bg-BG.rc [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/input/lang/bg-BG.rc [iso-8859-1] Wed May 14 10:51:53 2008
@@ -87,6 +87,8 @@
IDS_LAYOUT "Êëàâèàòóðíà ïîäðåäáà"
IDS_REM_QUESTION "Do you want to remove selected keyboard layout?"
IDS_CONFIRMATION "Confirmation"
+ IDS_LAYOUT_EXISTS "This layout already exists."
+ IDS_LAYOUT_EXISTS2 "This layout already exists and can not be added."
END
STRINGTABLE
Modified: trunk/reactos/dll/cpl/input/lang/de-DE.rc
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/input/lang/de-DE.r…
==============================================================================
--- trunk/reactos/dll/cpl/input/lang/de-DE.rc [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/input/lang/de-DE.rc [iso-8859-1] Wed May 14 10:51:53 2008
@@ -88,6 +88,8 @@
IDS_LAYOUT "Tastaturlayout"
IDS_REM_QUESTION "Do you want to remove selected keyboard layout?"
IDS_CONFIRMATION "Confirmation"
+ IDS_LAYOUT_EXISTS "This layout already exists."
+ IDS_LAYOUT_EXISTS2 "This layout already exists and can not be added."
END
STRINGTABLE
Modified: trunk/reactos/dll/cpl/input/lang/el-GR.rc
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/input/lang/el-GR.r…
==============================================================================
--- trunk/reactos/dll/cpl/input/lang/el-GR.rc [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/input/lang/el-GR.rc [iso-8859-1] Wed May 14 10:51:53 2008
@@ -87,6 +87,8 @@
IDS_LAYOUT "ÄéÜôáîç ðëçêôñïëïãßïõ"
IDS_REM_QUESTION "Do you want to remove selected keyboard layout?"
IDS_CONFIRMATION "Confirmation"
+ IDS_LAYOUT_EXISTS "This layout already exists."
+ IDS_LAYOUT_EXISTS2 "This layout already exists and can not be added."
END
STRINGTABLE
Modified: trunk/reactos/dll/cpl/input/lang/en-US.rc
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/input/lang/en-US.r…
==============================================================================
--- trunk/reactos/dll/cpl/input/lang/en-US.rc [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/input/lang/en-US.rc [iso-8859-1] Wed May 14 10:51:53 2008
@@ -85,8 +85,10 @@
IDS_WHATS_THIS "What's This?"
IDS_LANGUAGE "Language"
IDS_LAYOUT "Keyboard Layout"
- IDS_REM_QUESTION "Do you want to remove selected keyboard layout?"
- IDS_CONFIRMATION "Confirmation"
+ IDS_REM_QUESTION "Do you want to remove selected keyboard layout?"
+ IDS_CONFIRMATION "Confirmation"
+ IDS_LAYOUT_EXISTS "This layout already exists."
+ IDS_LAYOUT_EXISTS2 "This layout already exists and can not be added."
END
STRINGTABLE
Modified: trunk/reactos/dll/cpl/input/lang/es-ES.rc
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/input/lang/es-ES.r…
==============================================================================
--- trunk/reactos/dll/cpl/input/lang/es-ES.rc [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/input/lang/es-ES.rc [iso-8859-1] Wed May 14 10:51:53 2008
@@ -92,6 +92,8 @@
IDS_LAYOUT "Distribución del teclado"
IDS_REM_QUESTION "¿Quiere eliminar la distribución del teclado
seleccionada?"
IDS_CONFIRMATION "Confirmación"
+ IDS_LAYOUT_EXISTS "This layout already exists."
+ IDS_LAYOUT_EXISTS2 "This layout already exists and can not be added."
END
STRINGTABLE
Modified: trunk/reactos/dll/cpl/input/lang/fr-FR.rc
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/input/lang/fr-FR.r…
==============================================================================
--- trunk/reactos/dll/cpl/input/lang/fr-FR.rc [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/input/lang/fr-FR.rc [iso-8859-1] Wed May 14 10:51:53 2008
@@ -87,6 +87,8 @@
IDS_LAYOUT "Keyboard Layout"
IDS_REM_QUESTION "Do you want to remove selected keyboard layout?"
IDS_CONFIRMATION "Confirmation"
+ IDS_LAYOUT_EXISTS "This layout already exists."
+ IDS_LAYOUT_EXISTS2 "This layout already exists and can not be added."
END
/* FIXME : To improve/complete */
Modified: trunk/reactos/dll/cpl/input/lang/it-IT.rc
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/input/lang/it-IT.r…
==============================================================================
--- trunk/reactos/dll/cpl/input/lang/it-IT.rc [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/input/lang/it-IT.rc [iso-8859-1] Wed May 14 10:51:53 2008
@@ -87,6 +87,8 @@
IDS_LAYOUT "Disposizione tastiera"
IDS_REM_QUESTION "Volete rimuovere la disposizione di tastiera
selezionata?"
IDS_CONFIRMATION "Conferma"
+ IDS_LAYOUT_EXISTS "This layout already exists."
+ IDS_LAYOUT_EXISTS2 "This layout already exists and can not be added."
END
STRINGTABLE
Modified: trunk/reactos/dll/cpl/input/lang/pl-PL.rc
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/input/lang/pl-PL.r…
==============================================================================
--- trunk/reactos/dll/cpl/input/lang/pl-PL.rc [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/input/lang/pl-PL.rc [iso-8859-1] Wed May 14 10:51:53 2008
@@ -94,6 +94,8 @@
IDS_LAYOUT "Uk³ad klawiatury"
IDS_REM_QUESTION "Do you want to remove selected keyboard layout?"
IDS_CONFIRMATION "Confirmation"
+ IDS_LAYOUT_EXISTS "This layout already exists."
+ IDS_LAYOUT_EXISTS2 "This layout already exists and can not be added."
END
STRINGTABLE
Modified: trunk/reactos/dll/cpl/input/lang/ru-RU.rc
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/input/lang/ru-RU.r…
==============================================================================
--- trunk/reactos/dll/cpl/input/lang/ru-RU.rc [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/input/lang/ru-RU.rc [iso-8859-1] Wed May 14 10:51:53 2008
@@ -85,8 +85,10 @@
IDS_WHATS_THIS "×òî ýòî?"
IDS_LANGUAGE "ßçûê ââîäà"
IDS_LAYOUT "Ðàñêëàäêà"
- IDS_REM_QUESTION "Âû äåéñòâèòåëüíî õîòèòå óäàëèòü âûáðàííóþ ðàñêëàäêó
êëàâèàòóðû?"
- IDS_CONFIRMATION "Ïîäòâåðæäåíèå"
+ IDS_REM_QUESTION "Âû äåéñòâèòåëüíî õîòèòå óäàëèòü âûáðàííóþ ðàñêëàäêó
êëàâèàòóðû?"
+ IDS_CONFIRMATION "Ïîäòâåðæäåíèå"
+ IDS_LAYOUT_EXISTS "Òàêàÿ ðàñêëàäêà óæå ñóùåñòâóåò."
+ IDS_LAYOUT_EXISTS2 "Òàêàÿ ðàñêëàäêà óæå ñóùåñòâóåò è íå ìîæåò áûòü
äîáàâëåíà."
END
STRINGTABLE
Modified: trunk/reactos/dll/cpl/input/lang/sk-SK.rc
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/input/lang/sk-SK.r…
==============================================================================
--- trunk/reactos/dll/cpl/input/lang/sk-SK.rc [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/input/lang/sk-SK.rc [iso-8859-1] Wed May 14 10:51:53 2008
@@ -91,6 +91,8 @@
IDS_LAYOUT "Rozloenie klávesnice"
IDS_REM_QUESTION "Do you want to remove selected keyboard layout?"
IDS_CONFIRMATION "Confirmation"
+ IDS_LAYOUT_EXISTS "This layout already exists."
+ IDS_LAYOUT_EXISTS2 "This layout already exists and can not be added."
END
STRINGTABLE
Modified: trunk/reactos/dll/cpl/input/lang/uk-UA.rc
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/input/lang/uk-UA.r…
==============================================================================
--- trunk/reactos/dll/cpl/input/lang/uk-UA.rc [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/input/lang/uk-UA.rc [iso-8859-1] Wed May 14 10:51:53 2008
@@ -96,6 +96,8 @@
IDS_LAYOUT "Keyboard Layout"
IDS_REM_QUESTION "Do you want to remove selected keyboard layout?"
IDS_CONFIRMATION "Confirmation"
+ IDS_LAYOUT_EXISTS "This layout already exists."
+ IDS_LAYOUT_EXISTS2 "This layout already exists and can not be added."
END
STRINGTABLE
Modified: trunk/reactos/dll/cpl/input/resource.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/input/resource.h?r…
==============================================================================
--- trunk/reactos/dll/cpl/input/resource.h [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/input/resource.h [iso-8859-1] Wed May 14 10:51:53 2008
@@ -52,6 +52,8 @@
#define IDS_LAYOUT 9
#define IDS_REM_QUESTION 10
#define IDS_CONFIRMATION 11
+#define IDS_LAYOUT_EXISTS 12
+#define IDS_LAYOUT_EXISTS2 13
/* Layouts */
#define IDS_US_LAYOUT 5000
Modified: trunk/reactos/dll/cpl/input/settings.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/input/settings.c?r…
==============================================================================
--- trunk/reactos/dll/cpl/input/settings.c [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/input/settings.c [iso-8859-1] Wed May 14 10:51:53 2008
@@ -34,6 +34,72 @@
LVM_GETNEXTITEM, -1, LVNI_FOCUSED);
return iIndex;
+}
+
+BOOL
+IsLayoutExists(LPTSTR szLayoutID, LPTSTR szLangID)
+{
+ HKEY hKey, hSubKey;
+ TCHAR szPreload[CCH_LAYOUT_ID + 1], szLayoutNum[3 + 1],
+ szTmp[CCH_LAYOUT_ID + 1], szOldLangID[CCH_LAYOUT_ID + 1];
+ DWORD dwIndex = 0, dwType, dwSize;
+ BOOL IsLangExists = FALSE;
+ LANGID langid;
+
+ if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("Keyboard Layout\\Preload"),
+ 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS)
+ {
+ dwSize = sizeof(szLayoutNum);
+
+ while (RegEnumValue(hKey, dwIndex, szLayoutNum, &dwSize, NULL, &dwType,
NULL, NULL) == ERROR_SUCCESS)
+ {
+ dwSize = sizeof(szPreload);
+ if (RegQueryValueEx(hKey, szLayoutNum, NULL, NULL, (LPBYTE)szPreload,
&dwSize) != ERROR_SUCCESS)
+ {
+ RegCloseKey(hKey);
+ return FALSE;
+ }
+
+ langid = (LANGID)_tcstoul(szPreload, NULL, 16);
+ GetLocaleInfo(langid, LOCALE_ILANGUAGE, szTmp, sizeof(szTmp) /
sizeof(TCHAR));
+ wsprintf(szOldLangID, _T("0000%s"), szTmp);
+
+ if (_tcscmp(szOldLangID, szLangID) == 0) IsLangExists = TRUE;
+
+ if (szPreload[0] == 'd')
+ {
+ if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("Keyboard
Layout\\Substitutes"),
+ 0, KEY_QUERY_VALUE, &hSubKey) == ERROR_SUCCESS)
+ {
+ dwSize = sizeof(szTmp);
+ RegQueryValueEx(hSubKey, szPreload, NULL, NULL, (LPBYTE)szTmp,
&dwSize);
+
+ if ((_tcscmp(szTmp, szLayoutID) == 0)&&(IsLangExists))
+ {
+ RegCloseKey(hSubKey);
+ RegCloseKey(hKey);
+ return TRUE;
+ }
+ }
+ }
+ else
+ {
+ if (_tcscmp(szPreload, szLayoutID) == 0)
+ {
+ RegCloseKey(hKey);
+ return TRUE;
+ }
+ }
+
+ IsLangExists = FALSE;
+ dwSize = sizeof(szLayoutNum);
+ dwIndex++;
+ }
+
+ RegCloseKey(hKey);
+ }
+
+ return FALSE;
}
static HICON
@@ -314,7 +380,7 @@
LVITEM item;
HKEY hKey, hSubKey;
HWND hLayoutList = GetDlgItem(MainDlgWnd, IDC_KEYLAYOUT_LIST);
- TCHAR szLayoutNum[10 + 1], szTitle[MAX_PATH],
+ TCHAR szLayoutNum[3 + 1], szTitle[MAX_PATH],
szConf[MAX_PATH], szPreload[CCH_LAYOUT_ID + 1];
DWORD dwSize;
@@ -369,11 +435,39 @@
}
static VOID
+SetDefaultLayout()
+{
+ HKL hKl;
+ TCHAR szLCID[CCH_LAYOUT_ID + 1], szLayoutNum[CCH_ULONG_DEC + 1];
+ LVITEM item;
+ INT LayoutNum;
+
+ if (IsLayoutSelected() != -1)
+ {
+ ZeroMemory(&item, sizeof(LVITEM));
+
+ item.mask = LVIF_PARAM;
+ item.iItem = IsLayoutSelected();
+
+ (VOID) ListView_GetItem(GetDlgItem(MainDlgWnd, IDC_KEYLAYOUT_LIST), &item);
+
+ LayoutNum = (INT) item.lParam;
+ _ultot(LayoutNum, szLayoutNum, 10);
+
+ if (GetLayoutID(szLayoutNum, szLCID))
+ {
+ hKl = LoadKeyboardLayout(szLCID, KLF_ACTIVATE);
+ SystemParametersInfo(SPI_SETDEFAULTINPUTLANG, 0, &hKl,
SPIF_SENDWININICHANGE);
+ }
+ }
+}
+
+static VOID
SaveInputLang(HWND hDlg)
{
HKEY hKey, hSubKey;
TCHAR szLayoutID[CCH_LAYOUT_ID + 1], szLayoutNum[CCH_ULONG_DEC + 1],
- szPreload[CCH_LAYOUT_ID + 1], LangID[CCH_LAYOUT_ID + 1],
+ szPreload[CCH_LAYOUT_ID + 1], LangID[CCH_LAYOUT_ID + 1], szMessage[MAX_PATH],
Lang[MAX_PATH], SubPath[MAX_PATH];
PTSTR pts;
INT iLayout;
@@ -404,6 +498,15 @@
langid = (LANGID)_tcstoul(szPreload, NULL, 16);
GetLocaleInfo(langid, LOCALE_ILANGUAGE, Lang, sizeof(Lang) / sizeof(TCHAR));
wsprintf(LangID, _T("0000%s"), Lang);
+
+ if (IsLayoutExists(pts, LangID))
+ {
+ LoadString(hApplet, IDS_LAYOUT_EXISTS, szMessage, sizeof(szMessage) /
sizeof(TCHAR));
+ MessageBox(hDlg, szMessage, NULL, MB_OK | MB_ICONINFORMATION);
+
+ RegCloseKey(hKey);
+ return;
+ }
if (szPreload[0] == 'd')
{
@@ -614,7 +717,8 @@
break;
case IDC_SET_DEFAULT:
-
+ SetDefaultLayout();
+ UpdateLayoutsList();
break;
}
break;