Show a mark against profiles that are in connecting state

Currently we show a check mark on connected profiles with no
indication on profiles that may be in the connecting state.

Change this by adding a mark against connecting/reconnecting
profiles. The yellow connecting state icon is used to generate
this mark although a custom designed check mark may look better.

In case of nested configs, the parent menus are marked with a tick
mark and only the profile is marked with the connecting icon.

No change in behaviour for profiles that are connected or
disconnected.

Trac #1241

Signed-off-by: Selva Nair <selva.nair@gmail.com>
pull/391/head
Selva Nair 2020-01-26 18:21:17 -05:00
parent bcdda39660
commit 70b07c82d9
3 changed files with 38 additions and 2 deletions

View File

@ -242,7 +242,7 @@ ShowLocalizedMsg(const UINT stringId, ...)
va_end(args);
}
static HICON
HICON
LoadLocalizedIconEx(const UINT iconId, int cxDesired, int cyDesired)
{
LANGID langId = GetGUILanguage();

View File

@ -27,6 +27,7 @@ PTSTR LoadLocalizedString(const UINT, ...);
int LoadLocalizedStringBuf(PTSTR, const int, const UINT, ...);
void ShowLocalizedMsg(const UINT, ...);
int ShowLocalizedMsgEx(const UINT, LPCTSTR, const UINT, ...);
HICON LoadLocalizedIconEx(const UINT, int cx, int cy);
HICON LoadLocalizedIcon(const UINT);
HICON LoadLocalizedSmallIcon(const UINT);
LPCDLGTEMPLATE LocalizedDialogResource(const UINT);

37
tray.c
View File

@ -45,12 +45,32 @@ HMENU hMenu;
HMENU hMenuConn[MAX_CONFIGS];
HMENU hMenuService;
HBITMAP hbmpConnecting;
NOTIFYICONDATA ni;
extern options_t o;
#define USE_NESTED_CONFIG_MENU ((o.config_menu_view == CONFIG_VIEW_AUTO && o.num_configs > 25) \
|| (o.config_menu_view == CONFIG_VIEW_NESTED))
/* Create menu check bitmaps */
static void
CreateBitmaps()
{
if (hbmpConnecting)
return;
int cx = GetSystemMetrics(SM_CXMENUCHECK);
int cy = GetSystemMetrics(SM_CYMENUCHECK);
if (!hbmpConnecting)
{
HICON icon = LoadLocalizedIconEx(ID_ICO_CONNECTING, cx, cy);
ICONINFO iconinfo;
GetIconInfo(icon, &iconinfo);
hbmpConnecting = iconinfo.hbmColor;
}
}
/* Create popup menus */
void
CreatePopupMenus()
@ -61,6 +81,8 @@ CreatePopupMenus()
*/
assert(o.num_groups > 0);
CreateBitmaps();
for (int i = 0; i < o.num_configs; i++)
{
hMenuConn[i] = CreatePopupMenu();
@ -425,7 +447,10 @@ void
SetMenuStatusById(int i, conn_state_t state)
{
connection_t *c = &o.conn[i];
BOOL checked = (state == connected || state == disconnecting);
int checked = 0;
if (state == connected || state == disconnecting) checked = 1;
else if (state != disconnected) checked = 2;
if (o.num_configs == 1)
{
@ -463,6 +488,16 @@ SetMenuStatusById(int i, conn_state_t state)
if (USE_NESTED_CONFIG_MENU && CONFIG_GROUP(c))
parent = CONFIG_GROUP(c);
if (checked == 1)
{
/* Connected: use system-default check mark */
SetMenuItemBitmaps(parent->menu, pos, MF_BYPOSITION, NULL, NULL);
}
else if (checked == 2)
{
/* Connecting: use our custom check mark */
SetMenuItemBitmaps(parent->menu, pos, MF_BYPOSITION, NULL, hbmpConnecting);
}
CheckMenuItem(parent->menu, pos, MF_BYPOSITION | (checked ? MF_CHECKED : MF_UNCHECKED));
PrintDebug(L"Setting state of config %s checked = %d, parent %s, pos %d",