Ticket #5425: Screenshot.patch

File Screenshot.patch, 10.5 KB (added by mt, 14 years ago)

patch file

  • Screenshot.h

     
    1111
    1212
    1313#include <Application.h>
     14#include <Catalog.h>
    1415
    1516
    1617class Screenshot : public BApplication {
     
    3031    bool                fRefsReceived;
    3132    int32               fImageFileType;
    3233    int32               fTranslator;
     34    BCatalog                fCatalog;
    3335};
    3436
    3537#endif  /* SCREENSHOT_H */
  • ScreenshotWindow.cpp

     
    2121#include <BitmapStream.h>
    2222#include <Button.h>
    2323#include <CardLayout.h>
     24#include <Catalog.h>
    2425#include <CheckBox.h>
    2526#include <Directory.h>
    2627#include <Entry.h>
     
    3031#include <GridLayoutBuilder.h>
    3132#include <GroupLayoutBuilder.h>
    3233#include <LayoutItem.h>
     34#include <Locale.h>
    3335#include <Menu.h>
    3436#include <MenuField.h>
    3537#include <MenuItem.h>
     
    8385
    8486
    8587// #pragma mark - ScreenshotWindow
     88#undef TR_CONTEXT
     89#define TR_CONTEXT "ScreenshotWindow"
    8690
    8791
    8892ScreenshotWindow::ScreenshotWindow(bigtime_t delay, bool includeBorder,
    8993    bool includeMouse, bool grabActiveWindow, bool showConfigWindow,
    9094    bool saveScreenshotSilent, int32 imageFileType, int32 translator)
    9195    :
    92     BWindow(BRect(0, 0, 200.0, 100.0), "Retake screenshot", B_TITLED_WINDOW,
     96    BWindow(BRect(0, 0, 200.0, 100.0), TR("Retake screenshot"), B_TITLED_WINDOW,
    9397        B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_QUIT_ON_WINDOW_CLOSE |
    9498        B_AVOID_FRONT | B_AUTO_UPDATE_SIZE_LIMITS | B_CLOSE_ON_ESCAPE),
    9599    fDelayControl(NULL),
     
    155159            BCardLayout* layout = dynamic_cast<BCardLayout*> (GetLayout());
    156160            if (layout)
    157161                layout->SetVisibleItem(1L);
    158             SetTitle("Save screenshot");
     162            SetTitle(TR("Save screenshot"));
    159163            break;
    160164        }
    161165
     
    188192                BMessenger target(this);
    189193                fOutputPathPanel = new BFilePanel(B_OPEN_PANEL, &target,
    190194                    NULL, B_DIRECTORY_NODE, false, NULL, new DirectoryRefFilter());
    191                 fOutputPathPanel->Window()->SetTitle("Choose folder");
    192                 fOutputPathPanel->SetButtonLabel(B_DEFAULT_BUTTON, "Select");
     195                fOutputPathPanel->Window()->SetTitle(TR("Choose folder"));
     196                fOutputPathPanel->SetButtonLabel(B_DEFAULT_BUTTON, TR("Select"));
     197                fOutputPathPanel->SetButtonLabel(B_CANCEL_BUTTON, TR("Cancel"));
    193198            }
    194199            fOutputPathPanel->Show();
    195200            break;
     
    231236            if (layout)
    232237                layout->SetVisibleItem(0L);
    233238           
    234             SetTitle("Take Screenshot");
     239            SetTitle(TR("Take Screenshot"));
    235240            fBackToSave->SetEnabled(true);
    236241            break;
    237242        }
     
    283288void
    284289ScreenshotWindow::_SetupFirstLayoutItem(BCardLayout* layout)
    285290{
    286     BStringView* stringView = new BStringView("", "Options");
     291    BStringView* stringView = new BStringView("", TR("Options"));
    287292    stringView->SetFont(be_bold_font);
    288293    stringView->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
    289294
    290     fActiveWindow = new BRadioButton("Capture active window",
     295    fActiveWindow = new BRadioButton(TR("Capture active window"),
    291296        new BMessage(kScreenshotType));
    292     fWholeDesktop = new BRadioButton("Capture entire screen",
     297    fWholeDesktop = new BRadioButton(TR("Capture entire screen"),
    293298        new BMessage(kScreenshotType));
    294299    fWholeDesktop->SetValue(B_CONTROL_ON);
    295300
    296301    BString delay;
    297302    delay << fDelay / 1000000;
    298     fDelayControl = new BTextControl("", "Take screenshot after a delay of",
     303    fDelayControl = new BTextControl("", TR("Take screenshot after a delay of"),
    299304        delay.String(), NULL);
    300305    _DisallowChar(fDelayControl->TextView());
    301306    fDelayControl->TextView()->SetAlignment(B_ALIGN_RIGHT);
    302307
    303     BStringView* stringView2 = new BStringView("", "seconds");
     308    BStringView* stringView2 = new BStringView("", TR("seconds"));
    304309    stringView2->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
    305310
    306     fWindowBorder = new BCheckBox("Include window border",
     311    fWindowBorder = new BCheckBox(TR("Include window border"),
    307312        new BMessage(kIncludeBorder));
    308313    fWindowBorder->SetEnabled(false);
    309314
    310     fShowMouse = new BCheckBox("Include mouse pointer",
     315    fShowMouse = new BCheckBox(TR("Include mouse pointer"),
    311316        new BMessage(kShowMouse));
    312317    fShowMouse->SetValue(fIncludeMouse);
    313318
    314319    BBox* divider = new BBox(B_FANCY_BORDER, NULL);
    315320    divider->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 1));
    316321
    317     fBackToSave = new BButton("", "Back to saving", new BMessage(kBackToSave));
     322    fBackToSave = new BButton("", TR("Back to saving"), new BMessage(kBackToSave));
    318323    fBackToSave->SetEnabled(false);
    319324
    320     fTakeScreenshot = new BButton("", "Take screenshot",
     325    fTakeScreenshot = new BButton("", TR("Take screenshot"),
    321326        new BMessage(kTakeScreenshot));
    322327
    323328    layout->AddView(0, BGroupLayoutBuilder(B_VERTICAL)
     
    351356        .AddGroup(B_HORIZONTAL, 10.0)
    352357            .Add(fBackToSave)
    353358            .AddGlue()
    354             .Add(new BButton("", "Cancel", new BMessage(B_QUIT_REQUESTED)))
     359            .Add(new BButton("", TR("Cancel"), new BMessage(B_QUIT_REQUESTED)))
    355360            .Add(fTakeScreenshot)
    356361            .End()
    357362        .SetInsets(10.0, 10.0, 10.0, 10.0)
     
    370375{
    371376    fPreview = new PreviewView();
    372377
    373     fNameControl = new BTextControl("", "Name:", "screenshot1", NULL);
     378    fNameControl = new BTextControl("", TR("Name:"),
     379        TR_CMT("screenshot1", "!! Filename of first screenshot !!"), NULL);
    374380
    375381    BMessage settings(_ReadSettings());
    376382
    377     _SetupOutputPathMenu(new BMenu("Please select"), settings);
    378     BMenuField* menuField2 = new BMenuField("Save in:", fOutputPathMenu);
     383    _SetupOutputPathMenu(new BMenu(TR("Please select")), settings);
     384    BMenuField* menuField2 = new BMenuField(TR("Save in:"), fOutputPathMenu);
    379385   
    380     fNameControl->SetText(_FindValidFileName("screenshot1").String());
     386    fNameControl->SetText(_FindValidFileName(
     387        TR_CMT("screenshot1", "!! Filename of first screenshot !!")).String());
    381388
    382     _SetupTranslatorMenu(new BMenu("Please select"), settings);
    383     BMenuField* menuField = new BMenuField("Save as:", fTranslatorMenu);
     389    _SetupTranslatorMenu(new BMenu(TR("Please select")), settings);
     390    BMenuField* menuField = new BMenuField(TR("Save as:"), fTranslatorMenu);
    384391
    385392    BBox* divider = new BBox(B_FANCY_BORDER, NULL);
    386393    divider->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 1));
     
    392399        .Add(menuField->CreateMenuBarLayoutItem(), 1, 1)
    393400        .Add(menuField2->CreateLabelLayoutItem(), 0, 2)
    394401        .Add(menuField2->CreateMenuBarLayoutItem(), 1, 2);
    395     gridLayout->SetMinColumnWidth(1, menuField->StringWidth("SomethingLongHere"));
     402    gridLayout->SetMinColumnWidth(1,
     403        menuField->StringWidth(
     404            TR_CMT("SomethingLongHere", "!! length >= screenshot file name? !!")));
    396405
    397406    layout->AddView(1, BGroupLayoutBuilder(B_VERTICAL)
    398407        .Add(BGroupLayoutBuilder(B_HORIZONTAL, 10.0)
     
    405414        .Add(divider)
    406415        .AddStrut(10)
    407416        .AddGroup(B_HORIZONTAL, 10.0)
    408             .Add(new BButton("", "Options", new BMessage(kShowOptions)))
     417            .Add(new BButton("", TR("Options"), new BMessage(kShowOptions)))
    409418            .AddGlue()
    410             .Add(new BButton("", "Cancel", new BMessage(B_QUIT_REQUESTED)))
    411             .Add(new BButton("", "Save", new BMessage(kFinishScreenshot)))
     419            .Add(new BButton("", TR("Cancel"), new BMessage(B_QUIT_REQUESTED)))
     420            .Add(new BButton("", TR("Save"), new BMessage(kFinishScreenshot)))
    412421            .End()
    413422        .SetInsets(10.0, 10.0, 10.0, 10.0)
    414423    );
     
    473482    BPath path;
    474483    find_directory(B_USER_DIRECTORY, &path);
    475484
    476     BString label("Home folder");
     485    BString label(TR("Home folder"));
    477486    _AddItemToPathMenu(path.Path(), label, 0, (path.Path() == lastSelectedPath));
    478487
    479488    path.Append("Desktop");
    480     label.SetTo("Desktop");
     489    label.SetTo(TR("Desktop"));
    481490    _AddItemToPathMenu(path.Path(), label, 0, (path.Path() == lastSelectedPath));
    482491
    483492    find_directory(B_BEOS_ETC_DIRECTORY, &path);
    484493    path.Append("artwork");
    485494
    486     label.SetTo("Artwork folder");
     495    label.SetTo(TR("Artwork folder"));
    487496    _AddItemToPathMenu(path.Path(), label, 2, (path.Path() == lastSelectedPath));
    488497
    489498    int32 i = 0;
     
    503512    }
    504513
    505514    fOutputPathMenu->AddItem(new BSeparatorItem());
    506     fOutputPathMenu->AddItem(new BMenuItem("Choose folder...",
     515    fOutputPathMenu->AddItem(new BMenuItem(TR("Choose folder..."),
    507516        new BMessage(kChooseLocation)));
    508517}
    509518
     
    516525    message->AddString("path", path);
    517526
    518527    fOutputPathMenu->TruncateString(&label, B_TRUNCATE_MIDDLE,
    519         fOutputPathMenu->StringWidth("SomethingLongHere"));
     528        fOutputPathMenu->StringWidth(
     529            TR_CMT("SomethingLongHere", "!! length >= screenshot file name? !!")));
    520530
    521531    fOutputPathMenu->AddItem(new BMenuItem(label.String(), message), index);
    522532
     
    553563    if (layout)
    554564        layout->SetVisibleItem(1L);
    555565
    556     SetTitle("Save screenshot");
     566    SetTitle(TR("Save screenshot"));
    557567}
    558568
    559569
     
    602612    if (!BEntry(outputPath.Path()).Exists())
    603613        return fileName;
    604614
    605     if (baseName.FindFirst("screenshot") == 0)
    606         baseName.SetTo("screenshot");
     615    if (baseName.FindFirst(TR_CMT("screenshot", "!! Basename of screenshot files. !!")) == 0)
     616        baseName.SetTo(TR_CMT("screenshot", "!! Basename of screenshot files. !!" ));
    607617
    608618    BEntry entry;
    609619    int32 index = 1;
     
    772782        return B_ERROR;
    773783
    774784    if (fSaveScreenshotSilent) 
    775         path.Append(_FindValidFileName("screenshot1").String());
     785        path.Append(_FindValidFileName(
     786            TR_CMT("screenshot1", "!! Filename of first screenshot !!")).String());
    776787    else
    777788        path.Append(fNameControl->Text());
    778789   
     
    781792   
    782793    if (!fSaveScreenshotSilent) {
    783794        if (entry.Exists()) {
    784             BAlert *overwriteAlert = new BAlert("overwrite", "This file "
    785                 "already exists.\n Are you sure would you like to overwrite "
    786                 "it?", "Cancel", "Overwrite", NULL, B_WIDTH_AS_USUAL,
     795            BAlert* overwriteAlert = new BAlert(TR("overwrite"),
     796                TR("This file already exists.\n Are you sure would you like to overwrite it?"),
     797                TR("Cancel"), TR("Overwrite"), NULL, B_WIDTH_AS_USUAL,
    787798                B_EVEN_SPACING, B_WARNING_ALERT);
    788799
    789800                overwriteAlert->SetShortcut(0, B_ESCAPE);
  • Jamfile

     
    88    PreviewView.cpp
    99    Screenshot.cpp
    1010    ScreenshotWindow.cpp
    11     : be tracker translation libz.so $(TARGET_LIBSUPC++)
     11    : be tracker translation libz.so liblocale.so $(TARGET_LIBSUPC++)
    1212    : Screenshot.rdef
    1313;
    1414
     15DoCatalogs Screenshot :
     16    x-vnd.Haiku-Screenshot
     17    :
     18    ScreenshotWindow.cpp
     19    : en.catalog
     20    :
     21;
  • Screenshot.cpp

     
    1414#include <stdio.h>
    1515#include <stdlib.h>
    1616#include <string.h>
     17#include <Catalog.h>
     18#include <Locale.h>
    1719
    1820
    1921#include <TranslatorFormats.h>
     
    3032    fImageFileType(B_PNG_FORMAT),
    3133    fTranslator(8)
    3234{
     35    be_locale->GetAppCatalog(&fCatalog);
    3336}
    3437
    3538