Skip to content

Commit 8f8b5bd

Browse files
committed
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 8f8b5bd

18 files changed

+52
-7
lines changed

Makefile.am

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,11 @@ openvpn_gui_RESOURCES = \
7373
res/connected.ico \
7474
res/connecting.ico \
7575
res/disconnected.ico \
76+
res/connected_error.ico \
77+
res/connected_old.ico \
78+
res/connecting_old.ico \
79+
res/disconnected_old.ico \
7680
res/openvpn-gui.ico \
77-
res/reconnecting.ico \
7881
res/eye.ico \
7982
res/eye-stroke.ico \
8083
res/openvpn-gui.manifest \

localization.c

Lines changed: 26 additions & 3 deletions
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,26 @@ 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+
iconId_pref = ID_ICO_DISCONNECTED_LEGACY;
318+
break;
319+
case ID_ICO_CONNECTING:
320+
case ID_ICO_CONNECTED_ERR:
321+
iconId_pref = ID_ICO_CONNECTING_LEGACY;
322+
break;
323+
}
324+
}
325+
307326
HICON hIcon =
308-
(HICON) LoadImage (o.hInstance, MAKEINTRESOURCE(iconId),
327+
(HICON) LoadImage (o.hInstance, MAKEINTRESOURCE(iconId_pref),
309328
IMAGE_ICON, cxDesired, cyDesired, LR_DEFAULTSIZE|LR_SHARED);
310329
if (hIcon)
311330
return hIcon;
@@ -316,7 +335,7 @@ LoadLocalizedIconEx(const UINT iconId, int cxDesired, int cyDesired)
316335
* from the first image in the resource
317336
*/
318337
/* find group icon resource */
319-
HRSRC res = FindResourceLang(RT_GROUP_ICON, MAKEINTRESOURCE(iconId), langId);
338+
HRSRC res = FindResourceLang(RT_GROUP_ICON, MAKEINTRESOURCE(iconId_pref), langId);
320339
if (res == NULL)
321340
return NULL;
322341

@@ -553,6 +572,8 @@ GeneralSettingsDlgProc(HWND hwndDlg, UINT msg, UNUSED WPARAM wParam, LPARAM lPar
553572
Button_SetCheck(GetDlgItem(hwndDlg, ID_CHK_PLAP_REG), BST_CHECKED);
554573
if (o.enable_auto_restart)
555574
Button_SetCheck(GetDlgItem(hwndDlg, ID_CHK_AUTO_RESTART), BST_CHECKED);
575+
if (o.use_legacy_icons)
576+
Button_SetCheck(GetDlgItem(hwndDlg, ID_CHK_LEGACY_ICONS), BST_CHECKED);
556577

557578
break;
558579

@@ -601,7 +622,9 @@ GeneralSettingsDlgProc(HWND hwndDlg, UINT msg, UNUSED WPARAM wParam, LPARAM lPar
601622
(Button_GetCheck(GetDlgItem(hwndDlg, ID_CHK_SHOW_SCRIPT_WIN)) == BST_CHECKED);
602623
o.enable_auto_restart =
603624
(Button_GetCheck(GetDlgItem(hwndDlg, ID_CHK_AUTO_RESTART)) == BST_CHECKED);
604-
625+
o.use_legacy_icons =
626+
(Button_GetCheck(GetDlgItem(hwndDlg, ID_CHK_LEGACY_ICONS)) == BST_CHECKED);
627+
CheckAndSetTrayIcon(); /* in case icons changed */
605628

606629
SaveRegistryKeys();
607630

openvpn-gui-res.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929
#define ID_ICO_DISCONNECTED 93
3030
#define ID_ICO_EYE 94
3131
#define ID_ICO_EYESTROKE 95
32+
#define ID_ICO_CONNECTED_ERR 96
33+
#define ID_ICO_CONNECTED_LEGACY 97
34+
#define ID_ICO_CONNECTING_LEGACY 98
35+
#define ID_ICO_DISCONNECTED_LEGACY 99
3236

3337
/* About Dialog */
3438
#define ID_DLG_ABOUT 100
@@ -127,6 +131,9 @@
127131
#define ID_EDT_PROXY_USER 251
128132
#define ID_EDT_PROXY_PASS 252
129133

134+
/* General Settings continued */
135+
#define ID_CHK_LEGACY_ICONS 260
136+
130137
/* Advanced dialog */
131138
#define ID_DLG_ADVANCED 270
132139
#define ID_TXT_FOLDER 271

openvpn.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ OnStateChange(connection_t *c, char *data)
379379
if (!success)
380380
{
381381
SetDlgItemText(c->hwndStatus, ID_TXT_STATUS, LoadLocalizedString(IDS_NFO_STATE_ROUTE_ERROR));
382+
SetStatusWinIcon(c->hwndStatus, ID_ICO_CONNECTED_ERR);
382383
return;
383384
}
384385

options.c

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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 *);

plap/Makefile.am

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,11 @@ libopenvpn_plap_la_RESOURCES = \
6565
$(top_srcdir)/res/connected.ico \
6666
$(top_srcdir)/res/connecting.ico \
6767
$(top_srcdir)/res/disconnected.ico \
68+
$(top_srcdir)/res/connected_error.ico \
69+
$(top_srcdir)/res/connected_old.ico \
70+
$(top_srcdir)/res/connecting_old.ico \
71+
$(top_srcdir)/res/disconnected_old.ico \
6872
$(top_srcdir)/res/openvpn-gui.ico \
69-
$(top_srcdir)/res/reconnecting.ico \
7073
$(top_srcdir)/res/eye.ico \
7174
$(top_srcdir)/res/eye-stroke.ico \
7275
openvpn-plap-res.rc \

registry.c

Lines changed: 2 additions & 1 deletion
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

3.22 KB
Binary file not shown.

res/connected_error.ico

20.1 KB
Binary file not shown.

res/connected_old.ico

9.4 KB
Binary file not shown.

res/connecting.ico

11 KB
Binary file not shown.
File renamed without changes.

res/disconnected.ico

3.22 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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,12 @@ ID_ICO_APP ICON DISCARDABLE "openvpn-gui.ico"
3838
ID_ICO_CONNECTED ICON DISCARDABLE "connected.ico"
3939
ID_ICO_CONNECTING ICON DISCARDABLE "connecting.ico"
4040
ID_ICO_DISCONNECTED ICON DISCARDABLE "disconnected.ico"
41+
ID_ICO_CONNECTED_ERR ICON DISCARDABLE "connected_error.ico"
4142
ID_ICO_EYE ICON DISCARDABLE "eye.ico"
4243
ID_ICO_EYESTROKE ICON DISCARDABLE "eye-stroke.ico"
44+
ID_ICO_CONNECTED_LEGACY ICON DISCARDABLE "connected_old.ico"
45+
ID_ICO_CONNECTING_LEGACY ICON DISCARDABLE "connecting_old.ico"
46+
ID_ICO_DISCONNECTED_LEGACY ICON DISCARDABLE "disconnected_old.ico"
4347

4448
#ifdef ENABLE_OVPN3
4549
#define ADVANCED_DIALOG_HEIGHT 320

0 commit comments

Comments
 (0)