added initial interface settings dialog

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40451 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Alexander von Gluck IV
2011-02-11 22:31:49 +00:00
parent 9468533bfe
commit bd000a4a14
6 changed files with 148 additions and 84 deletions
@@ -16,6 +16,7 @@
#include "InterfacesAddOn.h"
#include "InterfacesListView.h"
#include "SettingsWindow.h"
#include <stdio.h>
@@ -136,8 +137,8 @@ InterfacesAddOn::MessageReceived(BMessage* msg)
if (!item)
break;
//NetworkWindow* nw = new NetworkWindow(item->GetSettings());
//nw->Show();
SettingsWindow* sw = new SettingsWindow(item->GetSettings());
sw->Show();
break;
}
@@ -17,6 +17,7 @@ Addon Interfaces :
InterfacesAddOn.cpp
InterfacesListView.cpp
NetworkSettings.cpp
SettingsWindow.cpp
# from src/apps/networkstatus
RadioView.cpp
@@ -1,52 +0,0 @@
/*
* Copyright 2004-2008 Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Author:
* Andre Alves Garzia, [email protected]
* Fredrik Modéen
*/
#include "NetworkWindow.h"
#include <Application.h>
#include <GroupLayout.h>
#include "EthernetSettingsView.h"
#include "NetworkSettings.h"
NetworkWindow::NetworkWindow(NetworkSettings* settings)
: BWindow(BRect(50, 50, 269, 302), "Network", B_TITLED_WINDOW,
B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE
| B_AUTO_UPDATE_SIZE_LIMITS)
{
SetLayout(new BGroupLayout(B_HORIZONTAL));
fEthernetView = new EthernetSettingsView(); // settings);
GetLayout()->AddView(fEthernetView);
SetTitle(settings->Name());
}
NetworkWindow::~NetworkWindow()
{
}
void
NetworkWindow::MessageReceived(BMessage* message)
{
switch (message->what) {
default:
BWindow::MessageReceived(message);
}
}
bool
NetworkWindow::QuitRequested()
{
return true;
}
@@ -1,30 +0,0 @@
/*
* Copyright 2004-2008 Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Author:
* Andre Alves Garzia, [email protected]
* Fredrik Modéen
*/
#ifndef NETWORK_WINDOW_H
#define NETWORK_WINDOW_H
#include <Window.h>
class Settings;
class EthernetSettingsView;
class NetworkWindow : public BWindow {
public:
NetworkWindow(Settings* setting);
virtual ~NetworkWindow();
virtual bool QuitRequested();
virtual void MessageReceived(BMessage* mesage);
private:
EthernetSettingsView* fEthernetView;
};
#endif /* NETWORK_WINDOW_H */
@@ -0,0 +1,97 @@
/*
* Copyright 2004-2011 Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Alexander von Gluck, [email protected]
*/
#include "SettingsWindow.h"
#include <Application.h>
#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "NetworkSetupWindow"
SettingsWindow::SettingsWindow(NetworkSettings* settings)
: BWindow(BRect(50, 50, 400, 302), "Interface Settings",
B_TITLED_WINDOW_LOOK, B_MODAL_APP_WINDOW_FEEL,
B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE
| B_AUTO_UPDATE_SIZE_LIMITS, B_CURRENT_WORKSPACE)
{
fNetworkSettings = settings;
fTabView = new BTabView("settings_tabs");
fApplyButton = new BButton("apply", B_TRANSLATE("Apply"),
new BMessage(APPLY_MSG));
fCancelButton = new BButton("cancel", B_TRANSLATE("Cancel"),
new BMessage(CANCEL_MSG));
fTabView->SetResizingMode(B_FOLLOW_ALL);
// ensure tab container matches window size
_PopulateTabs();
SetLayout(new BGroupLayout(B_VERTICAL));
AddChild(BGroupLayoutBuilder(B_VERTICAL, 10)
.Add(fTabView)
.AddGroup(B_HORIZONTAL, 5)
.AddGlue()
.Add(fCancelButton)
.Add(fApplyButton)
.End()
.SetInsets(10, 10, 10, 10)
);
}
SettingsWindow::~SettingsWindow()
{
}
void
SettingsWindow::MessageReceived(BMessage* message)
{
switch (message->what) {
default:
BWindow::MessageReceived(message);
}
}
status_t
SettingsWindow::_PopulateTabs()
{
// TODO : Temporary, just to get example data
BRect frame = fTabView->Bounds();
BView* view4 = new BView(frame, "net_settings_ipv4",
B_FOLLOW_ALL_SIDES, B_WILL_DRAW);
BView* view6 = new BView(frame, "net_settings_ipv6",
B_FOLLOW_ALL_SIDES, B_WILL_DRAW);
BTab* tab4 = new BTab;
BTab* tab6 = new BTab;
fTabView->AddTab(view4, tab4);
tab4->SetLabel("IPv4");
fTabView->AddTab(view6, tab6);
tab6->SetLabel("IPv6");
return B_OK;
}
bool
SettingsWindow::QuitRequested()
{
return true;
}
@@ -0,0 +1,47 @@
/*
* Copyright 2004-2011 Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Alexander von Gluck, [email protected]
*/
#ifndef SETTINGS_WINDOW_H
#define SETTINGS_WINDOW_H
#include "NetworkSettings.h"
#include <Button.h>
#include <Catalog.h>
#include <GroupLayout.h>
#include <GroupLayoutBuilder.h>
#include <TabView.h>
#include <Window.h>
enum {
APPLY_MSG = 'aply',
CANCEL_MSG = 'cncl'
};
class SettingsWindow : public BWindow {
public:
SettingsWindow(NetworkSettings* settings);
virtual ~SettingsWindow();
virtual bool QuitRequested();
virtual void MessageReceived(BMessage* mesage);
private:
status_t _PopulateTabs();
NetworkSettings* fNetworkSettings;
BButton* fApplyButton;
BButton* fCancelButton;
BTabView* fTabView;
};
#endif /* SETTINGS_WINDOW_H */