Disable the apply button when settings have been...er.. applied. Do some
enabling/disabling of the revert button too. Initialize Settings::fAuto to a default value on construction. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24032 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -56,6 +56,16 @@
|
|||||||
#include "AutoDeleter.h"
|
#include "AutoDeleter.h"
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
SetupTextControl(BTextControl *control)
|
||||||
|
{
|
||||||
|
// TODO: Disallow characters, etc.
|
||||||
|
// Would be nice to have a real
|
||||||
|
// formatted input control
|
||||||
|
control->SetModificationMessage(new BMessage(kMsgChange));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
EthernetSettingsView::_PrepareRequest(struct ifreq& request, const char* name)
|
EthernetSettingsView::_PrepareRequest(struct ifreq& request, const char* name)
|
||||||
{
|
{
|
||||||
@@ -116,6 +126,11 @@ EthernetSettingsView::AttachedToWindow()
|
|||||||
{
|
{
|
||||||
fApplyButton->SetTarget(this);
|
fApplyButton->SetTarget(this);
|
||||||
fRevertButton->SetTarget(this);
|
fRevertButton->SetTarget(this);
|
||||||
|
fIPTextControl->SetTarget(this);
|
||||||
|
fNetMaskTextControl->SetTarget(this);
|
||||||
|
fGatewayTextControl->SetTarget(this);
|
||||||
|
fPrimaryDNSTextControl->SetTarget(this);
|
||||||
|
fSecondaryDNSTextControl->SetTarget(this);
|
||||||
fDeviceMenuField->Menu()->SetTargetForItems(this);
|
fDeviceMenuField->Menu()->SetTargetForItems(this);
|
||||||
fTypeMenuField->Menu()->SetTargetForItems(this);
|
fTypeMenuField->Menu()->SetTargetForItems(this);
|
||||||
|
|
||||||
@@ -175,11 +190,13 @@ EthernetSettingsView::EthernetSettingsView(BRect frame)
|
|||||||
fIPTextControl = new BTextControl(frame, "ip", "IP Address:", "", NULL);
|
fIPTextControl = new BTextControl(frame, "ip", "IP Address:", "", NULL);
|
||||||
fIPTextControl->MoveTo(fTypeMenuField->Frame().LeftBottom() + spacing);
|
fIPTextControl->MoveTo(fTypeMenuField->Frame().LeftBottom() + spacing);
|
||||||
fIPTextControl->ResizeToPreferred();
|
fIPTextControl->ResizeToPreferred();
|
||||||
|
SetupTextControl(fIPTextControl);
|
||||||
AddChild(fIPTextControl);
|
AddChild(fIPTextControl);
|
||||||
|
|
||||||
fNetMaskTextControl = new BTextControl(frame, "mask", "Netmask:", "", NULL);
|
fNetMaskTextControl = new BTextControl(frame, "mask", "Netmask:", "", NULL);
|
||||||
fNetMaskTextControl->MoveTo(
|
fNetMaskTextControl->MoveTo(
|
||||||
fIPTextControl->Frame().LeftBottom() + spacing);
|
fIPTextControl->Frame().LeftBottom() + spacing);
|
||||||
|
SetupTextControl(fNetMaskTextControl);
|
||||||
AddChild(fNetMaskTextControl);
|
AddChild(fNetMaskTextControl);
|
||||||
fNetMaskTextControl->ResizeToPreferred();
|
fNetMaskTextControl->ResizeToPreferred();
|
||||||
|
|
||||||
@@ -187,6 +204,7 @@ EthernetSettingsView::EthernetSettingsView(BRect frame)
|
|||||||
NULL);
|
NULL);
|
||||||
fGatewayTextControl->MoveTo(
|
fGatewayTextControl->MoveTo(
|
||||||
fNetMaskTextControl->Frame().LeftBottom() + spacing);
|
fNetMaskTextControl->Frame().LeftBottom() + spacing);
|
||||||
|
SetupTextControl(fGatewayTextControl);
|
||||||
AddChild(fGatewayTextControl);
|
AddChild(fGatewayTextControl);
|
||||||
fGatewayTextControl->ResizeToPreferred();
|
fGatewayTextControl->ResizeToPreferred();
|
||||||
|
|
||||||
@@ -194,6 +212,7 @@ EthernetSettingsView::EthernetSettingsView(BRect frame)
|
|||||||
NULL);
|
NULL);
|
||||||
fPrimaryDNSTextControl->MoveTo(
|
fPrimaryDNSTextControl->MoveTo(
|
||||||
fGatewayTextControl->Frame().LeftBottom() + spacing);
|
fGatewayTextControl->Frame().LeftBottom() + spacing);
|
||||||
|
SetupTextControl(fPrimaryDNSTextControl);
|
||||||
AddChild(fPrimaryDNSTextControl);
|
AddChild(fPrimaryDNSTextControl);
|
||||||
fPrimaryDNSTextControl->ResizeToPreferred();
|
fPrimaryDNSTextControl->ResizeToPreferred();
|
||||||
|
|
||||||
@@ -201,6 +220,7 @@ EthernetSettingsView::EthernetSettingsView(BRect frame)
|
|||||||
NULL);
|
NULL);
|
||||||
fSecondaryDNSTextControl->MoveTo(
|
fSecondaryDNSTextControl->MoveTo(
|
||||||
fPrimaryDNSTextControl->Frame().LeftBottom() + spacing);
|
fPrimaryDNSTextControl->Frame().LeftBottom() + spacing);
|
||||||
|
SetupTextControl(fSecondaryDNSTextControl);
|
||||||
AddChild(fSecondaryDNSTextControl);
|
AddChild(fSecondaryDNSTextControl);
|
||||||
fSecondaryDNSTextControl->ResizeToPreferred();
|
fSecondaryDNSTextControl->ResizeToPreferred();
|
||||||
|
|
||||||
@@ -209,6 +229,7 @@ EthernetSettingsView::EthernetSettingsView(BRect frame)
|
|||||||
fRevertButton->ResizeToPreferred();
|
fRevertButton->ResizeToPreferred();
|
||||||
fRevertButton->MoveTo(
|
fRevertButton->MoveTo(
|
||||||
fSecondaryDNSTextControl->Frame().LeftBottom() + spacing);
|
fSecondaryDNSTextControl->Frame().LeftBottom() + spacing);
|
||||||
|
fRevertButton->SetEnabled(false);
|
||||||
AddChild(fRevertButton);
|
AddChild(fRevertButton);
|
||||||
|
|
||||||
fApplyButton = new BButton(frame, "apply", "Apply", new BMessage(kMsgApply));
|
fApplyButton = new BButton(frame, "apply", "Apply", new BMessage(kMsgApply));
|
||||||
@@ -330,6 +351,9 @@ EthernetSettingsView::_ApplyControlsToConfiguration()
|
|||||||
fPrimaryDNSTextControl->Text()));
|
fPrimaryDNSTextControl->Text()));
|
||||||
fCurrentSettings->fNameservers.AddItem(new BString(
|
fCurrentSettings->fNameservers.AddItem(new BString(
|
||||||
fSecondaryDNSTextControl->Text()));
|
fSecondaryDNSTextControl->Text()));
|
||||||
|
|
||||||
|
fApplyButton->SetEnabled(false);
|
||||||
|
fRevertButton->SetEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -437,6 +461,8 @@ EthernetSettingsView::MessageReceived(BMessage* message)
|
|||||||
case kMsgMode:
|
case kMsgMode:
|
||||||
if (BMenuItem* item = fTypeMenuField->Menu()->FindMarked())
|
if (BMenuItem* item = fTypeMenuField->Menu()->FindMarked())
|
||||||
_EnableTextControls(strcmp(item->Label(), "DHCP") != 0);
|
_EnableTextControls(strcmp(item->Label(), "DHCP") != 0);
|
||||||
|
fApplyButton->SetEnabled(true);
|
||||||
|
fRevertButton->SetEnabled(true);
|
||||||
break;
|
break;
|
||||||
case kMsgInfo: {
|
case kMsgInfo: {
|
||||||
const char* name;
|
const char* name;
|
||||||
@@ -453,10 +479,14 @@ EthernetSettingsView::MessageReceived(BMessage* message)
|
|||||||
}
|
}
|
||||||
case kMsgRevert:
|
case kMsgRevert:
|
||||||
_ShowConfiguration(fCurrentSettings);
|
_ShowConfiguration(fCurrentSettings);
|
||||||
|
fRevertButton->SetEnabled(false);
|
||||||
break;
|
break;
|
||||||
case kMsgApply:
|
case kMsgApply:
|
||||||
_SaveConfiguration();
|
_SaveConfiguration();
|
||||||
break;
|
break;
|
||||||
|
case kMsgChange:
|
||||||
|
fApplyButton->SetEnabled(true);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
BView::MessageReceived(message);
|
BView::MessageReceived(message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ static const uint32 kMsgClose = 'clse';
|
|||||||
static const uint32 kMsgField = 'fild';
|
static const uint32 kMsgField = 'fild';
|
||||||
static const uint32 kMsgInfo = 'info';
|
static const uint32 kMsgInfo = 'info';
|
||||||
static const uint32 kMsgMode = 'mode';
|
static const uint32 kMsgMode = 'mode';
|
||||||
|
static const uint32 kMsgChange = 'chng';
|
||||||
|
|
||||||
|
|
||||||
class EthernetSettingsView : public BView {
|
class EthernetSettingsView : public BView {
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -31,6 +31,8 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
Settings::Settings(const char *name)
|
Settings::Settings(const char *name)
|
||||||
|
:
|
||||||
|
fAuto(true)
|
||||||
{
|
{
|
||||||
fSocket = socket(AF_INET, SOCK_DGRAM, 0);
|
fSocket = socket(AF_INET, SOCK_DGRAM, 0);
|
||||||
fName = name;
|
fName = name;
|
||||||
|
|||||||
Reference in New Issue
Block a user