Ticket #4941: network.patch

File network.patch, 8.0 KB (added by mt, 12 years ago)

patch file

  • NetworkApp.h

     
    1515#include <stdlib.h>
    1616#include <unistd.h>
    1717#include <Application.h>
     18#include <Catalog.h>
     19#include <Locale.h>
    1820
    1921#include "NetworkWindow.h"
    2022
     
    2628        virtual void ReadyToRun();
    2729    private:
    2830        NetworkWindow   *fEthWindow;
     31        BCatalog    fCatalog;
    2932};
    3033
    3134
  • NetworkWindow.cpp

     
    99#include "NetworkWindow.h"
    1010
    1111#include <Application.h>
     12#include <Catalog.h>
    1213#include <GroupLayout.h>
     14#include <Locale.h>
    1315
    1416#include "EthernetSettingsView.h"
    1517
     18#undef TR_CONTEXT
     19#define TR_CONTEXT "NetworkWindow"
    1620
    1721NetworkWindow::NetworkWindow()
    18     : BWindow(BRect(50, 50, 269, 302), "Network", B_TITLED_WINDOW,
     22    : BWindow(BRect(50, 50, 269, 302), TR("Network"), B_TITLED_WINDOW,
    1923        B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE
    2024        | B_AUTO_UPDATE_SIZE_LIMITS)
    2125{
  • Jamfile

     
    99    EthernetSettingsView.cpp
    1010    Settings.cpp
    1111
    12     : be $(HAIKU_NETWORK_LIBS) $(TARGET_LIBSUPC++)
     12    : be $(HAIKU_NETWORK_LIBS) $(TARGET_LIBSUPC++) liblocale.so
    1313    : Network.rdef
    1414;
     15
     16DoCatalogs Network :
     17    x-vnd.Haiku-Network
     18    :
     19    EthernetSettingsView.cpp
     20    NetworkWindow.cpp
     21    : en.catalog
     22    ;
  • EthernetSettingsView.cpp

     
    1818#include <Alert.h>
    1919#include <Box.h>
    2020#include <Button.h>
     21#include <Catalog.h>
    2122#include <CheckBox.h>
    2223#include <File.h>
    2324#include <GridView.h>
    2425#include <GroupView.h>
    2526#include <LayoutItem.h>
     27#include <Locale.h>
    2628#include <Slider.h>
    2729#include <SpaceLayoutItem.h>
    2830#include <StringView.h>
     
    8789
    8890//  #pragma mark -
    8991
     92#undef TR_CONTEXT
     93#define TR_CONTEXT "EthernetSettingsView"
    9094
    9195EthernetSettingsView::EthernetSettingsView()
    9296    : BView("EthernetSettingsView", 0, NULL),
     
    121125    }
    122126
    123127    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)));
    126130    //modeMenu->AddSeparatorItem();
    127131    //BMenuItem* offItem = new BMenuItem("Disabled", NULL);
    128132    //modeMenu->AddItem(offItem);
    129133
    130     fDeviceMenuField = new BMenuField("Adapter:", deviceMenu);
     134    fDeviceMenuField = new BMenuField(TR("Adapter:"), deviceMenu);
    131135    layout->AddItem(fDeviceMenuField->CreateLabelLayoutItem(), 0, 0);
    132136    layout->AddItem(fDeviceMenuField->CreateMenuBarLayoutItem(), 1, 0);
    133137
    134     fTypeMenuField = new BMenuField("Mode:", modeMenu);
     138    fTypeMenuField = new BMenuField(TR("Mode:"), modeMenu);
    135139    layout->AddItem(fTypeMenuField->CreateLabelLayoutItem(), 0, 1);
    136140    layout->AddItem(fTypeMenuField->CreateMenuBarLayoutItem(), 1, 1);
    137141
    138     fIPTextControl = new BTextControl("IP Address:", "", NULL);
     142    fIPTextControl = new BTextControl(TR("IP Address:"), "", NULL);
    139143    SetupTextControl(fIPTextControl);
    140144
    141145    BLayoutItem* layoutItem = fIPTextControl->CreateTextViewLayoutItem();
     
    146150    layout->AddItem(fIPTextControl->CreateLabelLayoutItem(), 0, 2);
    147151    layout->AddItem(layoutItem, 1, 2);
    148152
    149     fNetMaskTextControl = new BTextControl("Netmask:", "", NULL);
     153    fNetMaskTextControl = new BTextControl(TR("Netmask:"), "", NULL);
    150154    SetupTextControl(fNetMaskTextControl);
    151155    layout->AddItem(fNetMaskTextControl->CreateLabelLayoutItem(), 0, 3);
    152156    layout->AddItem(fNetMaskTextControl->CreateTextViewLayoutItem(), 1, 3);
    153157
    154     fGatewayTextControl = new BTextControl("Gateway:", "", NULL);
     158    fGatewayTextControl = new BTextControl(TR("Gateway:"), "", NULL);
    155159    SetupTextControl(fGatewayTextControl);
    156160    layout->AddItem(fGatewayTextControl->CreateLabelLayoutItem(), 0, 4);
    157161    layout->AddItem(fGatewayTextControl->CreateTextViewLayoutItem(), 1, 4);
    158162
    159163    // TODO: Replace the DNS text controls by a BListView with add/remove
    160164    // functionality and so on...
    161     fPrimaryDNSTextControl = new BTextControl("DNS #1:", "", NULL);
     165    fPrimaryDNSTextControl = new BTextControl(TR("DNS #1:"), "", NULL);
    162166    SetupTextControl(fPrimaryDNSTextControl);
    163167    layout->AddItem(fPrimaryDNSTextControl->CreateLabelLayoutItem(), 0, 5);
    164168    layout->AddItem(fPrimaryDNSTextControl->CreateTextViewLayoutItem(), 1, 5);
    165169
    166     fSecondaryDNSTextControl = new BTextControl("DNS #2:", "", NULL);
     170    fSecondaryDNSTextControl = new BTextControl(TR("DNS #2:"), "", NULL);
    167171    SetupTextControl(fSecondaryDNSTextControl);
    168172    layout->AddItem(fSecondaryDNSTextControl->CreateLabelLayoutItem(), 0, 6);
    169173    layout->AddItem(fSecondaryDNSTextControl->CreateTextViewLayoutItem(), 1, 6);
     
    179183    // enabling/disabling)
    180184    BGroupView* buttonGroup = new BGroupView(B_HORIZONTAL);
    181185
    182     fRevertButton = new BButton("Revert", new BMessage(kMsgRevert));
     186    fRevertButton = new BButton(TR("Revert"), new BMessage(kMsgRevert));
    183187    fRevertButton->SetEnabled(false);
    184188    buttonGroup->GroupLayout()->AddView(fRevertButton);
    185189
    186190    buttonGroup->GroupLayout()->AddItem(BSpaceLayoutItem::CreateGlue());
    187191
    188     fApplyButton = new BButton("Apply", new BMessage(kMsgApply));
     192    fApplyButton = new BButton(TR("Apply"), new BMessage(kMsgApply));
    189193    buttonGroup->GroupLayout()->AddView(fApplyButton);
    190194
    191195    rootLayout->AddView(controlsGroup);
     
    304308        fNetMaskTextControl->SetText(settings->Netmask());
    305309
    306310        if (settings->AutoConfigure() == true)
    307             item = fTypeMenuField->Menu()->FindItem("DHCP");
     311            item = fTypeMenuField->Menu()->FindItem(TR("DHCP"));
    308312        else
    309             item = fTypeMenuField->Menu()->FindItem("Static");
     313            item = fTypeMenuField->Menu()->FindItem(TR("Static"));
    310314        if (item)
    311315            item->SetMarked(true);
    312316
     
    349353    fCurrentSettings->SetGateway(fGatewayTextControl->Text());
    350354
    351355    fCurrentSettings->SetAutoConfigure(
    352         strcmp(fTypeMenuField->Menu()->FindMarked()->Label(), "DHCP") == 0);
     356        strcmp(fTypeMenuField->Menu()->FindMarked()->Label(), TR("DHCP")) == 0);
    353357
    354358    fCurrentSettings->NameServers().MakeEmpty();
    355359    fCurrentSettings->NameServers().AddItem(new BString(
     
    456460{
    457461    BMessenger networkServer(kNetServerSignature);
    458462    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();
    461465        return B_ERROR;
    462466    }
    463467
     
    471475    BMessage reply;
    472476    status_t status = networkServer.SendMessage(&message, &reply);
    473477    if (status != B_OK) {
    474         BString errorMessage("Sending auto-config message failed: ");
     478        BString errorMessage(TR("Sending auto-config message failed: "));
    475479        errorMessage << strerror(status);
    476         (new BAlert("error", errorMessage.String(), "Ok"))->Go();
     480        (new BAlert("error", errorMessage.String(), TR("Ok")))->Go();
    477481        return status;
    478482    } else if (reply.FindInt32("status", &status) == B_OK
    479483            && status != B_OK) {
    480         BString errorMessage("Auto-configuring failed: ");
     484        BString errorMessage(TR("Auto-configuring failed: "));
    481485        errorMessage << strerror(status);
    482486        (new BAlert("error", errorMessage.String(), "Ok"))->Go();
    483487        return status;
     
    540544    switch (message->what) {
    541545        case kMsgMode:
    542546            if (BMenuItem* item = fTypeMenuField->Menu()->FindMarked())
    543                 _EnableTextControls(strcmp(item->Label(), "DHCP") != 0);
     547                _EnableTextControls(strcmp(item->Label(), TR("DHCP")) != 0);
    544548            fApplyButton->SetEnabled(true);
    545549            fRevertButton->SetEnabled(true);
    546550            break;
  • NetworkApp.cpp

     
    1515NetworkApp::NetworkApp()
    1616    : BApplication("application/x-vnd.Haiku-Network")
    1717{
     18    be_locale->GetAppCatalog(&fCatalog);
    1819}
    1920
    2021NetworkApp::~NetworkApp()