Added support to ShowImage for sending an image to the Trash by scripting
Tracker. For now it only works when the delete key is pressed. I suppose a menu item might be useful, but I can do that later if people really want it :) When the image is trashed the next image in the directory is opened. If the trashed image is the last in the directory the window is closed. The code seems pretty solid as I even tested it with Tracker not running. It also works fine in R5 (in fact that is where I tested it.) As shown I would prefer to use the Tracker headers rather than redefining the constant used for the trashing message. I'm already using Tracker's app MIME type from the private headers. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19564 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
SubDir HAIKU_TOP src apps showimage ;
|
||||
|
||||
UsePrivateHeaders tracker ;
|
||||
|
||||
SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||
|
||||
Application ShowImage : ShowImageApp.cpp
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
* Fernando Francisco de Oliveira
|
||||
* Michael Wilber
|
||||
* Michael Pfeiffer
|
||||
* Ryan Leavengood
|
||||
* yellowTAB GmbH
|
||||
* Bernd Korz
|
||||
*/
|
||||
@@ -42,10 +43,17 @@
|
||||
#include <SupportDefs.h>
|
||||
#include <TranslatorRoster.h>
|
||||
|
||||
#include <tracker_private.h>
|
||||
|
||||
#include <math.h>
|
||||
#include <new>
|
||||
#include <stdio.h>
|
||||
|
||||
// TODO: Remove this and use Tracker's Command.h once it is moved into the private headers
|
||||
namespace BPrivate {
|
||||
const uint32 kMoveToTrash = 'Ttrs';
|
||||
}
|
||||
|
||||
using std::nothrow;
|
||||
|
||||
|
||||
@@ -1599,8 +1607,22 @@ ShowImageView::KeyDown(const char* bytes, int32 numBytes)
|
||||
ClearSelection();
|
||||
break;
|
||||
case B_DELETE:
|
||||
// TODO: move image to Trash (script Tracker)
|
||||
{
|
||||
// Move image to Trash
|
||||
BMessage trash(BPrivate::kMoveToTrash);
|
||||
trash.AddRef("refs", &fCurrentRef);
|
||||
// We create our own messenger because the member fTrackerMessenger
|
||||
// could be invalid
|
||||
BMessenger tracker(kTrackerSignature);
|
||||
if (tracker.SendMessage(&trash) == B_OK)
|
||||
if (!NextFile()) {
|
||||
// This is the last (or only file) in this directory,
|
||||
// close the window
|
||||
BMessenger msgr(Window());
|
||||
msgr.SendMessage(B_QUIT_REQUESTED);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case '+':
|
||||
case '=':
|
||||
ZoomIn();
|
||||
|
||||
Reference in New Issue
Block a user