* Applied a slightly edited patch by Christophe Huriaux, as part of ticket
#5724: this adds a settable filename for the silent invocation, thanks! git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36312 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -85,6 +85,7 @@ Screenshot::ArgvReceived(int32 argc, char** argv)
|
||||
{
|
||||
bigtime_t delay = 0;
|
||||
|
||||
const char* outputFilename = NULL;
|
||||
bool includeBorder = false;
|
||||
bool includeMouse = false;
|
||||
bool grabActiveWindow = false;
|
||||
@@ -127,22 +128,24 @@ Screenshot::ArgvReceived(int32 argc, char** argv)
|
||||
, argv[i]);
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
} else if (i == argc - 1)
|
||||
outputFilename = argv[i];
|
||||
}
|
||||
|
||||
fArgvReceived = true;
|
||||
|
||||
new ScreenshotWindow(delay, includeBorder, includeMouse, grabActiveWindow,
|
||||
showConfigureWindow, saveScreenshotSilent, fImageFileType,
|
||||
fTranslator);
|
||||
fTranslator, outputFilename);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Screenshot::_ShowHelp() const
|
||||
{
|
||||
printf("Screenshot [OPTION]... Creates a bitmap of the current screen\n\n");
|
||||
printf("OPTION\n");
|
||||
printf("Screenshot [OPTIONS] [FILE] Creates a bitmap of the current screen\n\n");
|
||||
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");
|
||||
printf("OPTIONS\n");
|
||||
printf(" -o, --options Show options window first\n");
|
||||
printf(" -m, --mouse-pointer Include the mouse pointer\n");
|
||||
printf(" -b, --border Include the window border\n");
|
||||
|
||||
@@ -5,8 +5,10 @@
|
||||
* Authors:
|
||||
* Karsten Heimrich
|
||||
* Fredrik Modéen
|
||||
* Christophe Huriaux
|
||||
*/
|
||||
|
||||
|
||||
#include "ScreenshotWindow.h"
|
||||
|
||||
|
||||
@@ -75,23 +77,29 @@ enum {
|
||||
|
||||
class DirectoryRefFilter : public BRefFilter {
|
||||
public:
|
||||
virtual ~DirectoryRefFilter() {}
|
||||
bool Filter(const entry_ref* ref, BNode* node,
|
||||
struct stat_beos* stat, const char* filetype)
|
||||
{
|
||||
return node->IsDirectory();
|
||||
}
|
||||
virtual ~DirectoryRefFilter()
|
||||
{
|
||||
}
|
||||
|
||||
virtual bool Filter(const entry_ref* ref, BNode* node,
|
||||
struct stat_beos* stat, const char* filetype)
|
||||
{
|
||||
return node->IsDirectory();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// #pragma mark - ScreenshotWindow
|
||||
|
||||
|
||||
#undef TR_CONTEXT
|
||||
#define TR_CONTEXT "ScreenshotWindow"
|
||||
|
||||
|
||||
ScreenshotWindow::ScreenshotWindow(bigtime_t delay, bool includeBorder,
|
||||
bool includeMouse, bool grabActiveWindow, bool showConfigWindow,
|
||||
bool saveScreenshotSilent, int32 imageFileType, int32 translator)
|
||||
bool saveScreenshotSilent, int32 imageFileType, int32 translator,
|
||||
const char* outputFilename)
|
||||
:
|
||||
BWindow(BRect(0, 0, 200.0, 100.0), TR("Retake screenshot"), B_TITLED_WINDOW,
|
||||
B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_QUIT_ON_WINDOW_CLOSE |
|
||||
@@ -107,6 +115,7 @@ ScreenshotWindow::ScreenshotWindow(bigtime_t delay, bool includeBorder,
|
||||
fGrabActiveWindow(grabActiveWindow),
|
||||
fShowConfigWindow(showConfigWindow),
|
||||
fSaveScreenshotSilent(saveScreenshotSilent),
|
||||
fOutputFilename(outputFilename),
|
||||
fExtension(""),
|
||||
fTranslator(translator),
|
||||
fImageFileType(imageFileType)
|
||||
@@ -805,10 +814,13 @@ ScreenshotWindow::_SaveScreenshot()
|
||||
if (path == NULL)
|
||||
return B_ERROR;
|
||||
|
||||
if (fSaveScreenshotSilent)
|
||||
path.Append(_FindValidFileName(
|
||||
TR_CMT("screenshot1", "!! Filename of first screenshot !!")).String());
|
||||
else
|
||||
if (fSaveScreenshotSilent) {
|
||||
if (!fOutputFilename.Compare("")) {
|
||||
path.Append(_FindValidFileName(TR_CMT("screenshot1",
|
||||
"!! Filename of first screenshot !!")).String());
|
||||
} else
|
||||
path.SetTo(fOutputFilename);
|
||||
} else
|
||||
path.Append(fNameControl->Text());
|
||||
|
||||
BEntry entry;
|
||||
@@ -817,7 +829,8 @@ ScreenshotWindow::_SaveScreenshot()
|
||||
if (!fSaveScreenshotSilent) {
|
||||
if (entry.Exists()) {
|
||||
BAlert* overwriteAlert = new BAlert(TR("overwrite"),
|
||||
TR("This file already exists.\n Are you sure would you like to overwrite it?"),
|
||||
TR("This file already exists.\n Are you sure would you like "
|
||||
"to overwrite it?"),
|
||||
TR("Cancel"), TR("Overwrite"), NULL, B_WIDTH_AS_USUAL,
|
||||
B_EVEN_SPACING, B_WARNING_ALERT);
|
||||
|
||||
|
||||
@@ -37,7 +37,8 @@ public:
|
||||
bool showConfigWindow = false,
|
||||
bool saveScreenshotSilent = false,
|
||||
int32 imageFileType = B_PNG_FORMAT,
|
||||
int32 translator = 8);
|
||||
int32 translator = 8,
|
||||
const char* outputFilename = NULL);
|
||||
virtual ~ScreenshotWindow();
|
||||
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
@@ -93,6 +94,7 @@ private:
|
||||
bool fGrabActiveWindow;
|
||||
bool fShowConfigWindow;
|
||||
bool fSaveScreenshotSilent;
|
||||
BString fOutputFilename;
|
||||
BString fExtension;
|
||||
|
||||
int32 fTranslator;
|
||||
|
||||
Reference in New Issue
Block a user