Adapted to use TrackerAddonAppLaunch.h. A little cleanup. Not necessary for alphabranch.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32843 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -2,10 +2,12 @@
|
|||||||
* Copyright (c) 2008 Stephan Aßmus <[email protected]>. All rights reserved.
|
* Copyright (c) 2008 Stephan Aßmus <[email protected]>. All rights reserved.
|
||||||
* Distributed under the terms of the MIT/X11 license.
|
* Distributed under the terms of the MIT/X11 license.
|
||||||
*
|
*
|
||||||
* Copyright (c) 1999 Mike Steed. You are free to use and distribute this software
|
* Copyright (c) 1999 Mike Steed. You are free to use and distribute this
|
||||||
* as long as it is accompanied by it's documentation and this copyright notice.
|
* software as long as it is accompanied by it's documentation and this
|
||||||
* The software comes with no warranty, etc.
|
* copyright notice. The software comes with no warranty, etc.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "App.h"
|
#include "App.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -53,6 +55,12 @@ App::ArgvReceived(int32 argc, char** argv)
|
|||||||
void
|
void
|
||||||
App::RefsReceived(BMessage* message)
|
App::RefsReceived(BMessage* message)
|
||||||
{
|
{
|
||||||
|
if (!message->HasRef("refs") && message->HasRef("dir_ref")) {
|
||||||
|
entry_ref dirRef;
|
||||||
|
if (message->FindRef("dir_ref", &dirRef) == B_OK)
|
||||||
|
message->AddRef("refs", &dirRef);
|
||||||
|
}
|
||||||
|
|
||||||
if (fMainWindow == NULL) {
|
if (fMainWindow == NULL) {
|
||||||
// ReadyToRun() has not been called yet, this happens when someone
|
// ReadyToRun() has not been called yet, this happens when someone
|
||||||
// launches us with a B_REFS_RECEIVED message.
|
// launches us with a B_REFS_RECEIVED message.
|
||||||
@@ -110,3 +118,4 @@ App::QuitRequested()
|
|||||||
|
|
||||||
return BApplication::QuitRequested();
|
return BApplication::QuitRequested();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,36 +1,12 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1998-2007 Matthijs Hollemans
|
* Copyright (c) 1998-2007 Matthijs Hollemans
|
||||||
*
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
* copy of this software and associated documentation files (the "Software"),
|
|
||||||
* to deal in the Software without restriction, including without limitation
|
|
||||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
||||||
* and/or sell copies of the Software, and to permit persons to whom the
|
|
||||||
* Software is furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
* DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// NOTE: This code is the same in TextSearch. Maybe it could be made
|
|
||||||
// into some kind of common base class?
|
|
||||||
|
|
||||||
#include "App.h"
|
#include "App.h"
|
||||||
|
|
||||||
#include <AppFileInfo.h>
|
#include <TrackerAddOnAppLaunch.h>
|
||||||
#include <Entry.h>
|
|
||||||
#include <Roster.h>
|
|
||||||
#include <TrackerAddOn.h>
|
|
||||||
|
|
||||||
#include "Common.h"
|
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
@@ -41,49 +17,3 @@ main()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
process_refs(entry_ref dirRef, BMessage* message, void* /*reserved*/)
|
|
||||||
{
|
|
||||||
// Tracker calls this function when the user invokes the add-on.
|
|
||||||
// "dir_ref" contains the entry_ref of the current directory.
|
|
||||||
// "message" is a standard B_REFS_RECEIVED BMessage whose "refs"
|
|
||||||
// array contains the entry_refs of the selected files. The last
|
|
||||||
// argument, "reserved", is currently unused.
|
|
||||||
|
|
||||||
// This version of TrackerGrep is a Tracker add-on, but primarily
|
|
||||||
// it is a stand-alone application. The add-on launches the app
|
|
||||||
// on the set of files you had selected in Tracker. That way you
|
|
||||||
// get the benefits of the Tracker add-on with the benefits of the
|
|
||||||
// stand-alone application.
|
|
||||||
|
|
||||||
if (!message->HasRef("refs"))
|
|
||||||
message->AddRef("refs", &dirRef);
|
|
||||||
|
|
||||||
// get the path of the Tracker add-on
|
|
||||||
image_info image;
|
|
||||||
int32 cookie = 0;
|
|
||||||
status_t status = get_next_image_info(0, &cookie, &image);
|
|
||||||
|
|
||||||
while (status == B_OK) {
|
|
||||||
if (((char*)process_refs >= (char*)image.text
|
|
||||||
&& (char*)process_refs <= (char*)image.text + image.text_size)
|
|
||||||
|| ((char*)process_refs >= (char*)image.data
|
|
||||||
&& (char*)process_refs <= (char*)image.data + image.data_size))
|
|
||||||
break;
|
|
||||||
|
|
||||||
status = get_next_image_info(0, &cookie, &image);
|
|
||||||
}
|
|
||||||
|
|
||||||
entry_ref addonRef;
|
|
||||||
|
|
||||||
if (get_ref_for_path(image.name, &addonRef) == B_OK) {
|
|
||||||
// It's better to launch the application by its entry
|
|
||||||
// than by its application signature. There may be
|
|
||||||
// multiple instances and we would not be certain
|
|
||||||
// that the desired one is launched - the one which was
|
|
||||||
// loaded into Tracker and whose process_refs() was called.
|
|
||||||
be_roster->Launch(&addonRef, message);
|
|
||||||
} else
|
|
||||||
be_roster->Launch(kAppSignature, message);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
SubDir HAIKU_TOP src apps diskusage ;
|
SubDir HAIKU_TOP src apps diskusage ;
|
||||||
|
|
||||||
|
UsePrivateHeaders shared ;
|
||||||
UsePrivateHeaders tracker ;
|
UsePrivateHeaders tracker ;
|
||||||
SubDirHdrs $(HAIKU_TOP) src kits tracker ;
|
SubDirHdrs $(HAIKU_TOP) src kits tracker ;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user