Skip to content

Commit f7f9eec

Browse files
committed
WIP: Add a new set of icons for connection states and notifications
- The notification icons and status window and menu item states can now optionally use icons that resemble the main application icon. New icons for five states (disconnected, connecting, connected, connected_with_errors, idle_error) are loaded though we currently use only the first three. TODO: Indicate connected-with-errors state using the corresponding icon, and improve how states are reported when there are multiple connections with conflicting states. Signed-off-by: Selva Nair <[email protected]>
1 parent 4921b1e commit f7f9eec

15 files changed

+46
-5
lines changed

localization.c

+27-3
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include "options.h"
3939
#include "registry.h"
4040
#include "misc.h"
41+
#include "tray.h"
4142

4243
extern options_t o;
4344

@@ -304,8 +305,27 @@ LoadLocalizedIconEx(const UINT iconId, int cxDesired, int cyDesired)
304305
{
305306
LANGID langId = GetGUILanguage();
306307

308+
UINT iconId_pref = iconId;
309+
if (o.use_legacy_icons)
310+
{
311+
switch(iconId)
312+
{
313+
case ID_ICO_CONNECTED:
314+
iconId_pref = ID_ICO_CONNECTED_LEGACY;
315+
break;
316+
case ID_ICO_DISCONNECTED:
317+
case ID_ICO_IDLE_ERR:
318+
iconId_pref = ID_ICO_DISCONNECTED_LEGACY;
319+
break;
320+
case ID_ICO_CONNECTING:
321+
case ID_ICO_CONNECTED_ERR:
322+
iconId_pref = ID_ICO_CONNECTING_LEGACY;
323+
break;
324+
}
325+
}
326+
307327
HICON hIcon =
308-
(HICON) LoadImage (o.hInstance, MAKEINTRESOURCE(iconId),
328+
(HICON) LoadImage (o.hInstance, MAKEINTRESOURCE(iconId_pref),
309329
IMAGE_ICON, cxDesired, cyDesired, LR_DEFAULTSIZE|LR_SHARED);
310330
if (hIcon)
311331
return hIcon;
@@ -316,7 +336,7 @@ LoadLocalizedIconEx(const UINT iconId, int cxDesired, int cyDesired)
316336
* from the first image in the resource
317337
*/
318338
/* find group icon resource */
319-
HRSRC res = FindResourceLang(RT_GROUP_ICON, MAKEINTRESOURCE(iconId), langId);
339+
HRSRC res = FindResourceLang(RT_GROUP_ICON, MAKEINTRESOURCE(iconId_pref), langId);
320340
if (res == NULL)
321341
return NULL;
322342

@@ -553,6 +573,8 @@ GeneralSettingsDlgProc(HWND hwndDlg, UINT msg, UNUSED WPARAM wParam, LPARAM lPar
553573
Button_SetCheck(GetDlgItem(hwndDlg, ID_CHK_PLAP_REG), BST_CHECKED);
554574
if (o.enable_auto_restart)
555575
Button_SetCheck(GetDlgItem(hwndDlg, ID_CHK_AUTO_RESTART), BST_CHECKED);
576+
if (o.use_legacy_icons)
577+
Button_SetCheck(GetDlgItem(hwndDlg, ID_CHK_LEGACY_ICONS), BST_CHECKED);
556578

557579
break;
558580

@@ -601,7 +623,9 @@ GeneralSettingsDlgProc(HWND hwndDlg, UINT msg, UNUSED WPARAM wParam, LPARAM lPar
601623
(Button_GetCheck(GetDlgItem(hwndDlg, ID_CHK_SHOW_SCRIPT_WIN)) == BST_CHECKED);
602624
o.enable_auto_restart =
603625
(Button_GetCheck(GetDlgItem(hwndDlg, ID_CHK_AUTO_RESTART)) == BST_CHECKED);
604-
626+
o.use_legacy_icons =
627+
(Button_GetCheck(GetDlgItem(hwndDlg, ID_CHK_LEGACY_ICONS)) == BST_CHECKED);
628+
CheckAndSetTrayIcon(); /* in case icons changed */
605629

606630
SaveRegistryKeys();
607631

openvpn-gui-res.h

+8
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929
#define ID_ICO_DISCONNECTED 93
3030
#define ID_ICO_EYE 94
3131
#define ID_ICO_EYESTROKE 95
32+
#define ID_ICO_CONNECTED_ERR 94
33+
#define ID_ICO_IDLE_ERR 95
34+
#define ID_ICO_CONNECTED_LEGACY 96
35+
#define ID_ICO_CONNECTING_LEGACY 97
36+
#define ID_ICO_DISCONNECTED_LEGACY 98
3237

3338
/* About Dialog */
3439
#define ID_DLG_ABOUT 100
@@ -127,6 +132,9 @@
127132
#define ID_EDT_PROXY_USER 251
128133
#define ID_EDT_PROXY_PASS 252
129134

135+
/* General Settings continued */
136+
#define ID_CHK_LEGACY_ICONS 260
137+
130138
/* Advanced dialog */
131139
#define ID_DLG_ADVANCED 270
132140
#define ID_TXT_FOLDER 271

options.c

+1
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ InitOptions(options_t *opt)
379379
opt->version = MakeVersion (PACKAGE_VERSION_RESOURCE);
380380
opt->clr_warning = RGB(0xff, 0, 0);
381381
opt->clr_error = RGB(0xff, 0, 0);
382+
opt->use_legacy_icons = 1;
382383
}
383384

384385

options.h

+1
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ typedef struct {
246246
TCHAR *action_arg;
247247
HANDLE session_semaphore;
248248
HANDLE event_log;
249+
DWORD use_legacy_icons;
249250
} options_t;
250251

251252
void InitOptions(options_t *);

registry.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ struct regkey_int {
6767
{L"management_port_offset", &o.mgmt_port_offset, 25340},
6868
{L"enable_peristent_connections", &o.enable_persistent, 2},
6969
{L"enable_auto_restart", &o.enable_auto_restart, 1},
70-
{L"ovpn_engine", &o.ovpn_engine, OPENVPN_ENGINE_OVPN2}
70+
{L"ovpn_engine", &o.ovpn_engine, OPENVPN_ENGINE_OVPN2},
71+
{L"use_legacy_icons", &o.use_legacy_icons, 1},
7172
};
7273

7374
static int

res/connected.ico

-5.21 KB
Binary file not shown.

res/connected_error.ico

4.19 KB
Binary file not shown.

res/connected_old.ico

9.4 KB
Binary file not shown.

res/connecting.ico

-5.21 KB
Binary file not shown.

res/connecting_old.ico

9.4 KB
Binary file not shown.

res/disconnected.ico

-5.21 KB
Binary file not shown.

res/disconnected_old.ico

9.4 KB
Binary file not shown.

res/idle_error.ico

4.19 KB
Binary file not shown.

res/openvpn-gui-res-en.rc

+2-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ BEGIN
178178
GROUPBOX "Startup", 202, 6, 47, 235, 30
179179
AUTOCHECKBOX "Launch on User &Logon", ID_CHK_STARTUP, 17, 59, 100, 12
180180

181-
GROUPBOX "Preferences", ID_GROUPBOX3, 6, 82, 235, 165
181+
GROUPBOX "Preferences", ID_GROUPBOX3, 6, 82, 235, 180
182182
AUTOCHECKBOX "A&ppend to log", ID_CHK_LOG_APPEND, 17, 95, 60, 10
183183
AUTOCHECKBOX "Show script &window", ID_CHK_SHOW_SCRIPT_WIN, 17, 110, 200, 10
184184
AUTOCHECKBOX "S&ilent connection", ID_CHK_SILENT, 17, 125, 200, 10
@@ -193,6 +193,7 @@ BEGIN
193193
AUTORADIOBUTTON "&Disable", ID_RB_BALLOON5, 181, 200, 40, 10
194194
AUTOCHECKBOX "Enable Pre-Logon A&ccess Provider (requires admin access)", ID_CHK_PLAP_REG, 17, 215, 200, 10
195195
AUTOCHECKBOX "Enable auto restart of active connections", ID_CHK_AUTO_RESTART, 17, 230, 200, 10
196+
AUTOCHECKBOX "Use legacy icons", ID_CHK_LEGACY_ICONS, 17, 245, 200, 10
196197
END
197198

198199
/* Advanced Dialog */

res/openvpn-gui-res.rc

+5
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ ID_ICO_CONNECTING ICON DISCARDABLE "connecting.ico"
4040
ID_ICO_DISCONNECTED ICON DISCARDABLE "disconnected.ico"
4141
ID_ICO_EYE ICON DISCARDABLE "eye.ico"
4242
ID_ICO_EYESTROKE ICON DISCARDABLE "eye-stroke.ico"
43+
ID_ICO_CONNECTED_ERR ICON DISCARDABLE "connected_error.ico"
44+
ID_ICO_IDLE_ERR ICON DISCARDABLE "idle_error.ico"
45+
ID_ICO_CONNECTED_LEGACY ICON DISCARDABLE "connected_old.ico"
46+
ID_ICO_CONNECTING_LEGACY ICON DISCARDABLE "connecting_old.ico"
47+
ID_ICO_DISCONNECTED_LEGACY ICON DISCARDABLE "disconnected_old.ico"
4348

4449
#ifdef ENABLE_OVPN3
4550
#define ADVANCED_DIALOG_HEIGHT 320

0 commit comments

Comments
 (0)