NetworkSetup: move renegociate and disable buttons to HardwareView
The idea is making the interface list a generic list to add some stuff that are not interfaces there (ie services: DNS, FTP, SSH, ...)
This commit is contained in:
@@ -14,6 +14,7 @@
|
|||||||
#include "NetworkSettings.h"
|
#include "NetworkSettings.h"
|
||||||
#include "WirelessNetworkMenuItem.h"
|
#include "WirelessNetworkMenuItem.h"
|
||||||
|
|
||||||
|
#include <Button.h>
|
||||||
#include <Catalog.h>
|
#include <Catalog.h>
|
||||||
#include <ControlLook.h>
|
#include <ControlLook.h>
|
||||||
#include <LayoutBuilder.h>
|
#include <LayoutBuilder.h>
|
||||||
@@ -79,6 +80,14 @@ InterfaceHardwareView::InterfaceHardwareView(NetworkSettings* settings)
|
|||||||
fNetworkMenuField->SetAlignment(B_ALIGN_RIGHT);
|
fNetworkMenuField->SetAlignment(B_ALIGN_RIGHT);
|
||||||
fNetworkMenuField->Menu()->SetLabelFromMarked(true);
|
fNetworkMenuField->Menu()->SetLabelFromMarked(true);
|
||||||
|
|
||||||
|
// Construct the BButtons
|
||||||
|
fOnOff = new BButton("onoff", B_TRANSLATE("Disable"),
|
||||||
|
new BMessage(kMsgInterfaceToggle));
|
||||||
|
|
||||||
|
fRenegotiate = new BButton("heal", B_TRANSLATE("Renegotiate"),
|
||||||
|
new BMessage(kMsgInterfaceRenegotiate));
|
||||||
|
fRenegotiate->SetEnabled(false);
|
||||||
|
|
||||||
BLayoutBuilder::Group<>(this)
|
BLayoutBuilder::Group<>(this)
|
||||||
.AddGrid()
|
.AddGrid()
|
||||||
.Add(status, 0, 0)
|
.Add(status, 0, 0)
|
||||||
@@ -95,6 +104,11 @@ InterfaceHardwareView::InterfaceHardwareView(NetworkSettings* settings)
|
|||||||
.Add(fLinkRxField, 1, 5)
|
.Add(fLinkRxField, 1, 5)
|
||||||
.End()
|
.End()
|
||||||
.AddGlue()
|
.AddGlue()
|
||||||
|
.AddGroup(B_HORIZONTAL)
|
||||||
|
.Add(fOnOff)
|
||||||
|
.AddGlue()
|
||||||
|
.Add(fRenegotiate)
|
||||||
|
.End()
|
||||||
.SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING,
|
.SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING,
|
||||||
B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING);
|
B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING);
|
||||||
}
|
}
|
||||||
@@ -114,6 +128,9 @@ InterfaceHardwareView::AttachedToWindow()
|
|||||||
{
|
{
|
||||||
Update();
|
Update();
|
||||||
// Populate the fields
|
// Populate the fields
|
||||||
|
|
||||||
|
fOnOff->SetTarget(this);
|
||||||
|
fRenegotiate->SetTarget(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -126,6 +143,20 @@ InterfaceHardwareView::MessageReceived(BMessage* message)
|
|||||||
fSettings->SetWirelessNetwork(message->FindString("name"));
|
fSettings->SetWirelessNetwork(message->FindString("name"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case kMsgInterfaceToggle:
|
||||||
|
{
|
||||||
|
fSettings->SetDisabled(!fSettings->IsDisabled());
|
||||||
|
Update();
|
||||||
|
Window()->FindView("interfaces")->Invalidate();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case kMsgInterfaceRenegotiate:
|
||||||
|
{
|
||||||
|
fSettings->RenegotiateAddresses();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
BView::MessageReceived(message);
|
BView::MessageReceived(message);
|
||||||
}
|
}
|
||||||
@@ -233,6 +264,9 @@ InterfaceHardwareView::Update()
|
|||||||
menu->SetTargetForItems(this);
|
menu->SetTargetForItems(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fRenegotiate->SetEnabled(!fSettings->IsDisabled());
|
||||||
|
fOnOff->SetLabel(fSettings->IsDisabled() ? "Enable" : "Disable");
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,11 @@
|
|||||||
#include <GroupView.h>
|
#include <GroupView.h>
|
||||||
|
|
||||||
|
|
||||||
|
static const uint32 kMsgInterfaceToggle = 'onof';
|
||||||
|
static const uint32 kMsgInterfaceRenegotiate = 'redo';
|
||||||
|
|
||||||
|
|
||||||
|
class BButton;
|
||||||
class BMenuField;
|
class BMenuField;
|
||||||
class BMessage;
|
class BMessage;
|
||||||
class BRect;
|
class BRect;
|
||||||
@@ -45,6 +50,9 @@ private:
|
|||||||
BStringView* fLinkRxField;
|
BStringView* fLinkRxField;
|
||||||
|
|
||||||
BMenuField* fNetworkMenuField;
|
BMenuField* fNetworkMenuField;
|
||||||
|
|
||||||
|
BButton* fOnOff;
|
||||||
|
BButton* fRenegotiate;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ public:
|
|||||||
void Apply();
|
void Apply();
|
||||||
void Revert();
|
void Revert();
|
||||||
|
|
||||||
|
NetworkSettings* Settings() { return fNetworkSettings; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
status_t _PopulateTabs();
|
status_t _PopulateTabs();
|
||||||
|
|
||||||
|
|||||||
@@ -76,25 +76,11 @@ InterfacesAddOn::CreateView()
|
|||||||
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
|
|
||||||
fOnOff = new BButton("onoff", B_TRANSLATE("Disable"),
|
|
||||||
new BMessage(kMsgInterfaceToggle));
|
|
||||||
fOnOff->SetEnabled(false);
|
|
||||||
|
|
||||||
fRenegotiate = new BButton("heal", B_TRANSLATE("Renegotiate"),
|
|
||||||
new BMessage(kMsgInterfaceRenegotiate));
|
|
||||||
fRenegotiate->SetEnabled(false);
|
|
||||||
|
|
||||||
// Build the layout
|
// Build the layout
|
||||||
SetLayout(new BGroupLayout(B_HORIZONTAL));
|
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)
|
|
||||||
.Add(fOnOff)
|
|
||||||
.AddGlue()
|
|
||||||
.Add(fRenegotiate)
|
|
||||||
.End()
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
@@ -105,8 +91,6 @@ void
|
|||||||
InterfacesAddOn::AttachedToWindow()
|
InterfacesAddOn::AttachedToWindow()
|
||||||
{
|
{
|
||||||
fListView->SetTarget(this);
|
fListView->SetTarget(this);
|
||||||
fOnOff->SetTarget(this);
|
|
||||||
fRenegotiate->SetTarget(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -142,12 +126,8 @@ InterfacesAddOn::MessageReceived(BMessage* msg)
|
|||||||
switch (msg->what) {
|
switch (msg->what) {
|
||||||
case kMsgInterfaceSelected:
|
case kMsgInterfaceSelected:
|
||||||
{
|
{
|
||||||
fOnOff->SetEnabled(item != NULL);
|
|
||||||
fRenegotiate->SetEnabled(item != NULL);
|
|
||||||
if (item == NULL)
|
if (item == NULL)
|
||||||
break;
|
break;
|
||||||
fRenegotiate->SetEnabled(!item->IsDisabled());
|
|
||||||
fOnOff->SetLabel(item->IsDisabled() ? "Enable" : "Disable");
|
|
||||||
|
|
||||||
// TODO it would be better to reuse the view instead of recreating
|
// TODO it would be better to reuse the view instead of recreating
|
||||||
// one.
|
// one.
|
||||||
@@ -160,27 +140,9 @@ InterfacesAddOn::MessageReceived(BMessage* msg)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case kMsgInterfaceToggle:
|
case B_OBSERVER_NOTICE_CHANGE:
|
||||||
{
|
|
||||||
if (item == NULL)
|
|
||||||
break;
|
|
||||||
|
|
||||||
item->SetDisabled(!item->IsDisabled());
|
|
||||||
fOnOff->SetLabel(item->IsDisabled() ? "Enable" : "Disable");
|
|
||||||
fRenegotiate->SetEnabled(!item->IsDisabled());
|
|
||||||
fListView->Invalidate();
|
fListView->Invalidate();
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
case kMsgInterfaceRenegotiate:
|
|
||||||
{
|
|
||||||
if (item == NULL)
|
|
||||||
break;
|
|
||||||
|
|
||||||
NetworkSettings* ns = item->GetSettings();
|
|
||||||
ns->RenegotiateAddresses();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
BBox::MessageReceived(msg);
|
BBox::MessageReceived(msg);
|
||||||
|
|||||||
@@ -19,8 +19,6 @@
|
|||||||
|
|
||||||
|
|
||||||
static const uint32 kMsgInterfaceSelected = 'ifce';
|
static const uint32 kMsgInterfaceSelected = 'ifce';
|
||||||
static const uint32 kMsgInterfaceToggle = 'onof';
|
|
||||||
static const uint32 kMsgInterfaceRenegotiate = 'redo';
|
|
||||||
|
|
||||||
|
|
||||||
class BButton;
|
class BButton;
|
||||||
@@ -46,8 +44,6 @@ public:
|
|||||||
private:
|
private:
|
||||||
InterfacesListView* fListView;
|
InterfacesListView* fListView;
|
||||||
InterfaceView* fSettingsView;
|
InterfaceView* fSettingsView;
|
||||||
BButton* fOnOff;
|
|
||||||
BButton* fRenegotiate;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user