Ticket #4941: network.patch
File network.patch, 8.0 KB (added by , 14 years ago) |
---|
-
NetworkApp.h
15 15 #include <stdlib.h> 16 16 #include <unistd.h> 17 17 #include <Application.h> 18 #include <Catalog.h> 19 #include <Locale.h> 18 20 19 21 #include "NetworkWindow.h" 20 22 … … 26 28 virtual void ReadyToRun(); 27 29 private: 28 30 NetworkWindow *fEthWindow; 31 BCatalog fCatalog; 29 32 }; 30 33 31 34 -
NetworkWindow.cpp
9 9 #include "NetworkWindow.h" 10 10 11 11 #include <Application.h> 12 #include <Catalog.h> 12 13 #include <GroupLayout.h> 14 #include <Locale.h> 13 15 14 16 #include "EthernetSettingsView.h" 15 17 18 #undef TR_CONTEXT 19 #define TR_CONTEXT "NetworkWindow" 16 20 17 21 NetworkWindow::NetworkWindow() 18 : BWindow(BRect(50, 50, 269, 302), "Network", B_TITLED_WINDOW,22 : BWindow(BRect(50, 50, 269, 302), TR("Network"), B_TITLED_WINDOW, 19 23 B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE 20 24 | B_AUTO_UPDATE_SIZE_LIMITS) 21 25 { -
Jamfile
9 9 EthernetSettingsView.cpp 10 10 Settings.cpp 11 11 12 : be $(HAIKU_NETWORK_LIBS) $(TARGET_LIBSUPC++) 12 : be $(HAIKU_NETWORK_LIBS) $(TARGET_LIBSUPC++) liblocale.so 13 13 : Network.rdef 14 14 ; 15 16 DoCatalogs Network : 17 x-vnd.Haiku-Network 18 : 19 EthernetSettingsView.cpp 20 NetworkWindow.cpp 21 : en.catalog 22 ; -
EthernetSettingsView.cpp
18 18 #include <Alert.h> 19 19 #include <Box.h> 20 20 #include <Button.h> 21 #include <Catalog.h> 21 22 #include <CheckBox.h> 22 23 #include <File.h> 23 24 #include <GridView.h> 24 25 #include <GroupView.h> 25 26 #include <LayoutItem.h> 27 #include <Locale.h> 26 28 #include <Slider.h> 27 29 #include <SpaceLayoutItem.h> 28 30 #include <StringView.h> … … 87 89 88 90 // #pragma mark - 89 91 92 #undef TR_CONTEXT 93 #define TR_CONTEXT "EthernetSettingsView" 90 94 91 95 EthernetSettingsView::EthernetSettingsView() 92 96 : BView("EthernetSettingsView", 0, NULL), … … 121 125 } 122 126 123 127 BPopUpMenu* modeMenu = new BPopUpMenu("modes"); 124 modeMenu->AddItem(new BMenuItem( "Static", new BMessage(kMsgMode)));125 modeMenu->AddItem(new BMenuItem( "DHCP", new BMessage(kMsgMode)));128 modeMenu->AddItem(new BMenuItem(TR("Static"), new BMessage(kMsgMode))); 129 modeMenu->AddItem(new BMenuItem(TR("DHCP"), new BMessage(kMsgMode))); 126 130 //modeMenu->AddSeparatorItem(); 127 131 //BMenuItem* offItem = new BMenuItem("Disabled", NULL); 128 132 //modeMenu->AddItem(offItem); 129 133 130 fDeviceMenuField = new BMenuField( "Adapter:", deviceMenu);134 fDeviceMenuField = new BMenuField(TR("Adapter:"), deviceMenu); 131 135 layout->AddItem(fDeviceMenuField->CreateLabelLayoutItem(), 0, 0); 132 136 layout->AddItem(fDeviceMenuField->CreateMenuBarLayoutItem(), 1, 0); 133 137 134 fTypeMenuField = new BMenuField( "Mode:", modeMenu);138 fTypeMenuField = new BMenuField(TR("Mode:"), modeMenu); 135 139 layout->AddItem(fTypeMenuField->CreateLabelLayoutItem(), 0, 1); 136 140 layout->AddItem(fTypeMenuField->CreateMenuBarLayoutItem(), 1, 1); 137 141 138 fIPTextControl = new BTextControl( "IP Address:", "", NULL);142 fIPTextControl = new BTextControl(TR("IP Address:"), "", NULL); 139 143 SetupTextControl(fIPTextControl); 140 144 141 145 BLayoutItem* layoutItem = fIPTextControl->CreateTextViewLayoutItem(); … … 146 150 layout->AddItem(fIPTextControl->CreateLabelLayoutItem(), 0, 2); 147 151 layout->AddItem(layoutItem, 1, 2); 148 152 149 fNetMaskTextControl = new BTextControl( "Netmask:", "", NULL);153 fNetMaskTextControl = new BTextControl(TR("Netmask:"), "", NULL); 150 154 SetupTextControl(fNetMaskTextControl); 151 155 layout->AddItem(fNetMaskTextControl->CreateLabelLayoutItem(), 0, 3); 152 156 layout->AddItem(fNetMaskTextControl->CreateTextViewLayoutItem(), 1, 3); 153 157 154 fGatewayTextControl = new BTextControl( "Gateway:", "", NULL);158 fGatewayTextControl = new BTextControl(TR("Gateway:"), "", NULL); 155 159 SetupTextControl(fGatewayTextControl); 156 160 layout->AddItem(fGatewayTextControl->CreateLabelLayoutItem(), 0, 4); 157 161 layout->AddItem(fGatewayTextControl->CreateTextViewLayoutItem(), 1, 4); 158 162 159 163 // TODO: Replace the DNS text controls by a BListView with add/remove 160 164 // functionality and so on... 161 fPrimaryDNSTextControl = new BTextControl( "DNS #1:", "", NULL);165 fPrimaryDNSTextControl = new BTextControl(TR("DNS #1:"), "", NULL); 162 166 SetupTextControl(fPrimaryDNSTextControl); 163 167 layout->AddItem(fPrimaryDNSTextControl->CreateLabelLayoutItem(), 0, 5); 164 168 layout->AddItem(fPrimaryDNSTextControl->CreateTextViewLayoutItem(), 1, 5); 165 169 166 fSecondaryDNSTextControl = new BTextControl( "DNS #2:", "", NULL);170 fSecondaryDNSTextControl = new BTextControl(TR("DNS #2:"), "", NULL); 167 171 SetupTextControl(fSecondaryDNSTextControl); 168 172 layout->AddItem(fSecondaryDNSTextControl->CreateLabelLayoutItem(), 0, 6); 169 173 layout->AddItem(fSecondaryDNSTextControl->CreateTextViewLayoutItem(), 1, 6); … … 179 183 // enabling/disabling) 180 184 BGroupView* buttonGroup = new BGroupView(B_HORIZONTAL); 181 185 182 fRevertButton = new BButton( "Revert", new BMessage(kMsgRevert));186 fRevertButton = new BButton(TR("Revert"), new BMessage(kMsgRevert)); 183 187 fRevertButton->SetEnabled(false); 184 188 buttonGroup->GroupLayout()->AddView(fRevertButton); 185 189 186 190 buttonGroup->GroupLayout()->AddItem(BSpaceLayoutItem::CreateGlue()); 187 191 188 fApplyButton = new BButton( "Apply", new BMessage(kMsgApply));192 fApplyButton = new BButton(TR("Apply"), new BMessage(kMsgApply)); 189 193 buttonGroup->GroupLayout()->AddView(fApplyButton); 190 194 191 195 rootLayout->AddView(controlsGroup); … … 304 308 fNetMaskTextControl->SetText(settings->Netmask()); 305 309 306 310 if (settings->AutoConfigure() == true) 307 item = fTypeMenuField->Menu()->FindItem( "DHCP");311 item = fTypeMenuField->Menu()->FindItem(TR("DHCP")); 308 312 else 309 item = fTypeMenuField->Menu()->FindItem( "Static");313 item = fTypeMenuField->Menu()->FindItem(TR("Static")); 310 314 if (item) 311 315 item->SetMarked(true); 312 316 … … 349 353 fCurrentSettings->SetGateway(fGatewayTextControl->Text()); 350 354 351 355 fCurrentSettings->SetAutoConfigure( 352 strcmp(fTypeMenuField->Menu()->FindMarked()->Label(), "DHCP") == 0);356 strcmp(fTypeMenuField->Menu()->FindMarked()->Label(), TR("DHCP")) == 0); 353 357 354 358 fCurrentSettings->NameServers().MakeEmpty(); 355 359 fCurrentSettings->NameServers().AddItem(new BString( … … 456 460 { 457 461 BMessenger networkServer(kNetServerSignature); 458 462 if (!networkServer.IsValid()) { 459 (new BAlert("error", "The net_server needs to run for the auto "460 "configuration!" , "Ok"))->Go();463 (new BAlert("error", TR("The net_server needs to run for the auto " 464 "configuration!"), TR("Ok")))->Go(); 461 465 return B_ERROR; 462 466 } 463 467 … … 471 475 BMessage reply; 472 476 status_t status = networkServer.SendMessage(&message, &reply); 473 477 if (status != B_OK) { 474 BString errorMessage( "Sending auto-config message failed: ");478 BString errorMessage(TR("Sending auto-config message failed: ")); 475 479 errorMessage << strerror(status); 476 (new BAlert("error", errorMessage.String(), "Ok"))->Go();480 (new BAlert("error", errorMessage.String(), TR("Ok")))->Go(); 477 481 return status; 478 482 } else if (reply.FindInt32("status", &status) == B_OK 479 483 && status != B_OK) { 480 BString errorMessage( "Auto-configuring failed: ");484 BString errorMessage(TR("Auto-configuring failed: ")); 481 485 errorMessage << strerror(status); 482 486 (new BAlert("error", errorMessage.String(), "Ok"))->Go(); 483 487 return status; … … 540 544 switch (message->what) { 541 545 case kMsgMode: 542 546 if (BMenuItem* item = fTypeMenuField->Menu()->FindMarked()) 543 _EnableTextControls(strcmp(item->Label(), "DHCP") != 0);547 _EnableTextControls(strcmp(item->Label(), TR("DHCP")) != 0); 544 548 fApplyButton->SetEnabled(true); 545 549 fRevertButton->SetEnabled(true); 546 550 break; -
NetworkApp.cpp
15 15 NetworkApp::NetworkApp() 16 16 : BApplication("application/x-vnd.Haiku-Network") 17 17 { 18 be_locale->GetAppCatalog(&fCatalog); 18 19 } 19 20 20 21 NetworkApp::~NetworkApp()