Skip to content

Commit 789aeeb

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 c51a37c commit 789aeeb

15 files changed

+46
-5
lines changed

localization.c

Lines changed: 27 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,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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@
2727
#define ID_ICO_CONNECTED 91
2828
#define ID_ICO_CONNECTING 92
2929
#define ID_ICO_DISCONNECTED 93
30+
#define ID_ICO_CONNECTED_ERR 94
31+
#define ID_ICO_IDLE_ERR 95
32+
#define ID_ICO_CONNECTED_LEGACY 96
33+
#define ID_ICO_CONNECTING_LEGACY 97
34+
#define ID_ICO_DISCONNECTED_LEGACY 98
3035

3136
/* About Dialog */
3237
#define ID_DLG_ABOUT 100
@@ -124,6 +129,9 @@
124129
#define ID_EDT_PROXY_USER 251
125130
#define ID_EDT_PROXY_PASS 252
126131

132+
/* General Settings continued */
133+
#define ID_CHK_LEGACY_ICONS 260
134+
127135
/* Advanced dialog */
128136
#define ID_DLG_ADVANCED 270
129137
#define ID_TXT_FOLDER 271

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
@@ -245,6 +245,7 @@ typedef struct {
245245
TCHAR *action_arg;
246246
HANDLE session_semaphore;
247247
HANDLE event_log;
248+
DWORD use_legacy_icons;
248249
} options_t;
249250

250251
void InitOptions(options_t *);

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

-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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ BEGIN
174174
GROUPBOX "Startup", 202, 6, 47, 235, 30
175175
AUTOCHECKBOX "Launch on User &Logon", ID_CHK_STARTUP, 17, 59, 100, 12
176176

177-
GROUPBOX "Preferences", ID_GROUPBOX3, 6, 82, 235, 165
177+
GROUPBOX "Preferences", ID_GROUPBOX3, 6, 82, 235, 180
178178
AUTOCHECKBOX "A&ppend to log", ID_CHK_LOG_APPEND, 17, 95, 60, 10
179179
AUTOCHECKBOX "Show script &window", ID_CHK_SHOW_SCRIPT_WIN, 17, 110, 200, 10
180180
AUTOCHECKBOX "S&ilent connection", ID_CHK_SILENT, 17, 125, 200, 10
@@ -189,6 +189,7 @@ BEGIN
189189
AUTORADIOBUTTON "&Disable", ID_RB_BALLOON5, 181, 200, 40, 10
190190
AUTOCHECKBOX "Enable Pre-Logon A&ccess Provider (requires admin access)", ID_CHK_PLAP_REG, 17, 215, 200, 10
191191
AUTOCHECKBOX "Enable auto restart of active connections", ID_CHK_AUTO_RESTART, 17, 230, 200, 10
192+
AUTOCHECKBOX "Use legacy icons", ID_CHK_LEGACY_ICONS, 17, 245, 200, 10
192193
END
193194

194195
/* Advanced Dialog */

res/openvpn-gui-res.rc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ 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"
42+
ID_ICO_IDLE_ERR ICON DISCARDABLE "idle_error.ico"
43+
ID_ICO_CONNECTED_LEGACY ICON DISCARDABLE "connected_old.ico"
44+
ID_ICO_CONNECTING_LEGACY ICON DISCARDABLE "connecting_old.ico"
45+
ID_ICO_DISCONNECTED_LEGACY ICON DISCARDABLE "disconnected_old.ico"
4146

4247
#ifdef ENABLE_OVPN3
4348
#define ADVANCED_DIALOG_HEIGHT 320

0 commit comments

Comments
 (0)