network status: Add notifications for major network events

* Add a notification if the network interface monitored by
  the system tray icon has a major state change.
* This gives users a little feedback on connection state.
* User is only prompted once on each state change.
* TODO: change system tray icons to vector so we can scale
  them up better.
This commit is contained in:
Alexander von Gluck IV 2012-03-05 16:30:27 -06:00
parent 935af17a2f
commit b44d24c0ad
2 changed files with 23 additions and 1 deletions

View File

@ -546,8 +546,29 @@ NetworkStatusView::_Update(bool force)
}
}
if (fStatus != oldStatus)
if (fStatus != oldStatus) {
// A little notification on major status changes for primary interface
BNotification notification(B_INFORMATION_NOTIFICATION);
notification.SetGroup(B_TRANSLATE("Network Status"));
notification.SetTitle(interface.Name());
notification.SetMessageID(interface.Name());
notification.SetIcon(fBitmaps[fStatus]);
if (fStatus == kStatusConnecting) {
notification.SetContent(B_TRANSLATE("Connecting..."));
notification.Send();
} else if (fStatus == kStatusReady && oldStatus == kStatusConnecting) {
notification.SetContent(B_TRANSLATE("Connection Established"));
notification.Send();
} else if (fStatus == kStatusNoLink && oldStatus == kStatusConnecting) {
notification.SetContent(B_TRANSLATE("Connection Failed"));
notification.Send();
} else if (fStatus == kStatusNoLink && oldStatus == kStatusReady) {
notification.SetContent(B_TRANSLATE("Disconnected"));
notification.Send();
}
Invalidate();
}
}

View File

@ -10,6 +10,7 @@
#define NETWORK_STATUS_VIEW_H
#include <Notification.h>
#include <ObjectList.h>
#include <View.h>