Cleanup, no functional change.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17667 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2006-05-31 13:43:17 +00:00
parent 8aebe2c4b8
commit 66d3076d17
2 changed files with 326 additions and 314 deletions

View File

@ -32,6 +32,16 @@ names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#include "Attributes.h"
#include "AutoLock.h"
#include "Commands.h"
#include "FSUtils.h"
#include "IconMenuItem.h"
#include "OpenWithWindow.h"
#include "MimeTypes.h"
#include "StopWatch.h"
#include "Tracker.h"
#include <Alert.h>
#include <Button.h>
#include <Mime.h>
@ -45,16 +55,6 @@ All rights reserved.
#include <stdio.h>
#include <string.h>
#include "Attributes.h"
#include "AutoLock.h"
#include "Commands.h"
#include "FSUtils.h"
#include "IconMenuItem.h"
#include "OpenWithWindow.h"
#include "MimeTypes.h"
#include "StopWatch.h"
#include "Tracker.h"
const char *kDefaultOpenWithTemplate = "OpenWithSettings";
// ToDo:
@ -73,11 +73,11 @@ const int32 kOpenAndMakeDefault = 'OpDf';
const rgb_color kOpenWithDefaultColor = { 0xFF, 0xFF, 0xCC, 255};
OpenWithContainerWindow::OpenWithContainerWindow(BMessage *
entriesToOpen, LockingList<BWindow> *windowList,
window_look look, window_feel feel, uint32 flags, uint32 workspace)
: BContainerWindow(windowList, 0, look, feel, flags, workspace),
fEntriesToOpen(entriesToOpen)
OpenWithContainerWindow::OpenWithContainerWindow(BMessage *entriesToOpen,
LockingList<BWindow> *windowList, window_look look, window_feel feel,
uint32 flags, uint32 workspace)
: BContainerWindow(windowList, 0, look, feel, flags, workspace),
fEntriesToOpen(entriesToOpen)
{
AutoLock<BWindow> lock(this);
@ -216,11 +216,11 @@ AddOneUniqueDocumentType(const entry_ref *ref, void *castToList)
BFile file(&entry, O_RDONLY);
if (file.InitCheck() != B_OK)
return 0;
BNodeInfo info(&file);
if (info.GetType(type) != B_OK)
return 0;
if (list->EachElement(FindOne, &type))
// type already in list, bail
return 0;
@ -235,7 +235,7 @@ static const BString *
SetDefaultAppForOneType(const BString *element, void *castToEntryRef)
{
const entry_ref *appRef = (const entry_ref *)castToEntryRef;
// set entry as default handler for one mime string
BMimeType mime(element->String());
if (!mime.IsInstalled())
@ -249,7 +249,7 @@ SetDefaultAppForOneType(const BString *element, void *castToEntryRef)
char appSignature[B_MIME_TYPE_LENGTH];
if (GetAppSignatureFromAttr(&appFile, appSignature) != B_OK)
return 0;
if (mime.SetPreferredApp(appSignature) != B_OK)
return 0;
@ -280,7 +280,7 @@ OpenWithContainerWindow::MakeDefaultAndOpen()
ASSERT(count == 1);
if (!count)
return;
BPose *selectedAppPose = PoseView()->SelectionList()->FirstItem();
ASSERT(selectedAppPose);
if (!selectedAppPose)
@ -289,19 +289,19 @@ OpenWithContainerWindow::MakeDefaultAndOpen()
// collect all the types of all the opened documents into a list
BObjectList<BString> openedFileTypes(10, true);
EachEntryRef(EntryList(), AddOneUniqueDocumentType, &openedFileTypes, 100);
// set the default application to be the selected pose for all the
// mime types in the list
openedFileTypes.EachElement(SetDefaultAppForOneType,
(void *)selectedAppPose->TargetModel()->EntryRef());
// done setting the default application, now launch the app with the
// documents
OpenWithSelection();
}
void
void
OpenWithContainerWindow::MessageReceived(BMessage *message)
{
switch (message->what) {
@ -309,7 +309,7 @@ OpenWithContainerWindow::MessageReceived(BMessage *message)
OpenWithSelection();
PostMessage(B_QUIT_REQUESTED);
return;
case kOpenAndMakeDefault:
MakeDefaultAndOpen();
PostMessage(B_QUIT_REQUESTED);
@ -342,7 +342,20 @@ OpenWithContainerWindow::KeyDownFilter(BMessage *message, BHandler **,
}
void
bool
OpenWithContainerWindow::ShouldAddMenus() const
{
return false;
}
void
OpenWithContainerWindow::ShowContextMenu(BPoint, const entry_ref *, BView *)
{
}
void
OpenWithContainerWindow::AddShortcuts()
{
// add get info here
@ -376,12 +389,12 @@ OpenWithContainerWindow::NewAttributeMenu(BMenu *menu)
}
void
void
OpenWithContainerWindow::SaveState(bool)
{
BNode defaultingNode;
if (DefaultStateSourceNode(kDefaultOpenWithTemplate, &defaultingNode,
true, false)) {
true, false)) {
AttributeStreamFileNode streamNodeDestination(&defaultingNode);
SaveWindowState(&streamNodeDestination);
fPoseView->SaveState(&streamNodeDestination);
@ -389,14 +402,14 @@ OpenWithContainerWindow::SaveState(bool)
}
void
void
OpenWithContainerWindow::SaveState(BMessage &message) const
{
_inherited::SaveState(message);
}
void
void
OpenWithContainerWindow::Init(const BMessage *message)
{
_inherited::Init(message);
@ -425,7 +438,7 @@ OpenWithContainerWindow::RestoreState(const BMessage &message)
}
void
void
OpenWithContainerWindow::RestoreWindowState(AttributeStreamNode *node)
{
SetSizeLimits(310, 10000, 160, 10000);
@ -442,48 +455,48 @@ OpenWithContainerWindow::RestoreWindowState(AttributeStreamNode *node)
}
void
void
OpenWithContainerWindow::RestoreWindowState(const BMessage &message)
{
_inherited::RestoreWindowState(message);
}
bool
bool
OpenWithContainerWindow::NeedsDefaultStateSetup()
{
return true;
}
void
void
OpenWithContainerWindow::SetUpDefaultState()
{
}
bool
bool
OpenWithContainerWindow::IsShowing(const node_ref *) const
{
return false;
}
bool
bool
OpenWithContainerWindow::IsShowing(const entry_ref *) const
{
return false;
}
void
void
OpenWithContainerWindow::SetCanSetAppAsDefault(bool on)
{
fLaunchAndMakeDefaultButton->SetEnabled(on);
}
void
void
OpenWithContainerWindow::SetCanOpen(bool on)
{
fLaunchButton->SetEnabled(on);
@ -494,9 +507,9 @@ OpenWithContainerWindow::SetCanOpen(bool on)
OpenWithPoseView::OpenWithPoseView(BRect frame, uint32 resizeMask)
: BPoseView(0, frame, kListMode, resizeMask),
fHaveCommonPreferredApp(false),
fIterator(NULL)
: BPoseView(0, frame, kListMode, resizeMask),
fHaveCommonPreferredApp(false),
fIterator(NULL)
{
fSavePoseLocations = false;
fMultipleSelection = false;
@ -512,7 +525,7 @@ OpenWithPoseView::ContainerWindow() const
}
void
void
OpenWithPoseView::AttachedToWindow()
{
_inherited::AttachedToWindow();
@ -521,7 +534,7 @@ OpenWithPoseView::AttachedToWindow()
}
bool
bool
OpenWithPoseView::CanHandleDragSelection(const Model *, const BMessage *, bool)
{
return false;
@ -640,10 +653,10 @@ OpenWithPoseView::OpenSelection(BPose *pose, int32 *)
int32 count = fSelectionList->CountItems();
if (!count)
return;
if (!pose)
pose = fSelectionList->FirstItem();
ASSERT(pose);
BEntry entry(pose->TargetModel()->EntryRef());
@ -657,10 +670,8 @@ OpenWithPoseView::OpenSelection(BPose *pose, int32 *)
return;
}
if (OpenWithRelation(pose->TargetModel()) == kNoRelation) {
if (!fIterator->GenericFilesOnly()) {
BString warning;
warning << "The application \"" << pose->TargetModel()->Name()
<< "\" does not support the type of document you are "
@ -672,8 +683,9 @@ OpenWithPoseView::OpenSelection(BPose *pose, int32 *)
if ((new BAlert("", warning.String(), "Cancel", "Open", 0,
B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go() == 0)
return;
} // else - once we have an extensible sniffer, tell users to ask
// publishers to fix up sniffers
}
// else - once we have an extensible sniffer, tell users to ask
// publishers to fix up sniffers
}
@ -693,7 +705,7 @@ OpenWithPoseView::OpenSelection(BPose *pose, int32 *)
}
void
void
OpenWithPoseView::Pulse()
{
// disable the Open and make default button if the default
@ -788,7 +800,7 @@ OpenWithPoseView::CreatePoses(Model **models, PoseInfo *poseInfoArray, int32 cou
}
void
void
OpenWithPoseView::KeyDown(const char *bytes, int32 count)
{
if (bytes[0] == B_TAB)
@ -799,14 +811,14 @@ OpenWithPoseView::KeyDown(const char *bytes, int32 count)
}
void
void
OpenWithPoseView::SaveState(AttributeStreamNode *node)
{
_inherited::SaveState(node);
}
void
void
OpenWithPoseView::RestoreState(AttributeStreamNode *node)
{
_inherited::RestoreState(node);
@ -814,14 +826,14 @@ OpenWithPoseView::RestoreState(AttributeStreamNode *node)
}
void
void
OpenWithPoseView::SaveState(BMessage &message) const
{
_inherited::SaveState(message);
}
void
void
OpenWithPoseView::RestoreState(const BMessage &message)
{
_inherited::RestoreState(message);
@ -829,46 +841,46 @@ OpenWithPoseView::RestoreState(const BMessage &message)
}
void
void
OpenWithPoseView::SavePoseLocations(BRect *)
{
// do nothing
}
void
void
OpenWithPoseView::MoveSelectionToTrash(bool)
{
}
void
void
OpenWithPoseView::MoveSelectionTo(BPoint, BPoint, BContainerWindow *)
{
}
void
void
OpenWithPoseView::MoveSelectionInto(Model *, BContainerWindow *, bool, bool)
{
}
bool
bool
OpenWithPoseView::Represents(const node_ref *) const
{
return false;
}
bool
bool
OpenWithPoseView::Represents(const entry_ref *) const
{
return false;
}
bool
bool
OpenWithPoseView::HandleMessageDropped(BMessage *DEBUG_ONLY(message))
{
#if DEBUG
@ -887,7 +899,7 @@ OpenWithPoseView::HandleMessageDropped(BMessage *DEBUG_ONLY(message))
}
int32
int32
OpenWithPoseView::OpenWithRelation(const Model *model) const
{
OpenWithContainerWindow *window = ContainerWindow();
@ -897,7 +909,7 @@ OpenWithPoseView::OpenWithRelation(const Model *model) const
}
void
void
OpenWithPoseView::OpenWithRelationDescription(const Model *model,
BString *description) const
{
@ -925,8 +937,9 @@ OpenWithPoseView::ShouldShowPose(const Model *model, const PoseInfo *poseInfo)
RelationCachingModelProxy::RelationCachingModelProxy(Model *model)
: fModel(model),
relation(kUnknownRelation)
:
fModel(model),
fRelation(kUnknownRelation)
{
}
@ -936,14 +949,15 @@ RelationCachingModelProxy::~RelationCachingModelProxy()
delete fModel;
}
int32
int32
RelationCachingModelProxy::Relation(SearchForSignatureEntryList *iterator,
BMessage *entries) const
{
if (relation == kUnknownRelation)
relation = iterator->Relation(entries, fModel);
if (fRelation == kUnknownRelation)
fRelation = iterator->Relation(entries, fModel);
return relation;
return fRelation;
}
@ -951,13 +965,13 @@ RelationCachingModelProxy::Relation(SearchForSignatureEntryList *iterator,
OpenWithMenu::OpenWithMenu(const char *label, const BMessage *entriesToOpen,
BWindow *parentWindow, BHandler *target)
: BSlowMenu(label),
fEntriesToOpen(*entriesToOpen),
target(target),
fIterator(NULL),
fSupportingAppList(NULL),
fParentWindow(parentWindow)
BWindow *parentWindow, BHandler *target)
: BSlowMenu(label),
fEntriesToOpen(*entriesToOpen),
target(target),
fIterator(NULL),
fSupportingAppList(NULL),
fParentWindow(parentWindow)
{
InitIconPreloader();
@ -969,14 +983,14 @@ OpenWithMenu::OpenWithMenu(const char *label, const BMessage *entriesToOpen,
OpenWithMenu::OpenWithMenu(const char *label, const BMessage *entriesToOpen,
BWindow *parentWindow, const BMessenger &messenger)
: BSlowMenu(label),
fEntriesToOpen(*entriesToOpen),
target(NULL),
fMessenger(messenger),
fIterator(NULL),
fSupportingAppList(NULL),
fParentWindow(parentWindow)
BWindow *parentWindow, const BMessenger &messenger)
: BSlowMenu(label),
fEntriesToOpen(*entriesToOpen),
target(NULL),
fMessenger(messenger),
fIterator(NULL),
fSupportingAppList(NULL),
fParentWindow(parentWindow)
{
InitIconPreloader();
@ -1030,13 +1044,13 @@ OpenWithMenu::StartBuildingItemList()
}
fSupportingAppList = new BObjectList<RelationCachingModelProxy>(20, true);
//queryRetrieval = new BStopWatch("get next entry on BQuery");
return true;
}
bool
bool
OpenWithMenu::AddNextItem()
{
BEntry entry;
@ -1058,7 +1072,7 @@ OpenWithMenu::AddNextItem()
}
void
void
OpenWithMenu::DoneBuildingItemList()
{
// sort by app name
@ -1144,7 +1158,7 @@ OpenWithMenu::DoneBuildingItemList()
}
void
void
OpenWithMenu::ClearMenuBuildingState()
{
delete fIterator;
@ -1158,13 +1172,14 @@ OpenWithMenu::ClearMenuBuildingState()
SearchForSignatureEntryList::SearchForSignatureEntryList(bool canAddAllApps)
: fIteratorList(NULL),
fSignatures(20, true),
fPreferredAppCount(0),
fPreferredAppForFileCount(0),
fGenericFilesOnly(true),
fCanAddAllApps(canAddAllApps),
fFoundOneNonSuperHandler(false)
:
fIteratorList(NULL),
fSignatures(20, true),
fPreferredAppCount(0),
fPreferredAppForFileCount(0),
fGenericFilesOnly(true),
fCanAddAllApps(canAddAllApps),
fFoundOneNonSuperHandler(false)
{
}
@ -1487,16 +1502,16 @@ SearchForSignatureEntryList::CanOpenWithFilter(const Model *appModel,
return false;
}
if (strcmp(appModel->MimeType(), B_APP_MIME_TYPE) != 0)
if (strcmp(appModel->MimeType(), B_APP_MIME_TYPE) != 0) {
// filter out pe containers on PPC etc.
return false;
}
ASSERT(dynamic_cast<BFile *>(appModel->Node()));
char signature[B_MIME_TYPE_LENGTH];
status_t result = GetAppSignatureFromAttr(
dynamic_cast<BFile *>(appModel->Node()), signature);
if (result == B_OK && strcasecmp(signature, kTrackerSignature) == 0) {
// special case the Tracker - make sure only the running copy is
// in the list
@ -1553,10 +1568,11 @@ SearchForSignatureEntryList::CanOpenWithFilter(const Model *appModel,
return false;
}
if (relation != kNoRelation && relation != kSuperhandler && !fGenericFilesOnly)
if (relation != kNoRelation && relation != kSuperhandler && !fGenericFilesOnly) {
// we hit at least one app that is not a superhandler and
// handles the document
fFoundOneNonSuperHandler = true;
}
return true;
}
@ -1566,14 +1582,15 @@ SearchForSignatureEntryList::CanOpenWithFilter(const Model *appModel,
ConditionalAllAppsIterator::ConditionalAllAppsIterator(
SearchForSignatureEntryList *parent)
: fParent(parent),
fWalker(NULL)
SearchForSignatureEntryList *parent)
:
fParent(parent),
fWalker(NULL)
{
}
void
void
ConditionalAllAppsIterator::Instantiate()
{
if (fWalker)
@ -1592,7 +1609,7 @@ ConditionalAllAppsIterator::~ConditionalAllAppsIterator()
}
status_t
status_t
ConditionalAllAppsIterator::GetNextEntry(BEntry *entry, bool traverse)
{
if (!Iterate())
@ -1603,40 +1620,40 @@ ConditionalAllAppsIterator::GetNextEntry(BEntry *entry, bool traverse)
}
status_t
status_t
ConditionalAllAppsIterator::GetNextRef(entry_ref *ref)
{
if (!Iterate())
return B_ENTRY_NOT_FOUND;
Instantiate();
return fWalker->GetNextRef(ref);
}
int32
int32
ConditionalAllAppsIterator::GetNextDirents(struct dirent *buffer, size_t length, int32 count)
{
if (!Iterate())
return 0;
Instantiate();
return fWalker->GetNextDirents(buffer, length, count);
}
status_t
status_t
ConditionalAllAppsIterator::Rewind()
{
if (!Iterate())
return B_OK;
Instantiate();
return fWalker->Rewind();
}
int32
int32
ConditionalAllAppsIterator::CountEntries()
{
if (!Iterate())
@ -1647,7 +1664,7 @@ ConditionalAllAppsIterator::CountEntries()
}
bool
bool
ConditionalAllAppsIterator::Iterate() const
{
return fParent->ShowAllApplications();

View File

@ -61,265 +61,260 @@ enum {
kPreferredForFile
};
// pass in a predicate; a query will search for matches
// matches will be returned in iteration
class SearchForSignatureEntryList : public EntryListBase {
// pass in a predicate; a query will search for matches
// matches will be returned in iteration
public:
SearchForSignatureEntryList(bool canAddAllApps);
virtual ~SearchForSignatureEntryList();
void PushUniqueSignature(const char *);
// add one signature to search for
// entry list iterators
virtual status_t GetNextEntry(BEntry *entry, bool traverse = false);
virtual status_t GetNextRef(entry_ref *ref);
virtual int32 GetNextDirents(struct dirent *buffer, size_t length,
int32 count = INT_MAX);
virtual status_t Rewind();
virtual int32 CountEntries();
public:
SearchForSignatureEntryList(bool canAddAllApps);
virtual ~SearchForSignatureEntryList();
bool GetPreferredApp(entry_ref *ref) const;
// gets the preferred app for all the files it was asked to
// find supporting apps for, returns false if no preferred app
// found or if more than one found
void TrySettingPreferredApp(const entry_ref *);
void TrySettingPreferredAppForFile(const entry_ref *);
int32 Relation(const BMessage *entriesToOpen, const Model *) const;
// returns the reason why an application is shown in Open With window
void RelationDescription(const BMessage *entriesToOpen, const Model *,
BString *) const;
// returns a string describing why application handles files to open
void PushUniqueSignature(const char *);
// add one signature to search for
static int32 Relation(const BMessage *entriesToOpen,
const Model *, const entry_ref *preferredApp,
const entry_ref *preferredAppForFile);
// returns the reason why an application is shown in Open With window
// static version, needs the preferred app for preformance
static void RelationDescription(const BMessage *entriesToOpen,
const Model *, BString *, const entry_ref *preferredApp,
const entry_ref *preferredAppForFile);
// returns a string describing why application handles files to open
// entry list iterators
virtual status_t GetNextEntry(BEntry *entry, bool traverse = false);
virtual status_t GetNextRef(entry_ref *ref);
virtual int32 GetNextDirents(struct dirent *buffer, size_t length,
int32 count = INT_MAX);
bool CanOpenWithFilter(const Model *appModel, const BMessage *entriesToOpen,
const entry_ref *preferredApp);
virtual status_t Rewind();
virtual int32 CountEntries();
void NonGenericFileFound();
bool GenericFilesOnly() const;
bool ShowAllApplications() const;
bool GetPreferredApp(entry_ref *ref) const;
// gets the preferred app for all the files it was asked to
// find supporting apps for, returns false if no preferred app
// found or if more than one found
void TrySettingPreferredApp(const entry_ref *);
void TrySettingPreferredAppForFile(const entry_ref *);
private:
static int32 Relation(const Model *node, const Model *app);
// returns the reason why an application is shown in Open With window
int32 Relation(const BMessage *entriesToOpen, const Model *) const;
// returns the reason why an application is shown in Open With window
void RelationDescription(const BMessage *entriesToOpen, const Model *,
BString *) const;
// returns a string describing why application handles files to open
CachedEntryIteratorList *fIteratorList;
BObjectList<BString> fSignatures;
static int32 Relation(const BMessage *entriesToOpen,
const Model *, const entry_ref *preferredApp,
const entry_ref *preferredAppForFile);
// returns the reason why an application is shown in Open With window
// static version, needs the preferred app for preformance
static void RelationDescription(const BMessage *entriesToOpen,
const Model *, BString *, const entry_ref *preferredApp,
const entry_ref *preferredAppForFile);
// returns a string describing why application handles files to open
entry_ref fPreferredRef;
int32 fPreferredAppCount;
entry_ref fPreferredRefForFile;
int32 fPreferredAppForFileCount;
bool fGenericFilesOnly;
bool fCanAddAllApps;
bool fFoundOneNonSuperHandler;
bool CanOpenWithFilter(const Model *appModel, const BMessage *entriesToOpen,
const entry_ref *preferredApp);
void NonGenericFileFound();
bool GenericFilesOnly() const;
bool ShowAllApplications() const;
private:
static int32 Relation(const Model *node, const Model *app);
// returns the reason why an application is shown in Open With window
CachedEntryIteratorList *fIteratorList;
BObjectList<BString> fSignatures;
entry_ref fPreferredRef;
int32 fPreferredAppCount;
entry_ref fPreferredRefForFile;
int32 fPreferredAppForFileCount;
bool fGenericFilesOnly;
bool fCanAddAllApps;
bool fFoundOneNonSuperHandler;
};
class OpenWithContainerWindow : public BContainerWindow {
public:
OpenWithContainerWindow(BMessage *entriesToOpen,
LockingList<BWindow> *windowList,
window_look look = B_DOCUMENT_WINDOW_LOOK,
window_feel feel = B_NORMAL_WINDOW_FEEL,
uint32 flags = 0,
uint32 workspace = B_CURRENT_WORKSPACE);
// <entriesToOpen> eventually get opened by the selected app
public:
OpenWithContainerWindow(BMessage *entriesToOpen,
LockingList<BWindow> *windowList,
window_look look = B_DOCUMENT_WINDOW_LOOK,
window_feel feel = B_NORMAL_WINDOW_FEEL,
uint32 flags = 0, uint32 workspace = B_CURRENT_WORKSPACE);
// <entriesToOpen> eventually get opened by the selected app
virtual ~OpenWithContainerWindow();
~OpenWithContainerWindow();
virtual void Init(const BMessage *message);
virtual void Init(const BMessage *message);
const BMessage *EntryList() const;
// return the list of the entries we are supposed to open
const BMessage *EntryList() const;
// return the list of the entries we are supposed to open
void SetCanSetAppAsDefault(bool);
void SetCanOpen(bool);
void SetCanSetAppAsDefault(bool);
void SetCanOpen(bool);
OpenWithPoseView *PoseView() const;
OpenWithPoseView *PoseView() const;
protected:
virtual BPoseView *NewPoseView(Model *model, BRect rect, uint32 viewMode);
protected:
virtual BPoseView *NewPoseView(Model *model, BRect rect, uint32 viewMode);
virtual bool ShouldAddMenus() const;
virtual void ShowContextMenu(BPoint, const entry_ref *, BView *);
virtual void AddShortcuts();
virtual void NewAttributeMenu(BMenu *);
virtual bool ShouldAddMenus() const
{ return false; }
virtual void ShowContextMenu(BPoint, const entry_ref *, BView *)
{ }
virtual void AddShortcuts();
virtual void NewAttributeMenu(BMenu *);
virtual void RestoreState();
virtual void RestoreState(const BMessage &);
virtual void RestoreWindowState(AttributeStreamNode *);
virtual void RestoreWindowState(const BMessage &);
virtual bool NeedsDefaultStateSetup();
virtual void SaveState(bool hide = true);
virtual void SaveState(BMessage &) const;
virtual void SetUpDefaultState();
virtual void RestoreState();
virtual void RestoreState(const BMessage &);
virtual void RestoreWindowState(AttributeStreamNode *);
virtual void RestoreWindowState(const BMessage &);
virtual bool NeedsDefaultStateSetup();
virtual void SaveState(bool hide = true);
virtual void SaveState(BMessage &) const;
virtual void SetUpDefaultState();
virtual bool IsShowing(const node_ref *) const;
virtual bool IsShowing(const entry_ref *) const;
virtual bool IsShowing(const node_ref *) const;
virtual bool IsShowing(const entry_ref *) const;
virtual void MessageReceived(BMessage *);
virtual void MessageReceived(BMessage *);
void OpenWithSelection();
// open entries with the selected app
void MakeDefaultAndOpen();
// open entries with the selected app and make it the default handler
void OpenWithSelection();
// open entries with the selected app
void MakeDefaultAndOpen();
// open entries with the selected app and make it the default handler
private:
static filter_result KeyDownFilter(BMessage *, BHandler **, BMessageFilter *);
private:
static filter_result KeyDownFilter(BMessage *, BHandler **, BMessageFilter *);
BMessage *fEntriesToOpen;
BButton *fLaunchButton;
BButton *fLaunchAndMakeDefaultButton;
BMessage *fEntriesToOpen;
BButton *fLaunchButton;
BButton *fLaunchAndMakeDefaultButton;
typedef BContainerWindow _inherited;
typedef BContainerWindow _inherited;
};
class OpenWithPoseView : public BPoseView {
public:
OpenWithPoseView(BRect, uint32 resizeMask = B_FOLLOW_ALL);
public:
OpenWithPoseView(BRect, uint32 resizeMask = B_FOLLOW_ALL);
virtual void OpenSelection(BPose *, int32 *);
// open entries with the selected app
virtual void OpenSelection(BPose *, int32 *);
// open entries with the selected app
int32 OpenWithRelation(const Model *) const;
// returns the reason why an application is shown in Open With window
void OpenWithRelationDescription(const Model *, BString *) const;
// returns a string describing why application handles files to open
int32 OpenWithRelation(const Model *) const;
// returns the reason why an application is shown in Open With window
void OpenWithRelationDescription(const Model *, BString *) const;
// returns a string describing why application handles files to open
OpenWithContainerWindow *ContainerWindow() const;
virtual bool AddPosesThreadValid(const entry_ref *) const;
protected:
// don't do any volume watching and memtamime watching in open with panels for now
virtual void InitialStartWatching() {}
virtual void FinalStopWatching() {}
OpenWithContainerWindow *ContainerWindow() const;
virtual void AttachedToWindow();
EntryListBase *InitDirentIterator(const entry_ref *ref);
virtual bool AddPosesThreadValid(const entry_ref *) const;
virtual void SetUpDefaultColumnsIfNeeded();
// show launch window specific columns
// empty overrides for functions that depend on having an fModel
virtual void SaveState(AttributeStreamNode *);
virtual void RestoreState(AttributeStreamNode *);
virtual void SaveState(BMessage &) const;
virtual void RestoreState(const BMessage &);
virtual void SavePoseLocations(BRect * = NULL);
virtual void MoveSelectionToTrash(bool selectNext = true);
virtual void MoveSelectionTo(BPoint, BPoint, BContainerWindow*);
virtual void MoveSelectionInto(Model* destFolder, BContainerWindow *srcWindow,
bool forceCopy, bool create_link = false);
virtual bool HandleMessageDropped(BMessage *);
virtual bool CanHandleDragSelection(const Model *, const BMessage *, bool);
protected:
// don't do any volume watching and memtamime watching in open with panels for now
virtual void InitialStartWatching() {}
virtual void FinalStopWatching() {}
virtual bool Represents(const node_ref *) const;
virtual bool Represents(const entry_ref *) const;
virtual void AttachedToWindow();
EntryListBase *InitDirentIterator(const entry_ref *ref);
virtual void CreatePoses(Model **models, PoseInfo *poseInfoArray, int32 count,
BPose **resultingPoses, bool insertionSort = true, int32 *lastPoseIndexPtr = NULL,
BRect *boundsPtr = NULL, bool forceDraw = false);
// override to add selecting the default handling app for selection
virtual void SetUpDefaultColumnsIfNeeded();
// show launch window specific columns
virtual bool ShouldShowPose(const Model *, const PoseInfo *);
virtual void Pulse();
virtual void KeyDown(const char *bytes, int32 count);
// empty overrides for functions that depend on having an fModel
virtual void SaveState(AttributeStreamNode *);
virtual void RestoreState(AttributeStreamNode *);
virtual void SaveState(BMessage &) const;
virtual void RestoreState(const BMessage &);
virtual void SavePoseLocations(BRect * = NULL);
virtual void MoveSelectionToTrash(bool selectNext = true);
virtual void MoveSelectionTo(BPoint, BPoint, BContainerWindow*);
virtual void MoveSelectionInto(Model* destFolder, BContainerWindow *srcWindow,
bool forceCopy, bool create_link = false);
virtual bool HandleMessageDropped(BMessage *);
virtual bool CanHandleDragSelection(const Model *, const BMessage *, bool);
private:
entry_ref fPreferredRef;
bool fHaveCommonPreferredApp;
virtual bool Represents(const node_ref *) const;
virtual bool Represents(const entry_ref *) const;
SearchForSignatureEntryList *fIterator;
// private copy of the iterator pointer
typedef BPoseView _inherited;
virtual void CreatePoses(Model **models, PoseInfo *poseInfoArray, int32 count,
BPose **resultingPoses, bool insertionSort = true, int32 *lastPoseIndexPtr = NULL,
BRect *boundsPtr = NULL, bool forceDraw = false);
// override to add selecting the default handling app for selection
virtual bool ShouldShowPose(const Model *, const PoseInfo *);
virtual void Pulse();
virtual void KeyDown(const char *bytes, int32 count);
private:
entry_ref fPreferredRef;
bool fHaveCommonPreferredApp;
SearchForSignatureEntryList *fIterator;
// private copy of the iterator pointer
typedef BPoseView _inherited;
};
class RelationCachingModelProxy {
public:
RelationCachingModelProxy(Model *);
~RelationCachingModelProxy();
int32 Relation(SearchForSignatureEntryList *, BMessage *entries) const;
public:
RelationCachingModelProxy(Model *model);
~RelationCachingModelProxy();
Model *fModel;
mutable int32 relation;
int32 Relation(SearchForSignatureEntryList *iterator, BMessage *entries) const;
Model *fModel;
mutable int32 fRelation;
};
class OpenWithMenu : public BSlowMenu {
public:
OpenWithMenu(const char *, const BMessage *entriesToOpen,
BWindow *parentWindow, BHandler *);
OpenWithMenu(const char *, const BMessage *entriesToOpen,
BWindow *parentWindow, const BMessenger &);
public:
OpenWithMenu(const char *label, const BMessage *entriesToOpen,
BWindow *parentWindow, BHandler *target);
OpenWithMenu(const char *label, const BMessage *entriesToOpen,
BWindow *parentWindow, const BMessenger &target);
private:
virtual bool StartBuildingItemList();
virtual bool AddNextItem();
virtual void DoneBuildingItemList();
virtual void ClearMenuBuildingState();
private:
friend int SortByRelationAndName(const RelationCachingModelProxy *,
const RelationCachingModelProxy *, void *);
BMessage fEntriesToOpen;
BHandler *target;
BMessenger fMessenger;
virtual bool StartBuildingItemList();
virtual bool AddNextItem();
virtual void DoneBuildingItemList();
virtual void ClearMenuBuildingState();
BMessage fEntriesToOpen;
BHandler *target;
BMessenger fMessenger;
// menu building state
SearchForSignatureEntryList *fIterator;
entry_ref fPreferredRef;
BObjectList<RelationCachingModelProxy> *fSupportingAppList;
bool fHaveCommonPreferredApp;
BWindow *fParentWindow;
// menu building state
SearchForSignatureEntryList *fIterator;
entry_ref fPreferredRef;
BObjectList<RelationCachingModelProxy> *fSupportingAppList;
bool fHaveCommonPreferredApp;
BWindow *fParentWindow;
typedef BSlowMenu _inherited;
friend int SortByRelationAndName(const RelationCachingModelProxy *,
const RelationCachingModelProxy *, void *);
typedef BSlowMenu _inherited;
};
// used for optionally showing the list of all apps. Do nothing
// until asked to iterate and only if supposed to do so
class ConditionalAllAppsIterator : public EntryListBase {
// used for optionally showing the list of all apps. Do nothing
// until asked to iterate and only if supposed to do so
public:
ConditionalAllAppsIterator(SearchForSignatureEntryList *parent);
~ConditionalAllAppsIterator();
virtual status_t GetNextEntry(BEntry *entry, bool traverse = false);
virtual status_t GetNextRef(entry_ref *ref);
virtual int32 GetNextDirents(struct dirent *buffer, size_t length,
int32 count = INT_MAX);
public:
ConditionalAllAppsIterator(SearchForSignatureEntryList *parent);
~ConditionalAllAppsIterator();
virtual status_t Rewind();
virtual int32 CountEntries();
protected:
bool Iterate() const;
void Instantiate();
virtual status_t GetNextEntry(BEntry *entry, bool traverse = false);
virtual status_t GetNextRef(entry_ref *ref);
virtual int32 GetNextDirents(struct dirent *buffer, size_t length,
int32 count = INT_MAX);
private:
SearchForSignatureEntryList *fParent;
WALKER_NS::TWalker *fWalker;
virtual status_t Rewind();
virtual int32 CountEntries();
protected:
bool Iterate() const;
void Instantiate();
private:
SearchForSignatureEntryList *fParent;
WALKER_NS::TWalker *fWalker;
};
} // namespace BPrivate
using namespace BPrivate;
#endif
#endif // _OPEN_WITH_WINDOW_H