make sure at least one language is specified without creating a dialog
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@5597 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
0e6e08734d
commit
46a9c50689
1 changed files with 31 additions and 19 deletions
|
@ -23,6 +23,7 @@ int dofont;
|
||||||
int docp;
|
int docp;
|
||||||
|
|
||||||
int langs_num;
|
int langs_num;
|
||||||
|
int visible_langs_num;
|
||||||
|
|
||||||
struct lang {
|
struct lang {
|
||||||
char *name;
|
char *name;
|
||||||
|
@ -38,12 +39,9 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
switch (uMsg) {
|
switch (uMsg) {
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
// add languages
|
// add languages
|
||||||
for (i = langs_num - 1; i >= 0; i--) {
|
for (i = visible_langs_num - 1; i >= 0; i--) {
|
||||||
int cbi;
|
int cbi;
|
||||||
|
|
||||||
if (langs[i].cp != 0 && langs[i].cp != GetACP())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
cbi = SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_ADDSTRING, 0, (LPARAM) langs[i].name);
|
cbi = SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_ADDSTRING, 0, (LPARAM) langs[i].name);
|
||||||
SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_SETITEMDATA, cbi, (LPARAM) langs[i].id);
|
SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_SETITEMDATA, cbi, (LPARAM) langs[i].id);
|
||||||
|
|
||||||
|
@ -52,12 +50,6 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
selected_language = langs[i].name;
|
selected_language = langs[i].name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// empty list box?
|
|
||||||
if (SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_GETCOUNT, 0, 0) == 0) {
|
|
||||||
pushstring("no languages available");
|
|
||||||
EndDialog(hwndDlg, 0);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// select the current language
|
// select the current language
|
||||||
if (selected_language)
|
if (selected_language)
|
||||||
SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_SELECTSTRING, (WPARAM) -1, (LPARAM) selected_language);
|
SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_SELECTSTRING, (WPARAM) -1, (LPARAM) selected_language);
|
||||||
|
@ -171,6 +163,9 @@ void __declspec(dllexport) LangDialog(HWND hwndParent, int string_size,
|
||||||
// zero languages?
|
// zero languages?
|
||||||
if (!langs_num) return;
|
if (!langs_num) return;
|
||||||
|
|
||||||
|
// initialize visible languages count
|
||||||
|
visible_langs_num = 0;
|
||||||
|
|
||||||
// allocate language struct
|
// allocate language struct
|
||||||
langs = (struct lang *)GlobalAlloc(GPTR, langs_num*sizeof(struct lang));
|
langs = (struct lang *)GlobalAlloc(GPTR, langs_num*sizeof(struct lang));
|
||||||
if (!langs) return;
|
if (!langs) return;
|
||||||
|
@ -178,19 +173,29 @@ void __declspec(dllexport) LangDialog(HWND hwndParent, int string_size,
|
||||||
// fill language struct
|
// fill language struct
|
||||||
for (i = 0; i < langs_num; i++) {
|
for (i = 0; i < langs_num; i++) {
|
||||||
if (popstring(temp)) return;
|
if (popstring(temp)) return;
|
||||||
langs[i].name = GlobalAlloc(GPTR, lstrlen(temp)+1);
|
langs[visible_langs_num].name = GlobalAlloc(GPTR, lstrlen(temp)+1);
|
||||||
if (!langs[i].name) return;
|
if (!langs[visible_langs_num].name) return;
|
||||||
lstrcpy(langs[i].name, temp);
|
lstrcpy(langs[visible_langs_num].name, temp);
|
||||||
|
|
||||||
if (popstring(temp)) return;
|
if (popstring(temp)) return;
|
||||||
langs[i].id = GlobalAlloc(GPTR, lstrlen(temp)+1);
|
langs[visible_langs_num].id = GlobalAlloc(GPTR, lstrlen(temp)+1);
|
||||||
if (!langs[i].id) return;
|
if (!langs[visible_langs_num].id) return;
|
||||||
lstrcpy(langs[i].id, temp);
|
lstrcpy(langs[visible_langs_num].id, temp);
|
||||||
|
|
||||||
if (docp)
|
if (docp)
|
||||||
{
|
{
|
||||||
if (popstring(temp)) return;
|
if (popstring(temp)) return;
|
||||||
langs[i].cp = myatoi(temp);
|
langs[visible_langs_num].cp = myatoi(temp);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!docp || langs[visible_langs_num].cp == GetACP() || langs[visible_langs_num].cp == 0)
|
||||||
|
{
|
||||||
|
visible_langs_num++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GlobalFree(langs[visible_langs_num].name);
|
||||||
|
GlobalFree(langs[visible_langs_num].id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,10 +205,17 @@ void __declspec(dllexport) LangDialog(HWND hwndParent, int string_size,
|
||||||
}
|
}
|
||||||
|
|
||||||
// start dialog
|
// start dialog
|
||||||
DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_DIALOG), 0, DialogProc);
|
if (visible_langs_num > 0)
|
||||||
|
{
|
||||||
|
DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_DIALOG), 0, DialogProc);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pushstring("");
|
||||||
|
}
|
||||||
|
|
||||||
// free structs
|
// free structs
|
||||||
for (i = 0; i < langs_num; i++) {
|
for (i = 0; i < visible_langs_num; i++) {
|
||||||
GlobalFree(langs[i].name);
|
GlobalFree(langs[i].name);
|
||||||
GlobalFree(langs[i].id);
|
GlobalFree(langs[i].id);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue