Browse Source

Launch on startup setting

pull/46/head
Leonardo Basilio 9 years ago
parent
commit
ece6aef6a6
  1. 52
      localization.c
  2. 2
      localization.h
  3. 2
      main.c
  4. 1
      openvpn-gui-res.h
  5. 2
      res/openvpn-gui-res-de.rc
  6. 2
      res/openvpn-gui-res-dk.rc
  7. 2
      res/openvpn-gui-res-en.rc
  8. 2
      res/openvpn-gui-res-es.rc
  9. 2
      res/openvpn-gui-res-fi.rc
  10. 2
      res/openvpn-gui-res-fr.rc
  11. 2
      res/openvpn-gui-res-it.rc
  12. 2
      res/openvpn-gui-res-jp.rc
  13. 2
      res/openvpn-gui-res-nl.rc
  14. 2
      res/openvpn-gui-res-no.rc
  15. 2
      res/openvpn-gui-res-pl.rc
  16. 2
      res/openvpn-gui-res-pt.rc
  17. 2
      res/openvpn-gui-res-ru.rc
  18. 2
      res/openvpn-gui-res-se.rc
  19. 2
      res/openvpn-gui-res-tr.rc
  20. 2
      res/openvpn-gui-res-ua.rc
  21. 2
      res/openvpn-gui-res-zh-hant.rc

52
localization.c

@ -354,9 +354,54 @@ FillLangListProc(UNUSED HANDLE module, UNUSED PTSTR type, UNUSED PTSTR stringId,
return TRUE;
}
static BOOL
GetLaunchOnStartup()
{
WCHAR regPath[MAX_PATH], exePath[MAX_PATH];
BOOL result = FALSE;
HKEY regkey;
if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Run", 0, KEY_READ, &regkey) == ERROR_SUCCESS) {
if (GetRegistryValue(regkey, L"OpenVPN-GUI", regPath, MAX_PATH) &&
GetModuleFileNameW(NULL, exePath, MAX_PATH)) {
if (_wcsicmp(regPath, exePath) == 0)
result = TRUE;
}
RegCloseKey(regkey);
}
return result;
}
static void
SetLaunchOnStartup(BOOL value)
{
WCHAR exePath[MAX_PATH];
HKEY regkey;
if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Run", 0, KEY_WRITE, &regkey) == ERROR_SUCCESS) {
if (value) {
if (GetModuleFileNameW(NULL, exePath, MAX_PATH))
SetRegistryValue(regkey, L"OpenVPN-GUI", exePath);
}
else
RegDeleteValue(regkey, L"OpenVPN-GUI");
RegCloseKey(regkey);
}
}
INT_PTR CALLBACK
LanguageSettingsDlgProc(HWND hwndDlg, UINT msg, UNUSED WPARAM wParam, LPARAM lParam)
GeneralSettingsDlgProc(HWND hwndDlg, UINT msg, UNUSED WPARAM wParam, LPARAM lParam)
{
LPPSHNOTIFY psn;
langProcData langData = {
@ -379,6 +424,9 @@ LanguageSettingsDlgProc(HWND hwndDlg, UINT msg, UNUSED WPARAM wParam, LPARAM lPa
/* Clear language id data for the selected item */
ComboBox_SetItemData(langData.languages, ComboBox_GetCurSel(langData.languages), 0);
if (GetLaunchOnStartup())
Button_SetCheck(GetDlgItem(hwndDlg, ID_CHK_STARTUP), BST_CHECKED);
break;
case WM_NOTIFY:
@ -391,6 +439,8 @@ LanguageSettingsDlgProc(HWND hwndDlg, UINT msg, UNUSED WPARAM wParam, LPARAM lPa
if (langId != 0)
SetGUILanguage(langId);
SetLaunchOnStartup(Button_GetCheck(GetDlgItem(hwndDlg, ID_CHK_STARTUP)) == BST_CHECKED);
SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, PSNRET_NOERROR);
return TRUE;
}

2
localization.h

@ -32,6 +32,6 @@ LPCDLGTEMPLATE LocalizedDialogResource(const UINT);
INT_PTR LocalizedDialogBoxParam(const UINT, DLGPROC, const LPARAM);
HWND CreateLocalizedDialogParam(const UINT, DLGPROC, const LPARAM);
HWND CreateLocalizedDialog(const UINT, DLGPROC);
INT_PTR CALLBACK LanguageSettingsDlgProc(HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK GeneralSettingsDlgProc(HWND, UINT, WPARAM, LPARAM);
#endif

2
main.c

@ -486,7 +486,7 @@ ShowSettingsDialog()
psp[page_number].dwFlags = PSP_DLGINDIRECT;
psp[page_number].hInstance = o.hInstance;
psp[page_number].pResource = LocalizedDialogResource(ID_DLG_GENERAL);
psp[page_number].pfnDlgProc = LanguageSettingsDlgProc;
psp[page_number].pfnDlgProc = GeneralSettingsDlgProc;
psp[page_number].lParam = 0;
psp[page_number].pfnCallback = NULL;
++page_number;

1
openvpn-gui-res.h

@ -77,6 +77,7 @@
#define ID_DLG_GENERAL 230
#define ID_CMB_LANGUAGE 231
#define ID_TXT_LANGUAGE 232
#define ID_CHK_STARTUP 233
/* Proxy Auth Dialog */
#define ID_DLG_PROXY_AUTH 250

2
res/openvpn-gui-res-de.rc

@ -130,6 +130,8 @@ BEGIN
GROUPBOX "Benutzeroberfläche", 201, 6, 12, 235, 30
LTEXT "Sprache:", ID_TXT_LANGUAGE, 17, 25, 29, 12
COMBOBOX ID_CMB_LANGUAGE, 51, 23, 177, 400, CBS_DROPDOWNLIST | WS_TABSTOP
GROUPBOX "Startup", 202, 6, 47, 235, 30
AUTOCHECKBOX "Launch on Windows startup", ID_CHK_STARTUP, 17, 59, 200, 12
END
/* About Dialog */

2
res/openvpn-gui-res-dk.rc

@ -131,6 +131,8 @@ BEGIN
GROUPBOX "Brugergrænseflade", 201, 6, 12, 235, 30
LTEXT "Language:", ID_TXT_LANGUAGE, 17, 25, 52, 12
COMBOBOX ID_CMB_LANGUAGE, 57, 23, 171, 400, CBS_DROPDOWNLIST | WS_TABSTOP
GROUPBOX "Startup", 202, 6, 47, 235, 30
AUTOCHECKBOX "Launch on Windows startup", ID_CHK_STARTUP, 17, 59, 200, 12
END
/* About Dialog */

2
res/openvpn-gui-res-en.rc

@ -130,6 +130,8 @@ BEGIN
GROUPBOX "User Interface", 201, 6, 12, 235, 30
LTEXT "Language:", ID_TXT_LANGUAGE, 17, 25, 52, 12
COMBOBOX ID_CMB_LANGUAGE, 57, 23, 171, 400, CBS_DROPDOWNLIST | WS_TABSTOP
GROUPBOX "Startup", 202, 6, 47, 235, 30
AUTOCHECKBOX "Launch on Windows startup", ID_CHK_STARTUP, 17, 59, 200, 12
END
/* About Dialog */

2
res/openvpn-gui-res-es.rc

@ -129,6 +129,8 @@ BEGIN
GROUPBOX "Interfaz del Usuario", 201, 6, 12, 235, 30
LTEXT "Idioma:", ID_TXT_LANGUAGE, 17, 25, 52, 12
COMBOBOX ID_CMB_LANGUAGE, 45, 23, 183, 400, CBS_DROPDOWNLIST | WS_TABSTOP
GROUPBOX "Startup", 202, 6, 47, 235, 30
AUTOCHECKBOX "Launch on Windows startup", ID_CHK_STARTUP, 17, 59, 200, 12
END
/* About Dialog */

2
res/openvpn-gui-res-fi.rc

@ -131,6 +131,8 @@ BEGIN
GROUPBOX "Käyttöliittymä", 201, 6, 12, 235, 30
LTEXT "Kieli:", ID_TXT_LANGUAGE, 17, 25, 36, 12
COMBOBOX ID_CMB_LANGUAGE, 37, 23, 191, 400, CBS_DROPDOWNLIST | WS_TABSTOP
GROUPBOX "Startup", 202, 6, 47, 235, 30
AUTOCHECKBOX "Launch on Windows startup", ID_CHK_STARTUP, 17, 59, 200, 12
END
/* About Dialog */

2
res/openvpn-gui-res-fr.rc

@ -129,6 +129,8 @@ BEGIN
GROUPBOX "L'interface utilisateur", 201, 6, 12, 235, 30
LTEXT "Langue:", ID_TXT_LANGUAGE, 17, 25, 52, 12
COMBOBOX ID_CMB_LANGUAGE, 47, 23, 181, 400, CBS_DROPDOWNLIST | WS_TABSTOP
GROUPBOX "Startup", 202, 6, 47, 235, 30
AUTOCHECKBOX "Launch on Windows startup", ID_CHK_STARTUP, 17, 59, 200, 12
END
/* About Dialog */

2
res/openvpn-gui-res-it.rc

@ -129,6 +129,8 @@ BEGIN
GROUPBOX "Superficie di Lavoro", 201, 6, 12, 235, 30
LTEXT "Idioma:", ID_TXT_LANGUAGE, 17, 25, 52, 12
COMBOBOX ID_CMB_LANGUAGE, 43, 23, 185, 400, CBS_DROPDOWNLIST | WS_TABSTOP
GROUPBOX "Startup", 202, 6, 47, 235, 30
AUTOCHECKBOX "Launch on Windows startup", ID_CHK_STARTUP, 17, 59, 200, 12
END
/* About Dialog */

2
res/openvpn-gui-res-jp.rc

@ -132,6 +132,8 @@ BEGIN
GROUPBOX "ユーザーインターフェイス", 201, 6, 12, 235, 30
LTEXT "言語:", ID_TXT_LANGUAGE, 17, 25, 52, 12
COMBOBOX ID_CMB_LANGUAGE, 39, 23, 189, 400, CBS_DROPDOWNLIST | WS_TABSTOP
GROUPBOX "Startup", 202, 6, 47, 235, 30
AUTOCHECKBOX "Launch on Windows startup", ID_CHK_STARTUP, 17, 59, 200, 12
END
/* About Dialog */

2
res/openvpn-gui-res-nl.rc

@ -129,6 +129,8 @@ BEGIN
GROUPBOX "Gebruikersinterface", 201, 6, 12, 235, 30
LTEXT "Taal:", ID_TXT_LANGUAGE, 17, 25, 52, 12
COMBOBOX ID_CMB_LANGUAGE, 37, 23, 191, 400, CBS_DROPDOWNLIST | WS_TABSTOP
GROUPBOX "Startup", 202, 6, 47, 235, 30
AUTOCHECKBOX "Launch on Windows startup", ID_CHK_STARTUP, 17, 59, 200, 12
END
/* About Dialog */

2
res/openvpn-gui-res-no.rc

@ -130,6 +130,8 @@ BEGIN
GROUPBOX "Brukergrensesnitt", 201, 6, 12, 235, 30
LTEXT "Språk:", ID_TXT_LANGUAGE, 17, 25, 23, 12
COMBOBOX ID_CMB_LANGUAGE, 42, 23, 186, 400, CBS_DROPDOWNLIST | WS_TABSTOP
GROUPBOX "Startup", 202, 6, 47, 235, 30
AUTOCHECKBOX "Launch on Windows startup", ID_CHK_STARTUP, 17, 59, 200, 12
END
/* About Dialog */

2
res/openvpn-gui-res-pl.rc

@ -131,6 +131,8 @@ BEGIN
GROUPBOX "Interfejs Użytkownika", 201, 6, 12, 235, 30
LTEXT "Język:", ID_TXT_LANGUAGE, 17, 25, 52, 12
COMBOBOX ID_CMB_LANGUAGE, 42, 23, 186, 400, CBS_DROPDOWNLIST | WS_TABSTOP
GROUPBOX "Startup", 202, 6, 47, 235, 30
AUTOCHECKBOX "Launch on Windows startup", ID_CHK_STARTUP, 17, 59, 200, 12
END
/* About Dialog */

2
res/openvpn-gui-res-pt.rc

@ -129,6 +129,8 @@ BEGIN
GROUPBOX "Interface do Usuário", 201, 6, 12, 235, 30
LTEXT "Idioma:", ID_TXT_LANGUAGE, 17, 25, 52, 12
COMBOBOX ID_CMB_LANGUAGE, 57, 23, 171, 400, CBS_DROPDOWNLIST | WS_TABSTOP
GROUPBOX "Inicialização", 202, 6, 47, 235, 30
AUTOCHECKBOX "Executar ao iniciar o Windows", ID_CHK_STARTUP, 17, 59, 200, 12
END
/* About Dialog */

2
res/openvpn-gui-res-ru.rc

@ -131,6 +131,8 @@ BEGIN
GROUPBOX "Интерфейс пользователя", 201, 6, 12, 235, 30
LTEXT "Язык:", ID_TXT_LANGUAGE, 17, 25, 23, 12
COMBOBOX ID_CMB_LANGUAGE, 42, 23, 186, 400, CBS_DROPDOWNLIST | WS_TABSTOP
GROUPBOX "Startup", 202, 6, 47, 235, 30
AUTOCHECKBOX "Launch on Windows startup", ID_CHK_STARTUP, 17, 59, 200, 12
END
/* About Dialog */

2
res/openvpn-gui-res-se.rc

@ -129,6 +129,8 @@ BEGIN
GROUPBOX "Användargränssnitt", 201, 6, 12, 235, 30
LTEXT "Språk:", ID_TXT_LANGUAGE, 17, 25, 52, 12
COMBOBOX ID_CMB_LANGUAGE, 42, 23, 186, 400, CBS_DROPDOWNLIST | WS_TABSTOP
GROUPBOX "Startup", 202, 6, 47, 235, 30
AUTOCHECKBOX "Launch on Windows startup", ID_CHK_STARTUP, 17, 59, 200, 12
END
/* About Dialog */

2
res/openvpn-gui-res-tr.rc

@ -131,6 +131,8 @@ BEGIN
GROUPBOX "Kullanıcı Arayüzü", 201, 6, 12, 235, 30
LTEXT "Dil:", ID_TXT_LANGUAGE, 17, 25, 52, 12
COMBOBOX ID_CMB_LANGUAGE, 31, 23, 197, 400, CBS_DROPDOWNLIST | WS_TABSTOP
GROUPBOX "Startup", 202, 6, 47, 235, 30
AUTOCHECKBOX "Launch on Windows startup", ID_CHK_STARTUP, 17, 59, 200, 12
END
/* About Dialog */

2
res/openvpn-gui-res-ua.rc

@ -129,6 +129,8 @@ BEGIN
GROUPBOX "Інтерфейс користувача", 201, 6, 12, 235, 30
LTEXT "Мова:", ID_TXT_LANGUAGE, 17, 25, 23, 12
COMBOBOX ID_CMB_LANGUAGE, 42, 23, 186, 400, CBS_DROPDOWNLIST | WS_TABSTOP
GROUPBOX "Startup", 202, 6, 47, 235, 30
AUTOCHECKBOX "Launch on Windows startup", ID_CHK_STARTUP, 17, 59, 200, 12
END
/* About Dialog */

2
res/openvpn-gui-res-zh-hant.rc

@ -131,6 +131,8 @@ BEGIN
GROUPBOX "使用者介面", 201, 6, 12, 235, 30
LTEXT "語言:", ID_TXT_LANGUAGE, 17, 25, 52, 12
COMBOBOX ID_CMB_LANGUAGE, 40, 23, 188, 400, CBS_DROPDOWNLIST | WS_TABSTOP
GROUPBOX "Startup", 202, 6, 47, 235, 30
AUTOCHECKBOX "Launch on Windows startup", ID_CHK_STARTUP, 17, 59, 200, 12
END
/* About Dialog */

Loading…
Cancel
Save