NetworkSetup: put interface settings in main window
* The initial design was probably inspired by Windows network settings, which are a mess of nested windows and hyperlinks. * Instead, the settings can be put directly inside the main window, like it is done inthe media preflet. This makes the information available at a glance and makes the UI easier to navigate. * Remove the "configure" button and popup menu item. A single click is now enough to show the settings for an interface For this to work properly, complete the move to layout kit (there were a few BRect-based constructorls left which would mess the layout) and remove unneeded rectangle computations (layout kit does the job already). Further cleanup pending: * Removal of the duplicate "revert" button * Removal of the "save" button and switch to applying settings realtime * Move the disable/enable and renegociate buttons inside the interface settings * Remove the top-level tab view (nested tab views are not nice) and use a hierarchized list with both interfaces and services on the side (like the Media preflet has audio and video).
This commit is contained in:
@@ -30,7 +30,7 @@
|
|||||||
// #pragma mark - InterfaceAddressView
|
// #pragma mark - InterfaceAddressView
|
||||||
|
|
||||||
|
|
||||||
InterfaceAddressView::InterfaceAddressView(BRect frame, int family,
|
InterfaceAddressView::InterfaceAddressView(int family,
|
||||||
NetworkSettings* settings)
|
NetworkSettings* settings)
|
||||||
:
|
:
|
||||||
BGroupView(B_VERTICAL),
|
BGroupView(B_VERTICAL),
|
||||||
|
|||||||
@@ -30,8 +30,8 @@ class BTextControl;
|
|||||||
|
|
||||||
class InterfaceAddressView : public BGroupView {
|
class InterfaceAddressView : public BGroupView {
|
||||||
public:
|
public:
|
||||||
InterfaceAddressView(BRect frame,
|
InterfaceAddressView(int family,
|
||||||
int family, NetworkSettings* settings);
|
NetworkSettings* settings);
|
||||||
virtual ~InterfaceAddressView();
|
virtual ~InterfaceAddressView();
|
||||||
|
|
||||||
virtual void AttachedToWindow();
|
virtual void AttachedToWindow();
|
||||||
|
|||||||
@@ -32,8 +32,7 @@
|
|||||||
// #pragma mark - InterfaceHardwareView
|
// #pragma mark - InterfaceHardwareView
|
||||||
|
|
||||||
|
|
||||||
InterfaceHardwareView::InterfaceHardwareView(BRect frame,
|
InterfaceHardwareView::InterfaceHardwareView(NetworkSettings* settings)
|
||||||
NetworkSettings* settings)
|
|
||||||
:
|
:
|
||||||
BGroupView(B_VERTICAL),
|
BGroupView(B_VERTICAL),
|
||||||
fSettings(settings)
|
fSettings(settings)
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ class BStringView;
|
|||||||
|
|
||||||
class InterfaceHardwareView : public BGroupView {
|
class InterfaceHardwareView : public BGroupView {
|
||||||
public:
|
public:
|
||||||
InterfaceHardwareView(BRect frame,
|
InterfaceHardwareView(
|
||||||
NetworkSettings* settings);
|
NetworkSettings* settings);
|
||||||
virtual ~InterfaceHardwareView();
|
virtual ~InterfaceHardwareView();
|
||||||
|
|
||||||
|
|||||||
+18
-19
@@ -8,7 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "InterfaceWindow.h"
|
#include "InterfaceView.h"
|
||||||
|
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#include <Button.h>
|
#include <Button.h>
|
||||||
@@ -22,12 +22,9 @@
|
|||||||
#define B_TRANSLATION_CONTEXT "InterfaceWindow"
|
#define B_TRANSLATION_CONTEXT "InterfaceWindow"
|
||||||
|
|
||||||
|
|
||||||
InterfaceWindow::InterfaceWindow(NetworkSettings* settings)
|
InterfaceView::InterfaceView(NetworkSettings* settings)
|
||||||
:
|
:
|
||||||
BWindow(BRect(50, 50, 370, 350), "Interface Settings",
|
BView("Interface Settings", 0, 0)
|
||||||
B_FLOATING_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
|
|
||||||
B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_RESIZABLE
|
|
||||||
| B_AUTO_UPDATE_SIZE_LIMITS, B_CURRENT_WORKSPACE)
|
|
||||||
{
|
{
|
||||||
fNetworkSettings = settings;
|
fNetworkSettings = settings;
|
||||||
|
|
||||||
@@ -39,7 +36,6 @@ InterfaceWindow::InterfaceWindow(NetworkSettings* settings)
|
|||||||
|
|
||||||
fApplyButton = new BButton("save", B_TRANSLATE("Save"),
|
fApplyButton = new BButton("save", B_TRANSLATE("Save"),
|
||||||
new BMessage(MSG_IP_SAVE));
|
new BMessage(MSG_IP_SAVE));
|
||||||
SetDefaultButton(fApplyButton);
|
|
||||||
|
|
||||||
_PopulateTabs();
|
_PopulateTabs();
|
||||||
|
|
||||||
@@ -58,18 +54,24 @@ InterfaceWindow::InterfaceWindow(NetworkSettings* settings)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
InterfaceWindow::~InterfaceWindow()
|
InterfaceView::~InterfaceView()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
InterfaceWindow::MessageReceived(BMessage* message)
|
InterfaceView::AttachedToWindow()
|
||||||
|
{
|
||||||
|
Window()->SetDefaultButton(fApplyButton);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
InterfaceView::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) {
|
||||||
@@ -85,32 +87,29 @@ InterfaceWindow::MessageReceived(BMessage* message)
|
|||||||
fTabIPView[inet_id]->Save();
|
fTabIPView[inet_id]->Save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this->Quit();
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
BWindow::MessageReceived(message);
|
BView::MessageReceived(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
InterfaceWindow::_PopulateTabs()
|
InterfaceView::_PopulateTabs()
|
||||||
{
|
{
|
||||||
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(fNetworkSettings);
|
||||||
fNetworkSettings);
|
|
||||||
fTabView->AddTab(fTabHardwareView, hardwareTab);
|
fTabView->AddTab(fTabHardwareView, hardwareTab);
|
||||||
hardwareTab->SetLabel(B_TRANSLATE("Interface"));
|
hardwareTab->SetLabel(B_TRANSLATE("Interface"));
|
||||||
|
|
||||||
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] = new InterfaceAddressView(frame,
|
fTabIPView[inet_id] = new InterfaceAddressView(inet_id,
|
||||||
inet_id, fNetworkSettings);
|
fNetworkSettings);
|
||||||
BTab* tab = new BTab;
|
BTab* tab = new BTab;
|
||||||
fTabView->AddTab(fTabIPView[inet_id], tab);
|
fTabView->AddTab(fTabIPView[inet_id], tab);
|
||||||
tab->SetLabel(supportedFamilies[index].name);
|
tab->SetLabel(supportedFamilies[index].name);
|
||||||
@@ -122,7 +121,7 @@ InterfaceWindow::_PopulateTabs()
|
|||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
InterfaceWindow::QuitRequested()
|
InterfaceView::QuitRequested()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
+4
-3
@@ -31,11 +31,12 @@ typedef std::map<int, InterfaceAddressView*> IPViewMap;
|
|||||||
class BButton;
|
class BButton;
|
||||||
class BTabView;
|
class BTabView;
|
||||||
|
|
||||||
class InterfaceWindow : public BWindow {
|
class InterfaceView : public BView {
|
||||||
public:
|
public:
|
||||||
InterfaceWindow(NetworkSettings* settings);
|
InterfaceView(NetworkSettings* settings);
|
||||||
virtual ~InterfaceWindow();
|
virtual ~InterfaceView();
|
||||||
|
|
||||||
|
virtual void AttachedToWindow();
|
||||||
virtual void MessageReceived(BMessage* mesage);
|
virtual void MessageReceived(BMessage* mesage);
|
||||||
virtual bool QuitRequested();
|
virtual bool QuitRequested();
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "InterfacesAddOn.h"
|
#include "InterfacesAddOn.h"
|
||||||
#include "InterfaceWindow.h"
|
#include "InterfaceView.h"
|
||||||
|
|
||||||
#include <Alert.h>
|
#include <Alert.h>
|
||||||
#include <Button.h>
|
#include <Button.h>
|
||||||
@@ -48,7 +48,7 @@ get_nth_addon(image_id image, int index)
|
|||||||
InterfacesAddOn::InterfacesAddOn(image_id image)
|
InterfacesAddOn::InterfacesAddOn(image_id image)
|
||||||
:
|
:
|
||||||
NetworkSetupAddOn(image),
|
NetworkSetupAddOn(image),
|
||||||
BBox(BRect(0, 0, 0, 0), NULL, B_FOLLOW_ALL, B_NAVIGABLE_JUMP, B_NO_BORDER)
|
BBox(NULL, B_NAVIGABLE_JUMP, B_NO_BORDER)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,21 +66,16 @@ InterfacesAddOn::Name()
|
|||||||
|
|
||||||
|
|
||||||
BView*
|
BView*
|
||||||
InterfacesAddOn::CreateView(BRect *bounds)
|
InterfacesAddOn::CreateView()
|
||||||
{
|
{
|
||||||
// Construct the ListView
|
// Construct the ListView
|
||||||
fListView = new InterfacesListView("interfaces");
|
fListView = new InterfacesListView("interfaces");
|
||||||
fListView->SetSelectionMessage(new BMessage(kMsgInterfaceSelected));
|
fListView->SetSelectionMessage(new BMessage(kMsgInterfaceSelected));
|
||||||
fListView->SetInvocationMessage(new BMessage(kMsgInterfaceConfigure));
|
|
||||||
|
|
||||||
BScrollView* scrollView = new BScrollView("scrollView", fListView,
|
BScrollView* scrollView = new BScrollView("scrollView", fListView,
|
||||||
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("configure", B_TRANSLATE("Configure" B_UTF8_ELLIPSIS),
|
|
||||||
new BMessage(kMsgInterfaceConfigure));
|
|
||||||
fConfigure->SetEnabled(false);
|
|
||||||
|
|
||||||
fOnOff = new BButton("onoff", B_TRANSLATE("Disable"),
|
fOnOff = new BButton("onoff", B_TRANSLATE("Disable"),
|
||||||
new BMessage(kMsgInterfaceToggle));
|
new BMessage(kMsgInterfaceToggle));
|
||||||
fOnOff->SetEnabled(false);
|
fOnOff->SetEnabled(false);
|
||||||
@@ -90,12 +85,11 @@ InterfacesAddOn::CreateView(BRect *bounds)
|
|||||||
fRenegotiate->SetEnabled(false);
|
fRenegotiate->SetEnabled(false);
|
||||||
|
|
||||||
// Build the layout
|
// Build the layout
|
||||||
SetLayout(new BGroupLayout(B_VERTICAL));
|
SetLayout(new BGroupLayout(B_HORIZONTAL));
|
||||||
|
|
||||||
AddChild(BGroupLayoutBuilder(B_VERTICAL, B_USE_DEFAULT_SPACING)
|
AddChild(BGroupLayoutBuilder(B_VERTICAL, B_USE_DEFAULT_SPACING)
|
||||||
.Add(scrollView)
|
.Add(scrollView)
|
||||||
.AddGroup(B_HORIZONTAL, B_USE_SMALL_SPACING)
|
.AddGroup(B_HORIZONTAL, B_USE_SMALL_SPACING)
|
||||||
.Add(fConfigure)
|
|
||||||
.Add(fOnOff)
|
.Add(fOnOff)
|
||||||
.AddGlue()
|
.AddGlue()
|
||||||
.Add(fRenegotiate)
|
.Add(fRenegotiate)
|
||||||
@@ -104,7 +98,6 @@ InterfacesAddOn::CreateView(BRect *bounds)
|
|||||||
B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING)
|
B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING)
|
||||||
);
|
);
|
||||||
|
|
||||||
*bounds = Bounds();
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,7 +106,6 @@ void
|
|||||||
InterfacesAddOn::AttachedToWindow()
|
InterfacesAddOn::AttachedToWindow()
|
||||||
{
|
{
|
||||||
fListView->SetTarget(this);
|
fListView->SetTarget(this);
|
||||||
fConfigure->SetTarget(this);
|
|
||||||
fOnOff->SetTarget(this);
|
fOnOff->SetTarget(this);
|
||||||
fRenegotiate->SetTarget(this);
|
fRenegotiate->SetTarget(this);
|
||||||
}
|
}
|
||||||
@@ -138,24 +130,20 @@ InterfacesAddOn::MessageReceived(BMessage* msg)
|
|||||||
switch (msg->what) {
|
switch (msg->what) {
|
||||||
case kMsgInterfaceSelected:
|
case kMsgInterfaceSelected:
|
||||||
{
|
{
|
||||||
fConfigure->SetEnabled(item != NULL);
|
|
||||||
fOnOff->SetEnabled(item != NULL);
|
fOnOff->SetEnabled(item != NULL);
|
||||||
fRenegotiate->SetEnabled(item != NULL);
|
fRenegotiate->SetEnabled(item != NULL);
|
||||||
if (item == NULL)
|
if (item == NULL)
|
||||||
break;
|
break;
|
||||||
fConfigure->SetEnabled(!item->IsDisabled());
|
|
||||||
fRenegotiate->SetEnabled(!item->IsDisabled());
|
fRenegotiate->SetEnabled(!item->IsDisabled());
|
||||||
fOnOff->SetLabel(item->IsDisabled() ? "Enable" : "Disable");
|
fOnOff->SetLabel(item->IsDisabled() ? "Enable" : "Disable");
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case kMsgInterfaceConfigure:
|
// TODO it would be better to reuse the view instead of recreating
|
||||||
{
|
// one.
|
||||||
if (item == NULL)
|
InterfaceView* sw = new InterfaceView(item->GetSettings());
|
||||||
break;
|
BView* old = ChildAt(1);
|
||||||
|
RemoveChild(old);
|
||||||
InterfaceWindow* sw = new InterfaceWindow(item->GetSettings());
|
delete old;
|
||||||
sw->Show();
|
AddChild(sw);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,7 +153,6 @@ InterfacesAddOn::MessageReceived(BMessage* msg)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
item->SetDisabled(!item->IsDisabled());
|
item->SetDisabled(!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();
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
|
|
||||||
static const uint32 kMsgInterfaceSelected = 'ifce';
|
static const uint32 kMsgInterfaceSelected = 'ifce';
|
||||||
static const uint32 kMsgInterfaceConfigure = 'ifcf';
|
|
||||||
static const uint32 kMsgInterfaceToggle = 'onof';
|
static const uint32 kMsgInterfaceToggle = 'onof';
|
||||||
static const uint32 kMsgInterfaceRenegotiate = 'redo';
|
static const uint32 kMsgInterfaceRenegotiate = 'redo';
|
||||||
|
|
||||||
@@ -36,14 +35,13 @@ public:
|
|||||||
const char* Name();
|
const char* Name();
|
||||||
status_t Save();
|
status_t Save();
|
||||||
|
|
||||||
BView* CreateView(BRect *bounds);
|
BView* CreateView();
|
||||||
|
|
||||||
void AttachedToWindow();
|
void AttachedToWindow();
|
||||||
void MessageReceived(BMessage* msg);
|
void MessageReceived(BMessage* msg);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
InterfacesListView* fListView;
|
InterfacesListView* fListView;
|
||||||
BButton* fConfigure;
|
|
||||||
BButton* fOnOff;
|
BButton* fOnOff;
|
||||||
BButton* fRenegotiate;
|
BButton* fRenegotiate;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
#include <AutoDeleter.h>
|
#include <AutoDeleter.h>
|
||||||
|
|
||||||
#include "InterfacesAddOn.h"
|
#include "InterfacesAddOn.h"
|
||||||
#include "InterfaceWindow.h"
|
#include "InterfaceView.h"
|
||||||
|
|
||||||
|
|
||||||
#define ICON_SIZE 37
|
#define ICON_SIZE 37
|
||||||
@@ -121,19 +121,19 @@ InterfaceListItem::DrawItem(BView* owner, BRect /*bounds*/, bool complete)
|
|||||||
BBitmap* stateIcon(NULL);
|
BBitmap* stateIcon(NULL);
|
||||||
|
|
||||||
if (fSettings->IsDisabled()) {
|
if (fSettings->IsDisabled()) {
|
||||||
interfaceState << "disabled";
|
interfaceState = "disabled";
|
||||||
stateIcon = fIconOffline;
|
stateIcon = fIconOffline;
|
||||||
} else if (!fInterface.HasLink()) {
|
} else if (!fInterface.HasLink()) {
|
||||||
interfaceState << "no link";
|
interfaceState = "no link";
|
||||||
stateIcon = fIconOffline;
|
stateIcon = fIconOffline;
|
||||||
} else if ((fSettings->IPAddr(AF_INET).IsEmpty()
|
} else if ((fSettings->IPAddr(AF_INET).IsEmpty()
|
||||||
&& fSettings->IPAddr(AF_INET6).IsEmpty())
|
&& fSettings->IPAddr(AF_INET6).IsEmpty())
|
||||||
&& (fSettings->AutoConfigure(AF_INET)
|
&& (fSettings->AutoConfigure(AF_INET)
|
||||||
|| fSettings->AutoConfigure(AF_INET6))) {
|
|| fSettings->AutoConfigure(AF_INET6))) {
|
||||||
interfaceState << "connecting" B_UTF8_ELLIPSIS;
|
interfaceState = "connecting" B_UTF8_ELLIPSIS;
|
||||||
stateIcon = fIconPending;
|
stateIcon = fIconPending;
|
||||||
} else {
|
} else {
|
||||||
interfaceState << "connected";
|
interfaceState = "connected";
|
||||||
stateIcon = fIconOnline;
|
stateIcon = fIconOnline;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,7 +185,7 @@ InterfaceListItem::DrawItem(BView* owner, BRect /*bounds*/, bool complete)
|
|||||||
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 ipv4Str(B_TRANSLATE_COMMENT("IP:", "IPv4 address label"));
|
BString ipv4Str(B_TRANSLATE_COMMENT("IP:", "IPv4 address label"));
|
||||||
@@ -196,7 +196,7 @@ InterfaceListItem::DrawItem(BView* owner, BRect /*bounds*/, bool complete)
|
|||||||
|
|
||||||
list->DrawString(ipv4Str, line2Pt);
|
list->DrawString(ipv4Str, line2Pt);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render IPv6 Address (if present)
|
// Render IPv6 Address (if present)
|
||||||
if (!fSettings->IsDisabled()
|
if (!fSettings->IsDisabled()
|
||||||
&& !fSettings->IPAddr(AF_INET6).IsEmpty()) {
|
&& !fSettings->IPAddr(AF_INET6).IsEmpty()) {
|
||||||
@@ -337,7 +337,8 @@ InterfaceListItem::_PopulateBitmaps(const char* mediaType) {
|
|||||||
|
|
||||||
InterfacesListView::InterfacesListView(const char* name)
|
InterfacesListView::InterfacesListView(const char* name)
|
||||||
:
|
:
|
||||||
BListView(name)
|
BListView(name, B_SINGLE_SELECTION_LIST,
|
||||||
|
B_WILL_DRAW | B_NAVIGABLE | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE)
|
||||||
{
|
{
|
||||||
fContextMenu = new BPopUpMenu("context menu", false, false);
|
fContextMenu = new BPopUpMenu("context menu", false, false);
|
||||||
}
|
}
|
||||||
@@ -366,14 +367,6 @@ InterfacesListView::AttachedToWindow()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
InterfacesListView::FrameResized(float width, float height)
|
|
||||||
{
|
|
||||||
BListView::FrameResized(width, height);
|
|
||||||
Invalidate();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
InterfacesListView::DetachedFromWindow()
|
InterfacesListView::DetachedFromWindow()
|
||||||
{
|
{
|
||||||
@@ -430,9 +423,6 @@ InterfacesListView::MouseDown(BPoint where)
|
|||||||
fContextMenu->AddItem(new BMenuItem(B_TRANSLATE("Enable"),
|
fContextMenu->AddItem(new BMenuItem(B_TRANSLATE("Enable"),
|
||||||
new BMessage(kMsgInterfaceToggle)));
|
new BMessage(kMsgInterfaceToggle)));
|
||||||
} else {
|
} else {
|
||||||
fContextMenu->AddItem(new BMenuItem(
|
|
||||||
B_TRANSLATE("Configure" B_UTF8_ELLIPSIS),
|
|
||||||
new BMessage(kMsgInterfaceConfigure)));
|
|
||||||
if (item->GetSettings()->AutoConfigure(AF_INET)
|
if (item->GetSettings()->AutoConfigure(AF_INET)
|
||||||
|| item->GetSettings()->AutoConfigure(AF_INET6)) {
|
|| item->GetSettings()->AutoConfigure(AF_INET6)) {
|
||||||
fContextMenu->AddItem(new BMenuItem(
|
fContextMenu->AddItem(new BMenuItem(
|
||||||
@@ -450,14 +440,6 @@ InterfacesListView::MouseDown(BPoint where)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
switch (selected->Message()->what) {
|
switch (selected->Message()->what) {
|
||||||
case kMsgInterfaceConfigure:
|
|
||||||
{
|
|
||||||
InterfaceWindow* win = new InterfaceWindow(item->GetSettings());
|
|
||||||
win->MoveTo(ConvertToScreen(where));
|
|
||||||
win->Show();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case kMsgInterfaceToggle:
|
case kMsgInterfaceToggle:
|
||||||
item->SetDisabled(!item->IsDisabled());
|
item->SetDisabled(!item->IsDisabled());
|
||||||
Invalidate();
|
Invalidate();
|
||||||
@@ -541,6 +523,10 @@ InterfacesListView::_InitList()
|
|||||||
AddItem(new InterfaceListItem(interface.Name()));
|
AddItem(new InterfaceListItem(interface.Name()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME compute this according to the actual size of the largest item
|
||||||
|
// instead.
|
||||||
|
SetExplicitMinSize(BSize(10 + B_LARGE_ICON
|
||||||
|
+ StringWidth("/dev/net/MMMMMMMMMMM xxxxxxxxxx"), B_SIZE_UNSET));
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -76,7 +76,6 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
virtual void AttachedToWindow();
|
virtual void AttachedToWindow();
|
||||||
virtual void DetachedFromWindow();
|
virtual void DetachedFromWindow();
|
||||||
virtual void FrameResized(float width, float height);
|
|
||||||
|
|
||||||
virtual void MessageReceived(BMessage* message);
|
virtual void MessageReceived(BMessage* message);
|
||||||
virtual void MouseDown(BPoint where);
|
virtual void MouseDown(BPoint where);
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ Addon Interfaces :
|
|||||||
InterfacesAddOn.cpp
|
InterfacesAddOn.cpp
|
||||||
InterfacesListView.cpp
|
InterfacesListView.cpp
|
||||||
NetworkSettings.cpp
|
NetworkSettings.cpp
|
||||||
InterfaceWindow.cpp
|
InterfaceView.cpp
|
||||||
InterfaceAddressView.cpp
|
InterfaceAddressView.cpp
|
||||||
InterfaceHardwareView.cpp
|
InterfaceHardwareView.cpp
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ DoCatalogs Interfaces :
|
|||||||
:
|
:
|
||||||
InterfacesAddOn.cpp
|
InterfacesAddOn.cpp
|
||||||
InterfacesListView.cpp
|
InterfacesListView.cpp
|
||||||
InterfaceWindow.cpp
|
InterfaceView.cpp
|
||||||
InterfaceAddressView.cpp
|
InterfaceAddressView.cpp
|
||||||
InterfaceHardwareView.cpp
|
InterfaceHardwareView.cpp
|
||||||
;
|
;
|
||||||
|
|||||||
@@ -13,4 +13,4 @@ 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 ;
|
||||||
|
|||||||
@@ -30,15 +30,6 @@ NetworkSetupAddOn::~NetworkSetupAddOn()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BView*
|
|
||||||
NetworkSetupAddOn::CreateView(BRect* bounds)
|
|
||||||
{
|
|
||||||
BView *v = new BView(*bounds, "a view", B_FOLLOW_ALL, B_WILL_DRAW);
|
|
||||||
v->SetViewColor((rand() % 256), (rand() % 256), (rand() % 256));
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
NetworkSetupAddOn::Save()
|
NetworkSetupAddOn::Save()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class NetworkSetupAddOn {
|
|||||||
NetworkSetupAddOn(image_id addon_image);
|
NetworkSetupAddOn(image_id addon_image);
|
||||||
virtual ~NetworkSetupAddOn();
|
virtual ~NetworkSetupAddOn();
|
||||||
|
|
||||||
virtual BView * CreateView(BRect* bounds);
|
virtual BView * CreateView() = 0;
|
||||||
virtual status_t Save();
|
virtual status_t Save();
|
||||||
virtual status_t Revert();
|
virtual status_t Revert();
|
||||||
|
|
||||||
|
|||||||
@@ -82,9 +82,6 @@ NetworkSetupWindow::NetworkSetupWindow(const char *title)
|
|||||||
|
|
||||||
_BuildShowTabView(kMsgAddonShow);
|
_BuildShowTabView(kMsgAddonShow);
|
||||||
|
|
||||||
fPanel->SetExplicitMinSize(BSize(fMinAddonViewRect.Width(),
|
|
||||||
fMinAddonViewRect.Height()));
|
|
||||||
|
|
||||||
fAddonView = NULL;
|
fAddonView = NULL;
|
||||||
|
|
||||||
CenterOnScreen();
|
CenterOnScreen();
|
||||||
@@ -241,12 +238,6 @@ NetworkSetupWindow::_BuildShowTabView(int32 msg_what)
|
|||||||
if (!search_paths)
|
if (!search_paths)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
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;
|
||||||
char* search_path = strtok_r(search_paths, ":", &next_path_token);
|
char* search_path = strtok_r(search_paths, ":", &next_path_token);
|
||||||
@@ -302,10 +293,8 @@ NetworkSetupWindow::_BuildShowTabView(int32 msg_what)
|
|||||||
printf("Adding Tab: %d\n", fAddonCount);
|
printf("Adding Tab: %d\n", fAddonCount);
|
||||||
BMessage* msg = new BMessage(msg_what);
|
BMessage* msg = new BMessage(msg_what);
|
||||||
|
|
||||||
BRect r(0, 0, 0, 0);
|
|
||||||
BView* addon_view
|
BView* addon_view
|
||||||
= fNetworkAddOnMap[fAddonCount]->CreateView(&r);
|
= fNetworkAddOnMap[fAddonCount]->CreateView();
|
||||||
fMinAddonViewRect = fMinAddonViewRect | r;
|
|
||||||
|
|
||||||
msg->AddInt32("image_id", addon_id);
|
msg->AddInt32("image_id", addon_id);
|
||||||
msg->AddString("addon_path", addon_path.Path());
|
msg->AddString("addon_path", addon_path.Path());
|
||||||
|
|||||||
@@ -56,7 +56,6 @@ class NetworkSetupWindow : public BWindow
|
|||||||
BTabView* fPanel;
|
BTabView* fPanel;
|
||||||
BView* fAddonView;
|
BView* fAddonView;
|
||||||
int fAddonCount;
|
int fAddonCount;
|
||||||
BRect fMinAddonViewRect;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user