From 3b41ad8606a88410702af016bdfea61c3b33a5df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Tue, 6 May 2008 21:13:00 +0000 Subject: [PATCH] Applied patch by Dario Casalinuovo with some changes by myself: The NetworkStatus applet is now able to launch the Network preferences via its contex menu. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25329 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/networkstatus/NetworkStatusView.cpp | 27 ++++++++++++++++++++ src/apps/networkstatus/NetworkStatusView.h | 2 ++ 2 files changed, 29 insertions(+) diff --git a/src/apps/networkstatus/NetworkStatusView.cpp b/src/apps/networkstatus/NetworkStatusView.cpp index 538ea93606..d8a6f0b2d6 100644 --- a/src/apps/networkstatus/NetworkStatusView.cpp +++ b/src/apps/networkstatus/NetworkStatusView.cpp @@ -5,6 +5,7 @@ * Authors: * Axel Dörfler, axeld@pinc-software.de * Hugo Santos, hugosantos@gmail.com + * Dario Casalinuovo */ @@ -62,6 +63,8 @@ const uint32 kMsgShowConfiguration = 'shcf'; const uint32 kMinIconWidth = 16; const uint32 kMinIconHeight = 16; +const uint32 kOpenNetworkPref = 'onwp'; + const bigtime_t kUpdateInterval = 1000000; // every second @@ -232,6 +235,10 @@ NetworkStatusView::MessageReceived(BMessage* message) _ShowConfiguration(message); break; + case kOpenNetworkPref: + _OpenNetworksPreferences(); + break; + case B_ABOUT_REQUESTED: _AboutRequested(); break; @@ -354,6 +361,9 @@ NetworkStatusView::MouseDown(BPoint point) menu->AddSeparatorItem(); menu->AddItem(new BMenuItem("About NetworkStatus" B_UTF8_ELLIPSIS, new BMessage(B_ABOUT_REQUESTED))); + menu->AddItem(new BMenuItem("Open Networks Preferences" B_UTF8_ELLIPSIS, + new BMessage(kOpenNetworkPref))); + if (fInDeskbar) menu->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED))); menu->SetTargetForItems(this); @@ -466,6 +476,23 @@ NetworkStatusView::_Update(bool force) } +void +NetworkStatusView::_OpenNetworksPreferences() +{ + status_t ret = be_roster->Launch("application/x-vnd.Haiku-Network"); + if (ret < B_OK) { + BString errorMessage("Launching the Network preflet failed.\n\n" + "Error: "); + errorMessage << strerror(ret); + BAlert* alert = new BAlert("launch error", errorMessage.String(), + "Ok"); + // asynchronous alert in order to not block replicant host + // application + alert->Go(NULL); + } +} + + // #pragma mark - diff --git a/src/apps/networkstatus/NetworkStatusView.h b/src/apps/networkstatus/NetworkStatusView.h index 5cf2fc951d..c928dfaee7 100644 --- a/src/apps/networkstatus/NetworkStatusView.h +++ b/src/apps/networkstatus/NetworkStatusView.h @@ -4,6 +4,7 @@ * * Authors: * Axel Dörfler, axeld@pinc-software.de + * Dario Casalinuovo */ #ifndef NETWORK_STATUS_VIEW_H #define NETWORK_STATUS_VIEW_H @@ -53,6 +54,7 @@ class NetworkStatusView : public BView { const char* name); int32 _DetermineInterfaceStatus(const char* name); void _Update(bool force = false); + void _OpenNetworksPreferences(); BMessageRunner* fMessageRunner; BObjectList fInterfaces;