Ticket #5425: Screenshot.patch
File Screenshot.patch, 10.5 KB (added by , 14 years ago) |
---|
-
Screenshot.h
11 11 12 12 13 13 #include <Application.h> 14 #include <Catalog.h> 14 15 15 16 16 17 class Screenshot : public BApplication { … … 30 31 bool fRefsReceived; 31 32 int32 fImageFileType; 32 33 int32 fTranslator; 34 BCatalog fCatalog; 33 35 }; 34 36 35 37 #endif /* SCREENSHOT_H */ -
ScreenshotWindow.cpp
21 21 #include <BitmapStream.h> 22 22 #include <Button.h> 23 23 #include <CardLayout.h> 24 #include <Catalog.h> 24 25 #include <CheckBox.h> 25 26 #include <Directory.h> 26 27 #include <Entry.h> … … 30 31 #include <GridLayoutBuilder.h> 31 32 #include <GroupLayoutBuilder.h> 32 33 #include <LayoutItem.h> 34 #include <Locale.h> 33 35 #include <Menu.h> 34 36 #include <MenuField.h> 35 37 #include <MenuItem.h> … … 83 85 84 86 85 87 // #pragma mark - ScreenshotWindow 88 #undef TR_CONTEXT 89 #define TR_CONTEXT "ScreenshotWindow" 86 90 87 91 88 92 ScreenshotWindow::ScreenshotWindow(bigtime_t delay, bool includeBorder, 89 93 bool includeMouse, bool grabActiveWindow, bool showConfigWindow, 90 94 bool saveScreenshotSilent, int32 imageFileType, int32 translator) 91 95 : 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, 93 97 B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_QUIT_ON_WINDOW_CLOSE | 94 98 B_AVOID_FRONT | B_AUTO_UPDATE_SIZE_LIMITS | B_CLOSE_ON_ESCAPE), 95 99 fDelayControl(NULL), … … 155 159 BCardLayout* layout = dynamic_cast<BCardLayout*> (GetLayout()); 156 160 if (layout) 157 161 layout->SetVisibleItem(1L); 158 SetTitle( "Save screenshot");162 SetTitle(TR("Save screenshot")); 159 163 break; 160 164 } 161 165 … … 188 192 BMessenger target(this); 189 193 fOutputPathPanel = new BFilePanel(B_OPEN_PANEL, &target, 190 194 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")); 193 198 } 194 199 fOutputPathPanel->Show(); 195 200 break; … … 231 236 if (layout) 232 237 layout->SetVisibleItem(0L); 233 238 234 SetTitle( "Take Screenshot");239 SetTitle(TR("Take Screenshot")); 235 240 fBackToSave->SetEnabled(true); 236 241 break; 237 242 } … … 283 288 void 284 289 ScreenshotWindow::_SetupFirstLayoutItem(BCardLayout* layout) 285 290 { 286 BStringView* stringView = new BStringView("", "Options");291 BStringView* stringView = new BStringView("", TR("Options")); 287 292 stringView->SetFont(be_bold_font); 288 293 stringView->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET)); 289 294 290 fActiveWindow = new BRadioButton( "Capture active window",295 fActiveWindow = new BRadioButton(TR("Capture active window"), 291 296 new BMessage(kScreenshotType)); 292 fWholeDesktop = new BRadioButton( "Capture entire screen",297 fWholeDesktop = new BRadioButton(TR("Capture entire screen"), 293 298 new BMessage(kScreenshotType)); 294 299 fWholeDesktop->SetValue(B_CONTROL_ON); 295 300 296 301 BString delay; 297 302 delay << fDelay / 1000000; 298 fDelayControl = new BTextControl("", "Take screenshot after a delay of",303 fDelayControl = new BTextControl("", TR("Take screenshot after a delay of"), 299 304 delay.String(), NULL); 300 305 _DisallowChar(fDelayControl->TextView()); 301 306 fDelayControl->TextView()->SetAlignment(B_ALIGN_RIGHT); 302 307 303 BStringView* stringView2 = new BStringView("", "seconds");308 BStringView* stringView2 = new BStringView("", TR("seconds")); 304 309 stringView2->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET)); 305 310 306 fWindowBorder = new BCheckBox( "Include window border",311 fWindowBorder = new BCheckBox(TR("Include window border"), 307 312 new BMessage(kIncludeBorder)); 308 313 fWindowBorder->SetEnabled(false); 309 314 310 fShowMouse = new BCheckBox( "Include mouse pointer",315 fShowMouse = new BCheckBox(TR("Include mouse pointer"), 311 316 new BMessage(kShowMouse)); 312 317 fShowMouse->SetValue(fIncludeMouse); 313 318 314 319 BBox* divider = new BBox(B_FANCY_BORDER, NULL); 315 320 divider->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 1)); 316 321 317 fBackToSave = new BButton("", "Back to saving", new BMessage(kBackToSave));322 fBackToSave = new BButton("", TR("Back to saving"), new BMessage(kBackToSave)); 318 323 fBackToSave->SetEnabled(false); 319 324 320 fTakeScreenshot = new BButton("", "Take screenshot",325 fTakeScreenshot = new BButton("", TR("Take screenshot"), 321 326 new BMessage(kTakeScreenshot)); 322 327 323 328 layout->AddView(0, BGroupLayoutBuilder(B_VERTICAL) … … 351 356 .AddGroup(B_HORIZONTAL, 10.0) 352 357 .Add(fBackToSave) 353 358 .AddGlue() 354 .Add(new BButton("", "Cancel", new BMessage(B_QUIT_REQUESTED)))359 .Add(new BButton("", TR("Cancel"), new BMessage(B_QUIT_REQUESTED))) 355 360 .Add(fTakeScreenshot) 356 361 .End() 357 362 .SetInsets(10.0, 10.0, 10.0, 10.0) … … 370 375 { 371 376 fPreview = new PreviewView(); 372 377 373 fNameControl = new BTextControl("", "Name:", "screenshot1", NULL); 378 fNameControl = new BTextControl("", TR("Name:"), 379 TR_CMT("screenshot1", "!! Filename of first screenshot !!"), NULL); 374 380 375 381 BMessage settings(_ReadSettings()); 376 382 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); 379 385 380 fNameControl->SetText(_FindValidFileName("screenshot1").String()); 386 fNameControl->SetText(_FindValidFileName( 387 TR_CMT("screenshot1", "!! Filename of first screenshot !!")).String()); 381 388 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); 384 391 385 392 BBox* divider = new BBox(B_FANCY_BORDER, NULL); 386 393 divider->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 1)); … … 392 399 .Add(menuField->CreateMenuBarLayoutItem(), 1, 1) 393 400 .Add(menuField2->CreateLabelLayoutItem(), 0, 2) 394 401 .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? !!"))); 396 405 397 406 layout->AddView(1, BGroupLayoutBuilder(B_VERTICAL) 398 407 .Add(BGroupLayoutBuilder(B_HORIZONTAL, 10.0) … … 405 414 .Add(divider) 406 415 .AddStrut(10) 407 416 .AddGroup(B_HORIZONTAL, 10.0) 408 .Add(new BButton("", "Options", new BMessage(kShowOptions)))417 .Add(new BButton("", TR("Options"), new BMessage(kShowOptions))) 409 418 .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))) 412 421 .End() 413 422 .SetInsets(10.0, 10.0, 10.0, 10.0) 414 423 ); … … 473 482 BPath path; 474 483 find_directory(B_USER_DIRECTORY, &path); 475 484 476 BString label( "Home folder");485 BString label(TR("Home folder")); 477 486 _AddItemToPathMenu(path.Path(), label, 0, (path.Path() == lastSelectedPath)); 478 487 479 488 path.Append("Desktop"); 480 label.SetTo( "Desktop");489 label.SetTo(TR("Desktop")); 481 490 _AddItemToPathMenu(path.Path(), label, 0, (path.Path() == lastSelectedPath)); 482 491 483 492 find_directory(B_BEOS_ETC_DIRECTORY, &path); 484 493 path.Append("artwork"); 485 494 486 label.SetTo( "Artwork folder");495 label.SetTo(TR("Artwork folder")); 487 496 _AddItemToPathMenu(path.Path(), label, 2, (path.Path() == lastSelectedPath)); 488 497 489 498 int32 i = 0; … … 503 512 } 504 513 505 514 fOutputPathMenu->AddItem(new BSeparatorItem()); 506 fOutputPathMenu->AddItem(new BMenuItem( "Choose folder...",515 fOutputPathMenu->AddItem(new BMenuItem(TR("Choose folder..."), 507 516 new BMessage(kChooseLocation))); 508 517 } 509 518 … … 516 525 message->AddString("path", path); 517 526 518 527 fOutputPathMenu->TruncateString(&label, B_TRUNCATE_MIDDLE, 519 fOutputPathMenu->StringWidth("SomethingLongHere")); 528 fOutputPathMenu->StringWidth( 529 TR_CMT("SomethingLongHere", "!! length >= screenshot file name? !!"))); 520 530 521 531 fOutputPathMenu->AddItem(new BMenuItem(label.String(), message), index); 522 532 … … 553 563 if (layout) 554 564 layout->SetVisibleItem(1L); 555 565 556 SetTitle( "Save screenshot");566 SetTitle(TR("Save screenshot")); 557 567 } 558 568 559 569 … … 602 612 if (!BEntry(outputPath.Path()).Exists()) 603 613 return fileName; 604 614 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. !!" )); 607 617 608 618 BEntry entry; 609 619 int32 index = 1; … … 772 782 return B_ERROR; 773 783 774 784 if (fSaveScreenshotSilent) 775 path.Append(_FindValidFileName("screenshot1").String()); 785 path.Append(_FindValidFileName( 786 TR_CMT("screenshot1", "!! Filename of first screenshot !!")).String()); 776 787 else 777 788 path.Append(fNameControl->Text()); 778 789 … … 781 792 782 793 if (!fSaveScreenshotSilent) { 783 794 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, 787 798 B_EVEN_SPACING, B_WARNING_ALERT); 788 799 789 800 overwriteAlert->SetShortcut(0, B_ESCAPE); -
Jamfile
8 8 PreviewView.cpp 9 9 Screenshot.cpp 10 10 ScreenshotWindow.cpp 11 : be tracker translation libz.so $(TARGET_LIBSUPC++)11 : be tracker translation libz.so liblocale.so $(TARGET_LIBSUPC++) 12 12 : Screenshot.rdef 13 13 ; 14 14 15 DoCatalogs Screenshot : 16 x-vnd.Haiku-Screenshot 17 : 18 ScreenshotWindow.cpp 19 : en.catalog 20 : 21 ; -
Screenshot.cpp
14 14 #include <stdio.h> 15 15 #include <stdlib.h> 16 16 #include <string.h> 17 #include <Catalog.h> 18 #include <Locale.h> 17 19 18 20 19 21 #include <TranslatorFormats.h> … … 30 32 fImageFileType(B_PNG_FORMAT), 31 33 fTranslator(8) 32 34 { 35 be_locale->GetAppCatalog(&fCatalog); 33 36 } 34 37 35 38