From 65040013021283a6d1ac25bc3783765ccfd170b5 Mon Sep 17 00:00:00 2001 From: Ryan Leavengood Date: Tue, 19 Dec 2006 08:01:30 +0000 Subject: [PATCH] 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 --- src/apps/showimage/Jamfile | 2 ++ src/apps/showimage/ShowImageView.cpp | 24 +++++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/apps/showimage/Jamfile b/src/apps/showimage/Jamfile index 723caa8111..b94afb9344 100644 --- a/src/apps/showimage/Jamfile +++ b/src/apps/showimage/Jamfile @@ -1,5 +1,7 @@ SubDir HAIKU_TOP src apps showimage ; +UsePrivateHeaders tracker ; + SetSubDirSupportedPlatformsBeOSCompatible ; Application ShowImage : ShowImageApp.cpp diff --git a/src/apps/showimage/ShowImageView.cpp b/src/apps/showimage/ShowImageView.cpp index 50b1c46cb6..a1e1707e8f 100644 --- a/src/apps/showimage/ShowImageView.cpp +++ b/src/apps/showimage/ShowImageView.cpp @@ -8,6 +8,7 @@ * Fernando Francisco de Oliveira * Michael Wilber * Michael Pfeiffer + * Ryan Leavengood * yellowTAB GmbH * Bernd Korz */ @@ -42,10 +43,17 @@ #include #include +#include + #include #include #include +// 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();