aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/windows/identity/ui/credwnd.c19
-rw-r--r--src/windows/identity/ui/notifier.c78
-rw-r--r--src/windows/identity/ui/notifier.h3
3 files changed, 66 insertions, 34 deletions
diff --git a/src/windows/identity/ui/credwnd.c b/src/windows/identity/ui/credwnd.c
index 1148a9b..be2aa64 100644
--- a/src/windows/identity/ui/credwnd.c
+++ b/src/windows/identity/ui/credwnd.c
@@ -3575,11 +3575,30 @@ cw_kmq_wm_dispatch(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
}
else if (m->subtype == KMSG_KCDB_IDENT &&
m->uparam == KCDB_OP_NEW_DEFAULT) {
+ wchar_t idname[KCDB_IDENT_MAXCCH_NAME];
+ khm_size cb;
+ khm_handle defid = NULL;
cw_update_outline(tbl);
cw_update_extents(tbl, TRUE);
InvalidateRect(hwnd, NULL, FALSE);
+ if (KHM_SUCCEEDED(kcdb_identity_get_default(&defid)) &&
+ defid != NULL &&
+ KHM_SUCCEEDED(kcdb_identity_get_name(defid, idname, &cb)) &&
+ idname[0] != L'\0') {
+
+ khm_notify_icon_tooltip(idname);
+
+ } else {
+
+ LoadString(khm_hInstance, IDS_NOTIFY_READY,
+ idname, ARRAYLENGTH(idname));
+ khm_notify_icon_tooltip(idname);
+ }
+
+ if (defid)
+ kcdb_identity_release(defid);
}
else if (m->subtype == KMSG_KCDB_ATTRIB &&
(m->uparam == KCDB_OP_INSERT ||
diff --git a/src/windows/identity/ui/notifier.c b/src/windows/identity/ui/notifier.c
index 3c4a504..84db735 100644
--- a/src/windows/identity/ui/notifier.c
+++ b/src/windows/identity/ui/notifier.c
@@ -114,6 +114,12 @@ alerter_wnd_data * khui_alert_windows = NULL;
/* Notification icon for when there are no alerts to be displayed */
int iid_normal = IDI_NOTIFY_NONE;
+/* Tooltip to use when there are no alerts to be displayed */
+wchar_t tip_normal[128] = L"";
+
+/* Current notifier severity level */
+khm_int32 notifier_severity = KHERR_NONE;
+
/* The alert currently being displayed in a balloon */
khui_alert * balloon_alert = NULL;
@@ -2829,9 +2835,11 @@ void khm_notify_icon_add(void) {
ni.hIcon = LoadIcon(khm_hInstance, MAKEINTRESOURCE(iid_normal));
ni.uCallbackMessage = KHUI_WM_NOTIFIER;
LoadString(khm_hInstance, IDS_NOTIFY_PREFIX, buf, ARRAYLENGTH(buf));
- StringCbCopy(ni.szTip, sizeof(ni.szTip), buf);
+ StringCbCopy(tip_normal, sizeof(tip_normal), buf);
LoadString(khm_hInstance, IDS_NOTIFY_READY, buf, ARRAYLENGTH(buf));
- StringCbCat(ni.szTip, sizeof(ni.szTip), buf);
+ StringCbCat(tip_normal, sizeof(tip_normal), buf);
+
+ StringCbCopy(ni.szTip, sizeof(ni.szTip), tip_normal);
Shell_NotifyIcon(NIM_ADD, &ni);
@@ -2942,17 +2950,45 @@ void khm_notify_icon_change(khm_int32 severity) {
ni.uID = KHUI_NOTIFY_ICON_ID;
ni.uFlags = NIF_ICON | NIF_TIP;
ni.hIcon = LoadIcon(khm_hInstance, MAKEINTRESOURCE(iid));
- LoadString(khm_hInstance, IDS_NOTIFY_PREFIX, buf, ARRAYLENGTH(buf));
- StringCbCopy(ni.szTip, sizeof(ni.szTip), buf);
- if(severity == KHERR_NONE)
- LoadString(khm_hInstance, IDS_NOTIFY_READY, buf, ARRAYLENGTH(buf));
- else
+
+ if (severity == KHERR_NONE) {
+ StringCbCopy(ni.szTip, sizeof(ni.szTip), tip_normal);
+ } else {
+ LoadString(khm_hInstance, IDS_NOTIFY_PREFIX, buf, ARRAYLENGTH(buf));
+ StringCbCopy(ni.szTip, sizeof(ni.szTip), buf);
LoadString(khm_hInstance, IDS_NOTIFY_ATTENTION, buf, ARRAYLENGTH(buf));
- StringCbCat(ni.szTip, sizeof(ni.szTip), buf);
+ StringCbCat(ni.szTip, sizeof(ni.szTip), buf);
+ }
Shell_NotifyIcon(NIM_MODIFY, &ni);
DestroyIcon(ni.hIcon);
+
+ notifier_severity = severity;
+}
+
+void khm_notify_icon_tooltip(wchar_t * s) {
+ wchar_t buf[256];
+
+ LoadString(khm_hInstance, IDS_NOTIFY_PREFIX, buf, ARRAYLENGTH(buf));
+ StringCbCat(buf, sizeof(buf), s);
+
+ StringCbCopy(tip_normal, sizeof(tip_normal), buf);
+
+ if (notifier_severity == KHERR_NONE) {
+ NOTIFYICONDATA ni;
+
+ ZeroMemory(&ni, sizeof(ni));
+
+ ni.cbSize = sizeof(ni);
+ ni.hWnd = hwnd_notifier;
+ ni.uID = KHUI_NOTIFY_ICON_ID;
+ ni.uFlags = NIF_TIP;
+
+ StringCbCopy(ni.szTip, sizeof(ni.szTip), tip_normal);
+
+ Shell_NotifyIcon(NIM_MODIFY, &ni);
+ }
}
void khm_notify_icon_remove(void) {
@@ -3136,29 +3172,3 @@ void khm_exit_notifier(void)
notifier_ready = FALSE;
}
-/***** testing *****/
-
-void
-create_test_alerts(void) {
-
- khui_alert * a;
- int i;
-
- for (i=0; i < 50; i++) {
- wchar_t buf[128];
-
- StringCbPrintf(buf, sizeof(buf), L"Foo bar baz. This is alert number %d", i);
- khui_alert_create_simple(L"Title", buf, KHERR_INFO, &a);
- khui_alert_set_type(a, KHUI_ALERTTYPE_PLUGIN);
- khui_alert_set_suggestion(a, L"This is a suggestion. It is kinda long to see if the word wrapping actually works as we expect it to. Just in case, here's a line feed.\n\nDoes this show up on a different line? Cool!");
-
- khui_alert_add_command(a, KHUI_ACTION_NEW_CRED);
- khui_alert_add_command(a, KHUI_ACTION_CLOSE_APP);
- khui_alert_add_command(a, KHUI_ACTION_PROPERTIES);
- khui_alert_add_command(a, KHUI_ACTION_OPEN_APP);
- khui_alert_add_command(a, KHUI_ACTION_VIEW_REFRESH);
-
- khui_alert_show(a);
- khui_alert_release(a);
- }
-}
diff --git a/src/windows/identity/ui/notifier.h b/src/windows/identity/ui/notifier.h
index 449ad65..2bdbdf7 100644
--- a/src/windows/identity/ui/notifier.h
+++ b/src/windows/identity/ui/notifier.h
@@ -48,6 +48,9 @@ khm_exit_notifier(void);
void
khm_notify_icon_change(khm_int32 severity);
+void
+khm_notify_icon_tooltip(wchar_t * s);
+
void
khm_notify_icon_balloon(khm_int32 severity,
wchar_t * title,