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
This commit is contained in:
Stephan Aßmus 2008-05-06 21:13:00 +00:00
parent fa66c85543
commit 3b41ad8606
2 changed files with 29 additions and 0 deletions

View File

@ -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 -

View File

@ -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<BString> fInterfaces;