Update NetworkSetup preflet and Interfaces add-on.
Many updates including: * Add translation strings * MAC address in Interface Settings Window * Lots of layout kit improvements, works font sizes 8pt to 18pt. * Add right-click context menu to interfaces list view. * Make the Interfaces list view size a bit bigger. * Wired/Wireless settings use BStringViews instead of BTextViews since they aren't editable. * First interface is selected by default
This commit is contained in:
@@ -1,18 +1,33 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2004-2011 Haiku, Inc. All rights reserved.
|
* Copyright 2004-2013 Haiku, Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Alexander von Gluck, [email protected]
|
* Alexander von Gluck, [email protected]
|
||||||
|
* John Scipione, [email protected]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "InterfaceAddressView.h"
|
#include "InterfaceAddressView.h"
|
||||||
#include "NetworkSettings.h"
|
#include "NetworkSettings.h"
|
||||||
|
|
||||||
|
#include <Catalog.h>
|
||||||
|
#include <ControlLook.h>
|
||||||
#include <LayoutBuilder.h>
|
#include <LayoutBuilder.h>
|
||||||
#include <MenuItem.h>
|
#include <MenuItem.h>
|
||||||
|
#include <MenuField.h>
|
||||||
|
#include <PopUpMenu.h>
|
||||||
|
#include <Screen.h>
|
||||||
|
#include <Size.h>
|
||||||
#include <StringView.h>
|
#include <StringView.h>
|
||||||
|
#include <TextControl.h>
|
||||||
|
|
||||||
|
|
||||||
|
#undef B_TRANSLATION_CONTEXT
|
||||||
|
#define B_TRANSLATION_CONTEXT "IntefaceAddressView"
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark - InterfaceAddressView
|
||||||
|
|
||||||
|
|
||||||
InterfaceAddressView::InterfaceAddressView(BRect frame, int family,
|
InterfaceAddressView::InterfaceAddressView(BRect frame, int family,
|
||||||
@@ -27,26 +42,31 @@ InterfaceAddressView::InterfaceAddressView(BRect frame, int family,
|
|||||||
// Create our controls
|
// Create our controls
|
||||||
fModePopUpMenu = new BPopUpMenu("modes");
|
fModePopUpMenu = new BPopUpMenu("modes");
|
||||||
|
|
||||||
fModePopUpMenu->AddItem(new BMenuItem("Automatic",
|
fModePopUpMenu->AddItem(new BMenuItem(B_TRANSLATE("DHCP"),
|
||||||
new BMessage(M_MODE_AUTO)));
|
new BMessage(M_MODE_AUTO)));
|
||||||
fModePopUpMenu->AddItem(new BMenuItem("Static",
|
fModePopUpMenu->AddItem(new BMenuItem(B_TRANSLATE("Static"),
|
||||||
new BMessage(M_MODE_STATIC)));
|
new BMessage(M_MODE_STATIC)));
|
||||||
fModePopUpMenu->AddSeparatorItem();
|
fModePopUpMenu->AddSeparatorItem();
|
||||||
fModePopUpMenu->AddItem(new BMenuItem("None",
|
fModePopUpMenu->AddItem(new BMenuItem(B_TRANSLATE("Off"),
|
||||||
new BMessage(M_MODE_NONE)));
|
new BMessage(M_MODE_OFF)));
|
||||||
|
|
||||||
fModeField = new BMenuField("Mode:", fModePopUpMenu);
|
fModeField = new BMenuField(B_TRANSLATE("Mode:"), fModePopUpMenu);
|
||||||
fModeField->SetToolTip(BString("The method for obtaining an IP address"));
|
fModeField->SetToolTip(BString(B_TRANSLATE("The method for obtaining an IP address")));
|
||||||
|
|
||||||
fAddressField = new BTextControl("IP Address:", NULL, NULL);
|
float minimumWidth = be_control_look->DefaultItemSpacing() * 16;
|
||||||
fAddressField->SetToolTip(BString("Your internet protocol address"));
|
|
||||||
fNetmaskField = new BTextControl("Netmask:", NULL, NULL);
|
|
||||||
fNetmaskField->SetToolTip(BString("Your netmask (subnet)"));
|
|
||||||
fGatewayField = new BTextControl("Gateway:", NULL, NULL);
|
|
||||||
fGatewayField->SetToolTip(BString("Your gateway (router)"));
|
|
||||||
|
|
||||||
RevertFields();
|
fAddressField = new BTextControl(B_TRANSLATE("IP Address:"), NULL, NULL);
|
||||||
// Do the initial field population
|
fAddressField->SetToolTip(BString(B_TRANSLATE("Your IP address")));
|
||||||
|
fAddressField->TextView()->SetExplicitMinSize(BSize(minimumWidth, B_SIZE_UNSET));
|
||||||
|
fNetmaskField = new BTextControl(B_TRANSLATE("Netmask:"), NULL, NULL);
|
||||||
|
fNetmaskField->SetToolTip(BString(B_TRANSLATE("Your netmask")));
|
||||||
|
fNetmaskField->TextView()->SetExplicitMinSize(BSize(minimumWidth, B_SIZE_UNSET));
|
||||||
|
fGatewayField = new BTextControl(B_TRANSLATE("Gateway:"), NULL, NULL);
|
||||||
|
fGatewayField->SetToolTip(BString(B_TRANSLATE("Your gateway")));
|
||||||
|
fGatewayField->TextView()->SetExplicitMinSize(BSize(minimumWidth, B_SIZE_UNSET));
|
||||||
|
|
||||||
|
Revert();
|
||||||
|
// Populate the fields
|
||||||
|
|
||||||
BLayoutBuilder::Group<>(this)
|
BLayoutBuilder::Group<>(this)
|
||||||
.AddGrid()
|
.AddGrid()
|
||||||
@@ -67,6 +87,9 @@ InterfaceAddressView::~InterfaceAddressView()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark - InterfaceAddressView virtual methods
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
InterfaceAddressView::AttachedToWindow()
|
InterfaceAddressView::AttachedToWindow()
|
||||||
{
|
{
|
||||||
@@ -80,71 +103,109 @@ InterfaceAddressView::MessageReceived(BMessage* message)
|
|||||||
switch (message->what) {
|
switch (message->what) {
|
||||||
case M_MODE_AUTO:
|
case M_MODE_AUTO:
|
||||||
_EnableFields(false);
|
_EnableFields(false);
|
||||||
|
_ShowFields(true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case M_MODE_STATIC:
|
case M_MODE_STATIC:
|
||||||
_EnableFields(true);
|
_EnableFields(true);
|
||||||
|
_ShowFields(true);
|
||||||
break;
|
break;
|
||||||
case M_MODE_NONE:
|
|
||||||
_EnableFields(false);
|
case M_MODE_OFF:
|
||||||
fAddressField->SetText("");
|
fAddressField->SetText("");
|
||||||
fNetmaskField->SetText("");
|
fNetmaskField->SetText("");
|
||||||
fGatewayField->SetText("");
|
fGatewayField->SetText("");
|
||||||
|
_EnableFields(false);
|
||||||
|
_ShowFields(false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
BView::MessageReceived(message);
|
BView::MessageReceived(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark - InterfaceAddressView private methods
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
InterfaceAddressView::_EnableFields(bool enabled)
|
InterfaceAddressView::_EnableFields(bool enable)
|
||||||
{
|
{
|
||||||
fAddressField->SetEnabled(enabled);
|
fAddressField->SetEnabled(enable);
|
||||||
fNetmaskField->SetEnabled(enabled);
|
fNetmaskField->SetEnabled(enable);
|
||||||
fGatewayField->SetEnabled(enabled);
|
fGatewayField->SetEnabled(enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
InterfaceAddressView::_ShowFields(bool show)
|
||||||
|
{
|
||||||
|
if (show) {
|
||||||
|
if (fAddressField->IsHidden())
|
||||||
|
fAddressField->Show();
|
||||||
|
if (fNetmaskField->IsHidden())
|
||||||
|
fNetmaskField->Show();
|
||||||
|
if (fGatewayField->IsHidden())
|
||||||
|
fGatewayField->Show();
|
||||||
|
} else {
|
||||||
|
if (!fAddressField->IsHidden())
|
||||||
|
fAddressField->Hide();
|
||||||
|
if (!fNetmaskField->IsHidden())
|
||||||
|
fNetmaskField->Hide();
|
||||||
|
if (!fGatewayField->IsHidden())
|
||||||
|
fGatewayField->Hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark - InterfaceAddressView public methods
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
InterfaceAddressView::RevertFields()
|
InterfaceAddressView::Revert()
|
||||||
{
|
{
|
||||||
// Populate address fields with current settings
|
// Populate address fields with current settings
|
||||||
|
|
||||||
const char* currMode = fSettings->AutoConfigure(fFamily)
|
int32 mode;
|
||||||
? "Automatic" : "Static";
|
if (fSettings->AutoConfigure(fFamily)) {
|
||||||
|
mode = M_MODE_AUTO;
|
||||||
_EnableFields(!fSettings->AutoConfigure(fFamily));
|
|
||||||
// if Autoconfigured, disable address fields until changed
|
|
||||||
|
|
||||||
if (fSettings->IPAddr(fFamily).IsEmpty()
|
|
||||||
&& !fSettings->AutoConfigure(fFamily))
|
|
||||||
{
|
|
||||||
currMode = "None";
|
|
||||||
_EnableFields(false);
|
_EnableFields(false);
|
||||||
|
_ShowFields(true);
|
||||||
|
} else if (fSettings->IPAddr(fFamily).IsEmpty()) {
|
||||||
|
mode = M_MODE_OFF;
|
||||||
|
_EnableFields(false);
|
||||||
|
_ShowFields(false);
|
||||||
|
} else {
|
||||||
|
mode = M_MODE_STATIC;
|
||||||
|
_EnableFields(true);
|
||||||
|
_ShowFields(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
BMenuItem* item = fModePopUpMenu->FindItem(currMode);
|
BMenuItem* item = fModePopUpMenu->FindItem(mode);
|
||||||
if (item)
|
if (item != NULL)
|
||||||
item->SetMarked(true);
|
item->SetMarked(true);
|
||||||
|
|
||||||
fAddressField->SetText(fSettings->IP(fFamily));
|
if (!fSettings->IPAddr(fFamily).IsEmpty()) {
|
||||||
fNetmaskField->SetText(fSettings->Netmask(fFamily));
|
fAddressField->SetText(fSettings->IP(fFamily));
|
||||||
fGatewayField->SetText(fSettings->Gateway(fFamily));
|
fNetmaskField->SetText(fSettings->Netmask(fFamily));
|
||||||
|
fGatewayField->SetText(fSettings->Gateway(fFamily));
|
||||||
|
}
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
InterfaceAddressView::SaveFields()
|
InterfaceAddressView::Save()
|
||||||
{
|
{
|
||||||
|
BMenuItem* item = fModePopUpMenu->FindMarked();
|
||||||
|
if (item == NULL)
|
||||||
|
return B_ERROR;
|
||||||
|
|
||||||
fSettings->SetIP(fFamily, fAddressField->Text());
|
fSettings->SetIP(fFamily, fAddressField->Text());
|
||||||
fSettings->SetNetmask(fFamily, fNetmaskField->Text());
|
fSettings->SetNetmask(fFamily, fNetmaskField->Text());
|
||||||
fSettings->SetGateway(fFamily, fGatewayField->Text());
|
fSettings->SetGateway(fFamily, fGatewayField->Text());
|
||||||
|
fSettings->SetAutoConfigure(fFamily, item->Command() == M_MODE_AUTO);
|
||||||
BMenuItem* item = fModePopUpMenu->FindItem("Automatic");
|
|
||||||
fSettings->SetAutoConfigure(fFamily, item->IsMarked());
|
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2004-2011 Haiku, Inc. All rights reserved.
|
* Copyright 2004-2013 Haiku, Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Alexander von Gluck, [email protected]
|
* Alexander von Gluck, [email protected]
|
||||||
|
* John Scipione, [email protected]
|
||||||
*/
|
*/
|
||||||
#ifndef INTERFACE_ADDRESS_VIEW_H
|
#ifndef INTERFACE_ADDRESS_VIEW_H
|
||||||
#define INTERFACE_ADDRESS_VIEW_H
|
#define INTERFACE_ADDRESS_VIEW_H
|
||||||
@@ -11,33 +12,37 @@
|
|||||||
|
|
||||||
#include "NetworkSettings.h"
|
#include "NetworkSettings.h"
|
||||||
|
|
||||||
#include <MenuField.h>
|
|
||||||
#include <PopUpMenu.h>
|
|
||||||
#include <Screen.h>
|
|
||||||
#include <TextControl.h>
|
|
||||||
#include <GroupView.h>
|
#include <GroupView.h>
|
||||||
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
M_MODE_AUTO = 'iato',
|
M_MODE_AUTO = 'iato',
|
||||||
M_MODE_STATIC = 'istc',
|
M_MODE_STATIC = 'istc',
|
||||||
M_MODE_NONE = 'inon'
|
M_MODE_OFF = 'ioff'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class BMenuField;
|
||||||
|
class BMessage;
|
||||||
|
class BPopUpMenu;
|
||||||
|
class BRect;
|
||||||
|
class BTextControl;
|
||||||
|
|
||||||
class InterfaceAddressView : public BGroupView {
|
class InterfaceAddressView : public BGroupView {
|
||||||
public:
|
public:
|
||||||
InterfaceAddressView(BRect frame,
|
InterfaceAddressView(BRect frame,
|
||||||
int family, NetworkSettings* settings);
|
int family, NetworkSettings* settings);
|
||||||
virtual ~InterfaceAddressView();
|
virtual ~InterfaceAddressView();
|
||||||
virtual void MessageReceived(BMessage* message);
|
|
||||||
virtual void AttachedToWindow();
|
|
||||||
status_t RevertFields();
|
|
||||||
status_t SaveFields();
|
|
||||||
|
|
||||||
|
virtual void AttachedToWindow();
|
||||||
|
virtual void MessageReceived(BMessage* message);
|
||||||
|
|
||||||
|
status_t Revert();
|
||||||
|
status_t Save();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _EnableFields(bool enabled);
|
void _EnableFields(bool enable);
|
||||||
|
void _ShowFields(bool show);
|
||||||
|
|
||||||
NetworkSettings* fSettings;
|
NetworkSettings* fSettings;
|
||||||
int fFamily;
|
int fFamily;
|
||||||
@@ -50,5 +55,4 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /* INTERFACE_ADDRESS_VIEW_H */
|
#endif // INTERFACE_ADDRESS_VIEW_H
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,33 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2004-2011 Haiku, Inc. All rights reserved.
|
* Copyright 2004-2013 Haiku, Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Alexander von Gluck, [email protected]
|
* Alexander von Gluck, [email protected]
|
||||||
|
* John Scipione, [email protected]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "InterfaceHardwareView.h"
|
#include "InterfaceHardwareView.h"
|
||||||
#include "NetworkSettings.h"
|
#include "NetworkSettings.h"
|
||||||
|
|
||||||
|
#include <Catalog.h>
|
||||||
|
#include <ControlLook.h>
|
||||||
#include <LayoutBuilder.h>
|
#include <LayoutBuilder.h>
|
||||||
|
#include <MenuField.h>
|
||||||
#include <MenuItem.h>
|
#include <MenuItem.h>
|
||||||
|
#include <NetworkAddress.h>
|
||||||
|
#include <Screen.h>
|
||||||
|
#include <Size.h>
|
||||||
|
#include <StringView.h>
|
||||||
|
#include <TextControl.h>
|
||||||
|
|
||||||
|
|
||||||
|
#undef B_TRANSLATION_CONTEXT
|
||||||
|
#define B_TRANSLATION_CONTEXT "IntefaceHardwareView"
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark - InterfaceHardwareView
|
||||||
|
|
||||||
|
|
||||||
InterfaceHardwareView::InterfaceHardwareView(BRect frame,
|
InterfaceHardwareView::InterfaceHardwareView(BRect frame,
|
||||||
@@ -24,22 +40,34 @@ InterfaceHardwareView::InterfaceHardwareView(BRect frame,
|
|||||||
|
|
||||||
// TODO : Small graph of throughput?
|
// TODO : Small graph of throughput?
|
||||||
|
|
||||||
// TODO : Use strings instead of TextControls
|
float minimumWidth = be_control_look->DefaultItemSpacing() * 16;
|
||||||
fStatusField = new BTextControl("Status:", NULL, NULL);
|
|
||||||
fStatusField->SetEnabled(false);
|
|
||||||
fMACField = new BTextControl("MAC Address:", NULL, NULL);
|
|
||||||
fMACField->SetEnabled(false);
|
|
||||||
fSpeedField = new BTextControl("Link Speed:", NULL, NULL);
|
|
||||||
fSpeedField->SetEnabled(false);
|
|
||||||
|
|
||||||
RevertFields();
|
BStringView* status = new BStringView("status label", B_TRANSLATE("Status:"));
|
||||||
// Do the initial field population
|
status->SetAlignment(B_ALIGN_RIGHT);
|
||||||
|
fStatusField = new BStringView("status field", "");
|
||||||
|
fStatusField->SetExplicitMinSize(BSize(minimumWidth, B_SIZE_UNSET));
|
||||||
|
BStringView* macAddress = new BStringView("mac address label",
|
||||||
|
B_TRANSLATE("MAC address:"));
|
||||||
|
macAddress->SetAlignment(B_ALIGN_RIGHT);
|
||||||
|
fMacAddressField = new BStringView("mac address field", "");
|
||||||
|
fMacAddressField->SetExplicitMinSize(BSize(minimumWidth, B_SIZE_UNSET));
|
||||||
|
BStringView* linkSpeed = new BStringView("link speed label",
|
||||||
|
B_TRANSLATE("Link speed:"));
|
||||||
|
linkSpeed->SetAlignment(B_ALIGN_RIGHT);
|
||||||
|
fLinkSpeedField = new BStringView("link speed field", "");
|
||||||
|
fLinkSpeedField->SetExplicitMinSize(BSize(minimumWidth, B_SIZE_UNSET));
|
||||||
|
|
||||||
|
Revert();
|
||||||
|
// Populate the fields
|
||||||
|
|
||||||
BLayoutBuilder::Group<>(this)
|
BLayoutBuilder::Group<>(this)
|
||||||
.AddGrid()
|
.AddGrid()
|
||||||
.AddTextControl(fStatusField, 0, 0, B_ALIGN_RIGHT)
|
.Add(status, 0, 0)
|
||||||
.AddTextControl(fMACField, 0, 1, B_ALIGN_RIGHT)
|
.Add(fStatusField, 1, 0)
|
||||||
.AddTextControl(fSpeedField, 0, 2, B_ALIGN_RIGHT)
|
.Add(macAddress, 0, 1)
|
||||||
|
.Add(fMacAddressField, 1, 1)
|
||||||
|
.Add(linkSpeed, 0, 2)
|
||||||
|
.Add(fLinkSpeedField, 1, 2)
|
||||||
.End()
|
.End()
|
||||||
.AddGlue()
|
.AddGlue()
|
||||||
.SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING,
|
.SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING,
|
||||||
@@ -53,6 +81,9 @@ InterfaceHardwareView::~InterfaceHardwareView()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark - InterfaceHardwareView virtual methods
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
InterfaceHardwareView::AttachedToWindow()
|
InterfaceHardwareView::AttachedToWindow()
|
||||||
{
|
{
|
||||||
@@ -70,26 +101,29 @@ InterfaceHardwareView::MessageReceived(BMessage* message)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark - InterfaceHardwareView public methods
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
InterfaceHardwareView::RevertFields()
|
InterfaceHardwareView::Revert()
|
||||||
{
|
{
|
||||||
// Populate fields with current settings
|
// Populate fields with current settings
|
||||||
if (fSettings->HasLink())
|
if (fSettings->HasLink())
|
||||||
fStatusField->SetText("connected");
|
fStatusField->SetText(B_TRANSLATE("connected"));
|
||||||
else
|
else
|
||||||
fStatusField->SetText("disconnected");
|
fStatusField->SetText(B_TRANSLATE("disconnected"));
|
||||||
|
|
||||||
|
fMacAddressField->SetText(fSettings->HardwareAddress());
|
||||||
|
|
||||||
// TODO : Find how to get link speed
|
// TODO : Find how to get link speed
|
||||||
fSpeedField->SetText("100 Mb/s");
|
fLinkSpeedField->SetText("100 Mb/s");
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
InterfaceHardwareView::SaveFields()
|
InterfaceHardwareView::Save()
|
||||||
{
|
{
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2004-2011 Haiku, Inc. All rights reserved.
|
* Copyright 2004-2013 Haiku, Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Alexander von Gluck, kallisti5@unixzen.com
|
* Alexander von Gluck, kallisti5@unixzen.com
|
||||||
|
* John Scipione, jscipione@gmail.com
|
||||||
*/
|
*/
|
||||||
#ifndef INTERFACE_HARDWARE_VIEW_H
|
#ifndef INTERFACE_HARDWARE_VIEW_H
|
||||||
#define INTERFACE_HARDWARE_VIEW_H
|
#define INTERFACE_HARDWARE_VIEW_H
|
||||||
@@ -11,35 +12,34 @@
|
|||||||
|
|
||||||
#include "NetworkSettings.h"
|
#include "NetworkSettings.h"
|
||||||
|
|
||||||
#include <MenuField.h>
|
|
||||||
#include <PopUpMenu.h>
|
|
||||||
#include <Screen.h>
|
|
||||||
#include <StringView.h>
|
|
||||||
#include <TextControl.h>
|
|
||||||
#include <GroupView.h>
|
#include <GroupView.h>
|
||||||
|
|
||||||
|
|
||||||
|
class BMessage;
|
||||||
|
class BRect;
|
||||||
|
class BStringView;
|
||||||
|
|
||||||
class InterfaceHardwareView : public BGroupView {
|
class InterfaceHardwareView : public BGroupView {
|
||||||
public:
|
public:
|
||||||
InterfaceHardwareView(BRect frame,
|
InterfaceHardwareView(BRect frame,
|
||||||
NetworkSettings* settings);
|
NetworkSettings* settings);
|
||||||
virtual ~InterfaceHardwareView();
|
virtual ~InterfaceHardwareView();
|
||||||
|
|
||||||
virtual void MessageReceived(BMessage* message);
|
virtual void MessageReceived(BMessage* message);
|
||||||
virtual void AttachedToWindow();
|
virtual void AttachedToWindow();
|
||||||
status_t RevertFields();
|
status_t Revert();
|
||||||
status_t SaveFields();
|
status_t Save();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _EnableFields(bool enabled);
|
void _EnableFields(bool enabled);
|
||||||
|
|
||||||
NetworkSettings* fSettings;
|
NetworkSettings* fSettings;
|
||||||
|
|
||||||
BTextControl* fStatusField;
|
BStringView* fStatusField;
|
||||||
BTextControl* fMACField;
|
BStringView* fMacAddressField;
|
||||||
BTextControl* fSpeedField;
|
BStringView* fLinkSpeedField;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /* INTERFACE_HARDWARE_VIEW_H */
|
#endif // INTERFACE_HARDWARE_VIEW_H
|
||||||
|
|
||||||
|
|||||||
@@ -1,55 +1,59 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2004-2011 Haiku, Inc. All rights reserved.
|
* Copyright 2004-2013 Haiku, Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Alexander von Gluck, kallisti5@unixzen.com
|
* Alexander von Gluck, kallisti5@unixzen.com
|
||||||
|
* John Scipione, jscipione@gmail.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "InterfaceWindow.h"
|
#include "InterfaceWindow.h"
|
||||||
|
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
|
#include <Button.h>
|
||||||
#include <stdio.h>
|
#include <Catalog.h>
|
||||||
|
#include <GroupLayout.h>
|
||||||
|
#include <GroupLayoutBuilder.h>
|
||||||
|
#include <TabView.h>
|
||||||
|
|
||||||
|
|
||||||
#undef B_TRANSLATION_CONTEXT
|
#undef B_TRANSLATION_CONTEXT
|
||||||
#define B_TRANSLATION_CONTEXT "NetworkSetupWindow"
|
#define B_TRANSLATION_CONTEXT "InterfaceWindow"
|
||||||
|
|
||||||
|
|
||||||
InterfaceWindow::InterfaceWindow(NetworkSettings* settings)
|
InterfaceWindow::InterfaceWindow(NetworkSettings* settings)
|
||||||
:
|
:
|
||||||
BWindow(BRect(50, 50, 370, 350), "Interface Settings",
|
BWindow(BRect(50, 50, 370, 350), "Interface Settings",
|
||||||
B_TITLED_WINDOW_LOOK, B_MODAL_APP_WINDOW_FEEL,
|
B_FLOATING_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
|
||||||
B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE,
|
B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_RESIZABLE
|
||||||
B_CURRENT_WORKSPACE)
|
| B_AUTO_UPDATE_SIZE_LIMITS, B_CURRENT_WORKSPACE)
|
||||||
{
|
{
|
||||||
fNetworkSettings = settings;
|
fNetworkSettings = settings;
|
||||||
|
|
||||||
fTabView = new BTabView("settings_tabs");
|
fTabView = new BTabView("settings_tabs");
|
||||||
|
fTabView->SetTabWidth(B_WIDTH_FROM_LABEL);
|
||||||
fApplyButton = new BButton("save", B_TRANSLATE("Save"),
|
|
||||||
new BMessage(MSG_IP_SAVE));
|
|
||||||
|
|
||||||
fRevertButton = new BButton("revert", B_TRANSLATE("Revert"),
|
fRevertButton = new BButton("revert", B_TRANSLATE("Revert"),
|
||||||
new BMessage(MSG_IP_REVERT));
|
new BMessage(MSG_IP_REVERT));
|
||||||
|
|
||||||
fTabView->SetResizingMode(B_FOLLOW_ALL);
|
fApplyButton = new BButton("save", B_TRANSLATE("Save"),
|
||||||
// ensure tab container matches window size
|
new BMessage(MSG_IP_SAVE));
|
||||||
|
SetDefaultButton(fApplyButton);
|
||||||
|
|
||||||
_PopulateTabs();
|
_PopulateTabs();
|
||||||
|
|
||||||
SetLayout(new BGroupLayout(B_VERTICAL));
|
SetLayout(new BGroupLayout(B_VERTICAL));
|
||||||
|
|
||||||
AddChild(BGroupLayoutBuilder(B_VERTICAL, 10)
|
AddChild(BGroupLayoutBuilder(B_VERTICAL, B_USE_SMALL_SPACING)
|
||||||
.Add(fTabView)
|
.Add(fTabView)
|
||||||
.AddGroup(B_HORIZONTAL, 5)
|
.AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING)
|
||||||
.AddGlue()
|
|
||||||
.Add(fRevertButton)
|
.Add(fRevertButton)
|
||||||
|
.AddGlue()
|
||||||
.Add(fApplyButton)
|
.Add(fApplyButton)
|
||||||
.End()
|
.End()
|
||||||
.SetInsets(10, 10, 10, 10)
|
.SetInsets(B_USE_SMALL_SPACING, B_USE_SMALL_SPACING,
|
||||||
|
B_USE_SMALL_SPACING, B_USE_SMALL_SPACING)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,21 +69,20 @@ InterfaceWindow::MessageReceived(BMessage* message)
|
|||||||
protocols* supportedFamilies = fNetworkSettings->ProtocolVersions();
|
protocols* supportedFamilies = fNetworkSettings->ProtocolVersions();
|
||||||
|
|
||||||
switch (message->what) {
|
switch (message->what) {
|
||||||
|
|
||||||
case MSG_IP_REVERT:
|
case MSG_IP_REVERT:
|
||||||
for (int index = 0; index < MAX_PROTOCOLS; index++)
|
for (int index = 0; index < MAX_PROTOCOLS; index++) {
|
||||||
{
|
|
||||||
if (supportedFamilies[index].present) {
|
if (supportedFamilies[index].present) {
|
||||||
int inet_id = supportedFamilies[index].inet_id;
|
int inet_id = supportedFamilies[index].inet_id;
|
||||||
fTabIPView[inet_id]->RevertFields();
|
fTabIPView[inet_id]->Revert();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MSG_IP_SAVE:
|
case MSG_IP_SAVE:
|
||||||
for (int index = 0; index < MAX_PROTOCOLS; index++)
|
for (int index = 0; index < MAX_PROTOCOLS; index++) {
|
||||||
{
|
|
||||||
if (supportedFamilies[index].present) {
|
if (supportedFamilies[index].present) {
|
||||||
int inet_id = supportedFamilies[index].inet_id;
|
int inet_id = supportedFamilies[index].inet_id;
|
||||||
fTabIPView[inet_id]->SaveFields();
|
fTabIPView[inet_id]->Save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this->Quit();
|
this->Quit();
|
||||||
@@ -97,15 +100,15 @@ InterfaceWindow::_PopulateTabs()
|
|||||||
BRect frame = fTabView->Bounds();
|
BRect frame = fTabView->Bounds();
|
||||||
protocols* supportedFamilies = fNetworkSettings->ProtocolVersions();
|
protocols* supportedFamilies = fNetworkSettings->ProtocolVersions();
|
||||||
|
|
||||||
BTab* hardwaretab = new BTab;
|
BTab* hardwareTab = new BTab;
|
||||||
fTabHardwareView = new InterfaceHardwareView(frame,
|
fTabHardwareView = new InterfaceHardwareView(frame,
|
||||||
fNetworkSettings);
|
fNetworkSettings);
|
||||||
fTabView->AddTab(fTabHardwareView, hardwaretab);
|
fTabView->AddTab(fTabHardwareView, hardwareTab);
|
||||||
|
|
||||||
if (fNetworkSettings->IsEthernet())
|
if (fNetworkSettings->IsEthernet())
|
||||||
hardwaretab->SetLabel("Wired");
|
hardwareTab->SetLabel(B_TRANSLATE("Wired"));
|
||||||
else
|
else
|
||||||
hardwaretab->SetLabel("Wirless");
|
hardwareTab->SetLabel(B_TRANSLATE("Wirless"));
|
||||||
|
|
||||||
for (int index = 0; index < MAX_PROTOCOLS; index++)
|
for (int index = 0; index < MAX_PROTOCOLS; index++)
|
||||||
{
|
{
|
||||||
@@ -128,4 +131,3 @@ InterfaceWindow::QuitRequested()
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2004-2011 Haiku, Inc. All rights reserved.
|
* Copyright 2004-2013 Haiku, Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Alexander von Gluck, kallisti5@unixzen.com
|
* Alexander von Gluck, kallisti5@unixzen.com
|
||||||
|
* John Scipione, jscipione@gmail.com
|
||||||
*/
|
*/
|
||||||
#ifndef INTERFACE_WINDOW_H
|
#ifndef INTERFACE_WINDOW_H
|
||||||
#define INTERFACE_WINDOW_H
|
#define INTERFACE_WINDOW_H
|
||||||
@@ -13,15 +14,10 @@
|
|||||||
#include "InterfaceAddressView.h"
|
#include "InterfaceAddressView.h"
|
||||||
#include "InterfaceHardwareView.h"
|
#include "InterfaceHardwareView.h"
|
||||||
|
|
||||||
#include <Button.h>
|
|
||||||
#include <Catalog.h>
|
|
||||||
#include <GroupLayout.h>
|
|
||||||
#include <GroupLayoutBuilder.h>
|
|
||||||
#include <TabView.h>
|
|
||||||
#include <Window.h>
|
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
|
#include <Window.h>
|
||||||
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
MSG_IP_SAVE = 'ipap',
|
MSG_IP_SAVE = 'ipap',
|
||||||
@@ -32,25 +28,30 @@ enum {
|
|||||||
typedef std::map<int, InterfaceAddressView*> IPViewMap;
|
typedef std::map<int, InterfaceAddressView*> IPViewMap;
|
||||||
|
|
||||||
|
|
||||||
|
class BButton;
|
||||||
|
class BTabView;
|
||||||
|
|
||||||
class InterfaceWindow : public BWindow {
|
class InterfaceWindow : public BWindow {
|
||||||
public:
|
public:
|
||||||
InterfaceWindow(NetworkSettings* settings);
|
InterfaceWindow(NetworkSettings* settings);
|
||||||
virtual ~InterfaceWindow();
|
virtual ~InterfaceWindow();
|
||||||
virtual bool QuitRequested();
|
|
||||||
virtual void MessageReceived(BMessage* mesage);
|
virtual void MessageReceived(BMessage* mesage);
|
||||||
|
virtual bool QuitRequested();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
status_t _PopulateTabs();
|
status_t _PopulateTabs();
|
||||||
|
|
||||||
NetworkSettings* fNetworkSettings;
|
NetworkSettings* fNetworkSettings;
|
||||||
BButton* fApplyButton;
|
|
||||||
BButton* fRevertButton;
|
|
||||||
BTabView* fTabView;
|
|
||||||
|
|
||||||
IPViewMap fTabIPView;
|
BButton* fRevertButton;
|
||||||
InterfaceHardwareView* fTabHardwareView;
|
BButton* fApplyButton;
|
||||||
|
|
||||||
|
BTabView* fTabView;
|
||||||
|
|
||||||
|
IPViewMap fTabIPView;
|
||||||
|
InterfaceHardwareView* fTabHardwareView;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /* INTERFACE_WINDOW_H */
|
#endif // INTERFACE_WINDOW_H
|
||||||
|
|
||||||
|
|||||||
@@ -1,30 +1,38 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2004-2011 Haiku, Inc. All rights reserved.
|
* Copyright 2004-2013 Haiku, Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Andre Alves Garzia, andre@andregarzia.com
|
* Stephan Aßmus
|
||||||
* Stephan Assmuß
|
|
||||||
* Axel Dörfler
|
* Axel Dörfler
|
||||||
|
* Andre Alves Garzia, andre@andregarzia.com
|
||||||
|
* Alexander von Gluck, kallisti5@unixzen.com
|
||||||
* Philippe Houdoin
|
* Philippe Houdoin
|
||||||
* Fredrik Modéen
|
* Fredrik Modéen
|
||||||
* Hugo Santos
|
|
||||||
* Philippe Saint-Pierre
|
* Philippe Saint-Pierre
|
||||||
* Alexander von Gluck, kallisti5@unixzen.com
|
* Hugo Santos
|
||||||
|
* John Scipione, jscipione@gmail.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "InterfacesAddOn.h"
|
#include "InterfacesAddOn.h"
|
||||||
#include "InterfaceWindow.h"
|
#include "InterfaceWindow.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include <Alert.h>
|
#include <Alert.h>
|
||||||
|
#include <Button.h>
|
||||||
|
#include <Catalog.h>
|
||||||
|
#include <ControlLook.h>
|
||||||
#include <GroupLayout.h>
|
#include <GroupLayout.h>
|
||||||
#include <GroupLayoutBuilder.h>
|
#include <GroupLayoutBuilder.h>
|
||||||
|
#include <ListItem.h>
|
||||||
|
#include <ListView.h>
|
||||||
#include <ScrollView.h>
|
#include <ScrollView.h>
|
||||||
|
|
||||||
|
|
||||||
|
#undef B_TRANSLATION_CONTEXT
|
||||||
|
#define B_TRANSLATION_CONTEXT "InterfacesAddOn"
|
||||||
|
|
||||||
|
|
||||||
NetworkSetupAddOn*
|
NetworkSetupAddOn*
|
||||||
get_nth_addon(image_id image, int index)
|
get_nth_addon(image_id image, int index)
|
||||||
{
|
{
|
||||||
@@ -60,42 +68,40 @@ InterfacesAddOn::Name()
|
|||||||
BView*
|
BView*
|
||||||
InterfacesAddOn::CreateView(BRect *bounds)
|
InterfacesAddOn::CreateView(BRect *bounds)
|
||||||
{
|
{
|
||||||
BRect intViewRect = *bounds;
|
|
||||||
|
|
||||||
// Construct the ListView
|
// Construct the ListView
|
||||||
fListview = new InterfacesListView(intViewRect,
|
fListView = new InterfacesListView("interfaces");
|
||||||
"interfaces", B_FOLLOW_ALL_SIDES);
|
fListView->SetSelectionMessage(new BMessage(kMsgInterfaceSelected));
|
||||||
fListview->SetSelectionMessage(new BMessage(kMsgInterfaceSelected));
|
fListView->SetInvocationMessage(new BMessage(kMsgInterfaceConfigure));
|
||||||
fListview->SetInvocationMessage(new BMessage(kMsgInterfaceConfigure));
|
|
||||||
|
|
||||||
BScrollView* scrollView = new BScrollView(NULL, fListview,
|
BScrollView* scrollView = new BScrollView("scrollView", fListView,
|
||||||
B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_FRAME_EVENTS, false, true);
|
B_WILL_DRAW | B_FRAME_EVENTS, false, true);
|
||||||
|
|
||||||
// Construct the BButtons
|
// Construct the BButtons
|
||||||
fConfigure = new BButton(intViewRect, "configure",
|
fConfigure = new BButton("configure", B_TRANSLATE("Configure" B_UTF8_ELLIPSIS),
|
||||||
"Configure" B_UTF8_ELLIPSIS, new BMessage(kMsgInterfaceConfigure));
|
new BMessage(kMsgInterfaceConfigure));
|
||||||
fConfigure->SetEnabled(false);
|
fConfigure->SetEnabled(false);
|
||||||
|
|
||||||
fOnOff = new BButton(intViewRect, "onoff", "Disable",
|
fOnOff = new BButton("onoff", B_TRANSLATE("Disable"),
|
||||||
new BMessage(kMsgInterfaceToggle));
|
new BMessage(kMsgInterfaceToggle));
|
||||||
fOnOff->SetEnabled(false);
|
fOnOff->SetEnabled(false);
|
||||||
|
|
||||||
fRenegotiate = new BButton(intViewRect, "heal",
|
fRenegotiate = new BButton("heal", B_TRANSLATE("Renegotiate"),
|
||||||
"Renegotiate", new BMessage(kMsgInterfaceRenegotiate));
|
new BMessage(kMsgInterfaceRenegotiate));
|
||||||
fRenegotiate->SetEnabled(false);
|
fRenegotiate->SetEnabled(false);
|
||||||
|
|
||||||
// Build the layout
|
// Build the layout
|
||||||
SetLayout(new BGroupLayout(B_VERTICAL));
|
SetLayout(new BGroupLayout(B_VERTICAL));
|
||||||
|
|
||||||
AddChild(BGroupLayoutBuilder(B_VERTICAL, 10)
|
AddChild(BGroupLayoutBuilder(B_VERTICAL, B_USE_DEFAULT_SPACING)
|
||||||
.Add(scrollView)
|
.Add(scrollView)
|
||||||
.AddGroup(B_HORIZONTAL, 5)
|
.AddGroup(B_HORIZONTAL, B_USE_SMALL_SPACING)
|
||||||
.Add(fConfigure)
|
.Add(fConfigure)
|
||||||
.Add(fOnOff)
|
.Add(fOnOff)
|
||||||
.AddGlue()
|
.AddGlue()
|
||||||
.Add(fRenegotiate)
|
.Add(fRenegotiate)
|
||||||
.End()
|
.End()
|
||||||
.SetInsets(10, 10, 10, 10)
|
.SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING,
|
||||||
|
B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING)
|
||||||
);
|
);
|
||||||
|
|
||||||
*bounds = Bounds();
|
*bounds = Bounds();
|
||||||
@@ -106,7 +112,7 @@ InterfacesAddOn::CreateView(BRect *bounds)
|
|||||||
void
|
void
|
||||||
InterfacesAddOn::AttachedToWindow()
|
InterfacesAddOn::AttachedToWindow()
|
||||||
{
|
{
|
||||||
fListview->SetTarget(this);
|
fListView->SetTarget(this);
|
||||||
fConfigure->SetTarget(this);
|
fConfigure->SetTarget(this);
|
||||||
fOnOff->SetTarget(this);
|
fOnOff->SetTarget(this);
|
||||||
fRenegotiate->SetTarget(this);
|
fRenegotiate->SetTarget(this);
|
||||||
@@ -117,18 +123,17 @@ status_t
|
|||||||
InterfacesAddOn::Save()
|
InterfacesAddOn::Save()
|
||||||
{
|
{
|
||||||
// TODO : Profile?
|
// TODO : Profile?
|
||||||
return fListview->SaveItems();
|
return fListView->SaveItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
InterfacesAddOn::MessageReceived(BMessage* msg)
|
InterfacesAddOn::MessageReceived(BMessage* msg)
|
||||||
{
|
{
|
||||||
int nr = fListview->CurrentSelection();
|
int nr = fListView->CurrentSelection();
|
||||||
InterfaceListItem *item = NULL;
|
InterfaceListItem *item = NULL;
|
||||||
if (nr != -1) {
|
if (nr != -1)
|
||||||
item = dynamic_cast<InterfaceListItem*>(fListview->ItemAt(nr));
|
item = dynamic_cast<InterfaceListItem*>(fListView->ItemAt(nr));
|
||||||
}
|
|
||||||
|
|
||||||
switch (msg->what) {
|
switch (msg->what) {
|
||||||
case kMsgInterfaceSelected:
|
case kMsgInterfaceSelected:
|
||||||
@@ -136,7 +141,7 @@ InterfacesAddOn::MessageReceived(BMessage* msg)
|
|||||||
fConfigure->SetEnabled(item != NULL);
|
fConfigure->SetEnabled(item != NULL);
|
||||||
fOnOff->SetEnabled(item != NULL);
|
fOnOff->SetEnabled(item != NULL);
|
||||||
fRenegotiate->SetEnabled(item != NULL);
|
fRenegotiate->SetEnabled(item != NULL);
|
||||||
if (!item)
|
if (item == NULL)
|
||||||
break;
|
break;
|
||||||
fConfigure->SetEnabled(!item->IsDisabled());
|
fConfigure->SetEnabled(!item->IsDisabled());
|
||||||
fRenegotiate->SetEnabled(!item->IsDisabled());
|
fRenegotiate->SetEnabled(!item->IsDisabled());
|
||||||
@@ -146,7 +151,7 @@ InterfacesAddOn::MessageReceived(BMessage* msg)
|
|||||||
|
|
||||||
case kMsgInterfaceConfigure:
|
case kMsgInterfaceConfigure:
|
||||||
{
|
{
|
||||||
if (!item)
|
if (item == NULL)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
InterfaceWindow* sw = new InterfaceWindow(item->GetSettings());
|
InterfaceWindow* sw = new InterfaceWindow(item->GetSettings());
|
||||||
@@ -156,20 +161,20 @@ InterfacesAddOn::MessageReceived(BMessage* msg)
|
|||||||
|
|
||||||
case kMsgInterfaceToggle:
|
case kMsgInterfaceToggle:
|
||||||
{
|
{
|
||||||
if (!item)
|
if (item == NULL)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
item->SetDisabled(!item->IsDisabled());
|
item->SetDisabled(!item->IsDisabled());
|
||||||
fConfigure->SetEnabled(!item->IsDisabled());
|
fConfigure->SetEnabled(!item->IsDisabled());
|
||||||
fOnOff->SetLabel(item->IsDisabled() ? "Enable" : "Disable");
|
fOnOff->SetLabel(item->IsDisabled() ? "Enable" : "Disable");
|
||||||
fRenegotiate->SetEnabled(!item->IsDisabled());
|
fRenegotiate->SetEnabled(!item->IsDisabled());
|
||||||
fListview->Invalidate();
|
fListView->Invalidate();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case kMsgInterfaceRenegotiate:
|
case kMsgInterfaceRenegotiate:
|
||||||
{
|
{
|
||||||
if (!item)
|
if (item == NULL)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
NetworkSettings* ns = item->GetSettings();
|
NetworkSettings* ns = item->GetSettings();
|
||||||
|
|||||||
@@ -1,20 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2004-2011 Haiku, Inc. All rights reserved.
|
* Copyright 2004-2013 Haiku, Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
|
* Alexander von Gluck, <kallisti5@unixzen.com>
|
||||||
* Philippe Houdoin
|
* Philippe Houdoin
|
||||||
* Fredrik Modéen
|
* Fredrik Modéen
|
||||||
* Alexander von Gluck, <kallisti5@unixzen.com>
|
* John Scipione, jscipione@gmail.com
|
||||||
*/
|
*/
|
||||||
#ifndef INTERFACES_ADDON_H
|
#ifndef INTERFACES_ADDON_H
|
||||||
#define INTERFACES_ADDON_H
|
#define INTERFACES_ADDON_H
|
||||||
|
|
||||||
|
|
||||||
#include <Box.h>
|
#include <Box.h>
|
||||||
#include <ListView.h>
|
|
||||||
#include <ListItem.h>
|
|
||||||
#include <Button.h>
|
|
||||||
|
|
||||||
#include "NetworkSetupAddOn.h"
|
#include "NetworkSetupAddOn.h"
|
||||||
#include "InterfacesListView.h"
|
#include "InterfacesListView.h"
|
||||||
@@ -26,6 +24,9 @@ static const uint32 kMsgInterfaceToggle = 'onof';
|
|||||||
static const uint32 kMsgInterfaceRenegotiate = 'redo';
|
static const uint32 kMsgInterfaceRenegotiate = 'redo';
|
||||||
|
|
||||||
|
|
||||||
|
class BButton;
|
||||||
|
class BView;
|
||||||
|
|
||||||
class InterfacesAddOn : public NetworkSetupAddOn, public BBox
|
class InterfacesAddOn : public NetworkSetupAddOn, public BBox
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -41,12 +42,12 @@ public:
|
|||||||
void MessageReceived(BMessage* msg);
|
void MessageReceived(BMessage* msg);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
InterfacesListView* fListview;
|
InterfacesListView* fListView;
|
||||||
BButton* fConfigure;
|
BButton* fConfigure;
|
||||||
BButton* fOnOff;
|
BButton* fOnOff;
|
||||||
BButton* fRenegotiate;
|
BButton* fRenegotiate;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /*INTERFACES_ADDON_H*/
|
#endif // INTERFACES_ADDON_H
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2004-2011 Haiku, Inc. All rights reserved.
|
* Copyright 2004-2013 Haiku, Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
|
* Alexander von Gluck IV, kallisti5@unixzen.com
|
||||||
* Philippe Houdoin
|
* Philippe Houdoin
|
||||||
* Fredrik Modéen
|
* Fredrik Modéen
|
||||||
* Alexander von Gluck IV, kallisti5@unixzen.com
|
* John Scipione, jscipione@gmail.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -19,24 +20,39 @@
|
|||||||
#include <net/if_media.h>
|
#include <net/if_media.h>
|
||||||
#include <net/if_types.h>
|
#include <net/if_types.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
|
#include <net_notifications.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/sockio.h>
|
#include <sys/sockio.h>
|
||||||
|
|
||||||
|
#include <Bitmap.h>
|
||||||
|
#include <Catalog.h>
|
||||||
#include <File.h>
|
#include <File.h>
|
||||||
#include <IconUtils.h>
|
#include <IconUtils.h>
|
||||||
#include <net_notifications.h>
|
#include <MenuItem.h>
|
||||||
#include <NetworkDevice.h>
|
#include <NetworkDevice.h>
|
||||||
#include <NetworkInterface.h>
|
#include <NetworkInterface.h>
|
||||||
#include <NetworkRoster.h>
|
#include <NetworkRoster.h>
|
||||||
|
#include <Point.h>
|
||||||
|
#include <PopUpMenu.h>
|
||||||
#include <Resources.h>
|
#include <Resources.h>
|
||||||
|
#include <String.h>
|
||||||
|
#include <SeparatorItem.h>
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
#include <AutoDeleter.h>
|
#include <AutoDeleter.h>
|
||||||
|
|
||||||
#include "NetworkSettings.h"
|
#include "InterfacesAddOn.h"
|
||||||
|
#include "InterfaceWindow.h"
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
#define ICON_SIZE 37
|
||||||
|
|
||||||
|
|
||||||
|
#undef B_TRANSLATION_CONTEXT
|
||||||
|
#define B_TRANSLATION_CONTEXT "InterfacesListView"
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark - our_image function
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
@@ -53,7 +69,7 @@ our_image(image_info& image)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark - InterfaceListItem
|
||||||
|
|
||||||
|
|
||||||
InterfaceListItem::InterfaceListItem(const char* name)
|
InterfaceListItem::InterfaceListItem(const char* name)
|
||||||
@@ -73,22 +89,7 @@ InterfaceListItem::~InterfaceListItem()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
// #pragma mark - InterfaceListItem public methods
|
||||||
InterfaceListItem::Update(BView* owner, const BFont* font)
|
|
||||||
{
|
|
||||||
BListItem::Update(owner, font);
|
|
||||||
font_height height;
|
|
||||||
font->GetHeight(&height);
|
|
||||||
|
|
||||||
float lineHeight = ceilf(height.ascent) + ceilf(height.descent)
|
|
||||||
+ ceilf(height.leading);
|
|
||||||
|
|
||||||
fFirstlineOffset = 2 + ceilf(height.ascent + height.leading / 2);
|
|
||||||
fSecondlineOffset = fFirstlineOffset + lineHeight;
|
|
||||||
fThirdlineOffset = fFirstlineOffset + (lineHeight * 2);
|
|
||||||
|
|
||||||
SetHeight(3 * lineHeight + 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -96,22 +97,22 @@ InterfaceListItem::DrawItem(BView* owner, BRect /*bounds*/, bool complete)
|
|||||||
{
|
{
|
||||||
BListView* list = dynamic_cast<BListView*>(owner);
|
BListView* list = dynamic_cast<BListView*>(owner);
|
||||||
|
|
||||||
if (!list)
|
if (list == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
owner->PushState();
|
owner->PushState();
|
||||||
|
|
||||||
BRect bounds = list->ItemFrame(list->IndexOf(this));
|
BRect bounds = list->ItemFrame(list->IndexOf(this));
|
||||||
|
|
||||||
rgb_color black = {0, 0, 0, 255};
|
rgb_color highColor = list->HighColor();
|
||||||
|
rgb_color lowColor = list->LowColor();
|
||||||
|
|
||||||
if (IsSelected() || complete) {
|
if (IsSelected() || complete) {
|
||||||
if (IsSelected()) {
|
if (IsSelected()) {
|
||||||
list->SetHighColor(tint_color(list->ViewColor(),
|
list->SetHighColor(ui_color(B_LIST_SELECTED_BACKGROUND_COLOR));
|
||||||
B_HIGHLIGHT_BACKGROUND_TINT));
|
list->SetLowColor(list->HighColor());
|
||||||
} else {
|
} else
|
||||||
list->SetHighColor(list->LowColor());
|
list->SetHighColor(lowColor);
|
||||||
}
|
|
||||||
|
|
||||||
list->FillRect(bounds);
|
list->FillRect(bounds);
|
||||||
}
|
}
|
||||||
@@ -139,18 +140,18 @@ InterfaceListItem::DrawItem(BView* owner, BRect /*bounds*/, bool complete)
|
|||||||
// Set the initial bounds of item contents
|
// Set the initial bounds of item contents
|
||||||
BPoint iconPt = bounds.LeftTop();
|
BPoint iconPt = bounds.LeftTop();
|
||||||
BPoint namePt = bounds.LeftTop();
|
BPoint namePt = bounds.LeftTop();
|
||||||
BPoint v4addrPt = bounds.LeftTop();
|
BPoint line2Pt = bounds.LeftTop();
|
||||||
BPoint v6addrPt = bounds.LeftTop();
|
BPoint line3Pt = bounds.LeftTop();
|
||||||
BPoint statePt = bounds.RightTop();
|
BPoint statePt = bounds.RightTop();
|
||||||
|
|
||||||
iconPt += BPoint(4, 4);
|
iconPt += BPoint(4, 4);
|
||||||
statePt += BPoint(0, fFirstlineOffset);
|
statePt += BPoint(0, fFirstlineOffset);
|
||||||
namePt += BPoint(ICON_SIZE + 12, fFirstlineOffset);
|
namePt += BPoint(ICON_SIZE + 12, fFirstlineOffset);
|
||||||
v4addrPt += BPoint(ICON_SIZE + 12, fSecondlineOffset);
|
line2Pt += BPoint(ICON_SIZE + 12, fSecondlineOffset);
|
||||||
v6addrPt += BPoint(ICON_SIZE + 12, fThirdlineOffset);
|
line3Pt += BPoint(ICON_SIZE + 12, fThirdlineOffset);
|
||||||
|
|
||||||
statePt
|
statePt -= BPoint(
|
||||||
-= BPoint(be_plain_font->StringWidth(interfaceState.String()), 0);
|
be_plain_font->StringWidth(interfaceState.String()) + 4.0f, 0);
|
||||||
|
|
||||||
if (fSettings->IsDisabled()) {
|
if (fSettings->IsDisabled()) {
|
||||||
list->SetDrawingMode(B_OP_ALPHA);
|
list->SetDrawingMode(B_OP_ALPHA);
|
||||||
@@ -162,46 +163,75 @@ InterfaceListItem::DrawItem(BView* owner, BRect /*bounds*/, bool complete)
|
|||||||
list->DrawBitmapAsync(fIcon, iconPt);
|
list->DrawBitmapAsync(fIcon, iconPt);
|
||||||
list->DrawBitmapAsync(stateIcon, iconPt);
|
list->DrawBitmapAsync(stateIcon, iconPt);
|
||||||
|
|
||||||
if (fSettings->IsDisabled())
|
if (fSettings->IsDisabled()) {
|
||||||
list->SetHighColor(tint_color(black, B_LIGHTEN_1_TINT));
|
rgb_color textColor;
|
||||||
else
|
if (IsSelected())
|
||||||
list->SetHighColor(black);
|
textColor = ui_color(B_LIST_SELECTED_ITEM_TEXT_COLOR);
|
||||||
|
else
|
||||||
|
textColor = ui_color(B_LIST_ITEM_TEXT_COLOR);
|
||||||
|
|
||||||
|
if (textColor.red + textColor.green + textColor.blue > 128 * 3)
|
||||||
|
list->SetHighColor(tint_color(textColor, B_DARKEN_1_TINT));
|
||||||
|
else
|
||||||
|
list->SetHighColor(tint_color(textColor, B_LIGHTEN_1_TINT));
|
||||||
|
} else {
|
||||||
|
if (IsSelected())
|
||||||
|
list->SetHighColor(ui_color(B_LIST_SELECTED_ITEM_TEXT_COLOR));
|
||||||
|
else
|
||||||
|
list->SetHighColor(ui_color(B_LIST_ITEM_TEXT_COLOR));
|
||||||
|
}
|
||||||
|
|
||||||
list->SetFont(be_bold_font);
|
list->SetFont(be_bold_font);
|
||||||
list->DrawString(Name(), namePt);
|
list->DrawString(Name(), namePt);
|
||||||
list->SetFont(be_plain_font);
|
list->SetFont(be_plain_font);
|
||||||
|
|
||||||
list->DrawString(interfaceState, statePt);
|
list->DrawString(interfaceState, statePt);
|
||||||
|
|
||||||
if (!fSettings->IsDisabled()) {
|
if (!fSettings->IsDisabled()) {
|
||||||
// Render IPv4 Address
|
// Render IPv4 Address
|
||||||
BString v4str("IPv4: ");
|
BString ipv4Str(B_TRANSLATE_COMMENT("IP:", "IPv4 address label"));
|
||||||
|
|
||||||
if (fSettings->IPAddr(AF_INET).IsEmpty())
|
if (fSettings->IPAddr(AF_INET).IsEmpty())
|
||||||
v4str << "none";
|
ipv4Str << " " << B_TRANSLATE("None");
|
||||||
else {
|
|
||||||
v4str << fSettings->IP(AF_INET);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fSettings->AutoConfigure(AF_INET))
|
|
||||||
v4str << " (DHCP)";
|
|
||||||
else
|
else
|
||||||
v4str << " (static)";
|
ipv4Str << " " << BString(fSettings->IP(AF_INET));
|
||||||
|
|
||||||
list->DrawString(v4str.String(), v4addrPt);
|
list->DrawString(ipv4Str, line2Pt);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Render IPv6 Address (if present)
|
||||||
|
if (!fSettings->IsDisabled()
|
||||||
|
&& !fSettings->IPAddr(AF_INET6).IsEmpty()) {
|
||||||
|
BString ipv6Str(B_TRANSLATE_COMMENT("IPv6:", "IPv6 address label"));
|
||||||
|
ipv6Str << " " << BString(fSettings->IP(AF_INET6));
|
||||||
|
|
||||||
// Render IPv6 Address (if present)
|
list->DrawString(ipv6Str, line3Pt);
|
||||||
if (!fSettings->IPAddr(AF_INET6).IsEmpty()) {
|
|
||||||
BString v6str("IPv6: ");
|
|
||||||
v6str << fSettings->IP(AF_INET6);
|
|
||||||
list->DrawString(v6str, v6addrPt);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
owner->PopState();
|
owner->PopState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
InterfaceListItem::Update(BView* owner, const BFont* font)
|
||||||
|
{
|
||||||
|
BListItem::Update(owner, font);
|
||||||
|
font_height height;
|
||||||
|
font->GetHeight(&height);
|
||||||
|
|
||||||
|
float lineHeight = ceilf(height.ascent) + ceilf(height.descent)
|
||||||
|
+ ceilf(height.leading);
|
||||||
|
|
||||||
|
fFirstlineOffset = 2 + ceilf(height.ascent + height.leading / 2);
|
||||||
|
fSecondlineOffset = fFirstlineOffset + lineHeight;
|
||||||
|
fThirdlineOffset = fFirstlineOffset + (lineHeight * 2);
|
||||||
|
|
||||||
|
SetHeight(max(3 * lineHeight + 4, fIcon->Bounds().Height() + 8));
|
||||||
|
// either to the text height or icon height, whichever is taller
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark - InterfaceListItem private methods
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
InterfaceListItem::_Init()
|
InterfaceListItem::_Init()
|
||||||
{
|
{
|
||||||
@@ -299,17 +329,17 @@ InterfaceListItem::_PopulateBitmaps(const char* mediaType) {
|
|||||||
0, B_RGBA32);
|
0, B_RGBA32);
|
||||||
BIconUtils::GetVectorIcon(onlineHVIF, iconSize, fIconOnline);
|
BIconUtils::GetVectorIcon(onlineHVIF, iconSize, fIconOnline);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark - InterfaceListView
|
||||||
|
|
||||||
|
|
||||||
InterfacesListView::InterfacesListView(BRect rect, const char* name, uint32 resizingMode)
|
InterfacesListView::InterfacesListView(const char* name)
|
||||||
: BListView(rect, name, B_SINGLE_SELECTION_LIST, resizingMode)
|
:
|
||||||
|
BListView(name)
|
||||||
{
|
{
|
||||||
|
fContextMenu = new BPopUpMenu("context menu", false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -318,6 +348,9 @@ InterfacesListView::~InterfacesListView()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark - InterfaceListView protected methods
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
InterfacesListView::AttachedToWindow()
|
InterfacesListView::AttachedToWindow()
|
||||||
{
|
{
|
||||||
@@ -327,12 +360,16 @@ InterfacesListView::AttachedToWindow()
|
|||||||
|
|
||||||
start_watching_network(
|
start_watching_network(
|
||||||
B_WATCH_NETWORK_INTERFACE_CHANGES | B_WATCH_NETWORK_LINK_CHANGES, this);
|
B_WATCH_NETWORK_INTERFACE_CHANGES | B_WATCH_NETWORK_LINK_CHANGES, this);
|
||||||
|
|
||||||
|
Select(0);
|
||||||
|
// Select the first item in the list
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
InterfacesListView::FrameResized(float width, float height)
|
InterfacesListView::FrameResized(float width, float height)
|
||||||
{
|
{
|
||||||
|
BListView::FrameResized(width, height);
|
||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -345,9 +382,9 @@ InterfacesListView::DetachedFromWindow()
|
|||||||
stop_watching_network(this);
|
stop_watching_network(this);
|
||||||
|
|
||||||
// free all items, they will be retrieved again in AttachedToWindow()
|
// free all items, they will be retrieved again in AttachedToWindow()
|
||||||
for (int32 i = CountItems(); i-- > 0;) {
|
for (int32 i = CountItems(); i-- > 0;)
|
||||||
delete ItemAt(i);
|
delete ItemAt(i);
|
||||||
}
|
|
||||||
MakeEmpty();
|
MakeEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -366,7 +403,77 @@ InterfacesListView::MessageReceived(BMessage* message)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
InterfaceListItem *
|
void
|
||||||
|
InterfacesListView::MouseDown(BPoint where)
|
||||||
|
{
|
||||||
|
int32 buttons = 0;
|
||||||
|
Window()->CurrentMessage()->FindInt32("buttons", &buttons);
|
||||||
|
|
||||||
|
if ((B_SECONDARY_MOUSE_BUTTON & buttons) == 0) {
|
||||||
|
// If not secondary mouse button do the default
|
||||||
|
BListView::MouseDown(where);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
InterfaceListItem* item = FindItem(where);
|
||||||
|
if (item == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Remove all items from the menu
|
||||||
|
for (int32 i = fContextMenu->CountItems(); i >= 0; --i) {
|
||||||
|
BMenuItem* menuItem = fContextMenu->RemoveItem(i);
|
||||||
|
delete menuItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now add the ones we want
|
||||||
|
if (item->GetSettings()->IsDisabled()) {
|
||||||
|
fContextMenu->AddItem(new BMenuItem(B_TRANSLATE("Enable"),
|
||||||
|
new BMessage(kMsgInterfaceToggle)));
|
||||||
|
} else {
|
||||||
|
fContextMenu->AddItem(new BMenuItem(
|
||||||
|
B_TRANSLATE("Configure" B_UTF8_ELLIPSIS),
|
||||||
|
new BMessage(kMsgInterfaceConfigure)));
|
||||||
|
if (item->GetSettings()->AutoConfigure(AF_INET)
|
||||||
|
|| item->GetSettings()->AutoConfigure(AF_INET6)) {
|
||||||
|
fContextMenu->AddItem(new BMenuItem(
|
||||||
|
B_TRANSLATE("Renegotiate Address"),
|
||||||
|
new BMessage(kMsgInterfaceRenegotiate)));
|
||||||
|
}
|
||||||
|
fContextMenu->AddItem(new BSeparatorItem());
|
||||||
|
fContextMenu->AddItem(new BMenuItem(B_TRANSLATE("Disable"),
|
||||||
|
new BMessage(kMsgInterfaceToggle)));
|
||||||
|
}
|
||||||
|
|
||||||
|
fContextMenu->ResizeToPreferred();
|
||||||
|
BMenuItem* selected = fContextMenu->Go(ConvertToScreen(where));
|
||||||
|
if (selected == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
switch (selected->Message()->what) {
|
||||||
|
case kMsgInterfaceConfigure:
|
||||||
|
{
|
||||||
|
InterfaceWindow* win = new InterfaceWindow(item->GetSettings());
|
||||||
|
win->MoveTo(ConvertToScreen(where));
|
||||||
|
win->Show();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case kMsgInterfaceToggle:
|
||||||
|
item->SetDisabled(!item->IsDisabled());
|
||||||
|
Invalidate();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case kMsgInterfaceRenegotiate:
|
||||||
|
item->GetSettings()->RenegotiateAddresses();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark - InterfaceListView public methods
|
||||||
|
|
||||||
|
|
||||||
|
InterfaceListItem*
|
||||||
InterfacesListView::FindItem(const char* name)
|
InterfacesListView::FindItem(const char* name)
|
||||||
{
|
{
|
||||||
for (int32 i = CountItems(); i-- > 0;) {
|
for (int32 i = CountItems(); i-- > 0;) {
|
||||||
@@ -382,6 +489,22 @@ InterfacesListView::FindItem(const char* name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
InterfaceListItem*
|
||||||
|
InterfacesListView::FindItem(BPoint where)
|
||||||
|
{
|
||||||
|
for (int32 i = CountItems(); i-- > 0;) {
|
||||||
|
InterfaceListItem* item = dynamic_cast<InterfaceListItem*>(ItemAt(i));
|
||||||
|
if (item == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (ItemFrame(i).Contains(where))
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
InterfacesListView::SaveItems()
|
InterfacesListView::SaveItems()
|
||||||
{
|
{
|
||||||
@@ -403,6 +526,9 @@ InterfacesListView::SaveItems()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark - InterfaceListView private methods
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
InterfacesListView::_InitList()
|
InterfacesListView::_InitList()
|
||||||
{
|
{
|
||||||
@@ -411,9 +537,8 @@ InterfacesListView::_InitList()
|
|||||||
uint32 cookie = 0;
|
uint32 cookie = 0;
|
||||||
|
|
||||||
while (roster.GetNextInterface(&cookie, interface) == B_OK) {
|
while (roster.GetNextInterface(&cookie, interface) == B_OK) {
|
||||||
if (strncmp(interface.Name(), "loop", 4) && interface.Name()[0]) {
|
if (strncmp(interface.Name(), "loop", 4) && interface.Name()[0])
|
||||||
AddItem(new InterfaceListItem(interface.Name()));
|
AddItem(new InterfaceListItem(interface.Name()));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
@@ -447,29 +572,28 @@ InterfacesListView::_HandleNetworkMessage(BMessage* message)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
InterfaceListItem* item = FindItem(name);
|
InterfaceListItem* item = FindItem(name);
|
||||||
if (!item)
|
if (item == NULL)
|
||||||
printf("InterfaceListItem %s not found!\n", name);
|
printf("InterfaceListItem %s not found!\n", name);
|
||||||
|
|
||||||
switch (opcode) {
|
switch (opcode) {
|
||||||
case B_NETWORK_INTERFACE_CHANGED:
|
case B_NETWORK_INTERFACE_CHANGED:
|
||||||
case B_NETWORK_DEVICE_LINK_CHANGED:
|
case B_NETWORK_DEVICE_LINK_CHANGED:
|
||||||
if (item)
|
if (item != NULL)
|
||||||
InvalidateItem(IndexOf(item));
|
InvalidateItem(IndexOf(item));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_NETWORK_INTERFACE_ADDED:
|
case B_NETWORK_INTERFACE_ADDED:
|
||||||
if (item)
|
if (item != NULL)
|
||||||
InvalidateItem(IndexOf(item));
|
InvalidateItem(IndexOf(item));
|
||||||
else
|
else
|
||||||
AddItem(new InterfaceListItem(name));
|
AddItem(new InterfaceListItem(name));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_NETWORK_INTERFACE_REMOVED:
|
case B_NETWORK_INTERFACE_REMOVED:
|
||||||
if (item) {
|
if (item != NULL) {
|
||||||
RemoveItem(item);
|
RemoveItem(item);
|
||||||
delete item;
|
delete item;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,35 +1,30 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2004-2011 Haiku, Inc. All rights reserved.
|
* Copyright 2004-2013 Haiku, Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
|
* Alexander von Gluck, kallisti5@unixzen.com
|
||||||
* Philippe Houdoin
|
* Philippe Houdoin
|
||||||
* Fredrik Modéen
|
* Fredrik Modéen
|
||||||
* Alexander von Gluck, kallisti5@unixzen.com
|
* John Scipione, jscipione@gmail.com
|
||||||
*/
|
*/
|
||||||
#ifndef INTERFACES_LIST_VIEW_H
|
#ifndef INTERFACES_LIST_VIEW_H
|
||||||
#define INTERFACES_LIST_VIEW_H
|
#define INTERFACES_LIST_VIEW_H
|
||||||
|
|
||||||
|
|
||||||
#include <net/if.h>
|
|
||||||
#include <net/if_dl.h>
|
|
||||||
#include <net/if_media.h>
|
|
||||||
#include <net/if_types.h>
|
|
||||||
|
|
||||||
#include <Bitmap.h>
|
|
||||||
#include <ListView.h>
|
#include <ListView.h>
|
||||||
#include <ListItem.h>
|
#include <ListItem.h>
|
||||||
#include <MenuItem.h>
|
|
||||||
#include <NetworkDevice.h>
|
|
||||||
#include <NetworkInterface.h>
|
|
||||||
#include <PopUpMenu.h>
|
|
||||||
#include <String.h>
|
|
||||||
|
|
||||||
#include "NetworkSettings.h"
|
#include "NetworkSettings.h"
|
||||||
|
|
||||||
|
|
||||||
#define ICON_SIZE 37
|
class BBitmap;
|
||||||
|
class BMenuItem;
|
||||||
|
class BNetworkInterface;
|
||||||
|
class BPoint;
|
||||||
|
class BPopUpMenu;
|
||||||
|
class BSeparatorItem;
|
||||||
|
class BString;
|
||||||
|
|
||||||
class InterfaceListItem : public BListItem {
|
class InterfaceListItem : public BListItem {
|
||||||
public:
|
public:
|
||||||
@@ -71,13 +66,11 @@ private:
|
|||||||
|
|
||||||
class InterfacesListView : public BListView {
|
class InterfacesListView : public BListView {
|
||||||
public:
|
public:
|
||||||
InterfacesListView(BRect rect, const char* name,
|
InterfacesListView(const char* name);
|
||||||
uint32 resizingMode
|
|
||||||
= B_FOLLOW_LEFT | B_FOLLOW_TOP);
|
|
||||||
|
|
||||||
virtual ~InterfacesListView();
|
virtual ~InterfacesListView();
|
||||||
|
|
||||||
InterfaceListItem* FindItem(const char* name);
|
InterfaceListItem* FindItem(const char* name);
|
||||||
|
InterfaceListItem* FindItem(BPoint where);
|
||||||
status_t SaveItems();
|
status_t SaveItems();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -86,11 +79,16 @@ protected:
|
|||||||
virtual void FrameResized(float width, float height);
|
virtual void FrameResized(float width, float height);
|
||||||
|
|
||||||
virtual void MessageReceived(BMessage* message);
|
virtual void MessageReceived(BMessage* message);
|
||||||
|
virtual void MouseDown(BPoint where);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// Context menu
|
||||||
|
BPopUpMenu* fContextMenu;
|
||||||
|
|
||||||
status_t _InitList();
|
status_t _InitList();
|
||||||
status_t _UpdateList();
|
status_t _UpdateList();
|
||||||
void _HandleNetworkMessage(BMessage* message);
|
void _HandleNetworkMessage(BMessage* message);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*INTERFACES_LIST_VIEW_H*/
|
|
||||||
|
#endif // INTERFACES_LIST_VIEW_H
|
||||||
|
|||||||
@@ -34,3 +34,13 @@ Addon Interfaces :
|
|||||||
$(HAIKU_LOCALE_LIBS)
|
$(HAIKU_LOCALE_LIBS)
|
||||||
libicon.a libagg.a
|
libicon.a libagg.a
|
||||||
;
|
;
|
||||||
|
|
||||||
|
DoCatalogs Interfaces :
|
||||||
|
x-vnd.Haiku-InterfacesAddOn
|
||||||
|
:
|
||||||
|
InterfacesAddOn.cpp
|
||||||
|
InterfacesListView.cpp
|
||||||
|
InterfaceWindow.cpp
|
||||||
|
InterfaceAddressView.cpp
|
||||||
|
InterfaceHardwareView.cpp
|
||||||
|
;
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2004-2011 Haiku, Inc. All rights reserved.
|
* Copyright 2004-2013 Haiku, Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Andre Alves Garzia, andre@andregarzia.com
|
|
||||||
* Axel Dörfler, axeld@pinc-software.de.
|
* Axel Dörfler, axeld@pinc-software.de.
|
||||||
* Vegard Wærp, vegarwa@online.no
|
* Andre Alves Garzia, andre@andregarzia.com
|
||||||
* Alexander von Gluck, kallisti5@unixzen.com
|
* Alexander von Gluck, kallisti5@unixzen.com
|
||||||
|
* John Scipione, jscipione@gmail.com
|
||||||
|
* Vegard Wærp, vegarwa@online.no
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -18,20 +19,17 @@
|
|||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <resolv.h>
|
#include <resolv.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/sockio.h>
|
#include <sys/sockio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <AutoDeleter.h>
|
||||||
#include <driver_settings.h>
|
#include <driver_settings.h>
|
||||||
#include <File.h>
|
#include <File.h>
|
||||||
#include <FindDirectory.h>
|
#include <FindDirectory.h>
|
||||||
#include <Path.h>
|
#include <Path.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
|
||||||
#include <AutoDeleter.h>
|
|
||||||
|
|
||||||
|
|
||||||
NetworkSettings::NetworkSettings(const char* name)
|
NetworkSettings::NetworkSettings(const char* name)
|
||||||
:
|
:
|
||||||
@@ -353,3 +351,14 @@ NetworkSettings::RenegotiateAddresses()
|
|||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char*
|
||||||
|
NetworkSettings::HardwareAddress()
|
||||||
|
{
|
||||||
|
BNetworkAddress macAddress;
|
||||||
|
if (fNetworkInterface->GetHardwareAddress(macAddress) == B_OK)
|
||||||
|
return macAddress.ToString();
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,22 +1,22 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2004-2010 Haiku, Inc. All rights reserved.
|
* Copyright 2004-2013 Haiku, Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Andre Alves Garzia, andre@andregarzia.com
|
* Andre Alves Garzia, andre@andregarzia.com
|
||||||
* Vegard Wærp, vegarwa@online.no
|
|
||||||
* Alexander von Gluck, kallisti5@unixzen.com
|
* Alexander von Gluck, kallisti5@unixzen.com
|
||||||
|
* John Scipione, jscipione@gmail.com
|
||||||
|
* Vegard Wærp, vegarwa@online.no
|
||||||
*/
|
*/
|
||||||
#ifndef SETTINGS_H
|
#ifndef SETTINGS_H
|
||||||
#define SETTINGS_H
|
#define SETTINGS_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
#include <ObjectList.h>
|
||||||
#include <NetworkDevice.h>
|
#include <NetworkDevice.h>
|
||||||
#include <NetworkInterface.h>
|
#include <NetworkInterface.h>
|
||||||
#include <ObjectList.h>
|
|
||||||
#include <String.h>
|
|
||||||
|
|
||||||
#include <map>
|
|
||||||
|
|
||||||
|
|
||||||
#define MAX_PROTOCOLS 7
|
#define MAX_PROTOCOLS 7
|
||||||
@@ -39,6 +39,8 @@ typedef struct _protocols {
|
|||||||
} protocols;
|
} protocols;
|
||||||
|
|
||||||
|
|
||||||
|
class BString;
|
||||||
|
|
||||||
class NetworkSettings {
|
class NetworkSettings {
|
||||||
public:
|
public:
|
||||||
NetworkSettings(const char* name);
|
NetworkSettings(const char* name);
|
||||||
@@ -48,11 +50,11 @@ public:
|
|||||||
{ return fProtocols; }
|
{ return fProtocols; }
|
||||||
|
|
||||||
void SetIP(int family, const char* ip)
|
void SetIP(int family, const char* ip)
|
||||||
{ fAddress[family].SetTo(ip); }
|
{ fAddress[family].SetTo(family, ip); }
|
||||||
void SetNetmask(int family, const char* mask)
|
void SetNetmask(int family, const char* mask)
|
||||||
{ fNetmask[family].SetTo(mask); }
|
{ fNetmask[family].SetTo(family, mask); }
|
||||||
void SetGateway(int family, const char* ip)
|
void SetGateway(int family, const char* ip)
|
||||||
{ fGateway[family].SetTo(ip); }
|
{ fGateway[family].SetTo(family, ip); }
|
||||||
void SetAutoConfigure(int family, bool autoConf)
|
void SetAutoConfigure(int family, bool autoConf)
|
||||||
{ fAutoConfigure[family] = autoConf; }
|
{ fAutoConfigure[family] = autoConf; }
|
||||||
|
|
||||||
@@ -64,7 +66,6 @@ public:
|
|||||||
// void SetDomain(const BString& domain)
|
// void SetDomain(const BString& domain)
|
||||||
// { fDomain = domain; }
|
// { fDomain = domain; }
|
||||||
|
|
||||||
|
|
||||||
bool AutoConfigure(int family)
|
bool AutoConfigure(int family)
|
||||||
{ return fAutoConfigure[family]; }
|
{ return fAutoConfigure[family]; }
|
||||||
BNetworkAddress IPAddr(int family)
|
BNetworkAddress IPAddr(int family)
|
||||||
@@ -91,6 +92,8 @@ public:
|
|||||||
bool HasLink() {
|
bool HasLink() {
|
||||||
return fNetworkDevice->HasLink(); }
|
return fNetworkDevice->HasLink(); }
|
||||||
|
|
||||||
|
const char* HardwareAddress();
|
||||||
|
|
||||||
const BString& WirelessNetwork() { return fWirelessNetwork; }
|
const BString& WirelessNetwork() { return fWirelessNetwork; }
|
||||||
|
|
||||||
BObjectList<BString>& NameServers() { return fNameServers; }
|
BObjectList<BString>& NameServers() { return fNameServers; }
|
||||||
@@ -128,4 +131,4 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /* SETTINGS_H */
|
#endif // SETTINGS_H
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ Preference NetworkSetup :
|
|||||||
;
|
;
|
||||||
|
|
||||||
SubInclude HAIKU_TOP src tests kits net preflet InterfacesAddOn ;
|
SubInclude HAIKU_TOP src tests kits net preflet InterfacesAddOn ;
|
||||||
SubInclude HAIKU_TOP src tests kits net preflet ServicesAddOn ;
|
#SubInclude HAIKU_TOP src tests kits net preflet ServicesAddOn ;
|
||||||
SubInclude HAIKU_TOP src tests kits net preflet DummyAddOn ;
|
#SubInclude HAIKU_TOP src tests kits net preflet DummyAddOn ;
|
||||||
SubInclude HAIKU_TOP src tests kits net preflet MultipleAddOns ;
|
#SubInclude HAIKU_TOP src tests kits net preflet MultipleAddOns ;
|
||||||
# SubInclude HAIKU_TOP src tests kits net preflet DialUpAddOn ;
|
# SubInclude HAIKU_TOP src tests kits net preflet DialUpAddOn ;
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#include <Catalog.h>
|
#include <Catalog.h>
|
||||||
|
#include <ControlLook.h>
|
||||||
#include <GroupLayout.h>
|
#include <GroupLayout.h>
|
||||||
#include <GroupLayoutBuilder.h>
|
#include <GroupLayoutBuilder.h>
|
||||||
#include <InterfaceKit.h>
|
#include <InterfaceKit.h>
|
||||||
@@ -50,46 +51,43 @@ NetworkSetupWindow::NetworkSetupWindow(const char *title)
|
|||||||
|
|
||||||
fPanel = new BTabView("showview_box");
|
fPanel = new BTabView("showview_box");
|
||||||
|
|
||||||
// ---- Bottom globals buttons section
|
|
||||||
BBox *bottomDivider = new BBox(B_EMPTY_STRING);
|
|
||||||
bottomDivider->SetBorder(B_PLAIN_BORDER);
|
|
||||||
|
|
||||||
fApplyButton = new BButton("apply", B_TRANSLATE("Apply"),
|
fApplyButton = new BButton("apply", B_TRANSLATE("Apply"),
|
||||||
new BMessage(kMsgApply));
|
new BMessage(kMsgApply));
|
||||||
|
SetDefaultButton(fApplyButton);
|
||||||
|
|
||||||
fRevertButton = new BButton("revert", B_TRANSLATE("Revert"),
|
fRevertButton = new BButton("revert", B_TRANSLATE("Revert"),
|
||||||
new BMessage(kMsgRevert));
|
new BMessage(kMsgRevert));
|
||||||
// fRevertButton->SetEnabled(false);
|
// fRevertButton->SetEnabled(false);
|
||||||
|
|
||||||
// Enable boxes resizing modes
|
// Enable boxes resizing modes
|
||||||
fPanel->SetResizingMode(B_FOLLOW_ALL);
|
//fPanel->SetResizingMode(B_FOLLOW_ALL);
|
||||||
|
|
||||||
// Build the layout
|
// Build the layout
|
||||||
SetLayout(new BGroupLayout(B_VERTICAL));
|
SetLayout(new BGroupLayout(B_VERTICAL));
|
||||||
|
|
||||||
AddChild(BGroupLayoutBuilder(B_VERTICAL, 10)
|
AddChild(BGroupLayoutBuilder(B_VERTICAL, B_USE_SMALL_SPACING)
|
||||||
.AddGroup(B_HORIZONTAL, 5)
|
.AddGroup(B_HORIZONTAL, B_USE_SMALL_SPACING)
|
||||||
.Add(profilesMenuField)
|
.Add(profilesMenuField)
|
||||||
.AddGlue()
|
.AddGlue()
|
||||||
.End()
|
.End()
|
||||||
.Add(fPanel)
|
.Add(fPanel)
|
||||||
.Add(bottomDivider)
|
.AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING)
|
||||||
.AddGroup(B_HORIZONTAL, 5)
|
|
||||||
.AddGlue()
|
|
||||||
.Add(fRevertButton)
|
.Add(fRevertButton)
|
||||||
|
.AddGlue()
|
||||||
.Add(fApplyButton)
|
.Add(fApplyButton)
|
||||||
.End()
|
.End()
|
||||||
.SetInsets(10, 10, 10, 10)
|
.SetInsets(B_USE_SMALL_SPACING, B_USE_SMALL_SPACING,
|
||||||
|
B_USE_SMALL_SPACING, B_USE_SMALL_SPACING)
|
||||||
);
|
);
|
||||||
|
|
||||||
_BuildShowTabView(kMsgAddonShow);
|
_BuildShowTabView(kMsgAddonShow);
|
||||||
|
|
||||||
bottomDivider->SetExplicitMaxSize(BSize(B_SIZE_UNSET, 1));
|
|
||||||
fPanel->SetExplicitMinSize(BSize(fMinAddonViewRect.Width(),
|
fPanel->SetExplicitMinSize(BSize(fMinAddonViewRect.Width(),
|
||||||
fMinAddonViewRect.Height()));
|
fMinAddonViewRect.Height()));
|
||||||
|
|
||||||
fAddonView = NULL;
|
fAddonView = NULL;
|
||||||
|
|
||||||
|
CenterOnScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -243,7 +241,11 @@ NetworkSetupWindow::_BuildShowTabView(int32 msg_what)
|
|||||||
if (!search_paths)
|
if (!search_paths)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fMinAddonViewRect.Set(0, 0, 375, 225); // Minimum size
|
float minimumWidth = be_control_look->DefaultItemSpacing() * 37;
|
||||||
|
float minimumHight = be_control_look->DefaultItemSpacing() * 25;
|
||||||
|
|
||||||
|
fMinAddonViewRect.Set(0, 0, minimumWidth, minimumHight);
|
||||||
|
// Minimum size
|
||||||
|
|
||||||
search_paths = strdup(search_paths);
|
search_paths = strdup(search_paths);
|
||||||
char* next_path_token;
|
char* next_path_token;
|
||||||
@@ -287,37 +289,37 @@ NetworkSetupWindow::_BuildShowTabView(int32 msg_what)
|
|||||||
|
|
||||||
int tabCount = 0;
|
int tabCount = 0;
|
||||||
|
|
||||||
if (status == B_OK) {
|
if (status != B_OK) {
|
||||||
while ((fNetworkAddOnMap[fAddonCount]
|
// No "addon instantiate function" symbol found in this addon
|
||||||
= get_nth_addon(addon_id, tabCount)) != NULL) {
|
printf("No symbol \"get_nth_addon\" found in %s addon: not a "
|
||||||
printf("Adding Tab: %d\n", fAddonCount);
|
"network setup addon!\n", addon_path.Path());
|
||||||
BMessage* msg = new BMessage(msg_what);
|
unload_add_on(addon_id);
|
||||||
|
|
||||||
BRect r(0, 0, 0, 0);
|
|
||||||
BView* addon_view
|
|
||||||
= fNetworkAddOnMap[fAddonCount]->CreateView(&r);
|
|
||||||
fMinAddonViewRect = fMinAddonViewRect | r;
|
|
||||||
|
|
||||||
msg->AddInt32("image_id", addon_id);
|
|
||||||
msg->AddString("addon_path", addon_path.Path());
|
|
||||||
msg->AddPointer("addon", fNetworkAddOnMap[fAddonCount]);
|
|
||||||
msg->AddPointer("addon_view", addon_view);
|
|
||||||
|
|
||||||
BTab *tab = new BTab;
|
|
||||||
fPanel->AddTab(addon_view, tab);
|
|
||||||
tab->SetLabel(fNetworkAddOnMap[fAddonCount]->Name());
|
|
||||||
fAddonCount++;
|
|
||||||
// Number of tab addons total
|
|
||||||
tabCount++;
|
|
||||||
// Tabs for *this* addon
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// No "addon instantiate function" symbol found in this addon
|
while ((fNetworkAddOnMap[fAddonCount]
|
||||||
printf("No symbol \"get_nth_addon\" found in %s addon: not a "
|
= get_nth_addon(addon_id, tabCount)) != NULL) {
|
||||||
"network setup addon!\n", addon_path.Path());
|
printf("Adding Tab: %d\n", fAddonCount);
|
||||||
unload_add_on(addon_id);
|
BMessage* msg = new BMessage(msg_what);
|
||||||
|
|
||||||
|
BRect r(0, 0, 0, 0);
|
||||||
|
BView* addon_view
|
||||||
|
= fNetworkAddOnMap[fAddonCount]->CreateView(&r);
|
||||||
|
fMinAddonViewRect = fMinAddonViewRect | r;
|
||||||
|
|
||||||
|
msg->AddInt32("image_id", addon_id);
|
||||||
|
msg->AddString("addon_path", addon_path.Path());
|
||||||
|
msg->AddPointer("addon", fNetworkAddOnMap[fAddonCount]);
|
||||||
|
msg->AddPointer("addon_view", addon_view);
|
||||||
|
|
||||||
|
BTab* tab = new BTab;
|
||||||
|
fPanel->AddTab(addon_view, tab);
|
||||||
|
tab->SetLabel(fNetworkAddOnMap[fAddonCount]->Name());
|
||||||
|
fAddonCount++;
|
||||||
|
// Number of tab addons total
|
||||||
|
tabCount++;
|
||||||
|
// Tabs for *this* addon
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user