Ticket #5724: screenshotEnhancement-filenameInSilentMode.patch

File screenshotEnhancement-filenameInSilentMode.patch, 3.5 KB (added by Shisui, 15 years ago)

Allows the user to specify an output filename in silent mode.

  • src/apps/screenshot/ScreenshotWindow.cpp

     
    9191
    9292ScreenshotWindow::ScreenshotWindow(bigtime_t delay, bool includeBorder,
    9393    bool includeMouse, bool grabActiveWindow, bool showConfigWindow,
    94     bool saveScreenshotSilent, int32 imageFileType, int32 translator)
     94    bool saveScreenshotSilent, int32 imageFileType, int32 translator,
     95    BString outputFilename)
    9596    :
    9697    BWindow(BRect(0, 0, 200.0, 100.0), TR("Retake screenshot"), B_TITLED_WINDOW,
    9798        B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_QUIT_ON_WINDOW_CLOSE |
     
    107108    fGrabActiveWindow(grabActiveWindow),
    108109    fShowConfigWindow(showConfigWindow),
    109110    fSaveScreenshotSilent(saveScreenshotSilent),
     111    fOutputFilename(outputFilename),
    110112    fExtension(""),
    111113    fTranslator(translator),
    112114    fImageFileType(imageFileType)
     
    805807    if (path == NULL)
    806808        return B_ERROR;
    807809
    808     if (fSaveScreenshotSilent) 
    809         path.Append(_FindValidFileName(
    810             TR_CMT("screenshot1", "!! Filename of first screenshot !!")).String());
    811     else
     810    if (fSaveScreenshotSilent) {
     811        if (!fOutputFilename.Compare(""))
     812            path.Append(_FindValidFileName(
     813                TR_CMT("screenshot1", "!! Filename of first screenshot !!")).String());
     814        else
     815            path.SetTo(fOutputFilename);
     816    } else
    812817        path.Append(fNameControl->Text());
    813818   
    814819    BEntry entry;
  • src/apps/screenshot/ScreenshotWindow.h

     
    3737                                bool showConfigWindow = false,
    3838                                bool saveScreenshotSilent = false,
    3939                                int32 imageFileType = B_PNG_FORMAT,
    40                                 int32 translator = 8);
     40                                int32 translator = 8,
     41                                BString outputFilename = "");
    4142    virtual                 ~ScreenshotWindow();
    4243
    4344    virtual void            MessageReceived(BMessage* message);
     
    9394            bool            fGrabActiveWindow;
    9495            bool            fShowConfigWindow;
    9596            bool            fSaveScreenshotSilent;
     97            BString         fOutputFilename;
    9698            BString         fExtension;
    9799
    98100            int32           fTranslator;
  • src/apps/screenshot/Screenshot.cpp

     
    8585{
    8686    bigtime_t delay = 0;
    8787
     88    BString outputFilename = BString("");
    8889    bool includeBorder = false;
    8990    bool includeMouse = false;
    9091    bool grabActiveWindow = false;
     
    127128                    , argv[i]);
    128129                exit(0);
    129130            }
     131        } else if (i == argc - 1) {
     132            outputFilename << argv[i];
    130133        }
    131134    }
    132135   
     
    134137   
    135138    new ScreenshotWindow(delay, includeBorder, includeMouse, grabActiveWindow,
    136139        showConfigureWindow, saveScreenshotSilent, fImageFileType,
    137         fTranslator);
     140        fTranslator, outputFilename);
    138141}
    139142
    140143
    141144void
    142145Screenshot::_ShowHelp() const
    143146{
    144     printf("Screenshot [OPTION]... Creates a bitmap of the current screen\n\n");
    145     printf("OPTION\n");
     147    printf("Screenshot [OPTIONS] [FILE]  Creates a bitmap of the current screen\n\n");
     148    printf("FILE is the optional output path / filename used in silent mode. If FILE is not given, a default filename will be generated in the prefered directory.\n\n");
     149    printf("OPTIONS\n");
    146150    printf("  -o, --options         Show options window first\n");
    147151    printf("  -m, --mouse-pointer   Include the mouse pointer\n");
    148152    printf("  -b, --border          Include the window border\n");