Example #1
0
// --------------------------------------------------------------
NetworkSetupWindow::NetworkSetupWindow(const char *title)
    :
    BWindow(BRect(100, 100, 300, 300), title, B_TITLED_WINDOW,
           B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS),
    fAddonCount(0)
{
    // ---- Profiles section
    BMenu *profilesPopup = new BPopUpMenu("<none>");
    _BuildProfilesMenu(profilesPopup, kMsgProfileSelected);

    BMenuField *profilesMenuField = new BMenuField("profiles_menu",
            B_TRANSLATE("Profile:"), profilesPopup);

    profilesMenuField->SetFont(be_bold_font);
    profilesMenuField->SetEnabled(false);

    // ---- Settings section

    fPanel = new BTabView("showview_box");

    fApplyButton = new BButton("apply", B_TRANSLATE("Apply"),
                               new BMessage(kMsgApply));
    SetDefaultButton(fApplyButton);

    fRevertButton = new BButton("revert", B_TRANSLATE("Revert"),
                                new BMessage(kMsgRevert));
    // fRevertButton->SetEnabled(false);

    // Enable boxes resizing modes
    //fPanel->SetResizingMode(B_FOLLOW_ALL);

    // Build the layout
    SetLayout(new BGroupLayout(B_VERTICAL));

    AddChild(BGroupLayoutBuilder(B_VERTICAL, B_USE_SMALL_SPACING)
             .AddGroup(B_HORIZONTAL, B_USE_SMALL_SPACING)
             .Add(profilesMenuField)
             .AddGlue()
             .End()
             .Add(fPanel)
             .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)
            );

    _BuildShowTabView(kMsgAddonShow);

    fPanel->SetExplicitMinSize(BSize(fMinAddonViewRect.Width(),
                                     fMinAddonViewRect.Height()));

    fAddonView = NULL;

    CenterOnScreen();
}
Example #2
0
NetworkWindow::NetworkWindow()
	:
	BWindow(BRect(100, 100, 400, 400), B_TRANSLATE("Network"), B_TITLED_WINDOW,
		B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS),
	fServicesItem(NULL),
	fDialUpItem(NULL),
	fOtherItem(NULL)
{
	// Profiles section
#if ENABLE_PROFILES
	BPopUpMenu* profilesPopup = new BPopUpMenu("<none>");
	_BuildProfilesMenu(profilesPopup, kMsgProfileSelected);

	BMenuField* profilesMenuField = new BMenuField("profiles_menu",
		B_TRANSLATE("Profile:"), profilesPopup);

	profilesMenuField->SetFont(be_bold_font);
	profilesMenuField->SetEnabled(false);
#endif

	// Settings section

	fRevertButton = new BButton("revert", B_TRANSLATE("Revert"),
		new BMessage(kMsgRevert));

	BMessage* message = new BMessage(kMsgToggleReplicant);
	BCheckBox* showReplicantCheckBox = new BCheckBox("showReplicantCheckBox",
		B_TRANSLATE("Show network status in Deskbar"), message);
	showReplicantCheckBox->SetExplicitMaxSize(
		BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
	showReplicantCheckBox->SetValue(_IsReplicantInstalled());

	fListView = new BOutlineListView("list", B_SINGLE_SELECTION_LIST,
		B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_FRAME_EVENTS | B_NAVIGABLE);
	fListView->SetSelectionMessage(new BMessage(kMsgItemSelected));

	BScrollView* scrollView = new BScrollView("ScrollView", fListView,
		0, false, true);
	scrollView->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));

	fAddOnShellView = new BView("add-on shell", 0,
		new BGroupLayout(B_VERTICAL));
	fAddOnShellView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	fInterfaceView = new InterfaceView();

	// Build the layout
	BLayoutBuilder::Group<>(this, B_VERTICAL)
		.SetInsets(B_USE_DEFAULT_SPACING)

#if ENABLE_PROFILES
		.AddGroup(B_HORIZONTAL, B_USE_SMALL_SPACING)
			.Add(profilesMenuField)
			.AddGlue()
		.End()
#endif
		.AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING)
			.Add(scrollView)
			.Add(fAddOnShellView)
			.End()
		.Add(showReplicantCheckBox)
		.AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING)
			.Add(fRevertButton)
			.AddGlue()
		.End();

	gNetworkWindow = this;

	_ScanInterfaces();
	_ScanAddOns();
	_UpdateRevertButton();

	fListView->Select(0);
	_SelectItem(fListView->ItemAt(0));
		// Call this manually, so that CenterOnScreen() below already
		// knows the final window size.

	// Set size of the list view from its contents
	float width;
	float height;
	fListView->GetPreferredSize(&width, &height);
	width += 2 * be_control_look->DefaultItemSpacing();
	fListView->SetExplicitSize(BSize(width, B_SIZE_UNSET));
	fListView->SetExplicitMinSize(BSize(width, std::min(height, 400.f)));

	CenterOnScreen();

	fSettings.StartMonitoring(this);
	start_watching_network(B_WATCH_NETWORK_INTERFACE_CHANGES
		| B_WATCH_NETWORK_LINK_CHANGES | B_WATCH_NETWORK_WLAN_CHANGES, this);
}