dwDefaultLocaleId = GetSystemDefaultLCID();
- for (pCurrentLocale = LocaleList_Get();
+ for (pCurrentLocale = LocaleList_GetFirst();
pCurrentLocale != NULL;
pCurrentLocale = pCurrentLocale->pNext)
{
dwDefaultLayoutId = GetDefaultLayoutForLocale(dwDefaultLocaleId);
- for (pCurrentLayout = LayoutList_Get();
+ for (pCurrentLayout = LayoutList_GetFirst();
pCurrentLayout != NULL;
pCurrentLayout = pCurrentLayout->pNext)
{
LAYOUT_LIST_NODE *pCurrentLayout;
pCurrentLayout = (LAYOUT_LIST_NODE*)ComboBox_GetItemData(hwndLayoutCombo, iIndex);
+
if (pCurrentLayout != NULL && pCurrentLayout->dwId == dwLayoutId)
{
ComboBox_SetCurSel(hwndLayoutCombo, iIndex);
+ break;
}
}
}
*/
#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;
+}
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)
{
}
-VOID
-InputList_Remove(INPUT_LIST_NODE *pNode)
+static VOID
+InputList_RemoveNode(INPUT_LIST_NODE *pNode)
{
INPUT_LIST_NODE *pCurrent = pNode;
INPUT_LIST_NODE *pNext = pCurrent->pNext;
INPUT_LIST_NODE *pPrev = pCurrent->pPrev;
+ free(pCurrent->pszIndicator);
free(pCurrent);
if (pNext != NULL)
{
INPUT_LIST_NODE *pNext = pCurrent->pNext;
+ free(pCurrent->pszIndicator);
free(pCurrent);
pCurrent = pNext;
if (UnloadKeyboardLayout(pCurrent->hkl))
{
- InputList_Remove(pCurrent);
+ InputList_RemoveNode(pCurrent);
}
}
}
/* 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++;
}
}
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)
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;
+ }
+ }
}
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);
+ }
+ }
}
}
}
INPUT_LIST_NODE*
-InputList_Get(VOID)
+InputList_GetFirst(VOID)
{
return _InputList;
}
HKL hkl;
+ WCHAR *pszIndicator;
+
struct _INPUT_LIST_NODE *pPrev;
struct _INPUT_LIST_NODE *pNext;
} INPUT_LIST_NODE;
VOID
InputList_Add(LOCALE_LIST_NODE *pLocale, LAYOUT_LIST_NODE *pLayout);
+VOID
+InputList_SetDefault(INPUT_LIST_NODE *pNode);
+
VOID
InputList_Remove(INPUT_LIST_NODE *pNode);
InputList_Destroy(VOID);
INPUT_LIST_NODE*
-InputList_Get(VOID);
+InputList_GetFirst(VOID);
*/
#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;
+}
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;
return NULL;
}
- pNew->pszFile = DublicateString(pszFile);
- if (pNew->pszFile == NULL)
- {
- free(pNew->pszName);
- free(pNew);
- return NULL;
- }
-
pNew->dwId = dwId;
pNew->dwSpecialId = dwSpecialId;
LAYOUT_LIST_NODE *pNext = pCurrent->pNext;
free(pCurrent->pszName);
- free(pCurrent->pszFile);
free(pCurrent);
pCurrent = pNext;
{
DWORD dwLayoutId = DWORDfromString(szLayoutId);
- LayoutList_Append(dwLayoutId,
- dwSpecialId,
- szBuffer,
- szFilePath);
+ LayoutList_AppendNode(dwLayoutId, dwSpecialId, szBuffer);
}
}
}
LAYOUT_LIST_NODE*
-LayoutList_Get(VOID)
+LayoutList_GetFirst(VOID)
{
return _LayoutList;
}
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;
LayoutList_GetByHkl(HKL hkl);
LAYOUT_LIST_NODE*
-LayoutList_Get(VOID);
+LayoutList_GetFirst(VOID);
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;
return NULL;
}
- pNew->pszIndicator = DublicateString(pszIndicator);
- if (pNew->pszIndicator == NULL)
- {
- free(pNew->pszName);
- free(pNew);
- return NULL;
- }
-
pNew->dwId = dwId;
if (pCurrent == NULL)
LOCALE_LIST_NODE *pNext = pCurrent->pNext;
free(pCurrent->pszName);
- free(pCurrent->pszIndicator);
free(pCurrent);
pCurrent = pNext;
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);
LOCALE_LIST_NODE*
-LocaleList_Get(VOID)
+LocaleList_GetFirst(VOID)
{
return _LocaleList;
}
typedef struct _LOCALE_LIST_NODE
{
WCHAR *pszName;
- WCHAR *pszIndicator;
+
DWORD dwId;
+
struct _LOCALE_LIST_NODE *pPrev;
struct _LOCALE_LIST_NODE *pNext;
} LOCALE_LIST_NODE;
LocaleList_GetByHkl(HKL hkl);
LOCALE_LIST_NODE*
-LocaleList_Get(VOID);
+LocaleList_GetFirst(VOID);
{
HICON hLayoutIcon;
- hLayoutIcon = CreateLayoutIcon(pInputNode->pLocale->pszIndicator);
+ hLayoutIcon = CreateLayoutIcon(pInputNode->pszIndicator);
if (hLayoutIcon != NULL)
{
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);
+ }
}
}
if (hwndInputList != NULL)
{
- INPUT_LIST_NODE *pCurrentInputNode;
WCHAR szBuffer[MAX_STR_LEN];
HIMAGELIST hLayoutImageList;
LV_COLUMN column;
ListView_SetImageList(hwndInputList, hLayoutImageList, LVSIL_SMALL);
}
- for (pCurrentInputNode = InputList_Get();
- pCurrentInputNode != NULL;
- pCurrentInputNode = pCurrentInputNode->pNext)
- {
- AddToInputListView(hwndInputList, pCurrentInputNode);
- }
+ UpdateInputListView(hwndInputList);
}
}
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;
}