NetworkSetup: simplify UI layout

* Temporarily disable the non-working Profiles popup
* Remove the currently single-tabbed TabView
* Remove duplicate apply and revert buttons in the interfaces add-on.

The goal here is to remove functionalities not available in the current
network preferences, and finish the other parts, so we can put this new
preferences panel in service now. We can re-add the extra functionality
later.
This commit is contained in:
Adrien Destugues
2014-09-19 17:52:10 +02:00
parent 76a607d2fe
commit 763cd902f6
6 changed files with 58 additions and 72 deletions
@@ -24,33 +24,11 @@
InterfaceView::InterfaceView(NetworkSettings* settings) InterfaceView::InterfaceView(NetworkSettings* settings)
: :
BView("Interface Settings", 0, 0) BTabView("settings_tabs")
{ {
fNetworkSettings = settings; fNetworkSettings = settings;
SetTabWidth(B_WIDTH_FROM_LABEL);
fTabView = new BTabView("settings_tabs");
fTabView->SetTabWidth(B_WIDTH_FROM_LABEL);
fRevertButton = new BButton("revert", B_TRANSLATE("Revert"),
new BMessage(MSG_IP_REVERT));
fApplyButton = new BButton("save", B_TRANSLATE("Save"),
new BMessage(MSG_IP_SAVE));
_PopulateTabs(); _PopulateTabs();
SetLayout(new BGroupLayout(B_VERTICAL));
AddChild(BGroupLayoutBuilder(B_VERTICAL, B_USE_SMALL_SPACING)
.Add(fTabView)
.AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING)
.Add(fRevertButton)
.AddGlue()
.Add(fApplyButton)
.End()
.SetInsets(B_USE_SMALL_SPACING, B_USE_SMALL_SPACING,
B_USE_SMALL_SPACING, B_USE_SMALL_SPACING)
);
} }
@@ -60,38 +38,30 @@ InterfaceView::~InterfaceView()
void void
InterfaceView::AttachedToWindow() InterfaceView::Revert()
{ {
Window()->SetDefaultButton(fApplyButton); protocols* supportedFamilies = fNetworkSettings->ProtocolVersions();
for (int index = 0; index < MAX_PROTOCOLS; index++) {
if (supportedFamilies[index].present) {
int inet_id = supportedFamilies[index].inet_id;
fTabIPView[inet_id]->Revert();
}
}
} }
void void
InterfaceView::MessageReceived(BMessage* message) InterfaceView::Apply()
{ {
protocols* supportedFamilies = fNetworkSettings->ProtocolVersions(); protocols* supportedFamilies = fNetworkSettings->ProtocolVersions();
switch (message->what) { for (int index = 0; index < MAX_PROTOCOLS; index++) {
case MSG_IP_REVERT: if (supportedFamilies[index].present) {
for (int index = 0; index < MAX_PROTOCOLS; index++) { int inet_id = supportedFamilies[index].inet_id;
if (supportedFamilies[index].present) { fTabIPView[inet_id]->Save();
int inet_id = supportedFamilies[index].inet_id; }
fTabIPView[inet_id]->Revert();
}
}
break;
case MSG_IP_SAVE:
for (int index = 0; index < MAX_PROTOCOLS; index++) {
if (supportedFamilies[index].present) {
int inet_id = supportedFamilies[index].inet_id;
fTabIPView[inet_id]->Save();
}
}
break;
default:
BView::MessageReceived(message);
} }
} }
@@ -102,7 +72,7 @@ InterfaceView::_PopulateTabs()
BTab* hardwareTab = new BTab; BTab* hardwareTab = new BTab;
fTabHardwareView = new InterfaceHardwareView(fNetworkSettings); fTabHardwareView = new InterfaceHardwareView(fNetworkSettings);
fTabView->AddTab(fTabHardwareView, hardwareTab); 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++) {
@@ -111,7 +81,7 @@ InterfaceView::_PopulateTabs()
fTabIPView[inet_id] = new InterfaceAddressView(inet_id, fTabIPView[inet_id] = new InterfaceAddressView(inet_id,
fNetworkSettings); fNetworkSettings);
BTab* tab = new BTab; BTab* tab = new BTab;
fTabView->AddTab(fTabIPView[inet_id], tab); AddTab(fTabIPView[inet_id], tab);
tab->SetLabel(supportedFamilies[index].name); tab->SetLabel(supportedFamilies[index].name);
} }
} }
@@ -16,6 +16,7 @@
#include <map> #include <map>
#include <TabView.h>
#include <Window.h> #include <Window.h>
@@ -31,25 +32,21 @@ typedef std::map<int, InterfaceAddressView*> IPViewMap;
class BButton; class BButton;
class BTabView; class BTabView;
class InterfaceView : public BView { class InterfaceView : public BTabView {
public: public:
InterfaceView(NetworkSettings* settings); InterfaceView(NetworkSettings* settings);
virtual ~InterfaceView(); virtual ~InterfaceView();
virtual void AttachedToWindow();
virtual void MessageReceived(BMessage* mesage);
virtual bool QuitRequested(); virtual bool QuitRequested();
void Apply();
void Revert();
private: private:
status_t _PopulateTabs(); status_t _PopulateTabs();
NetworkSettings* fNetworkSettings; NetworkSettings* fNetworkSettings;
BButton* fRevertButton;
BButton* fApplyButton;
BTabView* fTabView;
IPViewMap fTabIPView; IPViewMap fTabIPView;
InterfaceHardwareView* fTabHardwareView; InterfaceHardwareView* fTabHardwareView;
}; };
@@ -50,6 +50,7 @@ InterfacesAddOn::InterfacesAddOn(image_id image)
NetworkSetupAddOn(image), NetworkSetupAddOn(image),
BBox(NULL, B_NAVIGABLE_JUMP, B_NO_BORDER) BBox(NULL, B_NAVIGABLE_JUMP, B_NO_BORDER)
{ {
fSettingsView = NULL;
} }
@@ -111,14 +112,27 @@ InterfacesAddOn::AttachedToWindow()
} }
// FIXME with this scheme the apply and revert button will only take effect for
// the currently shown interface. This can be confusing, it would be better to
// keep the state of all interfaces and allow reverting and saving all of them.
status_t status_t
InterfacesAddOn::Save() InterfacesAddOn::Save()
{ {
// TODO : Profile? // TODO : Profile?
fSettingsView->Apply();
return fListView->SaveItems(); return fListView->SaveItems();
} }
status_t
InterfacesAddOn::Revert()
{
fSettingsView->Revert();
return B_OK;
}
void void
InterfacesAddOn::MessageReceived(BMessage* msg) InterfacesAddOn::MessageReceived(BMessage* msg)
{ {
@@ -139,11 +153,12 @@ InterfacesAddOn::MessageReceived(BMessage* msg)
// 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.
InterfaceView* sw = new InterfaceView(item->GetSettings()); if (fSettingsView != NULL) {
BView* old = ChildAt(1); fSettingsView->RemoveSelf();
RemoveChild(old); delete fSettingsView;
delete old; }
AddChild(sw); fSettingsView = new InterfaceView(item->GetSettings());
AddChild(fSettingsView);
break; break;
} }
@@ -26,6 +26,8 @@ static const uint32 kMsgInterfaceRenegotiate = 'redo';
class BButton; class BButton;
class BView; class BView;
class InterfaceView;
class InterfacesAddOn : public NetworkSetupAddOn, public BBox class InterfacesAddOn : public NetworkSetupAddOn, public BBox
{ {
public: public:
@@ -34,6 +36,7 @@ public:
const char* Name(); const char* Name();
status_t Save(); status_t Save();
status_t Revert();
BView* CreateView(); BView* CreateView();
@@ -42,6 +45,7 @@ public:
private: private:
InterfacesListView* fListView; InterfacesListView* fListView;
InterfaceView* fSettingsView;
BButton* fOnOff; BButton* fOnOff;
BButton* fRenegotiate; BButton* fRenegotiate;
}; };
@@ -38,6 +38,7 @@ NetworkSetupWindow::NetworkSetupWindow(const char *title)
fAddonCount(0) fAddonCount(0)
{ {
// ---- Profiles section // ---- Profiles section
#if 0
BMenu *profilesPopup = new BPopUpMenu("<none>"); BMenu *profilesPopup = new BPopUpMenu("<none>");
_BuildProfilesMenu(profilesPopup, kMsgProfileSelected); _BuildProfilesMenu(profilesPopup, kMsgProfileSelected);
@@ -46,10 +47,11 @@ NetworkSetupWindow::NetworkSetupWindow(const char *title)
profilesMenuField->SetFont(be_bold_font); profilesMenuField->SetFont(be_bold_font);
profilesMenuField->SetEnabled(false); profilesMenuField->SetEnabled(false);
#endif
// ---- Settings section // ---- Settings section
fPanel = new BTabView("showview_box"); fPanel = new BGroupView(B_VERTICAL);
fApplyButton = new BButton("apply", B_TRANSLATE("Apply"), fApplyButton = new BButton("apply", B_TRANSLATE("Apply"),
new BMessage(kMsgApply)); new BMessage(kMsgApply));
@@ -59,17 +61,16 @@ NetworkSetupWindow::NetworkSetupWindow(const char *title)
new BMessage(kMsgRevert)); new BMessage(kMsgRevert));
// fRevertButton->SetEnabled(false); // fRevertButton->SetEnabled(false);
// Enable boxes resizing modes
//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, B_USE_SMALL_SPACING) AddChild(BGroupLayoutBuilder(B_VERTICAL, B_USE_SMALL_SPACING)
#if 0
.AddGroup(B_HORIZONTAL, B_USE_SMALL_SPACING) .AddGroup(B_HORIZONTAL, B_USE_SMALL_SPACING)
.Add(profilesMenuField) .Add(profilesMenuField)
.AddGlue() .AddGlue()
.End() .End()
#endif
.Add(fPanel) .Add(fPanel)
.AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING) .AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING)
.Add(fRevertButton) .Add(fRevertButton)
@@ -154,8 +155,6 @@ NetworkSetupWindow::MessageReceived(BMessage* msg)
break; break;
fPanel->AddChild(fAddonView); fPanel->AddChild(fAddonView);
fAddonView->ResizeTo(fPanel->Bounds().Width(),
fPanel->Bounds().Height());
break; break;
} }
@@ -301,9 +300,10 @@ NetworkSetupWindow::_BuildShowTabView(int32 msg_what)
msg->AddPointer("addon", fNetworkAddOnMap[fAddonCount]); msg->AddPointer("addon", fNetworkAddOnMap[fAddonCount]);
msg->AddPointer("addon_view", addon_view); msg->AddPointer("addon_view", addon_view);
BTab* tab = new BTab; // FIXME rework this: we don't want to use a tab view here,
fPanel->AddTab(addon_view, tab); // instead add-ons should populate the "interfaces" list with
tab->SetLabel(fNetworkAddOnMap[fAddonCount]->Name()); // interfaces, services, etc.
fPanel->AddChild(addon_view);
fAddonCount++; fAddonCount++;
// Number of tab addons total // Number of tab addons total
tabCount++; tabCount++;
@@ -53,7 +53,7 @@ class NetworkSetupWindow : public BWindow
NetworkAddOnMap fNetworkAddOnMap; NetworkAddOnMap fNetworkAddOnMap;
BTabView* fPanel; BView* fPanel;
BView* fAddonView; BView* fAddonView;
int fAddonCount; int fAddonCount;
}; };