status_t InterfacesListView::SaveItems() { // Grab each fSettings instance and write it's settings for (int32 i = CountItems(); i-- > 0;) { InterfaceListItem* item = dynamic_cast<InterfaceListItem*>(ItemAt(i)); if (item == NULL) continue; if (strcmp(item->Name(), "loop") == 0) continue; NetworkSettings* ns = item->GetSettings(); // TODO : SetConfiguration doesn't use the interface settings file ns->SetConfiguration(); } return B_OK; }
void InterfacesListView::MouseDown(BPoint where) { int32 buttons = 0; Window()->CurrentMessage()->FindInt32("buttons", &buttons); if ((B_SECONDARY_MOUSE_BUTTON & buttons) == 0) { // If not secondary mouse button do the default BListView::MouseDown(where); return; } InterfaceListItem* item = FindItem(where); if (item == NULL) return; // Remove all items from the menu for (int32 i = fContextMenu->CountItems(); i >= 0; --i) { BMenuItem* menuItem = fContextMenu->RemoveItem(i); delete menuItem; } // Now add the ones we want if (item->GetSettings()->IsDisabled()) { fContextMenu->AddItem(new BMenuItem(B_TRANSLATE("Enable"), new BMessage(kMsgInterfaceToggle))); } else { fContextMenu->AddItem(new BMenuItem( B_TRANSLATE("Configure" B_UTF8_ELLIPSIS), new BMessage(kMsgInterfaceConfigure))); if (item->GetSettings()->AutoConfigure(AF_INET) || item->GetSettings()->AutoConfigure(AF_INET6)) { fContextMenu->AddItem(new BMenuItem( B_TRANSLATE("Renegotiate Address"), new BMessage(kMsgInterfaceRenegotiate))); } fContextMenu->AddItem(new BSeparatorItem()); fContextMenu->AddItem(new BMenuItem(B_TRANSLATE("Disable"), new BMessage(kMsgInterfaceToggle))); } fContextMenu->ResizeToPreferred(); BMenuItem* selected = fContextMenu->Go(ConvertToScreen(where)); if (selected == NULL) return; switch (selected->Message()->what) { case kMsgInterfaceConfigure: { InterfaceWindow* win = new InterfaceWindow(item->GetSettings()); win->MoveTo(ConvertToScreen(where)); win->Show(); break; } case kMsgInterfaceToggle: item->SetDisabled(!item->IsDisabled()); Invalidate(); break; case kMsgInterfaceRenegotiate: item->GetSettings()->RenegotiateAddresses(); break; } }