[haiku-commits] haiku: hrev43825 - src/apps/networkstatus

hrev43825 adds 1 changeset to branch 'master'
old head: 935af17a2f49265d9ad240711ebd6882a6ab21bd
new head: b44d24c0add302a34ae55a305d9bac69b0ee4a1c

----------------------------------------------------------------------------

b44d24c: 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.

                          [ Alexander von Gluck IV <kallisti5@xxxxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev43825
Commit:      b44d24c0add302a34ae55a305d9bac69b0ee4a1c
URL:         http://cgit.haiku-os.org/haiku/commit/?id=b44d24c
Author:      Alexander von Gluck IV <kallisti5@xxxxxxxxxxx>
Date:        Mon Mar  5 22:30:27 2012 UTC

----------------------------------------------------------------------------

2 files changed, 23 insertions(+), 1 deletions(-)
src/apps/networkstatus/NetworkStatusView.cpp |   23 +++++++++++++++++++++-
src/apps/networkstatus/NetworkStatusView.h   |    1 +

----------------------------------------------------------------------------

diff --git a/src/apps/networkstatus/NetworkStatusView.cpp 
b/src/apps/networkstatus/NetworkStatusView.cpp
index b8b9b2a..1dcae82 100644
--- a/src/apps/networkstatus/NetworkStatusView.cpp
+++ b/src/apps/networkstatus/NetworkStatusView.cpp
@@ -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();
+       }
 }
 
 
diff --git a/src/apps/networkstatus/NetworkStatusView.h 
b/src/apps/networkstatus/NetworkStatusView.h
index ef0d17e..9bd6b45 100644
--- a/src/apps/networkstatus/NetworkStatusView.h
+++ b/src/apps/networkstatus/NetworkStatusView.h
@@ -10,6 +10,7 @@
 #define NETWORK_STATUS_VIEW_H
 
 
+#include <Notification.h>
 #include <ObjectList.h>
 #include <View.h>
 


Other related posts: