Author: dchapyshev
Date: Tue Aug 9 14:01:52 2016
New Revision: 72166
URL:
http://svn.reactos.org/svn/reactos?rev=72166&view=rev
Log:
[INPUT]
- Implement 'Remove', 'Set Default' for input methods
Modified:
trunk/reactos/dll/cpl/input_new/add_dialog.c
trunk/reactos/dll/cpl/input_new/edit_dialog.c
trunk/reactos/dll/cpl/input_new/input.h
trunk/reactos/dll/cpl/input_new/input_list.c
trunk/reactos/dll/cpl/input_new/input_list.h
trunk/reactos/dll/cpl/input_new/key_settings_dialog.c
trunk/reactos/dll/cpl/input_new/layout_list.c
trunk/reactos/dll/cpl/input_new/layout_list.h
trunk/reactos/dll/cpl/input_new/locale_list.c
trunk/reactos/dll/cpl/input_new/locale_list.h
trunk/reactos/dll/cpl/input_new/settings_page.c
Modified: trunk/reactos/dll/cpl/input_new/add_dialog.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/input_new/add_dial…
==============================================================================
--- trunk/reactos/dll/cpl/input_new/add_dialog.c [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/input_new/add_dialog.c [iso-8859-1] Tue Aug 9 14:01:52 2016
@@ -71,7 +71,7 @@
dwDefaultLocaleId = GetSystemDefaultLCID();
- for (pCurrentLocale = LocaleList_Get();
+ for (pCurrentLocale = LocaleList_GetFirst();
pCurrentLocale != NULL;
pCurrentLocale = pCurrentLocale->pNext)
{
@@ -86,7 +86,7 @@
dwDefaultLayoutId = GetDefaultLayoutForLocale(dwDefaultLocaleId);
- for (pCurrentLayout = LayoutList_Get();
+ for (pCurrentLayout = LayoutList_GetFirst();
pCurrentLayout != NULL;
pCurrentLayout = pCurrentLayout->pNext)
{
@@ -158,9 +158,11 @@
LAYOUT_LIST_NODE *pCurrentLayout;
pCurrentLayout =
(LAYOUT_LIST_NODE*)ComboBox_GetItemData(hwndLayoutCombo, iIndex);
+
if (pCurrentLayout != NULL && pCurrentLayout->dwId ==
dwLayoutId)
{
ComboBox_SetCurSel(hwndLayoutCombo, iIndex);
+ break;
}
}
}
Modified: trunk/reactos/dll/cpl/input_new/edit_dialog.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/input_new/edit_dia…
==============================================================================
--- trunk/reactos/dll/cpl/input_new/edit_dialog.c [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/input_new/edit_dialog.c [iso-8859-1] Tue Aug 9 14:01:52 2016
@@ -6,3 +6,33 @@
*/
#include "input.h"
+
+
+INT_PTR CALLBACK
+EditDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ UNREFERENCED_PARAMETER(lParam);
+
+ switch (uMsg)
+ {
+ case WM_INITDIALOG:
+ break;
+
+ case WM_COMMAND:
+ {
+ switch (LOWORD(wParam))
+ {
+ case IDOK:
+ EndDialog(hDlg, LOWORD(wParam));
+ break;
+
+ case IDCANCEL:
+ EndDialog(hDlg, LOWORD(wParam));
+ break;
+ }
+ }
+ break;
+ }
+
+ return FALSE;
+}
Modified: trunk/reactos/dll/cpl/input_new/input.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/input_new/input.h?…
==============================================================================
--- trunk/reactos/dll/cpl/input_new/input.h [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/input_new/input.h [iso-8859-1] Tue Aug 9 14:01:52 2016
@@ -51,6 +51,15 @@
INT_PTR CALLBACK
AddDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
+/* edit_dialog.c */
+INT_PTR CALLBACK
+EditDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
+
+/* key_settings_dialog.c */
+INT_PTR CALLBACK
+KeySettingsDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
+
+
static inline WCHAR*
DublicateString(const WCHAR *pszString)
{
Modified: trunk/reactos/dll/cpl/input_new/input_list.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/input_new/input_li…
==============================================================================
--- trunk/reactos/dll/cpl/input_new/input_list.c [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/input_new/input_list.c [iso-8859-1] Tue Aug 9 14:01:52 2016
@@ -44,8 +44,8 @@
}
-VOID
-InputList_Remove(INPUT_LIST_NODE *pNode)
+static VOID
+InputList_RemoveNode(INPUT_LIST_NODE *pNode)
{
INPUT_LIST_NODE *pCurrent = pNode;
@@ -57,6 +57,7 @@
INPUT_LIST_NODE *pNext = pCurrent->pNext;
INPUT_LIST_NODE *pPrev = pCurrent->pPrev;
+ free(pCurrent->pszIndicator);
free(pCurrent);
if (pNext != NULL)
@@ -84,6 +85,7 @@
{
INPUT_LIST_NODE *pNext = pCurrent->pNext;
+ free(pCurrent->pszIndicator);
free(pCurrent);
pCurrent = pNext;
@@ -234,7 +236,7 @@
if (UnloadKeyboardLayout(pCurrent->hkl))
{
- InputList_Remove(pCurrent);
+ InputList_RemoveNode(pCurrent);
}
}
@@ -267,12 +269,16 @@
}
/* Add methods to registry */
- for (pCurrent = _InputList, dwIndex = 2; pCurrent != NULL; pCurrent =
pCurrent->pNext, dwIndex++)
+ dwIndex = 2;
+
+ for (pCurrent = _InputList; pCurrent != NULL; pCurrent = pCurrent->pNext)
{
if (pCurrent->dwFlags & INPUT_LIST_NODE_FLAG_DEFAULT)
continue;
InputList_AddInputMethodToUserRegistry(dwIndex, pCurrent);
+
+ dwIndex++;
}
}
@@ -280,6 +286,7 @@
VOID
InputList_Add(LOCALE_LIST_NODE *pLocale, LAYOUT_LIST_NODE *pLayout)
{
+ WCHAR szIndicator[MAX_STR_LEN];
INPUT_LIST_NODE *pInput;
if (pLocale == NULL || pLayout == NULL)
@@ -293,6 +300,64 @@
pInput->pLocale = pLocale;
pInput->pLayout = pLayout;
+
+ if (GetLocaleInfoW(LOWORD(pInput->pLocale->dwId),
+ LOCALE_SABBREVLANGNAME | LOCALE_NOUSEROVERRIDE,
+ szIndicator,
+ ARRAYSIZE(szIndicator)))
+ {
+ size_t len = wcslen(szIndicator);
+
+ if (len > 0)
+ {
+ szIndicator[len - 1] = 0;
+ pInput->pszIndicator = DublicateString(szIndicator);
+ }
+ }
+}
+
+
+VOID
+InputList_SetDefault(INPUT_LIST_NODE *pNode)
+{
+ INPUT_LIST_NODE *pCurrent;
+
+ if (pNode == NULL)
+ return;
+
+ for (pCurrent = _InputList; pCurrent != NULL; pCurrent = pCurrent->pNext)
+ {
+ if (pCurrent == pNode)
+ {
+ pCurrent->dwFlags |= INPUT_LIST_NODE_FLAG_DEFAULT;
+ }
+ else
+ {
+ pCurrent->dwFlags &= ~INPUT_LIST_NODE_FLAG_DEFAULT;
+ }
+ }
+}
+
+
+VOID
+InputList_Remove(INPUT_LIST_NODE *pNode)
+{
+ if (pNode == NULL)
+ return;
+
+ pNode->dwFlags |= INPUT_LIST_NODE_FLAG_DELETED;
+
+ if (pNode->dwFlags & INPUT_LIST_NODE_FLAG_DEFAULT)
+ {
+ if (pNode->pNext != NULL)
+ {
+ pNode->pNext->dwFlags |= INPUT_LIST_NODE_FLAG_DEFAULT;
+ }
+ else if (pNode->pPrev != NULL)
+ {
+ pNode->pPrev->dwFlags |= INPUT_LIST_NODE_FLAG_DEFAULT;
+ }
+ }
}
@@ -318,14 +383,42 @@
if (pLocale != NULL && pLayout != NULL)
{
+ WCHAR szIndicator[MAX_STR_LEN] = { 0 };
INPUT_LIST_NODE *pInput;
+ HKL hklDefault;
pInput = InputList_AppendNode();
- pInput->dwFlags = 0;
pInput->pLocale = pLocale;
pInput->pLayout = pLayout;
pInput->hkl = pLayoutList[iIndex];
+
+ if (SystemParametersInfoW(SPI_GETDEFAULTINPUTLANG,
+ 0,
+ (LPVOID)((LPDWORD)&hklDefault),
+ 0) == FALSE)
+ {
+ hklDefault = GetKeyboardLayout(0);
+ }
+
+ if (pInput->hkl == hklDefault)
+ {
+ pInput->dwFlags |= INPUT_LIST_NODE_FLAG_DEFAULT;
+ }
+
+ if (GetLocaleInfoW(LOWORD(pInput->pLocale->dwId),
+ LOCALE_SABBREVLANGNAME | LOCALE_NOUSEROVERRIDE,
+ szIndicator,
+ ARRAYSIZE(szIndicator)))
+ {
+ size_t len = wcslen(szIndicator);
+
+ if (len > 0)
+ {
+ szIndicator[len - 1] = 0;
+ pInput->pszIndicator = DublicateString(szIndicator);
+ }
+ }
}
}
}
@@ -336,7 +429,7 @@
INPUT_LIST_NODE*
-InputList_Get(VOID)
+InputList_GetFirst(VOID)
{
return _InputList;
}
Modified: trunk/reactos/dll/cpl/input_new/input_list.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/input_new/input_li…
==============================================================================
--- trunk/reactos/dll/cpl/input_new/input_list.h [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/input_new/input_list.h [iso-8859-1] Tue Aug 9 14:01:52 2016
@@ -20,6 +20,8 @@
HKL hkl;
+ WCHAR *pszIndicator;
+
struct _INPUT_LIST_NODE *pPrev;
struct _INPUT_LIST_NODE *pNext;
} INPUT_LIST_NODE;
@@ -35,10 +37,13 @@
InputList_Add(LOCALE_LIST_NODE *pLocale, LAYOUT_LIST_NODE *pLayout);
VOID
+InputList_SetDefault(INPUT_LIST_NODE *pNode);
+
+VOID
InputList_Remove(INPUT_LIST_NODE *pNode);
VOID
InputList_Destroy(VOID);
INPUT_LIST_NODE*
-InputList_Get(VOID);
+InputList_GetFirst(VOID);
Modified: trunk/reactos/dll/cpl/input_new/key_settings_dialog.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/input_new/key_sett…
==============================================================================
--- trunk/reactos/dll/cpl/input_new/key_settings_dialog.c [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/input_new/key_settings_dialog.c [iso-8859-1] Tue Aug 9 14:01:52
2016
@@ -6,3 +6,33 @@
*/
#include "input.h"
+
+
+INT_PTR CALLBACK
+KeySettingsDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ UNREFERENCED_PARAMETER(lParam);
+
+ switch (uMsg)
+ {
+ case WM_INITDIALOG:
+ break;
+
+ case WM_COMMAND:
+ {
+ switch (LOWORD(wParam))
+ {
+ case IDOK:
+ EndDialog(hDlg, LOWORD(wParam));
+ break;
+
+ case IDCANCEL:
+ EndDialog(hDlg, LOWORD(wParam));
+ break;
+ }
+ }
+ break;
+ }
+
+ return FALSE;
+}
Modified: trunk/reactos/dll/cpl/input_new/layout_list.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/input_new/layout_l…
==============================================================================
--- trunk/reactos/dll/cpl/input_new/layout_list.c [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/input_new/layout_list.c [iso-8859-1] Tue Aug 9 14:01:52 2016
@@ -12,12 +12,12 @@
static LAYOUT_LIST_NODE*
-LayoutList_Append(DWORD dwId, DWORD dwSpecialId, const WCHAR *pszName, const WCHAR
*pszFile)
+LayoutList_AppendNode(DWORD dwId, DWORD dwSpecialId, const WCHAR *pszName)
{
LAYOUT_LIST_NODE *pCurrent;
LAYOUT_LIST_NODE *pNew;
- if (pszName == NULL || pszFile == NULL)
+ if (pszName == NULL)
return NULL;
pCurrent = _LayoutList;
@@ -35,14 +35,6 @@
return NULL;
}
- pNew->pszFile = DublicateString(pszFile);
- if (pNew->pszFile == NULL)
- {
- free(pNew->pszName);
- free(pNew);
- return NULL;
- }
-
pNew->dwId = dwId;
pNew->dwSpecialId = dwSpecialId;
@@ -80,7 +72,6 @@
LAYOUT_LIST_NODE *pNext = pCurrent->pNext;
free(pCurrent->pszName);
- free(pCurrent->pszFile);
free(pCurrent);
pCurrent = pNext;
@@ -163,10 +154,7 @@
{
DWORD dwLayoutId = DWORDfromString(szLayoutId);
- LayoutList_Append(dwLayoutId,
- dwSpecialId,
- szBuffer,
- szFilePath);
+ LayoutList_AppendNode(dwLayoutId, dwSpecialId, szBuffer);
}
}
}
@@ -215,7 +203,7 @@
LAYOUT_LIST_NODE*
-LayoutList_Get(VOID)
+LayoutList_GetFirst(VOID)
{
return _LayoutList;
}
Modified: trunk/reactos/dll/cpl/input_new/layout_list.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/input_new/layout_l…
==============================================================================
--- trunk/reactos/dll/cpl/input_new/layout_list.h [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/input_new/layout_list.h [iso-8859-1] Tue Aug 9 14:01:52 2016
@@ -5,9 +5,10 @@
typedef struct _LAYOUT_LIST_NODE
{
WCHAR *pszName;
- WCHAR *pszFile;
+
DWORD dwId;
DWORD dwSpecialId;
+
struct _LAYOUT_LIST_NODE *pPrev;
struct _LAYOUT_LIST_NODE *pNext;
} LAYOUT_LIST_NODE;
@@ -22,4 +23,4 @@
LayoutList_GetByHkl(HKL hkl);
LAYOUT_LIST_NODE*
-LayoutList_Get(VOID);
+LayoutList_GetFirst(VOID);
Modified: trunk/reactos/dll/cpl/input_new/locale_list.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/input_new/locale_l…
==============================================================================
--- trunk/reactos/dll/cpl/input_new/locale_list.c [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/input_new/locale_list.c [iso-8859-1] Tue Aug 9 14:01:52 2016
@@ -12,12 +12,12 @@
static LOCALE_LIST_NODE*
-LocaleList_Append(DWORD dwId, const WCHAR *pszName, const WCHAR *pszIndicator)
+LocaleList_Append(DWORD dwId, const WCHAR *pszName)
{
LOCALE_LIST_NODE *pCurrent;
LOCALE_LIST_NODE *pNew;
- if (pszName == NULL || pszIndicator == NULL)
+ if (pszName == NULL)
return NULL;
pCurrent = _LocaleList;
@@ -31,14 +31,6 @@
pNew->pszName = DublicateString(pszName);
if (pNew->pszName == NULL)
{
- free(pNew);
- return NULL;
- }
-
- pNew->pszIndicator = DublicateString(pszIndicator);
- if (pNew->pszIndicator == NULL)
- {
- free(pNew->pszName);
free(pNew);
return NULL;
}
@@ -79,7 +71,6 @@
LOCALE_LIST_NODE *pNext = pCurrent->pNext;
free(pCurrent->pszName);
- free(pCurrent->pszIndicator);
free(pCurrent);
pCurrent = pNext;
@@ -121,22 +112,7 @@
LOCALE_SLANGUAGE,
szName, ARRAYSIZE(szName)))
{
- WCHAR szIndicator[MAX_STR_LEN] = { 0 };
-
- if (GetLocaleInfoW(LOWORD(dwId),
- LOCALE_SABBREVLANGNAME | LOCALE_NOUSEROVERRIDE,
- szIndicator,
- ARRAYSIZE(szIndicator)))
- {
- size_t len = wcslen(szIndicator);
-
- if (len > 0)
- {
- szIndicator[len - 1] = 0;
- }
- }
-
- LocaleList_Append(dwId, szName, szIndicator);
+ LocaleList_Append(dwId, szName);
}
dwSize = sizeof(szValue);
@@ -165,7 +141,7 @@
LOCALE_LIST_NODE*
-LocaleList_Get(VOID)
+LocaleList_GetFirst(VOID)
{
return _LocaleList;
}
Modified: trunk/reactos/dll/cpl/input_new/locale_list.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/input_new/locale_l…
==============================================================================
--- trunk/reactos/dll/cpl/input_new/locale_list.h [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/input_new/locale_list.h [iso-8859-1] Tue Aug 9 14:01:52 2016
@@ -5,8 +5,9 @@
typedef struct _LOCALE_LIST_NODE
{
WCHAR *pszName;
- WCHAR *pszIndicator;
+
DWORD dwId;
+
struct _LOCALE_LIST_NODE *pPrev;
struct _LOCALE_LIST_NODE *pNext;
} LOCALE_LIST_NODE;
@@ -21,4 +22,4 @@
LocaleList_GetByHkl(HKL hkl);
LOCALE_LIST_NODE*
-LocaleList_Get(VOID);
+LocaleList_GetFirst(VOID);
Modified: trunk/reactos/dll/cpl/input_new/settings_page.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/input_new/settings…
==============================================================================
--- trunk/reactos/dll/cpl/input_new/settings_page.c [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/input_new/settings_page.c [iso-8859-1] Tue Aug 9 14:01:52 2016
@@ -99,7 +99,7 @@
{
HICON hLayoutIcon;
- hLayoutIcon = CreateLayoutIcon(pInputNode->pLocale->pszIndicator);
+ hLayoutIcon = CreateLayoutIcon(pInputNode->pszIndicator);
if (hLayoutIcon != NULL)
{
@@ -136,11 +136,14 @@
ListView_DeleteAllItems(hwndList);
- for (pCurrentInputNode = InputList_Get();
+ for (pCurrentInputNode = InputList_GetFirst();
pCurrentInputNode != NULL;
pCurrentInputNode = pCurrentInputNode->pNext)
{
- AddToInputListView(hwndList, pCurrentInputNode);
+ if (!(pCurrentInputNode->dwFlags & INPUT_LIST_NODE_FLAG_DELETED))
+ {
+ AddToInputListView(hwndList, pCurrentInputNode);
+ }
}
}
@@ -158,7 +161,6 @@
if (hwndInputList != NULL)
{
- INPUT_LIST_NODE *pCurrentInputNode;
WCHAR szBuffer[MAX_STR_LEN];
HIMAGELIST hLayoutImageList;
LV_COLUMN column;
@@ -191,12 +193,7 @@
ListView_SetImageList(hwndInputList, hLayoutImageList, LVSIL_SMALL);
}
- for (pCurrentInputNode = InputList_Get();
- pCurrentInputNode != NULL;
- pCurrentInputNode = pCurrentInputNode->pNext)
- {
- AddToInputListView(hwndInputList, pCurrentInputNode);
- }
+ UpdateInputListView(hwndInputList);
}
}
@@ -239,25 +236,74 @@
case IDC_REMOVE_BUTTON:
{
- PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
+ HWND hwndList = GetDlgItem(hwndDlg, IDC_KEYLAYOUT_LIST);
+
+ if (hwndList != NULL)
+ {
+ LVITEM item = { 0 };
+
+ item.mask = LVIF_PARAM;
+ item.iItem = ListView_GetNextItem(hwndList, -1, LVNI_SELECTED);
+
+ if (ListView_GetItem(hwndList, &item) != FALSE)
+ {
+ InputList_Remove((INPUT_LIST_NODE*)item.lParam);
+ UpdateInputListView(GetDlgItem(hwndDlg, IDC_KEYLAYOUT_LIST));
+ PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
+ }
+ }
}
break;
case IDC_PROP_BUTTON:
{
-
+ if (DialogBoxW(hApplet,
+ MAKEINTRESOURCEW(IDD_INPUT_LANG_PROP),
+ hwndDlg,
+ EditDialogProc) == IDOK)
+ {
+ UpdateInputListView(GetDlgItem(hwndDlg, IDC_KEYLAYOUT_LIST));
+ PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
+ }
}
break;
case IDC_SET_DEFAULT:
{
- PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
+ HWND hwndList = GetDlgItem(hwndDlg, IDC_KEYLAYOUT_LIST);
+
+ if (hwndList != NULL)
+ {
+ LVITEM item = { 0 };
+
+ item.mask = LVIF_PARAM;
+ item.iItem = ListView_GetNextItem(hwndList, -1, LVNI_SELECTED);
+
+ if (ListView_GetItem(hwndList, &item) != FALSE)
+ {
+ INPUT_LIST_NODE *pSelected;
+
+ pSelected = (INPUT_LIST_NODE*) item.lParam;
+ if (pSelected != NULL)
+ {
+ InputList_SetDefault(pSelected);
+ }
+
+ PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
+ }
+ }
}
break;
case IDC_KEY_SET_BTN:
{
-
+ if (DialogBoxW(hApplet,
+ MAKEINTRESOURCEW(IDD_KEYSETTINGS),
+ hwndDlg,
+ KeySettingsDialogProc) == IDOK)
+ {
+ PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
+ }
}
break;
}