Merge branch 'master' into x86_64

This commit is contained in:
Alex Smith
2012-07-30 08:24:31 +01:00
115 changed files with 3526 additions and 2185 deletions
+2
View File
@@ -4,3 +4,5 @@ build/user_config_headers
# ignore KDE backup files ending with a ~ # ignore KDE backup files ending with a ~
*~ *~
# Vim swp files
.*.swp
+7
View File
@@ -130,11 +130,18 @@ copy_headers $haikuSourceDir/headers/posix $tmpIncludeDir/posix
# configure gcc # configure gcc
cd $gccObjDir cd $gccObjDir
case `uname` in
Darwin)
# GCC 2 compiled for x86_64 OS X is broken, compile for i386.
export CC="gcc -arch i386"
;;
esac
CFLAGS="-O2 -U_FORTIFY_SOURCE" CXXFLAGS="-O2" $buildToolsDir/gcc/configure \ CFLAGS="-O2 -U_FORTIFY_SOURCE" CXXFLAGS="-O2" $buildToolsDir/gcc/configure \
--prefix=$installDir \ --prefix=$installDir \
--target=i586-pc-haiku --disable-nls --enable-shared=yes \ --target=i586-pc-haiku --disable-nls --enable-shared=yes \
--enable-languages=c,c++ --with-headers=$tmpIncludeDir \ --enable-languages=c,c++ --with-headers=$tmpIncludeDir \
--with-libs=$tmpLibDir || exit 1 --with-libs=$tmpLibDir || exit 1
unset CC
# hack the Makefile to avoid trouble with stuff we don't need anyway # hack the Makefile to avoid trouble with stuff we don't need anyway
sedExpr= sedExpr=
-8
View File
@@ -102,14 +102,6 @@ protected:
void SetupErrorBuffer(int x, int y, int width); void SetupErrorBuffer(int x, int y, int width);
void DitherFloydSteinberg(uchar* destination, void DitherFloydSteinberg(uchar* destination,
const uchar* source, int x, int y, int width); const uchar* source, int x, int y, int width);
// Do nothing method to get around a bug in
// the gcc2 cross-compiler built on Mac OS X
// Lion where a compiler error occurs when
// assigning a member function pointer to NULL
// or 0: cast specifies signature type.
// However, this should be legal according to
// the C++03 standard.
void DitherNone(uchar*, const uchar*, int, int, int) {};
private: private:
enum { enum {
+2 -2
View File
@@ -80,9 +80,9 @@ private:
void _InitData(); void _InitData();
void _InitMenuData(BMenu* menu); void _InitMenuData(BMenu* menu);
void _DrawMarkSymbol(rgb_color backgroundColor); void _DrawMarkSymbol();
void _DrawShortcutSymbol(); void _DrawShortcutSymbol();
void _DrawSubmenuSymbol(rgb_color backgroundColor); void _DrawSubmenuSymbol();
void _DrawControlChar(char shortcut, BPoint where); void _DrawControlChar(char shortcut, BPoint where);
private: private:
@@ -21,7 +21,7 @@
Resampler::Resampler(uint32 src_format, uint32 dst_format) Resampler::Resampler(uint32 src_format, uint32 dst_format)
: :
fFunc(&Resampler::no_conversion) fFunc(0)
{ {
if (dst_format == media_raw_audio_format::B_AUDIO_FLOAT) { if (dst_format == media_raw_audio_format::B_AUDIO_FLOAT) {
switch (src_format) { switch (src_format) {
@@ -81,7 +81,7 @@ Resampler::~Resampler()
status_t status_t
Resampler::InitCheck() const Resampler::InitCheck() const
{ {
return fFunc != &Resampler::no_conversion ? B_OK : B_ERROR; return fFunc != 0 ? B_OK : B_ERROR;
} }
@@ -65,15 +65,6 @@ private:
int32 srcSampleOffset, int32 srcSampleCount, int32 srcSampleOffset, int32 srcSampleCount,
void* dest, int32 destSampleOffset, void* dest, int32 destSampleOffset,
int32 destSampleCount, float gain); int32 destSampleCount, float gain);
// Do nothing method to get around a bug in
// the gcc2 cross-compiler built on Mac OS X
// Lion where a compiler error occurs when
// assigning a member function pointer to NULL
// or 0: cast specifies signature type.
// However, this should be legal according to
// the C++03 standard.
void no_conversion(const void*, int32, int32, void*,
int32, int32, float) {};
}; };
+10 -4
View File
@@ -594,14 +594,20 @@ CliDebugger::Run(const Options& options)
if (!get_debugged_program(options, programInfo)) if (!get_debugged_program(options, programInfo))
return false; return false;
if (start_team_debugger(programInfo.team, &settingsManager, this, TeamDebugger* teamDebugger = start_team_debugger(programInfo.team,
programInfo.thread, programInfo.stopInMain, userInterface) &settingsManager, this, programInfo.thread, programInfo.stopInMain,
== NULL) { userInterface);
if (teamDebugger == NULL)
return false; return false;
}
thread_id teamDebuggerThread = teamDebugger->Thread();
// run the input loop
userInterface->Run(); userInterface->Run();
// wait for the team debugger thread to terminate
wait_for_thread(teamDebuggerThread, NULL);
return true; return true;
} }
+161 -22
View File
@@ -11,6 +11,9 @@
#include <new> #include <new>
#include <AutoDeleter.h> #include <AutoDeleter.h>
#include <Entry.h>
#include <FindDirectory.h>
#include <Path.h>
#include "AttributeClasses.h" #include "AttributeClasses.h"
#include "AttributeValue.h" #include "AttributeValue.h"
@@ -27,6 +30,30 @@
#include "Variant.h" #include "Variant.h"
// #pragma mark - AutoSectionPutter
class AutoSectionPutter {
public:
AutoSectionPutter(ElfFile* elfFile, ElfSection* elfSection)
:
fElfFile(elfFile),
fElfSection(elfSection)
{
}
~AutoSectionPutter()
{
if (fElfSection != NULL)
fElfFile->PutSection(fElfSection);
}
private:
ElfFile* fElfFile;
ElfSection* fElfSection;
};
// #pragma mark - ExpressionEvaluationContext // #pragma mark - ExpressionEvaluationContext
@@ -281,7 +308,9 @@ private:
DwarfFile::DwarfFile() DwarfFile::DwarfFile()
: :
fName(NULL), fName(NULL),
fAlternateName(NULL),
fElfFile(NULL), fElfFile(NULL),
fAlternateElfFile(NULL),
fDebugInfoSection(NULL), fDebugInfoSection(NULL),
fDebugAbbrevSection(NULL), fDebugAbbrevSection(NULL),
fDebugStringSection(NULL), fDebugStringSection(NULL),
@@ -305,19 +334,24 @@ DwarfFile::~DwarfFile()
delete table; delete table;
if (fElfFile != NULL) { if (fElfFile != NULL) {
fElfFile->PutSection(fDebugInfoSection); ElfFile* debugInfoFile = fAlternateElfFile != NULL
fElfFile->PutSection(fDebugAbbrevSection); ? fAlternateElfFile : fElfFile;
fElfFile->PutSection(fDebugStringSection);
fElfFile->PutSection(fDebugRangesSection); debugInfoFile->PutSection(fDebugInfoSection);
fElfFile->PutSection(fDebugLineSection); debugInfoFile->PutSection(fDebugAbbrevSection);
fElfFile->PutSection(fDebugFrameSection); debugInfoFile->PutSection(fDebugStringSection);
debugInfoFile->PutSection(fDebugRangesSection);
debugInfoFile->PutSection(fDebugLineSection);
debugInfoFile->PutSection(fDebugFrameSection);
fElfFile->PutSection(fEHFrameSection); fElfFile->PutSection(fEHFrameSection);
fElfFile->PutSection(fDebugLocationSection); debugInfoFile->PutSection(fDebugLocationSection);
fElfFile->PutSection(fDebugPublicTypesSection); debugInfoFile->PutSection(fDebugPublicTypesSection);
delete fElfFile; delete fElfFile;
delete fAlternateElfFile;
} }
free(fName); free(fName);
free(fAlternateName);
} }
@@ -337,23 +371,24 @@ DwarfFile::Load(const char* fileName)
if (error != B_OK) if (error != B_OK)
return error; return error;
// get the interesting sections error = _LocateDebugInfo();
fDebugInfoSection = fElfFile->GetSection(".debug_info"); if (error != B_OK)
fDebugAbbrevSection = fElfFile->GetSection(".debug_abbrev"); return error;
if (fDebugInfoSection == NULL || fDebugAbbrevSection == NULL) {
WARNING("DwarfManager::File::Load(\"%s\"): no " ElfFile* debugInfoFile = fAlternateElfFile != NULL
".debug_info or .debug_abbrev.\n", fileName); ? fAlternateElfFile : fElfFile;
return B_ERROR;
}
// non mandatory sections // non mandatory sections
fDebugStringSection = fElfFile->GetSection(".debug_str"); fDebugStringSection = debugInfoFile->GetSection(".debug_str");
fDebugRangesSection = fElfFile->GetSection(".debug_ranges"); fDebugRangesSection = debugInfoFile->GetSection(".debug_ranges");
fDebugLineSection = fElfFile->GetSection(".debug_line"); fDebugLineSection = debugInfoFile->GetSection(".debug_line");
fDebugFrameSection = fElfFile->GetSection(".debug_frame"); fDebugFrameSection = debugInfoFile->GetSection(".debug_frame");
// .eh_frame doesn't appear to get copied into separate debug
// info files properly, therefore always use it off the main
// executable image
fEHFrameSection = fElfFile->GetSection(".eh_frame"); fEHFrameSection = fElfFile->GetSection(".eh_frame");
fDebugLocationSection = fElfFile->GetSection(".debug_loc"); fDebugLocationSection = debugInfoFile->GetSection(".debug_loc");
fDebugPublicTypesSection = fElfFile->GetSection(".debug_pubtypes"); fDebugPublicTypesSection = debugInfoFile->GetSection(".debug_pubtypes");
// iterate through the debug info section // iterate through the debug info section
DataReader dataReader(fDebugInfoSection->Data(), DataReader dataReader(fDebugInfoSection->Data(),
@@ -2224,3 +2259,107 @@ DwarfFile::_FindLocationExpression(CompilationUnit* unit, uint64 offset,
} }
} }
} }
status_t
DwarfFile::_LocateDebugInfo()
{
ElfFile* debugInfoFile = fElfFile;
ElfSection* debugLinkSection = fElfFile->GetSection(".gnu_debuglink");
if (debugLinkSection != NULL) {
AutoSectionPutter putter(fElfFile, debugLinkSection);
// the file specifies a debug link, look at its target instead
// for debug information.
// Format: null-terminated filename, as many 0 padding bytes as
// needed to reach the next 32-bit address boundary, followed
// by a 32-bit CRC
BString debugPath;
status_t result = _GetDebugInfoPath(
(const char*)debugLinkSection->Data(), debugPath);
if (result != B_OK)
return result;
fAlternateName = strdup(debugPath.String());
if (fAlternateName == NULL)
return B_NO_MEMORY;
/*
// TODO: validate CRC
int32 debugCRC = *(int32*)((char*)debugLinkSection->Data()
+ debugLinkSection->Size() - sizeof(int32));
*/
fAlternateElfFile = new(std::nothrow) ElfFile;
if (fAlternateElfFile == NULL)
return B_NO_MEMORY;
result = fAlternateElfFile->Init(fAlternateName);
if (result != B_OK)
return result;
debugInfoFile = fAlternateElfFile;
}
// get the interesting sections
fDebugInfoSection = debugInfoFile->GetSection(".debug_info");
fDebugAbbrevSection = debugInfoFile->GetSection(".debug_abbrev");
if (fDebugInfoSection == NULL || fDebugAbbrevSection == NULL) {
WARNING("DwarfManager::File::Load(\"%s\"): no "
".debug_info or .debug_abbrev.\n", fName);
return B_ERROR;
}
return B_OK;
}
status_t
DwarfFile::_GetDebugInfoPath(const char* debugFileName, BString& _infoPath)
{
const directory_which dirLocations[] = { B_USER_CONFIG_DIRECTORY,
B_COMMON_DIRECTORY, B_SYSTEM_DIRECTORY };
// first, see if we have a relative match to our local directory
BPath basePath;
status_t result = basePath.SetTo(fName);
if (result != B_OK)
return result;
basePath.GetParent(&basePath);
if (strcmp(basePath.Leaf(), "lib") == 0 || strcmp(basePath.Leaf(),
"add-ons") == 0) {
_infoPath.SetToFormat("%s/../debug/%s", basePath.Path(),
debugFileName);
} else
_infoPath.SetToFormat("%s/debug/%s", basePath.Path(), debugFileName);
BEntry entry(_infoPath.String());
result = entry.InitCheck();
if (result != B_OK && result != B_ENTRY_NOT_FOUND)
return result;
if (entry.Exists())
return B_OK;
// See if our image is in any of the system locations.
// if so, look for its debug info in the corresponding location.
for (uint16 i = 0; i < sizeof(dirLocations) / sizeof(directory_which);
i++) {
result = find_directory(dirLocations[i], &basePath);
if (result != B_OK)
return result;
if (strncmp(fName, basePath.Path(), strlen(basePath.Path())) == 0) {
_infoPath.SetToFormat("%s/develop/debug/%s", basePath.Path(),
debugFileName);
entry.SetTo(_infoPath.String());
result = entry.InitCheck();
if (result != B_OK && result != B_ENTRY_NOT_FOUND)
return result;
return entry.Exists() ? B_OK : B_ENTRY_NOT_FOUND;
}
}
return B_ENTRY_NOT_FOUND;
}
+6
View File
@@ -150,12 +150,18 @@ private:
const void*& _expression, const void*& _expression,
off_t& _length) const; off_t& _length) const;
status_t _LocateDebugInfo();
status_t _GetDebugInfoPath(const char* fileName,
BString& _infoPath);
private: private:
friend class DwarfFile::ExpressionEvaluationContext; friend class DwarfFile::ExpressionEvaluationContext;
private: private:
char* fName; char* fName;
char* fAlternateName;
ElfFile* fElfFile; ElfFile* fElfFile;
ElfFile* fAlternateElfFile;
ElfSection* fDebugInfoSection; ElfSection* fDebugInfoSection;
ElfSection* fDebugAbbrevSection; ElfSection* fDebugAbbrevSection;
ElfSection* fDebugStringSection; ElfSection* fDebugStringSection;
@@ -28,16 +28,22 @@ CliContext::CliContext()
fHistory(NULL), fHistory(NULL),
fPrompt(NULL), fPrompt(NULL),
fBlockingSemaphore(-1), fBlockingSemaphore(-1),
fInputLoopWaitingForEvents(0),
fEventsOccurred(0),
fInputLoopWaiting(false), fInputLoopWaiting(false),
fTerminating(false) fTerminating(false)
{ {
sCurrentContext = this; sCurrentContext = this;
} }
CliContext::~CliContext() CliContext::~CliContext()
{ {
Cleanup(); Cleanup();
sCurrentContext = NULL; sCurrentContext = NULL;
if (fBlockingSemaphore >= 0)
delete_sem(fBlockingSemaphore);
} }
@@ -47,6 +53,8 @@ CliContext::Init(Team* team, UserInterfaceListener* listener)
fTeam = team; fTeam = team;
fListener = listener; fListener = listener;
fTeam->AddListener(this);
status_t error = fLock.InitCheck(); status_t error = fLock.InitCheck();
if (error != B_OK) if (error != B_OK)
return error; return error;
@@ -88,6 +96,11 @@ CliContext::Cleanup()
history_end(fHistory); history_end(fHistory);
fHistory = NULL; fHistory = NULL;
} }
if (fTeam != NULL) {
fTeam->RemoveListener(this);
fTeam = NULL;
}
} }
@@ -97,13 +110,7 @@ CliContext::Terminating()
AutoLocker<BLocker> locker(fLock); AutoLocker<BLocker> locker(fLock);
fTerminating = true; fTerminating = true;
_SignalInputLoop(EVENT_QUIT);
if (fBlockingSemaphore >= 0) {
delete_sem(fBlockingSemaphore);
fBlockingSemaphore = -1;
}
fInputLoopWaiting = false;
// TODO: Signal the input loop, should it be in PromptUser()! // TODO: Signal the input loop, should it be in PromptUser()!
} }
@@ -134,27 +141,104 @@ CliContext::AddLineToInputHistory(const char* line)
void void
CliContext::QuitSession(bool killTeam) CliContext::QuitSession(bool killTeam)
{ {
AutoLocker<BLocker> locker(fLock); _PrepareToWaitForEvents(EVENT_QUIT);
sem_id blockingSemaphore = fBlockingSemaphore;
fInputLoopWaiting = true;
locker.Unlock();
fListener->UserInterfaceQuitRequested( fListener->UserInterfaceQuitRequested(
killTeam killTeam
? UserInterfaceListener::QUIT_OPTION_ASK_KILL_TEAM ? UserInterfaceListener::QUIT_OPTION_ASK_KILL_TEAM
: UserInterfaceListener::QUIT_OPTION_ASK_RESUME_TEAM); : UserInterfaceListener::QUIT_OPTION_ASK_RESUME_TEAM);
while (acquire_sem(blockingSemaphore) == B_INTERRUPTED) { _WaitForEvents();
}
} }
void void
CliContext::WaitForThreadOrUser() CliContext::WaitForThreadOrUser()
{ {
// TODO:... // TODO: Deal with SIGINT as well!
for (;;) {
_PrepareToWaitForEvents(
EVENT_USER_INTERRUPT | EVENT_THREAD_STATE_CHANGED);
// check whether there are any threads stopped already
thread_id stoppedThread = -1;
AutoLocker<Team> teamLocker(fTeam);
for (ThreadList::ConstIterator it = fTeam->Threads().GetIterator();
Thread* thread = it.Next();) {
if (thread->State() == THREAD_STATE_STOPPED) {
stoppedThread = thread->ID();
break;
}
}
teamLocker.Unlock();
if (stoppedThread >= 0)
_SignalInputLoop(EVENT_THREAD_STATE_CHANGED);
uint32 events = _WaitForEvents();
if ((events & EVENT_QUIT) != 0 || stoppedThread >= 0)
return;
}
}
void
CliContext::ThreadStateChanged(const Team::ThreadEvent& event)
{
_SignalInputLoop(EVENT_THREAD_STATE_CHANGED);
}
void
CliContext::_PrepareToWaitForEvents(uint32 eventMask)
{
// Set the events we're going to wait for -- always wait for "quit".
AutoLocker<BLocker> locker(fLock);
fInputLoopWaitingForEvents = eventMask | EVENT_QUIT;
fEventsOccurred = fTerminating ? EVENT_QUIT : 0;
}
uint32
CliContext::_WaitForEvents()
{
AutoLocker<BLocker> locker(fLock);
if (fEventsOccurred == 0) {
sem_id blockingSemaphore = fBlockingSemaphore;
fInputLoopWaiting = true;
locker.Unlock();
while (acquire_sem(blockingSemaphore) == B_INTERRUPTED) {
}
locker.Lock();
}
uint32 events = fEventsOccurred;
fEventsOccurred = 0;
return events;
}
void
CliContext::_SignalInputLoop(uint32 events)
{
AutoLocker<BLocker> locker(fLock);
if ((fInputLoopWaitingForEvents & events) == 0)
return;
fEventsOccurred = fInputLoopWaitingForEvents & events;
fInputLoopWaitingForEvents = 0;
if (fInputLoopWaiting) {
fInputLoopWaiting = false;
release_sem(fBlockingSemaphore);
}
} }
@@ -12,12 +12,21 @@
#include <Locker.h> #include <Locker.h>
#include "Team.h"
class Team; class Team;
class UserInterfaceListener; class UserInterfaceListener;
class CliContext { class CliContext : private Team::Listener {
public:
enum {
EVENT_QUIT = 0x01,
EVENT_USER_INTERRUPT = 0x02,
EVENT_THREAD_STATE_CHANGED = 0x04,
};
public: public:
CliContext(); CliContext();
~CliContext(); ~CliContext();
@@ -40,6 +49,15 @@ public:
void WaitForThreadOrUser(); void WaitForThreadOrUser();
private: private:
// Team::Listener
virtual void ThreadStateChanged(
const Team::ThreadEvent& event);
private:
void _PrepareToWaitForEvents(uint32 eventMask);
uint32 _WaitForEvents();
void _SignalInputLoop(uint32 events);
static const char* _GetPrompt(EditLine* editLine); static const char* _GetPrompt(EditLine* editLine);
private: private:
@@ -50,6 +68,8 @@ private:
History* fHistory; History* fHistory;
const char* fPrompt; const char* fPrompt;
sem_id fBlockingSemaphore; sem_id fBlockingSemaphore;
uint32 fInputLoopWaitingForEvents;
uint32 fEventsOccurred;
bool fInputLoopWaiting; bool fInputLoopWaiting;
volatile bool fTerminating; volatile bool fTerminating;
}; };
+1 -1
View File
@@ -858,7 +858,7 @@ void
TBarApp::FetchAppIcon(const char* signature, BBitmap* icon) TBarApp::FetchAppIcon(const char* signature, BBitmap* icon)
{ {
app_info appInfo; app_info appInfo;
icon_size size = icon->Bounds().IntegerHeight() >= 32 icon_size size = icon->Bounds().IntegerHeight() >= 31
? B_LARGE_ICON : B_MINI_ICON; ? B_LARGE_ICON : B_MINI_ICON;
if (be_roster->GetAppInfo(signature, &appInfo) == B_OK) { if (be_roster->GetAppInfo(signature, &appInfo) == B_OK) {
+1 -1
View File
@@ -53,7 +53,7 @@ static const uint32 kHidePassword = 'hdpw';
AuthenticationPanel::AuthenticationPanel(BRect parentFrame) AuthenticationPanel::AuthenticationPanel(BRect parentFrame)
: :
BWindow(BRect(-1000, -1000, -900, -900), BWindow(BRect(-1000, -1000, -900, -900),
B_TRANSLATE("Authentication Required"), B_TITLED_WINDOW_LOOK, B_TRANSLATE("Authentication required"), B_TITLED_WINDOW_LOOK,
B_MODAL_APP_WINDOW_FEEL, B_ASYNCHRONOUS_CONTROLS | B_NOT_RESIZABLE B_MODAL_APP_WINDOW_FEEL, B_ASYNCHRONOUS_CONTROLS | B_NOT_RESIZABLE
| B_NOT_ZOOMABLE | B_CLOSE_ON_ESCAPE | B_AUTO_UPDATE_SIZE_LIMITS), | B_NOT_ZOOMABLE | B_CLOSE_ON_ESCAPE | B_AUTO_UPDATE_SIZE_LIMITS),
m_parentWindowFrame(parentFrame), m_parentWindowFrame(parentFrame),
+7 -14
View File
@@ -356,7 +356,7 @@ BrowserWindow::BrowserWindow(BRect frame, SettingsMessage* appSettings,
menu->AddItem(fZoomTextOnlyMenuItem); menu->AddItem(fZoomTextOnlyMenuItem);
menu->AddSeparatorItem(); menu->AddSeparatorItem();
fFullscreenItem = new BMenuItem(B_TRANSLATE("Fullscreen"), fFullscreenItem = new BMenuItem(B_TRANSLATE("Full screen"),
new BMessage(TOGGLE_FULLSCREEN), B_RETURN); new BMessage(TOGGLE_FULLSCREEN), B_RETURN);
menu->AddItem(fFullscreenItem); menu->AddItem(fFullscreenItem);
menu->AddItem(new BMenuItem(B_TRANSLATE("Page source"), menu->AddItem(new BMenuItem(B_TRANSLATE("Page source"),
@@ -987,13 +987,6 @@ BrowserWindow::MenusBeginning()
} }
void
BrowserWindow::Zoom(BPoint origin, float width, float height)
{
ToggleFullscreen();
}
void void
BrowserWindow::ScreenChanged(BRect screenSize, color_space format) BrowserWindow::ScreenChanged(BRect screenSize, color_space format)
{ {
@@ -1234,8 +1227,8 @@ BrowserWindow::LoadNegotiating(const BString& url, BWebView* view)
fURLInputGroup->SetText(url.String()); fURLInputGroup->SetText(url.String());
BString status(B_TRANSLATE("Requesting: ")); BString status(B_TRANSLATE("Requesting %url"));
status << url; status.ReplaceFirst("%url", url);
view->WebPage()->SetStatusMessage(status); view->WebPage()->SetStatusMessage(status);
} }
@@ -1249,8 +1242,8 @@ BrowserWindow::LoadCommitted(const BString& url, BWebView* view)
// This hook is invoked when the load is commited. // This hook is invoked when the load is commited.
fURLInputGroup->SetText(url.String()); fURLInputGroup->SetText(url.String());
BString status(B_TRANSLATE("Loading: ")); BString status(B_TRANSLATE("Loading %url"));
status << url; status.ReplaceFirst("%url", url);
view->WebPage()->SetStatusMessage(status); view->WebPage()->SetStatusMessage(status);
} }
@@ -1275,7 +1268,7 @@ BrowserWindow::LoadFailed(const BString& url, BWebView* view)
if (view != CurrentWebView()) if (view != CurrentWebView())
return; return;
BString status(B_TRANSLATE_COMMENT("%url failed.", "Loading URL failed. " BString status(B_TRANSLATE_COMMENT("%url failed", "Loading URL failed. "
"Don't translate variable %url.")); "Don't translate variable %url."));
status.ReplaceFirst("%url", url); status.ReplaceFirst("%url", url);
view->WebPage()->SetStatusMessage(status); view->WebPage()->SetStatusMessage(status);
@@ -1290,7 +1283,7 @@ BrowserWindow::LoadFinished(const BString& url, BWebView* view)
if (view != CurrentWebView()) if (view != CurrentWebView())
return; return;
BString status(B_TRANSLATE_COMMENT("%url finished.", "Loading URL " BString status(B_TRANSLATE_COMMENT("%url finished", "Loading URL "
"finished. Don't translate variable %url.")); "finished. Don't translate variable %url."));
status.ReplaceFirst("%url", url); status.ReplaceFirst("%url", url);
view->WebPage()->SetStatusMessage(status); view->WebPage()->SetStatusMessage(status);
-1
View File
@@ -96,7 +96,6 @@ public:
virtual bool QuitRequested(); virtual bool QuitRequested();
virtual void MenusBeginning(); virtual void MenusBeginning();
virtual void Zoom(BPoint origin, float width, float height);
virtual void ScreenChanged(BRect screenSize, virtual void ScreenChanged(BRect screenSize,
color_space format); color_space format);
virtual void WorkspacesChanged(uint32 oldWorkspaces, virtual void WorkspacesChanged(uint32 oldWorkspaces,
+5 -5
View File
@@ -326,22 +326,22 @@ SettingsWindow::_CreateGeneralPage(float spacing)
fDaysInHistoryMenuControl->TextView()->DisallowChar(i); fDaysInHistoryMenuControl->TextView()->DisallowChar(i);
fShowTabsIfOnlyOnePage = new BCheckBox("show tabs if only one page", fShowTabsIfOnlyOnePage = new BCheckBox("show tabs if only one page",
B_TRANSLATE("Show tabs if only one page is open."), B_TRANSLATE("Show tabs if only one page is open"),
new BMessage(MSG_TAB_DISPLAY_BEHAVIOR_CHANGED)); new BMessage(MSG_TAB_DISPLAY_BEHAVIOR_CHANGED));
fShowTabsIfOnlyOnePage->SetValue(B_CONTROL_ON); fShowTabsIfOnlyOnePage->SetValue(B_CONTROL_ON);
fAutoHideInterfaceInFullscreenMode = new BCheckBox("auto-hide interface", fAutoHideInterfaceInFullscreenMode = new BCheckBox("auto-hide interface",
B_TRANSLATE("Auto-hide interface in fullscreen mode."), B_TRANSLATE("Auto-hide interface in full screen mode"),
new BMessage(MSG_AUTO_HIDE_INTERFACE_BEHAVIOR_CHANGED)); new BMessage(MSG_AUTO_HIDE_INTERFACE_BEHAVIOR_CHANGED));
fAutoHideInterfaceInFullscreenMode->SetValue(B_CONTROL_OFF); fAutoHideInterfaceInFullscreenMode->SetValue(B_CONTROL_OFF);
fAutoHidePointer = new BCheckBox("auto-hide pointer", fAutoHidePointer = new BCheckBox("auto-hide pointer",
B_TRANSLATE("Auto-hide mouse pointer."), B_TRANSLATE("Auto-hide mouse pointer"),
new BMessage(MSG_AUTO_HIDE_POINTER_BEHAVIOR_CHANGED)); new BMessage(MSG_AUTO_HIDE_POINTER_BEHAVIOR_CHANGED));
fAutoHidePointer->SetValue(B_CONTROL_OFF); fAutoHidePointer->SetValue(B_CONTROL_OFF);
fShowHomeButton = new BCheckBox("show home button", fShowHomeButton = new BCheckBox("show home button",
B_TRANSLATE("Show Home Button"), B_TRANSLATE("Show home button"),
new BMessage(MSG_SHOW_HOME_BUTTON_CHANGED)); new BMessage(MSG_SHOW_HOME_BUTTON_CHANGED));
fShowHomeButton->SetValue(B_CONTROL_ON); fShowHomeButton->SetValue(B_CONTROL_ON);
@@ -445,7 +445,7 @@ BView*
SettingsWindow::_CreateProxyPage(float spacing) SettingsWindow::_CreateProxyPage(float spacing)
{ {
fUseProxyCheckBox = new BCheckBox("use proxy", fUseProxyCheckBox = new BCheckBox("use proxy",
B_TRANSLATE("Use proxy server to connect to the internet."), B_TRANSLATE("Use proxy server to connect to the internet"),
new BMessage(MSG_USE_PROXY_CHANGED)); new BMessage(MSG_USE_PROXY_CHANGED));
fUseProxyCheckBox->SetValue(B_CONTROL_ON); fUseProxyCheckBox->SetValue(B_CONTROL_ON);
@@ -138,7 +138,7 @@ TabContainerView::MouseDown(BPoint where)
else { else {
if ((buttons & B_TERTIARY_MOUSE_BUTTON) != 0) { if ((buttons & B_TERTIARY_MOUSE_BUTTON) != 0) {
// Middle click outside tabs should always open a new tab. // Middle click outside tabs should always open a new tab.
fClickCount = 2; fController->DoubleClickOutsideTabs();
} else if (clicks > 1) } else if (clicks > 1)
fClickCount++; fClickCount++;
else else
+4 -13
View File
@@ -454,7 +454,6 @@ private:
TabManagerController* fController; TabManagerController* fController;
bool fOverCloseRect; bool fOverCloseRect;
bool fClicked; bool fClicked;
bool fCloseOnMouseUp;
}; };
@@ -464,8 +463,7 @@ WebTabView::WebTabView(TabManagerController* controller)
fIcon(NULL), fIcon(NULL),
fController(controller), fController(controller),
fOverCloseRect(false), fOverCloseRect(false),
fClicked(false), fClicked(false)
fCloseOnMouseUp(false)
{ {
} }
@@ -539,7 +537,8 @@ void
WebTabView::MouseDown(BPoint where, uint32 buttons) WebTabView::MouseDown(BPoint where, uint32 buttons)
{ {
if (buttons & B_TERTIARY_MOUSE_BUTTON) { if (buttons & B_TERTIARY_MOUSE_BUTTON) {
fCloseOnMouseUp = true; // Immediately close tab
fController->CloseTab(ContainerView()->IndexOf(this));
return; return;
} }
@@ -557,20 +556,12 @@ WebTabView::MouseDown(BPoint where, uint32 buttons)
void void
WebTabView::MouseUp(BPoint where) WebTabView::MouseUp(BPoint where)
{ {
if (!fClicked && !fCloseOnMouseUp) { if (!fClicked) {
TabView::MouseUp(where); TabView::MouseUp(where);
return; return;
} }
if (fCloseOnMouseUp && Frame().Contains(where)) {
fCloseOnMouseUp = false;
fController->CloseTab(ContainerView()->IndexOf(this));
// Probably this object is toast now, better return here.
return;
}
fClicked = false; fClicked = false;
fCloseOnMouseUp = false;
if (_CloseRectFrame(Frame()).Contains(where)) if (_CloseRectFrame(Frame()).Contains(where))
fController->CloseTab(ContainerView()->IndexOf(this)); fController->CloseTab(ContainerView()->IndexOf(this));
+2 -2
View File
@@ -127,7 +127,7 @@ _BMCMenuBar_::AttachedToWindow()
if (Parent() != NULL) if (Parent() != NULL)
SetLowColor(Parent()->LowColor()); SetLowColor(Parent()->LowColor());
else else
SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR)); SetLowColor(ui_color(B_MENU_BACKGROUND_COLOR));
} }
@@ -136,7 +136,7 @@ _BMCMenuBar_::Draw(BRect updateRect)
{ {
if (be_control_look != NULL) { if (be_control_look != NULL) {
BRect rect(Bounds()); BRect rect(Bounds());
rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR); rgb_color base = ui_color(B_MENU_BACKGROUND_COLOR);
uint32 flags = 0; uint32 flags = 0;
if (!IsEnabled()) if (!IsEnabled())
flags |= BControlLook::B_DISABLED; flags |= BControlLook::B_DISABLED;
+18 -27
View File
@@ -443,43 +443,34 @@ BMenuItem::DrawContent()
void void
BMenuItem::Draw() BMenuItem::Draw()
{ {
rgb_color lowColor = fSuper->LowColor();
bool enabled = IsEnabled(); bool enabled = IsEnabled();
bool selected = IsSelected(); bool selected = IsSelected();
rgb_color noTint = fSuper->LowColor();
rgb_color bgColor = noTint;
// set low color and fill background if selected // set low color and fill background if selected
bool activated = selected && (enabled || Submenu()) bool activated = selected && (enabled || Submenu())
/*&& fSuper->fRedrawAfterSticky*/; /*&& fSuper->fRedrawAfterSticky*/;
if (activated) { if (activated) {
bgColor = tint_color(bgColor, B_DARKEN_3_TINT);
if (be_control_look != NULL) { if (be_control_look != NULL) {
BRect rect = Frame(); BRect rect = Frame();
be_control_look->DrawMenuItemBackground(fSuper, rect, rect, be_control_look->DrawMenuItemBackground(fSuper, rect, rect,
noTint, BControlLook::B_ACTIVATED); ui_color(B_MENU_SELECTED_BACKGROUND_COLOR),
BControlLook::B_ACTIVATED);
} else { } else {
fSuper->SetLowColor(bgColor); fSuper->SetLowColor(ui_color(B_MENU_SELECTED_BACKGROUND_COLOR));
fSuper->FillRect(Frame(), B_SOLID_LOW); fSuper->FillRect(Frame(), B_SOLID_LOW);
} }
} else {
fSuper->SetLowColor(bgColor);
} }
// set high color // set high color
if (be_control_look != NULL) { if (activated)
if (enabled) { fSuper->SetHighColor(ui_color(B_MENU_SELECTED_ITEM_TEXT_COLOR));
fSuper->SetHighColor(tint_color(fSuper->LowColor(), else if (enabled)
B_DARKEN_MAX_TINT));
} else {
fSuper->SetHighColor(tint_color(fSuper->LowColor(),
B_DISABLED_LABEL_TINT));
}
} else {
if (enabled)
fSuper->SetHighColor(ui_color(B_MENU_ITEM_TEXT_COLOR)); fSuper->SetHighColor(ui_color(B_MENU_ITEM_TEXT_COLOR));
else else {
fSuper->SetHighColor(tint_color(bgColor, B_DISABLED_LABEL_TINT)); // TODO: Use a lighten tint if the menu uses a dark background
fSuper->SetHighColor(tint_color(lowColor, B_DISABLED_LABEL_TINT));
} }
// draw content // draw content
@@ -490,16 +481,16 @@ BMenuItem::Draw()
const menu_layout layout = MenuPrivate(fSuper).Layout(); const menu_layout layout = MenuPrivate(fSuper).Layout();
if (layout == B_ITEMS_IN_COLUMN) { if (layout == B_ITEMS_IN_COLUMN) {
if (IsMarked()) if (IsMarked())
_DrawMarkSymbol(bgColor); _DrawMarkSymbol();
if (fShortcutChar) if (fShortcutChar)
_DrawShortcutSymbol(); _DrawShortcutSymbol();
if (Submenu()) if (Submenu())
_DrawSubmenuSymbol(bgColor); _DrawSubmenuSymbol();
} }
fSuper->SetLowColor(noTint); fSuper->SetLowColor(lowColor);
} }
@@ -682,7 +673,7 @@ BMenuItem::Select(bool selected)
void void
BMenuItem::_DrawMarkSymbol(rgb_color bgColor) BMenuItem::_DrawMarkSymbol()
{ {
fSuper->PushState(); fSuper->PushState();
@@ -710,7 +701,6 @@ BMenuItem::_DrawMarkSymbol(rgb_color bgColor)
arrowShape.LineTo(BPoint(center.x + size, center.y - size)); arrowShape.LineTo(BPoint(center.x + size, center.y - size));
fSuper->SetDrawingMode(B_OP_OVER); fSuper->SetDrawingMode(B_OP_OVER);
fSuper->SetHighColor(tint_color(bgColor, B_DARKEN_MAX_TINT));
fSuper->SetPenSize(2.0); fSuper->SetPenSize(2.0);
// NOTE: StrokeShape() offsets the shape by the current pen position, // NOTE: StrokeShape() offsets the shape by the current pen position,
// it is not documented in the BeBook, but it is true! // it is not documented in the BeBook, but it is true!
@@ -742,6 +732,8 @@ BMenuItem::_DrawShortcutSymbol()
where.y += (fBounds.Height() - 11) / 2 - 1; where.y += (fBounds.Height() - 11) / 2 - 1;
where.x -= 4; where.x -= 4;
// TODO: It would be nice to draw these taking into account the text (low)
// color.
if (fModifiers & B_COMMAND_KEY) { if (fModifiers & B_COMMAND_KEY) {
const BBitmap *command = MenuPrivate::MenuItemCommand(); const BBitmap *command = MenuPrivate::MenuItemCommand();
const BRect &rect = command->Bounds(); const BRect &rect = command->Bounds();
@@ -773,7 +765,7 @@ BMenuItem::_DrawShortcutSymbol()
void void
BMenuItem::_DrawSubmenuSymbol(rgb_color bgColor) BMenuItem::_DrawSubmenuSymbol()
{ {
fSuper->PushState(); fSuper->PushState();
@@ -802,7 +794,6 @@ BMenuItem::_DrawSubmenuSymbol(rgb_color bgColor)
arrowShape.LineTo(BPoint(center.x - hSize, center.y + size)); arrowShape.LineTo(BPoint(center.x - hSize, center.y + size));
fSuper->SetDrawingMode(B_OP_OVER); fSuper->SetDrawingMode(B_OP_OVER);
fSuper->SetHighColor(tint_color(bgColor, B_DARKEN_MAX_TINT));
fSuper->SetPenSize(ceilf(size * 0.4)); fSuper->SetPenSize(ceilf(size * 0.4));
// NOTE: StrokeShape() offsets the shape by the current pen position, // NOTE: StrokeShape() offsets the shape by the current pen position,
// it is not documented in the BeBook, but it is true! // it is not documented in the BeBook, but it is true!
+26 -21
View File
@@ -156,8 +156,8 @@ AttributeStreamNode::Contains(const char* name, uint32 type)
off_t off_t
AttributeStreamNode::Read(const char* name, const char* foreignName, uint32 type, AttributeStreamNode::Read(const char* name, const char* foreignName,
off_t size, void* buffer, void (*swapFunc)(void*)) uint32 type, off_t size, void* buffer, void (*swapFunc)(void*))
{ {
if (!fReadFrom) if (!fReadFrom)
return 0; return 0;
@@ -167,8 +167,8 @@ AttributeStreamNode::Read(const char* name, const char* foreignName, uint32 type
off_t off_t
AttributeStreamNode::Write(const char* name, const char* foreignName, uint32 type, AttributeStreamNode::Write(const char* name, const char* foreignName,
off_t size, const void* buffer) uint32 type, off_t size, const void* buffer)
{ {
if (!fWriteTo) if (!fWriteTo)
return 0; return 0;
@@ -288,14 +288,15 @@ AttributeStreamFileNode::Contains(const char* name, uint32 type)
off_t off_t
AttributeStreamFileNode::Read(const char* name, const char* foreignName, uint32 type, AttributeStreamFileNode::Read(const char* name, const char* foreignName,
off_t size, void* buffer, void (*swapFunc)(void*)) uint32 type, off_t size, void* buffer, void (*swapFunc)(void*))
{ {
if (name && fNode->ReadAttr(name, type, 0, buffer, (size_t)size) == size) if (name && fNode->ReadAttr(name, type, 0, buffer, (size_t)size) == size)
return size; return size;
// didn't find the attribute under the native name, try the foreign name // didn't find the attribute under the native name, try the foreign name
if (foreignName && fNode->ReadAttr(foreignName, type, 0, buffer, (size_t)size) == size) { if (foreignName && fNode->ReadAttr(foreignName, type, 0, buffer,
(size_t)size) == size) {
// foreign attribute, swap the data // foreign attribute, swap the data
if (swapFunc) if (swapFunc)
(swapFunc)(buffer); (swapFunc)(buffer);
@@ -306,8 +307,8 @@ AttributeStreamFileNode::Read(const char* name, const char* foreignName, uint32
off_t off_t
AttributeStreamFileNode::Write(const char* name, const char* foreignName, uint32 type, AttributeStreamFileNode::Write(const char* name, const char* foreignName,
off_t size, const void* buffer) uint32 type, off_t size, const void* buffer)
{ {
ASSERT(fNode); ASSERT(fNode);
ASSERT(dynamic_cast<BNode*>(fNode)); ASSERT(dynamic_cast<BNode*>(fNode));
@@ -353,8 +354,8 @@ bool
AttributeStreamFileNode::Fill(char* buffer) const AttributeStreamFileNode::Fill(char* buffer) const
{ {
ASSERT(fNode); ASSERT(fNode);
return fNode->ReadAttr(fCurrentAttr.Name(), fCurrentAttr.Type(), 0, buffer, return fNode->ReadAttr(fCurrentAttr.Name(), fCurrentAttr.Type(), 0,
(size_t)fCurrentAttr.Size()) == (ssize_t)fCurrentAttr.Size(); buffer, (size_t)fCurrentAttr.Size()) == (ssize_t)fCurrentAttr.Size();
} }
@@ -422,8 +423,9 @@ AttributeStreamMemoryNode::Contains(const char* name, uint32 type)
off_t off_t
AttributeStreamMemoryNode::Read(const char* name, const char* DEBUG_ONLY(foreignName), AttributeStreamMemoryNode::Read(const char* name,
uint32 type, off_t bufferSize, void* buffer, void (*DEBUG_ONLY(swapFunc))(void*)) const char* DEBUG_ONLY(foreignName), uint32 type, off_t bufferSize,
void* buffer, void (*DEBUG_ONLY(swapFunc))(void*))
{ {
ASSERT(!foreignName); ASSERT(!foreignName);
ASSERT(!swapFunc); ASSERT(!swapFunc);
@@ -479,7 +481,8 @@ AttributeStreamMemoryNode::Drive()
AttributeStreamMemoryNode::AttrNode* AttributeStreamMemoryNode::AttrNode*
AttributeStreamMemoryNode::BufferingGet(const char* name, uint32 type, off_t size) AttributeStreamMemoryNode::BufferingGet(const char* name, uint32 type,
off_t size)
{ {
char* newBuffer = new char[size]; char* newBuffer = new char[size];
if (!fReadFrom->Fill(newBuffer)) { if (!fReadFrom->Fill(newBuffer)) {
@@ -659,22 +662,24 @@ AttributeStreamFilterNode::Contains(const char* name, uint32 type)
off_t off_t
AttributeStreamFilterNode::Read(const char* name, const char* foreignName, uint32 type, AttributeStreamFilterNode::Read(const char* name, const char* foreignName,
off_t size, void* buffer, void (*swapFunc)(void*)) uint32 type, off_t size, void* buffer, void (*swapFunc)(void*))
{ {
if (!fReadFrom) if (!fReadFrom)
return 0; return 0;
if (!Reject(name, type, size)) if (!Reject(name, type, size)) {
return fReadFrom->Read(name, foreignName, type, size, buffer, swapFunc); return fReadFrom->Read(name, foreignName, type, size, buffer,
swapFunc);
}
return 0; return 0;
} }
off_t off_t
AttributeStreamFilterNode::Write(const char* name, const char* foreignName, uint32 type, AttributeStreamFilterNode::Write(const char* name, const char* foreignName,
off_t size, const void* buffer) uint32 type, off_t size, const void* buffer)
{ {
if (!fWriteTo) if (!fWriteTo)
return 0; return 0;
@@ -693,7 +698,7 @@ NamesToAcceptAttrFilter::NamesToAcceptAttrFilter(const char** nameList)
bool bool
NamesToAcceptAttrFilter::Reject(const char* name, uint32 , off_t ) NamesToAcceptAttrFilter::Reject(const char* name, uint32, off_t)
{ {
for (int32 index = 0; ;index++) { for (int32 index = 0; ;index++) {
if (!fNameList[index]) if (!fNameList[index])
+39 -35
View File
@@ -39,13 +39,13 @@ All rights reserved.
// //
// destinationNode << transformer << buffer << filter << sourceNode // destinationNode << transformer << buffer << filter << sourceNode
// //
// transformer may for instance perform endian-swapping or offsetting of a B_RECT attribute // transformer may for instance perform endian-swapping or offsetting of
// filter may withold certain attributes // a B_RECT attribute filter may withold certain attributes buffer is a
// buffer is a memory allocated snapshot of attributes, may be repeatedly streamed into // memory allocated snapshot of attributes, may be repeatedly streamed into
// other files, buffers // other files, buffers
// //
// In addition to the whacky (but usefull) << syntax, calls like Read, Write are also // In addition to the whacky (but usefull) << syntax, calls like Read, Write
// available // are also available
#ifndef __ATTRIBUTE_STREAM__ #ifndef __ATTRIBUTE_STREAM__
#define __ATTRIBUTE_STREAM__ #define __ATTRIBUTE_STREAM__
@@ -104,7 +104,8 @@ public:
// any data it has, gets, transforms, doesn't filter out // any data it has, gets, transforms, doesn't filter out
// //
// under the hood sets up streaming into the next node; hooking // under the hood sets up streaming into the next node; hooking
// up source and destination, forces the stream head to start streaming // up source and destination, forces the stream head to start
// streaming
virtual void Rewind(); virtual void Rewind();
// get ready to start all over again // get ready to start all over again
@@ -114,11 +115,11 @@ public:
virtual off_t Contains(const char*, uint32); virtual off_t Contains(const char*, uint32);
// returns size of attribute if found // returns size of attribute if found
virtual off_t Read(const char* name, const char* foreignName, uint32 type, off_t size, virtual off_t Read(const char* name, const char* foreignName,
void* buffer, void (*swapFunc)(void*) = 0); uint32 type, off_t size, void* buffer, void (*swapFunc)(void*) = 0);
// read from this node // read from this node
virtual off_t Write(const char* name, const char* foreignName, uint32 type, off_t size, virtual off_t Write(const char* name, const char* foreignName,
const void* buffer); uint32 type, off_t size, const void* buffer);
// write to this node // write to this node
// work calls // work calls
@@ -128,14 +129,13 @@ public:
virtual const AttributeInfo* Next(); virtual const AttributeInfo* Next();
// give me the next attribute in the stream // give me the next attribute in the stream
virtual const char* Get(); virtual const char* Get();
// give me the data of the attribute in the stream that was just returned // give me the data of the attribute in the stream that was just
// by Next // returned by Next assumes there is a buffering node somewhere on the
// assumes there is a buffering node somewhere on the way to // way to the source, from which the resulting buffer is borrowed
// the source, from which the resulting buffer is borrowed
virtual bool Fill(char* buffer) const; virtual bool Fill(char* buffer) const;
// fill the buffer with data of the attribute in the stream that was just returned // fill the buffer with data of the attribute in the stream that was
// by next // just returned by next <buffer> is big enough to hold the entire
// <buffer> is big enough to hold the entire attribute data // attribute data
virtual bool CanFeed() const { return false; } virtual bool CanFeed() const { return false; }
// return true if can work as a source for the entire stream // return true if can work as a source for the entire stream
@@ -199,10 +199,10 @@ public:
virtual void MakeEmpty(); virtual void MakeEmpty();
virtual off_t Contains(const char* name, uint32 type); virtual off_t Contains(const char* name, uint32 type);
virtual off_t Read(const char* name, const char* foreignName, uint32 type, off_t size, virtual off_t Read(const char* name, const char* foreignName,
void* buffer, void (*swapFunc)(void*) = 0); uint32 type, off_t size, void* buffer, void (*swapFunc)(void*) = 0);
virtual off_t Write(const char* name, const char* foreignName, uint32 type, off_t size, virtual off_t Write(const char* name, const char* foreignName,
const void* buffer); uint32 type, off_t size, const void* buffer);
protected: protected:
virtual bool CanFeed() const { return true; } virtual bool CanFeed() const { return true; }
@@ -275,10 +275,10 @@ public:
AttributeStreamFilterNode() AttributeStreamFilterNode()
{} {}
virtual off_t Contains(const char* name, uint32 type); virtual off_t Contains(const char* name, uint32 type);
virtual off_t Read(const char* name, const char* foreignName, uint32 type, off_t size, virtual off_t Read(const char* name, const char* foreignName,
void* buffer, void (*swapFunc)(void*) = 0); uint32 type, off_t size, void* buffer, void (*swapFunc)(void*) = 0);
virtual off_t Write(const char* name, const char* foreignName, uint32 type, off_t size, virtual off_t Write(const char* name, const char* foreignName,
const void* buffer); uint32 type, off_t size, const void* buffer);
protected: protected:
virtual bool Reject(const char* name, uint32 type, off_t size); virtual bool Reject(const char* name, uint32 type, off_t size);
@@ -307,22 +307,25 @@ private:
class SelectiveAttributeTransformer : public AttributeStreamNode { class SelectiveAttributeTransformer : public AttributeStreamNode {
// node applies a transformation on specified attributes // node applies a transformation on specified attributes
public: public:
SelectiveAttributeTransformer(const char* attributeName, bool (*)(const char*, SelectiveAttributeTransformer(const char* attributeName,
uint32 , off_t , void*, void*), void* params); bool (*)(const char*, uint32 , off_t , void*, void*), void* params);
virtual ~SelectiveAttributeTransformer(); virtual ~SelectiveAttributeTransformer();
virtual off_t Read(const char* name, const char* foreignName, uint32 type, off_t size, virtual off_t Read(const char* name, const char* foreignName, uint32 type,
void* buffer, void (*swapFunc)(void*) = 0); off_t size, void* buffer, void (*swapFunc)(void*) = 0);
virtual void Rewind(); virtual void Rewind();
protected: protected:
virtual bool WillTransform(const char* name, uint32 type, off_t size, const char* data) const; virtual bool WillTransform(const char* name, uint32 type, off_t size,
// override to implement filtering; should only return true if transformation will const char* data) const;
// occur // override to implement filtering, should only return true if
virtual char* CopyAndApplyTransformer(const char* name, uint32 type, off_t size, const char* data); // transformation will occur
virtual char* CopyAndApplyTransformer(const char* name, uint32 type,
off_t size, const char* data);
// makes a copy of data // makes a copy of data
virtual bool ApplyTransformer(const char* name, uint32 type, off_t size, char* data); virtual bool ApplyTransformer(const char* name, uint32 type, off_t size,
char* data);
// transforms in place // transforms in place
virtual const AttributeInfo* Next(); virtual const AttributeInfo* Next();
virtual const char* Get(); virtual const char* Get();
@@ -342,7 +345,8 @@ private:
template <class Type> template <class Type>
class AttributeStreamConstValue : public AttributeStreamNode { class AttributeStreamConstValue : public AttributeStreamNode {
public: public:
AttributeStreamConstValue(const char* name, uint32 attributeType, Type value); AttributeStreamConstValue(const char* name, uint32 attributeType,
Type value);
protected: protected:
virtual bool CanFeed() const { return true; } virtual bool CanFeed() const { return true; }
+2 -2
View File
@@ -119,7 +119,8 @@ AutomountSettingsPanel::AutomountSettingsPanel(BMessage* settings,
new BMessage(kAutomountSettingsChanged)); new BMessage(kAutomountSettingsChanged));
fAutoMountAllBFSCheck = new BRadioButton("autoBFS", fAutoMountAllBFSCheck = new BRadioButton("autoBFS",
B_TRANSLATE("All BeOS disks"), new BMessage(kAutomountSettingsChanged)); B_TRANSLATE("All BeOS disks"),
new BMessage(kAutomountSettingsChanged));
fAutoMountAllCheck = new BRadioButton("autoAll", fAutoMountAllCheck = new BRadioButton("autoAll",
B_TRANSLATE("All disks"), new BMessage(kAutomountSettingsChanged)); B_TRANSLATE("All disks"), new BMessage(kAutomountSettingsChanged));
@@ -343,4 +344,3 @@ AutomountSettingsDialog::RunAutomountSettings(const BMessenger& target)
(new AutomountSettingsDialog(&reply, target))->Show(); (new AutomountSettingsDialog(&reply, target))->Show();
} }
+15 -9
View File
@@ -31,10 +31,10 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders. names are registered trademarks or trademarks of their respective holders.
All rights reserved. All rights reserved.
*/ */
#ifndef _TRACKER_BACKGROUND_H #ifndef _TRACKER_BACKGROUND_H
#define _TRACKER_BACKGROUND_H #define _TRACKER_BACKGROUND_H
#include <SupportDefs.h> #include <SupportDefs.h>
/*----------------------------------------------------------------*/ /*----------------------------------------------------------------*/
@@ -45,12 +45,18 @@ All rights reserved.
/*----------------------------------------------------------------*/ /*----------------------------------------------------------------*/
/*----- Tracker background BMessage entries --------------------*/ /*----- Tracker background BMessage entries --------------------*/
#define B_BACKGROUND_IMAGE "be:bgndimginfopath" // string path #define B_BACKGROUND_IMAGE "be:bgndimginfopath"
#define B_BACKGROUND_MODE "be:bgndimginfomode" // int32, the enum below // string path
#define B_BACKGROUND_ORIGIN "be:bgndimginfooffset" // BPoint #define B_BACKGROUND_MODE "be:bgndimginfomode"
#define B_BACKGROUND_TEXT_OUTLINE "be:bgndimginfoerasetext" // bool // int32, the enum below
// NOTE: the actual attribute name is kept for backwards compatible settings #define B_BACKGROUND_ORIGIN "be:bgndimginfooffset"
#define B_BACKGROUND_WORKSPACES "be:bgndimginfoworkspaces" // uint32 // BPoint
#define B_BACKGROUND_TEXT_OUTLINE "be:bgndimginfoerasetext"
// bool
// NOTE: the actual attribute name is kept for backwards
// compatible settings
#define B_BACKGROUND_WORKSPACES "be:bgndimginfoworkspaces"
// uint32
/*----------------------------------------------------------------*/ /*----------------------------------------------------------------*/
/*----- Background mode values ---------------------------------*/ /*----- Background mode values ---------------------------------*/
@@ -65,7 +71,7 @@ enum {
/*----------------------------------------------------------------*/ /*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/ /*----------------------------------------------------------------*/
const int32 B_RESTORE_BACKGROUND_IMAGE = 'Tbgr'; // force a Tracker window to const int32 B_RESTORE_BACKGROUND_IMAGE = 'Tbgr';
// use a new background image // force a Tracker window to use a new background image
#endif // _TRACKER_BACKGROUND_H #endif // _TRACKER_BACKGROUND_H
+20 -11
View File
@@ -71,9 +71,10 @@ BackgroundImage::GetBackgroundImage(const BNode* node, bool isDesktop)
return NULL; return NULL;
BMessage container; BMessage container;
char* buffer = new char [info.size]; char* buffer = new char[info.size];
status_t error = node->ReadAttr(kBackgroundImageInfo, info.type, 0, buffer, (size_t)info.size); status_t error = node->ReadAttr(kBackgroundImageInfo, info.type, 0,
buffer, (size_t)info.size);
if (error == info.size) if (error == info.size)
error = container.Unflatten(buffer); error = container.Unflatten(buffer);
@@ -91,7 +92,8 @@ BackgroundImage::GetBackgroundImage(const BNode* node, bool isDesktop)
BPoint offset; BPoint offset;
BBitmap* bitmap = NULL; BBitmap* bitmap = NULL;
if (container.FindString(kBackgroundImageInfoPath, index, &path) == B_OK) { if (container.FindString(kBackgroundImageInfoPath, index, &path)
== B_OK) {
bitmap = BTranslationUtils::GetBitmap(path); bitmap = BTranslationUtils::GetBitmap(path);
if (!bitmap) { if (!bitmap) {
PRINT(("failed to load background bitmap from path\n")); PRINT(("failed to load background bitmap from path\n"));
@@ -104,14 +106,16 @@ BackgroundImage::GetBackgroundImage(const BNode* node, bool isDesktop)
be_control_look->SetBackgroundInfo(container); be_control_look->SetBackgroundInfo(container);
} }
container.FindInt32(kBackgroundImageInfoWorkspaces, index, (int32*)&workspaces); container.FindInt32(kBackgroundImageInfoWorkspaces, index,
(int32*)&workspaces);
container.FindInt32(kBackgroundImageInfoMode, index, (int32*)&mode); container.FindInt32(kBackgroundImageInfoMode, index, (int32*)&mode);
container.FindBool(kBackgroundImageInfoTextOutline, index, &textWidgetLabelOutline); container.FindBool(kBackgroundImageInfoTextOutline, index,
&textWidgetLabelOutline);
container.FindPoint(kBackgroundImageInfoOffset, index, &offset); container.FindPoint(kBackgroundImageInfoOffset, index, &offset);
BackgroundImage::BackgroundImageInfo* imageInfo = new BackgroundImage::BackgroundImageInfo* imageInfo = new
BackgroundImage::BackgroundImageInfo(workspaces, bitmap, mode, offset, BackgroundImage::BackgroundImageInfo(workspaces, bitmap, mode,
textWidgetLabelOutline); offset, textWidgetLabelOutline);
if (!result) if (!result)
result = new BackgroundImage(node, isDesktop); result = new BackgroundImage(node, isDesktop);
@@ -175,6 +179,7 @@ BackgroundImage::Show(BView* view, int32 workspace)
} }
} }
void void
BackgroundImage::Show(BackgroundImageInfo* info, BView* view) BackgroundImage::Show(BackgroundImageInfo* info, BView* view)
{ {
@@ -274,13 +279,15 @@ BackgroundImage::Remove()
fView->ClearViewBitmap(); fView->ClearViewBitmap();
fView->Invalidate(); fView->Invalidate();
BPoseView* poseView = dynamic_cast<BPoseView*>(fView); BPoseView* poseView = dynamic_cast<BPoseView*>(fView);
// make sure text widgets draw the default way, erasing their background // make sure text widgets draw the default way, erasing
// their background
if (poseView) if (poseView)
poseView->SetWidgetTextOutline(true); poseView->SetWidgetTextOutline(true);
} }
fShowingBitmap = NULL; fShowingBitmap = NULL;
} }
BackgroundImage::BackgroundImageInfo* BackgroundImage::BackgroundImageInfo*
BackgroundImage::ImageInfoForWorkspace(int32 workspace) const BackgroundImage::ImageInfoForWorkspace(int32 workspace) const
{ {
@@ -306,6 +313,7 @@ BackgroundImage::ImageInfoForWorkspace(int32 workspace) const
return result; return result;
} }
void void
BackgroundImage::WorkspaceActivated(BView* view, int32 workspace, bool state) BackgroundImage::WorkspaceActivated(BView* view, int32 workspace, bool state)
{ {
@@ -332,6 +340,7 @@ BackgroundImage::WorkspaceActivated(BView* view, int32 workspace, bool state)
} }
} }
void void
BackgroundImage::ScreenChanged(BRect, color_space) BackgroundImage::ScreenChanged(BRect, color_space)
{ {
@@ -346,12 +355,13 @@ BackgroundImage::ScreenChanged(BRect, color_space)
(viewBounds.Width() - bitmapBounds.Width()) / 2, (viewBounds.Width() - bitmapBounds.Width()) / 2,
(viewBounds.Height() - bitmapBounds.Height()) / 2); (viewBounds.Height() - bitmapBounds.Height()) / 2);
fView->SetViewBitmap(fShowingBitmap->fBitmap, bitmapBounds, destinationBitmapBounds, fView->SetViewBitmap(fShowingBitmap->fBitmap, bitmapBounds,
B_FOLLOW_NONE, 0); destinationBitmapBounds, B_FOLLOW_NONE, 0);
fView->Invalidate(); fView->Invalidate();
} }
} }
BackgroundImage* BackgroundImage*
BackgroundImage::Refresh(BackgroundImage* oldBackgroundImage, BackgroundImage::Refresh(BackgroundImage* oldBackgroundImage,
const BNode* fromNode, bool desktop, BPoseView* poseView) const BNode* fromNode, bool desktop, BPoseView* poseView)
@@ -367,4 +377,3 @@ BackgroundImage::Refresh(BackgroundImage* oldBackgroundImage,
return result; return result;
} }
+2 -2
View File
@@ -77,8 +77,8 @@ public:
class BackgroundImageInfo { class BackgroundImageInfo {
// element of the per-workspace list // element of the per-workspace list
public: public:
BackgroundImageInfo(uint32 workspace, BBitmap* bitmap, Mode mode, BPoint offset, BackgroundImageInfo(uint32 workspace, BBitmap* bitmap, Mode mode,
bool textWidgetOutline); BPoint offset, bool textWidgetOutline);
~BackgroundImageInfo(); ~BackgroundImageInfo();
uint32 fWorkspace; uint32 fWorkspace;
+17 -8
View File
@@ -104,7 +104,8 @@ BImageResources::FinishResources(BResources* res) const
const void* const void*
BImageResources::LoadResource(type_code type, int32 id, size_t* out_size) const BImageResources::LoadResource(type_code type, int32 id,
size_t* out_size) const
{ {
// Serialize execution. // Serialize execution.
// Looks like BResources is not really thread safe. We should // Looks like BResources is not really thread safe. We should
@@ -116,12 +117,14 @@ BImageResources::LoadResource(type_code type, int32 id, size_t* out_size) const
// Return the resource. Because we never change the BResources // Return the resource. Because we never change the BResources
// object, the returned data will not change until TTracker is // object, the returned data will not change until TTracker is
// destroyed. // destroyed.
return const_cast<BResources*>(&fResources)->LoadResource(type, id, out_size); return const_cast<BResources*>(&fResources)->LoadResource(type, id,
out_size);
} }
const void* const void*
BImageResources::LoadResource(type_code type, const char* name, size_t* out_size) const BImageResources::LoadResource(type_code type, const char* name,
size_t* out_size) const
{ {
// Serialize execution. // Serialize execution.
BAutolock lock(fLock); BAutolock lock(fLock);
@@ -131,12 +134,14 @@ BImageResources::LoadResource(type_code type, const char* name, size_t* out_size
// Return the resource. Because we never change the BResources // Return the resource. Because we never change the BResources
// object, the returned data will not change until TTracker is // object, the returned data will not change until TTracker is
// destroyed. // destroyed.
return const_cast<BResources*>(&fResources)->LoadResource(type, name, out_size); return const_cast<BResources*>(&fResources)->LoadResource(type, name,
out_size);
} }
status_t status_t
BImageResources::GetIconResource(int32 id, icon_size size, BBitmap* dest) const BImageResources::GetIconResource(int32 id, icon_size size,
BBitmap* dest) const
{ {
size_t length = 0; size_t length = 0;
const void* data; const void* data;
@@ -144,8 +149,10 @@ BImageResources::GetIconResource(int32 id, icon_size size, BBitmap* dest) const
#ifdef __HAIKU__ #ifdef __HAIKU__
// try to load vector icon // try to load vector icon
data = LoadResource(B_VECTOR_ICON_TYPE, id, &length); data = LoadResource(B_VECTOR_ICON_TYPE, id, &length);
if (data != NULL && BIconUtils::GetVectorIcon((uint8*)data, length, dest) == B_OK) if (data != NULL
&& BIconUtils::GetVectorIcon((uint8*)data, length, dest) == B_OK) {
return B_OK; return B_OK;
}
#endif #endif
// fall back to R5 icon // fall back to R5 icon
@@ -155,7 +162,8 @@ BImageResources::GetIconResource(int32 id, icon_size size, BBitmap* dest) const
length = 0; length = 0;
data = LoadResource(size == B_LARGE_ICON ? 'ICON' : 'MICN', id, &length); data = LoadResource(size == B_LARGE_ICON ? 'ICON' : 'MICN', id, &length);
if (data == NULL || length != (size_t)(size == B_LARGE_ICON ? 1024 : 256)) { if (data == NULL
|| length != (size_t)(size == B_LARGE_ICON ? 1024 : 256)) {
TRESPASS(); TRESPASS();
return B_ERROR; return B_ERROR;
} }
@@ -212,7 +220,8 @@ BImageResources::find_image(void* memAddr) const
status_t status_t
BImageResources::GetBitmapResource(type_code type, int32 id, BBitmap** out) const BImageResources::GetBitmapResource(type_code type, int32 id,
BBitmap** out) const
{ {
*out = NULL; *out = NULL;
+241 -130
View File
@@ -110,12 +110,14 @@ namespace BPrivate {
class DraggableContainerIcon : public BView { class DraggableContainerIcon : public BView {
public: public:
DraggableContainerIcon(BRect rect, const char* name, uint32 resizeMask); DraggableContainerIcon(BRect rect, const char* name,
uint32 resizeMask);
virtual void AttachedToWindow(); virtual void AttachedToWindow();
virtual void MouseDown(BPoint where); virtual void MouseDown(BPoint where);
virtual void MouseUp(BPoint where); virtual void MouseUp(BPoint where);
virtual void MouseMoved(BPoint point, uint32 /*transit*/, const BMessage* message); virtual void MouseMoved(BPoint point, uint32 /*transit*/,
const BMessage* message);
virtual void FrameMoved(BPoint newLocation); virtual void FrameMoved(BPoint newLocation);
virtual void Draw(BRect updateRect); virtual void Draw(BRect updateRect);
@@ -151,8 +153,8 @@ ActivateWindowFilter(BMessage*, BHandler** target, BMessageFilter*)
{ {
BView* view = dynamic_cast<BView*>(*target); BView* view = dynamic_cast<BView*>(*target);
// activate the window if no PoseView or DraggableContainerIcon had been pressed // activate the window if no PoseView or DraggableContainerIcon had been
// (those will activate the window themselves, if necessary) // pressed (those will activate the window themselves, if necessary)
if (view if (view
&& !dynamic_cast<BPoseView*>(view) && !dynamic_cast<BPoseView*>(view)
&& !dynamic_cast<DraggableContainerIcon*>(view) && !dynamic_cast<DraggableContainerIcon*>(view)
@@ -215,7 +217,8 @@ CompareLabels(const BMenuItem* item1, const BMenuItem* item2)
static bool static bool
AddOneAddon(const Model* model, const char* name, uint32 shortcut, bool primary, void* context) AddOneAddon(const Model* model, const char* name, uint32 shortcut,
bool primary, void* context)
{ {
AddOneAddonParams* params = (AddOneAddonParams*)context; AddOneAddonParams* params = (AddOneAddonParams*)context;
@@ -249,14 +252,16 @@ AddOnThread(BMessage* refsMessage, entry_ref addonRef, entry_ref dirRef)
image_id addonImage = load_add_on(path.Path()); image_id addonImage = load_add_on(path.Path());
if (addonImage >= 0) { if (addonImage >= 0) {
void (*processRefs)(entry_ref, BMessage*, void*); void (*processRefs)(entry_ref, BMessage*, void*);
result = get_image_symbol(addonImage, "process_refs", 2, (void**)&processRefs); result = get_image_symbol(addonImage, "process_refs", 2,
(void**)&processRefs);
#ifndef __INTEL__ #ifndef __INTEL__
if (result < 0) { if (result < 0) {
PRINT(("trying old legacy ppc signature\n")); PRINT(("trying old legacy ppc signature\n"));
// try old-style addon signature // try old-style addon signature
result = get_image_symbol(addonImage, result = get_image_symbol(addonImage,
"process_refs__F9entry_refP8BMessagePv", 2, (void**)&processRefs); "process_refs__F9entry_refP8BMessagePv", 2,
(void**)&processRefs);
} }
#endif #endif
@@ -279,8 +284,8 @@ AddOnThread(BMessage* refsMessage, entry_ref addonRef, entry_ref dirRef)
buffer.ReplaceFirst("%error", strerror(result)); buffer.ReplaceFirst("%error", strerror(result));
buffer.ReplaceFirst("%name", addonRef.name); buffer.ReplaceFirst("%name", addonRef.name);
BAlert* alert = new BAlert("", buffer.String(), B_TRANSLATE("Cancel"), 0, 0, BAlert* alert = new BAlert("", buffer.String(), B_TRANSLATE("Cancel"),
B_WIDTH_AS_USUAL, B_WARNING_ALERT); 0, 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
alert->SetShortcut(0, B_ESCAPE); alert->SetShortcut(0, B_ESCAPE);
alert->Go(); alert->Go();
@@ -372,7 +377,8 @@ DraggableContainerIcon::MouseDown(BPoint point)
if (IconCache::sIconCache->IconHitTest(point, window->TargetModel(), if (IconCache::sIconCache->IconHitTest(point, window->TargetModel(),
kNormalIcon, B_MINI_ICON)) { kNormalIcon, B_MINI_ICON)) {
// The click hit the icon, initiate a drag // The click hit the icon, initiate a drag
fDragButton = buttons & (B_PRIMARY_MOUSE_BUTTON | B_SECONDARY_MOUSE_BUTTON); fDragButton = buttons
& (B_PRIMARY_MOUSE_BUTTON | B_SECONDARY_MOUSE_BUTTON);
fDragStarted = false; fDragStarted = false;
fClickPoint = point; fClickPoint = point;
} else } else
@@ -413,10 +419,11 @@ DraggableContainerIcon::MouseMoved(BPoint point, uint32 /*transit*/,
font_height fontHeight; font_height fontHeight;
font.GetHeight(&fontHeight); font.GetHeight(&fontHeight);
float height = fontHeight.ascent + fontHeight.descent + fontHeight.leading + 2 float height = fontHeight.ascent + fontHeight.descent + fontHeight.leading
+ Bounds().Height() + 8; + 2 + Bounds().Height() + 8;
BRect rect(0, 0, max_c(Bounds().Width(), font.StringWidth(model->Name()) + 4), height); BRect rect(0, 0, max_c(Bounds().Width(),
font.StringWidth(model->Name()) + 4), height);
BBitmap* dragBitmap = new BBitmap(rect, B_RGBA32, true); BBitmap* dragBitmap = new BBitmap(rect, B_RGBA32, true);
dragBitmap->Lock(); dragBitmap->Lock();
@@ -432,7 +439,8 @@ DraggableContainerIcon::MouseMoved(BPoint point, uint32 /*transit*/,
view->SetHighColor(0, 0, 0, 0); view->SetHighColor(0, 0, 0, 0);
view->FillRect(view->Bounds()); view->FillRect(view->Bounds());
view->SetDrawingMode(B_OP_ALPHA); view->SetDrawingMode(B_OP_ALPHA);
view->SetHighColor(0, 0, 0, 128); // set the level of transparency by value view->SetHighColor(0, 0, 0, 128);
// set the level of transparency by value
view->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE); view->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE);
// Draw the icon // Draw the icon
@@ -446,8 +454,10 @@ DraggableContainerIcon::MouseMoved(BPoint point, uint32 /*transit*/,
view->TruncateString(&nameString, B_TRUNCATE_END, rect.Width() - 5); view->TruncateString(&nameString, B_TRUNCATE_END, rect.Width() - 5);
// Draw the label // Draw the label
float leftText = (view->StringWidth(nameString.String()) - Bounds().Width()) / 2; float leftText = (view->StringWidth(nameString.String())
view->MovePenTo(BPoint(hIconOffset - leftText + 2, Bounds().Height() + (fontHeight.ascent + 2))); - Bounds().Width()) / 2;
view->MovePenTo(BPoint(hIconOffset - leftText + 2, Bounds().Height()
+ (fontHeight.ascent + 2)));
view->DrawString(nameString.String()); view->DrawString(nameString.String());
view->Sync(); view->Sync();
@@ -465,8 +475,8 @@ DraggableContainerIcon::MouseMoved(BPoint point, uint32 /*transit*/,
if (button & B_PRIMARY_MOUSE_BUTTON) { if (button & B_PRIMARY_MOUSE_BUTTON) {
// add an action specifier to the message, so that it is not copied // add an action specifier to the message, so that it is not copied
message.AddInt32("be:actions", message.AddInt32("be:actions", (modifiers() & B_OPTION_KEY) != 0
(modifiers() & B_OPTION_KEY) != 0 ? B_COPY_TARGET : B_MOVE_TARGET); ? B_COPY_TARGET : B_MOVE_TARGET);
} }
fDragStarted = true; fDragStarted = true;
@@ -782,14 +792,16 @@ BContainerWindow::CreatePoseView(Model* model)
&& !fPoseView->IsFilePanel()) { && !fPoseView->IsFilePanel()) {
BRect rect(Bounds()); BRect rect(Bounds());
rect.top = 0; rect.top = 0;
// The KeyMenuBar isn't attached yet, otherwise we'd use that to get the offset. // The KeyMenuBar isn't attached yet, otherwise we'd use that
// to get the offset.
rect.bottom = BNavigator::CalcNavigatorHeight(); rect.bottom = BNavigator::CalcNavigatorHeight();
fNavigator = new BNavigator(model, rect); fNavigator = new BNavigator(model, rect);
if (!settings.ShowNavigator()) if (!settings.ShowNavigator())
fNavigator->Hide(); fNavigator->Hide();
AddChild(fNavigator); AddChild(fNavigator);
} }
SetPathWatchingEnabled(settings.ShowNavigator() || settings.ShowFullPathInTitleBar()); SetPathWatchingEnabled(settings.ShowNavigator()
|| settings.ShowFullPathInTitleBar());
} }
@@ -886,8 +898,8 @@ BContainerWindow::RepopulateMenus()
int32 selectCount = PoseView()->SelectionList()->CountItems(); int32 selectCount = PoseView()->SelectionList()->CountItems();
SetupOpenWithMenu(fFileMenu); SetupOpenWithMenu(fFileMenu);
SetupMoveCopyMenus(selectCount SetupMoveCopyMenus(selectCount ? PoseView()->SelectionList()->
? PoseView()->SelectionList()->FirstItem()->TargetModel()->EntryRef() : NULL, FirstItem()->TargetModel()->EntryRef() : NULL,
fFileMenu); fFileMenu);
} }
@@ -920,7 +932,8 @@ BContainerWindow::Init(const BMessage* message)
if (ShouldAddMenus()) { if (ShouldAddMenus()) {
// add menu bar, menus and resize poseview to fit // add menu bar, menus and resize poseview to fit
fMenuBar = new BMenuBar(BRect(0, 0, Bounds().Width() + 1, 1), "MenuBar"); fMenuBar = new BMenuBar(BRect(0, 0, Bounds().Width() + 1, 1),
"MenuBar");
fMenuBar->SetBorder(B_BORDER_FRAME); fMenuBar->SetBorder(B_BORDER_FRAME);
AddMenus(); AddMenus();
AddChild(fMenuBar); AddChild(fMenuBar);
@@ -937,8 +950,10 @@ BContainerWindow::Init(const BMessage* message)
fPoseView->MoveTo(BPoint(0, navigatorDelta + y_delta)); fPoseView->MoveTo(BPoint(0, navigatorDelta + y_delta));
fPoseView->ResizeBy(0, -(y_delta)); fPoseView->ResizeBy(0, -(y_delta));
if (fPoseView->VScrollBar()) { if (fPoseView->VScrollBar()) {
fPoseView->VScrollBar()->MoveBy(0, KeyMenuBar()->Bounds().Height()); fPoseView->VScrollBar()->MoveBy(0,
fPoseView->VScrollBar()->ResizeBy(0, -(KeyMenuBar()->Bounds().Height())); KeyMenuBar()->Bounds().Height());
fPoseView->VScrollBar()->ResizeBy(0,
-(KeyMenuBar()->Bounds().Height()));
} }
// add folder icon to menu bar // add folder icon to menu bar
@@ -946,23 +961,27 @@ BContainerWindow::Init(const BMessage* message)
float iconSize = fMenuBar->Bounds().Height() - 2; float iconSize = fMenuBar->Bounds().Height() - 2;
if (iconSize < 16) if (iconSize < 16)
iconSize = 16; iconSize = 16;
float iconPosY = 1 + (fMenuBar->Bounds().Height() - 2 - iconSize) / 2; float iconPosY = 1 + (fMenuBar->Bounds().Height() - 2
BView* icon = new DraggableContainerIcon(BRect(Bounds().Width() - 4 - iconSize + 1, - iconSize) / 2;
iconPosY, Bounds().Width() - 4, iconPosY + iconSize - 1), BView* icon = new DraggableContainerIcon(BRect(Bounds().Width()
"ThisContainer", B_FOLLOW_RIGHT); - 4 - iconSize + 1, iconPosY, Bounds().Width() - 4,
iconPosY + iconSize - 1), "ThisContainer",
B_FOLLOW_RIGHT);
fMenuBar->AddChild(icon); fMenuBar->AddChild(icon);
} }
} else { } else {
// add equivalents of the menu shortcuts to the menuless desktop window // add equivalents of the menu shortcuts to the menuless
// desktop window
AddShortcuts(); AddShortcuts();
} }
AddContextMenus(); AddContextMenus();
AddShortcut('T', B_COMMAND_KEY | B_SHIFT_KEY, new BMessage(kDelete), PoseView()); AddShortcut('T', B_COMMAND_KEY | B_SHIFT_KEY, new BMessage(kDelete),
PoseView());
AddShortcut('K', B_COMMAND_KEY | B_SHIFT_KEY, new BMessage(kCleanupAll), AddShortcut('K', B_COMMAND_KEY | B_SHIFT_KEY, new BMessage(kCleanupAll),
PoseView()); PoseView());
AddShortcut('Q', B_COMMAND_KEY | B_OPTION_KEY | B_SHIFT_KEY | B_CONTROL_KEY, AddShortcut('Q', B_COMMAND_KEY | B_OPTION_KEY | B_SHIFT_KEY
new BMessage(kQuitTracker)); | B_CONTROL_KEY, new BMessage(kQuitTracker));
AddShortcut(B_DOWN_ARROW, B_COMMAND_KEY, new BMessage(kOpenSelection), AddShortcut(B_DOWN_ARROW, B_COMMAND_KEY, new BMessage(kOpenSelection),
PoseView()); PoseView());
@@ -971,9 +990,12 @@ BContainerWindow::Init(const BMessage* message)
#if DEBUG #if DEBUG
// add some debugging shortcuts // add some debugging shortcuts
AddShortcut('D', B_COMMAND_KEY | B_CONTROL_KEY, new BMessage('dbug'), PoseView()); AddShortcut('D', B_COMMAND_KEY | B_CONTROL_KEY, new BMessage('dbug'),
AddShortcut('C', B_COMMAND_KEY | B_CONTROL_KEY, new BMessage('dpcc'), PoseView()); PoseView());
AddShortcut('F', B_COMMAND_KEY | B_CONTROL_KEY, new BMessage('dpfl'), PoseView()); AddShortcut('C', B_COMMAND_KEY | B_CONTROL_KEY, new BMessage('dpcc'),
PoseView());
AddShortcut('F', B_COMMAND_KEY | B_CONTROL_KEY, new BMessage('dpfl'),
PoseView());
AddShortcut('F', B_COMMAND_KEY | B_CONTROL_KEY | B_OPTION_KEY, AddShortcut('F', B_COMMAND_KEY | B_CONTROL_KEY | B_OPTION_KEY,
new BMessage('dpfL'), PoseView()); new BMessage('dpfL'), PoseView());
#endif #endif
@@ -1007,7 +1029,8 @@ BContainerWindow::Init(const BMessage* message)
void void
BContainerWindow::RestoreState() BContainerWindow::RestoreState()
{ {
SetSizeLimits(kContainerWidthMinLimit, 10000, kContainerWindowHeightLimit, 10000); SetSizeLimits(kContainerWidthMinLimit, 10000,
kContainerWindowHeightLimit, 10000);
UpdateTitle(); UpdateTitle();
@@ -1022,7 +1045,8 @@ BContainerWindow::RestoreState()
void void
BContainerWindow::RestoreState(const BMessage &message) BContainerWindow::RestoreState(const BMessage &message)
{ {
SetSizeLimits(kContainerWidthMinLimit, 10000, kContainerWindowHeightLimit, 10000); SetSizeLimits(kContainerWidthMinLimit, 10000,
kContainerWindowHeightLimit, 10000);
UpdateTitle(); UpdateTitle();
@@ -1057,7 +1081,8 @@ BContainerWindow::RestoreStateCommon()
if (!fBackgroundImage && !isDesktop if (!fBackgroundImage && !isDesktop
&& DefaultStateSourceNode(kDefaultFolderTemplate, &defaultingNode)) && DefaultStateSourceNode(kDefaultFolderTemplate, &defaultingNode))
// look for background image info in the source for defaults // look for background image info in the source for defaults
fBackgroundImage = BackgroundImage::GetBackgroundImage(&defaultingNode, isDesktop); fBackgroundImage
= BackgroundImage::GetBackgroundImage(&defaultingNode, isDesktop);
} }
@@ -1075,7 +1100,8 @@ BContainerWindow::UpdateTitle()
SetTitle(TargetModel()->Name()); SetTitle(TargetModel()->Name());
if (Navigator()) if (Navigator())
Navigator()->UpdateLocation(PoseView()->TargetModel(), kActionUpdatePath); Navigator()->UpdateLocation(PoseView()->TargetModel(),
kActionUpdatePath);
} }
@@ -1121,7 +1147,8 @@ BContainerWindow::FrameResized(float, float)
if (offsetY < 0 && PoseView()->Bounds().bottom > extent.bottom if (offsetY < 0 && PoseView()->Bounds().bottom > extent.bottom
&& Bounds().Height() > fPreviousBounds.Height()) && Bounds().Height() > fPreviousBounds.Height())
scroll.y scroll.y
= max_c(fPreviousBounds.Height() - Bounds().Height(), offsetY); = max_c(fPreviousBounds.Height() - Bounds().Height(),
offsetY);
if (scroll != B_ORIGIN) if (scroll != B_ORIGIN)
PoseView()->ScrollBy(scroll.x, scroll.y); PoseView()->ScrollBy(scroll.x, scroll.y);
@@ -1154,7 +1181,8 @@ BContainerWindow::ViewModeChanged(uint32 oldMode, uint32 newMode)
{ {
BView* view = FindView("MenuBar"); BView* view = FindView("MenuBar");
if (view != NULL) { if (view != NULL) {
// make sure the draggable icon hides if it doesn't have space left anymore // make sure the draggable icon hides if it doesn't
// have space left anymore
view = view->FindView("ThisContainer"); view = view->FindView("ThisContainer");
if (view != NULL) if (view != NULL)
view->FrameMoved(view->Frame().LeftTop()); view->FrameMoved(view->Frame().LeftTop());
@@ -1248,8 +1276,10 @@ BContainerWindow::GetLayoutState(BNode* node, BMessage* message)
continue; continue;
char* buffer = new char[info.size]; char* buffer = new char[info.size];
if (node->ReadAttr(attrName, info.type, 0, buffer, (size_t)info.size) == info.size) if (node->ReadAttr(attrName, info.type, 0, buffer,
(size_t)info.size) == info.size) {
message->AddData(attrName, info.type, buffer, (ssize_t)info.size); message->AddData(attrName, info.type, buffer, (ssize_t)info.size);
}
delete [] buffer; delete [] buffer;
} }
return B_OK; return B_OK;
@@ -1285,7 +1315,8 @@ BContainerWindow::SetLayoutState(BNode* node, const BMessage* message)
return result; return result;
} }
if (node->WriteAttr(name, type, 0, buffer, (size_t)size) != size) { if (node->WriteAttr(name, type, 0, buffer,
(size_t)size) != size) {
PRINT(("error writing %s \n", name)); PRINT(("error writing %s \n", name));
return result; return result;
} }
@@ -1350,7 +1381,8 @@ BContainerWindow::ResizeToFit()
BRect screenFrame(screen.Frame()); BRect screenFrame(screen.Frame());
screenFrame.InsetBy(5, 5); screenFrame.InsetBy(5, 5);
screenFrame.top += 15; // keeps title bar of window visible screenFrame.top += 15;
// keeps title bar of window visible
BRect frame(Frame()); BRect frame(Frame());
@@ -1471,12 +1503,13 @@ BContainerWindow::MessageReceived(BMessage* message)
break; break;
PoseView()->MoveSelectionInto(&model, this, false, false, PoseView()->MoveSelectionInto(&model, this, false, false,
message->what == kCreateLink, message->what == kCreateRelativeLink); message->what == kCreateLink,
} else { message->what == kCreateRelativeLink);
} else if (!TargetModel()->IsQuery()) {
// no destination specified, create link in same dir as item // no destination specified, create link in same dir as item
if (!TargetModel()->IsQuery())
PoseView()->MoveSelectionInto(TargetModel(), this, false, false, PoseView()->MoveSelectionInto(TargetModel(), this, false, false,
message->what == kCreateLink, message->what == kCreateRelativeLink); message->what == kCreateLink,
message->what == kCreateRelativeLink);
} }
break; break;
} }
@@ -1535,13 +1568,17 @@ BContainerWindow::MessageReceived(BMessage* message)
// 'action' at all if he can't find it?? // 'action' at all if he can't find it??
action = kActionSet; action = kActionSet;
Navigator()->UpdateLocation(PoseView()->TargetModel(), action); Navigator()->UpdateLocation(PoseView()->TargetModel(),
action);
} }
TrackerSettings settings; TrackerSettings settings;
if (settings.ShowNavigator() || settings.ShowFullPathInTitleBar()) if (settings.ShowNavigator()
|| settings.ShowFullPathInTitleBar()) {
SetPathWatchingEnabled(true); SetPathWatchingEnabled(true);
SetSingleWindowBrowseShortcuts(settings.SingleWindowBrowse()); }
SetSingleWindowBrowseShortcuts(
settings.SingleWindowBrowse());
// Update draggable folder icon // Update draggable folder icon
BView* view = FindView("MenuBar"); BView* view = FindView("MenuBar");
@@ -1562,26 +1599,23 @@ BContainerWindow::MessageReceived(BMessage* message)
case B_REFS_RECEIVED: case B_REFS_RECEIVED:
if (Dragging()) { if (Dragging()) {
//
// ref in this message is the target, // ref in this message is the target,
// the end point of the drag // the end point of the drag
//
entry_ref ref; entry_ref ref;
if (message->FindRef("refs", &ref) == B_OK) { if (message->FindRef("refs", &ref) == B_OK) {
//printf("BContainerWindow::MessageReceived - refs received\n");
fWaitingForRefs = false; fWaitingForRefs = false;
BEntry entry(&ref, true); BEntry entry(&ref, true);
//
// don't copy to printers dir // don't copy to printers dir
if (!FSIsPrintersDir(&entry)) { if (!FSIsPrintersDir(&entry)) {
if (entry.InitCheck() == B_OK && entry.IsDirectory()) { if (entry.InitCheck() == B_OK
&& entry.IsDirectory()) {
Model targetModel(&entry, true, false); Model targetModel(&entry, true, false);
BPoint dropPoint; BPoint dropPoint;
uint32 buttons; uint32 buttons;
PoseView()->GetMouse(&dropPoint, &buttons, true); PoseView()->GetMouse(&dropPoint, &buttons, true);
PoseView()->HandleDropCommon(fDragMessage, &targetModel, NULL, PoseView()->HandleDropCommon(fDragMessage,
PoseView(), dropPoint); &targetModel, NULL, PoseView(), dropPoint);
} }
} }
} }
@@ -1592,15 +1626,21 @@ BContainerWindow::MessageReceived(BMessage* message)
case B_OBSERVER_NOTICE_CHANGE: case B_OBSERVER_NOTICE_CHANGE:
{ {
int32 observerWhat; int32 observerWhat;
if (message->FindInt32("be:observe_change_what", &observerWhat) == B_OK) { if (message->FindInt32("be:observe_change_what", &observerWhat)
== B_OK) {
TrackerSettings settings; TrackerSettings settings;
switch (observerWhat) { switch (observerWhat) {
case kWindowsShowFullPathChanged: case kWindowsShowFullPathChanged:
UpdateTitle(); UpdateTitle();
if (!IsPathWatchingEnabled() && settings.ShowFullPathInTitleBar()) if (!IsPathWatchingEnabled()
&& settings.ShowFullPathInTitleBar()) {
SetPathWatchingEnabled(true); SetPathWatchingEnabled(true);
if (IsPathWatchingEnabled() && !(settings.ShowNavigator() || settings.ShowFullPathInTitleBar())) }
if (IsPathWatchingEnabled()
&& !(settings.ShowNavigator()
|| settings.ShowFullPathInTitleBar())) {
SetPathWatchingEnabled(false); SetPathWatchingEnabled(false);
}
break; break;
case kSingleWindowBrowseChanged: case kSingleWindowBrowseChanged:
@@ -1611,35 +1651,47 @@ BContainerWindow::MessageReceived(BMessage* message)
&& !PoseView()->IsDesktopWindow()) { && !PoseView()->IsDesktopWindow()) {
BRect rect(Bounds()); BRect rect(Bounds());
rect.top = KeyMenuBar()->Bounds().Height() + 1; rect.top = KeyMenuBar()->Bounds().Height() + 1;
rect.bottom = rect.top + BNavigator::CalcNavigatorHeight(); rect.bottom = rect.top
+ BNavigator::CalcNavigatorHeight();
fNavigator = new BNavigator(TargetModel(), rect); fNavigator = new BNavigator(TargetModel(), rect);
fNavigator->Hide(); fNavigator->Hide();
AddChild(fNavigator); AddChild(fNavigator);
SetPathWatchingEnabled(settings.ShowNavigator() || settings.ShowFullPathInTitleBar()); SetPathWatchingEnabled(settings.ShowNavigator()
|| settings.ShowFullPathInTitleBar());
} }
SetSingleWindowBrowseShortcuts(settings.SingleWindowBrowse()); SetSingleWindowBrowseShortcuts(
settings.SingleWindowBrowse());
break; break;
case kShowNavigatorChanged: case kShowNavigatorChanged:
ShowNavigator(settings.ShowNavigator()); ShowNavigator(settings.ShowNavigator());
if (!IsPathWatchingEnabled() && settings.ShowNavigator()) if (!IsPathWatchingEnabled()
&& settings.ShowNavigator()) {
SetPathWatchingEnabled(true); SetPathWatchingEnabled(true);
if (IsPathWatchingEnabled() && !(settings.ShowNavigator() || settings.ShowFullPathInTitleBar())) }
if (IsPathWatchingEnabled()
&& !(settings.ShowNavigator()
|| settings.ShowFullPathInTitleBar())) {
SetPathWatchingEnabled(false); SetPathWatchingEnabled(false);
SetSingleWindowBrowseShortcuts(settings.SingleWindowBrowse()); }
SetSingleWindowBrowseShortcuts(
settings.SingleWindowBrowse());
break; break;
case kDontMoveFilesToTrashChanged: case kDontMoveFilesToTrashChanged:
{ {
bool dontMoveToTrash = settings.DontMoveFilesToTrash(); bool dontMoveToTrash
= settings.DontMoveFilesToTrash();
BMenuItem* item = fFileContextMenu->FindItem(kMoveToTrash); BMenuItem* item
if (item) { = fFileContextMenu->FindItem(kMoveToTrash);
if (item != NULL) {
item->SetLabel(dontMoveToTrash item->SetLabel(dontMoveToTrash
? B_TRANSLATE("Delete") ? B_TRANSLATE("Delete")
: B_TRANSLATE("Move to Trash")); : B_TRANSLATE("Move to Trash"));
} }
// Deskbar doesn't have a menu bar, so check if there is fMenuBar // Deskbar doesn't have a menu bar, so check if
// there is fMenuBar
if (fMenuBar && fFileMenu) { if (fMenuBar && fFileMenu) {
item = fFileMenu->FindItem(kMoveToTrash); item = fFileMenu->FindItem(kMoveToTrash);
if (item) { if (item) {
@@ -1945,6 +1997,20 @@ BContainerWindow::AddWindowMenu(BMenu* menu)
item->SetTarget(PoseView()); item->SetTarget(PoseView());
iconSizeMenu->AddItem(item); iconSizeMenu->AddItem(item);
message = new BMessage(kIconMode);
message->AddInt32("size", 96);
item = new BMenuItem(B_TRANSLATE("96 x 96"), message);
item->SetMarked(PoseView()->IconSizeInt() == 96);
item->SetTarget(PoseView());
iconSizeMenu->AddItem(item);
message = new BMessage(kIconMode);
message->AddInt32("size", 128);
item = new BMenuItem(B_TRANSLATE("128 x 128"), message);
item->SetMarked(PoseView()->IconSizeInt() == 128);
item->SetTarget(PoseView());
iconSizeMenu->AddItem(item);
iconSizeMenu->AddSeparatorItem(); iconSizeMenu->AddSeparatorItem();
message = new BMessage(kIconMode); message = new BMessage(kIconMode);
@@ -1990,8 +2056,8 @@ BContainerWindow::AddWindowMenu(BMenu* menu)
item->SetTarget(PoseView()); item->SetTarget(PoseView());
menu->AddItem(item); menu->AddItem(item);
item = new BMenuItem(B_TRANSLATE("Select all"), new BMessage(B_SELECT_ALL), item = new BMenuItem(B_TRANSLATE("Select all"),
'A'); new BMessage(B_SELECT_ALL), 'A');
item->SetTarget(PoseView()); item->SetTarget(PoseView());
menu->AddItem(item); menu->AddItem(item);
@@ -2007,8 +2073,8 @@ BContainerWindow::AddWindowMenu(BMenu* menu)
menu->AddItem(item); menu->AddItem(item);
} }
item = new BMenuItem(B_TRANSLATE("Close"), new BMessage(B_QUIT_REQUESTED), item = new BMenuItem(B_TRANSLATE("Close"),
'W'); new BMessage(B_QUIT_REQUESTED), 'W');
item->SetTarget(this); item->SetTarget(this);
menu->AddItem(item); menu->AddItem(item);
@@ -2034,26 +2100,42 @@ BContainerWindow::AddShortcuts()
ASSERT(!PoseView()->IsFilePanel()); ASSERT(!PoseView()->IsFilePanel());
ASSERT(!TargetModel()->IsQuery()); ASSERT(!TargetModel()->IsQuery());
AddShortcut('X', B_COMMAND_KEY | B_SHIFT_KEY, new BMessage(kCutMoreSelectionToClipboard), this); AddShortcut('X', B_COMMAND_KEY | B_SHIFT_KEY,
AddShortcut('C', B_COMMAND_KEY | B_SHIFT_KEY, new BMessage(kCopyMoreSelectionToClipboard), this); new BMessage(kCutMoreSelectionToClipboard), this);
AddShortcut('F', B_COMMAND_KEY, new BMessage(kFindButton), PoseView()); AddShortcut('C', B_COMMAND_KEY | B_SHIFT_KEY,
AddShortcut('N', B_COMMAND_KEY, new BMessage(kNewFolder), PoseView()); new BMessage(kCopyMoreSelectionToClipboard), this);
AddShortcut('O', B_COMMAND_KEY, new BMessage(kOpenSelection), PoseView()); AddShortcut('F', B_COMMAND_KEY,
AddShortcut('I', B_COMMAND_KEY, new BMessage(kGetInfo), PoseView()); new BMessage(kFindButton), PoseView());
AddShortcut('E', B_COMMAND_KEY, new BMessage(kEditItem), PoseView()); AddShortcut('N', B_COMMAND_KEY,
AddShortcut('D', B_COMMAND_KEY, new BMessage(kDuplicateSelection), PoseView()); new BMessage(kNewFolder), PoseView());
AddShortcut('T', B_COMMAND_KEY, new BMessage(kMoveToTrash), PoseView()); AddShortcut('O', B_COMMAND_KEY,
AddShortcut('K', B_COMMAND_KEY, new BMessage(kCleanup), PoseView()); new BMessage(kOpenSelection), PoseView());
AddShortcut('A', B_COMMAND_KEY, new BMessage(B_SELECT_ALL), PoseView()); AddShortcut('I', B_COMMAND_KEY,
AddShortcut('S', B_COMMAND_KEY, new BMessage(kInvertSelection), PoseView()); new BMessage(kGetInfo), PoseView());
AddShortcut('A', B_COMMAND_KEY | B_SHIFT_KEY, new BMessage(kShowSelectionWindow), PoseView()); AddShortcut('E', B_COMMAND_KEY,
AddShortcut('G', B_COMMAND_KEY, new BMessage(kEditQuery), PoseView()); new BMessage(kEditItem), PoseView());
AddShortcut('D', B_COMMAND_KEY,
new BMessage(kDuplicateSelection), PoseView());
AddShortcut('T', B_COMMAND_KEY,
new BMessage(kMoveToTrash), PoseView());
AddShortcut('K', B_COMMAND_KEY,
new BMessage(kCleanup), PoseView());
AddShortcut('A', B_COMMAND_KEY,
new BMessage(B_SELECT_ALL), PoseView());
AddShortcut('S', B_COMMAND_KEY,
new BMessage(kInvertSelection), PoseView());
AddShortcut('A', B_COMMAND_KEY | B_SHIFT_KEY,
new BMessage(kShowSelectionWindow), PoseView());
AddShortcut('G', B_COMMAND_KEY,
new BMessage(kEditQuery), PoseView());
// it is ok to add a global Edit query shortcut here, PoseView will // it is ok to add a global Edit query shortcut here, PoseView will
// filter out cases where selected pose is not a query // filter out cases where selected pose is not a query
AddShortcut('U', B_COMMAND_KEY, new BMessage(kUnmountVolume), PoseView()); AddShortcut('U', B_COMMAND_KEY,
AddShortcut(B_UP_ARROW, B_COMMAND_KEY, new BMessage(kOpenParentDir), PoseView()); new BMessage(kUnmountVolume), PoseView());
AddShortcut('O', B_COMMAND_KEY | B_CONTROL_KEY, new BMessage(kOpenSelectionWith), AddShortcut(B_UP_ARROW, B_COMMAND_KEY,
PoseView()); new BMessage(kOpenParentDir), PoseView());
AddShortcut('O', B_COMMAND_KEY | B_CONTROL_KEY,
new BMessage(kOpenSelectionWith), PoseView());
} }
@@ -2073,7 +2155,8 @@ BContainerWindow::MenusBeginning()
SetupOpenWithMenu(fFileMenu); SetupOpenWithMenu(fFileMenu);
SetupMoveCopyMenus(selectCount SetupMoveCopyMenus(selectCount
? PoseView()->SelectionList()->FirstItem()->TargetModel()->EntryRef() : NULL, fFileMenu); ? PoseView()->SelectionList()->FirstItem()->TargetModel()->EntryRef()
: NULL, fFileMenu);
UpdateMenu(fMenuBar, kMenuBarContext); UpdateMenu(fMenuBar, kMenuBarContext);
@@ -2445,11 +2528,13 @@ BContainerWindow::SetupMoveCopyMenus(const entry_ref* item_ref, BMenu* parent)
// add all mounted volumes (except the one this item lives on) // add all mounted volumes (except the one this item lives on)
if (modifierKeys & B_SHIFT_KEY) { if (modifierKeys & B_SHIFT_KEY) {
fCreateLinkItem->SetMessage(new BMessage(kCreateRelativeLink)); fCreateLinkItem->SetMessage(new BMessage(kCreateRelativeLink));
PopulateMoveCopyNavMenu(dynamic_cast<BNavMenu*>(fCreateLinkItem->Submenu()), PopulateMoveCopyNavMenu(dynamic_cast<BNavMenu*>
(fCreateLinkItem->Submenu()),
kCreateRelativeLink, item_ref, false); kCreateRelativeLink, item_ref, false);
} else { } else {
fCreateLinkItem->SetMessage(new BMessage(kCreateLink)); fCreateLinkItem->SetMessage(new BMessage(kCreateLink));
PopulateMoveCopyNavMenu(dynamic_cast<BNavMenu*>(fCreateLinkItem->Submenu()), PopulateMoveCopyNavMenu(dynamic_cast<BNavMenu*>
(fCreateLinkItem->Submenu()),
kCreateLink, item_ref, false); kCreateLink, item_ref, false);
} }
@@ -2547,7 +2632,8 @@ BContainerWindow::ShowContextMenu(BPoint loc, const entry_ref* ref, BView*)
// see the notes in SlowContextPopup::AttachedToWindow // see the notes in SlowContextPopup::AttachedToWindow
if (!FSIsPrintersDir(&entry) && !fDragContextMenu->IsShowing()) { if (!FSIsPrintersDir(&entry) && !fDragContextMenu->IsShowing()) {
// printf("ShowContextMenu - target is %s %i\n", ref->name, IsShowing(ref)); //printf("ShowContextMenu - target is %s %i\n",
// ref->name, IsShowing(ref));
fDragContextMenu->ClearMenu(); fDragContextMenu->ClearMenu();
// in case the ref is a symlink, resolve it // in case the ref is a symlink, resolve it
@@ -2567,7 +2653,8 @@ BContainerWindow::ShowContextMenu(BPoint loc, const entry_ref* ref, BView*)
if (poseView) { if (poseView) {
BMessenger target(poseView); BMessenger target(poseView);
fDragContextMenu->InitTrackingHook( fDragContextMenu->InitTrackingHook(
&BPoseView::MenuTrackingHook, &target, fDragMessage); &BPoseView::MenuTrackingHook, &target,
fDragMessage);
} }
// this is now asynchronous so that we don't // this is now asynchronous so that we don't
@@ -2857,7 +2944,8 @@ BContainerWindow::EachAddon(BPath &path, bool (*eachAddon)(const Model*,
else else
delete resolved; delete resolved;
} }
if (model->InitCheck() != B_OK || !model->ResolveIfLink()->IsExecutable()) { if (model->InitCheck() != B_OK
|| !model->ResolveIfLink()->IsExecutable()) {
delete model; delete model;
continue; continue;
} }
@@ -2884,7 +2972,8 @@ BContainerWindow::EachAddon(BPath &path, bool (*eachAddon)(const Model*,
// check all supported types if it has some set // check all supported types if it has some set
if (!secondary) { if (!secondary) {
for (int32 i = mimeTypes.CountItems(); !primary && i-- > 0;) { for (int32 i = mimeTypes.CountItems();
!primary && i-- > 0;) {
BString* type = mimeTypes.ItemAt(i); BString* type = mimeTypes.ItemAt(i);
if (info.IsSupportedType(type->String())) { if (info.IsSupportedType(type->String())) {
BMimeType mimeType(type->String()); BMimeType mimeType(type->String());
@@ -3025,7 +3114,8 @@ BContainerWindow::UpdateMenu(BMenu* menu, UpdateMenuContext context)
Model* selectedModel = NULL; Model* selectedModel = NULL;
if (selectCount == 1) if (selectCount == 1)
selectedModel = PoseView()->SelectionList()->FirstItem()->TargetModel(); selectedModel = PoseView()->SelectionList()->FirstItem()->
TargetModel();
if (context == kMenuBarContext || context == kPosePopUpContext) { if (context == kMenuBarContext || context == kPosePopUpContext) {
SetUpEditQueryItem(menu); SetUpEditQueryItem(menu);
@@ -3098,8 +3188,8 @@ BContainerWindow::UpdateMenu(BMenu* menu, UpdateMenuContext context)
BMenuItem* item = menu->FindItem(B_TRANSLATE("New")); BMenuItem* item = menu->FindItem(B_TRANSLATE("New"));
if (item) { if (item) {
TemplatesMenu* templateMenu = dynamic_cast<TemplatesMenu*>( TemplatesMenu* templateMenu = dynamic_cast<TemplatesMenu*>
item->Submenu()); (item->Submenu());
if (templateMenu) if (templateMenu)
templateMenu->UpdateMenuState(); templateMenu->UpdateMenuState();
} }
@@ -3140,8 +3230,8 @@ BContainerWindow::LoadAddOn(BMessage* message)
refs->AddMessenger("TrackerViewToken", BMessenger(PoseView())); refs->AddMessenger("TrackerViewToken", BMessenger(PoseView()));
LaunchInNewThread("Add-on", B_NORMAL_PRIORITY, &AddOnThread, refs, addonRef, LaunchInNewThread("Add-on", B_NORMAL_PRIORITY, &AddOnThread, refs,
*TargetModel()->EntryRef()); addonRef, *TargetModel()->EntryRef());
} }
@@ -3155,12 +3245,15 @@ BContainerWindow::_UpdateSelectionMIMEInfo()
if (!mimeType.Length() || mimeType.ICompare(B_FILE_MIMETYPE) == 0) { if (!mimeType.Length() || mimeType.ICompare(B_FILE_MIMETYPE) == 0) {
pose->TargetModel()->Mimeset(true); pose->TargetModel()->Mimeset(true);
if (pose->TargetModel()->IsSymLink()) { if (pose->TargetModel()->IsSymLink()) {
Model* resolved = new Model(pose->TargetModel()->EntryRef(), true, true); Model* resolved = new Model(pose->TargetModel()->EntryRef(),
true, true);
if (resolved->InitCheck() == B_OK) { if (resolved->InitCheck() == B_OK) {
mimeType.SetTo(resolved->MimeType()); mimeType.SetTo(resolved->MimeType());
if (!mimeType.Length() || mimeType.ICompare(B_FILE_MIMETYPE) == 0) if (!mimeType.Length()
|| mimeType.ICompare(B_FILE_MIMETYPE) == 0) {
resolved->Mimeset(true); resolved->Mimeset(true);
} }
}
delete resolved; delete resolved;
} }
} }
@@ -3222,8 +3315,8 @@ BContainerWindow::NewAttributeMenu(BMenu* menu)
kAttrRealName, B_STRING_TYPE, 145, B_ALIGN_LEFT, true, true)); kAttrRealName, B_STRING_TYPE, 145, B_ALIGN_LEFT, true, true));
} }
menu->AddItem(NewAttributeMenuItem (B_TRANSLATE("Size"), kAttrStatSize, B_OFF_T_TYPE, menu->AddItem(NewAttributeMenuItem (B_TRANSLATE("Size"), kAttrStatSize,
80, B_ALIGN_RIGHT, false, true)); B_OFF_T_TYPE, 80, B_ALIGN_RIGHT, false, true));
menu->AddItem(NewAttributeMenuItem(B_TRANSLATE("Modified"), menu->AddItem(NewAttributeMenuItem(B_TRANSLATE("Modified"),
kAttrStatModified, B_TIME_TYPE, 150, B_ALIGN_LEFT, false, true)); kAttrStatModified, B_TIME_TYPE, 150, B_ALIGN_LEFT, false, true));
@@ -3236,7 +3329,8 @@ BContainerWindow::NewAttributeMenu(BMenu* menu)
if (IsTrash() || InTrash()) { if (IsTrash() || InTrash()) {
menu->AddItem(NewAttributeMenuItem(B_TRANSLATE("Original name"), menu->AddItem(NewAttributeMenuItem(B_TRANSLATE("Original name"),
kAttrOriginalPath, B_STRING_TYPE, 225, B_ALIGN_LEFT, false, false)); kAttrOriginalPath, B_STRING_TYPE, 225, B_ALIGN_LEFT, false,
false));
} else { } else {
menu->AddItem(NewAttributeMenuItem(B_TRANSLATE("Location"), kAttrPath, menu->AddItem(NewAttributeMenuItem(B_TRANSLATE("Location"), kAttrPath,
B_STRING_TYPE, 225, B_ALIGN_LEFT, false, false)); B_STRING_TYPE, 225, B_ALIGN_LEFT, false, false));
@@ -3325,9 +3419,10 @@ BContainerWindow::MarkArrangeByMenu(BMenu* menu)
BMenuItem* item = menu->ItemAt(index); BMenuItem* item = menu->ItemAt(index);
if (item->Message()) { if (item->Message()) {
uint32 attrHash; uint32 attrHash;
if (item->Message()->FindInt32("attr_hash", (int32*)&attrHash) == B_OK) if (item->Message()->FindInt32("attr_hash",
(int32*)&attrHash) == B_OK) {
item->SetMarked(PoseView()->PrimarySort() == attrHash); item->SetMarked(PoseView()->PrimarySort() == attrHash);
else if (item->Command() == kArrangeReverseOrder) } else if (item->Command() == kArrangeReverseOrder)
item->SetMarked(PoseView()->ReverseSort()); item->SetMarked(PoseView()->ReverseSort());
} }
} }
@@ -3650,7 +3745,8 @@ BContainerWindow::SetUpDefaultState()
BDirectory desktop; BDirectory desktop;
FSGetDeskDir(&desktop); FSGetDeskDir(&desktop);
// try copying state from our parent directory, unless it is the desktop folder // try copying state from our parent directory, unless it is the
// desktop folder
BEntry entry(TargetModel()->EntryRef()); BEntry entry(TargetModel()->EntryRef());
BDirectory parent; BDirectory parent;
if (entry.GetParent(&parent) == B_OK && parent != desktop) { if (entry.GetParent(&parent) == B_OK && parent != desktop) {
@@ -3670,8 +3766,8 @@ BContainerWindow::SetUpDefaultState()
// tracker settings folder for what our state should be // tracker settings folder for what our state should be
// For simplicity we are not picking up the most recent // For simplicity we are not picking up the most recent
// changes that didn't get committed if home is still open in // changes that didn't get committed if home is still open in
// a window, that's probably not a problem; would be OK if state got committed // a window, that's probably not a problem; would be OK if state
// after every change // got committed after every change
&& !DefaultStateSourceNode(kDefaultFolderTemplate, &defaultingNode, true)) && !DefaultStateSourceNode(kDefaultFolderTemplate, &defaultingNode, true))
return; return;
@@ -3693,7 +3789,8 @@ BContainerWindow::SetUpDefaultState()
StaggerOneParams params; StaggerOneParams params;
params.rectFromParent = shouldStagger; params.rectFromParent = shouldStagger;
SelectiveAttributeTransformer frameOffsetter(kAttrWindowFrame, OffsetFrameOne, &params); SelectiveAttributeTransformer frameOffsetter(kAttrWindowFrame,
OffsetFrameOne, &params);
SelectiveAttributeTransformer scrollOriginCleaner(kAttrViewState, SelectiveAttributeTransformer scrollOriginCleaner(kAttrViewState,
ClearViewOriginOne, &params); ClearViewOriginOne, &params);
@@ -3725,7 +3822,8 @@ BContainerWindow::RestoreWindowState(AttributeStreamNode* node)
} }
BRect frame(Frame()); BRect frame(Frame());
if (node->Read(rectAttributeName, 0, B_RECT_TYPE, sizeof(BRect), &frame) == sizeof(BRect)) { if (node->Read(rectAttributeName, 0, B_RECT_TYPE, sizeof(BRect), &frame)
== sizeof(BRect)) {
MoveTo(frame.LeftTop()); MoveTo(frame.LeftTop());
ResizeTo(frame.Width(), frame.Height()); ResizeTo(frame.Width(), frame.Height());
} else } else
@@ -3735,7 +3833,8 @@ BContainerWindow::RestoreWindowState(AttributeStreamNode* node)
uint32 workspace; uint32 workspace;
if ((fContainerWindowFlags & kRestoreWorkspace) if ((fContainerWindowFlags & kRestoreWorkspace)
&& node->Read(workspaceAttributeName, 0, B_INT32_TYPE, sizeof(uint32), &workspace) == sizeof(uint32)) && node->Read(workspaceAttributeName, 0, B_INT32_TYPE, sizeof(uint32),
&workspace) == sizeof(uint32))
SetWorkspaces(workspace); SetWorkspaces(workspace);
if (fContainerWindowFlags & kIsHidden) if (fContainerWindowFlags & kIsHidden)
@@ -3747,7 +3846,8 @@ BContainerWindow::RestoreWindowState(AttributeStreamNode* node)
if (size > 0) { if (size > 0) {
char buffer[size]; char buffer[size];
if ((fContainerWindowFlags & kRestoreDecor) if ((fContainerWindowFlags & kRestoreDecor)
&& node->Read(kAttrWindowDecor, 0, B_RAW_TYPE, size, buffer) == size) { && node->Read(kAttrWindowDecor, 0, B_RAW_TYPE, size, buffer)
== size) {
BMessage decorSettings; BMessage decorSettings;
if (decorSettings.Unflatten(buffer) == B_OK) if (decorSettings.Unflatten(buffer) == B_OK)
SetDecoratorSettings(decorSettings); SetDecoratorSettings(decorSettings);
@@ -3783,8 +3883,10 @@ BContainerWindow::RestoreWindowState(const BMessage &message)
uint32 workspace; uint32 workspace;
if ((fContainerWindowFlags & kRestoreWorkspace) if ((fContainerWindowFlags & kRestoreWorkspace)
&& message.FindInt32(workspaceAttributeName, (int32*)&workspace) == B_OK) && message.FindInt32(workspaceAttributeName,
(int32*)&workspace) == B_OK) {
SetWorkspaces(workspace); SetWorkspaces(workspace);
}
if (fContainerWindowFlags & kIsHidden) if (fContainerWindowFlags & kIsHidden)
Minimize(true); Minimize(true);
@@ -3871,12 +3973,15 @@ BContainerWindow::DragStart(const BMessage* dragMessage)
// if already dragging, or // if already dragging, or
// if all the refs match // if all the refs match
if (Dragging() && SpringLoadedFolderCompareMessages(dragMessage, fDragMessage)) if (Dragging()
&& SpringLoadedFolderCompareMessages(dragMessage, fDragMessage)) {
return B_OK; return B_OK;
}
// cache the current drag message // cache the current drag message
// build a list of the mimetypes in the message // build a list of the mimetypes in the message
SpringLoadedFolderCacheDragData(dragMessage, &fDragMessage, &fCachedTypesList); SpringLoadedFolderCacheDragData(dragMessage, &fDragMessage,
&fCachedTypesList);
fWaitingForRefs = true; fWaitingForRefs = true;
@@ -4015,7 +4120,8 @@ BContainerWindow::SetSingleWindowBrowseShortcuts(bool enabled)
new BMessage(kOpenSelection), PoseView()); new BMessage(kOpenSelection), PoseView());
AddShortcut(B_UP_ARROW, B_COMMAND_KEY, AddShortcut(B_UP_ARROW, B_COMMAND_KEY,
new BMessage(kOpenParentDir), PoseView()); new BMessage(kOpenParentDir), PoseView());
// We change the meaning from kNavigatorCommandUp to kOpenParentDir. // We change the meaning from kNavigatorCommandUp
// to kOpenParentDir.
AddShortcut(B_UP_ARROW, B_COMMAND_KEY | B_OPTION_KEY, AddShortcut(B_UP_ARROW, B_COMMAND_KEY | B_OPTION_KEY,
new BMessage(kOpenParentDir), PoseView()); new BMessage(kOpenParentDir), PoseView());
// command + option results in closing the parent window // command + option results in closing the parent window
@@ -4099,7 +4205,8 @@ BContainerWindow::PopulateArrangeByMenu(BMenu* menu)
menu->AddSeparatorItem(); menu->AddSeparatorItem();
item = new BMenuItem(B_TRANSLATE("Clean up"), new BMessage(kCleanup), 'K'); item = new BMenuItem(B_TRANSLATE("Clean up"), new BMessage(kCleanup),
'K');
item->SetTarget(PoseView()); item->SetTarget(PoseView());
menu->AddItem(item); menu->AddItem(item);
} }
@@ -4108,7 +4215,8 @@ BContainerWindow::PopulateArrangeByMenu(BMenu* menu)
// #pragma mark - // #pragma mark -
WindowStateNodeOpener::WindowStateNodeOpener(BContainerWindow* window, bool forWriting) WindowStateNodeOpener::WindowStateNodeOpener(BContainerWindow* window,
bool forWriting)
: fModelOpener(NULL), : fModelOpener(NULL),
fNode(NULL), fNode(NULL),
fStreamNode(NULL) fStreamNode(NULL)
@@ -4120,9 +4228,12 @@ WindowStateNodeOpener::WindowStateNodeOpener(BContainerWindow* window, bool forW
fStreamNode = new AttributeStreamFileNode(fNode); fStreamNode = new AttributeStreamFileNode(fNode);
} }
} else if (window->TargetModel()){ } else if (window->TargetModel()){
fModelOpener = new ModelNodeLazyOpener(window->TargetModel(), forWriting, false); fModelOpener = new ModelNodeLazyOpener(window->TargetModel(),
if (fModelOpener->IsOpen(forWriting)) forWriting, false);
fStreamNode = new AttributeStreamFileNode(fModelOpener->TargetModel()->Node()); if (fModelOpener->IsOpen(forWriting)) {
fStreamNode = new AttributeStreamFileNode(
fModelOpener->TargetModel()->Node());
}
} }
} }
+15 -9
View File
@@ -78,7 +78,8 @@ class BContainerWindow : public BWindow {
uint32 containerWindowFlags, uint32 containerWindowFlags,
window_look look = B_DOCUMENT_WINDOW_LOOK, window_look look = B_DOCUMENT_WINDOW_LOOK,
window_feel feel = B_NORMAL_WINDOW_FEEL, window_feel feel = B_NORMAL_WINDOW_FEEL,
uint32 flags = B_WILL_ACCEPT_FIRST_CLICK | B_NO_WORKSPACE_ACTIVATION, uint32 flags = B_WILL_ACCEPT_FIRST_CLICK
| B_NO_WORKSPACE_ACTIVATION,
uint32 workspace = B_CURRENT_WORKSPACE); uint32 workspace = B_CURRENT_WORKSPACE);
virtual ~BContainerWindow(); virtual ~BContainerWindow();
@@ -152,7 +153,8 @@ class BContainerWindow : public BWindow {
void MarkAttributeMenu(); void MarkAttributeMenu();
void MarkArrangeByMenu(BMenu*); void MarkArrangeByMenu(BMenu*);
BMenuItem* NewAttributeMenuItem(const char* label, const char* name, BMenuItem* NewAttributeMenuItem(const char* label, const char* name,
int32 type, float width, int32 align, bool editable, bool statField); int32 type, float width, int32 align, bool editable,
bool statField);
BMenuItem* NewAttributeMenuItem(const char* label, const char* name, BMenuItem* NewAttributeMenuItem(const char* label, const char* name,
int32 type, const char* displayAs, float width, int32 align, int32 type, const char* displayAs, float width, int32 align,
bool editable, bool statField); bool editable, bool statField);
@@ -163,7 +165,8 @@ class BContainerWindow : public BWindow {
PiggybackTaskLoop* DelayedTaskLoop(); PiggybackTaskLoop* DelayedTaskLoop();
// use for RunLater queueing // use for RunLater queueing
void PulseTaskLoop(); void PulseTaskLoop();
// called by some view that has pulse, either BackgroundView or BPoseView // called by some view that has pulse, either BackgroundView
// or BPoseView
static bool DefaultStateSourceNode(const char* name, BNode* result, static bool DefaultStateSourceNode(const char* name, BNode* result,
bool createNew = false, bool createFolder = true); bool createNew = false, bool createFolder = true);
@@ -205,7 +208,8 @@ class BContainerWindow : public BWindow {
virtual void AddMenus(); virtual void AddMenus();
virtual void AddShortcuts(); virtual void AddShortcuts();
// add equivalents of the menu shortcuts to the menuless desktop window // add equivalents of the menu shortcuts to the menuless
// desktop window
virtual void AddFileMenu(BMenu* menu); virtual void AddFileMenu(BMenu* menu);
virtual void AddWindowMenu(BMenu* menu); virtual void AddWindowMenu(BMenu* menu);
@@ -227,7 +231,8 @@ class BContainerWindow : public BWindow {
virtual void SetCloseItem(BMenu*); virtual void SetCloseItem(BMenu*);
virtual void SetupNavigationMenu(const entry_ref*, BMenu*); virtual void SetupNavigationMenu(const entry_ref*, BMenu*);
virtual void SetupMoveCopyMenus(const entry_ref*, BMenu*); virtual void SetupMoveCopyMenus(const entry_ref*, BMenu*);
virtual void PopulateMoveCopyNavMenu(BNavMenu*, uint32, const entry_ref*, bool); virtual void PopulateMoveCopyNavMenu(BNavMenu*, uint32,
const entry_ref*, bool);
virtual void SetupOpenWithMenu(BMenu*); virtual void SetupOpenWithMenu(BMenu*);
virtual void SetUpEditQueryItem(BMenu*); virtual void SetUpEditQueryItem(BMenu*);
@@ -250,7 +255,8 @@ class BContainerWindow : public BWindow {
BHandler* ResolveSpecifier(BMessage*, int32, BMessage*, int32, BHandler* ResolveSpecifier(BMessage*, int32, BMessage*, int32,
const char*); const char*);
bool EachAddon(BPath &path, bool(*)(const Model*, const char*, uint32, bool, void*), bool EachAddon(BPath &path,
bool (*)(const Model*, const char*, uint32, bool, void*),
BObjectList<Model>*, void*, BObjectList<BString> &); BObjectList<Model>*, void*, BObjectList<BString> &);
void LoadAddOn(BMessage*); void LoadAddOn(BMessage*);
@@ -313,8 +319,8 @@ class WindowStateNodeOpener {
// this class manages opening and closing the proper node for // this class manages opening and closing the proper node for
// state restoring / saving; the constructor knows how to decide whether // state restoring / saving; the constructor knows how to decide whether
// to use a special directory for root, etc. // to use a special directory for root, etc.
// setter calls used when no attributes can be read from a node and defaults // setter calls used when no attributes can be read from a node and
// are to be substituted // defaults are to be substituted
public: public:
WindowStateNodeOpener(BContainerWindow* window, bool forWriting); WindowStateNodeOpener(BContainerWindow* window, bool forWriting);
virtual ~WindowStateNodeOpener(); virtual ~WindowStateNodeOpener();
@@ -428,7 +434,7 @@ BContainerWindow::IsPathWatchingEnabled() const
return fIsWatchingPath; return fIsWatchingPath;
} }
filter_result ActivateWindowFilter(BMessage* message, BHandler**target, filter_result ActivateWindowFilter(BMessage* message, BHandler** target,
BMessageFilter* messageFilter); BMessageFilter* messageFilter);
} // namespace BPrivate } // namespace BPrivate
+8 -4
View File
@@ -242,7 +242,8 @@ BCountView::Draw(BRect updateRect)
if (IsTypingAhead()) { if (IsTypingAhead()) {
// use a muted gray for the typeahead // use a muted gray for the typeahead
SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_4_TINT)); SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
B_DARKEN_4_TINT));
} else } else
SetHighColor(0, 0, 0); SetHighColor(0, 0, 0);
@@ -263,7 +264,8 @@ BCountView::Draw(BRect updateRect)
bounds.top--; bounds.top--;
AddLine(bounds.LeftTop(), bounds.RightTop(), shadow); AddLine(bounds.LeftTop(), bounds.RightTop(), shadow);
AddLine(BPoint(bounds.right, bounds.top + 2), bounds.RightBottom(), lightShadow); AddLine(BPoint(bounds.right, bounds.top + 2), bounds.RightBottom(),
lightShadow);
AddLine(bounds.LeftBottom(), bounds.RightBottom(), lightShadow); AddLine(bounds.LeftBottom(), bounds.RightBottom(), lightShadow);
} }
@@ -282,8 +284,10 @@ BCountView::Draw(BRect updateRect)
barberPoleRect.InsetBy(1, 1); barberPoleRect.InsetBy(1, 1);
BRect destRect(fBarberPoleMap ? fBarberPoleMap->Bounds() : BRect(0, 0, 0, 0)); BRect destRect(fBarberPoleMap
destRect.OffsetTo(barberPoleRect.LeftTop() - BPoint(0, fLastBarberPoleOffset)); ? fBarberPoleMap->Bounds() : BRect(0, 0, 0, 0));
destRect.OffsetTo(barberPoleRect.LeftTop()
- BPoint(0, fLastBarberPoleOffset));
fLastBarberPoleOffset -= 1; fLastBarberPoleOffset -= 1;
if (fLastBarberPoleOffset < 0) if (fLastBarberPoleOffset < 0)
fLastBarberPoleOffset = 5; fLastBarberPoleOffset = 5;
+19 -6
View File
@@ -84,7 +84,8 @@ struct AddOneShortcutParams {
}; };
static bool static bool
AddOneShortcut(const Model* model, const char*, uint32 shortcut, bool /*primary*/, void* context) AddOneShortcut(const Model* model, const char*, uint32 shortcut,
bool /*primary*/, void* context)
{ {
if (!shortcut) if (!shortcut)
// no shortcut, bail // no shortcut, bail
@@ -151,11 +152,10 @@ BDeskWindow::~BDeskWindow()
void void
BDeskWindow::Init(const BMessage*) BDeskWindow::Init(const BMessage*)
{ {
//
// Set the size of the screen before calling the container window's // Set the size of the screen before calling the container window's
// Init() because it will add volume poses to this window and // Init() because it will add volume poses to this window and
// they will be clipped otherwise // they will be clipped otherwise
//
BScreen screen(this); BScreen screen(this);
fOldFrame = screen.Frame(); fOldFrame = screen.Frame();
@@ -313,6 +313,20 @@ BDeskWindow::AddWindowContextMenus(BMenu* menu)
item->SetTarget(PoseView()); item->SetTarget(PoseView());
iconSizeMenu->AddItem(item); iconSizeMenu->AddItem(item);
message = new BMessage(kIconMode);
message->AddInt32("size", 96);
item = new BMenuItem(B_TRANSLATE("96 x 96"), message);
item->SetMarked(PoseView()->IconSizeInt() == 96);
item->SetTarget(PoseView());
iconSizeMenu->AddItem(item);
message = new BMessage(kIconMode);
message->AddInt32("size", 128);
item = new BMenuItem(B_TRANSLATE("128 x 128"), message);
item->SetMarked(PoseView()->IconSizeInt() == 128);
item->SetTarget(PoseView());
iconSizeMenu->AddItem(item);
iconSizeMenu->AddSeparatorItem(); iconSizeMenu->AddSeparatorItem();
message = new BMessage(kIconMode); message = new BMessage(kIconMode);
@@ -347,8 +361,8 @@ BDeskWindow::AddWindowContextMenus(BMenu* menu)
menu->AddItem(pasteItem); menu->AddItem(pasteItem);
menu->AddSeparatorItem(); menu->AddSeparatorItem();
#endif #endif
menu->AddItem(new BMenuItem(B_TRANSLATE("Clean up"), new BMessage(kCleanup), menu->AddItem(new BMenuItem(B_TRANSLATE("Clean up"),
'K')); new BMessage(kCleanup), 'K'));
menu->AddItem(new BMenuItem(B_TRANSLATE("Select"B_UTF8_ELLIPSIS), menu->AddItem(new BMenuItem(B_TRANSLATE("Select"B_UTF8_ELLIPSIS),
new BMessage(kShowSelectionWindow), 'A', B_SHIFT_KEY)); new BMessage(kShowSelectionWindow), 'A', B_SHIFT_KEY));
menu->AddItem(new BMenuItem(B_TRANSLATE("Select all"), menu->AddItem(new BMenuItem(B_TRANSLATE("Select all"),
@@ -470,4 +484,3 @@ BDeskWindow::MessageReceived(BMessage* message)
break; break;
} }
} }
+4 -3
View File
@@ -86,9 +86,10 @@ private:
BRect fOldFrame; BRect fOldFrame;
// in the desktop window addon shortcuts have to be added by AddShortcut // in the desktop window addon shortcuts have to be added by AddShortcut
// and we don't always get the MenusBeginning call to check for new addons/update the // and we don't always get the MenusBeginning call to check for new
// shortcuts -- instead we need to node monitor the addon directory and keep // addons/update the shortcuts -- instead we need to node monitor the
// a dirty flag that triggers shortcut re-installing // addon directory and keep a dirty flag that triggers shortcut
// reinstallation
bool fShouldUpdateAddonShortcuts; bool fShouldUpdateAddonShortcuts;
std::set<uint32> fCurrentAddonShortcuts; std::set<uint32> fCurrentAddonShortcuts;
// keeps track of which shortcuts are installed for Tracker addons // keeps track of which shortcuts are installed for Tracker addons
+14 -8
View File
@@ -79,13 +79,14 @@ DesktopPoseView::InitDesktopDirentIterator(BPoseView* nodeMonitoringTarget,
ASSERT(!sourceModel.IsQuery()); ASSERT(!sourceModel.IsQuery());
ASSERT(sourceModel.Node()); ASSERT(sourceModel.Node());
BDirectory* sourceDirectory = dynamic_cast<BDirectory*>(sourceModel.Node()); BDirectory* sourceDirectory
= dynamic_cast<BDirectory*>(sourceModel.Node());
ASSERT(sourceDirectory); ASSERT(sourceDirectory);
// build an iterator list, start with boot // build an iterator list, start with boot
EntryListBase* perDesktopIterator = new CachedDirectoryEntryList( EntryListBase* perDesktopIterator
*sourceDirectory); = new CachedDirectoryEntryList(*sourceDirectory);
result->AddItem(perDesktopIterator); result->AddItem(perDesktopIterator);
if (nodeMonitoringTarget) { if (nodeMonitoringTarget) {
@@ -131,7 +132,8 @@ DesktopPoseView::FSNotification(const BMessage* message)
break; break;
if (settings.MountVolumesOntoDesktop() if (settings.MountVolumesOntoDesktop()
&& (!volume.IsShared() || settings.MountSharedVolumesOntoDesktop())) { && (!volume.IsShared()
|| settings.MountSharedVolumesOntoDesktop())) {
// place an icon for the volume onto the desktop // place an icon for the volume onto the desktop
CreateVolumePose(&volume, true); CreateVolumePose(&volume, true);
} }
@@ -227,7 +229,8 @@ DesktopPoseView::AdaptToVolumeChange(BMessage* message)
message->FindBool("ShowDisksIcon", &showDisksIcon); message->FindBool("ShowDisksIcon", &showDisksIcon);
message->FindBool("MountVolumesOntoDesktop", &mountVolumesOnDesktop); message->FindBool("MountVolumesOntoDesktop", &mountVolumesOnDesktop);
message->FindBool("MountSharedVolumesOntoDesktop", &mountSharedVolumesOntoDesktop); message->FindBool("MountSharedVolumesOntoDesktop",
&mountSharedVolumesOntoDesktop);
BEntry entry("/"); BEntry entry("/");
Model model(&entry); Model model(&entry);
@@ -241,7 +244,8 @@ DesktopPoseView::AdaptToVolumeChange(BMessage* message)
entryMessage.AddInt32("opcode", B_ENTRY_REMOVED); entryMessage.AddInt32("opcode", B_ENTRY_REMOVED);
entry_ref ref; entry_ref ref;
if (entry.GetRef(&ref) == B_OK) { if (entry.GetRef(&ref) == B_OK) {
BContainerWindow* disksWindow = tracker->FindContainerWindow(&ref); BContainerWindow* disksWindow
= tracker->FindContainerWindow(&ref);
if (disksWindow) { if (disksWindow) {
disksWindow->Lock(); disksWindow->Lock();
disksWindow->Close(); disksWindow->Close();
@@ -252,7 +256,8 @@ DesktopPoseView::AdaptToVolumeChange(BMessage* message)
entryMessage.AddInt64("node", model.NodeRef()->node); entryMessage.AddInt64("node", model.NodeRef()->node);
entryMessage.AddInt64("directory", model.EntryRef()->directory); entryMessage.AddInt64("directory", model.EntryRef()->directory);
entryMessage.AddString("name", model.EntryRef()->name); entryMessage.AddString("name", model.EntryRef()->name);
BContainerWindow* deskWindow = dynamic_cast<BContainerWindow*>(Window()); BContainerWindow* deskWindow
= dynamic_cast<BContainerWindow*>(Window());
if (deskWindow) if (deskWindow)
deskWindow->PostMessage(&entryMessage, deskWindow->PoseView()); deskWindow->PostMessage(&entryMessage, deskWindow->PoseView());
} }
@@ -268,7 +273,8 @@ DesktopPoseView::AdaptToDesktopIntegrationChange(BMessage* message)
bool mountSharedVolumesOntoDesktop = true; bool mountSharedVolumesOntoDesktop = true;
message->FindBool("MountVolumesOntoDesktop", &mountVolumesOnDesktop); message->FindBool("MountVolumesOntoDesktop", &mountVolumesOnDesktop);
message->FindBool("MountSharedVolumesOntoDesktop", &mountSharedVolumesOntoDesktop); message->FindBool("MountSharedVolumesOntoDesktop",
&mountSharedVolumesOntoDesktop);
ShowVolumes(false, mountSharedVolumesOntoDesktop); ShowVolumes(false, mountSharedVolumesOntoDesktop);
ShowVolumes(mountVolumesOnDesktop, mountSharedVolumesOntoDesktop); ShowVolumes(mountVolumesOnDesktop, mountSharedVolumesOntoDesktop);
+14 -9
View File
@@ -109,10 +109,13 @@ BDirMenu::Populate(const BEntry* startEntry, BWindow* originatingWindow,
if (!includeStartEntry) { if (!includeStartEntry) {
BDirectory parent; BDirectory parent;
BDirectory dir(&entry); BDirectory dir(&entry);
// if we're at the root directory skip "mnt" and go straight to "/"
if (!showDesktop && dir.InitCheck() == B_OK && dir.IsRootDirectory()) if (!showDesktop && dir.InitCheck() == B_OK
&& dir.IsRootDirectory()) {
// if we're at the root directory skip "mnt" and
// go straight to "/"
parent.SetTo("/"); parent.SetTo("/");
else } else
entry.GetParent(&parent); entry.GetParent(&parent);
parent.GetEntry(&entry); parent.GetEntry(&entry);
@@ -137,10 +140,11 @@ BDirMenu::Populate(const BEntry* startEntry, BWindow* originatingWindow,
bool hitRoot = false; bool hitRoot = false;
// if we're at the root directory skip "mnt" and go straight to "/"
BDirectory dir(&entry); BDirectory dir(&entry);
if (!showDesktop && dir.InitCheck() == B_OK if (!showDesktop && dir.InitCheck() == B_OK
&& dir.IsRootDirectory()) { && dir.IsRootDirectory()) {
// if we're at the root directory skip "mnt" and
// go straight to "/"
hitRoot = true; hitRoot = true;
parent.SetTo("/"); parent.SetTo("/");
} }
@@ -213,12 +217,12 @@ BDirMenu::AddItemToDirMenu(const BEntry* entry, BWindow* originatingWindow,
BContainerWindow* window = originatingWindow ? BContainerWindow* window = originatingWindow ?
dynamic_cast<BContainerWindow*>(originatingWindow) : 0; dynamic_cast<BContainerWindow*>(originatingWindow) : 0;
if (window) if (window)
message->AddData("nodeRefsToClose", B_RAW_TYPE, window->TargetModel()->NodeRef(), message->AddData("nodeRefsToClose", B_RAW_TYPE,
sizeof (node_ref)); window->TargetModel()->NodeRef(), sizeof (node_ref));
ModelMenuItem* item; ModelMenuItem* item;
if (navMenuEntries) { if (navMenuEntries) {
BNavMenu* subMenu = new BNavMenu(model.Name(), B_REFS_RECEIVED, fTarget, BNavMenu* subMenu = new BNavMenu(model.Name(), B_REFS_RECEIVED,
window); fTarget, window);
entry_ref ref; entry_ref ref;
entry->GetRef(&ref); entry->GetRef(&ref);
subMenu->SetNavDir(&ref); subMenu->SetNavDir(&ref);
@@ -244,7 +248,8 @@ BDirMenu::AddItemToDirMenu(const BEntry* entry, BWindow* originatingWindow,
item->SetTarget(fTarget); item->SetTarget(fTarget);
if (fMenuBar) { if (fMenuBar) {
ModelMenuItem* menu = dynamic_cast<ModelMenuItem*>(fMenuBar->ItemAt(0)); ModelMenuItem* menu
= dynamic_cast<ModelMenuItem*>(fMenuBar->ItemAt(0));
if (menu) { if (menu) {
ThrowOnError(menu->SetEntry(entry)); ThrowOnError(menu->SetEntry(entry));
item->SetMarked(true); item->SetMarked(true);
+3 -2
View File
@@ -50,8 +50,9 @@ public:
virtual ~BDirMenu(); virtual ~BDirMenu();
void Populate(const BEntry* startDir, BWindow* originatingWindow, void Populate(const BEntry* startDir, BWindow* originatingWindow,
bool includeStartDir = false, bool select = false, bool reverse = false, bool includeStartDir = false, bool select = false,
bool addShortcuts = false, bool navMenuEntries = false); bool reverse = false, bool addShortcuts = false,
bool navMenuEntries = false);
void AddItemToDirMenu(const BEntry*, BWindow* originatingWindow, void AddItemToDirMenu(const BEntry*, BWindow* originatingWindow,
bool atEnd, bool addShortcuts, bool navMenuEntries = false); bool atEnd, bool addShortcuts, bool navMenuEntries = false);
void AddDisksIconToMenu(bool reverse = false); void AddDisksIconToMenu(bool reverse = false);
+4 -3
View File
@@ -131,8 +131,8 @@ EntryListBase::Next(dirent* ent)
// #pragma mark - // #pragma mark -
CachedEntryIterator::CachedEntryIterator(BEntryList* iterator, int32 numEntries, CachedEntryIterator::CachedEntryIterator(BEntryList* iterator,
bool sortInodes) int32 numEntries, bool sortInodes)
: :
fIterator(iterator), fIterator(iterator),
fEntryRefBuffer(NULL), fEntryRefBuffer(NULL),
@@ -265,7 +265,8 @@ CachedEntryIterator::GetNextDirents(struct dirent* ent, size_t size,
bufferRemain -= currentDirentSize; bufferRemain -= currentDirentSize;
ASSERT(bufferRemain >= 0); ASSERT(bufferRemain >= 0);
if ((size_t)bufferRemain < (sizeof(dirent) + B_FILE_NAME_LENGTH)) { if ((size_t)bufferRemain
< (sizeof(dirent) + B_FILE_NAME_LENGTH)) {
// cant fit a big entryRef in the buffer, just bail // cant fit a big entryRef in the buffer, just bail
// and start from scratch // and start from scratch
break; break;
+2 -2
View File
@@ -102,8 +102,8 @@ public:
// //
// each chunk of iterators in the cache are then returned in an order, // each chunk of iterators in the cache are then returned in an order,
// sorted by their i-node number -- this turns out to give quite a bit // sorted by their i-node number -- this turns out to give quite a bit
// better performance over just using the order in which they show up using // better performance over just using the order in which they show up
// the default BEntryList iterator subclass // using the default BEntryList iterator subclass
CachedEntryIterator(BEntryList* iterator, int32 numEntries, CachedEntryIterator(BEntryList* iterator, int32 numEntries,
bool sortInodes = false); bool sortInodes = false);
+38 -25
View File
@@ -48,7 +48,8 @@ static void MakeNodeFromName(node_ref* node, char* name);
static inline void MakeRefName(char* refName, const node_ref* node); static inline void MakeRefName(char* refName, const node_ref* node);
static inline void MakeModeName(char* modeName, const node_ref* node); static inline void MakeModeName(char* modeName, const node_ref* node);
static inline void MakeModeNameFromRefName(char* modeName, char* refName); static inline void MakeModeNameFromRefName(char* modeName, char* refName);
static inline bool CompareModeAndRefName(const char* modeName, const char* refName); static inline bool CompareModeAndRefName(const char* modeName,
const char* refName);
/* /*
static bool static bool
@@ -130,9 +131,11 @@ FSClipboardHasRefs()
uint32 type; uint32 type;
int32 count; int32 count;
if (clip->GetInfo(B_REF_TYPE, 0, &refName, &type, &count) == B_OK if (clip->GetInfo(B_REF_TYPE, 0, &refName, &type, &count) == B_OK
&& clip->GetInfo(B_INT32_TYPE, 0, &modeName, &type, &count) == B_OK) && clip->GetInfo(B_INT32_TYPE, 0, &modeName, &type, &count)
== B_OK) {
result = CompareModeAndRefName(modeName, refName); result = CompareModeAndRefName(modeName, refName);
} }
}
be_clipboard->Unlock(); be_clipboard->Unlock();
} }
return result; return result;
@@ -145,8 +148,8 @@ FSClipboardStartWatch(BMessenger target)
if (dynamic_cast<TTracker*>(be_app) != NULL) if (dynamic_cast<TTracker*>(be_app) != NULL)
((TTracker*)be_app)->ClipboardRefsWatcher()->AddToNotifyList(target); ((TTracker*)be_app)->ClipboardRefsWatcher()->AddToNotifyList(target);
else { else {
// this code is used by external apps using objects using FSClipboard functions // this code is used by external apps using objects using FSClipboard
// i.e: applications using FilePanel // functions, i.e. applications using FilePanel
BMessenger messenger(kTrackerSignature); BMessenger messenger(kTrackerSignature);
if (messenger.IsValid()) { if (messenger.IsValid()) {
BMessage message(kStartWatchClipboardRefs); BMessage message(kStartWatchClipboardRefs);
@@ -163,8 +166,8 @@ FSClipboardStopWatch(BMessenger target)
if (dynamic_cast<TTracker*>(be_app) != NULL) if (dynamic_cast<TTracker*>(be_app) != NULL)
((TTracker*)be_app)->ClipboardRefsWatcher()->AddToNotifyList(target); ((TTracker*)be_app)->ClipboardRefsWatcher()->AddToNotifyList(target);
else { else {
// this code is used by external apps using objects using FSClipboard functions // this code is used by external apps using objects using FSClipboard
// i.e: applications using FilePanel // functions, i.e. applications using FilePanel
BMessenger messenger(kTrackerSignature); BMessenger messenger(kTrackerSignature);
if (messenger.IsValid()) { if (messenger.IsValid()) {
BMessage message(kStopWatchClipboardRefs); BMessage message(kStopWatchClipboardRefs);
@@ -195,8 +198,8 @@ FSClipboardClear()
*/ */
uint32 uint32
FSClipboardAddPoses(const node_ref* directory, PoseList* list, uint32 moveMode, FSClipboardAddPoses(const node_ref* directory, PoseList* list,
bool clearClipboard) uint32 moveMode, bool clearClipboard)
{ {
uint32 refsAdded = 0; uint32 refsAdded = 0;
int32 listCount = list->CountItems(); int32 listCount = list->CountItems();
@@ -333,7 +336,8 @@ FSClipboardRemovePoses(const node_ref* directory, PoseList* list)
MakeRefName(refName, &clipNode.node); MakeRefName(refName, &clipNode.node);
MakeModeName(modeName); MakeModeName(modeName);
if (clip->RemoveName(refName) == B_OK && clip->RemoveName(modeName)) { if (clip->RemoveName(refName) == B_OK
&& clip->RemoveName(modeName)) {
updateMessage.AddData("tcnode", T_CLIPBOARD_NODE, &clipNode, updateMessage.AddData("tcnode", T_CLIPBOARD_NODE, &clipNode,
sizeof(TClipboardNodeRef), true, listCount); sizeof(TClipboardNodeRef), true, listCount);
refsRemoved++; refsRemoved++;
@@ -353,7 +357,6 @@ FSClipboardRemovePoses(const node_ref* directory, PoseList* list)
/** Pastes entries from the clipboard to the target model's directory. /** Pastes entries from the clipboard to the target model's directory.
* Updates moveModes and notifies listeners if necessary. * Updates moveModes and notifies listeners if necessary.
*/ */
bool bool
FSClipboardPaste(Model* model, uint32 linksMode) FSClipboardPaste(Model* model, uint32 linksMode)
{ {
@@ -409,13 +412,16 @@ FSClipboardPaste(Model* model, uint32 linksMode)
// we need this data later on // we need this data later on
MakeModeNameFromRefName(modeName, refName); MakeModeNameFromRefName(modeName, refName);
if (!linksMode && clip->FindInt32(modeName, (int32*)&moveMode) != B_OK) if (!linksMode && clip->FindInt32(modeName, (int32*)&moveMode)
!= B_OK) {
continue; continue;
}
BEntry entry(&ref); BEntry entry(&ref);
uint32 newMoveMode = 0; uint32 newMoveMode = 0;
bool sameDirectory = destNodeRef->device == ref.device && destNodeRef->node == ref.directory; bool sameDirectory = destNodeRef->device == ref.device
&& destNodeRef->node == ref.directory;
if (!entry.Exists()) { if (!entry.Exists()) {
// The entry doesn't exist anymore, so we'll remove // The entry doesn't exist anymore, so we'll remove
@@ -435,9 +441,10 @@ FSClipboardPaste(Model* model, uint32 linksMode)
copyList->AddItem(new entry_ref(ref)); copyList->AddItem(new entry_ref(ref));
} }
// if the entry should have been removed from its directory, // if the entry should have been removed from its
// we want to copy that entry next time, no matter if the // directory, we want to copy that entry next time, no
// items don't have to be moved at all (source == target) // matter if the items don't have to be moved at all
// (source == target)
if (moveMode == kMoveSelectionTo) if (moveMode == kMoveSelectionTo)
newMoveMode = kCopySelectionTo; newMoveMode = kCopySelectionTo;
} }
@@ -449,8 +456,8 @@ FSClipboardPaste(Model* model, uint32 linksMode)
TClipboardNodeRef clipNode; TClipboardNodeRef clipNode;
MakeNodeFromName(&clipNode.node, modeName); MakeNodeFromName(&clipNode.node, modeName);
clipNode.moveMode = kDelete; clipNode.moveMode = kDelete;
updateMessage->AddData("tcnode", T_CLIPBOARD_NODE, &clipNode, updateMessage->AddData("tcnode", T_CLIPBOARD_NODE,
sizeof(TClipboardNodeRef), true); &clipNode, sizeof(TClipboardNodeRef), true);
} }
} }
be_clipboard->Commit(); be_clipboard->Commit();
@@ -499,9 +506,10 @@ FSClipboardPaste(Model* model, uint32 linksMode)
} }
// asynchronous calls take over ownership of the objects passed to it // asynchronous calls take over ownership of the objects passed to it
if (moveList->CountItems() > 0) if (moveList->CountItems() > 0) {
FSMoveToFolder(moveList, new BEntry(entry), linksMode ? linksMode : kMoveSelectionTo); FSMoveToFolder(moveList, new BEntry(entry),
else linksMode ? linksMode : kMoveSelectionTo);
} else
delete moveList; delete moveList;
if (copyList->CountItems() > 0) if (copyList->CountItems() > 0)
@@ -583,7 +591,8 @@ FSClipboardRemove(Model* model)
report->AddInt32("device", ref->device); report->AddInt32("device", ref->device);
report->AddInt64("directory", ref->directory); report->AddInt64("directory", ref->directory);
report->AddBool("clearClipboard", false); report->AddBool("clearClipboard", false);
report->AddData("tcnode", T_CLIPBOARD_NODE, &tcnode, sizeof(tcnode), true); report->AddData("tcnode", T_CLIPBOARD_NODE, &tcnode, sizeof(tcnode),
true);
messenger.SendMessage(report); messenger.SendMessage(report);
delete report; delete report;
} }
@@ -619,7 +628,8 @@ BClipboardRefsWatcher::AddToNotifyList(BMessenger target)
BMessenger* messenger; BMessenger* messenger;
bool found = false; bool found = false;
for (int32 index = 0;(messenger = fNotifyList.ItemAt(index)) != NULL; index++) { for (int32 index = 0; (messenger = fNotifyList.ItemAt(index)) != NULL;
index++) {
if (*messenger == target) { if (*messenger == target) {
found = true; found = true;
break; break;
@@ -639,7 +649,8 @@ BClipboardRefsWatcher::RemoveFromNotifyList(BMessenger target)
if (Lock()) { if (Lock()) {
BMessenger* messenger; BMessenger* messenger;
for (int32 index = 0;(messenger = fNotifyList.ItemAt(index)) != NULL; index++) { for (int32 index = 0; (messenger = fNotifyList.ItemAt(index)) != NULL;
index++) {
if (*messenger == target) { if (*messenger == target) {
delete fNotifyList.RemoveItemAt(index); delete fNotifyList.RemoveItemAt(index);
break; break;
@@ -761,7 +772,8 @@ BClipboardRefsWatcher::Clear()
//void //void
//BClipboardRefsWatcher::UpdatePoseViews(bool clearClipboard, const node_ref* node) //BClipboardRefsWatcher::UpdatePoseViews(bool clearClipboard,
// const node_ref* node)
//{ //{
// BMessage message(kFSClipboardChanges); // BMessage message(kFSClipboardChanges);
// message.AddInt32("device", node->device); // message.AddInt32("device", node->device);
@@ -796,7 +808,8 @@ BClipboardRefsWatcher::UpdatePoseViews(BMessage* reportMessage)
int32 index = 0; int32 index = 0;
TClipboardNodeRef* tcnode = NULL; TClipboardNodeRef* tcnode = NULL;
ssize_t size; ssize_t size;
while (reportMessage->FindData("tcnode", T_CLIPBOARD_NODE, index, (const void**)&tcnode, &size) == B_OK) { while (reportMessage->FindData("tcnode", T_CLIPBOARD_NODE, index,
(const void**)&tcnode, &size) == B_OK) {
if (tcnode->moveMode == kDelete) { if (tcnode->moveMode == kDelete) {
watch_node(&tcnode->node, B_STOP_WATCHING, this); watch_node(&tcnode->node, B_STOP_WATCHING, this);
} else { } else {
+4 -2
View File
@@ -87,10 +87,12 @@ void FSClipboardStartWatch(BMessenger target);
void FSClipboardStopWatch(BMessenger target); void FSClipboardStopWatch(BMessenger target);
void FSClipboardClear(); void FSClipboardClear();
uint32 FSClipboardAddPoses(const node_ref* directory, PoseList* list, uint32 moveMode, bool clearClipboard); uint32 FSClipboardAddPoses(const node_ref* directory, PoseList* list,
uint32 moveMode, bool clearClipboard);
uint32 FSClipboardRemovePoses(const node_ref* directory, PoseList* list); uint32 FSClipboardRemovePoses(const node_ref* directory, PoseList* list);
bool FSClipboardPaste(Model* model, uint32 linksMode = 0); bool FSClipboardPaste(Model* model, uint32 linksMode = 0);
void FSClipboardRemove(Model* model); void FSClipboardRemove(Model* model);
uint32 FSClipboardFindNodeMode(Model* model, bool autoLock, bool updateRefIfNeeded); uint32 FSClipboardFindNodeMode(Model* model, bool autoLock,
bool updateRefIfNeeded);
#endif // FS_CLIPBOARD_H #endif // FS_CLIPBOARD_H
+22 -17
View File
@@ -50,7 +50,8 @@ class UndoItemMove : public UndoItem {
/** source - list of file(s) that were moved. Assumes ownership. /** source - list of file(s) that were moved. Assumes ownership.
* origfolder - location it was moved from * origfolder - location it was moved from
*/ */
UndoItemMove(BObjectList<entry_ref>* sourceList, BDirectory &target, BList* pointList); UndoItemMove(BObjectList<entry_ref>* sourceList, BDirectory &target,
BList* pointList);
virtual ~UndoItemMove(); virtual ~UndoItemMove();
virtual status_t Undo(); virtual status_t Undo();
@@ -72,10 +73,12 @@ class UndoItemFolder : public UndoItem {
virtual status_t Redo(); virtual status_t Redo();
private: private:
/* this ref has two different meanings in the different states of this object: // this ref has two different meanings in the different states of
- Undo() - fRef indicates the folder that was created via FSCreateNewFolderIn(...) // this object:
- Redo() - fRef indicates the folder in which FSCreateNewFolderIn() should be performed // - Undo() - fRef indicates the folder that was created via
*/ // FSCreateNewFolderIn(...)
// - Redo() - fRef indicates the folder in which
// FSCreateNewFolderIn() should be performed
entry_ref fRef; entry_ref fRef;
}; };
@@ -169,8 +172,8 @@ Undo::Remove()
} }
MoveCopyUndo::MoveCopyUndo(BObjectList<entry_ref>* sourceList, BDirectory &dest, MoveCopyUndo::MoveCopyUndo(BObjectList<entry_ref>* sourceList,
BList* pointList, uint32 moveMode) BDirectory &dest, BList* pointList, uint32 moveMode)
{ {
if (moveMode == kMoveSelectionTo) if (moveMode == kMoveSelectionTo)
fUndo = new UndoItemMove(sourceList, dest, pointList); fUndo = new UndoItemMove(sourceList, dest, pointList);
@@ -200,8 +203,8 @@ RenameVolumeUndo::RenameVolumeUndo(BVolume &volume, const char* newName)
// #pragma mark - // #pragma mark -
UndoItemCopy::UndoItemCopy(BObjectList<entry_ref>* sourceList, BDirectory &target, UndoItemCopy::UndoItemCopy(BObjectList<entry_ref>* sourceList,
BList* /*pointList*/, uint32 moveMode) BDirectory &target, BList* /*pointList*/, uint32 moveMode)
: :
fSourceList(*sourceList), fSourceList(*sourceList),
fTargetList(*sourceList), fTargetList(*sourceList),
@@ -236,8 +239,8 @@ UndoItemCopy::Undo()
status_t status_t
UndoItemCopy::Redo() UndoItemCopy::Redo()
{ {
FSMoveToFolder(new BObjectList<entry_ref>(fSourceList), new BEntry(&fTargetRef), FSMoveToFolder(new BObjectList<entry_ref>(fSourceList),
FSUndoMoveMode(fMoveMode), NULL); new BEntry(&fTargetRef), FSUndoMoveMode(fMoveMode), NULL);
return B_OK; return B_OK;
} }
@@ -264,8 +267,8 @@ UndoItemCopy::UpdateEntry(BEntry* entry, const char* name)
// #pragma mark - // #pragma mark -
UndoItemMove::UndoItemMove(BObjectList<entry_ref>* sourceList, BDirectory &target, UndoItemMove::UndoItemMove(BObjectList<entry_ref>* sourceList,
BList* /*pointList*/) BDirectory &target, BList* /*pointList*/)
: :
fSourceList(*sourceList) fSourceList(*sourceList)
{ {
@@ -293,7 +296,8 @@ UndoItemMove::Undo()
ChangeListSource(*list, entry); ChangeListSource(*list, entry);
// FSMoveToFolder() owns its arguments // FSMoveToFolder() owns its arguments
FSMoveToFolder(list, new BEntry(&fSourceRef), FSUndoMoveMode(kMoveSelectionTo), NULL); FSMoveToFolder(list, new BEntry(&fSourceRef),
FSUndoMoveMode(kMoveSelectionTo), NULL);
return B_OK; return B_OK;
} }
@@ -303,8 +307,8 @@ status_t
UndoItemMove::Redo() UndoItemMove::Redo()
{ {
// FSMoveToFolder() owns its arguments // FSMoveToFolder() owns its arguments
FSMoveToFolder(new BObjectList<entry_ref>(fSourceList), new BEntry(&fTargetRef), FSMoveToFolder(new BObjectList<entry_ref>(fSourceList),
FSUndoMoveMode(kMoveSelectionTo), NULL); new BEntry(&fTargetRef), FSUndoMoveMode(kMoveSelectionTo), NULL);
return B_OK; return B_OK;
} }
@@ -384,7 +388,8 @@ UndoItemRename::Redo()
// #pragma mark - // #pragma mark -
UndoItemRenameVolume::UndoItemRenameVolume(BVolume &volume, const char* newName) UndoItemRenameVolume::UndoItemRenameVolume(BVolume &volume,
const char* newName)
: :
fVolume(volume), fVolume(volume),
fNewName(newName) fNewName(newName)
+80 -58
View File
@@ -124,9 +124,10 @@ status_t MoveItem(BEntry* entry, BDirectory* destDir, BPoint* loc,
ConflictCheckResult PreFlightNameCheck(BObjectList<entry_ref>* srcList, ConflictCheckResult PreFlightNameCheck(BObjectList<entry_ref>* srcList,
const BDirectory* destDir, int32* collisionCount, uint32 moveMode); const BDirectory* destDir, int32* collisionCount, uint32 moveMode);
status_t CheckName(uint32 moveMode, const BEntry* srcEntry, status_t CheckName(uint32 moveMode, const BEntry* srcEntry,
const BDirectory* destDir, bool multipleCollisions, ConflictCheckResult &); const BDirectory* destDir, bool multipleCollisions,
void CopyAttributes(CopyLoopControl* control, BNode* srcNode, BNode* destNode, void* buffer, ConflictCheckResult &);
size_t bufsize); void CopyAttributes(CopyLoopControl* control, BNode* srcNode,
BNode* destNode, void* buffer, size_t bufsize);
void CopyPoseLocation(BNode* src, BNode* dest); void CopyPoseLocation(BNode* src, BNode* dest);
bool DirectoryMatchesOrContains(const BEntry*, directory_which); bool DirectoryMatchesOrContains(const BEntry*, directory_which);
bool DirectoryMatchesOrContains(const BEntry*, const char* additionalPath, bool DirectoryMatchesOrContains(const BEntry*, const char* additionalPath,
@@ -177,11 +178,13 @@ static const char* kFileDeleteErrorString =
static const char* kReplaceManyStr = static const char* kReplaceManyStr =
B_TRANSLATE_MARK("Some items already exist in this folder with " B_TRANSLATE_MARK("Some items already exist in this folder with "
"the same names as the items you are %verb.\n \nWould you like to replace " "the same names as the items you are %verb.\n \nWould you like to "
"them with the ones you are %verb or be prompted for each one?"); "replace them with the ones you are %verb or be prompted for each "
"one?");
static const char* kFindAlternativeStr = static const char* kFindAlternativeStr =
B_TRANSLATE_MARK("Would you like to find some other suitable application?"); B_TRANSLATE_MARK("Would you like to find some other suitable "
"application?");
static const char* kFindApplicationStr = static const char* kFindApplicationStr =
B_TRANSLATE_MARK("Would you like to find a suitable application " B_TRANSLATE_MARK("Would you like to find a suitable application "
@@ -635,21 +638,21 @@ ConfirmChangeIfWellKnownDirectory(const BEntry* entry,
if (DirectoryMatchesOrContains(entry, B_SYSTEM_DIRECTORY)) { if (DirectoryMatchesOrContains(entry, B_SYSTEM_DIRECTORY)) {
warning.SetTo( warning.SetTo(
B_TRANSLATE("If you %ifYouDoAction the system folder or its " B_TRANSLATE("If you %ifYouDoAction the system folder or its "
"contents, you won't be able to boot %osName!\n\nAre you sure you " "contents, you won't be able to boot %osName!\n\nAre you sure "
"want to do this?\n\nTo %toDoAction the system folder or its " "you want to do this?\n\nTo %toDoAction the system folder or its "
"contents anyway, hold down the Shift key and click " "contents anyway, hold down the Shift key and click "
"\"%toConfirmAction\".")); "\"%toConfirmAction\"."));
} else if (DirectoryMatches(entry, B_COMMON_DIRECTORY)) { } else if (DirectoryMatches(entry, B_COMMON_DIRECTORY)) {
warning.SetTo( warning.SetTo(
B_TRANSLATE("If you %ifYouDoAction the common folder, %osName " B_TRANSLATE("If you %ifYouDoAction the common folder, %osName "
"may not behave properly!\n\nAre you sure you want to do this?\n\n" "may not behave properly!\n\nAre you sure you want to do this?"
"To %toDoAction the common folder anyway, hold down the " "\n\nTo %toDoAction the common folder anyway, hold down the "
"Shift key and click \"%toConfirmAction\".")); "Shift key and click \"%toConfirmAction\"."));
} else if (DirectoryMatches(entry, B_USER_DIRECTORY)) { } else if (DirectoryMatches(entry, B_USER_DIRECTORY)) {
warning .SetTo( warning .SetTo(
B_TRANSLATE("If you %ifYouDoAction the home folder, %osName " B_TRANSLATE("If you %ifYouDoAction the home folder, %osName "
"may not behave properly!\n\nAre you sure you want to do this?\n\n" "may not behave properly!\n\nAre you sure you want to do this?"
"To %toDoAction the home folder anyway, hold down the " "\n\nTo %toDoAction the home folder anyway, hold down the "
"Shift key and click \"%toConfirmAction\".")); "Shift key and click \"%toConfirmAction\"."));
} else if (DirectoryMatchesOrContains(entry, B_USER_CONFIG_DIRECTORY) } else if (DirectoryMatchesOrContains(entry, B_USER_CONFIG_DIRECTORY)
|| DirectoryMatchesOrContains(entry, B_COMMON_SETTINGS_DIRECTORY)) { || DirectoryMatchesOrContains(entry, B_COMMON_SETTINGS_DIRECTORY)) {
@@ -660,21 +663,21 @@ ConfirmChangeIfWellKnownDirectory(const BEntry* entry,
B_COMMON_SETTINGS_DIRECTORY)) { B_COMMON_SETTINGS_DIRECTORY)) {
warning.SetTo( warning.SetTo(
B_TRANSLATE("If you %ifYouDoAction the mime settings, " B_TRANSLATE("If you %ifYouDoAction the mime settings, "
"%osName may not behave properly!\n\nAre you sure you want to " "%osName may not behave properly!\n\nAre you sure you want "
"do this?")); "to do this?"));
requireOverride = false; requireOverride = false;
} else if (DirectoryMatches(entry, B_USER_CONFIG_DIRECTORY)) { } else if (DirectoryMatches(entry, B_USER_CONFIG_DIRECTORY)) {
warning.SetTo( warning.SetTo(
B_TRANSLATE("If you %ifYouDoAction the config folder, %osName " B_TRANSLATE("If you %ifYouDoAction the config folder, "
"may not behave properly!\n\nAre you sure you want to do " "%osName may not behave properly!\n\nAre you sure you want "
"this?")); "to do this?"));
requireOverride = false; requireOverride = false;
} else if (DirectoryMatches(entry, B_USER_SETTINGS_DIRECTORY) } else if (DirectoryMatches(entry, B_USER_SETTINGS_DIRECTORY)
|| DirectoryMatches(entry, B_COMMON_SETTINGS_DIRECTORY)) { || DirectoryMatches(entry, B_COMMON_SETTINGS_DIRECTORY)) {
warning.SetTo( warning.SetTo(
B_TRANSLATE("If you %ifYouDoAction the settings folder, " B_TRANSLATE("If you %ifYouDoAction the settings folder, "
"%osName may not behave properly!\n\nAre you sure you want to " "%osName may not behave properly!\n\nAre you sure you want "
"do this?")); "to do this?"));
requireOverride = false; requireOverride = false;
} }
} }
@@ -752,11 +755,13 @@ InitCopy(CopyLoopControl* loopControl, uint32 moveMode,
"directory.")); "directory."));
} else { } else {
errorStr.SetTo( errorStr.SetTo(
B_TRANSLATE("You cannot copy or move the root directory.")); B_TRANSLATE("You cannot copy or move the root "
"directory."));
} }
BAlert* alert = new BAlert("", errorStr.String(), BAlert* alert = new BAlert("", errorStr.String(),
B_TRANSLATE("Cancel"), 0, 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT); B_TRANSLATE("Cancel"), 0, 0, B_WIDTH_AS_USUAL,
B_WARNING_ALERT);
alert->SetShortcut(0, B_ESCAPE); alert->SetShortcut(0, B_ESCAPE);
alert->Go(); alert->Go();
return B_ERROR; return B_ERROR;
@@ -783,11 +788,13 @@ InitCopy(CopyLoopControl* loopControl, uint32 moveMode,
*preflightResult = kPrompt; *preflightResult = kPrompt;
*collisionCount = 0; *collisionCount = 0;
*preflightResult = PreFlightNameCheck(srcList, destDir, collisionCount, *preflightResult = PreFlightNameCheck(srcList, destDir,
moveMode); collisionCount, moveMode);
if (*preflightResult == kCanceled) // user canceled if (*preflightResult == kCanceled) {
// user canceled
return B_ERROR; return B_ERROR;
} }
}
// set up the status display // set up the status display
switch (moveMode) { switch (moveMode) {
@@ -802,7 +809,8 @@ InitCopy(CopyLoopControl* loopControl, uint32 moveMode,
off_t totalSize = 0; off_t totalSize = 0;
if (needSizeCalculation) { if (needSizeCalculation) {
if (CalcItemsAndSize(loopControl, srcList, if (CalcItemsAndSize(loopControl, srcList,
dstVol->BlockSize(), &totalItems, &totalSize) != B_OK) { dstVol->BlockSize(), &totalItems, &totalSize)
!= B_OK) {
return B_ERROR; return B_ERROR;
} }
@@ -997,7 +1005,8 @@ MoveTask(BObjectList<entry_ref>* srcList, BEntry* destEntry, BList* pointList,
result = MoveEntryToTrash(&sourceEntry, loc, undo); result = MoveEntryToTrash(&sourceEntry, loc, undo);
if (result != B_OK) { if (result != B_OK) {
BString error(B_TRANSLATE("Error moving \"%name\" to Trash. (%error)")); BString error(B_TRANSLATE("Error moving \"%name\" to Trash. "
"(%error)"));
error.ReplaceFirst("%name", srcRef->name); error.ReplaceFirst("%name", srcRef->name);
error.ReplaceFirst("%error", strerror(result)); error.ReplaceFirst("%error", strerror(result));
BAlert* alert = new BAlert("", error.String(), BAlert* alert = new BAlert("", error.String(),
@@ -1011,8 +1020,8 @@ MoveTask(BObjectList<entry_ref>* srcList, BEntry* destEntry, BList* pointList,
} }
// resolve name collisions and hierarchy problems // resolve name collisions and hierarchy problems
if (CheckName(moveMode, &sourceEntry, &destDir, collisionCount > 1, if (CheckName(moveMode, &sourceEntry, &destDir,
conflictCheckResult) != B_OK) { collisionCount > 1, conflictCheckResult) != B_OK) {
// we will skip the current item, because we got a conflict // we will skip the current item, because we got a conflict
// and were asked to or because there was some conflict // and were asked to or because there was some conflict
@@ -1160,8 +1169,9 @@ CopyFile(BEntry* srcFile, StatStruct* srcStat, BDirectory* destDir,
throw (status_t)err; throw (status_t)err;
if (err != B_OK) { if (err != B_OK) {
if (!loopControl->FileError(B_TRANSLATE_NOCOLLECT(kFileErrorString), if (!loopControl->FileError(
destName, err, true)) { B_TRANSLATE_NOCOLLECT(kFileErrorString), destName, err,
true)) {
throw (status_t)err; throw (status_t)err;
} else { } else {
// user selected continue in spite of error, update status bar // user selected continue in spite of error, update status bar
@@ -1176,7 +1186,8 @@ CopyFile(BEntry* srcFile, StatStruct* srcStat, BDirectory* destDir,
static bool static bool
CreateFileSystemCompatibleName(const BDirectory* destDir, char* destName) CreateFileSystemCompatibleName(const BDirectory* destDir, char* destName)
{ {
// Is it a FAT32 file system? (this is the only one we currently now about) // Is it a FAT32 file system?
// (this is the only one we currently know about)
BEntry target; BEntry target;
destDir->GetEntry(&target); destDir->GetEntry(&target);
@@ -1412,8 +1423,9 @@ CopyAttributes(CopyLoopControl* control, BNode* srcNode, BNode* destNode,
static void static void
CopyFolder(BEntry* srcEntry, BDirectory* destDir, CopyLoopControl* loopControl, CopyFolder(BEntry* srcEntry, BDirectory* destDir,
BPoint* loc, bool makeOriginalName, Undo &undo, bool removeSource = false) CopyLoopControl* loopControl, BPoint* loc, bool makeOriginalName,
Undo &undo, bool removeSource = false)
{ {
BDirectory newDir; BDirectory newDir;
BEntry entry; BEntry entry;
@@ -1669,7 +1681,8 @@ MoveItem(BEntry* entry, BDirectory* destDir, BPoint* loc, uint32 moveMode,
// else source and target are in the same dir // else source and target are in the same dir
source.Append(path.Leaf()); source.Append(path.Leaf());
err = destDir->CreateSymLink(name, source.String(), &link); err = destDir->CreateSymLink(name, source.String(),
&link);
chdir(oldwd); chdir(oldwd);
// change working dir back to original // change working dir back to original
@@ -1871,7 +1884,8 @@ MoveEntryToTrash(BEntry* entry, BPoint* loc, Undo &undo)
if (volume == boot) { if (volume == boot) {
char name[B_FILE_NAME_LENGTH]; char name[B_FILE_NAME_LENGTH];
volume.GetName(name); volume.GetName(name);
BString buffer(B_TRANSLATE("Cannot unmount the boot volume \"%name\".")); BString buffer(
B_TRANSLATE("Cannot unmount the boot volume \"%name\"."));
buffer.ReplaceFirst("%name", name); buffer.ReplaceFirst("%name", name);
BAlert* alert = new BAlert("", buffer.String(), BAlert* alert = new BAlert("", buffer.String(),
B_TRANSLATE("Cancel"), 0, 0, B_WIDTH_AS_USUAL, B_TRANSLATE("Cancel"), 0, 0, B_WIDTH_AS_USUAL,
@@ -2060,7 +2074,8 @@ CheckName(uint32 moveMode, const BEntry* sourceEntry,
&& moveMode != kCreateRelativeLink) { && moveMode != kCreateRelativeLink) {
(new BAlert("", (new BAlert("",
B_TRANSLATE("You can't move or copy the trash."), B_TRANSLATE("You can't move or copy the trash."),
B_TRANSLATE("OK"), 0, 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go(); B_TRANSLATE("OK"), 0, 0, B_WIDTH_AS_USUAL,
B_WARNING_ALERT))->Go();
return B_ERROR; return B_ERROR;
} }
@@ -2092,7 +2107,8 @@ CheckName(uint32 moveMode, const BEntry* sourceEntry,
} }
} }
// Ensure user isn't trying to replace a file with folder or vice versa. // ensure that the user isn't trying to replace a file with folder
// or vice-versa
if (moveMode != kCreateLink if (moveMode != kCreateLink
&& moveMode != kCreateRelativeLink && moveMode != kCreateRelativeLink
&& destIsDir != sourceIsDirectory) { && destIsDir != sourceIsDirectory) {
@@ -2107,7 +2123,6 @@ CheckName(uint32 moveMode, const BEntry* sourceEntry,
if (replaceAll != kReplaceAll) { if (replaceAll != kReplaceAll) {
// prompt user to determine whether to replace or not // prompt user to determine whether to replace or not
BString replaceMsg; BString replaceMsg;
if (moveMode == kCreateLink || moveMode == kCreateRelativeLink) { if (moveMode == kCreateLink || moveMode == kCreateRelativeLink) {
@@ -2176,7 +2191,8 @@ CheckName(uint32 moveMode, const BEntry* sourceEntry,
return B_OK; return B_OK;
if (err != B_OK) { if (err != B_OK) {
BString error(B_TRANSLATE("There was a problem trying to replace \"%name\". The item might be open or busy.")); BString error(B_TRANSLATE("There was a problem trying to replace "
"\"%name\". The item might be open or busy."));
error.ReplaceFirst("%name", name);; error.ReplaceFirst("%name", name);;
BAlert* alert = new BAlert("", error.String(), BAlert* alert = new BAlert("", error.String(),
B_TRANSLATE("Cancel"), 0, 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT); B_TRANSLATE("Cancel"), 0, 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
@@ -2381,8 +2397,9 @@ FSRecursiveCalcSize(BInfoWindow* window, CopyLoopControl* loopControl,
status_t status_t
CalcItemsAndSize(CopyLoopControl* loopControl, BObjectList<entry_ref>* refList, CalcItemsAndSize(CopyLoopControl* loopControl,
ssize_t blockSize, int32* totalCount, off_t* totalSize) BObjectList<entry_ref>* refList, ssize_t blockSize, int32* totalCount,
off_t* totalSize)
{ {
int32 fileCount = 0; int32 fileCount = 0;
int32 dirCount = 0; int32 dirCount = 0;
@@ -2488,8 +2505,8 @@ FSGetTrashDir(BDirectory* trashDir, dev_t dev)
if (data != NULL) if (data != NULL)
trashDir->WriteAttr(kAttrMiniIcon, 'MICN', 0, data, size); trashDir->WriteAttr(kAttrMiniIcon, 'MICN', 0, data, size);
data = GetTrackerResources()->LoadResource(B_VECTOR_ICON_TYPE, R_TrashIcon, data = GetTrackerResources()->LoadResource(B_VECTOR_ICON_TYPE,
&size); R_TrashIcon, &size);
if (data != NULL) if (data != NULL)
trashDir->WriteAttr(kAttrIcon, B_VECTOR_ICON_TYPE, 0, data, size); trashDir->WriteAttr(kAttrIcon, B_VECTOR_ICON_TYPE, 0, data, size);
@@ -3228,14 +3245,15 @@ _TrackerLaunchAppWithDocuments(const entry_ref* appRef, const BMessage* refs,
if (refs && openWithOK && error != B_SHUTTING_DOWN) { if (refs && openWithOK && error != B_SHUTTING_DOWN) {
alertString << B_TRANSLATE_NOCOLLECT(kFindAlternativeStr); alertString << B_TRANSLATE_NOCOLLECT(kFindAlternativeStr);
BAlert* alert = new BAlert("", alertString.String(), BAlert* alert = new BAlert("", alertString.String(),
B_TRANSLATE("Cancel"), B_TRANSLATE("Find"), 0, B_WIDTH_AS_USUAL, B_TRANSLATE("Cancel"), B_TRANSLATE("Find"), 0,
B_WARNING_ALERT); B_WIDTH_AS_USUAL, B_WARNING_ALERT);
alert->SetShortcut(0, B_ESCAPE); alert->SetShortcut(0, B_ESCAPE);
if (alert->Go() == 1) if (alert->Go() == 1)
error = TrackerOpenWith(refs); error = TrackerOpenWith(refs);
} else { } else {
BAlert* alert = new BAlert("", alertString.String(), BAlert* alert = new BAlert("", alertString.String(),
B_TRANSLATE("Cancel"), 0, 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT); B_TRANSLATE("Cancel"), 0, 0, B_WIDTH_AS_USUAL,
B_WARNING_ALERT);
alert->SetShortcut(0, B_ESCAPE); alert->SetShortcut(0, B_ESCAPE);
alert->Go(); alert->Go();
} }
@@ -3389,8 +3407,8 @@ _TrackerLaunchDocuments(const entry_ref* /*doNotUse*/, const BMessage* refs,
} else { } else {
BEntry appEntry(&app, true); BEntry appEntry(&app, true);
for (int32 index = 0;;) { for (int32 index = 0;;) {
// remove the app itself from the refs received so we don't try // remove the app itself from the refs received so we don't
// to open ourselves // try to open ourselves
entry_ref ref; entry_ref ref;
if (copyOfRefs.FindRef("refs", index, &ref) != B_OK) if (copyOfRefs.FindRef("refs", index, &ref) != B_OK)
break; break;
@@ -3483,15 +3501,18 @@ _TrackerLaunchDocuments(const entry_ref* /*doNotUse*/, const BMessage* refs,
&& LoaderErrorDetails(&app, loaderErrorString) == B_OK) { && LoaderErrorDetails(&app, loaderErrorString) == B_OK) {
if (openedDocuments) { if (openedDocuments) {
alertString.SetTo(B_TRANSLATE("Could not open \"%document\" " alertString.SetTo(B_TRANSLATE("Could not open \"%document\" "
"with application \"%app\" (Missing symbol: %symbol). \n")); "with application \"%app\" (Missing symbol: %symbol). "
"\n"));
alertString.ReplaceFirst("%document", documentRef.name); alertString.ReplaceFirst("%document", documentRef.name);
alertString.ReplaceFirst("%app", app.name); alertString.ReplaceFirst("%app", app.name);
alertString.ReplaceFirst("%symbol", loaderErrorString.String()); alertString.ReplaceFirst("%symbol",
loaderErrorString.String());
} else { } else {
alertString.SetTo(B_TRANSLATE("Could not open \"%document\" " alertString.SetTo(B_TRANSLATE("Could not open \"%document\" "
"(Missing symbol: %symbol). \n")); "(Missing symbol: %symbol). \n"));
alertString.ReplaceFirst("%document", documentRef.name); alertString.ReplaceFirst("%document", documentRef.name);
alertString.ReplaceFirst("%symbol", loaderErrorString.String()); alertString.ReplaceFirst("%symbol",
loaderErrorString.String());
} }
alternative = B_TRANSLATE_NOCOLLECT(kFindAlternativeStr); alternative = B_TRANSLATE_NOCOLLECT(kFindAlternativeStr);
} else if (error == B_MISSING_LIBRARY } else if (error == B_MISSING_LIBRARY
@@ -3502,12 +3523,14 @@ _TrackerLaunchDocuments(const entry_ref* /*doNotUse*/, const BMessage* refs,
"\n")); "\n"));
alertString.ReplaceFirst("%document", documentRef.name); alertString.ReplaceFirst("%document", documentRef.name);
alertString.ReplaceFirst("%app", app.name); alertString.ReplaceFirst("%app", app.name);
alertString.ReplaceFirst("%library", loaderErrorString.String()); alertString.ReplaceFirst("%library",
loaderErrorString.String());
} else { } else {
alertString.SetTo(B_TRANSLATE("Could not open \"%document\" " alertString.SetTo(B_TRANSLATE("Could not open \"%document\" "
"(Missing libraries: %library). \n")); "(Missing libraries: %library). \n"));
alertString.ReplaceFirst("%document", documentRef.name); alertString.ReplaceFirst("%document", documentRef.name);
alertString.ReplaceFirst("%library", loaderErrorString.String()); alertString.ReplaceFirst("%library",
loaderErrorString.String());
} }
alternative = B_TRANSLATE_NOCOLLECT(kFindAlternativeStr); alternative = B_TRANSLATE_NOCOLLECT(kFindAlternativeStr);
} else { } else {
@@ -3525,14 +3548,15 @@ _TrackerLaunchDocuments(const entry_ref* /*doNotUse*/, const BMessage* refs,
ASSERT(alternative); ASSERT(alternative);
alertString << alternative; alertString << alternative;
BAlert* alert = new BAlert("", alertString.String(), BAlert* alert = new BAlert("", alertString.String(),
B_TRANSLATE("Cancel"), B_TRANSLATE("Find"), 0, B_WIDTH_AS_USUAL, B_TRANSLATE("Cancel"), B_TRANSLATE("Find"), 0,
B_WARNING_ALERT); B_WIDTH_AS_USUAL, B_WARNING_ALERT);
alert->SetShortcut(0, B_ESCAPE); alert->SetShortcut(0, B_ESCAPE);
if (alert->Go() == 1) if (alert->Go() == 1)
error = TrackerOpenWith(refs); error = TrackerOpenWith(refs);
} else { } else {
BAlert* alert = new BAlert("", alertString.String(), BAlert* alert = new BAlert("", alertString.String(),
B_TRANSLATE("Cancel"), 0, 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT); B_TRANSLATE("Cancel"), 0, 0, B_WIDTH_AS_USUAL,
B_WARNING_ALERT);
alert->SetShortcut(0, B_ESCAPE); alert->SetShortcut(0, B_ESCAPE);
alert->Go(); alert->Go();
} }
@@ -3841,8 +3865,6 @@ WellKnowEntryList::WellKnowEntryList()
AddOne((directory_which)B_USER_QUERIES_DIRECTORY, B_USER_DIRECTORY, AddOne((directory_which)B_USER_QUERIES_DIRECTORY, B_USER_DIRECTORY,
"queries", "queries"); "queries", "queries");
AddOne(B_COMMON_DEVELOP_DIRECTORY, "develop"); AddOne(B_COMMON_DEVELOP_DIRECTORY, "develop");
AddOne((directory_which)B_USER_DESKBAR_DEVELOP_DIRECTORY, AddOne((directory_which)B_USER_DESKBAR_DEVELOP_DIRECTORY,
B_USER_DESKBAR_DIRECTORY, "Development", "develop"); B_USER_DESKBAR_DIRECTORY, "Development", "develop");
+44 -35
View File
@@ -46,7 +46,7 @@ All rights reserved.
#include "ObjectList.h" #include "ObjectList.h"
// Note - APIs/code in FSUtils.h and FSUtils.cpp is slated for a major cleanup // APIs/code in FSUtils.h and FSUtils.cpp is slated for a major cleanup
// -- in other words, you will find a lot of ugly cruft in here // -- in other words, you will find a lot of ugly cruft in here
class BDirectory; class BDirectory;
@@ -87,7 +87,7 @@ public:
kReplace, // remove entry before copying new one kReplace, // remove entry before copying new one
kMerge // for folders: leave existing folder, update kMerge // for folders: leave existing folder, update
// contents leaving nonconflicting items // contents leaving nonconflicting items
// for files: save original attributes on file. // for files: save original attributes on file
}; };
//! Override to always overwrite, never overwrite, let user decide, //! Override to always overwrite, never overwrite, let user decide,
@@ -165,36 +165,39 @@ private:
#endif #endif
_IMPEXP_TRACKER status_t FSCopyAttributesAndStats(BNode*, BNode*); _IMPEXP_TRACKER status_t FSCopyAttributesAndStats(BNode*, BNode*);
_IMPEXP_TRACKER void FSDuplicate(BObjectList<entry_ref>* srcList, BList* pointList); _IMPEXP_TRACKER void FSDuplicate(BObjectList<entry_ref>* srcList,
_IMPEXP_TRACKER void FSMoveToFolder(BObjectList<entry_ref>* srcList, BEntry*, uint32 moveMode, BList* pointList);
BList* pointList = NULL); _IMPEXP_TRACKER void FSMoveToFolder(BObjectList<entry_ref>* srcList, BEntry*,
_IMPEXP_TRACKER void FSMakeOriginalName(char* name, BDirectory* destDir, const char* suffix); uint32 moveMode, BList* pointList = NULL);
_IMPEXP_TRACKER void FSMakeOriginalName(char* name, BDirectory* destDir,
const char* suffix);
_IMPEXP_TRACKER bool FSIsTrashDir(const BEntry*); _IMPEXP_TRACKER bool FSIsTrashDir(const BEntry*);
_IMPEXP_TRACKER bool FSIsPrintersDir(const BEntry*); _IMPEXP_TRACKER bool FSIsPrintersDir(const BEntry*);
_IMPEXP_TRACKER bool FSIsDeskDir(const BEntry*); _IMPEXP_TRACKER bool FSIsDeskDir(const BEntry*);
_IMPEXP_TRACKER bool FSIsHomeDir(const BEntry*); _IMPEXP_TRACKER bool FSIsHomeDir(const BEntry*);
_IMPEXP_TRACKER bool FSIsRootDir(const BEntry*); _IMPEXP_TRACKER bool FSIsRootDir(const BEntry*);
_IMPEXP_TRACKER void FSMoveToTrash(BObjectList<entry_ref>* srcList, BList* pointList = NULL, _IMPEXP_TRACKER void FSMoveToTrash(BObjectList<entry_ref>* srcList,
bool async = true); BList* pointList = NULL, bool async = true);
// Deprecated // Deprecated
void FSDeleteRefList(BObjectList<entry_ref>*, bool, bool confirm = true); void FSDeleteRefList(BObjectList<entry_ref>*, bool, bool confirm = true);
void FSDelete(entry_ref*, bool, bool confirm = true); void FSDelete(entry_ref*, bool, bool confirm = true);
void FSRestoreRefList(BObjectList<entry_ref>* list, bool async); void FSRestoreRefList(BObjectList<entry_ref>* list, bool async);
_IMPEXP_TRACKER status_t FSLaunchItem(const entry_ref* application, const BMessage* refsReceived, _IMPEXP_TRACKER status_t FSLaunchItem(const entry_ref* application,
bool async, bool openWithOK); const BMessage* refsReceived, bool async, bool openWithOK);
// Preferred way of launching; only pass an actual application in <application>, not // Preferred way of launching; only pass an actual application in
// a document; to open documents with the preferred app, pase 0 in <application> and // <application>, not a document; to open documents with the preferred
// stuff all the document refs into <refsReceived> // app, pase 0 in <application> and stuff all the document refs into
// Consider having silent mode that does not show alerts, just returns error code // <refsReceived> Consider having silent mode that does not show alerts,
// just returns error code
_IMPEXP_TRACKER status_t FSOpenWith(BMessage* listOfRefs); _IMPEXP_TRACKER status_t FSOpenWith(BMessage* listOfRefs);
// runs the Open With window; pas a list of refs // runs the Open With window; pas a list of refs
_IMPEXP_TRACKER void FSEmptyTrash(); _IMPEXP_TRACKER void FSEmptyTrash();
_IMPEXP_TRACKER status_t FSCreateNewFolderIn(const node_ref* destDir, entry_ref* newRef, _IMPEXP_TRACKER status_t FSCreateNewFolderIn(const node_ref* destDir,
node_ref* new_node); entry_ref* newRef, node_ref* new_node);
_IMPEXP_TRACKER void FSCreateTrashDirs(); _IMPEXP_TRACKER void FSCreateTrashDirs();
_IMPEXP_TRACKER status_t FSGetTrashDir(BDirectory* trashDir, dev_t volume); _IMPEXP_TRACKER status_t FSGetTrashDir(BDirectory* trashDir, dev_t volume);
_IMPEXP_TRACKER status_t FSGetDeskDir(BDirectory* deskDir); _IMPEXP_TRACKER status_t FSGetDeskDir(BDirectory* deskDir);
@@ -218,23 +221,26 @@ enum ReadAttrResult {
kReadAttrForeignOK kReadAttrForeignOK
}; };
ReadAttrResult ReadAttr(const BNode*, const char* hostAttrName, const char* foreignAttrName, ReadAttrResult ReadAttr(const BNode*, const char* hostAttrName,
type_code , off_t , void*, size_t , void (*swapFunc)(void*) = 0, const char* foreignAttrName, type_code, off_t, void*, size_t,
bool isForeign = false); void (*swapFunc)(void*) = 0, bool isForeign = false);
// Endian swapping ReadAttr call; endianness is determined by trying first the // Endian swapping ReadAttr call; endianness is determined by trying
// native attribute name, then the foreign one; an endian swapping function can // first the native attribute name, then the foreign one; an endian
// be passed, if null data won't be swapped; if <isForeign> set the foreign endianness // swapping function can be passed, if null data won't be swapped;
// will be read directly without first trying the native one // if <isForeign> set the foreign endianness will be read directly
// without first trying the native one
ReadAttrResult GetAttrInfo(const BNode*, const char* hostAttrName, const char* foreignAttrName, ReadAttrResult GetAttrInfo(const BNode*, const char* hostAttrName,
type_code* = NULL, size_t* = NULL); const char* foreignAttrName, type_code* = NULL, size_t* = NULL);
status_t FSCreateNewFolder(const entry_ref*); status_t FSCreateNewFolder(const entry_ref*);
status_t FSRecursiveCreateFolder(const char* path); status_t FSRecursiveCreateFolder(const char* path);
void FSMakeOriginalName(BString &name, const BDirectory* destDir, const char* suffix = 0); void FSMakeOriginalName(BString &name, const BDirectory* destDir,
const char* suffix = 0);
status_t TrackerLaunch(const entry_ref* app, bool async); status_t TrackerLaunch(const entry_ref* app, bool async);
status_t TrackerLaunch(const BMessage* refs, bool async, bool okToRunOpenWith = true); status_t TrackerLaunch(const BMessage* refs, bool async,
bool okToRunOpenWith = true);
status_t TrackerLaunch(const entry_ref* app, const BMessage* refs, bool async, status_t TrackerLaunch(const entry_ref* app, const BMessage* refs, bool async,
bool okToRunOpenWith = true); bool okToRunOpenWith = true);
status_t LaunchBrokenLink(const char*, const BMessage*); status_t LaunchBrokenLink(const char*, const BMessage*);
@@ -243,9 +249,9 @@ status_t FSFindTrackerSettingsDir(BPath*, bool autoCreate = true);
bool FSIsDeskDir(const BEntry*); bool FSIsDeskDir(const BEntry*);
// two separate ifYouDoAction and toDoAction versions are needed for localization // two separate ifYouDoAction and toDoAction versions are needed for
// purposes. The first one is used in "If you do action ..." sentence, // localization purposes. The first one is used in "If you do action..."
// the second one in the "To do action" sentence. // sentence, the second one in the "To do action" sentence.
bool ConfirmChangeIfWellKnownDirectory(const BEntry* entry, bool ConfirmChangeIfWellKnownDirectory(const BEntry* entry,
const char* ifYouDoAction, const char* toDoAction, const char* ifYouDoAction, const char* toDoAction,
const char* toConfirmAction, bool dontAsk = false, const char* toConfirmAction, bool dontAsk = false,
@@ -254,12 +260,14 @@ bool ConfirmChangeIfWellKnownDirectory(const BEntry* entry,
bool CheckDevicesEqual(const entry_ref* entry, const Model* targetModel); bool CheckDevicesEqual(const entry_ref* entry, const Model* targetModel);
// Deprecated calls use newer calls above instead // Deprecated calls use newer calls above instead
_IMPEXP_TRACKER void FSLaunchItem(const entry_ref*, BMessage* = NULL, int32 workspace = -1); _IMPEXP_TRACKER void FSLaunchItem(const entry_ref*, BMessage* = NULL,
int32 workspace = -1);
_IMPEXP_TRACKER status_t FSLaunchItem(const entry_ref*, BMessage*, _IMPEXP_TRACKER status_t FSLaunchItem(const entry_ref*, BMessage*,
int32 workspace, bool asynch); int32 workspace, bool asynch);
_IMPEXP_TRACKER void FSOpenWithDocuments(const entry_ref* executableToLaunch, _IMPEXP_TRACKER void FSOpenWithDocuments(const entry_ref* executableToLaunch,
BMessage* documentEntryRefs); BMessage* documentEntryRefs);
_IMPEXP_TRACKER status_t FSLaunchUsing(const entry_ref* ref, BMessage* listOfRefs); _IMPEXP_TRACKER status_t FSLaunchUsing(const entry_ref* ref,
BMessage* listOfRefs);
// some extra directory_which values // some extra directory_which values
@@ -279,7 +287,8 @@ class WellKnowEntryList {
// system hierarchy // system hierarchy
public: public:
struct WellKnownEntry { struct WellKnownEntry {
WellKnownEntry(const node_ref* node, directory_which which, const char* name) WellKnownEntry(const node_ref* node, directory_which which,
const char* name)
: :
node(*node), node(*node),
which(which), which(which),
@@ -314,8 +323,8 @@ class WellKnowEntryList {
WellKnowEntryList(); WellKnowEntryList();
void AddOne(directory_which, const char* name); void AddOne(directory_which, const char* name);
void AddOne(directory_which, const char* path, const char* name); void AddOne(directory_which, const char* path, const char* name);
void AddOne(directory_which, directory_which base, const char* extension, void AddOne(directory_which, directory_which base,
const char* name); const char* extension, const char* name);
std::vector<WellKnownEntry> entries; std::vector<WellKnownEntry> entries;
static WellKnowEntryList* self; static WellKnowEntryList* self;
+11 -6
View File
@@ -124,7 +124,8 @@ FavoritesMenu::AddNextItem()
try { try {
BPath path; BPath path;
ThrowOnError( find_directory (B_USER_SETTINGS_DIRECTORY, &path, true) ); ThrowOnError(find_directory(B_USER_SETTINGS_DIRECTORY,
&path, true));
path.Append(kGoDirectory); path.Append(kGoDirectory);
mkdir(path.Path(), 0777); mkdir(path.Path(), 0777);
@@ -169,7 +170,8 @@ FavoritesMenu::AddNextItem()
if (item == NULL) if (item == NULL)
return true; return true;
item->SetLabel(ref.name); // this is the name of the link in the Go dir item->SetLabel(ref.name);
// this is the name of the link in the Go dir
if (!fAddedSeparatorForSection) { if (!fAddedSeparatorForSection) {
fAddedSeparatorForSection = true; fAddedSeparatorForSection = true;
@@ -214,7 +216,8 @@ FavoritesMenu::AddNextItem()
if (!ShouldShowModel(&model)) if (!ShouldShowModel(&model))
return true; return true;
BMenuItem* item = BNavMenu::NewModelItem(&model, fOpenFileMessage, fTarget); BMenuItem* item = BNavMenu::NewModelItem(&model,
fOpenFileMessage, fTarget);
if (item) { if (item) {
if (!fAddedSeparatorForSection) { if (!fAddedSeparatorForSection) {
fAddedSeparatorForSection = true; fAddedSeparatorForSection = true;
@@ -252,8 +255,10 @@ FavoritesMenu::AddNextItem()
// don't add folders that are already in the GoTo section // don't add folders that are already in the GoTo section
if (find_if(fUniqueRefCheck.begin(), fUniqueRefCheck.end(), if (find_if(fUniqueRefCheck.begin(), fUniqueRefCheck.end(),
bind2nd(std::equal_to<entry_ref>(), ref)) != fUniqueRefCheck.end()) bind2nd(std::equal_to<entry_ref>(), ref))
!= fUniqueRefCheck.end()) {
continue; continue;
}
Model model(&ref, true); Model model(&ref, true);
if (model.InitCheck() != B_OK) if (model.InitCheck() != B_OK)
@@ -262,8 +267,8 @@ FavoritesMenu::AddNextItem()
if (!ShouldShowModel(&model)) if (!ShouldShowModel(&model))
return true; return true;
BMenuItem* item = BNavMenu::NewModelItem(&model, fOpenFolderMessage, BMenuItem* item = BNavMenu::NewModelItem(&model,
fTarget, true); fOpenFolderMessage, fTarget, true);
if (item) { if (item) {
if (!fAddedSeparatorForSection) { if (!fAddedSeparatorForSection) {
fAddedSeparatorForSection = true; fAddedSeparatorForSection = true;
+2 -1
View File
@@ -111,7 +111,8 @@ enum recent_type {
class RecentsMenu : public BNavMenu { class RecentsMenu : public BNavMenu {
public: public:
RecentsMenu(const char* name,int32 which,uint32 what,BHandler* target); RecentsMenu(const char* name, int32 which, uint32 what,
BHandler* target);
void DetachedFromWindow(); void DetachedFromWindow();
+93 -49
View File
@@ -507,7 +507,8 @@ TFilePanel::AdjustButton()
if (!button) if (!button)
return; return;
BTextControl* textControl = dynamic_cast<BTextControl*>(FindView("text view")); BTextControl* textControl
= dynamic_cast<BTextControl*>(FindView("text view"));
BObjectList<BPose>* selectionList = fPoseView->SelectionList(); BObjectList<BPose>* selectionList = fPoseView->SelectionList();
BString buttonText = fButtonText; BString buttonText = fButtonText;
bool enabled = false; bool enabled = false;
@@ -522,7 +523,8 @@ TFilePanel::AdjustButton()
enabled = true; enabled = true;
buttonText = B_TRANSLATE("Open"); buttonText = B_TRANSLATE("Open");
} else { } else {
// insert the name of the selected model into the text field // insert the name of the selected model into
// the text field
textControl->SetText(model->Name()); textControl->SetText(model->Name());
textControl->MakeFocus(true); textControl->MakeFocus(true);
} }
@@ -736,30 +738,39 @@ TFilePanel::Init(const BMessage*)
AddShortcut('W', B_COMMAND_KEY, new BMessage(kCancelButton)); AddShortcut('W', B_COMMAND_KEY, new BMessage(kCancelButton));
AddShortcut('H', B_COMMAND_KEY, new BMessage(kSwitchToHome)); AddShortcut('H', B_COMMAND_KEY, new BMessage(kSwitchToHome));
AddShortcut('A', B_COMMAND_KEY | B_SHIFT_KEY, new BMessage(kShowSelectionWindow)); AddShortcut('A', B_COMMAND_KEY | B_SHIFT_KEY,
new BMessage(kShowSelectionWindow));
AddShortcut('A', B_COMMAND_KEY, new BMessage(B_SELECT_ALL), PoseView()); AddShortcut('A', B_COMMAND_KEY, new BMessage(B_SELECT_ALL), PoseView());
AddShortcut('S', B_COMMAND_KEY, new BMessage(kInvertSelection), PoseView()); AddShortcut('S', B_COMMAND_KEY, new BMessage(kInvertSelection),
PoseView());
AddShortcut('Y', B_COMMAND_KEY, new BMessage(kResizeToFit), PoseView()); AddShortcut('Y', B_COMMAND_KEY, new BMessage(kResizeToFit), PoseView());
AddShortcut(B_DOWN_ARROW, B_COMMAND_KEY, new BMessage(kOpenDir)); AddShortcut(B_DOWN_ARROW, B_COMMAND_KEY, new BMessage(kOpenDir));
AddShortcut(B_DOWN_ARROW, B_COMMAND_KEY | B_OPTION_KEY, new BMessage(kOpenDir)); AddShortcut(B_DOWN_ARROW, B_COMMAND_KEY | B_OPTION_KEY,
new BMessage(kOpenDir));
AddShortcut(B_UP_ARROW, B_COMMAND_KEY, new BMessage(kOpenParentDir)); AddShortcut(B_UP_ARROW, B_COMMAND_KEY, new BMessage(kOpenParentDir));
AddShortcut(B_UP_ARROW, B_COMMAND_KEY | B_OPTION_KEY, new BMessage(kOpenParentDir)); AddShortcut(B_UP_ARROW, B_COMMAND_KEY | B_OPTION_KEY,
new BMessage(kOpenParentDir));
// New code to make buttons font sensitive // New code to make buttons font sensitive
rect = windRect; rect = windRect;
rect.top = rect.bottom - 35; rect.top = rect.bottom - 35;
rect.bottom -= 10; rect.bottom -= 10;
rect.right -= 25; rect.right -= 25;
float default_width = be_plain_font->StringWidth(fButtonText.String()) + 20; float default_width
rect.left = (default_width > 75) ? (rect.right - default_width) : (rect.right - 75); = be_plain_font->StringWidth(fButtonText.String()) + 20;
rect.left = default_width > 75
? rect.right - default_width : rect.right - 75;
BButton* default_button = new BButton(rect, "default button", fButtonText.String(), BButton* default_button = new BButton(rect, "default button",
new BMessage(kDefaultButton), B_FOLLOW_RIGHT + B_FOLLOW_BOTTOM); fButtonText.String(), new BMessage(kDefaultButton),
B_FOLLOW_RIGHT + B_FOLLOW_BOTTOM);
fBackView->AddChild(default_button); fBackView->AddChild(default_button);
rect.right = rect.left -= 10; rect.right = rect.left -= 10;
float cancel_width = be_plain_font->StringWidth(B_TRANSLATE("Cancel")) + 20; float cancel_width
rect.left = (cancel_width > 75) ? (rect.right - cancel_width) : (rect.right - 75); = be_plain_font->StringWidth(B_TRANSLATE("Cancel")) + 20;
rect.left = cancel_width > 75
? rect.right - cancel_width : rect.right - 75;
BButton* cancel_button = new BButton(rect, "cancel button", BButton* cancel_button = new BButton(rect, "cancel button",
B_TRANSLATE("Cancel"), new BMessage(kCancelButton), B_TRANSLATE("Cancel"), new BMessage(kCancelButton),
@@ -804,7 +815,8 @@ void
TFilePanel::RestoreState() TFilePanel::RestoreState()
{ {
BNode defaultingNode; BNode defaultingNode;
if (DefaultStateSourceNode(kDefaultFilePanelTemplate, &defaultingNode, false)) { if (DefaultStateSourceNode(kDefaultFilePanelTemplate, &defaultingNode,
false)) {
AttributeStreamFileNode streamNodeSource(&defaultingNode); AttributeStreamFileNode streamNodeSource(&defaultingNode);
RestoreWindowState(&streamNodeSource); RestoreWindowState(&streamNodeSource);
PoseView()->Init(&streamNodeSource); PoseView()->Init(&streamNodeSource);
@@ -882,7 +894,8 @@ TFilePanel::AddFileContextMenus(BMenu* menu)
new BMessage(B_CUT), 'X')); new BMessage(B_CUT), 'X'));
menu->AddItem(new BMenuItem(B_TRANSLATE("Copy"), menu->AddItem(new BMenuItem(B_TRANSLATE("Copy"),
new BMessage(B_COPY), 'C')); new BMessage(B_COPY), 'C'));
// menu->AddItem(pasteItem = new BMenuItem("Paste", new BMessage(B_PASTE), 'V')); //menu->AddItem(pasteItem = new BMenuItem("Paste", new BMessage(B_PASTE),
// 'V'));
menu->SetTargetForItems(PoseView()); menu->SetTargetForItems(PoseView());
} }
@@ -898,10 +911,12 @@ TFilePanel::AddVolumeContextMenus(BMenu* menu)
menu->AddItem(new BMenuItem(B_TRANSLATE("Edit name"), menu->AddItem(new BMenuItem(B_TRANSLATE("Edit name"),
new BMessage(kEditItem), 'E')); new BMessage(kEditItem), 'E'));
menu->AddSeparatorItem(); menu->AddSeparatorItem();
menu->AddItem(new BMenuItem(B_TRANSLATE("Cut"), new BMessage(B_CUT), 'X')); menu->AddItem(new BMenuItem(B_TRANSLATE("Cut"), new BMessage(B_CUT),
'X'));
menu->AddItem(new BMenuItem(B_TRANSLATE("Copy"), menu->AddItem(new BMenuItem(B_TRANSLATE("Copy"),
new BMessage(B_COPY), 'C')); new BMessage(B_COPY), 'C'));
// menu->AddItem(pasteItem = new BMenuItem("Paste", new BMessage(B_PASTE), 'V')); //menu->AddItem(pasteItem = new BMenuItem("Paste", new BMessage(B_PASTE),
// 'V'));
menu->SetTargetForItems(PoseView()); menu->SetTargetForItems(PoseView());
} }
@@ -955,7 +970,8 @@ TFilePanel::MenusBeginning()
int32 count = PoseView()->SelectionList()->CountItems(); int32 count = PoseView()->SelectionList()->CountItems();
EnableNamedMenuItem(fMenuBar, kNewFolder, !TargetModel()->IsRoot()); EnableNamedMenuItem(fMenuBar, kNewFolder, !TargetModel()->IsRoot());
EnableNamedMenuItem(fMenuBar, kMoveToTrash, !TargetModel()->IsRoot() && count); EnableNamedMenuItem(fMenuBar, kMoveToTrash, !TargetModel()->IsRoot()
&& count);
EnableNamedMenuItem(fMenuBar, kGetInfo, count != 0); EnableNamedMenuItem(fMenuBar, kGetInfo, count != 0);
EnableNamedMenuItem(fMenuBar, kEditItem, count == 1); EnableNamedMenuItem(fMenuBar, kEditItem, count == 1);
@@ -977,9 +993,12 @@ TFilePanel::MenusEnded()
void void
TFilePanel::ShowContextMenu(BPoint point, const entry_ref* ref, BView* view) TFilePanel::ShowContextMenu(BPoint point, const entry_ref* ref, BView* view)
{ {
EnableNamedMenuItem(fWindowContextMenu, kNewFolder, !TargetModel()->IsRoot()); EnableNamedMenuItem(fWindowContextMenu, kNewFolder,
EnableNamedMenuItem(fWindowContextMenu, kOpenParentDir, !TargetModel()->IsRoot()); !TargetModel()->IsRoot());
EnableNamedMenuItem(fWindowContextMenu, kMoveToTrash, !TargetModel()->IsRoot()); EnableNamedMenuItem(fWindowContextMenu, kOpenParentDir,
!TargetModel()->IsRoot());
EnableNamedMenuItem(fWindowContextMenu, kMoveToTrash,
!TargetModel()->IsRoot());
_inherited::ShowContextMenu(point, ref, view); _inherited::ShowContextMenu(point, ref, view);
} }
@@ -998,7 +1017,8 @@ TFilePanel::SetButtonLabel(file_panel_button selector, const char* text)
switch (selector) { switch (selector) {
case B_CANCEL_BUTTON: case B_CANCEL_BUTTON:
{ {
BButton* button = dynamic_cast<BButton*>(FindView("cancel button")); BButton* button
= dynamic_cast<BButton*>(FindView("cancel button"));
if (!button) if (!button)
break; break;
@@ -1016,7 +1036,8 @@ TFilePanel::SetButtonLabel(file_panel_button selector, const char* text)
{ {
fButtonText = text; fButtonText = text;
float delta = 0; float delta = 0;
BButton* button = dynamic_cast<BButton*>(FindView("default button")); BButton* button
= dynamic_cast<BButton*>(FindView("default button"));
if (button) { if (button) {
float old_width = button->StringWidth(button->Label()); float old_width = button->StringWidth(button->Label());
button->SetLabel(text); button->SetLabel(text);
@@ -1043,7 +1064,8 @@ TFilePanel::SetSaveText(const char* text)
if (!text) if (!text)
return; return;
BTextControl* textControl = dynamic_cast<BTextControl*>(FindView("text view")); BTextControl* textControl
= dynamic_cast<BTextControl*>(FindView("text view"));
textControl->SetText(text); textControl->SetText(text);
textControl->TextView()->SelectAll(); textControl->TextView()->SelectAll();
} }
@@ -1060,9 +1082,9 @@ TFilePanel::MessageReceived(BMessage* message)
if (message->FindRef("refs", &ref) == B_OK) { if (message->FindRef("refs", &ref) == B_OK) {
BEntry entry(&ref, true); BEntry entry(&ref, true);
if (entry.InitCheck() == B_OK) { if (entry.InitCheck() == B_OK) {
// Double-click on dir or link-to-dir ALWAYS opens the dir. // Double-click on dir or link-to-dir ALWAYS opens the
// If more than one dir is selected, the // dir. If more than one dir is selected, the first is
// first is entered. // entered.
if (entry.IsDirectory()) { if (entry.IsDirectory()) {
entry.GetRef(&ref); entry.GetRef(&ref);
bool isDesktop = SwitchDirToDesktopIfNeeded(ref); bool isDesktop = SwitchDirToDesktopIfNeeded(ref);
@@ -1075,7 +1097,8 @@ TFilePanel::MessageReceived(BMessage* message)
// Otherwise, we have a file or a link to a file. // Otherwise, we have a file or a link to a file.
// AdjustButton has already tested the flavor; // AdjustButton has already tested the flavor;
// all we have to do is see if the button is enabled. // all we have to do is see if the button is enabled.
BButton* button = dynamic_cast<BButton*>(FindView("default button")); BButton* button = dynamic_cast<BButton*>(
FindView("default button"));
if (!button) if (!button)
break; break;
@@ -1087,15 +1110,19 @@ TFilePanel::MessageReceived(BMessage* message)
// Don't allow saves of multiple files // Don't allow saves of multiple files
if (count > 1) { if (count > 1) {
ShowCenteredAlert( ShowCenteredAlert(
B_TRANSLATE("Sorry, saving more than one item is not allowed."), B_TRANSLATE(
"Sorry, saving more than one "
"item is not allowed."),
B_TRANSLATE("Cancel")); B_TRANSLATE("Cancel"));
} else { } else {
// if we are a savepanel, set up the filepanel correctly // if we are a savepanel, set up the
// then pass control so we follow the same path as if the user // filepanel correctly then pass control
// so we follow the same path as if the user
// clicked the save button // clicked the save button
// set the 'name' fld to the current ref's name // set the 'name' fld to the current ref's
// notify the panel that the default button should be enabled // name notify the panel that the default
// button should be enabled
SetSaveText(ref.name); SetSaveText(ref.name);
SelectionChanged(); SelectionChanged();
@@ -1144,8 +1171,10 @@ TFilePanel::MessageReceived(BMessage* message)
case kAddCurrentDir: case kAddCurrentDir:
{ {
BPath path; BPath path;
if (find_directory (B_USER_SETTINGS_DIRECTORY, &path, true) != B_OK) if (find_directory(B_USER_SETTINGS_DIRECTORY, &path, true)
!= B_OK) {
break; break;
}
path.Append(kGoDirectory); path.Append(kGoDirectory);
BDirectory goDirectory(path.Path()); BDirectory goDirectory(path.Path());
@@ -1155,7 +1184,8 @@ TFilePanel::MessageReceived(BMessage* message)
entry.GetPath(&path); entry.GetPath(&path);
BSymLink link; BSymLink link;
goDirectory.CreateSymLink(TargetModel()->Name(), path.Path(), &link); goDirectory.CreateSymLink(TargetModel()->Name(), path.Path(),
&link);
} }
break; break;
} }
@@ -1163,8 +1193,10 @@ TFilePanel::MessageReceived(BMessage* message)
case kEditFavorites: case kEditFavorites:
{ {
BPath path; BPath path;
if (find_directory (B_USER_SETTINGS_DIRECTORY, &path, true) != B_OK) if (find_directory (B_USER_SETTINGS_DIRECTORY, &path, true)
!= B_OK) {
break; break;
}
path.Append(kGoDirectory); path.Append(kGoDirectory);
BMessenger msgr(kTrackerSignature); BMessenger msgr(kTrackerSignature);
@@ -1199,7 +1231,8 @@ TFilePanel::MessageReceived(BMessage* message)
if (fIsSavePanel) { if (fIsSavePanel) {
if (PoseView()->IsFocus() if (PoseView()->IsFocus()
&& PoseView()->SelectionList()->CountItems() == 1) { && PoseView()->SelectionList()->CountItems() == 1) {
Model* model = (PoseView()->SelectionList()->FirstItem())->TargetModel(); Model* model = (PoseView()->SelectionList()->
FirstItem())->TargetModel();
if (model->ResolveIfLink()->IsDirectory()) { if (model->ResolveIfLink()->IsDirectory()) {
PoseView()->CommitActivePose(); PoseView()->CommitActivePose();
PoseView()->OpenSelection(); PoseView()->OpenSelection();
@@ -1215,13 +1248,17 @@ TFilePanel::MessageReceived(BMessage* message)
case B_OBSERVER_NOTICE_CHANGE: case B_OBSERVER_NOTICE_CHANGE:
{ {
int32 observerWhat; int32 observerWhat;
if (message->FindInt32("be:observe_change_what", &observerWhat) == B_OK) { if (message->FindInt32("be:observe_change_what", &observerWhat)
== B_OK) {
switch (observerWhat) { switch (observerWhat) {
case kDesktopFilePanelRootChanged: case kDesktopFilePanelRootChanged:
{ {
bool desktopIsRoot = true; bool desktopIsRoot = true;
if (message->FindBool("DesktopFilePanelRoot", &desktopIsRoot) == B_OK) if (message->FindBool("DesktopFilePanelRoot",
TrackerSettings().SetDesktopFilePanelRoot(desktopIsRoot); &desktopIsRoot) == B_OK) {
TrackerSettings().
SetDesktopFilePanelRoot(desktopIsRoot);
}
SetTo(TargetModel()->EntryRef()); SetTo(TargetModel()->EntryRef());
break; break;
} }
@@ -1416,9 +1453,10 @@ TFilePanel::HandleSaveButton()
fTextControl->TextView()->SelectAll(); fTextControl->TextView()->SelectAll();
return; return;
} else { } else {
// if this was invoked by a dbl click, it is an explicit replacement // if this was invoked by a dbl click, it is an explicit
// of the file. // replacement of the file.
BString str(B_TRANSLATE("The file \"%name\" already exists in the specified folder. Do you want to replace it?")); BString str(B_TRANSLATE("The file \"%name\" already exists in "
"the specified folder. Do you want to replace it?"));
str.ReplaceFirst("%name", fTextControl->Text()); str.ReplaceFirst("%name", fTextControl->Text());
if (ShowCenteredAlert(str.String(), B_TRANSLATE("Cancel"), if (ShowCenteredAlert(str.String(), B_TRANSLATE("Cancel"),
@@ -1512,9 +1550,11 @@ TFilePanel::HandleOpenButton()
if (((fNodeFlavors & B_DIRECTORY_NODE) != 0 if (((fNodeFlavors & B_DIRECTORY_NODE) != 0
&& model->ResolveIfLink()->IsDirectory()) && model->ResolveIfLink()->IsDirectory())
|| ((fNodeFlavors & B_SYMLINK_NODE) != 0 && model->IsSymLink()) || ((fNodeFlavors & B_SYMLINK_NODE) != 0 && model->IsSymLink())
|| ((fNodeFlavors & B_FILE_NODE) != 0 && model->ResolveIfLink()->IsFile())) || ((fNodeFlavors & B_FILE_NODE) != 0
&& model->ResolveIfLink()->IsFile())) {
message.AddRef("refs", model->EntryRef()); message.AddRef("refs", model->EntryRef());
} }
}
OpenSelectionCommon(&message); OpenSelectionCommon(&message);
} }
@@ -1550,7 +1590,8 @@ TFilePanel::WindowActivated(bool active)
// #pragma mark - // #pragma mark -
BFilePanelPoseView::BFilePanelPoseView(Model* model, BRect frame, uint32 resizeMask) BFilePanelPoseView::BFilePanelPoseView(Model* model, BRect frame,
uint32 resizeMask)
: BPoseView(model, frame, kListMode, resizeMask), : BPoseView(model, frame, kListMode, resizeMask),
fIsDesktop(model->IsDesktop()) fIsDesktop(model->IsDesktop())
{ {
@@ -1583,8 +1624,8 @@ bool
BFilePanelPoseView::FSNotification(const BMessage* message) BFilePanelPoseView::FSNotification(const BMessage* message)
{ {
if (IsDesktopView()) { if (IsDesktopView()) {
// Pretty much copied straight from DesktopPoseView. Would be better // Pretty much copied straight from DesktopPoseView.
// if the code could be shared somehow. // Would be better if the code could be shared somehow.
switch (message->FindInt32("opcode")) { switch (message->FindInt32("opcode")) {
case B_DEVICE_MOUNTED: case B_DEVICE_MOUNTED:
{ {
@@ -1600,7 +1641,8 @@ BFilePanelPoseView::FSNotification(const BMessage* message)
break; break;
if (settings.MountVolumesOntoDesktop() if (settings.MountVolumesOntoDesktop()
&& (!volume.IsShared() || settings.MountSharedVolumesOntoDesktop())) { && (!volume.IsShared()
|| settings.MountSharedVolumesOntoDesktop())) {
// place an icon for the volume onto the desktop // place an icon for the volume onto the desktop
CreateVolumePose(&volume, true); CreateVolumePose(&volume, true);
} }
@@ -1692,7 +1734,8 @@ BFilePanelPoseView::AdaptToVolumeChange(BMessage* message)
message->FindBool("ShowDisksIcon", &showDisksIcon); message->FindBool("ShowDisksIcon", &showDisksIcon);
message->FindBool("MountVolumesOntoDesktop", &mountVolumesOnDesktop); message->FindBool("MountVolumesOntoDesktop", &mountVolumesOnDesktop);
message->FindBool("MountSharedVolumesOntoDesktop", &mountSharedVolumesOntoDesktop); message->FindBool("MountSharedVolumesOntoDesktop",
&mountSharedVolumesOntoDesktop);
BEntry entry("/"); BEntry entry("/");
Model model(&entry); Model model(&entry);
@@ -1725,7 +1768,8 @@ BFilePanelPoseView::AdaptToDesktopIntegrationChange(BMessage* message)
bool mountSharedVolumesOntoDesktop = true; bool mountSharedVolumesOntoDesktop = true;
message->FindBool("MountVolumesOntoDesktop", &mountVolumesOnDesktop); message->FindBool("MountVolumesOntoDesktop", &mountVolumesOnDesktop);
message->FindBool("MountSharedVolumesOntoDesktop", &mountSharedVolumesOntoDesktop); message->FindBool("MountSharedVolumesOntoDesktop",
&mountSharedVolumesOntoDesktop);
ShowVolumes(false, mountSharedVolumesOntoDesktop); ShowVolumes(false, mountSharedVolumesOntoDesktop);
ShowVolumes(mountVolumesOnDesktop, mountSharedVolumesOntoDesktop); ShowVolumes(mountVolumesOnDesktop, mountSharedVolumesOntoDesktop);
+4 -2
View File
@@ -122,7 +122,8 @@ protected:
virtual void WindowActivated(bool state); virtual void WindowActivated(bool state);
static filter_result FSFilter(BMessage*, BHandler**, BMessageFilter*); static filter_result FSFilter(BMessage*, BHandler**, BMessageFilter*);
static filter_result MessageDropFilter(BMessage*, BHandler**, BMessageFilter*); static filter_result MessageDropFilter(BMessage*, BHandler**,
BMessageFilter*);
int32 ShowCenteredAlert(const char* text, const char* button1, int32 ShowCenteredAlert(const char* text, const char* button1,
const char* button2 = NULL, const char* button3 = NULL); const char* button2 = NULL, const char* button3 = NULL);
@@ -166,7 +167,8 @@ public:
void SetIsDesktop(bool); void SetIsDesktop(bool);
protected: protected:
// don't do any volume watching and memtamime watching in file panels for now // don't do any volume watching and memtamime watching in file panels
// for now
virtual void StartWatching(); virtual void StartWatching();
virtual void StopWatching(); virtual void StopWatching();
+61 -28
View File
@@ -56,30 +56,41 @@ FilePermissionsView::FilePermissionsView(BRect rect, Model* model)
fModel(model) fModel(model)
{ {
// Constants for the column labels: "User", "Group" and "Other". // Constants for the column labels: "User", "Group" and "Other".
const float kColumnLabelMiddle = 77, kColumnLabelTop = 6, kColumnLabelSpacing = 37, const float kColumnLabelMiddle = 77, kColumnLabelTop = 6,
kColumnLabelBottom = 20, kColumnLabelWidth = 35, kAttribFontHeight = 10; kColumnLabelSpacing = 37, kColumnLabelBottom = 20,
kColumnLabelWidth = 35, kAttribFontHeight = 10;
BStringView* strView; BStringView* strView;
strView = new BStringView(BRect(kColumnLabelMiddle - kColumnLabelWidth / 2, strView = new BStringView(
kColumnLabelTop, kColumnLabelMiddle + kColumnLabelWidth / 2, kColumnLabelBottom), BRect(kColumnLabelMiddle - kColumnLabelWidth / 2,
kColumnLabelTop,
kColumnLabelMiddle + kColumnLabelWidth / 2,
kColumnLabelBottom),
"", B_TRANSLATE("Owner")); "", B_TRANSLATE("Owner"));
AddChild(strView); AddChild(strView);
strView->SetAlignment(B_ALIGN_CENTER); strView->SetAlignment(B_ALIGN_CENTER);
strView->SetFontSize(kAttribFontHeight); strView->SetFontSize(kAttribFontHeight);
strView = new BStringView(BRect(kColumnLabelMiddle - kColumnLabelWidth / 2 strView = new BStringView(
+ kColumnLabelSpacing, kColumnLabelTop, BRect(kColumnLabelMiddle - kColumnLabelWidth / 2
+ kColumnLabelSpacing,
kColumnLabelTop,
kColumnLabelMiddle + kColumnLabelWidth / 2 + kColumnLabelSpacing, kColumnLabelMiddle + kColumnLabelWidth / 2 + kColumnLabelSpacing,
kColumnLabelBottom), "", B_TRANSLATE("Group")); kColumnLabelBottom),
"", B_TRANSLATE("Group"));
AddChild(strView); AddChild(strView);
strView->SetAlignment(B_ALIGN_CENTER); strView->SetAlignment(B_ALIGN_CENTER);
strView->SetFontSize(kAttribFontHeight); strView->SetFontSize(kAttribFontHeight);
strView = new BStringView(BRect(kColumnLabelMiddle - kColumnLabelWidth / 2 strView = new BStringView(
+ 2 * kColumnLabelSpacing, kColumnLabelTop, BRect(kColumnLabelMiddle - kColumnLabelWidth / 2
kColumnLabelMiddle + kColumnLabelWidth / 2 + 2 * kColumnLabelSpacing, + 2 * kColumnLabelSpacing,
kColumnLabelBottom), "", B_TRANSLATE("Other")); kColumnLabelTop,
kColumnLabelMiddle + kColumnLabelWidth / 2
+ 2 * kColumnLabelSpacing,
kColumnLabelBottom),
"", B_TRANSLATE("Other"));
AddChild(strView); AddChild(strView);
strView->SetAlignment(B_ALIGN_CENTER); strView->SetAlignment(B_ALIGN_CENTER);
strView->SetFontSize(kAttribFontHeight); strView->SetFontSize(kAttribFontHeight);
@@ -89,8 +100,8 @@ FilePermissionsView::FilePermissionsView(BRect rect, Model* model)
kRowLabelVerticalSpacing = 18, kRowLabelRight = kColumnLabelMiddle kRowLabelVerticalSpacing = 18, kRowLabelRight = kColumnLabelMiddle
- kColumnLabelWidth / 2 - 5, kRowLabelHeight = 14; - kColumnLabelWidth / 2 - 5, kRowLabelHeight = 14;
strView = new BStringView(BRect(kRowLabelLeft, kRowLabelTop, kRowLabelRight, strView = new BStringView(BRect(kRowLabelLeft, kRowLabelTop,
kRowLabelTop + kRowLabelHeight), kRowLabelRight, kRowLabelTop + kRowLabelHeight),
"", B_TRANSLATE("Read")); "", B_TRANSLATE("Read"));
AddChild(strView); AddChild(strView);
strView->SetAlignment(B_ALIGN_RIGHT); strView->SetAlignment(B_ALIGN_RIGHT);
@@ -113,14 +124,29 @@ FilePermissionsView::FilePermissionsView(BRect rect, Model* model)
strView->SetFontSize(kAttribFontHeight); strView->SetFontSize(kAttribFontHeight);
// Constants for the 3x3 check box array. // Constants for the 3x3 check box array.
const float kLeftMargin = kRowLabelRight + 15, kTopMargin = kRowLabelTop - 2, const float kLeftMargin = kRowLabelRight + 15,
kHorizontalSpacing = kColumnLabelSpacing, kVerticalSpacing = kRowLabelVerticalSpacing, kTopMargin = kRowLabelTop - 2,
kHorizontalSpacing = kColumnLabelSpacing,
kVerticalSpacing = kRowLabelVerticalSpacing,
kCheckBoxWidth = 18, kCheckBoxHeight = 18; kCheckBoxWidth = 18, kCheckBoxHeight = 18;
FocusCheckBox** checkBoxArray[3][3] = { FocusCheckBox** checkBoxArray[3][3] = {
{ &fReadUserCheckBox, &fReadGroupCheckBox, &fReadOtherCheckBox }, {
{ &fWriteUserCheckBox, &fWriteGroupCheckBox, &fWriteOtherCheckBox }, &fReadUserCheckBox,
{ &fExecuteUserCheckBox, &fExecuteGroupCheckBox, &fExecuteOtherCheckBox }}; &fReadGroupCheckBox,
&fReadOtherCheckBox
},
{
&fWriteUserCheckBox,
&fWriteGroupCheckBox,
&fWriteOtherCheckBox
},
{
&fExecuteUserCheckBox,
&fExecuteGroupCheckBox,
&fExecuteOtherCheckBox
}
};
for (int32 x = 0; x < 3; x++) { for (int32 x = 0; x < 3; x++) {
for (int32 y = 0; y < 3; y++) { for (int32 y = 0; y < 3; y++) {
@@ -135,7 +161,8 @@ FilePermissionsView::FilePermissionsView(BRect rect, Model* model)
} }
const float kTextControlLeft = 170, kTextControlRight = 270, const float kTextControlLeft = 170, kTextControlRight = 270,
kTextControlTop = kColumnLabelTop, kTextControlHeight = 14, kTextControlSpacing = 16; kTextControlTop = kColumnLabelTop, kTextControlHeight = 14,
kTextControlSpacing = 16;
strView = new BStringView(BRect(kTextControlLeft, kTextControlTop, strView = new BStringView(BRect(kTextControlLeft, kTextControlTop,
kTextControlRight, kTextControlTop + kTextControlHeight), "", kTextControlRight, kTextControlTop + kTextControlHeight), "",
@@ -144,25 +171,30 @@ FilePermissionsView::FilePermissionsView(BRect rect, Model* model)
strView->SetFontSize(kAttribFontHeight); strView->SetFontSize(kAttribFontHeight);
AddChild(strView); AddChild(strView);
fOwnerTextControl = new BTextControl(BRect(kTextControlLeft, kTextControlTop - 2 fOwnerTextControl = new BTextControl(
+ kTextControlSpacing, kTextControlRight, kTextControlTop + kTextControlHeight - 2 BRect(kTextControlLeft,
+ kTextControlSpacing), "", "", "", new BMessage(kNewOwnerEntered)); kTextControlTop - 2 + kTextControlSpacing,
kTextControlRight,
kTextControlTop + kTextControlHeight - 2 + kTextControlSpacing),
"", "", "", new BMessage(kNewOwnerEntered));
fOwnerTextControl->SetDivider(0); fOwnerTextControl->SetDivider(0);
AddChild(fOwnerTextControl); AddChild(fOwnerTextControl);
strView = new BStringView(BRect(kTextControlLeft, strView = new BStringView(BRect(kTextControlLeft,
kTextControlTop + 5 + 2 * kTextControlSpacing, kTextControlTop + 5 + 2 * kTextControlSpacing,
kTextControlRight, kTextControlRight,
kTextControlTop + 2 + 2 * kTextControlSpacing + kTextControlHeight), kTextControlTop + 2 + 2 * kTextControlSpacing
+ kTextControlHeight),
"", B_TRANSLATE("Group")); "", B_TRANSLATE("Group"));
strView->SetAlignment(B_ALIGN_CENTER); strView->SetAlignment(B_ALIGN_CENTER);
strView->SetFontSize(kAttribFontHeight); strView->SetFontSize(kAttribFontHeight);
AddChild(strView); AddChild(strView);
fGroupTextControl = new BTextControl(BRect(kTextControlLeft, kTextControlTop fGroupTextControl = new BTextControl(BRect(kTextControlLeft,
+ 3 * kTextControlSpacing, kTextControlRight, kTextControlTop kTextControlTop + 3 * kTextControlSpacing,
+ 3 * kTextControlSpacing + kTextControlHeight), "", "", "", kTextControlRight,
new BMessage(kNewGroupEntered)); kTextControlTop + 3 * kTextControlSpacing + kTextControlHeight),
"", "", "", new BMessage(kNewGroupEntered));
fGroupTextControl->SetDivider(0); fGroupTextControl->SetDivider(0);
AddChild(fGroupTextControl); AddChild(fGroupTextControl);
@@ -277,7 +309,8 @@ FilePermissionsView::MessageReceived(BMessage* message)
case kPermissionsChanged: case kPermissionsChanged:
if (fModel != NULL) { if (fModel != NULL) {
mode_t newPermissions = 0; mode_t newPermissions = 0;
newPermissions = (mode_t)((fReadUserCheckBox->Value() ? S_IRUSR : 0) newPermissions
= (mode_t)((fReadUserCheckBox->Value() ? S_IRUSR : 0)
| (fReadGroupCheckBox->Value() ? S_IRGRP : 0) | (fReadGroupCheckBox->Value() ? S_IRGRP : 0)
| (fReadOtherCheckBox->Value() ? S_IROTH : 0) | (fReadOtherCheckBox->Value() ? S_IROTH : 0)
+185 -115
View File
@@ -106,7 +106,8 @@ namespace BPrivate {
class MostUsedNames { class MostUsedNames {
public: public:
MostUsedNames(const char* fileName, const char* directory, int32 maxCount = 5); MostUsedNames(const char* fileName, const char* directory,
int32 maxCount = 5);
~MostUsedNames(); ~MostUsedNames();
bool ObtainList(BList* list); bool ObtainList(BList* list);
@@ -175,8 +176,8 @@ MoreOptionsStruct::QueryTemporary(const BNode* node)
FindWindow::FindWindow(const entry_ref* newRef, bool editIfTemplateOnly) FindWindow::FindWindow(const entry_ref* newRef, bool editIfTemplateOnly)
: :
BWindow(kInitialRect, B_TRANSLATE("Find"), B_TITLED_WINDOW, B_NOT_RESIZABLE BWindow(kInitialRect, B_TRANSLATE("Find"), B_TITLED_WINDOW,
| B_NOT_ZOOMABLE), B_NOT_RESIZABLE | B_NOT_ZOOMABLE),
fFile(TryOpening(newRef)), fFile(TryOpening(newRef)),
fFromTemplate(false), fFromTemplate(false),
fEditTemplateOnly(false), fEditTemplateOnly(false),
@@ -218,7 +219,8 @@ FindWindow::FindWindow(const entry_ref* newRef, bool editIfTemplateOnly)
fFromTemplate = IsQueryTemplate(fFile); fFromTemplate = IsQueryTemplate(fFile);
fBackground = new FindPanel(Bounds(), fFile, this, fFromTemplate, fEditTemplateOnly); fBackground = new FindPanel(Bounds(), fFile, this, fFromTemplate,
fEditTemplateOnly);
AddChild(fBackground); AddChild(fBackground);
} }
@@ -292,8 +294,10 @@ const char*
FindWindow::QueryName() const FindWindow::QueryName() const
{ {
if (fFromTemplate) { if (fFromTemplate) {
if (!fQueryNameFromTemplate.Length()) if (!fQueryNameFromTemplate.Length()) {
fFile->ReadAttrString(kAttrQueryTemplateName, &fQueryNameFromTemplate); fFile->ReadAttrString(kAttrQueryTemplateName,
&fQueryNameFromTemplate);
}
return fQueryNameFromTemplate.String(); return fQueryNameFromTemplate.String();
} }
@@ -330,7 +334,8 @@ void
FindWindow::GetPredicateString(BString &predicate, bool &dynamicDate) FindWindow::GetPredicateString(BString &predicate, bool &dynamicDate)
{ {
BQuery query; BQuery query;
BTextControl* textControl = dynamic_cast<BTextControl*>(FindView("TextControl")); BTextControl* textControl
= dynamic_cast<BTextControl*>(FindView("TextControl"));
switch (fBackground->Mode()) { switch (fBackground->Mode()) {
case kByNameItem: case kByNameItem:
fBackground->GetByNamePredicate(&query); fBackground->GetByNamePredicate(&query);
@@ -370,20 +375,22 @@ FindWindow::GetDefaultName(BString &result)
void void
FindWindow::SaveQueryAttributes(BNode* file, bool queryTemplate) FindWindow::SaveQueryAttributes(BNode* file, bool queryTemplate)
{ {
ThrowOnError( BNodeInfo(file).SetType( ThrowOnError(BNodeInfo(file).SetType(
queryTemplate ? B_QUERY_TEMPLATE_MIMETYPE : B_QUERY_MIMETYPE) ); queryTemplate ? B_QUERY_TEMPLATE_MIMETYPE : B_QUERY_MIMETYPE));
// save date/time info for recent query support and transient query killer // save date/time info for recent query support and transient query killer
int32 currentTime = (int32)time(0); int32 currentTime = (int32)time(0);
file->WriteAttr(kAttrQueryLastChange, B_INT32_TYPE, 0, &currentTime, sizeof(int32)); file->WriteAttr(kAttrQueryLastChange, B_INT32_TYPE, 0, &currentTime,
sizeof(int32));
int32 tmp = 1; int32 tmp = 1;
file->WriteAttr("_trk/recentQuery", B_INT32_TYPE, 0, &tmp, sizeof(int32)); file->WriteAttr("_trk/recentQuery", B_INT32_TYPE, 0, &tmp, sizeof(int32));
} }
status_t status_t
FindWindow::SaveQueryAsAttributes(BNode* file, BEntry* entry, bool queryTemplate, FindWindow::SaveQueryAsAttributes(BNode* file, BEntry* entry,
const BMessage* oldAttributes, const BPoint* oldLocation) bool queryTemplate, const BMessage* oldAttributes,
const BPoint* oldLocation)
{ {
if (oldAttributes) if (oldAttributes)
// revive old window settings // revive old window settings
@@ -393,7 +400,8 @@ FindWindow::SaveQueryAsAttributes(BNode* file, BEntry* entry, bool queryTemplate
// and the file's location // and the file's location
FSSetPoseLocation(entry, *oldLocation); FSSetPoseLocation(entry, *oldLocation);
BNodeInfo(file).SetType(queryTemplate ? B_QUERY_TEMPLATE_MIMETYPE : B_QUERY_MIMETYPE); BNodeInfo(file).SetType(queryTemplate
? B_QUERY_TEMPLATE_MIMETYPE : B_QUERY_MIMETYPE);
BString predicate; BString predicate;
bool dynamicDate; bool dynamicDate;
@@ -509,7 +517,8 @@ FindWindow::Find()
} }
int32 currentTime = (int32)time(0); int32 currentTime = (int32)time(0);
fFile->WriteAttr(kAttrQueryLastChange, B_INT32_TYPE, 0, &currentTime, sizeof(int32)); fFile->WriteAttr(kAttrQueryLastChange, B_INT32_TYPE, 0, &currentTime,
sizeof(int32));
// tell the tracker about it // tell the tracker about it
BMessage message(B_REFS_RECEIVED); BMessage message(B_REFS_RECEIVED);
@@ -606,7 +615,8 @@ FindWindow::MessageReceived(BMessage* message)
bool queryTemplate; bool queryTemplate;
if (message->FindString("name", &name) == B_OK if (message->FindString("name", &name) == B_OK
&& message->FindRef("directory", &dir) == B_OK && message->FindRef("directory", &dir) == B_OK
&& message->FindBool("template", &queryTemplate) == B_OK) { && message->FindBool("template", &queryTemplate)
== B_OK) {
delete fFile; delete fFile;
fFile = NULL; fFile = NULL;
BDirectory directory(&dir); BDirectory directory(&dir);
@@ -616,7 +626,8 @@ FindWindow::MessageReceived(BMessage* message)
fFile = TryOpening(&tmpRef); fFile = TryOpening(&tmpRef);
if (fFile) { if (fFile) {
fRef = tmpRef; fRef = tmpRef;
SaveQueryAsAttributes(fFile, &entry, queryTemplate, 0, 0); SaveQueryAsAttributes(fFile, &entry, queryTemplate,
0, 0);
// try to save whatever state we aleady have // try to save whatever state we aleady have
// to the new query so that if the user // to the new query so that if the user
// opens it before runing it from the find panel, // opens it before runing it from the find panel,
@@ -683,7 +694,8 @@ FindPanel::FindPanel(BRect frame, BFile* node, FindWindow* parent,
BMessenger self(this); BMessenger self(this);
fRecentQueries = new BPopUpMenu("RecentQueries"); fRecentQueries = new BPopUpMenu("RecentQueries");
FindPanel::AddRecentQueries(fRecentQueries, true, &self, kSwitchToQueryTemplate); FindPanel::AddRecentQueries(fRecentQueries, true, &self,
kSwitchToQueryTemplate);
AddChild(new MiniMenuField(rect, "RecentQueries", fRecentQueries)); AddChild(new MiniMenuField(rect, "RecentQueries", fRecentQueries));
@@ -697,7 +709,8 @@ FindPanel::FindPanel(BRect frame, BFile* node, FindWindow* parent,
rect.right = rect.left + 150; rect.right = rect.left + 150;
fMimeTypeField = new BMenuField(rect, "MimeTypeMenu", "", fMimeTypeMenu); fMimeTypeField = new BMenuField(rect, "MimeTypeMenu", "", fMimeTypeMenu);
fMimeTypeField->SetDivider(0.0f); fMimeTypeField->SetDivider(0.0f);
fMimeTypeField->MenuItem()->SetLabel(B_TRANSLATE("All files and folders")); fMimeTypeField->MenuItem()->SetLabel(
B_TRANSLATE("All files and folders"));
AddChild(fMimeTypeField); AddChild(fMimeTypeField);
// add popup for search criteria // add popup for search criteria
@@ -741,8 +754,8 @@ FindPanel::FindPanel(BRect frame, BFile* node, FindWindow* parent,
B_TRANSLATE_NOCOLLECT(kDragNDropActionSpecifiers[1])); B_TRANSLATE_NOCOLLECT(kDragNDropActionSpecifiers[1]));
BMessenger self(this); BMessenger self(this);
fDraggableIcon = new DraggableQueryIcon(DraggableIcon::PreferredRect(draggableIconOrigin, fDraggableIcon = new DraggableQueryIcon(DraggableIcon::PreferredRect(
B_LARGE_ICON), "saveHere", &dragNDropMessage, draggableIconOrigin, B_LARGE_ICON), "saveHere", &dragNDropMessage,
self, B_FOLLOW_LEFT | B_FOLLOW_BOTTOM); self, B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
AddChild(fDraggableIcon); AddChild(fDraggableIcon);
} }
@@ -769,8 +782,8 @@ FindPanel::FindPanel(BRect frame, BFile* node, FindWindow* parent,
rect = expandedBounds; rect = expandedBounds;
rect.right = rect.left + 200; rect.right = rect.left + 200;
rect.bottom = rect.top + 20;; rect.bottom = rect.top + 20;;
fQueryName = new BTextControl(rect, "queryName", B_TRANSLATE("Query name:"), fQueryName = new BTextControl(rect, "queryName",
"", 0); B_TRANSLATE("Query name:"), "", 0);
fQueryName->SetDivider(fQueryName->StringWidth(fQueryName->Label()) + 5); fQueryName->SetDivider(fQueryName->StringWidth(fQueryName->Label()) + 5);
fMoreOptionsPane->AddItem(fQueryName, 1); fMoreOptionsPane->AddItem(fQueryName, 1);
FillCurrentQueryName(fQueryName, parent); FillCurrentQueryName(fQueryName, parent);
@@ -838,19 +851,21 @@ FindPanel::AttachedToWindow()
fQueryName->SetTarget(this); fQueryName->SetTarget(this);
fLatch->SetTarget(fMoreOptionsPane); fLatch->SetTarget(fMoreOptionsPane);
RestoreMimeTypeMenuSelection(node); RestoreMimeTypeMenuSelection(node);
// preselect the mime we used the last time // preselect the mime we used the last time have to do it here
// have to do it here because AddByAttributeItems will build different // because AddByAttributeItems will build different menus based
// menus based on which mime type is preselected // on which mime type is preselected
RestoreWindowState(node); RestoreWindowState(node);
if (!Window()->CurrentFocus()) { if (!Window()->CurrentFocus()) {
// try to pick a good focus if we restore to one already // try to pick a good focus if we restore to one already
BTextControl* textControl = dynamic_cast<BTextControl*>(FindView("TextControl")); BTextControl* textControl
= dynamic_cast<BTextControl*>(FindView("TextControl"));
if (!textControl) { if (!textControl) {
// pick the last text control in the attribute view // pick the last text control in the attribute view
BString title("TextEntry"); BString title("TextEntry");
title << (fAttrViewList.CountItems() - 1); title << (fAttrViewList.CountItems() - 1);
textControl = dynamic_cast<BTextControl*>(FindView(title.String())); textControl
= dynamic_cast<BTextControl*>(FindView(title.String()));
} }
if (textControl) if (textControl)
textControl->MakeFocus(); textControl->MakeFocus();
@@ -971,6 +986,7 @@ FindPanel::ShowVolumeMenuLabel()
tmpItem = item; tmpItem = item;
} }
} }
if (countSelected == 0) { if (countSelected == 0) {
// no disk selected, for now revert to search all disks // no disk selected, for now revert to search all disks
// ToDo: // ToDo:
@@ -1011,7 +1027,6 @@ FindPanel::MessageReceived(BMessage* message)
ASSERT(menu); ASSERT(menu);
if (dev == -1) { if (dev == -1) {
// all disks selected, uncheck everything else // all disks selected, uncheck everything else
int32 count = menu->CountItems(); int32 count = menu->CountItems();
for (int32 index = 2; index < count; index++) for (int32 index = 2; index < count; index++)
@@ -1020,7 +1035,6 @@ FindPanel::MessageReceived(BMessage* message)
// make all disks the title and check it // make all disks the title and check it
PopUpMenuSetTitle(menu, menu->ItemAt(0)->Label()); PopUpMenuSetTitle(menu, menu->ItemAt(0)->Label());
menu->ItemAt(0)->SetMarked(true); menu->ItemAt(0)->SetMarked(true);
} else { } else {
// a specific volume selected, unmark "all disks" // a specific volume selected, unmark "all disks"
menu->ItemAt(0)->SetMarked(false); menu->ItemAt(0)->SetMarked(false);
@@ -1072,7 +1086,8 @@ FindPanel::MessageReceived(BMessage* message)
if (fMode != kByAttributeItem) if (fMode != kByAttributeItem)
break; break;
// the attributes for this type may be different, rip out the existing ones // the attributes for this type may be different,
// rip out the existing ones
RemoveAttrViewItems(); RemoveAttrViewItems();
Window()->ResizeTo(Window()->Frame().Width(), Window()->ResizeTo(Window()->Frame().Width(),
@@ -1112,10 +1127,12 @@ FindPanel::MessageReceived(BMessage* message)
if (error == B_OK) if (error == B_OK)
error = message->FindString("name", &name); error = message->FindString("name", &name);
} }
if (error == B_OK) if (error == B_OK)
SaveAsQueryOrTemplate(&dir, name, true); SaveAsQueryOrTemplate(&dir, name, true);
}
break; break;
}
case B_COPY_TARGET: case B_COPY_TARGET:
{ {
@@ -1123,9 +1140,11 @@ FindPanel::MessageReceived(BMessage* message)
const char* str; const char* str;
const char* mimeType = NULL; const char* mimeType = NULL;
const char* actionSpecifier = NULL; const char* actionSpecifier = NULL;
if (message->FindString("be:types", &str) == B_OK if (message->FindString("be:types", &str) == B_OK
&& strcasecmp(str, B_FILE_MIME_TYPE) == 0 && strcasecmp(str, B_FILE_MIME_TYPE) == 0
&& (message->FindString("be:actionspecifier", &actionSpecifier) == B_OK && (message->FindString("be:actionspecifier",
&actionSpecifier) == B_OK
|| message->FindString("be:filetypes", &mimeType) == B_OK) || message->FindString("be:filetypes", &mimeType) == B_OK)
&& message->FindString("name", &name) == B_OK && message->FindString("name", &name) == B_OK
&& message->FindRef("directory", &dir) == B_OK) { && message->FindRef("directory", &dir) == B_OK) {
@@ -1146,14 +1165,17 @@ FindPanel::MessageReceived(BMessage* message)
} else if (mimeType && strcasecmp(mimeType, } else if (mimeType && strcasecmp(mimeType,
kDragNDropTypes[0]) == 0) { kDragNDropTypes[0]) == 0) {
query = true; query = true;
} else if (mimeType && strcasecmp(mimeType, kDragNDropTypes[1]) == 0) } else if (mimeType && strcasecmp(mimeType,
kDragNDropTypes[1]) == 0) {
queryTemplate = true; queryTemplate = true;
}
if (query || queryTemplate) if (query || queryTemplate)
SaveAsQueryOrTemplate(&dir, name, queryTemplate); SaveAsQueryOrTemplate(&dir, name, queryTemplate);
} }
}
break; break;
}
default: default:
_inherited::MessageReceived(message); _inherited::MessageReceived(message);
@@ -1163,11 +1185,13 @@ FindPanel::MessageReceived(BMessage* message)
void void
FindPanel::SaveAsQueryOrTemplate(const entry_ref* dir, const char* name, bool queryTemplate) FindPanel::SaveAsQueryOrTemplate(const entry_ref* dir, const char* name,
bool queryTemplate)
{ {
BDirectory directory(dir); BDirectory directory(dir);
BFile file(&directory, name, O_RDWR | O_CREAT | O_TRUNC); BFile file(&directory, name, O_RDWR | O_CREAT | O_TRUNC);
BNodeInfo(&file).SetType(queryTemplate ? B_QUERY_TEMPLATE_MIMETYPE : B_QUERY_MIMETYPE); BNodeInfo(&file).SetType(queryTemplate
? B_QUERY_TEMPLATE_MIMETYPE : B_QUERY_MIMETYPE);
BMessage attach(kAttachFile); BMessage attach(kAttachFile);
attach.AddRef("directory", dir); attach.AddRef("directory", dir);
@@ -1194,7 +1218,8 @@ FindPanel::BuildAttrQuery(BQuery* query, bool &dynamicDate) const
if (!textControl) if (!textControl)
return; return;
BMenuField* menuField = dynamic_cast<BMenuField*>(view->FindView("MenuField")); BMenuField* menuField
= dynamic_cast<BMenuField*>(view->FindView("MenuField"));
if (!menuField) if (!menuField)
return; return;
@@ -1221,75 +1246,84 @@ FindPanel::BuildAttrQuery(BQuery* query, bool &dynamicDate) const
{ {
int flags = 0; int flags = 0;
DEBUG_ONLY(time_t result =) DEBUG_ONLY(time_t result =)
parsedate_etc(textControl->TextView()->Text(), -1, &flags); parsedate_etc(textControl->TextView()->Text(), -1,
&flags);
dynamicDate = (flags & PARSEDATE_RELATIVE_TIME) != 0; dynamicDate = (flags & PARSEDATE_RELATIVE_TIME) != 0;
PRINT(("parsedate_etc - date is %srelative, %" PRINT(("parsedate_etc - date is %srelative, %"
B_PRIdTIME "\n", B_PRIdTIME "\n",
dynamicDate ? "" : "not ", result)); dynamicDate ? "" : "not ", result));
query->PushDate(textControl->TextView()->Text()); query->PushDate(textControl->TextView()->Text());
}
break; break;
}
case B_BOOL_TYPE: case B_BOOL_TYPE:
{ {
uint32 value; uint32 value;
if (strcasecmp(textControl->TextView()->Text(), "true") == 0) if (strcasecmp(textControl->TextView()->Text(),
"true") == 0) {
value = 1; value = 1;
else if (strcasecmp(textControl->TextView()->Text(), "true") == 0) } else if (strcasecmp(textControl->TextView()->Text(),
"true") == 0) {
value = 1; value = 1;
else } else
value = (uint32)atoi(textControl->TextView()->Text()); value = (uint32)atoi(textControl->TextView()->Text());
value %= 2; value %= 2;
query->PushUInt32(value); query->PushUInt32(value);
}
break; break;
}
case B_UINT8_TYPE: case B_UINT8_TYPE:
case B_UINT16_TYPE: case B_UINT16_TYPE:
case B_UINT32_TYPE: case B_UINT32_TYPE:
query->PushUInt32((uint32)StringToScalar(textControl->TextView()->Text())); query->PushUInt32((uint32)StringToScalar(
textControl->TextView()->Text()));
break; break;
case B_INT8_TYPE: case B_INT8_TYPE:
case B_INT16_TYPE: case B_INT16_TYPE:
case B_INT32_TYPE: case B_INT32_TYPE:
query->PushInt32((int32)StringToScalar(textControl->TextView()->Text())); query->PushInt32((int32)StringToScalar(
textControl->TextView()->Text()));
break; break;
case B_UINT64_TYPE: case B_UINT64_TYPE:
query->PushUInt64((uint64)StringToScalar(textControl->TextView()->Text())); query->PushUInt64((uint64)StringToScalar(
textControl->TextView()->Text()));
break; break;
case B_OFF_T_TYPE: case B_OFF_T_TYPE:
case B_INT64_TYPE: case B_INT64_TYPE:
query->PushInt64(StringToScalar(textControl->TextView()->Text())); query->PushInt64(StringToScalar(
textControl->TextView()->Text()));
break; break;
case B_FLOAT_TYPE: case B_FLOAT_TYPE:
{ {
float floatVal; float floatVal;
sscanf(textControl->TextView()->Text(), "%f", &floatVal); sscanf(textControl->TextView()->Text(), "%f",
&floatVal);
query->PushFloat(floatVal); query->PushFloat(floatVal);
}
break; break;
}
case B_DOUBLE_TYPE: case B_DOUBLE_TYPE:
{ {
double doubleVal; double doubleVal;
sscanf(textControl->TextView()->Text(), "%lf", &doubleVal); sscanf(textControl->TextView()->Text(), "%lf",
&doubleVal);
query->PushDouble(doubleVal); query->PushDouble(doubleVal);
}
break; break;
}
} }
} }
query_op theOperator; query_op theOperator;
BMenuItem* operatorItem = item->Submenu()->FindMarked(); BMenuItem* operatorItem = item->Submenu()->FindMarked();
if (operatorItem && operatorItem->Message() != NULL) { if (operatorItem && operatorItem->Message() != NULL) {
operatorItem->Message()->FindInt32("operator", (int32*)&theOperator); operatorItem->Message()->FindInt32("operator",
(int32*)&theOperator);
query->PushOp(theOperator); query->PushOp(theOperator);
} else } else
query->PushOp(B_EQ); query->PushOp(B_EQ);
@@ -1297,7 +1331,8 @@ FindPanel::BuildAttrQuery(BQuery* query, bool &dynamicDate) const
// add logic based on selection in Logic menufield // add logic based on selection in Logic menufield
if (index > 0) { if (index > 0) {
TAttrView* prevView = fAttrViewList.ItemAt(index - 1); TAttrView* prevView = fAttrViewList.ItemAt(index - 1);
menuField = dynamic_cast<BMenuField*>(prevView->FindView("Logic")); menuField
= dynamic_cast<BMenuField*>(prevView->FindView("Logic"));
if (menuField) { if (menuField) {
item = menuField->Menu()->FindMarked(); item = menuField->Menu()->FindMarked();
if (item) { if (item) {
@@ -1348,7 +1383,8 @@ FindPanel::GetByAttrPredicate(BQuery* query, bool &dynamicDate) const
void void
FindPanel::GetDefaultName(BString &result) const FindPanel::GetDefaultName(BString &result) const
{ {
BTextControl* textControl = dynamic_cast<BTextControl*>(FindView("TextControl")); BTextControl* textControl
= dynamic_cast<BTextControl*>(FindView("TextControl"));
switch (Mode()) { switch (Mode()) {
case kByNameItem: case kByNameItem:
result.SetTo(B_TRANSLATE_COMMENT("Name = %name", result.SetTo(B_TRANSLATE_COMMENT("Name = %name",
@@ -1393,16 +1429,17 @@ void
FindPanel::GetByNamePredicate(BQuery* query) const FindPanel::GetByNamePredicate(BQuery* query) const
{ {
ASSERT(Mode() == (int32)kByNameItem); ASSERT(Mode() == (int32)kByNameItem);
BTextControl* textControl = dynamic_cast<BTextControl*>(FindView("TextControl")); BTextControl* textControl
= dynamic_cast<BTextControl*>(FindView("TextControl"));
ASSERT(textControl); ASSERT(textControl);
query->PushAttr("name"); query->PushAttr("name");
query->PushString(textControl->TextView()->Text(), true); query->PushString(textControl->TextView()->Text(), true);
if (strstr(textControl->TextView()->Text(), "*")) if (strstr(textControl->TextView()->Text(), "*")) {
// assume pattern is a regular expression and try doing an exact match // assume pattern is a regular expression, try doing an exact match
query->PushOp(B_EQ); query->PushOp(B_EQ);
else } else
query->PushOp(B_CONTAINS); query->PushOp(B_CONTAINS);
PushMimeType(query); PushMimeType(query);
@@ -1424,6 +1461,7 @@ FindPanel::SwitchMode(uint32 mode)
switch (mode) { switch (mode) {
case kByFormulaItem: case kByFormulaItem:
{
if (oldMode == kByAttributeItem || oldMode == kByNameItem) { if (oldMode == kByAttributeItem || oldMode == kByNameItem) {
BQuery query; BQuery query;
if (oldMode == kByAttributeItem) { if (oldMode == kByAttributeItem) {
@@ -1434,8 +1472,7 @@ FindPanel::SwitchMode(uint32 mode)
query.GetPredicate(&buffer); query.GetPredicate(&buffer);
} }
// fall thru } // fall thru
case kByNameItem: case kByNameItem:
{ {
fMode = mode; fMode = mode;
@@ -1446,16 +1483,18 @@ FindPanel::SwitchMode(uint32 mode)
bounds.bottom -= 10; bounds.bottom -= 10;
if (fLatch->Value()) if (fLatch->Value())
bounds.bottom -= kMoreOptionsDelta; bounds.bottom -= kMoreOptionsDelta;
box->ResizeTo(bounds.Width(), BoxHeightForMode(mode, fLatch->Value() != 0)); box->ResizeTo(bounds.Width(), BoxHeightForMode(mode,
fLatch->Value() != 0));
RemoveByAttributeItems(); RemoveByAttributeItems();
ShowOrHideMimeTypeMenu(); ShowOrHideMimeTypeMenu();
AddByNameOrFormulaItems(); AddByNameOrFormulaItems();
if (buffer.Length()) { if (buffer.Length()) {
ASSERT(mode == kByFormulaItem || oldMode == kByAttributeItem); ASSERT(mode == kByFormulaItem
BTextControl* textControl = dynamic_cast<BTextControl*> || oldMode == kByAttributeItem);
(FindView("TextControl")); BTextControl* textControl
= dynamic_cast<BTextControl*>(FindView("TextControl"));
textControl->SetText(buffer.String()); textControl->SetText(buffer.String());
} }
break; break;
@@ -1470,9 +1509,8 @@ FindPanel::SwitchMode(uint32 mode)
Window()->ResizeTo(Window()->Frame().Width(), Window()->ResizeTo(Window()->Frame().Width(),
ViewHeightForMode(mode, fLatch->Value() != 0)); ViewHeightForMode(mode, fLatch->Value() != 0));
BTextControl* textControl = dynamic_cast<BTextControl*> BTextControl* textControl
(FindView("TextControl")); = dynamic_cast<BTextControl*>(FindView("TextControl"));
if (textControl) { if (textControl) {
textControl->RemoveSelf(); textControl->RemoveSelf();
delete textControl; delete textControl;
@@ -1492,9 +1530,11 @@ FindPanel::CurrentMimeType(const char** type) const
// search for marked item in the list // search for marked item in the list
BMenuItem* item = MimeTypeMenu()->FindMarked(); BMenuItem* item = MimeTypeMenu()->FindMarked();
if (item != NULL && MimeTypeMenu()->IndexOf(item) != 0
&& item->Submenu() == NULL) {
// if it's one of the most used items, ignore it // if it's one of the most used items, ignore it
if (item != NULL && MimeTypeMenu()->IndexOf(item) != 0 && item->Submenu() == NULL)
item = NULL; item = NULL;
}
if (item == NULL) { if (item == NULL) {
for (int32 index = MimeTypeMenu()->CountItems(); index-- > 0;) { for (int32 index = MimeTypeMenu()->CountItems(); index-- > 0;) {
@@ -1536,7 +1576,7 @@ FindPanel::SetCurrentMimeType(BMenuItem* item)
fMimeTypeField->MenuItem()->SetLabel(item->Label()); fMimeTypeField->MenuItem()->SetLabel(item->Label());
BMenuItem* search; BMenuItem* search;
for (int32 i = 2;(search = MimeTypeMenu()->ItemAt(i)) != NULL;i++) { for (int32 i = 2; (search = MimeTypeMenu()->ItemAt(i)) != NULL; i++) {
if (item == search || !search->Label()) if (item == search || !search->Label())
continue; continue;
if (!strcmp(item->Label(),search->Label())) { if (!strcmp(item->Label(),search->Label())) {
@@ -1583,12 +1623,14 @@ FindPanel::SetCurrentMimeType(const char* label)
if (submenu != NULL && !found) { if (submenu != NULL && !found) {
for (int32 subIndex = submenu->CountItems(); subIndex-- > 0;) { for (int32 subIndex = submenu->CountItems(); subIndex-- > 0;) {
BMenuItem* subItem = submenu->ItemAt(subIndex); BMenuItem* subItem = submenu->ItemAt(subIndex);
if (subItem->Label() != NULL && !strcmp(label, subItem->Label())) { if (subItem->Label() != NULL
&& !strcmp(label, subItem->Label())) {
subItem->SetMarked(true); subItem->SetMarked(true);
found = true; found = true;
} }
} }
} }
if (item->Label() != NULL && !strcmp(label, item->Label())) { if (item->Label() != NULL && !strcmp(label, item->Label())) {
item->SetMarked(true); item->SetMarked(true);
return B_OK; return B_OK;
@@ -1615,8 +1657,9 @@ FindPanel::AddOneMimeTypeToMenu(const ShortMimeInfo* info, void* castToMenu)
BMessage* msg = new BMessage(kMIMETypeItem); BMessage* msg = new BMessage(kMIMETypeItem);
msg->AddString("mimetype", info->InternalName()); msg->AddString("mimetype", info->InternalName());
superItem->Submenu()->AddItem(new IconMenuItem(info->ShortDescription(), superItem->Submenu()->AddItem(new IconMenuItem(
msg, info->InternalName(), B_MINI_ICON)); info->ShortDescription(), msg, info->InternalName(),
B_MINI_ICON));
} }
return false; return false;
@@ -1628,8 +1671,8 @@ FindPanel::AddMimeTypesToMenu()
{ {
BMessage* itemMessage = new BMessage(kMIMETypeItem); BMessage* itemMessage = new BMessage(kMIMETypeItem);
itemMessage->AddString("mimetype", kAllMimeTypes); itemMessage->AddString("mimetype", kAllMimeTypes);
MimeTypeMenu()->AddItem(new BMenuItem(B_TRANSLATE("All files and folders"), MimeTypeMenu()->AddItem(
itemMessage)); new BMenuItem(B_TRANSLATE("All files and folders"), itemMessage));
MimeTypeMenu()->AddSeparatorItem(); MimeTypeMenu()->AddSeparatorItem();
MimeTypeMenu()->ItemAt(0)->SetMarked(true); MimeTypeMenu()->ItemAt(0)->SetMarked(true);
@@ -1777,8 +1820,8 @@ AddOneRecentItem(const entry_ref* ref, void* castToParams)
void void
FindPanel::AddRecentQueries(BMenu* menu, bool addSaveAsItem, const BMessenger* target, FindPanel::AddRecentQueries(BMenu* menu, bool addSaveAsItem,
uint32 what) const BMessenger* target, uint32 what)
{ {
BObjectList<entry_ref> templates(10, true); BObjectList<entry_ref> templates(10, true);
BObjectList<EntryWithDate> recentQueries(10, true); BObjectList<EntryWithDate> recentQueries(10, true);
@@ -1788,7 +1831,8 @@ FindPanel::AddRecentQueries(BMenu* menu, bool addSaveAsItem, const BMessenger* t
BVolume volume; BVolume volume;
roster.Rewind(); roster.Rewind();
while (roster.GetNextVolume(&volume) == B_OK) { while (roster.GetNextVolume(&volume) == B_OK) {
if (volume.IsPersistent() && volume.KnowsQuery() && volume.KnowsAttr()) { if (volume.IsPersistent() && volume.KnowsQuery()
&& volume.KnowsAttr()) {
BQuery query; BQuery query;
query.SetVolume(&volume); query.SetVolume(&volume);
@@ -2046,9 +2090,11 @@ FindPanel::SaveWindowState(BNode* node, bool editTemplate)
saveMoreOptions.searchTrash = fSearchTrashCheck->Value() != 0; saveMoreOptions.searchTrash = fSearchTrashCheck->Value() != 0;
saveMoreOptions.temporary = fTemporaryCheck->Value() != 0; saveMoreOptions.temporary = fTemporaryCheck->Value() != 0;
if (node->WriteAttr(kAttrQueryMoreOptions, B_RAW_TYPE, 0, &saveMoreOptions, if (node->WriteAttr(kAttrQueryMoreOptions, B_RAW_TYPE, 0,
sizeof(saveMoreOptions)) == sizeof(saveMoreOptions)) &saveMoreOptions,
sizeof(saveMoreOptions)) == sizeof(saveMoreOptions)) {
node->RemoveAttr(kAttrQueryMoreOptionsForeign); node->RemoveAttr(kAttrQueryMoreOptionsForeign);
}
if (editTemplate) { if (editTemplate) {
if (UserSpecifiedName()) { if (UserSpecifiedName()) {
@@ -2075,9 +2121,10 @@ FindPanel::SaveWindowState(BNode* node, bool editTemplate)
node->WriteAttr(kAttrQueryInitialAttrs, B_MESSAGE_TYPE, 0, node->WriteAttr(kAttrQueryInitialAttrs, B_MESSAGE_TYPE, 0,
buffer, (size_t)size); buffer, (size_t)size);
} }
delete [] buffer;
} delete[] buffer;
break; break;
}
case kByNameItem: case kByNameItem:
case kByFormulaItem: case kByFormulaItem:
@@ -2167,9 +2214,10 @@ FindPanel::RestoreWindowState(const BNode* node)
FillCurrentQueryName(fQueryName, dynamic_cast<FindWindow*>(Window())); FillCurrentQueryName(fQueryName, dynamic_cast<FindWindow*>(Window()));
// set modification message after checking the temporary check box, // set modification message after checking the temporary check box,
// and filling out the text control so that we do not // and filling out the text control so that we do not always trigger
// always trigger clearing of the temporary check box. // clearing of the temporary check box.
fQueryName->SetModificationMessage(new BMessage(kNameModifiedMessage)); fQueryName->SetModificationMessage(
new BMessage(kNameModifiedMessage));
} }
// get volumes to perform query on // get volumes to perform query on
@@ -2178,23 +2226,25 @@ FindPanel::RestoreWindowState(const BNode* node)
attr_info info; attr_info info;
if (node->GetAttrInfo(kAttrQueryVolume, &info) == B_OK) { if (node->GetAttrInfo(kAttrQueryVolume, &info) == B_OK) {
char* buffer = new char[info.size]; char* buffer = new char[info.size];
if (node->ReadAttr(kAttrQueryVolume, B_MESSAGE_TYPE, 0, buffer, (size_t)info.size) if (node->ReadAttr(kAttrQueryVolume, B_MESSAGE_TYPE, 0, buffer,
== info.size) { (size_t)info.size) == info.size) {
BMessage message; BMessage message;
if (message.Unflatten(buffer) == B_OK) { if (message.Unflatten(buffer) == B_OK) {
for (int32 index = 0; ;index++) { for (int32 index = 0; ;index++) {
ASSERT(index < 100); ASSERT(index < 100);
BVolume volume; BVolume volume;
// match a volume with the info embedded in the message // match a volume with the info embedded in
status_t result = MatchArchivedVolume(&volume, &message, index); // the message
status_t result
= MatchArchivedVolume(&volume, &message, index);
if (result == B_OK) { if (result == B_OK) {
char name[256]; char name[256];
volume.GetName(name); volume.GetName(name);
SelectItemWithLabel(fVolMenu, name); SelectItemWithLabel(fVolMenu, name);
searchAllVolumes = false; searchAllVolumes = false;
} else if (result != B_DEV_BAD_DRIVE_NUM) } else if (result != B_DEV_BAD_DRIVE_NUM)
// if B_DEV_BAD_DRIVE_NUM, the volume just isn't mounted this // if B_DEV_BAD_DRIVE_NUM, the volume just isn't
// time around, keep looking for more // mounted this time around, keep looking for more
// if other error, bail // if other error, bail
break; break;
} }
@@ -2215,14 +2265,16 @@ FindPanel::RestoreWindowState(const BNode* node)
if (node->GetAttrInfo(kAttrQueryInitialAttrs, &info) != B_OK) if (node->GetAttrInfo(kAttrQueryInitialAttrs, &info) != B_OK)
break; break;
char* buffer = new char[info.size]; char* buffer = new char[info.size];
if (node->ReadAttr(kAttrQueryInitialAttrs, B_MESSAGE_TYPE, 0, buffer, (size_t)info.size) if (node->ReadAttr(kAttrQueryInitialAttrs, B_MESSAGE_TYPE, 0,
== info.size) { buffer, (size_t)info.size) == info.size) {
BMessage message; BMessage message;
if (message.Unflatten(buffer) == B_OK) if (message.Unflatten(buffer) == B_OK)
for (int32 index = 0; index < count; index++) for (int32 index = 0; index < count; index++) {
fAttrViewList.ItemAt(index)->RestoreState(message, index); fAttrViewList.ItemAt(index)->RestoreState(message,
index);
} }
delete [] buffer; }
delete[] buffer;
break; break;
} }
@@ -2230,16 +2282,17 @@ FindPanel::RestoreWindowState(const BNode* node)
case kByFormulaItem: case kByFormulaItem:
{ {
BString buffer; BString buffer;
if (node->ReadAttrString(kAttrQueryInitialString, &buffer) == B_OK) { if (node->ReadAttrString(kAttrQueryInitialString, &buffer)
== B_OK) {
BTextControl* textControl = dynamic_cast<BTextControl*> BTextControl* textControl = dynamic_cast<BTextControl*>
(FindView("TextControl")); (FindView("TextControl"));
ASSERT(textControl); ASSERT(textControl);
textControl->TextView()->SetText(buffer.String()); textControl->TextView()->SetText(buffer.String());
} }
}
break; break;
} }
}
// try to restore focus and possibly text selection // try to restore focus and possibly text selection
BString focusedView; BString focusedView;
@@ -2304,7 +2357,8 @@ FindPanel::AddByNameOrFormulaItems()
BRect bounds(box->Bounds()); BRect bounds(box->Bounds());
bounds.InsetBy(10, 10); bounds.InsetBy(10, 10);
BTextControl* textControl = new BTextControl(bounds, "TextControl", "", "", NULL); BTextControl* textControl = new BTextControl(bounds, "TextControl",
"", "", NULL);
textControl->SetDivider(0.0f); textControl->SetDivider(0.0f);
box->AddChild(textControl); box->AddChild(textControl);
textControl->MakeFocus(); textControl->MakeFocus();
@@ -2353,7 +2407,8 @@ FindPanel::RemoveByAttributeItems()
void void
FindPanel::ShowOrHideMimeTypeMenu() FindPanel::ShowOrHideMimeTypeMenu()
{ {
BMenuField* menuField = dynamic_cast<BMenuField*>(FindView("MimeTypeMenu")); BMenuField* menuField
= dynamic_cast<BMenuField*>(FindView("MimeTypeMenu"));
if (Mode() == (int32)kByFormulaItem && !menuField->IsHidden()) if (Mode() == (int32)kByFormulaItem && !menuField->IsHidden())
menuField->Hide(); menuField->Hide();
else if (menuField->IsHidden()) else if (menuField->IsHidden())
@@ -2398,8 +2453,8 @@ TAttrView::TAttrView(BRect frame, int32 index)
for (int32 i = 0; i < 5; i++) { for (int32 i = 0; i < 5; i++) {
message = new BMessage(kAttributeItem); message = new BMessage(kAttributeItem);
message->AddInt32("operator", operators[i]); message->AddInt32("operator", operators[i]);
submenu->AddItem(new BMenuItem(B_TRANSLATE_NOCOLLECT(operatorLabels[i]), submenu->AddItem(new BMenuItem(B_TRANSLATE_NOCOLLECT(
message)); operatorLabels[i]), message));
} }
// mark first item // mark first item
@@ -2558,7 +2613,8 @@ TAttrView::SaveState(BMessage* message, int32)
if (field) { if (field) {
BMenuItem* item = field->Menu()->FindMarked(); BMenuItem* item = field->Menu()->FindMarked();
ASSERT(item); ASSERT(item);
message->AddInt32("logicalRelation", item ? field->Menu()->IndexOf(item) : 0); message->AddInt32("logicalRelation",
item ? field->Menu()->IndexOf(item) : 0);
} }
} }
@@ -2618,7 +2674,8 @@ TAttrView::Draw(BRect)
// draws the is/contains, etc. string // draws the is/contains, etc. string
bounds.left -= (width + 10); bounds.left -= (width + 10);
bounds.bottom -= 6; bounds.bottom -= 6;
DrawString(item->Submenu()->FindMarked()->Label(), bounds.LeftBottom()); DrawString(item->Submenu()->FindMarked()->Label(),
bounds.LeftBottom());
} }
} }
@@ -2677,15 +2734,19 @@ TAttrView::AddAttributes(BMenu* menu, const BMimeType &mimeType)
// go through each field in meta mime and add it to a menu // go through each field in meta mime and add it to a menu
for (int32 index = 0; ; index++) { for (int32 index = 0; ; index++) {
const char* publicName; const char* publicName;
if (attributeMessage.FindString("attr:public_name", index, &publicName) != B_OK) if (attributeMessage.FindString("attr:public_name", index,
&publicName) != B_OK) {
break; break;
}
if (!attributeMessage.FindBool("attr:viewable")) if (!attributeMessage.FindBool("attr:viewable"))
continue; continue;
const char* attributeName; const char* attributeName;
if (attributeMessage.FindString("attr:name", index, &attributeName) != B_OK) if (attributeMessage.FindString("attr:name", index, &attributeName)
!= B_OK) {
continue; continue;
}
int32 type; int32 type;
if (attributeMessage.FindInt32("attr:type", index, &type) != B_OK) if (attributeMessage.FindInt32("attr:type", index, &type) != B_OK)
@@ -2714,7 +2775,8 @@ TAttrView::AddAttributes(BMenu* menu, const BMimeType &mimeType)
message = new BMessage(kAttributeItem); message = new BMessage(kAttributeItem);
message->AddInt32("operator", B_NE); message->AddInt32("operator", B_NE);
submenu->AddItem(new BMenuItem(B_TRANSLATE("is not"), message)); submenu->AddItem(new BMenuItem(B_TRANSLATE("is not"),
message));
submenu->SetTargetForItems(this); submenu->SetTargetForItems(this);
message = new BMessage(kAttributeItem); message = new BMessage(kAttributeItem);
@@ -2942,12 +3004,14 @@ DeleteTransientQueriesTask::ProcessOneRef(Model* model)
ASSERT(dynamic_cast<TTracker*>(be_app)); ASSERT(dynamic_cast<TTracker*>(be_app));
// check that it is not showing // check that it is not showing
if (dynamic_cast<TTracker*>(be_app)->EntryHasWindowOpen(model->EntryRef())) { if (dynamic_cast<TTracker*>(be_app)->EntryHasWindowOpen(
model->EntryRef())) {
PRINT(("query %s, showing, can't delete\n", model->Name())); PRINT(("query %s, showing, can't delete\n", model->Name()));
return false; return false;
} }
PRINT(("query %s, old, temporary, not shownig - deleting\n", model->Name())); PRINT(("query %s, old, temporary, not shownig - deleting\n",
model->Name()));
BEntry entry(model->EntryRef()); BEntry entry(model->EntryRef());
entry.Remove(); entry.Remove();
@@ -2993,8 +3057,8 @@ DeleteTransientQueriesTask::StartUpTransientQueryCleaner()
// #pragma mark - // #pragma mark -
RecentFindItemsMenu::RecentFindItemsMenu(const char* title, const BMessenger* target, RecentFindItemsMenu::RecentFindItemsMenu(const char* title,
uint32 what) const BMessenger* target, uint32 what)
: BMenu(title, B_ITEMS_IN_COLUMN), : BMenu(title, B_ITEMS_IN_COLUMN),
fTarget(*target), fTarget(*target),
fWhat(what) fWhat(what)
@@ -3029,7 +3093,8 @@ TrackerBuildRecentFindItemsMenu(const char* title)
DraggableQueryIcon::DraggableQueryIcon(BRect frame, const char* name, DraggableQueryIcon::DraggableQueryIcon(BRect frame, const char* name,
const BMessage* message, BMessenger messenger, uint32 resizeFlags, uint32 flags) const BMessage* message, BMessenger messenger, uint32 resizeFlags,
uint32 flags)
: DraggableIcon(frame, name, B_QUERY_MIMETYPE, B_LARGE_ICON, : DraggableIcon(frame, name, B_QUERY_MIMETYPE, B_LARGE_ICON,
message, messenger, resizeFlags, flags) message, messenger, resizeFlags, flags)
{ {
@@ -3056,7 +3121,8 @@ DraggableQueryIcon::DragStarted(BMessage* dragMessage)
// #pragma mark - // #pragma mark -
MostUsedNames::MostUsedNames(const char* fileName, const char* directory, int32 maxCount) MostUsedNames::MostUsedNames(const char* fileName, const char* directory,
int32 maxCount)
: :
fFileName(fileName), fFileName(fileName),
fDirectory(directory), fDirectory(directory),
@@ -3157,7 +3223,8 @@ MostUsedNames::AddName(const char* name)
list_entry* entry = NULL; list_entry* entry = NULL;
if (fList.CountItems() > fCount * 2) { if (fList.CountItems() > fCount * 2) {
entry = static_cast<list_entry*>(fList.RemoveItem(fList.CountItems() - 1)); entry = static_cast<list_entry*>(
fList.RemoveItem(fList.CountItems() - 1));
// is this the name we want to add here? // is this the name we want to add here?
if (strcmp(name, entry->name)) { if (strcmp(name, entry->name)) {
@@ -3169,10 +3236,13 @@ MostUsedNames::AddName(const char* name)
} }
if (entry == NULL) { if (entry == NULL) {
for (int32 i = 0; (entry = static_cast<list_entry*>(fList.ItemAt(i))) != NULL; i++) for (int32 i = 0;
(entry = static_cast<list_entry*>(fList.ItemAt(i))) != NULL;
i++) {
if (!strcmp(entry->name, name)) if (!strcmp(entry->name, name))
break; break;
} }
}
if (entry == NULL) { if (entry == NULL) {
entry = new list_entry; entry = new list_entry;
+13 -8
View File
@@ -129,8 +129,8 @@ class FindWindow : public BWindow {
{ return fFile; } { return fFile; }
const char* QueryName() const; const char* QueryName() const;
// reads in the query name from either a saved name in a template or // reads in the query name from either a saved name in a template
// form a saved query name // or form a saved query name
static bool IsQueryTemplate(BNode* file); static bool IsQueryTemplate(BNode* file);
@@ -140,7 +140,8 @@ class FindWindow : public BWindow {
private: private:
static BFile* TryOpening(const entry_ref* ref); static BFile* TryOpening(const entry_ref* ref);
static void GetDefaultQuery(BEntry &entry); static void GetDefaultQuery(BEntry &entry);
// when opening an empty panel, use the default query to set the panel up // when opening an empty panel, use the default query to set the
// panel up
void SaveQueryAttributes(BNode* file, bool templateQuery); void SaveQueryAttributes(BNode* file, bool templateQuery);
void Find(); void Find();
@@ -242,10 +243,12 @@ class FindPanel : public BView {
void RemoveByAttributeItems(); void RemoveByAttributeItems();
void RemoveAttrViewItems(); void RemoveAttrViewItems();
void ShowOrHideMimeTypeMenu(); void ShowOrHideMimeTypeMenu();
// MimeTypeWindow is only shown in kByNameItem and kByAttributeItem modes // MimeTypeWindow is only shown in kByNameItem and
// kByAttributeItem modes
void ShowOrHideMoreOptions(bool show); void ShowOrHideMoreOptions(bool show);
// fMode gets set by this and the call relies on it being up-to-date // fMode gets set by this and the call relies on it being
// up-to-date
static int32 InitialAttrCount(const BNode*); static int32 InitialAttrCount(const BNode*);
void FillCurrentQueryName(BTextControl*, FindWindow*); void FillCurrentQueryName(BTextControl*, FindWindow*);
void AddByNameOrFormulaItems(); void AddByNameOrFormulaItems();
@@ -348,7 +351,8 @@ class DeleteTransientQueriesTask {
class RecentFindItemsMenu : public BMenu { class RecentFindItemsMenu : public BMenu {
public: public:
RecentFindItemsMenu(const char* title, const BMessenger* target, uint32 what); RecentFindItemsMenu(const char* title, const BMessenger* target,
uint32 what);
protected: protected:
virtual void AttachedToWindow(); virtual void AttachedToWindow();
@@ -362,8 +366,9 @@ class RecentFindItemsMenu : public BMenu {
class DraggableQueryIcon : public DraggableIcon { class DraggableQueryIcon : public DraggableIcon {
// query/query template drag&drop helper // query/query template drag&drop helper
public: public:
DraggableQueryIcon(BRect frame, const char* name, const BMessage* message, DraggableQueryIcon(BRect frame, const char* name,
BMessenger target, uint32 resizeFlags = B_FOLLOW_LEFT | B_FOLLOW_TOP, const BMessage* message, BMessenger target,
uint32 resizeFlags = B_FOLLOW_LEFT | B_FOLLOW_TOP,
uint32 flags = B_WILL_DRAW); uint32 flags = B_WILL_DRAW);
protected: protected:
+34 -21
View File
@@ -252,9 +252,11 @@ private:
template <class Result, class Param1, class Param2, class Param3> template <class Result, class Param1, class Param2, class Param3>
class ThreeParamFunctionObjectWithResult : public FunctionObjectWithResult<Result> { class ThreeParamFunctionObjectWithResult : public
FunctionObjectWithResult<Result> {
public: public:
ThreeParamFunctionObjectWithResult(Result (*callThis)(Param1, Param2, Param3), ThreeParamFunctionObjectWithResult(
Result (*callThis)(Param1, Param2, Param3),
Param1 p1, Param2 p2, Param3 p3) Param1 p1, Param2 p2, Param3 p3)
: function(callThis), : function(callThis),
p1(p1), p1(p1),
@@ -300,10 +302,13 @@ private:
}; };
template <class Result, class Param1, class Param2, class Param3, class Param4> template <class Result, class Param1, class Param2, class Param3,
class FourParamFunctionObjectWithResult : public FunctionObjectWithResult<Result> { class Param4>
class FourParamFunctionObjectWithResult : public
FunctionObjectWithResult<Result> {
public: public:
FourParamFunctionObjectWithResult(Result (*callThis)(Param1, Param2, Param3, Param4), FourParamFunctionObjectWithResult(
Result (*callThis)(Param1, Param2, Param3, Param4),
Param1 p1, Param2 p2, Param3 p3, Param4 p4) Param1 p1, Param2 p2, Param3 p3, Param4 p4)
: function(callThis), : function(callThis),
p1(p1), p1(p1),
@@ -369,7 +374,8 @@ private:
template<class T, class R> template<class T, class R>
class PlainMemberFunctionObjectWithResult : public FunctionObjectWithResult<R> { class PlainMemberFunctionObjectWithResult : public
FunctionObjectWithResult<R> {
public: public:
PlainMemberFunctionObjectWithResult(R (T::*function)(), T* onThis) PlainMemberFunctionObjectWithResult(R (T::*function)(), T* onThis)
: function(function), : function(function),
@@ -390,7 +396,8 @@ private:
template<class T, class Param1> template<class T, class Param1>
class SingleParamMemberFunctionObject : public FunctionObject { class SingleParamMemberFunctionObject : public FunctionObject {
public: public:
SingleParamMemberFunctionObject(void (T::*function)(Param1), T* onThis, Param1 p1) SingleParamMemberFunctionObject(void (T::*function)(Param1),
T* onThis, Param1 p1)
: function(function), : function(function),
target(onThis), target(onThis),
p1(p1) p1(p1)
@@ -410,8 +417,8 @@ private:
template<class T, class Param1, class Param2> template<class T, class Param1, class Param2>
class TwoParamMemberFunctionObject : public FunctionObject { class TwoParamMemberFunctionObject : public FunctionObject {
public: public:
TwoParamMemberFunctionObject(void (T::*function)(Param1, Param2), T* onThis, TwoParamMemberFunctionObject(void (T::*function)(Param1, Param2),
Param1 p1, Param2 p2) T* onThis, Param1 p1, Param2 p2)
: function(function), : function(function),
target(onThis), target(onThis),
p1(p1), p1(p1),
@@ -432,10 +439,11 @@ protected:
template<class T, class R, class Param1> template<class T, class R, class Param1>
class SingleParamMemberFunctionObjectWithResult : public FunctionObjectWithResult<R> { class SingleParamMemberFunctionObjectWithResult : public
FunctionObjectWithResult<R> {
public: public:
SingleParamMemberFunctionObjectWithResult(R (T::*function)(Param1), T* onThis, SingleParamMemberFunctionObjectWithResult(R (T::*function)(Param1),
Param1 p1) T* onThis, Param1 p1)
: function(function), : function(function),
target(onThis), target(onThis),
p1(p1) p1(p1)
@@ -443,7 +451,8 @@ public:
} }
virtual void operator()() virtual void operator()()
{ FunctionObjectWithResult<R>::result = (target->*function)(p1.Pass()); } { FunctionObjectWithResult<R>::result
= (target->*function)(p1.Pass()); }
protected: protected:
R (T::*function)(Param1); R (T::*function)(Param1);
@@ -453,10 +462,11 @@ protected:
template<class T, class R, class Param1, class Param2> template<class T, class R, class Param1, class Param2>
class TwoParamMemberFunctionObjectWithResult : public FunctionObjectWithResult<R> { class TwoParamMemberFunctionObjectWithResult : public
FunctionObjectWithResult<R> {
public: public:
TwoParamMemberFunctionObjectWithResult(R (T::*function)(Param1, Param2), T* onThis, TwoParamMemberFunctionObjectWithResult(R (T::*function)(Param1, Param2),
Param1 p1, Param2 p2) T* onThis, Param1 p1, Param2 p2)
: function(function), : function(function),
target(onThis), target(onThis),
p1(p1), p1(p1),
@@ -505,7 +515,8 @@ ThreeParamFunctionObject<Param1, Param2, Param3>*
NewFunctionObject(void (*function)(Param1, Param2, Param3), NewFunctionObject(void (*function)(Param1, Param2, Param3),
Param1 p1, Param2 p2, Param3 p3) Param1 p1, Param2 p2, Param3 p3)
{ {
return new ThreeParamFunctionObject<Param1, Param2, Param3>(function, p1, p2, p3); return new ThreeParamFunctionObject<Param1, Param2, Param3>
(function, p1, p2, p3);
} }
@@ -521,7 +532,8 @@ template<class T, class Param1>
SingleParamMemberFunctionObject<T, Param1>* SingleParamMemberFunctionObject<T, Param1>*
NewMemberFunctionObject(void (T::*function)(Param1), T* onThis, Param1 p1) NewMemberFunctionObject(void (T::*function)(Param1), T* onThis, Param1 p1)
{ {
return new SingleParamMemberFunctionObject<T, Param1>(function, onThis, p1); return new SingleParamMemberFunctionObject<T, Param1>
(function, onThis, p1);
} }
@@ -530,8 +542,8 @@ TwoParamMemberFunctionObject<T, Param1, Param2>*
NewMemberFunctionObject(void (T::*function)(Param1, Param2), T* onThis, NewMemberFunctionObject(void (T::*function)(Param1, Param2), T* onThis,
Param1 p1, Param2 p2) Param1 p1, Param2 p2)
{ {
return new TwoParamMemberFunctionObject<T, Param1, Param2>(function, onThis, return new TwoParamMemberFunctionObject<T, Param1, Param2>
p1, p2); (function, onThis, p1, p2);
} }
@@ -550,7 +562,8 @@ PlainLockingMemberFunctionObject<HandlerOrSubclass>*
NewLockingMemberFunctionObject(void (HandlerOrSubclass::*function)(), NewLockingMemberFunctionObject(void (HandlerOrSubclass::*function)(),
HandlerOrSubclass* onThis) HandlerOrSubclass* onThis)
{ {
return new PlainLockingMemberFunctionObject<HandlerOrSubclass>(function, onThis); return new PlainLockingMemberFunctionObject<HandlerOrSubclass>
(function, onThis);
} }
} // namespace BPrivate } // namespace BPrivate
+9 -5
View File
@@ -176,8 +176,10 @@ TGroupedMenu::TGroupedMenu(const char* name)
TGroupedMenu::~TGroupedMenu() TGroupedMenu::~TGroupedMenu()
{ {
TMenuItemGroup* group; TMenuItemGroup* group;
while ((group = static_cast<TMenuItemGroup*>(fGroups.RemoveItem(0L))) != NULL) while ((group = static_cast<TMenuItemGroup*>(fGroups.RemoveItem(0L)))
!= NULL) {
delete group; delete group;
}
} }
@@ -247,7 +249,8 @@ TGroupedMenu::CountGroups()
void void
TGroupedMenu::AddGroupItem(TMenuItemGroup* group, BMenuItem* item, int32 atIndex) TGroupedMenu::AddGroupItem(TMenuItemGroup* group, BMenuItem* item,
int32 atIndex)
{ {
int32 groupIndex = fGroups.IndexOf(group); int32 groupIndex = fGroups.IndexOf(group);
bool addSeparator = false; bool addSeparator = false;
@@ -257,7 +260,8 @@ TGroupedMenu::AddGroupItem(TMenuItemGroup* group, BMenuItem* item, int32 atIndex
if (groupIndex > 0) { if (groupIndex > 0) {
// add this group after an existing one // add this group after an existing one
TMenuItemGroup* previous = GroupAt(groupIndex - 1); TMenuItemGroup* previous = GroupAt(groupIndex - 1);
group->fFirstItemIndex = previous->fFirstItemIndex + previous->fItemsTotal; group->fFirstItemIndex = previous->fFirstItemIndex
+ previous->fItemsTotal;
addSeparator = true; addSeparator = true;
} else { } else {
// this is the first group // this is the first group
@@ -283,7 +287,8 @@ TGroupedMenu::AddGroupItem(TMenuItemGroup* group, BMenuItem* item, int32 atIndex
// insert item for real // insert item for real
AddItem(item, atIndex + group->fFirstItemIndex + (group->HasSeparator() ? 1 : 0)); AddItem(item,
atIndex + group->fFirstItemIndex + (group->HasSeparator() ? 1 : 0));
// move the groups after this one // move the groups after this one
@@ -320,4 +325,3 @@ TGroupedMenu::RemoveGroupItem(TMenuItemGroup* group, BMenuItem* item)
group->fFirstItemIndex -= removedSeparator ? 2 : 1; group->fFirstItemIndex -= removedSeparator ? 2 : 1;
} }
} }
+2 -1
View File
@@ -58,7 +58,8 @@ class TGroupedMenu : public BMenu {
private: private:
friend class TMenuItemGroup; friend class TMenuItemGroup;
void AddGroupItem(TMenuItemGroup* group, BMenuItem* item, int32 atIndex); void AddGroupItem(TMenuItemGroup* group, BMenuItem* item,
int32 atIndex);
void RemoveGroupItem(TMenuItemGroup* group, BMenuItem* item); void RemoveGroupItem(TMenuItemGroup* group, BMenuItem* item);
private: private:
+116 -76
View File
@@ -242,13 +242,17 @@ IconCacheEntry::IconHitTest(BPoint where, IconDrawMode mode, icon_size size) con
BBitmap* BBitmap*
IconCacheEntry::ConstructBitmap(BBitmap* constructFrom, IconDrawMode requestedMode, IconCacheEntry::ConstructBitmap(BBitmap* constructFrom,
IconDrawMode constructFromMode, icon_size size, LazyBitmapAllocator* lazyBitmap) IconDrawMode requestedMode, IconDrawMode constructFromMode,
icon_size size, LazyBitmapAllocator* lazyBitmap)
{ {
ASSERT(requestedMode == kSelected && constructFromMode == kNormalIcon); ASSERT(requestedMode == kSelected && constructFromMode == kNormalIcon);
// for now // for now
if (requestedMode == kSelected && constructFromMode == kNormalIcon)
return IconCache::sIconCache->MakeSelectedIcon(constructFrom, size, lazyBitmap); if (requestedMode == kSelected && constructFromMode == kNormalIcon) {
return IconCache::sIconCache->MakeSelectedIcon(constructFrom, size,
lazyBitmap);
}
return NULL; return NULL;
} }
@@ -260,7 +264,8 @@ IconCacheEntry::ConstructBitmap(IconDrawMode requestedMode, icon_size size,
{ {
BBitmap* source = (size == B_MINI_ICON) ? fMiniIcon : fLargeIcon; BBitmap* source = (size == B_MINI_ICON) ? fMiniIcon : fLargeIcon;
ASSERT(source); ASSERT(source);
return ConstructBitmap(source, requestedMode, kNormalIcon, size, lazyBitmap); return ConstructBitmap(source, requestedMode, kNormalIcon, size,
lazyBitmap);
} }
@@ -303,14 +308,13 @@ IconCache::IconCache()
} }
// The following calls use the icon lookup sequence node-prefered app for node- // The following calls use the icon lookup sequence node-prefered app for
// metamime-preferred app for metamime to find an icon; // node-metamime-preferred app for metamime to find an icon;
// if we are trying to get a specialized icon, we will first look for a normal // if we are trying to get a specialized icon, we will first look for a normal
// icon in each of the locations, if we get a hit, we look for the specialized, // icon in each of the locations, if we get a hit, we look for the
// if we don't find one, we try to auto-construct one, if we can't we assume the // specialized, if we don't find one, we try to auto-construct one, if we
// icon is not available // can't we assume the icon is not available for now the code only looks for
// for now the code only looks for normal icons, selected icons are auto-generated // normal icons, selected icons are auto-generated
IconCacheEntry* IconCacheEntry*
IconCache::GetIconForPreferredApp(const char* fileTypeSignature, IconCache::GetIconForPreferredApp(const char* fileTypeSignature,
const char* preferredApp, IconDrawMode mode, icon_size size, const char* preferredApp, IconDrawMode mode, icon_size size,
@@ -336,20 +340,24 @@ IconCache::GetIconForPreferredApp(const char* fileTypeSignature,
if (!entry || !entry->HaveIconBitmap(NORMAL_ICON_ONLY, size)) { if (!entry || !entry->HaveIconBitmap(NORMAL_ICON_ONLY, size)) {
PRINT_DISK_HITS(("File %s; Line %d # hitting disk for preferredApp %s, type %s\n", PRINT_DISK_HITS(
("File %s; Line %d # hitting disk for preferredApp %s, type %s\n",
__FILE__, __LINE__, preferredApp, fileTypeSignature)); __FILE__, __LINE__, preferredApp, fileTypeSignature));
BMimeType preferredAppType(preferredApp); BMimeType preferredAppType(preferredApp);
BString signature(fileTypeSignature); BString signature(fileTypeSignature);
signature.ToLower(); signature.ToLower();
if (preferredAppType.GetIconForType(signature.String(), lazyBitmap->Get(), if (preferredAppType.GetIconForType(signature.String(),
size) != B_OK) lazyBitmap->Get(), size) != B_OK) {
return NULL; return NULL;
}
BBitmap* bitmap = lazyBitmap->Adopt(); BBitmap* bitmap = lazyBitmap->Adopt();
if (!entry) { if (!entry) {
PRINT_ADD_ITEM(("File %s; Line %d # adding entry for preferredApp %s, type %s\n", PRINT_ADD_ITEM(
__FILE__, __LINE__, preferredApp, fileTypeSignature)); ("File %s; Line %d # adding entry for preferredApp %s, "
"type %s\n", __FILE__, __LINE__, preferredApp,
fileTypeSignature));
entry = fSharedCache.AddItem(fileTypeSignature, preferredApp); entry = fSharedCache.AddItem(fileTypeSignature, preferredApp);
} }
entry->SetIcon(bitmap, kNormalIcon, size); entry->SetIcon(bitmap, kNormalIcon, size);
@@ -394,8 +402,10 @@ IconCache::GetIconFromMetaMime(const char* fileType, IconDrawMode mode,
return NULL; return NULL;
SharedCacheEntry* aliasTo = NULL; SharedCacheEntry* aliasTo = NULL;
if (entry) if (entry) {
aliasTo = (SharedCacheEntry*)entry->ResolveIfAlias(&fSharedCache); aliasTo
= (SharedCacheEntry*)entry->ResolveIfAlias(&fSharedCache);
}
// look for icon defined by preferred app from metamime // look for icon defined by preferred app from metamime
aliasTo = (SharedCacheEntry*)GetIconForPreferredApp(fileType, aliasTo = (SharedCacheEntry*)GetIconForPreferredApp(fileType,
@@ -407,7 +417,8 @@ IconCache::GetIconFromMetaMime(const char* fileType, IconDrawMode mode,
// make an aliased entry so that the next time we get a // make an aliased entry so that the next time we get a
// hit on the first FindItem in here // hit on the first FindItem in here
if (!entry) { if (!entry) {
PRINT_ADD_ITEM(("File %s; Line %d # adding entry as alias for type %s\n", PRINT_ADD_ITEM(
("File %s; Line %d # adding entry as alias for type %s\n",
__FILE__, __LINE__, fileType)); __FILE__, __LINE__, fileType));
entry = fSharedCache.AddItem(&aliasTo, fileType); entry = fSharedCache.AddItem(&aliasTo, fileType);
entry->SetAliasFor(&fSharedCache, aliasTo); entry->SetAliasFor(&fSharedCache, aliasTo);
@@ -489,8 +500,9 @@ IconCache::GetIconFromFileTypes(ModelNodeLazyOpener* modelOpener,
lazyBitmap, entry); lazyBitmap, entry);
#if DEBUG #if DEBUG
else else
PRINT(("File %s; Line %d # failed to get supertype for type %s\n", PRINT(
__FILE__, __LINE__, fileType)); ("File %s; Line %d # failed to get supertype for "
"type %s\n", __FILE__, __LINE__, fileType));
#endif #endif
} }
} }
@@ -503,15 +515,20 @@ IconCache::GetIconFromFileTypes(ModelNodeLazyOpener* modelOpener,
// make an aliased entry so that the next time we get a // make an aliased entry so that the next time we get a
// hit and substitute a generic icon right away // hit and substitute a generic icon right away
PRINT_ADD_ITEM(("File %s; Line %d # adding entry as alias for preferredApp %s, type %s\n", PRINT_ADD_ITEM(
("File %s; Line %d # adding entry as alias for "
"preferredApp %s, type %s\n",
__FILE__, __LINE__, nodePreferredApp, fileType)); __FILE__, __LINE__, nodePreferredApp, fileType));
IconCacheEntry* aliasedEntry = fSharedCache.AddItem((SharedCacheEntry**)&entry, IconCacheEntry* aliasedEntry
fileType, nodePreferredApp); = fSharedCache.AddItem((SharedCacheEntry**)&entry, fileType,
aliasedEntry->SetAliasFor(&fSharedCache, (SharedCacheEntry*)entry); nodePreferredApp);
aliasedEntry->SetAliasFor(&fSharedCache,
(SharedCacheEntry*)entry);
// OK to cast here, have a runtime check // OK to cast here, have a runtime check
source = kPreferredAppForNode; source = kPreferredAppForNode;
// set source as preferred for node, so that next time we get a hit in // set source as preferred for node, so that next time we
// the initial find that uses GetIconForPreferredApp // get a hit in the initial find that uses
// GetIconForPreferredApp
} else } else
source = kMetaMime; source = kMetaMime;
#if DEBUG #if DEBUG
@@ -542,8 +559,8 @@ IconCache::GetVolumeIcon(AutoLock<SimpleIconCache>*nodeCacheLocker,
if (source == kTrackerDefault) { if (source == kTrackerDefault) {
// if tracker default, resolved entry is from shared cache // if tracker default, resolved entry is from shared cache
// this could be done a little cleaner if entry had a way to reach // this could be done a little cleaner if entry had a way to
// the cache it is in // reach the cache it is in
*resultingOpenCache = sharedCacheLocker; *resultingOpenCache = sharedCacheLocker;
sharedCacheLocker->Lock(); sharedCacheLocker->Lock();
} }
@@ -563,7 +580,8 @@ IconCache::GetVolumeIcon(AutoLock<SimpleIconCache>*nodeCacheLocker,
BBitmap* bitmap = lazyBitmap->Get(); BBitmap* bitmap = lazyBitmap->Get();
GetTrackerResources()->GetIconResource(R_ShareIcon, size, bitmap); GetTrackerResources()->GetIconResource(R_ShareIcon, size, bitmap);
if (!entry) { if (!entry) {
PRINT_ADD_ITEM(("File %s; Line %d # adding entry for model %s\n", PRINT_ADD_ITEM(
("File %s; Line %d # adding entry for model %s\n",
__FILE__, __LINE__, model->Name())); __FILE__, __LINE__, model->Name()));
entry = fNodeCache.AddItem(model->NodeRef()); entry = fNodeCache.AddItem(model->NodeRef());
} }
@@ -573,7 +591,8 @@ IconCache::GetVolumeIcon(AutoLock<SimpleIconCache>*nodeCacheLocker,
BBitmap* bitmap = lazyBitmap->Adopt(); BBitmap* bitmap = lazyBitmap->Adopt();
ASSERT(bitmap); ASSERT(bitmap);
if (!entry) { if (!entry) {
PRINT_ADD_ITEM(("File %s; Line %d # adding entry for model %s\n", PRINT_ADD_ITEM(
("File %s; Line %d # adding entry for model %s\n",
__FILE__, __LINE__, model->Name())); __FILE__, __LINE__, model->Name()));
entry = fNodeCache.AddItem(model->NodeRef()); entry = fNodeCache.AddItem(model->NodeRef());
} }
@@ -584,7 +603,8 @@ IconCache::GetVolumeIcon(AutoLock<SimpleIconCache>*nodeCacheLocker,
*resultingOpenCache = sharedCacheLocker; *resultingOpenCache = sharedCacheLocker;
sharedCacheLocker->Lock(); sharedCacheLocker->Lock();
// If the volume doesnt have a device it should have the generic icon // If the volume doesnt have a device it should have
// the generic icon
entry = GetIconFromMetaMime(B_VOLUME_MIMETYPE, mode, entry = GetIconFromMetaMime(B_VOLUME_MIMETYPE, mode,
size, lazyBitmap, entry); size, lazyBitmap, entry);
} }
@@ -754,8 +774,10 @@ IconCache::GetNodeIcon(ModelNodeLazyOpener* modelOpener,
status_t result; status_t result;
if (file) if (file)
result = GetAppIconFromAttr(file, lazyBitmap->Get(), size); result = GetAppIconFromAttr(file, lazyBitmap->Get(), size);
else else {
result = GetFileIconFromAttr(model->Node(), lazyBitmap->Get(), size); result = GetFileIconFromAttr(model->Node(), lazyBitmap->Get(),
size);
}
if (result == B_OK) { if (result == B_OK) {
// node has it's own icon, use it // node has it's own icon, use it
@@ -806,7 +828,8 @@ IconCache::GetGenericIcon(AutoLock<SimpleIconCache>* sharedCacheLocker,
// make an aliased entry so that the next time we get a // make an aliased entry so that the next time we get a
// hit and substitute a generic icon right away // hit and substitute a generic icon right away
PRINT_ADD_ITEM(("File %s; Line %d # adding entry for preferredApp %s, type %s\n", PRINT_ADD_ITEM(
("File %s; Line %d # adding entry for preferredApp %s, type %s\n",
__FILE__, __LINE__, model->PreferredAppSignature(), __FILE__, __LINE__, model->PreferredAppSignature(),
model->MimeType())); model->MimeType()));
IconCacheEntry* aliasedEntry = fSharedCache.AddItem( IconCacheEntry* aliasedEntry = fSharedCache.AddItem(
@@ -913,9 +936,9 @@ IconCache::Preload(AutoLock<SimpleIconCache>* nodeCacheLocker,
model, source, mode, size, &lazyBitmap, entry); model, source, mode, size, &lazyBitmap, entry);
} }
} }
// update the icon source // update the icon source
model->SetIconFrom(source); model->SetIconFrom(source);
} else { } else {
// we already know where the icon should come from, // we already know where the icon should come from,
// use shortcuts to get it // use shortcuts to get it
@@ -1001,18 +1024,21 @@ IconCache::Preload(AutoLock<SimpleIconCache>* nodeCacheLocker,
if (!entry || !entry->HaveIconBitmap(mode, size)) { if (!entry || !entry->HaveIconBitmap(mode, size)) {
// we don't have an icon, go with the generic // we don't have an icon, go with the generic
PRINT(("icon cache complete miss, falling back on generic icon for %s\n", PRINT(
model->Name())); ("icon cache complete miss, falling back on generic icon "
"for %s\n", model->Name()));
entry = GetGenericIcon(sharedCacheLocker, &resultingOpenCache, entry = GetGenericIcon(sharedCacheLocker, &resultingOpenCache,
model, source, mode, size, &lazyBitmap, entry); model, source, mode, size, &lazyBitmap, entry);
// we don't even have generic, something is really broken, // we don't even have generic, something is really broken,
// go with hardcoded generic icon // go with hardcoded generic icon
if (!entry || !entry->HaveIconBitmap(mode, size)) { if (!entry || !entry->HaveIconBitmap(mode, size)) {
PRINT(("icon cache complete miss, falling back on generic icon for %s\n", PRINT(
model->Name())); ("icon cache complete miss, falling back on generic "
entry = GetFallbackIcon(sharedCacheLocker, &resultingOpenCache, "icon for %s\n", model->Name()));
model, mode, size, &lazyBitmap, entry); entry = GetFallbackIcon(sharedCacheLocker,
&resultingOpenCache, model, mode, size, &lazyBitmap,
entry);
} }
// force icon pick up next time around because we probably just // force icon pick up next time around because we probably just
@@ -1061,8 +1087,9 @@ IconCache::Draw(Model* model, BView* view, BPoint where, IconDrawMode mode,
void void
IconCache::SyncDraw(Model* model, BView* view, BPoint where, IconDrawMode mode, IconCache::SyncDraw(Model* model, BView* view, BPoint where,
icon_size size, void (*blitFunc)(BView*, BPoint, BBitmap*, void*), IconDrawMode mode, icon_size size,
void (*blitFunc)(BView*, BPoint, BBitmap*, void*),
void* passThruState) void* passThruState)
{ {
AutoLock<SimpleIconCache> nodeCacheLocker(&fNodeCache, false); AutoLock<SimpleIconCache> nodeCacheLocker(&fNodeCache, false);
@@ -1083,12 +1110,14 @@ IconCache::SyncDraw(Model* model, BView* view, BPoint where, IconDrawMode mode,
void void
IconCache::Preload(Model* model, IconDrawMode mode, icon_size size, bool permanent) IconCache::Preload(Model* model, IconDrawMode mode, icon_size size,
bool permanent)
{ {
AutoLock<SimpleIconCache> nodeCacheLocker(&fNodeCache, false); AutoLock<SimpleIconCache> nodeCacheLocker(&fNodeCache, false);
AutoLock<SimpleIconCache> sharedCacheLocker(&fSharedCache, false); AutoLock<SimpleIconCache> sharedCacheLocker(&fSharedCache, false);
Preload(&nodeCacheLocker, &sharedCacheLocker, 0, model, mode, size, permanent); Preload(&nodeCacheLocker, &sharedCacheLocker, 0, model, mode, size,
permanent);
} }
@@ -1358,9 +1387,8 @@ IconCacheEntry::RetireIcons(BObjectList<BBitmap>* retiredBitmapList)
// In debug mode keep the hash table sizes small so that they grow a lot and // In debug mode keep the hash table sizes small so that they grow a lot and
// execercise the resizing code a lot. In release mode allocate them large up-front // execercise the resizing code a lot. In release mode allocate them large
// for better performance // up-front for better performance
SharedIconCache::SharedIconCache() SharedIconCache::SharedIconCache()
#if DEBUG #if DEBUG
: SimpleIconCache("Shared Icon cache aka \"The Dead-Locker\""), : SimpleIconCache("Shared Icon cache aka \"The Dead-Locker\""),
@@ -1397,26 +1425,31 @@ SharedIconCache::Draw(IconCacheEntry* entry, BView* view, BPoint where,
SharedCacheEntry* SharedCacheEntry*
SharedIconCache::FindItem(const char* fileType, const char* appSignature) const SharedIconCache::FindItem(const char* fileType,
const char* appSignature) const
{ {
ASSERT(fileType); ASSERT(fileType);
if (!fileType) if (!fileType)
fileType = B_FILE_MIMETYPE; fileType = B_FILE_MIMETYPE;
SharedCacheEntry* result = fHashTable.FindFirst(SharedCacheEntry::Hash(fileType, SharedCacheEntry* result
= fHashTable.FindFirst(SharedCacheEntry::Hash(fileType,
appSignature)); appSignature));
if (!result) if (!result)
return NULL; return NULL;
for(;;) { for(;;) {
if (result->fFileType == fileType && result->fAppSignature == appSignature) if (result->fFileType == fileType
&& result->fAppSignature == appSignature) {
return result; return result;
}
if (result->fNext < 0) if (result->fNext < 0)
break; break;
result = const_cast<SharedCacheEntry*>(&fElementArray.At(result->fNext)); result
= const_cast<SharedCacheEntry*>(&fElementArray.At(result->fNext));
} }
return NULL; return NULL;
@@ -1438,8 +1471,8 @@ SharedIconCache::AddItem(const char* fileType, const char* appSignature)
SharedCacheEntry* SharedCacheEntry*
SharedIconCache::AddItem(SharedCacheEntry** outstandingEntry, const char* fileType, SharedIconCache::AddItem(SharedCacheEntry** outstandingEntry,
const char* appSignature) const char* fileType, const char* appSignature)
{ {
int32 entryToken = fHashTable.ElementIndex(*outstandingEntry); int32 entryToken = fHashTable.ElementIndex(*outstandingEntry);
ASSERT(entryToken >= 0); ASSERT(entryToken >= 0);
@@ -1481,7 +1514,8 @@ SharedIconCache::RemoveAliasesTo(int32 aliasIndex)
void void
SharedIconCache::SetAliasFor(IconCacheEntry* alias, const SharedCacheEntry* original) const SharedIconCache::SetAliasFor(IconCacheEntry* alias,
const SharedCacheEntry* original) const
{ {
alias->fAliasForIndex = fHashTable.ElementIndex(original); alias->fAliasForIndex = fHashTable.ElementIndex(original);
} }
@@ -1493,7 +1527,8 @@ SharedCacheEntry::SharedCacheEntry()
} }
SharedCacheEntry::SharedCacheEntry(const char* fileType, const char* appSignature) SharedCacheEntry::SharedCacheEntry(const char* fileType,
const char* appSignature)
: fNext(-1), : fNext(-1),
fFileType(fileType), fFileType(fileType),
fAppSignature(appSignature) fAppSignature(appSignature)
@@ -1502,8 +1537,8 @@ SharedCacheEntry::SharedCacheEntry(const char* fileType, const char* appSignatur
void void
SharedCacheEntry::Draw(BView* view, BPoint where, IconDrawMode mode, icon_size size, SharedCacheEntry::Draw(BView* view, BPoint where, IconDrawMode mode,
bool async) icon_size size, bool async)
{ {
BBitmap* bitmap = IconForMode(mode, size); BBitmap* bitmap = IconForMode(mode, size);
ASSERT(bitmap); ASSERT(bitmap);
@@ -1529,8 +1564,9 @@ SharedCacheEntry::Draw(BView* view, BPoint where, IconDrawMode mode, icon_size s
void void
SharedCacheEntry::Draw(BView* view, BPoint where, IconDrawMode mode, icon_size size, SharedCacheEntry::Draw(BView* view, BPoint where, IconDrawMode mode,
void (*blitFunc)(BView*, BPoint, BBitmap*, void*), void* passThruState) icon_size size, void (*blitFunc)(BView*, BPoint, BBitmap*, void*),
void* passThruState)
{ {
BBitmap* bitmap = IconForMode(mode, size); BBitmap* bitmap = IconForMode(mode, size);
if (!bitmap) if (!bitmap)
@@ -1542,7 +1578,7 @@ SharedCacheEntry::Draw(BView* view, BPoint where, IconDrawMode mode, icon_size s
// } else { // } else {
// view->SetDrawingMode(B_OP_OVER); // view->SetDrawingMode(B_OP_OVER);
// } // }
//
(blitFunc)(view, where, bitmap, passThruState); (blitFunc)(view, where, bitmap, passThruState);
} }
@@ -1572,7 +1608,8 @@ SharedCacheEntry::Hash() const
bool bool
SharedCacheEntry::operator==(const SharedCacheEntry &entry) const SharedCacheEntry::operator==(const SharedCacheEntry &entry) const
{ {
return fFileType == entry.FileType() && fAppSignature == entry.AppSignature(); return fFileType == entry.FileType()
&& fAppSignature == entry.AppSignature();
} }
@@ -1616,8 +1653,8 @@ NodeCacheEntry::NodeCacheEntry(const node_ref* node, bool permanent)
void void
NodeCacheEntry::Draw(BView* view, BPoint where, IconDrawMode mode, icon_size size, NodeCacheEntry::Draw(BView* view, BPoint where, IconDrawMode mode,
bool async) icon_size size, bool async)
{ {
BBitmap* bitmap = IconForMode(mode, size); BBitmap* bitmap = IconForMode(mode, size);
if (!bitmap) if (!bitmap)
@@ -1646,8 +1683,9 @@ NodeCacheEntry::Draw(BView* view, BPoint where, IconDrawMode mode, icon_size siz
void void
NodeCacheEntry::Draw(BView* view, BPoint where, IconDrawMode mode, icon_size size, NodeCacheEntry::Draw(BView* view, BPoint where, IconDrawMode mode,
void (*blitFunc)(BView*, BPoint, BBitmap*, void*), void* passThruState) icon_size size, void (*blitFunc)(BView*, BPoint, BBitmap*, void*),
void* passThruState)
{ {
BBitmap* bitmap = IconForMode(mode, size); BBitmap* bitmap = IconForMode(mode, size);
if (!bitmap) if (!bitmap)
@@ -1766,7 +1804,8 @@ NodeIconCache::FindItem(const node_ref* node) const
if (result->fNext < 0) if (result->fNext < 0)
break; break;
result = const_cast<NodeCacheEntry*>(&fElementArray.At(result->fNext)); result
= const_cast<NodeCacheEntry*>(&fElementArray.At(result->fNext));
} }
return NULL; return NULL;
@@ -1786,7 +1825,8 @@ NodeIconCache::AddItem(const node_ref* node, bool permanent)
NodeCacheEntry* NodeCacheEntry*
NodeIconCache::AddItem(NodeCacheEntry** outstandingEntry, const node_ref* node) NodeIconCache::AddItem(NodeCacheEntry** outstandingEntry,
const node_ref* node)
{ {
int32 entryToken = fHashTable.ElementIndex(*outstandingEntry); int32 entryToken = fHashTable.ElementIndex(*outstandingEntry);
@@ -1876,8 +1916,8 @@ SimpleIconCache::SimpleIconCache(const char* name)
void void
SimpleIconCache::Draw(IconCacheEntry*, BView*, BPoint, IconDrawMode , SimpleIconCache::Draw(IconCacheEntry*, BView*, BPoint, IconDrawMode,
icon_size , bool ) icon_size, bool)
{ {
TRESPASS(); TRESPASS();
// pure virtual, do nothing // pure virtual, do nothing
@@ -1885,8 +1925,8 @@ SimpleIconCache::Draw(IconCacheEntry*, BView*, BPoint, IconDrawMode ,
void void
SimpleIconCache::Draw(IconCacheEntry*, BView*, BPoint, IconDrawMode, icon_size, SimpleIconCache::Draw(IconCacheEntry*, BView*, BPoint, IconDrawMode,
void(*)(BView*, BPoint, BBitmap*, void*), void*) icon_size, void(*)(BView*, BPoint, BBitmap*, void*), void*)
{ {
TRESPASS(); TRESPASS();
// pure virtual, do nothing // pure virtual, do nothing
@@ -1917,8 +1957,8 @@ SimpleIconCache::IsLocked() const
// #pragma mark - // #pragma mark -
LazyBitmapAllocator::LazyBitmapAllocator(icon_size size, color_space colorSpace, LazyBitmapAllocator::LazyBitmapAllocator(icon_size size,
bool preallocate) color_space colorSpace, bool preallocate)
: fBitmap(NULL), : fBitmap(NULL),
fSize(size), fSize(size),
fColorSpace(colorSpace) fColorSpace(colorSpace)
+44 -36
View File
@@ -49,13 +49,13 @@ All rights reserved.
#include "Utilities.h" #include "Utilities.h"
// Icon cache splits icons into two caches - the shared cache, likely to get the // Icon cache splits icons into two caches - the shared cache, likely to
// most hits and the node cache. Every icon that is found in a mime based // get the most hits and the node cache. Every icon that is found in a
// structure goes into the shared cache, only files that have their own private // mime-based structure goes into the shared cache, only files that have
// icon use the node cache; // their own private icon use the node cache;
// Entries are only deleted from the shared cache if an icon for a mime type changes, // Entries are only deleted from the shared cache if an icon for a mime type
// this makes async icon drawing easier. Node cache deletes it's entries whenever a // changes, this makes async icon drawing easier. Node cache deletes it's
// file gets deleted. // entries whenever a file gets deleted.
// if a view ever uses the cache to draw in async mode, it needs to call // if a view ever uses the cache to draw in async mode, it needs to call
// it when it is being destroyed // it when it is being destroyed
@@ -100,13 +100,14 @@ enum IconDrawMode {
// Where did an icon come from // Where did an icon come from
enum IconSource { enum IconSource {
kUnknownSource, kUnknownSource,
kUnknownNotFromNode, // icon origin not known but determined not to be from kUnknownNotFromNode, // icon origin not known but determined not
// the node itself // to be from the node itself
kTrackerDefault, // file has no type, Tracker provides generic, folder, kTrackerDefault, // file has no type, Tracker provides generic,
// symlink or app // folder, symlink or app
kTrackerSupplied, // home directory, boot volume, trash, etc. kTrackerSupplied, // home directory, boot volume, trash, etc.
kMetaMime, // from BMimeType kMetaMime, // from BMimeType
kPreferredAppForType, // have a preferred application for a type, has an icon kPreferredAppForType, // have a preferred application for a type,
// has an icon
kPreferredAppForNode, // have a preferred application for this node, kPreferredAppForNode, // have a preferred application for this node,
// has an icon // has an icon
kVolume, kVolume,
@@ -127,7 +128,8 @@ public:
~IconCacheEntry(); ~IconCacheEntry();
void SetAliasFor(const SharedIconCache*, const SharedCacheEntry*); void SetAliasFor(const SharedIconCache*, const SharedCacheEntry*);
static IconCacheEntry* ResolveIfAlias(const SharedIconCache*, IconCacheEntry*); static IconCacheEntry* ResolveIfAlias(const SharedIconCache*,
IconCacheEntry*);
IconCacheEntry* ResolveIfAlias(const SharedIconCache*); IconCacheEntry* ResolveIfAlias(const SharedIconCache*);
void SetIcon(BBitmap* bitmap, IconDrawMode mode, icon_size size, void SetIcon(BBitmap* bitmap, IconDrawMode mode, icon_size size,
@@ -137,9 +139,9 @@ public:
bool CanConstructBitmap(IconDrawMode mode, icon_size size) const; bool CanConstructBitmap(IconDrawMode mode, icon_size size) const;
static bool AlternateModeForIconConstructing(IconDrawMode requestedMode, static bool AlternateModeForIconConstructing(IconDrawMode requestedMode,
IconDrawMode &alternate, icon_size size); IconDrawMode &alternate, icon_size size);
BBitmap* ConstructBitmap(BBitmap* constructFrom, IconDrawMode requestedMode, BBitmap* ConstructBitmap(BBitmap* constructFrom,
IconDrawMode constructFromMode, icon_size size, IconDrawMode requestedMode, IconDrawMode constructFromMode,
LazyBitmapAllocator*); icon_size size, LazyBitmapAllocator*);
BBitmap* ConstructBitmap(IconDrawMode requestedMode, icon_size size, BBitmap* ConstructBitmap(IconDrawMode requestedMode, icon_size size,
LazyBitmapAllocator*); LazyBitmapAllocator*);
// same as above, always uses normal icon as source // same as above, always uses normal icon as source
@@ -242,16 +244,18 @@ public:
virtual void Draw(IconCacheEntry*, BView*, BPoint, IconDrawMode, virtual void Draw(IconCacheEntry*, BView*, BPoint, IconDrawMode,
icon_size, void (*)(BView*, BPoint, BBitmap*, void*), void* = NULL); icon_size, void (*)(BView*, BPoint, BBitmap*, void*), void* = NULL);
SharedCacheEntry* FindItem(const char* fileType, const char* appSignature = 0) SharedCacheEntry* FindItem(const char* fileType,
const; const char* appSignature = 0) const;
SharedCacheEntry* AddItem(const char* fileType, const char* appSignature = 0); SharedCacheEntry* AddItem(const char* fileType,
SharedCacheEntry* AddItem(SharedCacheEntry** outstandingEntry, const char* fileType,
const char* appSignature = 0); const char* appSignature = 0);
// same as previous AddItem, updates the pointer to outstandingEntry, because SharedCacheEntry* AddItem(SharedCacheEntry** outstandingEntry,
// adding to the hash table makes any pending pointer invalid const char* fileType, const char* appSignature = 0);
// same as previous AddItem, updates the pointer to outstandingEntry,
// because adding to the hash table makes any pending pointer invalid
void IconChanged(SharedCacheEntry*); void IconChanged(SharedCacheEntry*);
void SetAliasFor(IconCacheEntry* alias, const SharedCacheEntry* original) const; void SetAliasFor(IconCacheEntry* alias,
const SharedCacheEntry* original) const;
IconCacheEntry* ResolveIfAlias(IconCacheEntry* entry) const; IconCacheEntry* ResolveIfAlias(IconCacheEntry* entry) const;
int32 EntryIndex(const SharedCacheEntry* entry) const; int32 EntryIndex(const SharedCacheEntry* entry) const;
@@ -261,9 +265,9 @@ private:
OpenHashTable<SharedCacheEntry, SharedCacheEntryArray> fHashTable; OpenHashTable<SharedCacheEntry, SharedCacheEntryArray> fHashTable;
SharedCacheEntryArray fElementArray; SharedCacheEntryArray fElementArray;
BObjectList<BBitmap> fRetiredBitmaps; BObjectList<BBitmap> fRetiredBitmaps;
// icons are drawn asynchronously, can't just delete them // icons are drawn asynchronously, can't just delete them right away,
// right away, instead have to place them onto the retired bitmap list // instead have to place them onto the retired bitmap list and wait
// and wait for the next sync to delete them // for the next sync to delete them
}; };
@@ -317,11 +321,13 @@ public:
NodeCacheEntry* FindItem(const node_ref*) const; NodeCacheEntry* FindItem(const node_ref*) const;
NodeCacheEntry* AddItem(const node_ref*, bool permanent = false); NodeCacheEntry* AddItem(const node_ref*, bool permanent = false);
NodeCacheEntry* AddItem(NodeCacheEntry** outstandingEntry, const node_ref*); NodeCacheEntry* AddItem(NodeCacheEntry** outstandingEntry,
// same as previous AddItem, updates the pointer to outstandingEntry, because const node_ref*);
// adding to the hash table makes any pending pointer invalid // same as previous AddItem, updates the pointer to outstandingEntry,
// because adding to the hash table makes any pending pointer invalid
void Deleting(const node_ref*); void Deleting(const node_ref*);
// model for this node is getting deleted (not necessarily the node itself) // model for this node is getting deleted
// (not necessarily the node itself)
void Removing(const node_ref*); void Removing(const node_ref*);
// used by permanent NodeIconCache entries, when an entry gets deleted // used by permanent NodeIconCache entries, when an entry gets deleted
void Deleting(const BView*); void Deleting(const BView*);
@@ -406,12 +412,12 @@ private:
IconCacheEntry* GetIconForPreferredApp(const char* mimeTypeSignature, IconCacheEntry* GetIconForPreferredApp(const char* mimeTypeSignature,
const char* preferredApp, IconDrawMode mode, icon_size size, const char* preferredApp, IconDrawMode mode, icon_size size,
LazyBitmapAllocator*, IconCacheEntry*); LazyBitmapAllocator*, IconCacheEntry*);
IconCacheEntry* GetIconFromFileTypes(ModelNodeLazyOpener*, IconSource &source, IconCacheEntry* GetIconFromFileTypes(ModelNodeLazyOpener*,
IconSource &source, IconDrawMode mode, icon_size size,
LazyBitmapAllocator*, IconCacheEntry*);
IconCacheEntry* GetIconFromMetaMime(const char* fileType,
IconDrawMode mode, icon_size size, LazyBitmapAllocator*, IconDrawMode mode, icon_size size, LazyBitmapAllocator*,
IconCacheEntry*); IconCacheEntry*);
IconCacheEntry* GetIconFromMetaMime(const char* fileType, IconDrawMode mode,
icon_size size, LazyBitmapAllocator*,
IconCacheEntry*);
IconCacheEntry* GetVolumeIcon(AutoLock<SimpleIconCache>* nodeCache, IconCacheEntry* GetVolumeIcon(AutoLock<SimpleIconCache>* nodeCache,
AutoLock<SimpleIconCache>* sharedCache, AutoLock<SimpleIconCache>* sharedCache,
AutoLock<SimpleIconCache>** resultingLockedCache, AutoLock<SimpleIconCache>** resultingLockedCache,
@@ -431,12 +437,14 @@ private:
AutoLock<SimpleIconCache>* nodeCache, AutoLock<SimpleIconCache>* nodeCache,
AutoLock<SimpleIconCache>** resultingLockedCache, AutoLock<SimpleIconCache>** resultingLockedCache,
Model*, IconSource&, IconDrawMode mode, Model*, IconSource&, IconDrawMode mode,
icon_size size, LazyBitmapAllocator*, IconCacheEntry*, bool permanent); icon_size size, LazyBitmapAllocator*, IconCacheEntry*,
bool permanent);
IconCacheEntry* GetGenericIcon(AutoLock<SimpleIconCache>* sharedCache, IconCacheEntry* GetGenericIcon(AutoLock<SimpleIconCache>* sharedCache,
AutoLock<SimpleIconCache>** resultingLockedCache, AutoLock<SimpleIconCache>** resultingLockedCache,
Model*, IconSource&, IconDrawMode mode, Model*, IconSource&, IconDrawMode mode,
icon_size size, LazyBitmapAllocator*, IconCacheEntry*); icon_size size, LazyBitmapAllocator*, IconCacheEntry*);
IconCacheEntry* GetFallbackIcon(AutoLock<SimpleIconCache>* sharedCacheLocker, IconCacheEntry* GetFallbackIcon(
AutoLock<SimpleIconCache>* sharedCacheLocker,
AutoLock<SimpleIconCache>** resultingOpenCache, AutoLock<SimpleIconCache>** resultingOpenCache,
Model* model, IconDrawMode mode, icon_size size, Model* model, IconDrawMode mode, icon_size size,
LazyBitmapAllocator* lazyBitmap, IconCacheEntry* entry); LazyBitmapAllocator* lazyBitmap, IconCacheEntry* entry);
+9 -6
View File
@@ -52,11 +52,12 @@ const bigtime_t kSynchMenuInvokeTimeout = 5000000;
class IconMenuItem : public PositionPassingMenuItem { class IconMenuItem : public PositionPassingMenuItem {
public: public:
IconMenuItem(const char* label, BMessage* message, BBitmap* icon); IconMenuItem(const char* label, BMessage* message, BBitmap* icon);
IconMenuItem(const char* label, BMessage* message, const char* iconType, IconMenuItem(const char* label, BMessage* message,
icon_size which); const char* iconType, icon_size which);
IconMenuItem(const char* label, BMessage* message, IconMenuItem(const char* label, BMessage* message,
const BNodeInfo* nodeInfo, icon_size which); const BNodeInfo* nodeInfo, icon_size which);
IconMenuItem(BMenu*, BMessage*, const char* iconType, icon_size which); IconMenuItem(BMenu*, BMessage*, const char* iconType,
icon_size which);
virtual ~IconMenuItem(); virtual ~IconMenuItem();
virtual void GetContentSize(float* width, float* height); virtual void GetContentSize(float* width, float* height);
@@ -72,9 +73,11 @@ class IconMenuItem : public PositionPassingMenuItem {
class ModelMenuItem : public BMenuItem { class ModelMenuItem : public BMenuItem {
public: public:
ModelMenuItem(const Model*, const char* title, BMessage*, char shortcut = '\0', ModelMenuItem(const Model*, const char* title, BMessage*,
uint32 modifiers = 0, bool drawText = true, bool extraPad = false); char shortcut = '\0', uint32 modifiers = 0,
ModelMenuItem(const Model*, BMenu*, bool drawText = true, bool extraPad = false); bool drawText = true, bool extraPad = false);
ModelMenuItem(const Model*, BMenu*, bool drawText = true,
bool extraPad = false);
virtual ~ModelMenuItem(); virtual ~ModelMenuItem();
virtual status_t SetEntry(const BEntry*); virtual status_t SetEntry(const BEntry*);
+165 -91
View File
@@ -120,7 +120,8 @@ class AttributeView : public BView {
BTextView* TextView() const { return fTitleEditView; } BTextView* TextView() const { return fTitleEditView; }
static filter_result TextViewFilter(BMessage*, BHandler**, BMessageFilter*); static filter_result TextViewFilter(BMessage*, BHandler**,
BMessageFilter*);
off_t LastSize() const; off_t LastSize() const;
void SetLastSize(off_t); void SetLastSize(off_t);
@@ -278,7 +279,8 @@ OpenToolTipWindow(BScreen& screen, BRect rect, const char* name,
// #pragma mark - // #pragma mark -
BInfoWindow::BInfoWindow(Model* model, int32 group_index, LockingList<BWindow>* list) BInfoWindow::BInfoWindow(Model* model, int32 group_index,
LockingList<BWindow>* list)
: BWindow(BInfoWindow::InfoWindowRect(false), : BWindow(BInfoWindow::InfoWindowRect(false),
"InfoWindow", B_TITLED_WINDOW, "InfoWindow", B_TITLED_WINDOW,
B_NOT_RESIZABLE | B_NOT_ZOOMABLE, B_CURRENT_WORKSPACE), B_NOT_RESIZABLE | B_NOT_ZOOMABLE, B_CURRENT_WORKSPACE),
@@ -366,7 +368,8 @@ BInfoWindow::Show()
AddChild(fAttributeView); AddChild(fAttributeView);
// position window appropriately based on index // position window appropriately based on index
BRect windRect(InfoWindowRect(TargetModel()->IsSymLink() || TargetModel()->IsFile())); BRect windRect(InfoWindowRect(TargetModel()->IsSymLink()
|| TargetModel()->IsFile()));
if ((fIndex + 2) % 2 == 1) { if ((fIndex + 2) % 2 == 1) {
windRect.OffsetBy(320, 0); windRect.OffsetBy(320, 0);
fIndex--; fIndex--;
@@ -499,8 +502,9 @@ BInfoWindow::MessageReceived(BMessage* message)
// We now have to re-target the broken symlink. Unfortunately, // We now have to re-target the broken symlink. Unfortunately,
// there's no way to change the target of an existing symlink. // there's no way to change the target of an existing symlink.
// So we have to delete the old one and create a new one. // So we have to delete the old one and create a new one.
// First, stop watching the broken node (we don't want this window // First, stop watching the broken node
// to quit when the node is removed.) // (we don't want this window to quit when the node
// is removed.)
stop_watching(this); stop_watching(this);
// Get the parent // Get the parent
@@ -601,8 +605,10 @@ BInfoWindow::MessageReceived(BMessage* message)
case B_STAT_CHANGED: case B_STAT_CHANGED:
case B_ATTR_CHANGED: case B_ATTR_CHANGED:
fAttributeView->ModelChanged(TargetModel(), message); fAttributeView->ModelChanged(TargetModel(), message);
// must be called before the FilePermissionView::ModelChanged() // must be called before the
// call, because it changes the model... (bad style!) // FilePermissionView::ModelChanged()
// call, because it changes the model...
// (bad style!)
if (fPermissionsView != NULL) if (fPermissionsView != NULL)
fPermissionsView->ModelChanged(TargetModel()); fPermissionsView->ModelChanged(TargetModel());
@@ -610,13 +616,15 @@ BInfoWindow::MessageReceived(BMessage* message)
case B_DEVICE_UNMOUNTED: case B_DEVICE_UNMOUNTED:
{ {
// We were watching a volume that is no longer mounted, // We were watching a volume that is no longer
// we might as well quit // mounted, we might as well quit
node_ref itemNode; node_ref itemNode;
// Only the device information is available // Only the device information is available
message->FindInt32("device", &itemNode.device); message->FindInt32("device", &itemNode.device);
if (TargetModel()->NodeRef()->device == itemNode.device) if (TargetModel()->NodeRef()->device
== itemNode.device) {
Close(); Close();
}
break; break;
} }
@@ -629,8 +637,10 @@ BInfoWindow::MessageReceived(BMessage* message)
case kPermissionsSelected: case kPermissionsSelected:
if (fPermissionsView == NULL) { if (fPermissionsView == NULL) {
// Only true on first call. // Only true on first call.
fPermissionsView = new FilePermissionsView(BRect(kBorderWidth + 1, fPermissionsView
fAttributeView->Bounds().bottom, fAttributeView->Bounds().right, = new FilePermissionsView(BRect(kBorderWidth + 1,
fAttributeView->Bounds().bottom,
fAttributeView->Bounds().right,
fAttributeView->Bounds().bottom+80), fModel); fAttributeView->Bounds().bottom+80), fModel);
ResizeBy(0, fPermissionsView->Bounds().Height()); ResizeBy(0, fPermissionsView->Bounds().Height());
@@ -661,7 +671,7 @@ BInfoWindow::GetSizeString(BString &result, off_t size, int32 fileCount)
char sizeBuffer[128]; char sizeBuffer[128];
result << string_for_size((double)size, sizeBuffer, sizeof(sizeBuffer)); result << string_for_size((double)size, sizeBuffer, sizeof(sizeBuffer));
// when we show the byte size, format it with a thousands delimiter (comma) // when we show the byte size, format it with a thousands delimiter
// TODO: use BCountry::FormatNumber // TODO: use BCountry::FormatNumber
if (size >= kKBSize) { if (size >= kKBSize) {
char numStr[128]; char numStr[128];
@@ -784,7 +794,8 @@ BInfoWindow::CalcSize(void* castToWindow)
void void
BInfoWindow::SetSizeStr(const char* sizeStr) BInfoWindow::SetSizeStr(const char* sizeStr)
{ {
AttributeView* view = dynamic_cast<AttributeView *>(FindView("attr_view")); AttributeView* view
= dynamic_cast<AttributeView *>(FindView("attr_view"));
if (view) if (view)
view->SetSizeStr(sizeStr); view->SetSizeStr(sizeStr);
} }
@@ -803,7 +814,8 @@ BInfoWindow::OpenFilePanel(const entry_ref* ref)
false, &message); false, &message);
if (fFilePanel != NULL) { if (fFilePanel != NULL) {
fFilePanel->SetButtonLabel(B_DEFAULT_BUTTON, B_TRANSLATE("Select")); fFilePanel->SetButtonLabel(B_DEFAULT_BUTTON,
B_TRANSLATE("Select"));
fFilePanel->Window()->ResizeTo(500, 300); fFilePanel->Window()->ResizeTo(500, 300);
BString title(B_TRANSLATE_COMMENT("Link \"%name\" to:", BString title(B_TRANSLATE_COMMENT("Link \"%name\" to:",
"File dialog title for new sym link")); "File dialog title for new sym link"));
@@ -826,7 +838,8 @@ BInfoWindow::OpenFilePanel(const entry_ref* ref)
AttributeView::AttributeView(BRect rect, Model* model) AttributeView::AttributeView(BRect rect, Model* model)
: BView(rect, "attr_view", B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_PULSE_NEEDED), : BView(rect, "attr_view", B_FOLLOW_ALL_SIDES,
B_WILL_DRAW | B_PULSE_NEEDED),
fDivider(0), fDivider(0),
fPreferredAppMenu(NULL), fPreferredAppMenu(NULL),
fModel(model), fModel(model),
@@ -873,9 +886,12 @@ AttributeView::AttributeView(BRect rect, Model* model)
fTitleRect.left = fIconRect.right + 5; fTitleRect.left = fIconRect.right + 5;
fTitleRect.top = 0; fTitleRect.top = 0;
fTitleRect.bottom = fontMetrics.ascent + 1; fTitleRect.bottom = fontMetrics.ascent + 1;
fTitleRect.right = min_c(fTitleRect.left + currentFont.StringWidth(fModel->Name()), Bounds().Width() - 5); fTitleRect.right = min_c(
fTitleRect.left + currentFont.StringWidth(fModel->Name()),
Bounds().Width() - 5);
// Offset so that it centers with the icon // Offset so that it centers with the icon
fTitleRect.OffsetBy(0, fIconRect.top + ((fIconRect.Height() - fTitleRect.Height()) / 2)); fTitleRect.OffsetBy(0,
fIconRect.top + ((fIconRect.Height() - fTitleRect.Height()) / 2));
// Make some room for the border for when we are in edit mode // Make some room for the border for when we are in edit mode
// (Negative numbers increase the size of the rect) // (Negative numbers increase the size of the rect)
fTitleRect.InsetBy(-1, -2); fTitleRect.InsetBy(-1, -2);
@@ -904,8 +920,10 @@ AttributeView::AttributeView(BRect rect, Model* model)
BRect preferredAppRect(kBorderWidth + kBorderMargin, BRect preferredAppRect(kBorderWidth + kBorderMargin,
fTitleRect.bottom + (lineHeight * 7), fTitleRect.bottom + (lineHeight * 7),
Bounds().Width() - 5, fTitleRect.bottom + (lineHeight * 8)); Bounds().Width() - 5, fTitleRect.bottom + (lineHeight * 8));
fPreferredAppMenu = new BMenuField(preferredAppRect, "", "", new BPopUpMenu("")); fPreferredAppMenu = new BMenuField(preferredAppRect, "", "",
fDivider = currentFont.StringWidth(B_TRANSLATE("Opens with:")) + 5; new BPopUpMenu(""));
fDivider = currentFont.StringWidth(B_TRANSLATE("Opens with:"))
+ 5;
fPreferredAppMenu->SetDivider(fDivider); fPreferredAppMenu->SetDivider(fDivider);
fDivider += (preferredAppRect.left - 2); fDivider += (preferredAppRect.left - 2);
fPreferredAppMenu->SetFont(&currentFont); fPreferredAppMenu->SetFont(&currentFont);
@@ -928,8 +946,10 @@ AttributeView::AttributeView(BRect rect, Model* model)
for (int32 index = 0; ; index++) { for (int32 index = 0; ; index++) {
const char* signature; const char* signature;
if (supportingAppList.FindString("applications", index, &signature) != B_OK) if (supportingAppList.FindString("applications", index,
&signature) != B_OK) {
break; break;
}
// Only add separator item if there are more items // Only add separator item if there are more items
if (index == 0) if (index == 0)
@@ -1020,7 +1040,8 @@ AttributeView::InitStrings(const Model* model)
// If the BPath is initialized, then check the file for existence // If the BPath is initialized, then check the file for existence
if (traversedPath.InitCheck() == B_OK) { if (traversedPath.InitCheck() == B_OK) {
BEntry entry(traversedPath.Path(), false); // look at the target itself BEntry entry(traversedPath.Path(), false);
// look at the target itself
if (entry.InitCheck() == B_OK && entry.Exists()) if (entry.InitCheck() == B_OK && entry.Exists())
linked = true; linked = true;
} }
@@ -1034,8 +1055,10 @@ AttributeView::InitStrings(const Model* model)
if (!linked) if (!linked)
fLinkToStr += " (broken)"; // link points to missing object fLinkToStr += " (broken)"; // link points to missing object
} else if (model->IsExecutable()) { } else if (model->IsExecutable()) {
if (((Model*)model)->GetLongVersionString(fDescStr, B_APP_VERSION_KIND) == B_OK) { if (((Model*)model)->GetLongVersionString(fDescStr,
// we want a flat string, so we replace all newlines/tabs with spaces B_APP_VERSION_KIND) == B_OK) {
// we want a flat string, so replace all newlines and tabs
// with spaces
fDescStr.ReplaceAll('\n', ' '); fDescStr.ReplaceAll('\n', ' ');
fDescStr.ReplaceAll('\t', ' '); fDescStr.ReplaceAll('\t', ' ');
} else } else
@@ -1097,10 +1120,10 @@ AttributeView::ModelChanged(Model* model, BMessage* message)
// ensure notification is for us // ensure notification is for us
if (*model->NodeRef() == itemNode if (*model->NodeRef() == itemNode
// For volumes, the device ID is obviously not handled in a // For volumes, the device ID is obviously not handled in a
// consistent way; the node monitor sends us the ID of the parent // consistent way; the node monitor sends us the ID of the
// device, while the model is set to the device of the volume // parent device, while the model is set to the device of the
// directly - this hack works for volumes that are mounted in // volume directly - this hack works for volumes that are
// the root directory // mounted in the root directory
|| (model->IsVolume() || (model->IsVolume()
&& itemNode.device == 1 && itemNode.device == 1
&& itemNode.node == model->NodeRef()->node)) { && itemNode.node == model->NodeRef()->node)) {
@@ -1167,8 +1190,8 @@ AttributeView::ModelChanged(Model* model, BMessage* message)
fModel = model; fModel = model;
if (fModel->IsSymLink()) { if (fModel->IsSymLink()) {
// if we are looking at a symlink, deference the model and look at the // if we are looking at a symlink, deference the model and look
// target // at the target
Model* resolvedModel = new Model(model->EntryRef(), true, true); Model* resolvedModel = new Model(model->EntryRef(), true, true);
if (resolvedModel->InitCheck() == B_OK) { if (resolvedModel->InitCheck() == B_OK) {
if (fIconModel != fModel) if (fIconModel != fModel)
@@ -1245,7 +1268,8 @@ AttributeView::MouseDown(BPoint point)
} else if (fTitleEditView) { } else if (fTitleEditView) {
FinishEditingTitle(true); FinishEditingTitle(true);
} else if (fSizeRect.Contains(point)) { } else if (fSizeRect.Contains(point)) {
if (fModel->IsDirectory() && !fModel->IsVolume() && !fModel->IsRoot()) { if (fModel->IsDirectory() && !fModel->IsVolume()
&& !fModel->IsRoot()) {
InvertRect(fSizeRect); InvertRect(fSizeRect);
fTrackingState = size_track; fTrackingState = size_track;
} else } else
@@ -1253,13 +1277,16 @@ AttributeView::MouseDown(BPoint point)
} else if (fIconRect.Contains(point)) { } else if (fIconRect.Contains(point)) {
uint32 buttons; uint32 buttons;
Window()->CurrentMessage()->FindInt32("buttons", (int32*)&buttons); Window()->CurrentMessage()->FindInt32("buttons", (int32*)&buttons);
if (((modifiers() & B_CONTROL_KEY) != 0) || (buttons & B_SECONDARY_MOUSE_BUTTON) != 0) { if (((modifiers() & B_CONTROL_KEY) != 0)
|| (buttons & B_SECONDARY_MOUSE_BUTTON) != 0) {
// Show contextual menu // Show contextual menu
BPopUpMenu* contextMenu = new BPopUpMenu("FileContext", false, false); BPopUpMenu* contextMenu
= new BPopUpMenu("FileContext", false, false);
if (contextMenu) { if (contextMenu) {
BuildContextMenu(contextMenu); BuildContextMenu(contextMenu);
contextMenu->SetAsyncAutoDestruct(true); contextMenu->SetAsyncAutoDestruct(true);
contextMenu->Go(ConvertToScreen(point), true, true, ConvertToScreen(fIconRect)); contextMenu->Go(ConvertToScreen(point), true, true,
ConvertToScreen(fIconRect));
} }
} else { } else {
// Check to see if the point is actually on part of the icon, // Check to see if the point is actually on part of the icon,
@@ -1268,21 +1295,25 @@ AttributeView::MouseDown(BPoint point)
BPoint offsetPoint; BPoint offsetPoint;
offsetPoint.x = point.x - fIconRect.left; offsetPoint.x = point.x - fIconRect.left;
offsetPoint.y = point.y - fIconRect.top; offsetPoint.y = point.y - fIconRect.top;
if (IconCache::sIconCache->IconHitTest(offsetPoint, fIconModel, kNormalIcon, B_LARGE_ICON)) { if (IconCache::sIconCache->IconHitTest(offsetPoint, fIconModel,
kNormalIcon, B_LARGE_ICON)) {
// Can't drag the trash anywhere.. // Can't drag the trash anywhere..
fTrackingState = fModel->IsTrash() ? open_only_track : icon_track; fTrackingState = fModel->IsTrash()
? open_only_track : icon_track;
// Check for possible double click // Check for possible double click
if (abs((int32)(fClickPoint.x - point.x)) < kDragSlop if (abs((int32)(fClickPoint.x - point.x)) < kDragSlop
&& abs((int32)(fClickPoint.y - point.y)) < kDragSlop) { && abs((int32)(fClickPoint.y - point.y)) < kDragSlop) {
int32 clickCount; int32 clickCount;
Window()->CurrentMessage()->FindInt32("clicks", &clickCount); Window()->CurrentMessage()->FindInt32("clicks",
&clickCount);
// This checks the* previous* click point // This checks the* previous* click point
if (clickCount == 2) { if (clickCount == 2) {
offsetPoint.x = fClickPoint.x - fIconRect.left; offsetPoint.x = fClickPoint.x - fIconRect.left;
offsetPoint.y = fClickPoint.y - fIconRect.top; offsetPoint.y = fClickPoint.y - fIconRect.top;
fDoubleClick = IconCache::sIconCache->IconHitTest(offsetPoint, fDoubleClick
= IconCache::sIconCache->IconHitTest(offsetPoint,
fIconModel, kNormalIcon, B_LARGE_ICON); fIconModel, kNormalIcon, B_LARGE_ICON);
} }
} }
@@ -1301,7 +1332,8 @@ AttributeView::MouseMoved(BPoint point, uint32, const BMessage* message)
// Highlight Drag target // Highlight Drag target
if (message && message->ReturnAddress() != BMessenger(this) if (message && message->ReturnAddress() != BMessenger(this)
&& message->what == B_SIMPLE_DATA && message->what == B_SIMPLE_DATA
&& BPoseView::CanHandleDragSelection(fModel, message, (modifiers() & B_CONTROL_KEY) != 0)) { && BPoseView::CanHandleDragSelection(fModel, message,
(modifiers() & B_CONTROL_KEY) != 0)) {
bool overTarget = fIconRect.Contains(point); bool overTarget = fIconRect.Contains(point);
SetDrawingMode(B_OP_OVER); SetDrawingMode(B_OP_OVER);
if (overTarget != fIsDropTarget) { if (overTarget != fIsDropTarget) {
@@ -1334,19 +1366,23 @@ AttributeView::MouseMoved(BPoint point, uint32, const BMessage* message)
break; break;
case icon_track: case icon_track:
if (fMouseDown && !fDragging && (abs((int32)(point.x - fClickPoint.x)) > kDragSlop if (fMouseDown && !fDragging
&& (abs((int32)(point.x - fClickPoint.x)) > kDragSlop
|| abs((int32)(point.y - fClickPoint.y)) > kDragSlop)) { || abs((int32)(point.y - fClickPoint.y)) > kDragSlop)) {
// Find the required height // Find the required height
BFont font; BFont font;
GetFont(&font); GetFont(&font);
font.SetSize(kAttribFontHeight); font.SetSize(kAttribFontHeight);
float height = CurrentFontHeight(kAttribFontHeight) + fIconRect.Height() + 8; float height = CurrentFontHeight(kAttribFontHeight)
+ fIconRect.Height() + 8;
BRect rect(0, 0, min_c(fIconRect.Width() BRect rect(0, 0, min_c(fIconRect.Width()
+ font.StringWidth(fModel->Name()) + 4, fIconRect.Width() * 3), height); + font.StringWidth(fModel->Name()) + 4,
fIconRect.Width() * 3), height);
BBitmap* dragBitmap = new BBitmap(rect, B_RGBA32, true); BBitmap* dragBitmap = new BBitmap(rect, B_RGBA32, true);
dragBitmap->Lock(); dragBitmap->Lock();
BView* view = new BView(dragBitmap->Bounds(), "", B_FOLLOW_NONE, 0); BView* view = new BView(dragBitmap->Bounds(), "",
B_FOLLOW_NONE, 0);
dragBitmap->AddChild(view); dragBitmap->AddChild(view);
view->SetOrigin(0, 0); view->SetOrigin(0, 0);
BRect clipRect(view->Bounds()); BRect clipRect(view->Bounds());
@@ -1358,23 +1394,27 @@ AttributeView::MouseMoved(BPoint point, uint32, const BMessage* message)
view->SetHighColor(0, 0, 0, 0); view->SetHighColor(0, 0, 0, 0);
view->FillRect(view->Bounds()); view->FillRect(view->Bounds());
view->SetDrawingMode(B_OP_ALPHA); view->SetDrawingMode(B_OP_ALPHA);
view->SetHighColor(0, 0, 0, 128); // set the level of transparency by value view->SetHighColor(0, 0, 0, 128);
// set the level of transparency by value
view->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE); view->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE);
// Draw the icon // Draw the icon
float hIconOffset = (rect.Width() - fIconRect.Width()) / 2; float hIconOffset = (rect.Width() - fIconRect.Width()) / 2;
IconCache::sIconCache->Draw(fIconModel, view, BPoint(hIconOffset, 0), IconCache::sIconCache->Draw(fIconModel, view,
kNormalIcon, B_LARGE_ICON, true); BPoint(hIconOffset, 0), kNormalIcon, B_LARGE_ICON, true);
// See if we need to truncate the string // See if we need to truncate the string
BString nameString(fModel->Name()); BString nameString(fModel->Name());
if (view->StringWidth(fModel->Name()) > rect.Width()) if (view->StringWidth(fModel->Name()) > rect.Width()) {
view->TruncateString(&nameString, B_TRUNCATE_END, rect.Width() - 5); view->TruncateString(&nameString, B_TRUNCATE_END,
rect.Width() - 5);
}
// Draw the label // Draw the label
font_height fontHeight; font_height fontHeight;
font.GetHeight(&fontHeight); font.GetHeight(&fontHeight);
float leftText = (view->StringWidth(nameString.String()) - fIconRect.Width()) / 2; float leftText = (view->StringWidth(nameString.String())
- fIconRect.Width()) / 2;
view->MovePenTo(BPoint(hIconOffset - leftText + 2, view->MovePenTo(BPoint(hIconOffset - leftText + 2,
fIconRect.Height() + (fontHeight.ascent + 2))); fIconRect.Height() + (fontHeight.ascent + 2)));
view->DrawString(nameString.String()); view->DrawString(nameString.String());
@@ -1391,9 +1431,11 @@ AttributeView::MouseMoved(BPoint point, uint32, const BMessage* message)
message.AddInt32("buttons", (int32)button); message.AddInt32("buttons", (int32)button);
message.AddInt32("be:actions", message.AddInt32("be:actions",
(modifiers() & B_OPTION_KEY) != 0 ? B_COPY_TARGET : B_MOVE_TARGET); (modifiers() & B_OPTION_KEY) != 0
? B_COPY_TARGET : B_MOVE_TARGET);
message.AddRef("refs", fModel->EntryRef()); message.AddRef("refs", fModel->EntryRef());
DragMessage(&message, dragBitmap, B_OP_ALPHA, BPoint((fClickPoint.x - fIconRect.left) DragMessage(&message, dragBitmap, B_OP_ALPHA,
BPoint((fClickPoint.x - fIconRect.left)
+ hIconOffset, fClickPoint.y - fIconRect.top), this); + hIconOffset, fClickPoint.y - fIconRect.top), this);
fDragging = true; fDragging = true;
} }
@@ -1413,47 +1455,57 @@ AttributeView::MouseMoved(BPoint point, uint32, const BMessage* message)
BPoint point; BPoint point;
GetMouse(&point, &buttons); GetMouse(&point, &buttons);
if (Window()->IsActive() && !buttons) { if (Window()->IsActive() && !buttons) {
// If we are down here, then that means that we're tracking the mouse // If we are down here, then that means that we're tracking
// but not from a mouse down. In this case, we're just interested in // the mouse but not from a mouse down. In this case, we're
// knowing whether or not we need to display the "pop-up" version // just interested in knowing whether or not we need to
// of the path or link text. // display the "pop-up" version of the path or link text.
BScreen screen(Window()); BScreen screen(Window());
BFont font; BFont font;
GetFont(&font); GetFont(&font);
font.SetSize(kAttribFontHeight); font.SetSize(kAttribFontHeight);
float maxWidth = (Bounds().Width() - (fDivider + kBorderMargin)); float maxWidth = (Bounds().Width()
- (fDivider + kBorderMargin));
if (fPathRect.Contains(point) if (fPathRect.Contains(point)
&& font.StringWidth(fPathStr.String()) > maxWidth) { && font.StringWidth(fPathStr.String()) > maxWidth) {
fTrackingState = no_track; fTrackingState = no_track;
BRect rect(fPathRect); BRect rect(fPathRect);
rect.OffsetBy(Window()->Frame().left, Window()->Frame().top); rect.OffsetBy(Window()->Frame().left,
Window()->Frame().top);
if (!fPathWindow || BMessenger(fPathWindow).IsValid() == false) { if (!fPathWindow
fPathWindow = OpenToolTipWindow(screen, rect, "fPathWindow", || BMessenger(fPathWindow).IsValid() == false) {
fPathStr.String(), BMessenger(this), fPathWindow = OpenToolTipWindow(screen, rect,
"fPathWindow", fPathStr.String(),
BMessenger(this),
new BMessage(kOpenLinkSource)); new BMessage(kOpenLinkSource));
} }
} else if (fLinkRect.Contains(point) } else if (fLinkRect.Contains(point)
&& font.StringWidth(fLinkToStr.String()) > maxWidth) { && font.StringWidth(fLinkToStr.String()) > maxWidth) {
fTrackingState = no_track; fTrackingState = no_track;
BRect rect(fLinkRect); BRect rect(fLinkRect);
rect.OffsetBy(Window()->Frame().left, Window()->Frame().top); rect.OffsetBy(Window()->Frame().left,
Window()->Frame().top);
if (!fLinkWindow || BMessenger(fLinkWindow).IsValid() == false) { if (!fLinkWindow
fLinkWindow = OpenToolTipWindow(screen, rect, "fLinkWindow", || BMessenger(fLinkWindow).IsValid() == false) {
fLinkToStr.String(), BMessenger(this), fLinkWindow = OpenToolTipWindow(screen, rect,
"fLinkWindow", fLinkToStr.String(),
BMessenger(this),
new BMessage(kOpenLinkTarget)); new BMessage(kOpenLinkTarget));
} }
} else if (fDescRect.Contains(point) } else if (fDescRect.Contains(point)
&& font.StringWidth(fDescStr.String()) > maxWidth) { && font.StringWidth(fDescStr.String()) > maxWidth) {
fTrackingState = no_track; fTrackingState = no_track;
BRect rect(fDescRect); BRect rect(fDescRect);
rect.OffsetBy(Window()->Frame().left, Window()->Frame().top); rect.OffsetBy(Window()->Frame().left,
Window()->Frame().top);
if (!fDescWindow || BMessenger(fDescWindow).IsValid() == false) { if (!fDescWindow
fDescWindow = OpenToolTipWindow(screen, rect, "fDescWindow", || BMessenger(fDescWindow).IsValid() == false) {
fDescStr.String(), BMessenger(this), NULL); fDescWindow = OpenToolTipWindow(screen, rect,
"fDescWindow", fDescStr.String(),
BMessenger(this), NULL);
} }
} }
} }
@@ -1509,12 +1561,13 @@ AttributeView::MouseUp(BPoint point)
} else if (fTrackingState == path_track && fPathRect.Contains(point)) { } else if (fTrackingState == path_track && fPathRect.Contains(point)) {
InvertRect(fPathRect); InvertRect(fPathRect);
OpenLinkSource(); OpenLinkSource();
} else if ((fTrackingState == icon_track || fTrackingState == open_only_track) } else if ((fTrackingState == icon_track
|| fTrackingState == open_only_track)
&& fIconRect.Contains(point)) { && fIconRect.Contains(point)) {
// If it was a double click, then tell Tracker to open the item // If it was a double click, then tell Tracker to open the item
// The CurrentMessage() here does* not* have a "clicks" field, // The CurrentMessage() here does* not* have a "clicks" field,
// which is why we are tracking the clicks with this temp var // which is why we are tracking the clicks with this temp var
if (fDoubleClick){ if (fDoubleClick) {
// Double click, launch. // Double click, launch.
BMessage message(B_REFS_RECEIVED); BMessage message(B_REFS_RECEIVED);
message.AddRef("refs", fModel->EntryRef()); message.AddRef("refs", fModel->EntryRef());
@@ -1580,8 +1633,10 @@ AttributeView::CheckAndSetSize()
StatStruct statBuf; StatStruct statBuf;
BModelOpener opener(fModel); BModelOpener opener(fModel);
if (fModel->InitCheck() != B_OK || fModel->Node()->GetStat(&statBuf) != B_OK) if (fModel->InitCheck() != B_OK
|| fModel->Node()->GetStat(&statBuf) != B_OK) {
return; return;
}
if (fLastSize == statBuf.st_size) if (fLastSize == statBuf.st_size)
return; return;
@@ -1594,7 +1649,8 @@ AttributeView::CheckAndSetSize()
BRect bounds(Bounds()); BRect bounds(Bounds());
float lineHeight = CurrentFontHeight() + 2; float lineHeight = CurrentFontHeight() + 2;
bounds.Set(fDivider, fIconRect.bottom, bounds.right, fIconRect.bottom + lineHeight); bounds.Set(fDivider, fIconRect.bottom, bounds.right,
fIconRect.bottom + lineHeight);
Invalidate(bounds); Invalidate(bounds);
} }
@@ -1606,8 +1662,10 @@ AttributeView::MessageReceived(BMessage* message)
&& message->what == B_SIMPLE_DATA && message->what == B_SIMPLE_DATA
&& message->ReturnAddress() != BMessenger(this) && message->ReturnAddress() != BMessenger(this)
&& fIconRect.Contains(ConvertFromScreen(message->DropPoint())) && fIconRect.Contains(ConvertFromScreen(message->DropPoint()))
&& BPoseView::CanHandleDragSelection(fModel, message, (modifiers() & B_CONTROL_KEY) != 0)) { && BPoseView::CanHandleDragSelection(fModel, message,
BPoseView::HandleDropCommon(message, fModel, 0, this, message->DropPoint()); (modifiers() & B_CONTROL_KEY) != 0)) {
BPoseView::HandleDropCommon(message, fModel, 0, this,
message->DropPoint());
Invalidate(fIconRect); Invalidate(fIconRect);
return; return;
} }
@@ -1679,7 +1737,8 @@ AttributeView::Draw(BRect)
MovePenTo(BPoint(fIconRect.right + 6, lineBase)); MovePenTo(BPoint(fIconRect.right + 6, lineBase));
// Recalculate the rect width // Recalculate the rect width
fTitleRect.right = min_c(fTitleRect.left + currentFont.StringWidth(fModel->Name()), fTitleRect.right = min_c(
fTitleRect.left + currentFont.StringWidth(fModel->Name()),
Bounds().Width() - 5); Bounds().Width() - 5);
// Check for possible need of truncation // Check for possible need of truncation
if (StringWidth(fModel->Name()) > fTitleRect.Width()) { if (StringWidth(fModel->Name()) > fTitleRect.Width()) {
@@ -1718,12 +1777,14 @@ AttributeView::Draw(BRect)
MovePenTo(BPoint(fDivider + kDrawMargin, lineBase)); MovePenTo(BPoint(fDivider + kDrawMargin, lineBase));
SetHighColor(kAttrValueColor); SetHighColor(kAttrValueColor);
// Check for possible need of truncation // Check for possible need of truncation
if (StringWidth(fSizeStr.String()) > (Bounds().Width() - (fDivider + kBorderMargin))) { if (StringWidth(fSizeStr.String())
> (Bounds().Width() - (fDivider + kBorderMargin))) {
BString tmpString(fSizeStr.String()); BString tmpString(fSizeStr.String());
TruncateString(&tmpString, B_TRUNCATE_MIDDLE, TruncateString(&tmpString, B_TRUNCATE_MIDDLE,
Bounds().Width() - (fDivider + kBorderMargin)); Bounds().Width() - (fDivider + kBorderMargin));
DrawString(tmpString.String()); DrawString(tmpString.String());
fSizeRect.right = fSizeRect.left + StringWidth(tmpString.String()) + 3; fSizeRect.right = fSizeRect.left + StringWidth(tmpString.String())
+ 3;
} else { } else {
DrawString(fSizeStr.String()); DrawString(fSizeStr.String());
fSizeRect.right = fSizeRect.left + StringWidth(fSizeStr.String()) + 3; fSizeRect.right = fSizeRect.left + StringWidth(fSizeStr.String()) + 3;
@@ -1752,7 +1813,8 @@ AttributeView::Draw(BRect)
lineBase += lineHeight; lineBase += lineHeight;
// Kind // Kind
MovePenTo(BPoint(fDivider - (StringWidth(B_TRANSLATE("Kind:"))), lineBase)); MovePenTo(BPoint(fDivider - (StringWidth(B_TRANSLATE("Kind:"))),
lineBase));
SetHighColor(kAttrTitleColor); SetHighColor(kAttrTitleColor);
DrawString(B_TRANSLATE("Kind:")); DrawString(B_TRANSLATE("Kind:"));
MovePenTo(BPoint(fDivider + kDrawMargin, lineBase)); MovePenTo(BPoint(fDivider + kDrawMargin, lineBase));
@@ -1773,7 +1835,8 @@ AttributeView::Draw(BRect)
SetHighColor(kLinkColor); SetHighColor(kLinkColor);
// Check for truncation // Check for truncation
if (StringWidth(fPathStr.String()) > (Bounds().Width() - (fDivider + kBorderMargin))) { if (StringWidth(fPathStr.String()) > (Bounds().Width()
- (fDivider + kBorderMargin))) {
BString nameString(fPathStr.String()); BString nameString(fPathStr.String());
TruncateString(&nameString, B_TRUNCATE_MIDDLE, TruncateString(&nameString, B_TRUNCATE_MIDDLE,
Bounds().Width() - (fDivider + kBorderMargin)); Bounds().Width() - (fDivider + kBorderMargin));
@@ -1799,7 +1862,8 @@ AttributeView::Draw(BRect)
SetHighColor(kLinkColor); SetHighColor(kLinkColor);
// Check for truncation // Check for truncation
if (StringWidth(fLinkToStr.String()) > (Bounds().Width() - (fDivider + kBorderMargin))) { if (StringWidth(fLinkToStr.String()) > (Bounds().Width()
- (fDivider + kBorderMargin))) {
BString nameString(fLinkToStr.String()); BString nameString(fLinkToStr.String());
TruncateString(&nameString, B_TRUNCATE_MIDDLE, TruncateString(&nameString, B_TRUNCATE_MIDDLE,
Bounds().Width() - (fDivider + kBorderMargin)); Bounds().Width() - (fDivider + kBorderMargin));
@@ -1811,7 +1875,8 @@ AttributeView::Draw(BRect)
fLinkRect.top = lineBase - fontMetrics.ascent; fLinkRect.top = lineBase - fontMetrics.ascent;
fLinkRect.bottom = lineBase + fontMetrics.descent; fLinkRect.bottom = lineBase + fontMetrics.descent;
fLinkRect.left = fDivider + 2; fLinkRect.left = fDivider + 2;
fLinkRect.right = fLinkRect.left + StringWidth(fLinkToStr.String()) + 3; fLinkRect.right = fLinkRect.left + StringWidth(fLinkToStr.String())
+ 3;
// No description field // No description field
fDescRect = BRect(-1, -1, -1, -1); fDescRect = BRect(-1, -1, -1, -1);
@@ -1838,7 +1903,8 @@ AttributeView::Draw(BRect)
MovePenTo(BPoint(fDivider + kDrawMargin, lineBase)); MovePenTo(BPoint(fDivider + kDrawMargin, lineBase));
SetHighColor(kAttrValueColor); SetHighColor(kAttrValueColor);
// Check for truncation // Check for truncation
if (StringWidth(fDescStr.String()) > (Bounds().Width() - (fDivider + kBorderMargin))) { if (StringWidth(fDescStr.String()) > (Bounds().Width()
- (fDivider + kBorderMargin))) {
BString nameString(fDescStr.String()); BString nameString(fDescStr.String());
TruncateString(&nameString, B_TRUNCATE_MIDDLE, TruncateString(&nameString, B_TRUNCATE_MIDDLE,
Bounds().Width() - (fDivider + kBorderMargin)); Bounds().Width() - (fDivider + kBorderMargin));
@@ -1873,8 +1939,9 @@ AttributeView::BeginEditingTitle()
textRect.OffsetTo(0, 0); textRect.OffsetTo(0, 0);
textRect.InsetBy(1, 1); textRect.InsetBy(1, 1);
// Just make it some really large size, since we don't do any line wrapping. // Just make it some really large size, since we don't do any line
// The text filter will make sure to scroll the cursor into position // wrapping. The text filter will make sure to scroll the cursor
// into position
textRect.right = 2000; textRect.right = 2000;
fTitleEditView = new BTextView(textFrame, "text_editor", fTitleEditView = new BTextView(textFrame, "text_editor",
@@ -1911,7 +1978,8 @@ AttributeView::FinishEditingTitle(bool commit)
const char* text = fTitleEditView->Text(); const char* text = fTitleEditView->Text();
uint32 length = strlen(text); uint32 length = strlen(text);
if (commit && strcmp(text, fModel->Name()) != 0 && length < B_FILE_NAME_LENGTH) { if (commit && strcmp(text, fModel->Name()) != 0
&& length < B_FILE_NAME_LENGTH) {
BEntry entry(fModel->EntryRef()); BEntry entry(fModel->EntryRef());
BDirectory parent; BDirectory parent;
if (entry.InitCheck() == B_OK if (entry.InitCheck() == B_OK
@@ -1936,7 +2004,8 @@ AttributeView::FinishEditingTitle(bool commit)
GetFont(&currentFont); GetFont(&currentFont);
currentFont.SetSize(kTitleFontHeight); currentFont.SetSize(kTitleFontHeight);
fTitleRect.right = min_c(fTitleRect.left fTitleRect.right = min_c(fTitleRect.left
+ currentFont.StringWidth(fTitleEditView->Text()), Bounds().Width() - 5); + currentFont.StringWidth(fTitleEditView->Text()),
Bounds().Width() - 5);
} }
} }
} else if (length >= B_FILE_NAME_LENGTH) { } else if (length >= B_FILE_NAME_LENGTH) {
@@ -2081,12 +2150,14 @@ AttributeView::BuildContextMenu(BMenu* parent)
BMenuItem* sizeItem = NULL; BMenuItem* sizeItem = NULL;
if (model.IsDirectory() && !model.IsVolume() && !model.IsRoot()) { if (model.IsDirectory() && !model.IsVolume() && !model.IsRoot()) {
parent->AddItem(sizeItem = new BMenuItem(B_TRANSLATE("Recalculate folder size"), parent->AddItem(sizeItem
= new BMenuItem(B_TRANSLATE("Recalculate folder size"),
new BMessage(kRecalculateSize))); new BMessage(kRecalculateSize)));
} }
if (model.IsSymLink()) { if (model.IsSymLink()) {
parent->AddItem(sizeItem = new BMenuItem(B_TRANSLATE("Set new link target"), parent->AddItem(sizeItem
= new BMenuItem(B_TRANSLATE("Set new link target"),
new BMessage(kSetLinkTarget))); new BMessage(kSetLinkTarget)));
} }
@@ -2116,7 +2187,8 @@ AttributeView::SetPermissionsSwitchState(int32 state)
filter_result filter_result
AttributeView::TextViewFilter(BMessage* message, BHandler**, BMessageFilter* filter) AttributeView::TextViewFilter(BMessage* message, BHandler**,
BMessageFilter* filter)
{ {
uchar key; uchar key;
AttributeView* attribView = static_cast<AttributeView*>( AttributeView* attribView = static_cast<AttributeView*>(
@@ -2162,7 +2234,8 @@ AttributeView::SetSizeStr(const char* sizeStr)
BRect bounds(Bounds()); BRect bounds(Bounds());
float lineHeight = CurrentFontHeight(kAttribFontHeight) + 6; float lineHeight = CurrentFontHeight(kAttribFontHeight) + 6;
bounds.Set(fDivider, fIconRect.bottom, bounds.right, fIconRect.bottom + lineHeight); bounds.Set(fDivider, fIconRect.bottom, bounds.right,
fIconRect.bottom + lineHeight);
Invalidate(bounds); Invalidate(bounds);
} }
@@ -2171,7 +2244,8 @@ AttributeView::SetSizeStr(const char* sizeStr)
TrackingView::TrackingView(BRect frame, const char* str, BMessage* message) TrackingView::TrackingView(BRect frame, const char* str, BMessage* message)
: BControl(frame, "trackingView", str, message, B_FOLLOW_ALL, B_WILL_DRAW), : BControl(frame, "trackingView", str, message, B_FOLLOW_ALL,
B_WILL_DRAW),
fMouseDown(false), fMouseDown(false),
fMouseInView(false) fMouseInView(false)
{ {
+4 -2
View File
@@ -55,7 +55,8 @@ class AttributeView;
class BInfoWindow : public BWindow { class BInfoWindow : public BWindow {
public: public:
BInfoWindow(Model*, int32 groupIndex, LockingList<BWindow>* list = NULL); BInfoWindow(Model*, int32 groupIndex,
LockingList<BWindow>* list = NULL);
~BInfoWindow(); ~BInfoWindow();
virtual bool IsShowing(const node_ref*) const; virtual bool IsShowing(const node_ref*) const;
@@ -64,7 +65,8 @@ class BInfoWindow : public BWindow {
bool StopCalc(); bool StopCalc();
void OpenFilePanel(const entry_ref*); void OpenFilePanel(const entry_ref*);
static void GetSizeString(BString &result, off_t size, int32 fileCount); static void GetSizeString(BString &result, off_t size,
int32 fileCount);
protected: protected:
virtual void Quit(); virtual void Quit();
+2 -3
View File
@@ -77,7 +77,8 @@ ShortMimeInfo::ShortDescription() const
} }
int int
ShortMimeInfo::CompareShortDescription(const ShortMimeInfo* a, const ShortMimeInfo* b) ShortMimeInfo::CompareShortDescription(const ShortMimeInfo* a,
const ShortMimeInfo* b)
{ {
return a->fShortDescription.ICompare(b->fShortDescription); return a->fShortDescription.ICompare(b->fShortDescription);
} }
@@ -160,5 +161,3 @@ MimeTypeList::Build()
fCommonMimeList.SortItems(&ShortMimeInfo::CompareShortDescription); fCommonMimeList.SortItems(&ShortMimeInfo::CompareShortDescription);
fLock.Unlock(); fLock.Unlock();
} }
+52 -36
View File
@@ -270,8 +270,8 @@ Model::SetTo(const entry_ref* newRef, bool traverse, bool open, bool writable)
status_t status_t
Model::SetTo(const node_ref* dirNode, const node_ref* nodeRef, const char* name, Model::SetTo(const node_ref* dirNode, const node_ref* nodeRef,
bool open, bool writable) const char* name, bool open, bool writable)
{ {
delete fNode; delete fNode;
fNode = NULL; fNode = NULL;
@@ -425,7 +425,8 @@ Model::OpenNodeCommon(bool writable)
case kQueryTemplateNode: case kQueryTemplateNode:
// open or reopen // open or reopen
delete fNode; delete fNode;
fNode = new BFile(&fEntryRef, (uint32)(writable ? O_RDWR : O_RDONLY)); fNode = new BFile(&fEntryRef,
(uint32)(writable ? O_RDWR : O_RDONLY));
break; break;
case kDirectoryNode: case kDirectoryNode:
@@ -455,11 +456,12 @@ Model::OpenNodeCommon(bool writable)
PrintToStream(); PrintToStream();
#endif #endif
TRESPASS(); TRESPASS();
// this can only happen if GetStat failed before, in which case // this can only happen if GetStat failed before,
// we shouldn't be here // in which case we shouldn't be here
// ToDo: Obviously, we can also be here if the type could not be determined,
// for example for block devices (so the TRESPASS() macro shouldn't be // ToDo: Obviously, we can also be here if the type could not
// used here)! // be determined, for example for block devices (so the TRESPASS()
// macro shouldn't be used here)!
return fStatus = B_ERROR; return fStatus = B_ERROR;
} }
@@ -598,11 +600,12 @@ Model::FinishSettingUpType()
&& fBaseType != kLinkNode && fBaseType != kLinkNode
&& !CheckNodeIconHintPrivate(fNode, dynamic_cast<TTracker*>(be_app) == NULL) && !CheckNodeIconHintPrivate(fNode, dynamic_cast<TTracker*>(be_app) == NULL)
&& !HasVectorIconHint(fNode)) { && !HasVectorIconHint(fNode)) {
// when checking for the node icon hint, if we are libtracker, only check // when checking for the node icon hint, if we are libtracker,
// for small icons - checking for the large icons is a little more // only check for small icons - checking for the large icons
// work for the filesystem and this will speed up the test. // is a little more work for the filesystem and this will
// This makes node icons only work if there is a small and a large node // speed up the test. This makes node icons only work if there
// icon on a file - for libtracker that is not a problem though // is a small and a large node icon on a file - for libtracker
// that is not a problem though
fIconFrom = kUnknownNotFromNode; fIconFrom = kUnknownNotFromNode;
} }
@@ -648,10 +651,12 @@ Model::FinishSettingUpType()
fMimeType = mimeString; fMimeType = mimeString;
if (fIconFrom == kUnknownNotFromNode if (fIconFrom == kUnknownNotFromNode
&& WellKnowEntryList::Match(NodeRef()) > (directory_which)-1) && WellKnowEntryList::Match(NodeRef())
> (directory_which)-1) {
// one of home, beos, system, boot, etc. // one of home, beos, system, boot, etc.
fIconFrom = kTrackerSupplied; fIconFrom = kTrackerSupplied;
} }
}
break; break;
case kVolumeNode: case kVolumeNode:
@@ -695,9 +700,8 @@ Model::FinishSettingUpType()
case kExecutableNode: case kExecutableNode:
if (IsNodeOpen()) { if (IsNodeOpen()) {
char signature[B_MIME_TYPE_LENGTH]; char signature[B_MIME_TYPE_LENGTH];
if (GetAppSignatureFromAttr(dynamic_cast<BFile*>(fNode), signature) if (GetAppSignatureFromAttr(dynamic_cast<BFile*>(fNode),
== B_OK) { signature) == B_OK) {
if (fPreferredAppName) if (fPreferredAppName)
DeletePreferredAppVolumeNameLinkTo(); DeletePreferredAppVolumeNameLinkTo();
@@ -706,7 +710,8 @@ Model::FinishSettingUpType()
} }
} }
if (!fMimeType.Length()) if (!fMimeType.Length())
fMimeType = B_APP_MIME_TYPE; // should use a shared string here fMimeType = B_APP_MIME_TYPE;
// should use a shared string here
break; break;
default: default:
@@ -728,7 +733,8 @@ Model::ResetIconFrom()
// mirror the logic from FinishSettingUpType // mirror the logic from FinishSettingUpType
if ((fBaseType == kDirectoryNode || fBaseType == kVolumeNode if ((fBaseType == kDirectoryNode || fBaseType == kVolumeNode
|| fBaseType == kTrashNode || fBaseType == kDesktopNode) || fBaseType == kTrashNode || fBaseType == kDesktopNode)
&& !CheckNodeIconHintPrivate(fNode, dynamic_cast<TTracker*>(be_app) == NULL)) { && !CheckNodeIconHintPrivate(fNode,
dynamic_cast<TTracker*>(be_app) == NULL)) {
if (WellKnowEntryList::Match(NodeRef()) > (directory_which)-1) { if (WellKnowEntryList::Match(NodeRef()) > (directory_which)-1) {
fIconFrom = kTrackerSupplied; fIconFrom = kTrackerSupplied;
return; return;
@@ -813,7 +819,8 @@ Model::GetPreferredAppForBrokenSymLink(BString &result)
BModelOpener opener(this); BModelOpener opener(this);
BNodeInfo info(fNode); BNodeInfo info(fNode);
status_t error = info.GetPreferredApp(result.LockBuffer(B_MIME_TYPE_LENGTH)); status_t error
= info.GetPreferredApp(result.LockBuffer(B_MIME_TYPE_LENGTH));
result.UnlockBuffer(); result.UnlockBuffer();
if (error != B_OK) if (error != B_OK)
@@ -1078,9 +1085,10 @@ Model::SupportsMimeType(const char* type, const BObjectList<BString>* list,
const char* mimeSignature; const char* mimeSignature;
int32 bufferLength; int32 bufferLength;
if (message.FindData("types", 'CSTR', index, (const void**)&mimeSignature, if (message.FindData("types", 'CSTR', index,
&bufferLength)) (const void**)&mimeSignature, &bufferLength)) {
return result; return result;
}
if (IsSuperHandlerSignature(mimeSignature)) { if (IsSuperHandlerSignature(mimeSignature)) {
if (!exactReason) if (!exactReason)
@@ -1098,7 +1106,8 @@ Model::SupportsMimeType(const char* type, const BObjectList<BString>* list,
} else } else
match = WhileEachListItem(const_cast<BObjectList<BString>*>(list), match = WhileEachListItem(const_cast<BObjectList<BString>*>(list),
MatchMimeTypeString, mimeSignature); MatchMimeTypeString, mimeSignature);
// const_cast shouldnt be here, have to have it until MW cleans up // const_cast shouldnt be here, have to have it until
// MW cleans up
if (match == kMatch) if (match == kMatch)
// supports the actual type, it can't get any better // supports the actual type, it can't get any better
@@ -1150,9 +1159,10 @@ Model::IsSuperHandler() const
const char* mimeSignature; const char* mimeSignature;
int32 bufferLength; int32 bufferLength;
if (message.FindData("types", 'CSTR', index, (const void**)&mimeSignature, if (message.FindData("types", 'CSTR', index,
&bufferLength)) (const void**)&mimeSignature, &bufferLength)) {
return false; return false;
}
if (IsSuperHandlerSignature(mimeSignature)) if (IsSuperHandlerSignature(mimeSignature))
return true; return true;
@@ -1261,7 +1271,8 @@ Model::GetVersionString(BString &result, version_kind kind)
return error; return error;
char vstr[32]; char vstr[32];
sprintf(vstr, "%ld.%ld.%ld", version.major, version.middle, version.minor); sprintf(vstr, "%ld.%ld.%ld", version.major, version.middle,
version.minor);
result = vstr; result = vstr;
return B_OK; return B_OK;
} }
@@ -1271,8 +1282,8 @@ Model::GetVersionString(BString &result, version_kind kind)
void void
Model::PrintToStream(int32 level, bool deep) Model::PrintToStream(int32 level, bool deep)
{ {
PRINT(("model name %s, entry name %s, inode %" B_PRIdINO ", dev %" B_PRIdDEV PRINT(("model name %s, entry name %s, inode %" B_PRIdINO ", dev %"
", directory inode %" B_PRIdINO "\n", B_PRIdDEV ", directory inode %" B_PRIdINO "\n",
Name() ? Name() : "**empty name**", Name() ? Name() : "**empty name**",
EntryRef()->name ? EntryRef()->name : "**empty ref name**", EntryRef()->name ? EntryRef()->name : "**empty ref name**",
NodeRef()->node, NodeRef()->node,
@@ -1324,8 +1335,10 @@ Model::PrintToStream(int32 level, bool deep)
if (level < 1) if (level < 1)
return; return;
if (!IsVolume()) if (!IsVolume()) {
PRINT(("preferred app %s\n", fPreferredAppName ? fPreferredAppName : "")); PRINT(("preferred app %s\n",
fPreferredAppName ? fPreferredAppName : ""));
}
PRINT(("icon from: ")); PRINT(("icon from: "));
switch (IconFrom()) { switch (IconFrom()) {
@@ -1426,8 +1439,9 @@ Model::TrackIconSource(icon_size size)
BMimeType preferredAppType(preferredApp); BMimeType preferredAppType(preferredApp);
err = preferredAppType.GetIconForType(MimeType(), &bitmap, size); err = preferredAppType.GetIconForType(MimeType(), &bitmap, size);
if (err == B_OK) { if (err == B_OK) {
PRINT(("track icon - got icon for type %s from preferred app %s for file\n", PRINT(
MimeType(), preferredApp)); ("track icon - got icon for type %s from preferred "
"app %s for file\n", MimeType(), preferredApp));
return; return;
} }
} }
@@ -1453,12 +1467,14 @@ Model::TrackIconSource(icon_size size)
err = preferredAppType.GetIconForType(MimeType(), &bitmap, size); err = preferredAppType.GetIconForType(MimeType(), &bitmap, size);
if (err == B_OK) { if (err == B_OK) {
// the preferred app knew icon to use for the type, we are done // the preferred app knew icon to use for the type, we are done
PRINT(("track icon - signature %s, got icon from preferred app %s\n", PRINT(
MimeType(), preferredApp)); ("track icon - signature %s, got icon from preferred "
"app %s\n", MimeType(), preferredApp));
return; return;
} }
PRINT(("track icon - signature %s, preferred app %s, no icon, error %s\n", PRINT(
MimeType(), preferredApp, strerror(err))); ("track icon - signature %s, preferred app %s, no icon, "
"error %s\n", MimeType(), preferredApp, strerror(err)));
} }
} }
+22 -16
View File
@@ -88,11 +88,12 @@ class Model {
status_t InitCheck() const; status_t InitCheck() const;
status_t SetTo(const BEntry*, bool open = false, bool writable = false); status_t SetTo(const BEntry*, bool open = false,
status_t SetTo(const entry_ref*, bool traverse = false, bool open = false,
bool writable = false); bool writable = false);
status_t SetTo(const node_ref* dirNode, const node_ref* node, const char* name, status_t SetTo(const entry_ref*, bool traverse = false,
bool open = false, bool writable = false); bool open = false, bool writable = false);
status_t SetTo(const node_ref* dirNode, const node_ref* node,
const char* name, bool open = false, bool writable = false);
int CompareFolderNamesFirst(const Model* compareModel) const; int CompareFolderNamesFirst(const Model* compareModel) const;
@@ -124,9 +125,9 @@ class Model {
void SetPreferredAppSignature(const char*); void SetPreferredAppSignature(const char*);
void GetPreferredAppForBrokenSymLink(BString &result); void GetPreferredAppForBrokenSymLink(BString &result);
// special purpose call - if a symlink is unresolvable, it makes sense // special purpose call - if a symlink is unresolvable, it makes
// to be able to get at it's preferred handler which may be different // sense to be able to get at it's preferred handler which may be
// from the Tracker. Used by the network neighborhood. // different from the Tracker. Used by the network neighborhood.
// type getters // type getters
bool IsFile() const; bool IsFile() const;
@@ -159,8 +160,8 @@ class Model {
status_t GetLongVersionString(BString &, version_kind); status_t GetLongVersionString(BString &, version_kind);
status_t GetVersionString(BString &, version_kind); status_t GetVersionString(BString &, version_kind);
status_t AttrAsString(BString &, int64* value, const char* attributeName, status_t AttrAsString(BString &, int64* value,
uint32 attributeType); const char* attributeName, uint32 attributeType);
// Node monitor update call // Node monitor update call
void UpdateEntryRef(const node_ref* dirRef, const char* name); void UpdateEntryRef(const node_ref* dirRef, const char* name);
@@ -189,8 +190,8 @@ class Model {
#endif #endif
bool IsSuperHandler() const; bool IsSuperHandler() const;
int32 SupportsMimeType(const char* type, const BObjectList<BString>* list, int32 SupportsMimeType(const char* type,
bool exactReason = false) const; const BObjectList<BString>* list, bool exactReason = false) const;
// pass in one string in <type> or a bunch in <list> // pass in one string in <type> or a bunch in <list>
// if <exactReason> false, returns as soon as it figures out that // if <exactReason> false, returns as soon as it figures out that
// app supports a given type, if true, returns an exact reason // app supports a given type, if true, returns an exact reason
@@ -200,8 +201,9 @@ class Model {
const void* buffer, size_t ); const void* buffer, size_t );
// cover call, creates a writable node and writes out attributes // cover call, creates a writable node and writes out attributes
// into it; work around for file nodes not being writeable // into it; work around for file nodes not being writeable
ssize_t WriteAttrKillForeign(const char* attr, const char* foreignAttr, ssize_t WriteAttrKillForeign(const char* attr,
type_code type, off_t, const void* buffer, size_t); const char* foreignAttr, type_code type, off_t,
const void* buffer, size_t);
bool Mimeset(bool force); bool Mimeset(bool force);
// returns true if mime type changed // returns true if mime type changed
@@ -242,11 +244,13 @@ class Model {
entry_ref fEntryRef; entry_ref fEntryRef;
StatStruct fStatBuf; StatStruct fStatBuf;
BString fMimeType; // should use string that may be shared for common types BString fMimeType;
// should use string that may be shared for common types
// bit of overloading hackery here to save on footprint // bit of overloading hackery here to save on footprint
union { union {
char* fPreferredAppName; // used if we are neither a volume nor a symlink char* fPreferredAppName; // used if we are neither a volume
// nor a symlink
char* fVolumeName; // used if we are a volume char* fVolumeName; // used if we are a volume
Model* fLinkTo; // used if we are a symlink Model* fLinkTo; // used if we are a symlink
}; };
@@ -267,7 +271,8 @@ class ModelNodeLazyOpener {
public: public:
// consider failing when open does not succeed // consider failing when open does not succeed
ModelNodeLazyOpener(Model* model, bool writable = false, bool openLater = true); ModelNodeLazyOpener(Model* model, bool writable = false,
bool openLater = true);
~ModelNodeLazyOpener(); ~ModelNodeLazyOpener();
bool IsOpen() const; bool IsOpen() const;
@@ -463,7 +468,8 @@ Model::HasLocalizedName() const
inline inline
ModelNodeLazyOpener::ModelNodeLazyOpener(Model* model, bool writable, bool openLater) ModelNodeLazyOpener::ModelNodeLazyOpener(Model* model, bool writable,
bool openLater)
: fModel(model), : fModel(model),
fWasOpen(model->IsNodeOpen()), fWasOpen(model->IsNodeOpen()),
fWasOpenForWriting(model->IsNodeOpenForWriting()) fWasOpenForWriting(model->IsNodeOpenForWriting())
+38 -22
View File
@@ -58,8 +58,8 @@ static const int32 kMaxHistory = 32;
static BPicture sPicture; static BPicture sPicture;
BNavigatorButton::BNavigatorButton(BRect rect, const char* name, BMessage* message, BNavigatorButton::BNavigatorButton(BRect rect, const char* name,
int32 resIDon, int32 resIDoff, int32 resIDdisabled) BMessage* message, int32 resIDon, int32 resIDoff, int32 resIDdisabled)
: BPictureButton(rect, name, &sPicture, &sPicture, message), : BPictureButton(rect, name, &sPicture, &sPicture, message),
fResIDOn(resIDon), fResIDOn(resIDon),
fResIDOff(resIDoff), fResIDOff(resIDoff),
@@ -81,17 +81,20 @@ void
BNavigatorButton::AttachedToWindow() BNavigatorButton::AttachedToWindow()
{ {
BBitmap* bmpOn = 0; BBitmap* bmpOn = 0;
GetTrackerResources()->GetBitmapResource(B_MESSAGE_TYPE, fResIDOn, &bmpOn); GetTrackerResources()->GetBitmapResource(B_MESSAGE_TYPE, fResIDOn,
&bmpOn);
SetPicture(bmpOn, true, true); SetPicture(bmpOn, true, true);
delete bmpOn; delete bmpOn;
BBitmap* bmpOff = 0; BBitmap* bmpOff = 0;
GetTrackerResources()->GetBitmapResource(B_MESSAGE_TYPE, fResIDOff, &bmpOff); GetTrackerResources()->GetBitmapResource(B_MESSAGE_TYPE, fResIDOff,
&bmpOff);
SetPicture(bmpOff, true, false); SetPicture(bmpOff, true, false);
delete bmpOff; delete bmpOff;
BBitmap* bmpDisabled = 0; BBitmap* bmpDisabled = 0;
GetTrackerResources()->GetBitmapResource(B_MESSAGE_TYPE, fResIDDisabled, &bmpDisabled); GetTrackerResources()->GetBitmapResource(B_MESSAGE_TYPE, fResIDDisabled,
&bmpDisabled);
SetPicture(bmpDisabled, false, false); SetPicture(bmpDisabled, false, false);
SetPicture(bmpDisabled, false, true); SetPicture(bmpDisabled, false, true);
delete bmpDisabled; delete bmpDisabled;
@@ -197,8 +200,10 @@ BNavigator::Draw(BRect)
// Draws a beveled smooth border // Draws a beveled smooth border
BeginLineArray(4); BeginLineArray(4);
AddLine(Bounds().LeftTop(), Bounds().RightTop(), shineColor); AddLine(Bounds().LeftTop(), Bounds().RightTop(), shineColor);
AddLine(Bounds().LeftTop(), Bounds().LeftBottom() - BPoint(0, 1), shineColor); AddLine(Bounds().LeftTop(), Bounds().LeftBottom() - BPoint(0, 1),
AddLine(Bounds().LeftBottom() - BPoint(-1, 1), Bounds().RightBottom() - BPoint(0, 1), halfDarkColor); shineColor);
AddLine(Bounds().LeftBottom() - BPoint(-1, 1),
Bounds().RightBottom() - BPoint(0, 1), halfDarkColor);
AddLine(Bounds().LeftBottom(), Bounds().RightBottom(), darkColor); AddLine(Bounds().LeftBottom(), Bounds().RightBottom(), darkColor);
EndLineArray(); EndLineArray();
} }
@@ -275,14 +280,17 @@ BNavigator::GoUp(bool option)
BEntry entry; BEntry entry;
if (entry.SetTo(fPath.Path()) == B_OK) { if (entry.SetTo(fPath.Path()) == B_OK) {
BEntry parentEntry; BEntry parentEntry;
if (entry.GetParent(&parentEntry) == B_OK && !FSIsDeskDir(&parentEntry)) if (entry.GetParent(&parentEntry) == B_OK
&& !FSIsDeskDir(&parentEntry)) {
SendNavigationMessage(kActionUp, &parentEntry, option); SendNavigationMessage(kActionUp, &parentEntry, option);
} }
}
} }
void void
BNavigator::SendNavigationMessage(NavigationAction action, BEntry* entry, bool option) BNavigator::SendNavigationMessage(NavigationAction action, BEntry* entry,
bool option)
{ {
entry_ref ref; entry_ref ref;
@@ -298,26 +306,33 @@ BNavigator::SendNavigationMessage(NavigationAction action, BEntry* entry, bool o
else else
nodeRef = NULL; nodeRef = NULL;
// if the option key was held down, open in new window (send message to be_app) // if the option key was held down, open in new window (send message
// otherwise send message to this window. TTracker (be_app) understands nodeRefToSlection, // to be_app) otherwise send message to this window. TTracker
// BContainerWindow doesn't, so we have to select the item manually // (be_app) understands nodeRefToSlection, BContainerWindow doesn't,
// so we have to select the item manually
if (option) { if (option) {
message.what = B_REFS_RECEIVED; message.what = B_REFS_RECEIVED;
if (nodeRef) if (nodeRef) {
message.AddData("nodeRefToSelect", B_RAW_TYPE, nodeRef, sizeof(node_ref)); message.AddData("nodeRefToSelect", B_RAW_TYPE, nodeRef,
sizeof(node_ref));
}
be_app->PostMessage(&message); be_app->PostMessage(&message);
} else { } else {
message.what = kSwitchDirectory; message.what = kSwitchDirectory;
Window()->PostMessage(&message); Window()->PostMessage(&message);
UnlockLooper(); UnlockLooper();
// This is to prevent a dead-lock situation. SelectChildInParentSoon() // This is to prevent a dead-lock situation.
// eventually locks the TaskLoop::fLock. Later, when StandAloneTaskLoop::Run() // SelectChildInParentSoon() eventually locks the
// runs, it also locks TaskLoop::fLock and subsequently locks this window's looper. // TaskLoop::fLock. Later, when StandAloneTaskLoop::Run()
// Therefore we can't call SelectChildInParentSoon with our Looper locked, // runs, it also locks TaskLoop::fLock and subsequently
// because we would get different orders of locking (thus the risk of dead-locking). // locks this window's looper. Therefore we can't call
// SelectChildInParentSoon with our Looper locked,
// because we would get different orders of locking
// (thus the risk of dead-locking).
// //
// Todo: Change the locking behaviour of StandAloneTaskLoop::Run() and sub- // Todo: Change the locking behaviour of
// sequently called functions. // StandAloneTaskLoop::Run() and subsequently called
// functions.
if (nodeRef) if (nodeRef)
dynamic_cast<TTracker*>(be_app)->SelectChildInParentSoon(&ref, nodeRef); dynamic_cast<TTracker*>(be_app)->SelectChildInParentSoon(&ref, nodeRef);
LockLooper(); LockLooper();
@@ -387,7 +402,8 @@ BNavigator::UpdateLocation(const Model* newmodel, int32 action)
BEntry entry; BEntry entry;
if (entry.SetTo(fPath.Path()) == B_OK) { if (entry.SetTo(fPath.Path()) == B_OK) {
BEntry parentEntry; BEntry parentEntry;
fUp->SetEnabled(entry.GetParent(&parentEntry) == B_OK && !FSIsDeskDir(&parentEntry)); fUp->SetEnabled(entry.GetParent(&parentEntry) == B_OK
&& !FSIsDeskDir(&parentEntry));
} }
// Enable history buttons if history contains something // Enable history buttons if history contains something
+14 -9
View File
@@ -1433,8 +1433,8 @@ SearchForSignatureEntryList::Relation(const BMessage* entriesToOpen,
void void
SearchForSignatureEntryList::RelationDescription(const BMessage* entriesToOpen, SearchForSignatureEntryList::RelationDescription(const BMessage* entriesToOpen,
const Model* applicationModel, BString* description, const entry_ref* preferredApp, const Model* applicationModel, BString* description,
const entry_ref* preferredAppForFile) const entry_ref* preferredApp, const entry_ref* preferredAppForFile)
{ {
for (int32 index = 0; ;index++) { for (int32 index = 0; ;index++) {
entry_ref ref; entry_ref ref;
@@ -1482,10 +1482,11 @@ SearchForSignatureEntryList::RelationDescription(const BMessage* entriesToOpen,
{ {
mimeType.SetTo(model.MimeType()); mimeType.SetTo(model.MimeType());
if (preferredApp && *applicationModel->EntryRef() == *preferredApp) if (preferredApp
&& *applicationModel->EntryRef() == *preferredApp) {
// application matches cached preferred app, we are done // application matches cached preferred app, we are done
description->SetTo(B_TRANSLATE("Preferred for %type")); description->SetTo(B_TRANSLATE("Preferred for %type"));
else } else
description->SetTo(B_TRANSLATE("Handles %type")); description->SetTo(B_TRANSLATE("Handles %type"));
char shortDescription[256]; char shortDescription[256];
@@ -1543,7 +1544,9 @@ SearchForSignatureEntryList::CanOpenWithFilter(const Model* appModel,
BEntry entry2(&trackerInfo.ref); BEntry entry2(&trackerInfo.ref);
entry2.GetPath(&path2); entry2.GetPath(&path2);
PRINT(("filtering out %s, sig %s, active Tracker at %s, result %s, refName %s\n", PRINT(
("filtering out %s, sig %s, active Tracker at %s, "
"result %s, refName %s\n",
path.Path(), signature, path2.Path(), strerror(result), path.Path(), signature, path2.Path(), strerror(result),
trackerInfo.ref.name)); trackerInfo.ref.name));
#endif #endif
@@ -1583,7 +1586,8 @@ SearchForSignatureEntryList::CanOpenWithFilter(const Model* appModel,
return false; 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 // we hit at least one app that is not a superhandler and
// handles the document // handles the document
fFoundOneNonSuperHandler = true; fFoundOneNonSuperHandler = true;
@@ -1614,7 +1618,8 @@ ConditionalAllAppsIterator::Instantiate()
BString lookForAppsPredicate; BString lookForAppsPredicate;
lookForAppsPredicate << "(" << kAttrAppSignature << " = \"*\" ) && ( " lookForAppsPredicate << "(" << kAttrAppSignature << " = \"*\" ) && ( "
<< kAttrMIMEType << " = " << B_APP_MIME_TYPE << " ) "; << kAttrMIMEType << " = " << B_APP_MIME_TYPE << " ) ";
fWalker = new BTrackerPrivate::TQueryWalker(lookForAppsPredicate.String()); fWalker
= new BTrackerPrivate::TQueryWalker(lookForAppsPredicate.String());
} }
@@ -1647,8 +1652,8 @@ ConditionalAllAppsIterator::GetNextRef(entry_ref* ref)
int32 int32
ConditionalAllAppsIterator::GetNextDirents(struct dirent* buffer, size_t length, ConditionalAllAppsIterator::GetNextDirents(struct dirent* buffer,
int32 count) size_t length, int32 count)
{ {
if (!Iterate()) if (!Iterate())
return 0; return 0;
+37 -22
View File
@@ -91,23 +91,26 @@ class SearchForSignatureEntryList : public EntryListBase {
void TrySettingPreferredAppForFile(const entry_ref*); void TrySettingPreferredAppForFile(const entry_ref*);
int32 Relation(const BMessage* entriesToOpen, const Model*) const; int32 Relation(const BMessage* entriesToOpen, const Model*) const;
// returns the reason why an application is shown in Open With window // returns the reason why an application is shown in
// Open With window
void RelationDescription(const BMessage* entriesToOpen, const Model*, void RelationDescription(const BMessage* entriesToOpen, const Model*,
BString*) const; BString*) const;
// returns a string describing why application handles files to open // returns a string describing why application handles files
// to open
static int32 Relation(const BMessage* entriesToOpen, static int32 Relation(const BMessage* entriesToOpen,
const Model*, const entry_ref* preferredApp, const Model*, const entry_ref* preferredApp,
const entry_ref* preferredAppForFile); const entry_ref* preferredAppForFile);
// returns the reason why an application is shown in Open With window // returns the reason why an application is shown in Open With
// static version, needs the preferred app for preformance // window static version, needs the preferred app for preformance
static void RelationDescription(const BMessage* entriesToOpen, static void RelationDescription(const BMessage* entriesToOpen,
const Model*, BString*, const entry_ref* preferredApp, const Model*, BString*, const entry_ref* preferredApp,
const entry_ref* preferredAppForFile); const entry_ref* preferredAppForFile);
// returns a string describing why application handles files to open // returns a string describing why application handles files
// to open
bool CanOpenWithFilter(const Model* appModel, const BMessage* entriesToOpen, bool CanOpenWithFilter(const Model* appModel,
const entry_ref* preferredApp); const BMessage* entriesToOpen, const entry_ref* preferredApp);
void NonGenericFileFound(); void NonGenericFileFound();
bool GenericFilesOnly() const; bool GenericFilesOnly() const;
@@ -116,7 +119,8 @@ class SearchForSignatureEntryList : public EntryListBase {
private: private:
static int32 Relation(const Model* node, const Model* app); static int32 Relation(const Model* node, const Model* app);
// returns the reason why an application is shown in Open With window // returns the reason why an application is shown in
// Open With window
CachedEntryIteratorList* fIteratorList; CachedEntryIteratorList* fIteratorList;
BObjectList<BString> fSignatures; BObjectList<BString> fSignatures;
@@ -152,7 +156,8 @@ class OpenWithContainerWindow : public BContainerWindow {
OpenWithPoseView* PoseView() const; OpenWithPoseView* PoseView() const;
protected: protected:
virtual BPoseView* NewPoseView(Model* model, BRect rect, uint32 viewMode); virtual BPoseView* NewPoseView(Model* model, BRect rect,
uint32 viewMode);
virtual bool ShouldAddMenus() const; virtual bool ShouldAddMenus() const;
virtual void ShowContextMenu(BPoint, const entry_ref*, BView*); virtual void ShowContextMenu(BPoint, const entry_ref*, BView*);
@@ -176,10 +181,12 @@ class OpenWithContainerWindow : public BContainerWindow {
void OpenWithSelection(); void OpenWithSelection();
// open entries with the selected app // open entries with the selected app
void MakeDefaultAndOpen(); void MakeDefaultAndOpen();
// open entries with the selected app and make it the default handler // open entries with the selected app and make it
// the default handler
private: private:
static filter_result KeyDownFilter(BMessage*, BHandler**, BMessageFilter*); static filter_result KeyDownFilter(BMessage*, BHandler**,
BMessageFilter*);
BMessage* fEntriesToOpen; BMessage* fEntriesToOpen;
BButton* fLaunchButton; BButton* fLaunchButton;
@@ -198,16 +205,19 @@ class OpenWithPoseView : public BPoseView {
// open entries with the selected app // open entries with the selected app
int32 OpenWithRelation(const Model*) const; int32 OpenWithRelation(const Model*) const;
// returns the reason why an application is shown in Open With window // returns the reason why an application is shown in
// Open With window
void OpenWithRelationDescription(const Model*, BString*) const; void OpenWithRelationDescription(const Model*, BString*) const;
// returns a string describing why application handles files to open // returns a string describing why application handles files
// to open
OpenWithContainerWindow* ContainerWindow() const; OpenWithContainerWindow* ContainerWindow() const;
virtual bool AddPosesThreadValid(const entry_ref*) const; virtual bool AddPosesThreadValid(const entry_ref*) const;
protected: protected:
// don't do any volume watching and memtamime watching in open with panels for now // don't do any volume watching and memtamime watching in open with
// panels for now
virtual void InitialStartWatching() {} virtual void InitialStartWatching() {}
virtual void FinalStopWatching() {} virtual void FinalStopWatching() {}
@@ -225,18 +235,22 @@ class OpenWithPoseView : public BPoseView {
virtual void SavePoseLocations(BRect* = NULL); virtual void SavePoseLocations(BRect* = NULL);
virtual void MoveSelectionToTrash(bool selectNext = true); virtual void MoveSelectionToTrash(bool selectNext = true);
virtual void MoveSelectionTo(BPoint, BPoint, BContainerWindow*); virtual void MoveSelectionTo(BPoint, BPoint, BContainerWindow*);
virtual void MoveSelectionInto(Model* destFolder, BContainerWindow* srcWindow, virtual void MoveSelectionInto(Model* destFolder,
bool forceCopy, bool create_link = false); BContainerWindow* srcWindow, bool forceCopy,
bool create_link = false);
virtual bool HandleMessageDropped(BMessage*); virtual bool HandleMessageDropped(BMessage*);
virtual bool CanHandleDragSelection(const Model*, const BMessage*, bool); virtual bool CanHandleDragSelection(const Model*, const BMessage*,
bool);
virtual bool Represents(const node_ref*) const; virtual bool Represents(const node_ref*) const;
virtual bool Represents(const entry_ref*) const; virtual bool Represents(const entry_ref*) const;
virtual void CreatePoses(Model** models, PoseInfo* poseInfoArray, int32 count, virtual void CreatePoses(Model** models, PoseInfo* poseInfoArray,
BPose** resultingPoses, bool insertionSort = true, int32* lastPoseIndexPtr = NULL, int32 count, BPose** resultingPoses, bool insertionSort = true,
BRect* boundsPtr = NULL, bool forceDraw = false); int32* lastPoseIndexPtr = NULL, BRect* boundsPtr = NULL,
// override to add selecting the default handling app for selection bool forceDraw = false);
// override to add selecting the default handling app
// for selection
virtual bool ShouldShowPose(const Model*, const PoseInfo*); virtual bool ShouldShowPose(const Model*, const PoseInfo*);
@@ -260,7 +274,8 @@ class RelationCachingModelProxy {
RelationCachingModelProxy(Model* model); RelationCachingModelProxy(Model* model);
~RelationCachingModelProxy(); ~RelationCachingModelProxy();
int32 Relation(SearchForSignatureEntryList* iterator, BMessage* entries) const; int32 Relation(SearchForSignatureEntryList* iterator,
BMessage* entries) const;
Model* fModel; Model* fModel;
mutable int32 fRelation; mutable int32 fRelation;
+6 -3
View File
@@ -102,7 +102,8 @@ OverrideAlert::OverPosition(float width, float height)
// This positions the alert window like a normal alert, put // This positions the alert window like a normal alert, put
// places it on top of the calling window if possible. // places it on top of the calling window if possible.
BWindow* window = dynamic_cast<BWindow*>(BLooper::LooperForThread(find_thread(NULL))); BWindow* window
= dynamic_cast<BWindow*>(BLooper::LooperForThread(find_thread(NULL)));
BRect screenFrame; BRect screenFrame;
BRect desirableRect; BRect desirableRect;
screenFrame = BScreen(window).Frame(); screenFrame = BScreen(window).Frame();
@@ -149,7 +150,9 @@ OverrideAlert::UpdateButtons(uint32 modifiers, bool force)
fCurModifiers = modifiers; fCurModifiers = modifiers;
for (int32 i = 0; i < 3; i++) { for (int32 i = 0; i < 3; i++) {
BButton* button = ButtonAt(i); BButton* button = ButtonAt(i);
if (button) if (button) {
button->SetEnabled(((fButtonModifiers[i] & fCurModifiers) == fButtonModifiers[i])); button->SetEnabled(((fButtonModifiers[i] & fCurModifiers)
== fButtonModifiers[i]));
}
} }
} }
+57 -34
View File
@@ -56,7 +56,8 @@ CalcFreeSpace(BVolume* volume)
if (capacity == 0) if (capacity == 0)
return 100; return 100;
int32 percent = static_cast<int32>(volume->FreeBytes() / (capacity / 100)); int32 percent
= static_cast<int32>(volume->FreeBytes() / (capacity / 100));
// warn below 20 MB of free space (if this is less than 10% of free space) // warn below 20 MB of free space (if this is less than 10% of free space)
if (volume->FreeBytes() < 20 * 1024 * 1024 && percent < 10) if (volume->FreeBytes() < 20 * 1024 * 1024 && percent < 10)
@@ -69,7 +70,8 @@ CalcFreeSpace(BVolume* volume)
// symlink pose uses the resolved model to retrieve the icon, if not broken // symlink pose uses the resolved model to retrieve the icon, if not broken
// everything else, like the attributes, etc. is retrieved directly from the // everything else, like the attributes, etc. is retrieved directly from the
// symlink itself // symlink itself
BPose::BPose(Model* model, BPoseView* view, uint32 clipboardMode, bool selected) BPose::BPose(Model* model, BPoseView* view, uint32 clipboardMode,
bool selected)
: fModel(model), : fModel(model),
fWidgetList(4, true), fWidgetList(4, true),
fClipboardMode(clipboardMode), fClipboardMode(clipboardMode),
@@ -148,7 +150,8 @@ BPose::AddWidget(BPoseView* poseView, BColumn* column)
BTextWidget* BTextWidget*
BPose::AddWidget(BPoseView* poseView, BColumn* column, ModelNodeLazyOpener &opener) BPose::AddWidget(BPoseView* poseView, BColumn* column,
ModelNodeLazyOpener &opener)
{ {
opener.OpenNode(); opener.OpenNode();
if (fModel->InitCheck() != B_OK) if (fModel->InitCheck() != B_OK)
@@ -171,7 +174,8 @@ BPose::RemoveWidget(BPoseView*, BColumn* column)
void void
BPose::Commit(bool saveChanges, BPoint loc, BPoseView* poseView, int32 poseIndex) BPose::Commit(bool saveChanges, BPoint loc, BPoseView* poseView,
int32 poseIndex)
{ {
int32 count = fWidgetList.CountItems(); int32 count = fWidgetList.CountItems();
for (int32 index = 0; index < count; index++) { for (int32 index = 0; index < count; index++) {
@@ -185,8 +189,8 @@ BPose::Commit(bool saveChanges, BPoint loc, BPoseView* poseView, int32 poseIndex
inline bool inline bool
OneMouseUp(BTextWidget* widget, BPose* pose, BPoseView* poseView, BColumn* column, OneMouseUp(BTextWidget* widget, BPose* pose, BPoseView* poseView,
BPoint poseLoc, BPoint where) BColumn* column, BPoint poseLoc, BPoint where)
{ {
BRect rect; BRect rect;
if (poseView->ViewMode() == kListMode) if (poseView->ViewMode() == kListMode)
@@ -258,7 +262,8 @@ BPose::UpdateWidgetAndModel(Model* resolvedModel, const char* attrName,
BTextWidget* widget = fWidgetList.ItemAt(i); BTextWidget* widget = fWidgetList.ItemAt(i);
BColumn* column = poseView->ColumnFor(widget->AttrHash()); BColumn* column = poseView->ColumnFor(widget->AttrHash());
if (column != NULL && !strcmp(column->AttrName(), attrName)) { if (column != NULL && !strcmp(column->AttrName(), attrName)) {
widget->CheckAndUpdate(poseLoc, column, poseView, visible); widget->CheckAndUpdate(poseLoc, column, poseView,
visible);
break; break;
} }
} }
@@ -283,8 +288,10 @@ BPose::UpdateWidgetAndModel(Model* resolvedModel, const char* attrName,
if (column->StatField()) { if (column->StatField()) {
BTextWidget* widget = WidgetFor(column->AttrHash()); BTextWidget* widget = WidgetFor(column->AttrHash());
if (widget) if (widget) {
widget->CheckAndUpdate(poseLoc, column, poseView, visible); widget->CheckAndUpdate(poseLoc, column, poseView,
visible);
}
} }
} }
} }
@@ -403,7 +410,8 @@ BPose::EditPreviousNextWidgetCommon(BPoseView* poseView, bool next)
{ {
bool found = false; bool found = false;
int32 delta = next ? 1 : -1; int32 delta = next ? 1 : -1;
for (int32 index = next ? 0 : poseView->CountColumns() - 1; ; index += delta) { for (int32 index = next ? 0 : poseView->CountColumns() - 1; ;
index += delta) {
BColumn* column = poseView->ColumnAt(index); BColumn* column = poseView->ColumnAt(index);
if (!column) if (!column)
break; break;
@@ -510,7 +518,8 @@ BPose::PointInPose(BPoint loc, const BPoseView* poseView, BPoint where,
if (!column) if (!column)
break; break;
BTextWidget* widget = WidgetFor(column->AttrHash()); BTextWidget* widget = WidgetFor(column->AttrHash());
if (widget && widget->CalcClickRect(loc, column, poseView).Contains(where)) { if (widget
&& widget->CalcClickRect(loc, column, poseView).Contains(where)) {
if (hitWidget) if (hitWidget)
*hitWidget = widget; *hitWidget = widget;
return true; return true;
@@ -522,8 +531,8 @@ BPose::PointInPose(BPoint loc, const BPoseView* poseView, BPoint where,
void void
BPose::Draw(BRect rect, const BRect& updateRect, BPoseView* poseView, BView* drawView, BPose::Draw(BRect rect, const BRect& updateRect, BPoseView* poseView,
bool fullDraw, BPoint offset, bool selected) BView* drawView, bool fullDraw, BPoint offset, bool selected)
{ {
// If the background wasn't cleared and Draw() is not called after // If the background wasn't cleared and Draw() is not called after
// having edited a name or similar (with fullDraw) // having edited a name or similar (with fullDraw)
@@ -549,8 +558,8 @@ BPose::Draw(BRect rect, const BRect& updateRect, BPoseView* poseView, BView* dra
iconRect.top = iconRect.bottom - size; iconRect.top = iconRect.bottom - size;
if (updateRect.Intersects(iconRect)) { if (updateRect.Intersects(iconRect)) {
iconRect.OffsetBy(offset); iconRect.OffsetBy(offset);
DrawIcon(iconRect.LeftTop(), drawView, poseView->IconSize(), directDraw, DrawIcon(iconRect.LeftTop(), drawView, poseView->IconSize(),
!windowActive && !showSelectionWhenInactive); directDraw, !windowActive && !showSelectionWhenInactive);
} }
// draw text // draw text
@@ -571,8 +580,8 @@ BPose::Draw(BRect rect, const BRect& updateRect, BPoseView* poseView, BView* dra
poseView)); poseView));
if (updateRect.Intersects(widgetRect)) { if (updateRect.Intersects(widgetRect)) {
BRect widgetTextRect(widget->CalcRect(rect.LeftTop(), column, BRect widgetTextRect(widget->CalcRect(rect.LeftTop(),
poseView)); column, poseView));
bool selectDuringDraw = directDraw && selected bool selectDuringDraw = directDraw && selected
&& windowActive; && windowActive;
@@ -583,12 +592,15 @@ BPose::Draw(BRect rect, const BRect& updateRect, BPoseView* poseView, BView* dra
drawView->SetLowColor(0, 0, 0); drawView->SetLowColor(0, 0, 0);
} }
if (index == 0) if (index == 0) {
widget->Draw(widgetRect, widgetTextRect, column->Width(), widget->Draw(widgetRect, widgetTextRect,
poseView, drawView, selected, fClipboardMode, offset, directDraw); column->Width(), poseView, drawView, selected,
else fClipboardMode, offset, directDraw);
} else {
widget->Draw(widgetTextRect, widgetTextRect, column->Width(), widget->Draw(widgetTextRect, widgetTextRect, column->Width(),
poseView, drawView, false, fClipboardMode, offset, directDraw); poseView, drawView, false, fClipboardMode,
offset, directDraw);
}
if (index == 0 && selectDuringDraw) if (index == 0 && selectDuringDraw)
drawView->PopState(); drawView->PopState();
@@ -596,7 +608,8 @@ BPose::Draw(BRect rect, const BRect& updateRect, BPoseView* poseView, BView* dra
if (windowActive || isDrawingSelectionRect) { if (windowActive || isDrawingSelectionRect) {
widgetTextRect.OffsetBy(offset); widgetTextRect.OffsetBy(offset);
drawView->InvertRect(widgetTextRect); drawView->InvertRect(widgetTextRect);
} else if (!windowActive && showSelectionWhenInactive) { } else if (!windowActive
&& showSelectionWhenInactive) {
widgetTextRect.OffsetBy(offset); widgetTextRect.OffsetBy(offset);
drawView->PushState(); drawView->PushState();
drawView->SetDrawingMode(B_OP_BLEND); drawView->SetDrawingMode(B_OP_BLEND);
@@ -705,8 +718,10 @@ BPose::MoveTo(BPoint point, BPoseView* poseView, bool inval)
// might need to move a text view if we're active // might need to move a text view if we're active
if (poseView->ActivePose() == this) { if (poseView->ActivePose() == this) {
BView* border_view = poseView->FindView("BorderView"); BView* border_view = poseView->FindView("BorderView");
if (border_view) if (border_view) {
border_view->MoveBy(point.x - oldLocation.x, point.y - oldLocation.y); border_view->MoveBy(point.x - oldLocation.x,
point.y - oldLocation.y);
}
} }
float scale = 1.0; float scale = 1.0;
@@ -756,8 +771,8 @@ BPose::WidgetFor(uint32 attr, int32* index) const
BTextWidget* BTextWidget*
BPose::WidgetFor(BColumn* column, BPoseView* poseView, ModelNodeLazyOpener &opener, BPose::WidgetFor(BColumn* column, BPoseView* poseView,
int32* index) ModelNodeLazyOpener &opener, int32* index)
{ {
BTextWidget* widget = WidgetFor(column->AttrHash(), index); BTextWidget* widget = WidgetFor(column->AttrHash(), index);
if (!widget) if (!widget)
@@ -777,17 +792,20 @@ BPose::TestLargeIconPixel(BPoint point) const
void void
BPose::DrawIcon(BPoint where, BView* view, icon_size kind, bool direct, bool drawUnselected) BPose::DrawIcon(BPoint where, BView* view, icon_size kind, bool direct,
bool drawUnselected)
{ {
if (fClipboardMode == kMoveSelectionTo) { if (fClipboardMode == kMoveSelectionTo) {
view->SetDrawingMode(B_OP_ALPHA); view->SetDrawingMode(B_OP_ALPHA);
view->SetHighColor(0, 0, 0, 64); // set the level of transparency view->SetHighColor(0, 0, 0, 64);
// set the level of transparency
view->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_OVERLAY); view->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_OVERLAY);
} else if (direct) } else if (direct)
view->SetDrawingMode(B_OP_OVER); view->SetDrawingMode(B_OP_OVER);
IconCache::sIconCache->Draw(ResolvedModel(), view, where, IconCache::sIconCache->Draw(ResolvedModel(), view, where,
fIsSelected && !drawUnselected ? kSelectedIcon : kNormalIcon, kind, true); fIsSelected && !drawUnselected ? kSelectedIcon : kNormalIcon, kind,
true);
if (fPercent != -1) if (fPercent != -1)
DrawBar(where, view, kind); DrawBar(where, view, kind);
@@ -816,7 +834,8 @@ BPose::DrawBar(BPoint where,BView* view,icon_size kind)
view->SetHighColor(32, 32, 32, 92); view->SetHighColor(32, 32, 32, 92);
view->MovePenTo(BPoint(where.x + size, where.y + 1 + yOffset)); view->MovePenTo(BPoint(where.x + size, where.y + 1 + yOffset));
view->StrokeLine(BPoint(where.x + size, where.y + size - yOffset)); view->StrokeLine(BPoint(where.x + size, where.y + size - yOffset));
view->StrokeLine(BPoint(where.x + size - barWidth + 1, where.y + size - yOffset)); view->StrokeLine(BPoint(where.x + size - barWidth + 1,
where.y + size - yOffset));
view->SetDrawingMode(B_OP_ALPHA); view->SetDrawingMode(B_OP_ALPHA);
@@ -846,7 +865,9 @@ BPose::DrawBar(BPoint where,BView* view,icon_size kind)
// the used space bar // the used space bar
bar.top = bar.bottom + 1; bar.top = bar.bottom + 1;
bar.bottom = rect.bottom; bar.bottom = rect.bottom;
view->SetHighColor(fPercent < -1 ? TrackerSettings().WarningSpaceColor() : TrackerSettings().UsedSpaceColor()); view->SetHighColor(fPercent < -1
? TrackerSettings().WarningSpaceColor()
: TrackerSettings().UsedSpaceColor());
view->FillRect(bar); view->FillRect(bar);
view->PopState(); view->PopState();
@@ -899,8 +920,10 @@ BPose::CalcRect(BPoint loc, const BPoseView* poseView, bool minimalRect) const
if (minimalRect) { if (minimalRect) {
BTextWidget* widget = WidgetFor(poseView->FirstColumn()->AttrHash()); BTextWidget* widget = WidgetFor(poseView->FirstColumn()->AttrHash());
if (widget) if (widget) {
rect.right = widget->CalcRect(loc, poseView->FirstColumn(), poseView).right; rect.right = widget->CalcRect(loc, poseView->FirstColumn(),
poseView).right;
}
} }
return rect; return rect;
+8 -4
View File
@@ -55,11 +55,13 @@ enum {
class BPose { class BPose {
public: public:
BPose(Model* adopt, BPoseView*, uint32 clipboardMode, bool selected = false); BPose(Model* adopt, BPoseView*, uint32 clipboardMode,
bool selected = false);
virtual ~BPose(); virtual ~BPose();
BTextWidget* AddWidget(BPoseView*, BColumn*); BTextWidget* AddWidget(BPoseView*, BColumn*);
BTextWidget* AddWidget(BPoseView*, BColumn*, ModelNodeLazyOpener &opener); BTextWidget* AddWidget(BPoseView*, BColumn*,
ModelNodeLazyOpener &opener);
void RemoveWidget(BPoseView*, BColumn*); void RemoveWidget(BPoseView*, BColumn*);
void SetLocation(BPoint, const BPoseView*); void SetLocation(BPoint, const BPoseView*);
void MoveTo(BPoint, BPoseView*, bool inval = true); void MoveTo(BPoint, BPoseView*, bool inval = true);
@@ -68,13 +70,15 @@ class BPose {
bool fullDraw = true); bool fullDraw = true);
void Draw(BRect poseRect, const BRect& updateRect, BPoseView*, void Draw(BRect poseRect, const BRect& updateRect, BPoseView*,
BView* drawView, bool fullDraw, BPoint offset, bool selected); BView* drawView, bool fullDraw, BPoint offset, bool selected);
void DeselectWithoutErasingBackground(BRect rect, BPoseView* poseView); void DeselectWithoutErasingBackground(BRect rect,
BPoseView* poseView);
// special purpose draw call for deselecting over a textured // special purpose draw call for deselecting over a textured
// background // background
void DrawBar(BPoint where, BView* view, icon_size kind); void DrawBar(BPoint where, BView* view, icon_size kind);
void DrawIcon(BPoint, BView*, icon_size, bool direct, bool drawUnselected = false); void DrawIcon(BPoint, BView*, icon_size, bool direct,
bool drawUnselected = false);
void DrawToggleSwitch(BRect, BPoseView*); void DrawToggleSwitch(BRect, BPoseView*);
void MouseUp(BPoint poseLoc, BPoseView*, BPoint where, int32 index); void MouseUp(BPoint poseLoc, BPoseView*, BPoint where, int32 index);
Model* TargetModel() const; Model* TargetModel() const;
+22 -15
View File
@@ -73,7 +73,8 @@ public:
template<class EachParam1> template<class EachParam1>
void void
EachPoseAndModel(PoseList* list, void (*eachFunction)(BPose*, Model*, EachParam1), EachPoseAndModel(PoseList* list,
void (*eachFunction)(BPose*, Model*, EachParam1),
EachParam1 eachParam1) EachParam1 eachParam1)
{ {
for (int32 index = list->CountItems() - 1; index >= 0; index--) { for (int32 index = list->CountItems() - 1; index >= 0; index--) {
@@ -87,8 +88,9 @@ EachPoseAndModel(PoseList* list, void (*eachFunction)(BPose*, Model*, EachParam1
template<class EachParam1> template<class EachParam1>
void void
EachPoseAndModel(PoseList* list, void (*eachFunction)(BPose*, Model*, int32 , EachPoseAndModel(PoseList* list,
EachParam1), EachParam1 eachParam1) void (*eachFunction)(BPose*, Model*, int32, EachParam1),
EachParam1 eachParam1)
{ {
for (int32 index = list->CountItems() - 1; index >= 0; index--) { for (int32 index = list->CountItems() - 1; index >= 0; index--) {
BPose* pose = list->ItemAt(index); BPose* pose = list->ItemAt(index);
@@ -101,8 +103,9 @@ EachPoseAndModel(PoseList* list, void (*eachFunction)(BPose*, Model*, int32 ,
template<class EachParam1, class EachParam2> template<class EachParam1, class EachParam2>
void void
EachPoseAndModel(PoseList* list, void (*eachFunction)(BPose*, Model*, EachParam1, EachPoseAndModel(PoseList* list,
EachParam2), EachParam1 eachParam1, EachParam2 eachParam2) void (*eachFunction)(BPose*, Model*, EachParam1, EachParam2),
EachParam1 eachParam1, EachParam2 eachParam2)
{ {
for (int32 index = list->CountItems() - 1; index >= 0; index--) { for (int32 index = list->CountItems() - 1; index >= 0; index--) {
BPose* pose = list->ItemAt(index); BPose* pose = list->ItemAt(index);
@@ -114,8 +117,9 @@ EachPoseAndModel(PoseList* list, void (*eachFunction)(BPose*, Model*, EachParam1
template<class EachParam1, class EachParam2> template<class EachParam1, class EachParam2>
void void
EachPoseAndModel(PoseList* list, void (*eachFunction)(BPose*, Model*, int32, EachPoseAndModel(PoseList* list,
EachParam1, EachParam2), EachParam1 eachParam1, EachParam2 eachParam2) void (*eachFunction)(BPose*, Model*, int32, EachParam1, EachParam2),
EachParam1 eachParam1, EachParam2 eachParam2)
{ {
for (int32 index = list->CountItems() - 1; index >= 0; index--) { for (int32 index = list->CountItems() - 1; index >= 0; index--) {
BPose* pose = list->ItemAt(index); BPose* pose = list->ItemAt(index);
@@ -127,8 +131,8 @@ EachPoseAndModel(PoseList* list, void (*eachFunction)(BPose*, Model*, int32,
template<class EachParam1> template<class EachParam1>
void void
EachPoseAndResolvedModel(PoseList* list, void (*eachFunction)(BPose*, Model*, EachParam1), EachPoseAndResolvedModel(PoseList* list,
EachParam1 eachParam1) void (*eachFunction)(BPose*, Model*, EachParam1), EachParam1 eachParam1)
{ {
for (int32 index = list->CountItems() - 1; index >= 0; index--) { for (int32 index = list->CountItems() - 1; index >= 0; index--) {
BPose* pose = list->ItemAt(index); BPose* pose = list->ItemAt(index);
@@ -140,8 +144,9 @@ EachPoseAndResolvedModel(PoseList* list, void (*eachFunction)(BPose*, Model*, Ea
template<class EachParam1> template<class EachParam1>
void void
EachPoseAndResolvedModel(PoseList* list, void (*eachFunction)(BPose*, Model*, int32 , EachPoseAndResolvedModel(PoseList* list,
EachParam1), EachParam1 eachParam1) void (*eachFunction)(BPose*, Model*, int32 , EachParam1),
EachParam1 eachParam1)
{ {
for (int32 index = list->CountItems() - 1; index >= 0; index--) { for (int32 index = list->CountItems() - 1; index >= 0; index--) {
BPose* pose = list->ItemAt(index); BPose* pose = list->ItemAt(index);
@@ -153,8 +158,9 @@ EachPoseAndResolvedModel(PoseList* list, void (*eachFunction)(BPose*, Model*, in
template<class EachParam1, class EachParam2> template<class EachParam1, class EachParam2>
void void
EachPoseAndResolvedModel(PoseList* list, void (*eachFunction)(BPose*, Model*, EachParam1, EachPoseAndResolvedModel(PoseList* list,
EachParam2), EachParam1 eachParam1, EachParam2 eachParam2) void (*eachFunction)(BPose*, Model*, EachParam1, EachParam2),
EachParam1 eachParam1, EachParam2 eachParam2)
{ {
for (int32 index = list->CountItems() - 1; index >= 0; index--) { for (int32 index = list->CountItems() - 1; index >= 0; index--) {
BPose* pose = list->ItemAt(index); BPose* pose = list->ItemAt(index);
@@ -166,8 +172,9 @@ EachPoseAndResolvedModel(PoseList* list, void (*eachFunction)(BPose*, Model*, Ea
template<class EachParam1, class EachParam2> template<class EachParam1, class EachParam2>
void void
EachPoseAndResolvedModel(PoseList* list, void (*eachFunction)(BPose*, Model*, int32, EachPoseAndResolvedModel(PoseList* list,
EachParam1, EachParam2), EachParam1 eachParam1, EachParam2 eachParam2) void (*eachFunction)(BPose*, Model*, int32, EachParam1, EachParam2),
EachParam1 eachParam1, EachParam2 eachParam2)
{ {
for (int32 index = list->CountItems() - 1; index >= 0; index--) { for (int32 index = list->CountItems() - 1; index >= 0; index--) {
BPose* pose = list->ItemAt(index); BPose* pose = list->ItemAt(index);
+65 -34
View File
@@ -203,7 +203,8 @@ PoseCompareAddWidget(const BPose* p1, const BPose* p2, BPoseView* view);
// #pragma mark - // #pragma mark -
BPoseView::BPoseView(Model* model, BRect bounds, uint32 viewMode, uint32 resizeMask) BPoseView::BPoseView(Model* model, BRect bounds, uint32 viewMode,
uint32 resizeMask)
: BView(bounds, "PoseView", resizeMask, B_WILL_DRAW | B_PULSE_NEEDED), : BView(bounds, "PoseView", resizeMask, B_WILL_DRAW | B_PULSE_NEEDED),
fIsDrawingSelectionRect(false), fIsDrawingSelectionRect(false),
fHScrollBar(NULL), fHScrollBar(NULL),
@@ -265,7 +266,8 @@ BPoseView::BPoseView(Model* model, BRect bounds, uint32 viewMode, uint32 resizeM
fDeskbarFrame(0, 0, -1, -1) fDeskbarFrame(0, 0, -1, -1)
{ {
fViewState->SetViewMode(viewMode); fViewState->SetViewMode(viewMode);
fShowSelectionWhenInactive = TrackerSettings().ShowSelectionWhenInactive(); fShowSelectionWhenInactive
= TrackerSettings().ShowSelectionWhenInactive();
fTransparentSelection = TrackerSettings().TransparentSelection(); fTransparentSelection = TrackerSettings().TransparentSelection();
fFilterStrings.AddItem(new BString("")); fFilterStrings.AddItem(new BString(""));
} }
@@ -400,7 +402,8 @@ BPoseView::RestoreColumnState(AttributeStreamNode* node)
} }
if (size > 0 && size < 10000) { if (size > 0 && size < 10000) {
// check for invalid sizes here to protect against munged attributes // check for invalid sizes here to protect against
// munged attributes
char* buffer = new char[size]; char* buffer = new char[size];
off_t result = node->Read(name, 0, B_RAW_TYPE, size, buffer); off_t result = node->Read(name, 0, B_RAW_TYPE, size, buffer);
if (result) { if (result) {
@@ -468,7 +471,8 @@ BPoseView::AddColumnList(BObjectList<BColumn>* list)
list->SortItems(&CompareColumns); list->SortItems(&CompareColumns);
float nextLeftEdge = 0; float nextLeftEdge = 0;
for (int32 columIndex = 0; columIndex < list->CountItems(); columIndex++) { for (int32 columIndex = 0; columIndex < list->CountItems();
columIndex++) {
BColumn* column = list->ItemAt(columIndex); BColumn* column = list->ItemAt(columIndex);
// Make sure that columns don't overlap // Make sure that columns don't overlap
@@ -477,13 +481,15 @@ BPoseView::AddColumnList(BObjectList<BColumn>* list)
column->SetOffset(nextLeftEdge); column->SetOffset(nextLeftEdge);
} }
nextLeftEdge = column->Offset() + column->Width() - kRoomForLine / 2.0f nextLeftEdge = column->Offset() + column->Width()
+ kTitleColumnExtraMargin; - kRoomForLine / 2.0f + kTitleColumnExtraMargin;
fColumnList->AddItem(column); fColumnList->AddItem(column);
if (!IsWatchingDateFormatChange() && column->AttrType() == B_TIME_TYPE) if (!IsWatchingDateFormatChange()
&& column->AttrType() == B_TIME_TYPE) {
StartWatchDateFormatChange(); StartWatchDateFormatChange();
} }
}
} }
@@ -514,14 +520,16 @@ BPoseView::RestoreState(AttributeStreamNode* node)
} }
if (size > 0 && size < 10000) { if (size > 0 && size < 10000) {
// check for invalid sizes here to protect against munged attributes // check for invalid sizes here to protect against
// munged attributes
char* buffer = new char[size]; char* buffer = new char[size];
off_t result = node->Read(name, 0, B_RAW_TYPE, size, buffer); off_t result = node->Read(name, 0, B_RAW_TYPE, size, buffer);
if (result) { if (result) {
BMallocIO stream; BMallocIO stream;
stream.WriteAt(0, buffer, size); stream.WriteAt(0, buffer, size);
stream.Seek(0, SEEK_SET); stream.Seek(0, SEEK_SET);
BViewState* viewstate = BViewState::InstantiateFromStream(&stream, BViewState* viewstate
= BViewState::InstantiateFromStream(&stream,
wrongEndianness); wrongEndianness);
if (viewstate) { if (viewstate) {
delete fViewState; delete fViewState;
@@ -805,25 +813,28 @@ BPoseView::SavePoseLocations(BRect* frameIfDesktop)
// nuke opposite endianness // nuke opposite endianness
dir.RemoveAttr(poseInfoAttrForeign); dir.RemoveAttr(poseInfoAttrForeign);
if (!isTrash && desktop && dir.WriteAttr(kAttrExtendedDisksPoseInfo, if (!isTrash && desktop
B_RAW_TYPE, 0, && dir.WriteAttr(kAttrExtendedDisksPoseInfo,
extendedPoseInfo, extendedPoseInfoSize) B_RAW_TYPE, 0, extendedPoseInfo, extendedPoseInfoSize)
== (ssize_t)extendedPoseInfoSize) == (ssize_t)extendedPoseInfoSize) {
// nuke opposite endianness // nuke opposite endianness
dir.RemoveAttr(kAttrExtendedDisksPoseInfoForegin); dir.RemoveAttr(kAttrExtendedDisksPoseInfoForegin);
} }
}
} else { } else {
model->WriteAttrKillForeign(kAttrPoseInfo, kAttrPoseInfoForeign, model->WriteAttrKillForeign(kAttrPoseInfo,
B_RAW_TYPE, 0, &poseInfo, sizeof(poseInfo)); kAttrPoseInfoForeign, B_RAW_TYPE, 0, &poseInfo,
sizeof(poseInfo));
if (desktop) { if (desktop) {
model->WriteAttrKillForeign(kAttrExtendedPoseInfo, model->WriteAttrKillForeign(kAttrExtendedPoseInfo,
kAttrExtendedPoseInfoForegin, kAttrExtendedPoseInfoForegin,
B_RAW_TYPE, 0, extendedPoseInfo, extendedPoseInfoSize); B_RAW_TYPE, 0, extendedPoseInfo,
extendedPoseInfoSize);
} }
} }
delete [] (char*)extendedPoseInfo; delete[] (char*)extendedPoseInfo;
// TODO: fix up this mess // TODO: fix up this mess
} }
} }
@@ -935,15 +946,19 @@ BPoseView::AttachedToWindow()
if (fIsDesktopWindow) if (fIsDesktopWindow)
AddFilter(new TPoseViewFilter(this)); AddFilter(new TPoseViewFilter(this));
AddFilter(new ShortcutFilter(B_RETURN, B_OPTION_KEY, kOpenSelection, this)); AddFilter(new ShortcutFilter(B_RETURN, B_OPTION_KEY, kOpenSelection,
// add Option-Return as a shortcut filter because AddShortcut doesn't allow this));
// us to have shortcuts without Command yet // add Option-Return as a shortcut filter because AddShortcut
// doesn't allow us to have shortcuts without Command yet
AddFilter(new ShortcutFilter(B_ESCAPE, 0, B_CANCEL, this)); AddFilter(new ShortcutFilter(B_ESCAPE, 0, B_CANCEL, this));
// Escape key, used to abort an on-going clipboard cut or filtering // Escape key, used to abort an on-going clipboard cut or filtering
AddFilter(new ShortcutFilter(B_ESCAPE, B_SHIFT_KEY, kCancelSelectionToClipboard, this)); AddFilter(new ShortcutFilter(B_ESCAPE, B_SHIFT_KEY,
// Escape + SHIFT will remove current selection from clipboard, or all poses from current folder if 0 selected kCancelSelectionToClipboard, this));
// Escape + SHIFT will remove current selection from clipboard,
// or all poses from current folder if 0 selected
AddFilter(new LongAndDragTrackingFilter(kMsgMouseLongDown, kMsgMouseDragged)); AddFilter(new LongAndDragTrackingFilter(kMsgMouseLongDown,
kMsgMouseDragged));
fLastLeftTop = LeftTop(); fLastLeftTop = LeftTop();
BFont font(be_plain_font); BFont font(be_plain_font);
@@ -954,7 +969,8 @@ BPoseView::AttachedToWindow()
// static - init just once // static - init just once
if (sFontHeight == -1) { if (sFontHeight == -1) {
font.GetHeight(&sFontInfo); font.GetHeight(&sFontInfo);
sFontHeight = sFontInfo.ascent + sFontInfo.descent + sFontInfo.leading; sFontHeight = sFontInfo.ascent + sFontInfo.descent
+ sFontInfo.leading;
} }
if (TTracker* app = dynamic_cast<TTracker*>(be_app)) { if (TTracker* app = dynamic_cast<TTracker*>(be_app)) {
@@ -981,7 +997,8 @@ BPoseView::SetIconPoseHeight()
case kMiniIconMode: case kMiniIconMode:
fViewState->SetIconSize(B_MINI_ICON); fViewState->SetIconSize(B_MINI_ICON);
fIconPoseHeight = ceilf(sFontHeight < IconSizeInt() ? IconSizeInt() : sFontHeight + 1); fIconPoseHeight = ceilf(sFontHeight <
IconSizeInt() ? IconSizeInt() : sFontHeight + 1);
break; break;
default: default:
@@ -1263,7 +1280,7 @@ BPoseView::AddPosesTask(void* castToParams)
{ {
// AddPosesTask reeds a bunch of models and passes them off to // AddPosesTask reeds a bunch of models and passes them off to
// the pose placing and drawing routine. // the pose placing and drawing routine.
//
AddPosesParams* params = (AddPosesParams*)castToParams; AddPosesParams* params = (AddPosesParams*)castToParams;
BMessenger target(params->target); BMessenger target(params->target);
entry_ref ref(params->ref); entry_ref ref(params->ref);
@@ -1318,8 +1335,9 @@ BPoseView::AddPosesTask(void* castToParams)
node_ref itemNode; node_ref itemNode;
posesResult->fModels[modelChunkIndex] = 0; posesResult->fModels[modelChunkIndex] = 0;
// ToDo - redo this so that modelChunkIndex increments right before // ToDo - redo this so that modelChunkIndex increments
// a new model is added to the array; start with modelChunkIndex = -1 // right before a new model is added to the array;
// start with modelChunkIndex = -1
int32 count = container->GetNextDirents(eptr, 1024, 1); int32 count = container->GetNextDirents(eptr, 1024, 1);
if (count <= 0 && !modelChunkIndex) if (count <= 0 && !modelChunkIndex)
@@ -1328,9 +1346,11 @@ BPoseView::AddPosesTask(void* castToParams)
if (count) { if (count) {
ASSERT(count == 1); ASSERT(count == 1);
if ((!hideDotFiles && (!strcmp(eptr->d_name, ".") || !strcmp(eptr->d_name, ".."))) if ((!hideDotFiles && (!strcmp(eptr->d_name, ".")
|| (hideDotFiles && eptr->d_name[0] == '.')) || !strcmp(eptr->d_name, "..")))
|| (hideDotFiles && eptr->d_name[0] == '.')) {
continue; continue;
}
dirNode.device = eptr->d_pdev; dirNode.device = eptr->d_pdev;
dirNode.node = eptr->d_pino; dirNode.node = eptr->d_pino;
@@ -2151,6 +2171,12 @@ BPoseView::MessageReceived(BMessage* message)
case 64: case 64:
fViewState->SetIconSize(48); fViewState->SetIconSize(48);
break; break;
case 96:
fViewState->SetIconSize(64);
break;
case 128:
fViewState->SetIconSize(96);
break;
} }
} else if (scale == 1 && (int32)IconSizeInt() != 128) { } else if (scale == 1 && (int32)IconSizeInt() != 128) {
switch ((int32)IconSizeInt()) { switch ((int32)IconSizeInt()) {
@@ -2163,11 +2189,17 @@ BPoseView::MessageReceived(BMessage* message)
case 48: case 48:
fViewState->SetIconSize(64); fViewState->SetIconSize(64);
break; break;
case 64:
fViewState->SetIconSize(96);
break;
case 96:
fViewState->SetIconSize(128);
break;
} }
} }
} else { } else {
int32 iconSize = fViewState->LastIconSize(); int32 iconSize = fViewState->LastIconSize();
if (iconSize < 32 || iconSize > 64) { if (iconSize < 32 || iconSize > 128) {
// uninitialized last icon size? // uninitialized last icon size?
iconSize = 32; iconSize = 32;
} }
@@ -6881,8 +6913,7 @@ BPoseView::MouseDown(BPoint where)
uint32 buttons = (uint32)window->CurrentMessage()->FindInt32("buttons"); uint32 buttons = (uint32)window->CurrentMessage()->FindInt32("buttons");
uint32 modifs = modifiers(); uint32 modifs = modifiers();
if (buttons == B_SECONDARY_MOUSE_BUTTON) fTrackRightMouseUp = (buttons == B_SECONDARY_MOUSE_BUTTON);
fTrackRightMouseUp = true;
bool extendSelection = (modifs & B_COMMAND_KEY) && fMultipleSelection; bool extendSelection = (modifs & B_COMMAND_KEY) && fMultipleSelection;
@@ -6893,7 +6924,7 @@ BPoseView::MouseDown(BPoint where)
if (pose) { if (pose) {
AddRemoveSelectionRange(where, extendSelection, pose); AddRemoveSelectionRange(where, extendSelection, pose);
if (!extendSelection && WasDoubleClick(pose, where)) { if (!extendSelection && !fTrackRightMouseUp && WasDoubleClick(pose, where)) {
// special handling for Path field double-clicks // special handling for Path field double-clicks
if (!WasClickInPath(pose, index, where)) if (!WasClickInPath(pose, index, where))
OpenSelection(pose, &index); OpenSelection(pose, &index);
+156 -73
View File
@@ -104,7 +104,8 @@ const uint32 kCheckTypeahead = 'Tcty';
class BPoseView : public BView { class BPoseView : public BView {
public: public:
BPoseView(Model*, BRect, uint32 viewMode, uint32 resizeMask = B_FOLLOW_ALL); BPoseView(Model*, BRect, uint32 viewMode,
uint32 resizeMask = B_FOLLOW_ALL);
virtual ~BPoseView(); virtual ~BPoseView();
// setup, teardown // setup, teardown
@@ -113,8 +114,8 @@ class BPoseView : public BView {
void InitCommon(); void InitCommon();
virtual void DetachedFromWindow(); virtual void DetachedFromWindow();
// Returns true if for instance, node ref is a remote desktop directory and // Returns true if for instance, node ref is a remote desktop
// this is a desktop pose view. // directory and this is a desktop pose view.
virtual bool Represents(const node_ref*) const; virtual bool Represents(const node_ref*) const;
virtual bool Represents(const entry_ref*) const; virtual bool Represents(const entry_ref*) const;
@@ -151,9 +152,9 @@ class BPoseView : public BView {
virtual void SwitchDir(const entry_ref*, virtual void SwitchDir(const entry_ref*,
AttributeStreamNode* node = NULL); AttributeStreamNode* node = NULL);
// in the rare cases where a pose view needs to be explicitly refreshed // in the rare cases where a pose view needs to be explicitly
// (for instance in a query window with a dynamic date query), this is // refreshed (for instance in a query window with a dynamic
// used // date query), this is used
virtual void Refresh(); virtual void Refresh();
// callbacks // callbacks
@@ -228,7 +229,8 @@ class BPoseView : public BView {
icon_size IconSize() const; icon_size IconSize() const;
BRect Extent() const; BRect Extent() const;
void GetLayoutInfo(uint32 viewMode, BPoint* grid, BPoint* offset) const; void GetLayoutInfo(uint32 viewMode, BPoint* grid,
BPoint* offset) const;
int32 CountItems() const; int32 CountItems() const;
void UpdateCount(); void UpdateCount();
@@ -250,8 +252,8 @@ class BPoseView : public BView {
BPoint ResizeColumn(BColumn*, float, float* lastLineDrawPos = NULL, BPoint ResizeColumn(BColumn*, float, float* lastLineDrawPos = NULL,
void (*drawLineFunc)(BPoseView*, BPoint, BPoint) = 0, void (*drawLineFunc)(BPoseView*, BPoint, BPoint) = 0,
void (*undrawLineFunc)(BPoseView*, BPoint, BPoint) = 0); void (*undrawLineFunc)(BPoseView*, BPoint, BPoint) = 0);
// returns the bottom right of the last pose drawn or bottom right of // returns the bottom right of the last pose drawn or
// bounds // the bottom right of bounds
BColumn* ColumnAt(int32 index) const; BColumn* ColumnAt(int32 index) const;
BColumn* ColumnFor(uint32 attribute_hash) const; BColumn* ColumnFor(uint32 attribute_hash) const;
@@ -265,14 +267,16 @@ class BPoseView : public BView {
BPose* PoseAtIndex(int32 index) const; BPose* PoseAtIndex(int32 index) const;
BPose* FindPose(BPoint where, int32* index = NULL) const; BPose* FindPose(BPoint where, int32* index = NULL) const;
// return pose at location h, v (search list starting from bottom so // return pose at location h, v (search list starting from
// drawing and hit detection reflect the same pose ordering) // bottom so drawing and hit detection reflect the same pose
// ordering)
BPose* FindPose(const Model*, int32* index = NULL) const; BPose* FindPose(const Model*, int32* index = NULL) const;
BPose* FindPose(const node_ref*, int32* index = NULL) const; BPose* FindPose(const node_ref*, int32* index = NULL) const;
BPose* FindPose(const entry_ref*, int32* index = NULL) const; BPose* FindPose(const entry_ref*, int32* index = NULL) const;
BPose* FindPose(const entry_ref*, int32 specifierForm, int32* index) const; BPose* FindPose(const entry_ref*, int32 specifierForm,
// special form of FindPose used for scripting, <specifierForm> may int32* index) const;
// ask for previous or next pose // special form of FindPose used for scripting,
// <specifierForm> may ask for previous or next pose
BPose* DeepFindPose(const node_ref* node, int32* index = NULL) const; BPose* DeepFindPose(const node_ref* node, int32* index = NULL) const;
// same as FindPose, node can be a target of the actual // same as FindPose, node can be a target of the actual
// pose if the pose is a symlink // pose if the pose is a symlink
@@ -284,17 +288,22 @@ class BPoseView : public BView {
void UnmountSelectedVolumes(); void UnmountSelectedVolumes();
virtual void OpenParent(); virtual void OpenParent();
virtual void OpenSelection(BPose* clicked_pose = NULL, int32* index = NULL); virtual void OpenSelection(BPose* clicked_pose = NULL,
void OpenSelectionUsing(BPose* clicked_pose = NULL, int32* index = NULL); int32* index = NULL);
void OpenSelectionUsing(BPose* clicked_pose = NULL,
int32* index = NULL);
// launches the open with window // launches the open with window
virtual void MoveSelectionTo(BPoint, BPoint, BContainerWindow*); virtual void MoveSelectionTo(BPoint, BPoint, BContainerWindow*);
void DuplicateSelection(BPoint* dropStart = NULL, BPoint* dropEnd = NULL); void DuplicateSelection(BPoint* dropStart = NULL,
BPoint* dropEnd = NULL);
// Move to trash calls try to select the next pose in the view when they // Move to trash calls try to select the next pose in the view
// are dones // when they are dones
virtual void MoveSelectionToTrash(bool selectNext = true); virtual void MoveSelectionToTrash(bool selectNext = true);
virtual void DeleteSelection(bool selectNext = true, bool askUser = true); virtual void DeleteSelection(bool selectNext = true,
virtual void MoveEntryToTrash(const entry_ref*, bool selectNext = true); bool askUser = true);
virtual void MoveEntryToTrash(const entry_ref*,
bool selectNext = true);
void RestoreSelectionFromTrash(bool selectNext = true); void RestoreSelectionFromTrash(bool selectNext = true);
@@ -306,7 +315,8 @@ class BPoseView : public BView {
void ShowSelectionWindow(); void ShowSelectionWindow();
void ClearSelection(); void ClearSelection();
void ShowSelection(bool); void ShowSelection(bool);
void AddRemovePoseFromSelection(BPose* pose, int32 index, bool select); void AddRemovePoseFromSelection(BPose* pose, int32 index,
bool select);
BLooper* SelectionHandler(); BLooper* SelectionHandler();
void SetSelectionHandler(BLooper*); void SetSelectionHandler(BLooper*);
@@ -339,7 +349,8 @@ class BPoseView : public BView {
inline bool HasPosesInClipboard(); inline bool HasPosesInClipboard();
inline void SetHasPosesInClipboard(bool hasPoses); inline void SetHasPosesInClipboard(bool hasPoses);
void SetPosesClipboardMode(uint32 clipboardMode); void SetPosesClipboardMode(uint32 clipboardMode);
void UpdatePosesClipboardModeFromClipboard(BMessage* clipboardReport = NULL); void UpdatePosesClipboardModeFromClipboard(
BMessage* clipboardReport = NULL);
// filtering // filtering
void SetRefFilter(BRefFilter*); void SetRefFilter(BRefFilter*);
@@ -353,21 +364,25 @@ class BPoseView : public BView {
// drag&drop handling // drag&drop handling
virtual bool HandleMessageDropped(BMessage*); virtual bool HandleMessageDropped(BMessage*);
static bool HandleDropCommon(BMessage* dragMessage, Model* target, BPose*, static bool HandleDropCommon(BMessage* dragMessage, Model* target,
BView* view, BPoint dropPt); BPose*, BView* view, BPoint dropPt);
// used by pose views and info windows // used by pose views and info windows
static bool CanHandleDragSelection(const Model* target, static bool CanHandleDragSelection(const Model* target,
const BMessage* dragMessage, bool ignoreTypes); const BMessage* dragMessage, bool ignoreTypes);
virtual void DragSelectedPoses(const BPose* clickedPose, BPoint); virtual void DragSelectedPoses(const BPose* clickedPose, BPoint);
void MoveSelectionInto(Model* destFolder, BContainerWindow* srcWindow, void MoveSelectionInto(Model* destFolder, BContainerWindow* srcWindow,
bool forceCopy, bool forceMove = false, bool createLink = false, bool relativeLink = false); bool forceCopy, bool forceMove = false, bool createLink = false,
static void MoveSelectionInto(Model* destFolder, BContainerWindow* srcWindow, bool relativeLink = false);
BContainerWindow* destWindow, uint32 buttons, BPoint loc, static void MoveSelectionInto(Model* destFolder,
bool forceCopy, bool forceMove = false, bool createLink = false, bool relativeLink = false, BContainerWindow* srcWindow, BContainerWindow* destWindow,
BPoint clickPt = BPoint(0, 0), bool pinToGrid = false); uint32 buttons, BPoint loc, bool forceCopy,
bool forceMove = false, bool createLink = false,
bool relativeLink = false, BPoint clickPt = BPoint(0, 0),
bool pinToGrid = false);
bool UpdateDropTarget(BPoint, const BMessage*, bool trackingContextMenu); bool UpdateDropTarget(BPoint, const BMessage*,
bool trackingContextMenu);
// return true if drop target changed // return true if drop target changed
void HiliteDropTarget(bool hiliteState); void HiliteDropTarget(bool hiliteState);
@@ -390,7 +405,8 @@ class BPoseView : public BView {
// easy to have the right StringWidth picked up by // easy to have the right StringWidth picked up by
// template instantiation, as used by WidgetAttributeText // template instantiation, as used by WidgetAttributeText
// show/hide barberpole while a background task is filling up the view, etc. // show/hide barberpole while a background task is filling
// up the view, etc.
void ShowBarberPole(); void ShowBarberPole();
void HideBarberPole(); void HideBarberPole();
@@ -423,7 +439,8 @@ class BPoseView : public BView {
// create a new folder, optionally specify a location // create a new folder, optionally specify a location
void NewFileFromTemplate(const BMessage*); void NewFileFromTemplate(const BMessage*);
// create a new file based on a template, optionally specify a location // create a new file based on a template, optionally specify
// a location
void ShowContextMenu(BPoint); void ShowContextMenu(BPoint);
@@ -434,7 +451,8 @@ class BPoseView : public BView {
bool GetProperty(BMessage*, int32, const char*, BMessage*); bool GetProperty(BMessage*, int32, const char*, BMessage*);
bool CreateProperty(BMessage* message, BMessage* specifier, int32, bool CreateProperty(BMessage* message, BMessage* specifier, int32,
const char*, BMessage* reply); const char*, BMessage* reply);
bool ExecuteProperty(BMessage* specifier, int32, const char*, BMessage* reply); bool ExecuteProperty(BMessage* specifier, int32, const char*,
BMessage* reply);
bool CountProperty(BMessage*, int32, const char*, BMessage*); bool CountProperty(BMessage*, int32, const char*, BMessage*);
bool DeleteProperty(BMessage*, int32, const char*, BMessage*); bool DeleteProperty(BMessage*, int32, const char*, BMessage*);
@@ -448,16 +466,18 @@ class BPoseView : public BView {
void _CheckPoseSortOrder(PoseList* list, BPose*, int32 index); void _CheckPoseSortOrder(PoseList* list, BPose*, int32 index);
// pose creation // pose creation
BPose* EntryCreated(const node_ref*, const node_ref*, const char*, int32* index = 0); BPose* EntryCreated(const node_ref*, const node_ref*, const char*,
int32* index = 0);
void AddPoseToList(PoseList* list, bool visibleList, bool insertionSort, void AddPoseToList(PoseList* list, bool visibleList,
BPose* pose, BRect&viewBounds, float&listViewScrollBy, bool insertionSort, BPose* pose, BRect&viewBounds,
bool forceDraw, int32* indexPtr = NULL); float& listViewScrollBy, bool forceDraw, int32* indexPtr = NULL);
BPose* CreatePose(Model*, PoseInfo*, bool insertionSort = true, BPose* CreatePose(Model*, PoseInfo*, bool insertionSort = true,
int32* index = 0, BRect* boundsPtr = 0, bool forceDraw = true); int32* index = 0, BRect* boundsPtr = 0, bool forceDraw = true);
virtual void CreatePoses(Model**models, PoseInfo* poseInfoArray, int32 count, virtual void CreatePoses(Model**models, PoseInfo* poseInfoArray,
BPose**resultingPoses, bool insertionSort = true, int32* lastPoseIndexPtr = 0, int32 count, BPose** resultingPoses, bool insertionSort = true,
BRect* boundsPtr = 0, bool forceDraw = false); int32* lastPoseIndexPtr = 0, BRect* boundsPtr = 0,
bool forceDraw = false);
virtual bool ShouldShowPose(const Model*, const PoseInfo*); virtual bool ShouldShowPose(const Model*, const PoseInfo*);
// filter, subclasses override to control which poses show up // filter, subclasses override to control which poses show up
// subclasses should always call inherited // subclasses should always call inherited
@@ -468,28 +488,29 @@ class BPoseView : public BView {
virtual bool AddPosesThreadValid(const entry_ref*) const; virtual bool AddPosesThreadValid(const entry_ref*) const;
// verifies whether or not the current set of AddPoses threads // verifies whether or not the current set of AddPoses threads
// are valid and allowed to be adding poses -- returns false // are valid and allowed to be adding poses -- returns false
// in the case where the directory has been switched while populating // in the case where the directory has been switched while
// the view // populating the view
virtual void AddPoses(Model* model = NULL); virtual void AddPoses(Model* model = NULL);
// if <model> is zero, PoseView has other means of iterating through all // if <model> is zero, PoseView has other means of iterating
// the entries thaat it adds // through all the entries thaat it adds
virtual void AddRootPoses(bool watchIndividually, bool mountShared); virtual void AddRootPoses(bool watchIndividually, bool mountShared);
// watchIndividually is used when placing a volume pose onto the Desktop // watchIndividually is used when placing a volume pose onto
// where unlike in the Root window it will not be watched by the folder // the Desktop where unlike in the Root window it will not be
// representing root. If set, each volume will therefore be watched // watched by the folder representing root. If set, each volume
// individually // will therefore be watched individually
virtual void RemoveRootPoses(); virtual void RemoveRootPoses();
virtual void AddTrashPoses(); virtual void AddTrashPoses();
virtual bool DeletePose(const node_ref*, BPose* pose = NULL, int32 index = 0); virtual bool DeletePose(const node_ref*, BPose* pose = NULL,
virtual void DeleteSymLinkPoseTarget(const node_ref* itemNode, BPose* pose, int32 index = 0);
int32 index); virtual void DeleteSymLinkPoseTarget(const node_ref* itemNode,
BPose* pose, int32 index);
// the pose itself wasn't deleted but it's target node was - the // the pose itself wasn't deleted but it's target node was - the
// pose must be a symlink // pose must be a symlink
static void PoseHandleDeviceUnmounted(BPose* pose, Model* model, int32 index, static void PoseHandleDeviceUnmounted(BPose* pose, Model* model,
BPoseView* poseView, dev_t device); int32 index, BPoseView* poseView, dev_t device);
static void RemoveNonBootDesktopModels(BPose*, Model* model, int32, static void RemoveNonBootDesktopModels(BPose*, Model* model, int32,
BPoseView* poseView, dev_t); BPoseView* poseView, dev_t);
@@ -497,7 +518,8 @@ class BPoseView : public BView {
void CheckAutoPlacedPoses(); void CheckAutoPlacedPoses();
// find poses that need placing and place them in a new spot // find poses that need placing and place them in a new spot
void PlacePose(BPose*, BRect&); void PlacePose(BPose*, BRect&);
// find a new place for a pose, starting at fHintLocation and place it // find a new place for a pose, starting at fHintLocation
// and place it
bool IsValidLocation(const BPose* pose); bool IsValidLocation(const BPose* pose);
bool IsValidLocation(const BRect& rect); bool IsValidLocation(const BRect& rect);
status_t GetDeskbarFrame(BRect* frame); status_t GetDeskbarFrame(BRect* frame);
@@ -539,14 +561,15 @@ class BPoseView : public BView {
virtual void StopWatching(); virtual void StopWatching();
status_t WatchNewNode(const node_ref* item); status_t WatchNewNode(const node_ref* item);
// the above would ideally be the only call of these three and it would // the above would ideally be the only call of these three and
// be a virtual, overriding the specific watch mask in query pose view, etc. // it would be a virtual, overriding the specific watch mask in
// however we need to call WatchNewNode from inside AddPosesTask while // query pose view, etc. however we need to call WatchNewNode
// the window is unlocked - we have to use the static and a cached // from inside AddPosesTask while the window is unlocked - we
// messenger and masks. // have to use the static and a cached messenger and masks.
static status_t WatchNewNode(const node_ref*, uint32, BMessenger); static status_t WatchNewNode(const node_ref*, uint32, BMessenger);
virtual uint32 WatchNewNodeMask(); virtual uint32 WatchNewNodeMask();
// override to change different watch modes for query pose view, etc. // override to change different watch modes for query pose
// view, etc.
// drag&drop handling // drag&drop handling
static bool EachItemInDraggedSelection(const BMessage* message, static bool EachItemInDraggedSelection(const BMessage* message,
@@ -556,21 +579,25 @@ class BPoseView : public BView {
// window of the current drag message; locks the window // window of the current drag message; locks the window
// add const version // add const version
BRect GetDragRect(int32 clickedPoseIndex); BRect GetDragRect(int32 clickedPoseIndex);
BBitmap* MakeDragBitmap(BRect dragRect, BPoint clickedPoint, int32 clickedPoseIndex, BPoint&offset); BBitmap* MakeDragBitmap(BRect dragRect, BPoint clickedPoint,
static bool FindDragNDropAction(const BMessage* dragMessage, bool&canCopy, int32 clickedPoseIndex, BPoint&offset);
bool&canMove, bool&canLink, bool&canErase); static bool FindDragNDropAction(const BMessage* dragMessage,
bool&canCopy, bool&canMove, bool&canLink, bool&canErase);
static bool CanTrashForeignDrag(const Model*); static bool CanTrashForeignDrag(const Model*);
static bool CanCopyOrMoveForeignDrag(const Model*, const BMessage*); static bool CanCopyOrMoveForeignDrag(const Model*, const BMessage*);
static bool DragSelectionContains(const BPose* target, const BMessage* dragMessage); static bool DragSelectionContains(const BPose* target,
const BMessage* dragMessage);
static status_t CreateClippingFile(BPoseView* poseView, BFile&result, static status_t CreateClippingFile(BPoseView* poseView, BFile&result,
char* resultingName, BDirectory* dir, BMessage* message, const char* fallbackName, char* resultingName, BDirectory* dir, BMessage* message,
bool setLocation = false, BPoint dropPoint = BPoint(0, 0)); const char* fallbackName, bool setLocation = false,
BPoint dropPoint = BPoint(0, 0));
// opening files, lanunching // opening files, lanunching
void OpenSelectionCommon(BPose*, int32*, bool); void OpenSelectionCommon(BPose*, int32*, bool);
// used by OpenSelection and OpenSelectionUsing // used by OpenSelection and OpenSelectionUsing
static void LaunchAppWithSelection(Model*, const BMessage*, bool checkTypes = true); static void LaunchAppWithSelection(Model*, const BMessage*,
bool checkTypes = true);
// node monitoring calls // node monitoring calls
virtual bool EntryMoved(const BMessage*); virtual bool EntryMoved(const BMessage*);
@@ -585,7 +612,8 @@ class BPoseView : public BView {
// selection // selection
void SelectPosesListMode(BRect, BList**); void SelectPosesListMode(BRect, BList**);
void SelectPosesIconMode(BRect, BList**); void SelectPosesIconMode(BRect, BList**);
void AddRemoveSelectionRange(BPoint where, bool extendSelection, BPose*); void AddRemoveSelectionRange(BPoint where, bool extendSelection,
BPose*);
void _BeginSelectionRect(const BPoint& point, bool extendSelection); void _BeginSelectionRect(const BPoint& point, bool extendSelection);
void _UpdateSelectionRect(const BPoint& point); void _UpdateSelectionRect(const BPoint& point);
@@ -637,10 +665,11 @@ class BPoseView : public BView {
PoseList* CurrentPoseList() const; PoseList* CurrentPoseList() const;
// misc // misc
BList* GetDropPointList(BPoint dropPoint, BPoint startPoint, const PoseList*, BList* GetDropPointList(BPoint dropPoint, BPoint startPoint,
bool sourceInListMode, bool dropOnGrid) const; const PoseList*, bool sourceInListMode, bool dropOnGrid) const;
void SendSelectionAsRefs(uint32 what, bool onlyQueries = false); void SendSelectionAsRefs(uint32 what, bool onlyQueries = false);
void MoveListToTrash(BObjectList<entry_ref>*, bool selectNext, bool deleteDirectly); void MoveListToTrash(BObjectList<entry_ref>*, bool selectNext,
bool deleteDirectly);
void Delete(BObjectList<entry_ref>*, bool selectNext, bool askUser); void Delete(BObjectList<entry_ref>*, bool selectNext, bool askUser);
void Delete(const entry_ref&ref, bool selectNext, bool askUser); void Delete(const entry_ref&ref, bool selectNext, bool askUser);
void RestoreItemsFromTrash(BObjectList<entry_ref>*, bool selectNext); void RestoreItemsFromTrash(BObjectList<entry_ref>*, bool selectNext);
@@ -779,226 +808,265 @@ class TPoseViewFilter : public BMessageFilter {
extern bool extern bool
ClearViewOriginOne(const char* name, uint32 type, off_t size, void* data, void* params); ClearViewOriginOne(const char* name, uint32 type, off_t size, void* data,
void* params);
// inlines follow // inlines follow
inline BContainerWindow* inline BContainerWindow*
BPoseView::ContainerWindow() const BPoseView::ContainerWindow() const
{ {
return dynamic_cast<BContainerWindow*>(Window()); return dynamic_cast<BContainerWindow*>(Window());
} }
inline Model* inline Model*
BPoseView::TargetModel() const BPoseView::TargetModel() const
{ {
return fModel; return fModel;
} }
inline float inline float
BPoseView::ListElemHeight() const BPoseView::ListElemHeight() const
{ {
return fListElemHeight; return fListElemHeight;
} }
inline float inline float
BPoseView::IconPoseHeight() const BPoseView::IconPoseHeight() const
{ {
return fIconPoseHeight; return fIconPoseHeight;
} }
inline uint32 inline uint32
BPoseView::IconSizeInt() const BPoseView::IconSizeInt() const
{ {
return fViewState->IconSize(); return fViewState->IconSize();
} }
inline icon_size inline icon_size
BPoseView::IconSize() const BPoseView::IconSize() const
{ {
return (icon_size)fViewState->IconSize(); return (icon_size)fViewState->IconSize();
} }
inline PoseList* inline PoseList*
BPoseView::SelectionList() const BPoseView::SelectionList() const
{ {
return fSelectionList; return fSelectionList;
} }
inline BObjectList<BString>* inline BObjectList<BString>*
BPoseView::MimeTypesInSelection() BPoseView::MimeTypesInSelection()
{ {
return&fMimeTypesInSelectionCache; return&fMimeTypesInSelectionCache;
} }
inline BHScrollBar* inline BHScrollBar*
BPoseView::HScrollBar() const BPoseView::HScrollBar() const
{ {
return fHScrollBar; return fHScrollBar;
} }
inline BScrollBar* inline BScrollBar*
BPoseView::VScrollBar() const BPoseView::VScrollBar() const
{ {
return fVScrollBar; return fVScrollBar;
} }
inline BCountView* inline BCountView*
BPoseView::CountView() const BPoseView::CountView() const
{ {
return fCountView; return fCountView;
} }
inline bool inline bool
BPoseView::StateNeedsSaving() BPoseView::StateNeedsSaving()
{ {
return fStateNeedsSaving || fViewState->StateNeedsSaving(); return fStateNeedsSaving || fViewState->StateNeedsSaving();
} }
inline uint32 inline uint32
BPoseView::ViewMode() const BPoseView::ViewMode() const
{ {
return fViewState->ViewMode(); return fViewState->ViewMode();
} }
inline font_height inline font_height
BPoseView::FontInfo() const BPoseView::FontInfo() const
{ {
return sFontInfo; return sFontInfo;
} }
inline float inline float
BPoseView::FontHeight() const BPoseView::FontHeight() const
{ {
return sFontHeight; return sFontHeight;
} }
inline BPose* inline BPose*
BPoseView::ActivePose() const BPoseView::ActivePose() const
{ {
return fActivePose; return fActivePose;
} }
inline void inline void
BPoseView::DisableSaveLocation() BPoseView::DisableSaveLocation()
{ {
fSavePoseLocations = false; fSavePoseLocations = false;
} }
inline bool inline bool
BPoseView::IsFilePanel() const BPoseView::IsFilePanel() const
{ {
return false; return false;
} }
inline bool inline bool
BPoseView::IsDesktopWindow() const BPoseView::IsDesktopWindow() const
{ {
return fIsDesktopWindow; return fIsDesktopWindow;
} }
inline bool inline bool
BPoseView::IsDesktopView() const BPoseView::IsDesktopView() const
{ {
return false; return false;
} }
inline uint32 inline uint32
BPoseView::PrimarySort() const BPoseView::PrimarySort() const
{ {
return fViewState->PrimarySort(); return fViewState->PrimarySort();
} }
inline uint32 inline uint32
BPoseView::PrimarySortType() const BPoseView::PrimarySortType() const
{ {
return fViewState->PrimarySortType(); return fViewState->PrimarySortType();
} }
inline uint32 inline uint32
BPoseView::SecondarySort() const BPoseView::SecondarySort() const
{ {
return fViewState->SecondarySort(); return fViewState->SecondarySort();
} }
inline uint32 inline uint32
BPoseView::SecondarySortType() const BPoseView::SecondarySortType() const
{ {
return fViewState->SecondarySortType(); return fViewState->SecondarySortType();
} }
inline bool inline bool
BPoseView::ReverseSort() const BPoseView::ReverseSort() const
{ {
return fViewState->ReverseSort(); return fViewState->ReverseSort();
} }
inline void inline void
BPoseView::SetShowHideSelection(bool on) BPoseView::SetShowHideSelection(bool on)
{ {
fShowHideSelection = on; fShowHideSelection = on;
} }
inline void inline void
BPoseView::SetIconMapping(bool on) BPoseView::SetIconMapping(bool on)
{ {
fOkToMapIcons = on; fOkToMapIcons = on;
} }
inline void inline void
BPoseView::AddToExtent(const BRect&rect) BPoseView::AddToExtent(const BRect&rect)
{ {
fExtent = fExtent | rect; fExtent = fExtent | rect;
} }
inline void inline void
BPoseView::ClearExtent() BPoseView::ClearExtent()
{ {
fExtent.Set(LONG_MAX, LONG_MAX, LONG_MIN, LONG_MIN); fExtent.Set(LONG_MAX, LONG_MAX, LONG_MIN, LONG_MIN);
} }
inline int32 inline int32
BPoseView::CountColumns() const BPoseView::CountColumns() const
{ {
return fColumnList->CountItems(); return fColumnList->CountItems();
} }
inline int32 inline int32
BPoseView::IndexOfColumn(const BColumn* column) const BPoseView::IndexOfColumn(const BColumn* column) const
{ {
return fColumnList->IndexOf(const_cast<BColumn*>(column)); return fColumnList->IndexOf(const_cast<BColumn*>(column));
} }
inline int32 inline int32
BPoseView::IndexOfPose(const BPose* pose) const BPoseView::IndexOfPose(const BPose* pose) const
{ {
return CurrentPoseList()->IndexOf(pose); return CurrentPoseList()->IndexOf(pose);
} }
inline BPose* inline BPose*
BPoseView::PoseAtIndex(int32 index) const BPoseView::PoseAtIndex(int32 index) const
{ {
return CurrentPoseList()->ItemAt(index); return CurrentPoseList()->ItemAt(index);
} }
inline BColumn* inline BColumn*
BPoseView::ColumnAt(int32 index) const BPoseView::ColumnAt(int32 index) const
{ {
return fColumnList->ItemAt(index); return fColumnList->ItemAt(index);
} }
inline BColumn* inline BColumn*
BPoseView::FirstColumn() const BPoseView::FirstColumn() const
{ {
return fColumnList->FirstItem(); return fColumnList->FirstItem();
} }
inline BColumn* inline BColumn*
BPoseView::LastColumn() const BPoseView::LastColumn() const
{ {
return fColumnList->LastItem(); return fColumnList->LastItem();
} }
inline int32 inline int32
BPoseView::CountItems() const BPoseView::CountItems() const
{ {
@@ -1012,90 +1080,105 @@ BPoseView::SetMultipleSelection(bool state)
fMultipleSelection = state; fMultipleSelection = state;
} }
inline void inline void
BPoseView::SetSelectionChangedHook(bool state) BPoseView::SetSelectionChangedHook(bool state)
{ {
fSelectionChangedHook = state; fSelectionChangedHook = state;
} }
inline void inline void
BPoseView::SetAutoScroll(bool state) BPoseView::SetAutoScroll(bool state)
{ {
fShouldAutoScroll = state; fShouldAutoScroll = state;
} }
inline void inline void
BPoseView::SetPoseEditing(bool state) BPoseView::SetPoseEditing(bool state)
{ {
fAllowPoseEditing = state; fAllowPoseEditing = state;
} }
inline void inline void
BPoseView::SetDragEnabled(bool state) BPoseView::SetDragEnabled(bool state)
{ {
fDragEnabled = state; fDragEnabled = state;
} }
inline void inline void
BPoseView::SetDropEnabled(bool state) BPoseView::SetDropEnabled(bool state)
{ {
fDropEnabled = state; fDropEnabled = state;
} }
inline void inline void
BPoseView::SetSelectionRectEnabled(bool state) BPoseView::SetSelectionRectEnabled(bool state)
{ {
fSelectionRectEnabled = state; fSelectionRectEnabled = state;
} }
inline void inline void
BPoseView::SetAlwaysAutoPlace(bool state) BPoseView::SetAlwaysAutoPlace(bool state)
{ {
fAlwaysAutoPlace = state; fAlwaysAutoPlace = state;
} }
inline void inline void
BPoseView::SetEnsurePosesVisible(bool state) BPoseView::SetEnsurePosesVisible(bool state)
{ {
fEnsurePosesVisible = state; fEnsurePosesVisible = state;
} }
inline void inline void
BPoseView::SetSelectionHandler(BLooper* looper) BPoseView::SetSelectionHandler(BLooper* looper)
{ {
fSelectionHandler = looper; fSelectionHandler = looper;
} }
inline void inline void
BPoseView::SetRefFilter(BRefFilter* filter) BPoseView::SetRefFilter(BRefFilter* filter)
{ {
fRefFilter = filter; fRefFilter = filter;
} }
inline BRefFilter* inline BRefFilter*
BPoseView::RefFilter() const BPoseView::RefFilter() const
{ {
return fRefFilter; return fRefFilter;
} }
inline void inline void
BHScrollBar::SetTitleView(BView* view) BHScrollBar::SetTitleView(BView* view)
{ {
fTitleView = view; fTitleView = view;
} }
inline BPose* inline BPose*
BPoseView::FindPose(const Model* model, int32* index) const BPoseView::FindPose(const Model* model, int32* index) const
{ {
return CurrentPoseList()->FindPose(model, index); return CurrentPoseList()->FindPose(model, index);
} }
inline BPose* inline BPose*
BPoseView::FindPose(const node_ref* node, int32* index) const BPoseView::FindPose(const node_ref* node, int32* index) const
{ {
return CurrentPoseList()->FindPose(node, index); return CurrentPoseList()->FindPose(node, index);
} }
inline BPose* inline BPose*
BPoseView::FindPose(const entry_ref* entry, int32* index) const BPoseView::FindPose(const entry_ref* entry, int32* index) const
{ {
+47 -33
View File
@@ -63,12 +63,12 @@ All rights reserved.
// and previous/next specifiers the current PoseView sort order is used. // and previous/next specifiers the current PoseView sort order is used.
// If PoseView is not in list view mode, the order in which poses are indexed // If PoseView is not in list view mode, the order in which poses are indexed
// is arbitrary. // is arbitrary.
// Both of these specifiers, but indices more so, are likely to be accurate only // Both of these specifiers, but indices more so, are likely to be accurate
// till a next change to the PoseView (a change may be adding, removing a pose, changing // only untill a next change to the PoseView (a change may be adding,
// an attribute or stat resulting in a sort ordering change, changing the sort ordering // removing a pose, changing an attribute or stat resulting in a sort ordering
// rule. When getting a selected item, there is no guarantee that the item will still // change, changing the sort ordering rule. When getting a selected item,
// be selected after the operation. The client must be able to deal with these // there is no guarantee that the item will still be selected after the
// inaccuracies. // operation. The client must be able to deal with these inaccuracies.
// Specifying an index/entry_ref that no longer exists will be handled well. // Specifying an index/entry_ref that no longer exists will be handled well.
#if 0 #if 0
@@ -128,7 +128,8 @@ const property_info kPosesPropertyList[] = {
}, },
{ kPropertyEntry, { kPropertyEntry,
{ B_GET_PROPERTY }, { B_GET_PROPERTY },
{ B_DIRECT_SPECIFIER, B_INDEX_SPECIFIER, kPreviousSpecifier, kNextSpecifier }, { B_DIRECT_SPECIFIER, B_INDEX_SPECIFIER, kPreviousSpecifier,
kNextSpecifier },
"get Entry [next|previous|index] # returns specified entries", "get Entry [next|previous|index] # returns specified entries",
0, 0,
{ B_REF_TYPE }, { B_REF_TYPE },
@@ -156,7 +157,8 @@ const property_info kPosesPropertyList[] = {
{ kPropertySelection, { kPropertySelection,
{ B_SET_PROPERTY }, { B_SET_PROPERTY },
{ B_DIRECT_SPECIFIER, kPreviousSpecifier, kNextSpecifier }, { B_DIRECT_SPECIFIER, kPreviousSpecifier, kNextSpecifier },
"set Selection of ... to {next|previous|entry} # selects specified entries", "set Selection of ... to {next|previous|entry} # selects specified "
"entries",
0, 0,
{}, {},
{}, {},
@@ -191,7 +193,7 @@ const property_info kPosesPropertyList[] = {
{}, {},
{} {}
}, },
{NULL, { NULL,
{}, {},
{}, {},
NULL, 0, NULL, 0,
@@ -209,7 +211,8 @@ BPoseView::GetSupportedSuites(BMessage* _SCRIPTING_ONLY(data))
{ {
#if _SUPPORTS_FEATURE_SCRIPTING #if _SUPPORTS_FEATURE_SCRIPTING
data->AddString("suites", kPosesSuites); data->AddString("suites", kPosesSuites);
BPropertyInfo propertyInfo(const_cast<property_info*>(kPosesPropertyList)); BPropertyInfo propertyInfo(
const_cast<property_info*>(kPosesPropertyList));
data->AddFlat("messages", &propertyInfo); data->AddFlat("messages", &propertyInfo);
return _inherited::GetSupportedSuites(data); return _inherited::GetSupportedSuites(data);
@@ -249,7 +252,8 @@ BPoseView::HandleScriptingMessage(BMessage* _SCRIPTING_ONLY(message))
switch (message->what) { switch (message->what) {
case B_CREATE_PROPERTY: case B_CREATE_PROPERTY:
handled = CreateProperty(message, &specifier, form, property, &reply); handled = CreateProperty(message, &specifier, form, property,
&reply);
break; break;
case B_GET_PROPERTY: case B_GET_PROPERTY:
@@ -257,7 +261,8 @@ BPoseView::HandleScriptingMessage(BMessage* _SCRIPTING_ONLY(message))
break; break;
case B_SET_PROPERTY: case B_SET_PROPERTY:
handled = SetProperty(message, &specifier, form, property, &reply); handled = SetProperty(message, &specifier, form, property,
&reply);
break; break;
case B_COUNT_PROPERTIES: case B_COUNT_PROPERTIES:
@@ -302,7 +307,6 @@ BPoseView::ExecuteProperty(BMessage* _SCRIPTING_ONLY(specifier),
for (int32 index = 0; specifier->FindRef("refs", index, &ref) for (int32 index = 0; specifier->FindRef("refs", index, &ref)
== B_OK; index++) == B_OK; index++)
launchMessage.AddRef("refs", &ref); launchMessage.AddRef("refs", &ref);
} else if (form == (int32)B_INDEX_SPECIFIER) { } else if (form == (int32)B_INDEX_SPECIFIER) {
// move all poses specified by index to Trash // move all poses specified by index to Trash
int32 specifyingIndex; int32 specifyingIndex;
@@ -323,7 +327,8 @@ BPoseView::ExecuteProperty(BMessage* _SCRIPTING_ONLY(specifier),
if (error == B_OK) { if (error == B_OK) {
// add a messenger to the launch message that will be used to // add a messenger to the launch message that will be used to
// dispatch scripting calls from apps to the PoseView // dispatch scripting calls from apps to the PoseView
launchMessage.AddMessenger("TrackerViewToken", BMessenger(this, 0, 0)); launchMessage.AddMessenger("TrackerViewToken",
BMessenger(this, 0, 0));
if (fSelectionHandler) if (fSelectionHandler)
fSelectionHandler->PostMessage(&launchMessage); fSelectionHandler->PostMessage(&launchMessage);
} }
@@ -413,8 +418,8 @@ BPoseView::DeleteProperty(BMessage* _SCRIPTING_ONLY(specifier),
bool handled = false; bool handled = false;
if (strcmp(property, kPropertySelection) == 0) { if (strcmp(property, kPropertySelection) == 0) {
// deleting on a selection is handled as removing a part of the selection // deleting on a selection is handled as removing a part of the
// not to be confused with deleting a selected item // selection not to be confused with deleting a selected item
if (form == (int32)B_ENTRY_SPECIFIER) { if (form == (int32)B_ENTRY_SPECIFIER) {
entry_ref ref; entry_ref ref;
@@ -469,8 +474,8 @@ BPoseView::DeleteProperty(BMessage* _SCRIPTING_ONLY(specifier),
} else if (form == (int32)B_INDEX_SPECIFIER) { } else if (form == (int32)B_INDEX_SPECIFIER) {
// move all poses specified by index to Trash // move all poses specified by index to Trash
int32 specifyingIndex; int32 specifyingIndex;
for (int32 index = 0; specifier->FindInt32("index", index, &specifyingIndex) for (int32 index = 0; specifier->FindInt32("index", index,
== B_OK; index++) { &specifyingIndex) == B_OK; index++) {
BPose* pose = PoseAtIndex(specifyingIndex); BPose* pose = PoseAtIndex(specifyingIndex);
if (!pose) { if (!pose) {
@@ -478,7 +483,8 @@ BPoseView::DeleteProperty(BMessage* _SCRIPTING_ONLY(specifier),
break; break;
} }
entryList->AddItem(new entry_ref(*pose->TargetModel()->EntryRef())); entryList->AddItem(
new entry_ref(*pose->TargetModel()->EntryRef()));
} }
} else } else
return false; return false;
@@ -486,8 +492,8 @@ BPoseView::DeleteProperty(BMessage* _SCRIPTING_ONLY(specifier),
if (error == B_OK) { if (error == B_OK) {
TrackerSettings settings; TrackerSettings settings;
if (!settings.DontMoveFilesToTrash()) { if (!settings.DontMoveFilesToTrash()) {
// move the list we build into trash, don't make the trashing task // move the list we build into trash, don't make the
// select the next item // trashing task select the next item
MoveListToTrash(entryList, false, false); MoveListToTrash(entryList, false, false);
} else } else
Delete(entryList, false, settings.AskBeforeDeleteFile()); Delete(entryList, false, settings.AskBeforeDeleteFile());
@@ -507,12 +513,13 @@ BPoseView::DeleteProperty(BMessage* _SCRIPTING_ONLY(specifier),
bool bool
BPoseView::CountProperty(BMessage*, int32, const char* _SCRIPTING_ONLY(property), BPoseView::CountProperty(BMessage*, int32,
const char* _SCRIPTING_ONLY(property),
BMessage* _SCRIPTING_ONLY(reply)) BMessage* _SCRIPTING_ONLY(reply))
{ {
#if _SUPPORTS_FEATURE_SCRIPTING #if _SUPPORTS_FEATURE_SCRIPTING
bool handled = false; bool handled = false;
// PRINT(("BPoseView::CountProperty, %s\n", property)); //PRINT(("BPoseView::CountProperty, %s\n", property));
// just return the respecitve counts // just return the respecitve counts
if (strcmp(property, kPropertySelection) == 0) { if (strcmp(property, kPropertySelection) == 0) {
@@ -583,7 +590,8 @@ BPoseView::GetProperty(BMessage* _SCRIPTING_ONLY(specifier),
} }
if (pose->IsSelected()) { if (pose->IsSelected()) {
reply->AddRef("result", pose->TargetModel()->EntryRef()); reply->AddRef("result",
pose->TargetModel()->EntryRef());
reply->AddInt32("index", IndexOfPose(pose)); reply->AddInt32("index", IndexOfPose(pose));
break; break;
} }
@@ -599,8 +607,10 @@ BPoseView::GetProperty(BMessage* _SCRIPTING_ONLY(specifier),
case B_DIRECT_SPECIFIER: case B_DIRECT_SPECIFIER:
{ {
// return all entries of all poses in PoseView // return all entries of all poses in PoseView
for (int32 index = 0; index < count; index++) for (int32 index = 0; index < count; index++) {
reply->AddRef("result", PoseAtIndex(index)->TargetModel()->EntryRef()); reply->AddRef("result",
PoseAtIndex(index)->TargetModel()->EntryRef());
}
handled = true; handled = true;
break; break;
@@ -618,7 +628,8 @@ BPoseView::GetProperty(BMessage* _SCRIPTING_ONLY(specifier),
handled = true; handled = true;
break; break;
} }
reply->AddRef("result", PoseAtIndex(index)->TargetModel()->EntryRef()); reply->AddRef("result",
PoseAtIndex(index)->TargetModel()->EntryRef());
handled = true; handled = true;
break; break;
@@ -627,7 +638,8 @@ BPoseView::GetProperty(BMessage* _SCRIPTING_ONLY(specifier),
case kPreviousSpecifier: case kPreviousSpecifier:
case kNextSpecifier: case kNextSpecifier:
{ {
// return entry and index of pose before or after specified pose // return entry and index of pose before or after
// specified pose
entry_ref ref; entry_ref ref;
if (specifier->FindRef("data", &ref) != B_OK) if (specifier->FindRef("data", &ref) != B_OK)
break; break;
@@ -711,8 +723,8 @@ BPoseView::SetProperty(BMessage* _SCRIPTING_ONLY(message), BMessage*,
} }
if (clearSelection) { if (clearSelection) {
// first selected item must call SelectPose so the selection // first selected item must call SelectPose so the
// gets cleared first // selection gets cleared first
SelectPose(pose, poseIndex); SelectPose(pose, poseIndex);
clearSelection = false; clearSelection = false;
} else } else
@@ -741,11 +753,13 @@ BPoseView::ResolveSpecifier(BMessage* _SCRIPTING_ONLY(message),
int32 _SCRIPTING_ONLY(form), const char* _SCRIPTING_ONLY(property)) int32 _SCRIPTING_ONLY(form), const char* _SCRIPTING_ONLY(property))
{ {
#if _SUPPORTS_FEATURE_SCRIPTING #if _SUPPORTS_FEATURE_SCRIPTING
BPropertyInfo propertyInfo(const_cast<property_info*>(kPosesPropertyList)); BPropertyInfo propertyInfo(
const_cast<property_info*>(kPosesPropertyList));
int32 result = propertyInfo.FindMatch(message, index, specifier, form, property); int32 result = propertyInfo.FindMatch(message, index, specifier, form,
property);
if (result < 0) { if (result < 0) {
// PRINT(("FindMatch result %d \n")); //PRINT(("FindMatch result %d \n"));
return _inherited::ResolveSpecifier(message, index, specifier, return _inherited::ResolveSpecifier(message, index, specifier,
form, property); form, property);
} }
+6 -3
View File
@@ -46,12 +46,15 @@ const uint32 kSaveButton = 'Tsav';
const uint32 kShowSplash = 'Spls'; const uint32 kShowSplash = 'Spls';
const uint32 kStartWatchClipboardRefs = 'TCbw'; const uint32 kStartWatchClipboardRefs = 'TCbw';
// StartWatching() clipboard changes. Changes will be sent to given BMessenger "target" // StartWatching() clipboard changes. Changes will be sent to given
// BMessenger "target"
const uint32 kStopWatchClipboardRefs = 'TCfw'; const uint32 kStopWatchClipboardRefs = 'TCfw';
// StopWatching() given BMessenger "target" // StopWatching() given BMessenger "target"
const uint32 kFSClipboardChanges = 'TCch'; const uint32 kFSClipboardChanges = 'TCch';
// Used by FSClipboard functions which change refs in clipboard and are used outside Tracker (like BFilePanel called in another app) // Used by FSClipboard functions which change refs in clipboard and are
// Contains movemodes named as in FSClipboard operations and in Clipboard (look into FSClipboard files) // used outside Tracker (like BFilePanel called in another app)
// Contains movemodes named as in FSClipboard operations and in Clipboard
// (look into FSClipboard files)
} // namespace BPrivate } // namespace BPrivate
+8 -6
View File
@@ -101,8 +101,8 @@ BQueryContainerWindow::AddWindowMenu(BMenu* menu)
item->SetTarget(PoseView()); item->SetTarget(PoseView());
menu->AddItem(item); menu->AddItem(item);
item = new BMenuItem(B_TRANSLATE("Select all"), new BMessage(B_SELECT_ALL), item = new BMenuItem(B_TRANSLATE("Select all"),
'A'); new BMessage(B_SELECT_ALL), 'A');
item->SetTarget(PoseView()); item->SetTarget(PoseView());
menu->AddItem(item); menu->AddItem(item);
@@ -111,8 +111,8 @@ BQueryContainerWindow::AddWindowMenu(BMenu* menu)
item->SetTarget(PoseView()); item->SetTarget(PoseView());
menu->AddItem(item); menu->AddItem(item);
item = new BMenuItem(B_TRANSLATE("Close"), new BMessage(B_QUIT_REQUESTED), item = new BMenuItem(B_TRANSLATE("Close"),
'W'); new BMessage(B_QUIT_REQUESTED), 'W');
item->SetTarget(this); item->SetTarget(this);
menu->AddItem(item); menu->AddItem(item);
} }
@@ -161,9 +161,11 @@ BQueryContainerWindow::SetUpDefaultState()
defaultStatePath += sanitizedType; defaultStatePath += sanitizedType;
PRINT(("looking for default query state at %s\n", defaultStatePath.String())); PRINT(("looking for default query state at %s\n",
defaultStatePath.String()));
if (!DefaultStateSourceNode(defaultStatePath.String(), &defaultingNode, false)) { if (!DefaultStateSourceNode(defaultStatePath.String(), &defaultingNode,
false)) {
TRACE(); TRACE();
return; return;
} }
+37 -24
View File
@@ -261,7 +261,8 @@ BQueryPoseView::InitDirentIterator(const entry_ref* ref)
oldPoseList->AddList(fPoseList); oldPoseList->AddList(fPoseList);
} }
fQueryListContainer = new QueryEntryListCollection(&sourceModel, this, oldPoseList); fQueryListContainer = new QueryEntryListCollection(&sourceModel, this,
oldPoseList);
fCreateOldPoseList = false; fCreateOldPoseList = false;
if (fQueryListContainer->InitCheck() != B_OK) { if (fQueryListContainer->InitCheck() != B_OK) {
@@ -298,8 +299,8 @@ BQueryPoseView::InitDirentIterator(const entry_ref* ref)
timeData.tm_min = 0; timeData.tm_min = 0;
nextHour = mktime(&timeData); nextHour = mktime(&timeData);
PRINT(("%ld minutes, %ld seconds till next hour\n", (nextHour - now) / 60, PRINT(("%ld minutes, %ld seconds till next hour\n",
(nextHour - now) % 60)); (nextHour - now) / 60, (nextHour - now) % 60));
time_t nextMinute = now + 60; time_t nextMinute = now + 60;
// move ahead by a minute // move ahead by a minute
@@ -342,7 +343,8 @@ BQueryPoseView::InitDirentIterator(const entry_ref* ref)
TTracker* tracker = dynamic_cast<TTracker*>(be_app); TTracker* tracker = dynamic_cast<TTracker*>(be_app);
ASSERT(tracker); ASSERT(tracker);
tracker->MainTaskLoop()->RunLater( tracker->MainTaskLoop()->RunLater(
NewLockingMemberFunctionObject(&BQueryPoseView::Refresh, this), delta); NewLockingMemberFunctionObject(&BQueryPoseView::Refresh, this),
delta);
} }
return fQueryListContainer->Clone(); return fQueryListContainer->Clone();
@@ -365,14 +367,19 @@ BQueryPoseView::SearchForType() const
attr_info attrInfo; attr_info attrInfo;
// read the type of files we are looking for // read the type of files we are looking for
status_t status = TargetModel()->Node()->GetAttrInfo(kAttrQueryInitialMime, &attrInfo); status_t status
if (status == B_OK) = TargetModel()->Node()->GetAttrInfo(kAttrQueryInitialMime,
TargetModel()->Node()->ReadAttrString(kAttrQueryInitialMime, &buffer); &attrInfo);
if (status == B_OK) {
TargetModel()->Node()->ReadAttrString(kAttrQueryInitialMime,
&buffer);
}
if (buffer.Length()) { if (buffer.Length()) {
TTracker* tracker = dynamic_cast<TTracker*>(be_app); TTracker* tracker = dynamic_cast<TTracker*>(be_app);
if (tracker) { if (tracker) {
const ShortMimeInfo* info = tracker->MimeTypes()->FindMimeType(buffer.String()); const ShortMimeInfo* info
= tracker->MimeTypes()->FindMimeType(buffer.String());
if (info) if (info)
fSearchForMimeType = info->InternalName(); fSearchForMimeType = info->InternalName();
} }
@@ -401,8 +408,8 @@ BQueryPoseView::ActiveOnDevice(dev_t device) const
// #pragma mark - // #pragma mark -
QueryEntryListCollection::QueryEntryListCollection(Model* model, BHandler* target, QueryEntryListCollection::QueryEntryListCollection(Model* model,
PoseList* oldPoseList) BHandler* target, PoseList* oldPoseList)
: fQueryListRep(new QueryListRep(new BObjectList<BQuery>(5, true))) : fQueryListRep(new QueryListRep(new BObjectList<BQuery>(5, true)))
{ {
Rewind(); Rewind();
@@ -421,7 +428,8 @@ QueryEntryListCollection::QueryEntryListCollection(Model* model, BHandler* targe
BString buffer; BString buffer;
if (model->Node()->ReadAttr(kAttrQueryString, B_STRING_TYPE, 0, if (model->Node()->ReadAttr(kAttrQueryString, B_STRING_TYPE, 0,
buffer.LockBuffer((int32)info.size), (size_t)info.size) != info.size) { buffer.LockBuffer((int32)info.size),
(size_t)info.size) != info.size) {
fStatus = B_ERROR; fStatus = B_ERROR;
return; return;
} }
@@ -430,8 +438,9 @@ QueryEntryListCollection::QueryEntryListCollection(Model* model, BHandler* targe
// read the extra options // read the extra options
MoreOptionsStruct saveMoreOptions; MoreOptionsStruct saveMoreOptions;
if (ReadAttr(model->Node(), kAttrQueryMoreOptions, kAttrQueryMoreOptionsForeign, if (ReadAttr(model->Node(), kAttrQueryMoreOptions,
B_RAW_TYPE, 0, &saveMoreOptions, sizeof(MoreOptionsStruct), kAttrQueryMoreOptionsForeign, B_RAW_TYPE, 0, &saveMoreOptions,
sizeof(MoreOptionsStruct),
&MoreOptionsStruct::EndianSwap) != kReadAttrFailed) { &MoreOptionsStruct::EndianSwap) != kReadAttrFailed) {
fQueryListRep->fShowResultsFromTrash = saveMoreOptions.searchTrash; fQueryListRep->fShowResultsFromTrash = saveMoreOptions.searchTrash;
} }
@@ -445,7 +454,8 @@ QueryEntryListCollection::QueryEntryListCollection(Model* model, BHandler* targe
fQueryListRep->fRefreshEveryMinute = false; fQueryListRep->fRefreshEveryMinute = false;
if (model->Node()->ReadAttr(kAttrDynamicDateQuery, B_BOOL_TYPE, 0, if (model->Node()->ReadAttr(kAttrDynamicDateQuery, B_BOOL_TYPE, 0,
&fQueryListRep->fDynamicDateQuery, sizeof(bool)) != sizeof(bool)) { &fQueryListRep->fDynamicDateQuery,
sizeof(bool)) != sizeof(bool)) {
fQueryListRep->fDynamicDateQuery = false; fQueryListRep->fDynamicDateQuery = false;
} }
@@ -473,15 +483,16 @@ QueryEntryListCollection::QueryEntryListCollection(Model* model, BHandler* targe
char* buffer = NULL; char* buffer = NULL;
if ((buffer = (char*)malloc((size_t)info.size)) != NULL if ((buffer = (char*)malloc((size_t)info.size)) != NULL
&& model->Node()->ReadAttr(kAttrQueryVolume, B_MESSAGE_TYPE, 0, buffer, && model->Node()->ReadAttr(kAttrQueryVolume, B_MESSAGE_TYPE, 0,
(size_t)info.size) == info.size) { buffer, (size_t)info.size) == info.size) {
BMessage message; BMessage message;
if (message.Unflatten(buffer) == B_OK) { if (message.Unflatten(buffer) == B_OK) {
for (int32 index = 0; ;index++) { for (int32 index = 0; ;index++) {
ASSERT(index < 100); ASSERT(index < 100);
BVolume volume; BVolume volume;
// match a volume with the info embedded in the message // match a volume with the info embedded in
// the message
result = MatchArchivedVolume(&volume, &message, index); result = MatchArchivedVolume(&volume, &message, index);
if (result == B_OK) { if (result == B_OK) {
// start the query on this volume // start the query on this volume
@@ -492,8 +503,8 @@ QueryEntryListCollection::QueryEntryListCollection(Model* model, BHandler* targe
searchAllVolumes = false; searchAllVolumes = false;
} else if (result != B_DEV_BAD_DRIVE_NUM) { } else if (result != B_DEV_BAD_DRIVE_NUM) {
// if B_DEV_BAD_DRIVE_NUM, the volume just isn't mounted this // if B_DEV_BAD_DRIVE_NUM, the volume just isn't
// time around, keep looking for more // mounted this time around, keep looking for more
// if other error, bail // if other error, bail
break; break;
} }
@@ -594,7 +605,8 @@ QueryEntryListCollection::GetNextEntry(BEntry* entry, bool traverse)
for (int32 count = fQueryListRep->fQueryList->CountItems(); for (int32 count = fQueryListRep->fQueryList->CountItems();
fQueryListRep->fQueryListIndex < count; fQueryListRep->fQueryListIndex < count;
fQueryListRep->fQueryListIndex++) { fQueryListRep->fQueryListIndex++) {
result = fQueryListRep->fQueryList->ItemAt(fQueryListRep->fQueryListIndex) result = fQueryListRep->fQueryList->
ItemAt(fQueryListRep->fQueryListIndex)
->GetNextEntry(entry, traverse); ->GetNextEntry(entry, traverse);
if (result == B_OK) if (result == B_OK)
break; break;
@@ -613,8 +625,9 @@ QueryEntryListCollection::GetNextDirents(struct dirent* buffer, size_t length,
fQueryListRep->fQueryListIndex < queryCount; fQueryListRep->fQueryListIndex < queryCount;
fQueryListRep->fQueryListIndex++) { fQueryListRep->fQueryListIndex++) {
result = fQueryListRep->fQueryList->ItemAt(fQueryListRep->fQueryListIndex) result = fQueryListRep->fQueryList->
->GetNextDirents(buffer, length, count); ItemAt(fQueryListRep->fQueryListIndex)->GetNextDirents(buffer,
length, count);
if (result > 0) if (result > 0)
break; break;
} }
@@ -631,8 +644,8 @@ QueryEntryListCollection::GetNextRef(entry_ref* ref)
fQueryListRep->fQueryListIndex < count; fQueryListRep->fQueryListIndex < count;
fQueryListRep->fQueryListIndex++) { fQueryListRep->fQueryListIndex++) {
result = fQueryListRep->fQueryList->ItemAt(fQueryListRep->fQueryListIndex) result = fQueryListRep->fQueryList->
->GetNextRef(ref); ItemAt(fQueryListRep->fQueryListIndex)->GetNextRef(ref);
if (result == B_OK) if (result == B_OK)
break; break;
} }
+4 -2
View File
@@ -137,11 +137,13 @@ class QueryEntryListCollection : public EntryListBase {
PoseList* fOldPoseList; PoseList* fOldPoseList;
// when doing a Refresh, this list is used to detect poses that // when doing a Refresh, this list is used to detect poses that
// are no longer a part of a fDynamicDateQuery and need to be removed // are no longer a part of a fDynamicDateQuery and need to be
// removed
}; };
public: public:
QueryEntryListCollection(Model*, BHandler* = NULL, PoseList* oldPoseList = NULL); QueryEntryListCollection(Model*, BHandler* = NULL,
PoseList* oldPoseList = NULL);
virtual ~QueryEntryListCollection(); virtual ~QueryEntryListCollection();
QueryEntryListCollection* Clone(); QueryEntryListCollection* Clone();
+7 -4
View File
@@ -363,7 +363,8 @@ BRecentFilesList::BRecentFilesList(int32 maxItems, bool navMenuFolders,
BRecentFilesList::BRecentFilesList(int32 maxItems, bool navMenuFolders, BRecentFilesList::BRecentFilesList(int32 maxItems, bool navMenuFolders,
const char* ofTypeList[], int32 ofTypeListCount, const char* openedByAppSig) const char* ofTypeList[], int32 ofTypeListCount,
const char* openedByAppSig)
: :
BRecentItemsList(maxItems, navMenuFolders), BRecentItemsList(maxItems, navMenuFolders),
fType(NULL), fType(NULL),
@@ -415,15 +416,17 @@ BRecentFilesList::NewFileListMenu(const char* title,
const char* openedByAppSig) const char* openedByAppSig)
{ {
return new RecentFilesMenu(title, openFileMessage, return new RecentFilesMenu(title, openFileMessage,
openFolderMessage, target, maxItems, navMenuFolders, ofType, openedByAppSig); openFolderMessage, target, maxItems, navMenuFolders, ofType,
openedByAppSig);
} }
BMenu* BMenu*
BRecentFilesList::NewFileListMenu(const char* title, BRecentFilesList::NewFileListMenu(const char* title,
BMessage* openFileMessage, BMessage* openFolderMessage, BMessage* openFileMessage, BMessage* openFolderMessage,
BHandler* target, int32 maxItems, bool navMenuFolders, const char* ofTypeList[], BHandler* target, int32 maxItems, bool navMenuFolders,
int32 ofTypeListCount, const char* openedByAppSig) const char* ofTypeList[], int32 ofTypeListCount,
const char* openedByAppSig)
{ {
return new RecentFilesMenu(title, openFileMessage, return new RecentFilesMenu(title, openFileMessage,
openFolderMessage, target, maxItems, navMenuFolders, ofTypeList, openFolderMessage, target, maxItems, navMenuFolders, ofTypeList,
+8 -7
View File
@@ -63,12 +63,12 @@ public:
virtual BMenuItem* GetNextMenuItem(const BMessage* fileOpenMessage = NULL, virtual BMenuItem* GetNextMenuItem(const BMessage* fileOpenMessage = NULL,
const BMessage* containerOpenMessage = NULL, const BMessage* containerOpenMessage = NULL,
BHandler* target = NULL, entry_ref* currentItemRef = NULL); BHandler* target = NULL, entry_ref* currentItemRef = NULL);
// if <fileOpenMessage> specified, the item for a file gets a copy with // if <fileOpenMessage> specified, the item for a file gets a copy
// the item ref attached as "refs", otherwise a default B_REFS_RECEIVED // with the item ref attached as "refs", otherwise a default
// message message gets attached
// if <containerOpenMessage> specified, the item for a folder, volume or query
// gets a copy with the item ref attached as "refs", otherwise a default
// B_REFS_RECEIVED message message gets attached // B_REFS_RECEIVED message message gets attached
// if <containerOpenMessage> specified, the item for a folder, volume
// or query gets a copy with the item ref attached as "refs",
// otherwise a default B_REFS_RECEIVED message message gets attached
// if <currentItemRef> gets passed, the caller gets to look at the // if <currentItemRef> gets passed, the caller gets to look at the
// entry_ref corresponding to the item // entry_ref corresponding to the item
@@ -101,8 +101,9 @@ public:
// use one of the two constructors to set up next item iteration // use one of the two constructors to set up next item iteration
BRecentFilesList(int32 maxItems = 10, bool navMenuFolders = false, BRecentFilesList(int32 maxItems = 10, bool navMenuFolders = false,
const char* ofType = NULL, const char* openedByAppSig = NULL); const char* ofType = NULL, const char* openedByAppSig = NULL);
BRecentFilesList(int32 maxItems, bool navMenuFolders, const char* ofTypeList[], BRecentFilesList(int32 maxItems, bool navMenuFolders,
int32 ofTypeListCount, const char* openedByAppSig = NULL); const char* ofTypeList[], int32 ofTypeListCount,
const char* openedByAppSig = NULL);
virtual ~BRecentFilesList(); virtual ~BRecentFilesList();
// use one of the two NewFileListMenu calls to get an entire menu // use one of the two NewFileListMenu calls to get an entire menu
+43 -31
View File
@@ -91,8 +91,8 @@ const uint8 kRegExpMagic = 0234;
// that Compile() supplies a regmust only if the r.e. contains something // that Compile() supplies a regmust only if the r.e. contains something
// potentially expensive (at present, the only such thing detected is * or + // potentially expensive (at present, the only such thing detected is * or +
// at the start of the r.e., which can involve a lot of backup). Regmlen is // at the start of the r.e., which can involve a lot of backup). Regmlen is
// supplied because the test in RunMatcher() needs it and Compile() is computing // supplied because the test in RunMatcher() needs it and Compile() is
// it anyway. // computing it anyway.
// //
// //
// //
@@ -100,15 +100,16 @@ const uint8 kRegExpMagic = 0234;
// of a nondeterministic finite-state machine (aka syntax charts or // of a nondeterministic finite-state machine (aka syntax charts or
// "railroad normal form" in parsing technology). Each node is an opcode // "railroad normal form" in parsing technology). Each node is an opcode
// plus a "next" pointer, possibly plus an operand. "Next" pointers of // plus a "next" pointer, possibly plus an operand. "Next" pointers of
// all nodes except kRegExpBranch implement concatenation; a "next" pointer with // all nodes except kRegExpBranch implement concatenation; a "next" pointer
// a kRegExpBranch on both ends of it is connecting two alternatives. (Here we // with a kRegExpBranch on both ends of it is connecting two alternatives.
// have one of the subtle syntax dependencies: an individual kRegExpBranch (as // (Here we have one of the subtle syntax dependencies: an individual
// opposed to a collection of them) is never concatenated with anything // kRegExpBranch (as opposed to a collection of them) is never concatenated
// because of operator precedence.) The operand of some types of node is // with anything because of operator precedence.) The operand of some types
// a literal string; for others, it is a node leading into a sub-FSM. In // of node is a literal string; for others, it is a node leading into a
// particular, the operand of a kRegExpBranch node is the first node of the branch. // sub-FSM. In particular, the operand of a kRegExpBranch node is the first
// (NB this is* not* a tree structure: the tail of the branch connects // node of the branch. (NB this is* not* a tree structure: the tail of the
// to the thing following the set of kRegExpBranches.) The opcodes are: // branch connects to the thing following the set of kRegExpBranches).
// The opcodes are:
// //
// definition number opnd? meaning // definition number opnd? meaning
@@ -133,21 +134,21 @@ enum {
// //
// Opcode notes: // Opcode notes:
// //
// kRegExpBranch The set of branches constituting a single choice are hooked // kRegExpBranch The set of branches constituting a single choice are
// together with their "next" pointers, since precedence prevents // hooked together with their "next" pointers, since precedence prevents
// anything being concatenated to any individual branch. The // anything being concatenated to any individual branch. The
// "next" pointer of the last kRegExpBranch in a choice points to the // "next" pointer of the last kRegExpBranch in a choice points to the
// thing following the whole choice. This is also where the // thing following the whole choice. This is also where the
// final "next" pointer of each individual branch points; each // final "next" pointer of each individual branch points; each
// branch starts with the operand node of a kRegExpBranch node. // branch starts with the operand node of a kRegExpBranch node.
// //
// kRegExpBack Normal "next" pointers all implicitly point forward; kRegExpBack // kRegExpBack Normal "next" pointers all implicitly point forward;
// exists to make loop structures possible. // kRegExpBack exists to make loop structures possible.
// //
// kRegExpStar,kRegExpPlus '?', and complex '*' and '+', are implemented as circular // kRegExpStar,kRegExpPlus '?', and complex '*' and '+', are implemented as
// kRegExpBranch structures using kRegExpBack. Simple cases (one character // circular kRegExpBranch structures using kRegExpBack. Simple cases
// per match) are implemented with kRegExpStar and kRegExpPlus for speed // (one character per match) are implemented with kRegExpStar and
// and to minimize recursive plunges. // kRegExpPlus for speed and to minimize recursive plunges.
// //
// kRegExpOpen,kRegExpClose ...are numbered at compile time. // kRegExpOpen,kRegExpClose ...are numbered at compile time.
// //
@@ -164,7 +165,8 @@ enum {
// //
const char* kMeta = "^$.[()|?+*\\"; const char* kMeta = "^$.[()|?+*\\";
const int32 kMaxSize = 32767L; // Probably could be 65535L. const int32 kMaxSize = 32767L;
// Probably could be 65535L.
// Flags to be passed up and down: // Flags to be passed up and down:
enum { enum {
@@ -360,7 +362,8 @@ RegExp::Compile(const char* exp)
longest = NULL; longest = NULL;
len = 0; len = 0;
for (; scan != NULL; scan = Next((char*)scan)) for (; scan != NULL; scan = Next((char*)scan))
if (*scan == kRegExpExactly && (int32)strlen(Operand(scan)) >= len) { if (*scan == kRegExpExactly
&& (int32)strlen(Operand(scan)) >= len) {
longest = Operand(scan); longest = Operand(scan);
len = (int32)strlen(Operand(scan)); len = (int32)strlen(Operand(scan));
} }
@@ -520,10 +523,10 @@ RegExp::Branch(int32* flagp)
// - Piece - something followed by possible [*+?] // - Piece - something followed by possible [*+?]
// //
// Note that the branching code sequences used for ? and the general cases // Note that the branching code sequences used for ? and the general cases
// of * and + are somewhat optimized: they use the same kRegExpNothing node as // of * and + are somewhat optimized: they use the same kRegExpNothing node
// both the endmarker for their branch list and the body of the last branch. // as both the endmarker for their branch list and the body of the last
// It might seem that this node could be dispensed with entirely, but the // branch. It might seem that this node could be dispensed with entirely,
// endmarker role is not redundant. // but the endmarker role is not redundant.
// //
char* char*
RegExp::Piece(int32* flagp) RegExp::Piece(int32* flagp)
@@ -623,12 +626,14 @@ RegExp::Atom(int32* flagp)
ret = Node(kRegExpAnyOf); ret = Node(kRegExpAnyOf);
if (*fInputScanPointer == ']' || *fInputScanPointer == '-') if (*fInputScanPointer == ']' || *fInputScanPointer == '-')
Char(*fInputScanPointer++); Char(*fInputScanPointer++);
while (*fInputScanPointer != '\0' && *fInputScanPointer != ']') { while (*fInputScanPointer != '\0'
&& *fInputScanPointer != ']') {
if (*fInputScanPointer == '-') { if (*fInputScanPointer == '-') {
fInputScanPointer++; fInputScanPointer++;
if (*fInputScanPointer == ']' || *fInputScanPointer == '\0') if (*fInputScanPointer == ']'
|| *fInputScanPointer == '\0') {
Char('-'); Char('-');
else { } else {
cclass = UCharAt(fInputScanPointer - 2) + 1; cclass = UCharAt(fInputScanPointer - 2) + 1;
classend = UCharAt(fInputScanPointer); classend = UCharAt(fInputScanPointer);
if (cclass > classend + 1) { if (cclass > classend + 1) {
@@ -688,21 +693,25 @@ RegExp::Atom(int32* flagp)
SetError(REGEXP_INTERNAL_ERROR); SetError(REGEXP_INTERNAL_ERROR);
return NULL; return NULL;
} }
ender = *(fInputScanPointer + len); ender = *(fInputScanPointer + len);
if (len > 1 && IsMult(ender)) if (len > 1 && IsMult(ender))
len--; // Back off clear of ?+* operand. len--; // Back off clear of ?+* operand.
*flagp |= kHasWidth; *flagp |= kHasWidth;
if (len == 1) if (len == 1)
*flagp |= kSimple; *flagp |= kSimple;
ret = Node(kRegExpExactly); ret = Node(kRegExpExactly);
while (len > 0) { while (len > 0) {
Char(*fInputScanPointer++); Char(*fInputScanPointer++);
len--; len--;
} }
Char('\0'); Char('\0');
}
break; break;
} }
}
return ret; return ret;
} }
@@ -964,8 +973,10 @@ RegExp::Match(const char* prog) const
return 0; return 0;
uint32 len = strlen(opnd); uint32 len = strlen(opnd);
if (len > 1 && strncmp(opnd, fStringInputPointer, len) != 0) if (len > 1
&& strncmp(opnd, fStringInputPointer, len) != 0) {
return 0; return 0;
}
fStringInputPointer += len; fStringInputPointer += len;
} }
@@ -1255,7 +1266,8 @@ RegExp::Dump()
else else
printf("(%ld)", (s - fRegExp->program) + (next - s)); printf("(%ld)", (s - fRegExp->program) + (next - s));
s += 3; s += 3;
if (op == kRegExpAnyOf || op == kRegExpAnyBut || op == kRegExpExactly) { if (op == kRegExpAnyOf || op == kRegExpAnyBut
|| op == kRegExpExactly) {
// Literal string, where present. // Literal string, where present.
while (*s != '\0') { while (*s != '\0') {
putchar(*s); putchar(*s);
+25 -17
View File
@@ -63,14 +63,16 @@ SelectionWindow::SelectionWindow(BContainerWindow* window)
fParentWindow(window) fParentWindow(window)
{ {
if (window->Feel() & kPrivateDesktopWindowFeel) { if (window->Feel() & kPrivateDesktopWindowFeel) {
// The window will not show up if we have B_FLOATING_SUBSET_WINDOW_FEEL // The window will not show up if we have
// and use it with the desktop window since it's never in front. // B_FLOATING_SUBSET_WINDOW_FEEL and use it with the desktop window
// since it's never in front.
SetFeel(B_NORMAL_WINDOW_FEEL); SetFeel(B_NORMAL_WINDOW_FEEL);
} }
AddToSubset(fParentWindow); AddToSubset(fParentWindow);
BView* backgroundView = new BView(Bounds(), "bgView", B_FOLLOW_ALL, B_WILL_DRAW); BView* backgroundView = new BView(Bounds(), "bgView", B_FOLLOW_ALL,
B_WILL_DRAW);
backgroundView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); backgroundView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
AddChild(backgroundView); AddChild(backgroundView);
@@ -88,17 +90,18 @@ SelectionWindow::SelectionWindow(BContainerWindow* window)
// Set wildcard matching to default. // Set wildcard matching to default.
// Set up the menu field // Set up the menu field
fMatchingTypeMenuField = new BMenuField(BRect(7, 6, Bounds().right - 5, 0), fMatchingTypeMenuField = new BMenuField(BRect(7, 6,
NULL, B_TRANSLATE("Name"), menu); Bounds().right - 5, 0), NULL, B_TRANSLATE("Name"), menu);
backgroundView->AddChild(fMatchingTypeMenuField); backgroundView->AddChild(fMatchingTypeMenuField);
fMatchingTypeMenuField->SetDivider(fMatchingTypeMenuField->StringWidth( fMatchingTypeMenuField->SetDivider(fMatchingTypeMenuField->StringWidth(
B_TRANSLATE("Name")) + 8); B_TRANSLATE("Name")) + 8);
fMatchingTypeMenuField->ResizeToPreferred(); fMatchingTypeMenuField->ResizeToPreferred();
// Set up the expression text control // Set up the expression text control
fExpressionTextControl = new BTextControl(BRect(7, fMatchingTypeMenuField-> fExpressionTextControl = new BTextControl(BRect(7,
Bounds().bottom + 11, Bounds().right - 6, 0), NULL, NULL, NULL, NULL, fMatchingTypeMenuField->Bounds().bottom + 11,
B_FOLLOW_LEFT_RIGHT); Bounds().right - 6, 0),
NULL, NULL, NULL, NULL, B_FOLLOW_LEFT_RIGHT);
backgroundView->AddChild(fExpressionTextControl); backgroundView->AddChild(fExpressionTextControl);
fExpressionTextControl->ResizeToPreferred(); fExpressionTextControl->ResizeToPreferred();
fExpressionTextControl->MakeFocus(true); fExpressionTextControl->MakeFocus(true);
@@ -113,15 +116,16 @@ SelectionWindow::SelectionWindow(BContainerWindow* window)
// Set up the Ignore Case checkbox // Set up the Ignore Case checkbox
fIgnoreCaseCheckBox = new BCheckBox( fIgnoreCaseCheckBox = new BCheckBox(
BRect(fInverseCheckBox->Frame().right + 10, BRect(fInverseCheckBox->Frame().right + 10,
fInverseCheckBox->Frame().top, 6, 6), NULL, B_TRANSLATE("Ignore case"), fInverseCheckBox->Frame().top, 6, 6),
NULL); NULL, B_TRANSLATE("Ignore case"), NULL);
fIgnoreCaseCheckBox->SetValue(1); fIgnoreCaseCheckBox->SetValue(1);
backgroundView->AddChild(fIgnoreCaseCheckBox); backgroundView->AddChild(fIgnoreCaseCheckBox);
fIgnoreCaseCheckBox->ResizeToPreferred(); fIgnoreCaseCheckBox->ResizeToPreferred();
// Set up the Select button // Set up the Select button
fSelectButton = new BButton(BRect(0, 0, 5, 5), NULL, B_TRANSLATE("Select"), fSelectButton = new BButton(BRect(0, 0, 5, 5), NULL,
new BMessage(kSelectButtonPressed), B_FOLLOW_RIGHT); B_TRANSLATE("Select"), new BMessage(kSelectButtonPressed),
B_FOLLOW_RIGHT);
backgroundView->AddChild(fSelectButton); backgroundView->AddChild(fSelectButton);
fSelectButton->ResizeToPreferred(); fSelectButton->ResizeToPreferred();
@@ -138,16 +142,19 @@ SelectionWindow::SelectionWindow(BContainerWindow* window)
// Center the checkboxes vertically to the button // Center the checkboxes vertically to the button
float topMiddleButton = float topMiddleButton =
(fSelectButton->Bounds().Height() / 2 - (fSelectButton->Bounds().Height() / 2 -
(fh.ascent + fh.descent + fh.leading + 4) / 2) + fSelectButton->Frame().top; (fh.ascent + fh.descent + fh.leading + 4) / 2)
+ fSelectButton->Frame().top;
fInverseCheckBox->MoveTo(fInverseCheckBox->Frame().left, topMiddleButton); fInverseCheckBox->MoveTo(fInverseCheckBox->Frame().left, topMiddleButton);
fIgnoreCaseCheckBox->MoveTo(fIgnoreCaseCheckBox->Frame().left, fIgnoreCaseCheckBox->MoveTo(fIgnoreCaseCheckBox->Frame().left,
topMiddleButton); topMiddleButton);
float bottomMinWidth = 32 + fSelectButton->Bounds().Width() + float bottomMinWidth = 32 + fSelectButton->Bounds().Width()
fInverseCheckBox->Bounds().Width() + fIgnoreCaseCheckBox->Bounds().Width(); + fInverseCheckBox->Bounds().Width()
+ fIgnoreCaseCheckBox->Bounds().Width();
float topMinWidth = be_plain_font->StringWidth( float topMinWidth = be_plain_font->StringWidth(
B_TRANSLATE("Name matches wildcard expression:###")); B_TRANSLATE("Name matches wildcard expression:###"));
float minWidth = bottomMinWidth > topMinWidth ? bottomMinWidth : topMinWidth; float minWidth = bottomMinWidth > topMinWidth
? bottomMinWidth : topMinWidth;
class EscapeFilter : public BMessageFilter { class EscapeFilter : public BMessageFilter {
public: public:
@@ -240,7 +247,8 @@ SelectionWindow::MoveCloseToMouse()
// ... unless that's outside of the current screen size: // ... unless that's outside of the current screen size:
BScreen screen; BScreen screen;
windowPosition.x = MAX(20, MIN(screen.Frame().right - 20 - Frame().Width(), windowPosition.x
= MAX(20, MIN(screen.Frame().right - 20 - Frame().Width(),
windowPosition.x)); windowPosition.x));
windowPosition.y = MAX(20, windowPosition.y = MAX(20,
MIN(screen.Frame().bottom - 20 - Frame().Height(), windowPosition.y)); MIN(screen.Frame().bottom - 20 - Frame().Height(), windowPosition.y));
+6 -5
View File
@@ -46,8 +46,9 @@ Settings* settings = NULL;
// generic setting handler classes // generic setting handler classes
StringValueSetting::StringValueSetting(const char* name, const char* defaultValue, StringValueSetting::StringValueSetting(const char* name,
const char* valueExpectedErrorString, const char* wrongValueErrorString) const char* defaultValue, const char* valueExpectedErrorString,
const char* wrongValueErrorString)
: SettingsArgvDispatcher(name), : SettingsArgvDispatcher(name),
fDefaultValue(defaultValue), fDefaultValue(defaultValue),
fValueExpectedErrorString(valueExpectedErrorString), fValueExpectedErrorString(valueExpectedErrorString),
@@ -240,9 +241,9 @@ ScalarValueSetting::NeedsSaving() const
// #pragma mark - // #pragma mark -
HexScalarValueSetting::HexScalarValueSetting(const char* name, int32 defaultValue, HexScalarValueSetting::HexScalarValueSetting(const char* name,
const char* valueExpectedErrorString, const char* wrongValueErrorString, int32 defaultValue, const char* valueExpectedErrorString,
int32 min, int32 max) const char* wrongValueErrorString, int32 min, int32 max)
: ScalarValueSetting(name, defaultValue, valueExpectedErrorString, : ScalarValueSetting(name, defaultValue, valueExpectedErrorString,
wrongValueErrorString, min, max) wrongValueErrorString, min, max)
{ {
+6 -4
View File
@@ -85,8 +85,9 @@ class ScalarValueSetting : public SettingsArgvDispatcher {
// simple int32 setting // simple int32 setting
public: public:
ScalarValueSetting(const char* name, int32 defaultValue, ScalarValueSetting(const char* name, int32 defaultValue,
const char* valueExpectedErrorString, const char* wrongValueErrorString, const char* valueExpectedErrorString,
int32 min = LONG_MIN, int32 max = LONG_MAX); const char* wrongValueErrorString, int32 min = LONG_MIN,
int32 max = LONG_MAX);
void ValueChanged(int32 newValue); void ValueChanged(int32 newValue);
int32 Value() const; int32 Value() const;
@@ -110,8 +111,9 @@ class HexScalarValueSetting : public ScalarValueSetting {
// hexadecimal int32 setting // hexadecimal int32 setting
public: public:
HexScalarValueSetting(const char* name, int32 defaultValue, HexScalarValueSetting(const char* name, int32 defaultValue,
const char* valueExpectedErrorString, const char* wrongValueErrorString, const char* valueExpectedErrorString,
int32 min = LONG_MIN, int32 max = LONG_MAX); const char* wrongValueErrorString, int32 min = LONG_MIN,
int32 max = LONG_MAX);
void GetValueAsString(char* buffer) const; void GetValueAsString(char* buffer) const;
+8 -5
View File
@@ -188,7 +188,8 @@ ArgvParser::EachArgvPrivate(const char* name, ArgvHandler argvHandlerFunc,
// handle new line // handle new line
fEatComment = false; fEatComment = false;
if (!fSawBackslash && (fInDoubleQuote || fInSingleQuote)) { if (!fSawBackslash && (fInDoubleQuote || fInSingleQuote)) {
printf("File %s ; Line %ld # unterminated quote\n", name, fLineNo); printf("File %s ; Line %ld # unterminated quote\n", name,
fLineNo);
result = B_ERROR; result = B_ERROR;
break; break;
} }
@@ -211,7 +212,8 @@ ArgvParser::EachArgvPrivate(const char* name, ArgvHandler argvHandlerFunc,
if (!fSawBackslash) { if (!fSawBackslash) {
if (!fInDoubleQuote && !fInSingleQuote) { if (!fInDoubleQuote && !fInSingleQuote) {
if (ch == ';') { if (ch == ';') {
// semicolon is a command separator, pass on the whole argv // semicolon is a command separator, pass on
// the whole argv
result = SendArgv(argvHandlerFunc, passThru); result = SendArgv(argvHandlerFunc, passThru);
if (result != B_OK) if (result != B_OK)
break; break;
@@ -259,7 +261,8 @@ SettingsArgvDispatcher::SettingsArgvDispatcher(const char* name)
void void
SettingsArgvDispatcher::SaveSettings(Settings* settings, bool onlyIfNonDefault) SettingsArgvDispatcher::SaveSettings(Settings* settings,
bool onlyIfNonDefault)
{ {
if (!onlyIfNonDefault || NeedsSaving()) { if (!onlyIfNonDefault || NeedsSaving()) {
settings->Write("%s ", Name()); settings->Write("%s ", Name());
@@ -270,8 +273,8 @@ SettingsArgvDispatcher::SaveSettings(Settings* settings, bool onlyIfNonDefault)
bool bool
SettingsArgvDispatcher::HandleRectValue(BRect &result, const char* const* argv, SettingsArgvDispatcher::HandleRectValue(BRect &result,
bool printError) const char* const* argv, bool printError)
{ {
if (!*argv) { if (!*argv) {
if (printError) if (printError)
+4 -2
View File
@@ -50,7 +50,8 @@ namespace BPrivate {
class Settings; class Settings;
typedef const char* (*ArgvHandler)(int argc, const char* const *argv, void* params); typedef const char* (*ArgvHandler)(int argc, const char* const *argv,
void* params);
// return 0 or error string if parsing failed // return 0 or error string if parsing failed
const int32 kBufferSize = 1024; const int32 kBufferSize = 1024;
@@ -117,7 +118,8 @@ public:
// return a pointer to an error message or null if parsed OK // return a pointer to an error message or null if parsed OK
// some handy reader/writer calls // some handy reader/writer calls
bool HandleRectValue(BRect&, const char* const *argv, bool printError = true); bool HandleRectValue(BRect&, const char* const *argv,
bool printError = true);
void WriteRectValue(Settings*, BRect); void WriteRectValue(Settings*, BRect);
protected: protected:
+46 -24
View File
@@ -59,11 +59,14 @@ static const float kIndentSpacing = 12.0f;
//TODO: defaults should be set in one place only (TrackerSettings.cpp) while //TODO: defaults should be set in one place only (TrackerSettings.cpp) while
// being accessible from here. // being accessible from here.
// What about adding DefaultValue(), IsDefault() etc... methods to xxxValueSetting ? // What about adding DefaultValue(), IsDefault() etc... methods to
// xxxValueSetting ?
static const uint8 kSpaceBarAlpha = 192; static const uint8 kSpaceBarAlpha = 192;
static const rgb_color kDefaultUsedSpaceColor = {0, 203, 0, kSpaceBarAlpha}; static const rgb_color kDefaultUsedSpaceColor = {0, 203, 0, kSpaceBarAlpha};
static const rgb_color kDefaultFreeSpaceColor = {255, 255, 255, kSpaceBarAlpha}; static const rgb_color kDefaultFreeSpaceColor
static const rgb_color kDefaultWarningSpaceColor = {203, 0, 0, kSpaceBarAlpha}; = {255, 255, 255, kSpaceBarAlpha};
static const rgb_color kDefaultWarningSpaceColor
= {203, 0, 0, kSpaceBarAlpha};
static void static void
@@ -370,10 +373,13 @@ DesktopSettingsView::ShowCurrentSettings()
TrackerSettings settings; TrackerSettings settings;
fShowDisksIconRadioButton->SetValue(settings.ShowDisksIcon()); fShowDisksIconRadioButton->SetValue(settings.ShowDisksIcon());
fMountVolumesOntoDesktopRadioButton->SetValue(settings.MountVolumesOntoDesktop()); fMountVolumesOntoDesktopRadioButton->SetValue(
settings.MountVolumesOntoDesktop());
fMountSharedVolumesOntoDesktopCheckBox->SetValue(settings.MountSharedVolumesOntoDesktop()); fMountSharedVolumesOntoDesktopCheckBox->SetValue(
fMountSharedVolumesOntoDesktopCheckBox->SetEnabled(settings.MountVolumesOntoDesktop()); settings.MountSharedVolumesOntoDesktop());
fMountSharedVolumesOntoDesktopCheckBox->SetEnabled(
settings.MountVolumesOntoDesktop());
} }
@@ -476,19 +482,22 @@ WindowsSettingsView::MessageReceived(BMessage* message)
switch (message->what) { switch (message->what) {
case kWindowsShowFullPathChanged: case kWindowsShowFullPathChanged:
settings.SetShowFullPathInTitleBar(fShowFullPathInTitleBarCheckBox->Value() == 1); settings.SetShowFullPathInTitleBar(
fShowFullPathInTitleBarCheckBox->Value() == 1);
tracker->SendNotices(kWindowsShowFullPathChanged); tracker->SendNotices(kWindowsShowFullPathChanged);
Window()->PostMessage(kSettingsContentsModified); Window()->PostMessage(kSettingsContentsModified);
break; break;
case kSingleWindowBrowseChanged: case kSingleWindowBrowseChanged:
settings.SetSingleWindowBrowse(fSingleWindowBrowseCheckBox->Value() == 1); settings.SetSingleWindowBrowse(
fSingleWindowBrowseCheckBox->Value() == 1);
if (fSingleWindowBrowseCheckBox->Value() == 0) { if (fSingleWindowBrowseCheckBox->Value() == 0) {
fShowNavigatorCheckBox->SetEnabled(false); fShowNavigatorCheckBox->SetEnabled(false);
settings.SetShowNavigator(0); settings.SetShowNavigator(0);
} else { } else {
fShowNavigatorCheckBox->SetEnabled(true); fShowNavigatorCheckBox->SetEnabled(true);
settings.SetShowNavigator(fShowNavigatorCheckBox->Value() != 0); settings.SetShowNavigator(
fShowNavigatorCheckBox->Value() != 0);
} }
tracker->SendNotices(kShowNavigatorChanged); tracker->SendNotices(kShowNavigatorChanged);
tracker->SendNotices(kSingleWindowBrowseChanged); tracker->SendNotices(kSingleWindowBrowseChanged);
@@ -516,10 +525,12 @@ WindowsSettingsView::MessageReceived(BMessage* message)
case kSortFolderNamesFirstChanged: case kSortFolderNamesFirstChanged:
{ {
settings.SetSortFolderNamesFirst(fSortFolderNamesFirstCheckBox->Value() == 1); settings.SetSortFolderNamesFirst(
fSortFolderNamesFirstCheckBox->Value() == 1);
// Make the notification message and send it to the tracker: // Make the notification message and send it to the tracker:
send_bool_notices(kSortFolderNamesFirstChanged, "SortFolderNamesFirst", send_bool_notices(kSortFolderNamesFirstChanged,
"SortFolderNamesFirst",
fSortFolderNamesFirstCheckBox->Value() == 1); fSortFolderNamesFirstCheckBox->Value() == 1);
Window()->PostMessage(kSettingsContentsModified); Window()->PostMessage(kSettingsContentsModified);
@@ -528,8 +539,10 @@ WindowsSettingsView::MessageReceived(BMessage* message)
case kTypeAheadFilteringChanged: case kTypeAheadFilteringChanged:
{ {
settings.SetTypeAheadFiltering(fTypeAheadFilteringCheckBox->Value() == 1); settings.SetTypeAheadFiltering(
send_bool_notices(kTypeAheadFilteringChanged, "TypeAheadFiltering", fTypeAheadFilteringCheckBox->Value() == 1);
send_bool_notices(kTypeAheadFilteringChanged,
"TypeAheadFiltering",
fTypeAheadFilteringCheckBox->Value() == 1); fTypeAheadFilteringCheckBox->Value() == 1);
Window()->PostMessage(kSettingsContentsModified); Window()->PostMessage(kSettingsContentsModified);
break; break;
@@ -653,7 +666,8 @@ WindowsSettingsView::ShowCurrentSettings()
{ {
TrackerSettings settings; TrackerSettings settings;
fShowFullPathInTitleBarCheckBox->SetValue(settings.ShowFullPathInTitleBar()); fShowFullPathInTitleBarCheckBox->SetValue(
settings.ShowFullPathInTitleBar());
fSingleWindowBrowseCheckBox->SetValue(settings.SingleWindowBrowse()); fSingleWindowBrowseCheckBox->SetValue(settings.SingleWindowBrowse());
fShowNavigatorCheckBox->SetEnabled(settings.SingleWindowBrowse()); fShowNavigatorCheckBox->SetEnabled(settings.SingleWindowBrowse());
fShowNavigatorCheckBox->SetValue(settings.ShowNavigator()); fShowNavigatorCheckBox->SetValue(settings.ShowNavigator());
@@ -722,9 +736,10 @@ SpaceBarSettingsView::SpaceBarSettingsView()
BBox* box = new BBox("box"); BBox* box = new BBox("box");
box->SetLabel(fColorPicker = new BMenuField("menu", NULL, menu)); box->SetLabel(fColorPicker = new BMenuField("menu", NULL, menu));
fColorControl = new BColorControl(BPoint(8, fColorPicker->Bounds().Height() fColorControl = new BColorControl(BPoint(8,
+ 8 + kItemExtraSpacing), fColorPicker->Bounds().Height() + 8 + kItemExtraSpacing),
B_CELLS_16x16, 1, "SpaceColorControl", new BMessage(kSpaceBarColorChanged)); B_CELLS_16x16, 1, "SpaceColorControl",
new BMessage(kSpaceBarColorChanged));
fColorControl->SetValue(TrackerSettings().UsedSpaceColor()); fColorControl->SetValue(TrackerSettings().UsedSpaceColor());
box->AddChild(fColorControl); box->AddChild(fColorControl);
@@ -767,7 +782,8 @@ SpaceBarSettingsView::MessageReceived(BMessage* message)
switch (message->what) { switch (message->what) {
case kUpdateVolumeSpaceBar: case kUpdateVolumeSpaceBar:
{ {
settings.SetShowVolumeSpaceBar(fSpaceBarShowCheckBox->Value() == 1); settings.SetShowVolumeSpaceBar(
fSpaceBarShowCheckBox->Value() == 1);
Window()->PostMessage(kSettingsContentsModified); Window()->PostMessage(kSettingsContentsModified);
tracker->PostMessage(kShowVolumeSpaceBar); tracker->PostMessage(kShowVolumeSpaceBar);
break; break;
@@ -794,7 +810,8 @@ SpaceBarSettingsView::MessageReceived(BMessage* message)
{ {
rgb_color color = fColorControl->ValueAsColor(); rgb_color color = fColorControl->ValueAsColor();
color.alpha = kSpaceBarAlpha; color.alpha = kSpaceBarAlpha;
//alpha is ignored by BColorControl but is checked in equalities // alpha is ignored by BColorControl but is checked
// in equalities
switch (fCurrentColor) { switch (fCurrentColor) {
case 0: case 0:
@@ -870,7 +887,8 @@ SpaceBarSettingsView::Revert()
if (settings.ShowVolumeSpaceBar() != fSpaceBarShow) { if (settings.ShowVolumeSpaceBar() != fSpaceBarShow) {
settings.SetShowVolumeSpaceBar(fSpaceBarShow); settings.SetShowVolumeSpaceBar(fSpaceBarShow);
send_bool_notices(kShowVolumeSpaceBar, "ShowVolumeSpaceBar", fSpaceBarShow); send_bool_notices(kShowVolumeSpaceBar, "ShowVolumeSpaceBar",
fSpaceBarShow);
} }
if (settings.UsedSpaceColor() != fUsedSpaceColor if (settings.UsedSpaceColor() != fUsedSpaceColor
@@ -978,14 +996,16 @@ TrashSettingsView::MessageReceived(BMessage* message)
switch (message->what) { switch (message->what) {
case kDontMoveFilesToTrashChanged: case kDontMoveFilesToTrashChanged:
settings.SetDontMoveFilesToTrash(fDontMoveFilesToTrashCheckBox->Value() == 1); settings.SetDontMoveFilesToTrash(
fDontMoveFilesToTrashCheckBox->Value() == 1);
tracker->SendNotices(kDontMoveFilesToTrashChanged); tracker->SendNotices(kDontMoveFilesToTrashChanged);
Window()->PostMessage(kSettingsContentsModified); Window()->PostMessage(kSettingsContentsModified);
break; break;
case kAskBeforeDeleteFileChanged: case kAskBeforeDeleteFileChanged:
settings.SetAskBeforeDeleteFile(fAskBeforeDeleteFileCheckBox->Value() == 1); settings.SetAskBeforeDeleteFile(
fAskBeforeDeleteFileCheckBox->Value() == 1);
tracker->SendNotices(kAskBeforeDeleteFileChanged); tracker->SendNotices(kAskBeforeDeleteFileChanged);
Window()->PostMessage(kSettingsContentsModified); Window()->PostMessage(kSettingsContentsModified);
@@ -1069,7 +1089,9 @@ TrashSettingsView::RecordRevertSettings()
bool bool
TrashSettingsView::IsRevertable() const TrashSettingsView::IsRevertable() const
{ {
return fDontMoveFilesToTrash != (fDontMoveFilesToTrashCheckBox->Value() > 0) return fDontMoveFilesToTrash
|| fAskBeforeDeleteFile != (fAskBeforeDeleteFileCheckBox->Value() > 0); != (fDontMoveFilesToTrashCheckBox->Value() > 0)
|| fAskBeforeDeleteFile
!= (fAskBeforeDeleteFileCheckBox->Value() > 0);
} }
+6 -5
View File
@@ -462,8 +462,8 @@ BSlowContextMenu::BuildVolumeMenu()
fMessenger, fParentWindow, fTypesList); fMessenger, fParentWindow, fTypesList);
menu->SetNavDir(model->EntryRef()); menu->SetNavDir(model->EntryRef());
menu->InitTrackingHook(fTrackingHook.fTrackingHook, &(fTrackingHook.fTarget), menu->InitTrackingHook(fTrackingHook.fTrackingHook,
fTrackingHook.fDragMessage); &(fTrackingHook.fTarget), fTrackingHook.fDragMessage);
ASSERT(menu->Name()); ASSERT(menu->Name());
@@ -519,8 +519,8 @@ BSlowContextMenu::SetTarget(const BMessenger &target)
TrackingHookData* TrackingHookData*
BSlowContextMenu::InitTrackingHook(bool (*hook)(BMenu*, void*), const BMessenger* target, BSlowContextMenu::InitTrackingHook(bool (*hook)(BMenu*, void*),
const BMessage* dragMessage) const BMessenger* target, const BMessage* dragMessage)
{ {
fTrackingHook.fTrackingHook = hook; fTrackingHook.fTrackingHook = hook;
if (target) if (target)
@@ -532,7 +532,8 @@ BSlowContextMenu::InitTrackingHook(bool (*hook)(BMenu*, void*), const BMessenger
void void
BSlowContextMenu::SetTrackingHookDeep(BMenu* menu, bool (*func)(BMenu*, void*), void* state) BSlowContextMenu::SetTrackingHookDeep(BMenu* menu,
bool (*func)(BMenu*, void*), void* state)
{ {
menu->SetTrackingHook(func, state); menu->SetTrackingHook(func, state);
int32 count = menu->CountItems(); int32 count = menu->CountItems();
+3 -2
View File
@@ -63,8 +63,9 @@ public:
void SetTypesList(const BObjectList<BString>* list); void SetTypesList(const BObjectList<BString>* list);
const BObjectList<BString>* TypesList() const; const BObjectList<BString>* TypesList() const;
static ModelMenuItem* NewModelItem(Model*, const BMessage*, const BMessenger&, static ModelMenuItem* NewModelItem(Model*, const BMessage*,
bool suppressFolderHierarchy = false, BContainerWindow* = NULL, const BMessenger&, bool suppressFolderHierarchy = false,
BContainerWindow* = NULL,
const BObjectList<BString>* typeslist = NULL, const BObjectList<BString>* typeslist = NULL,
TrackingHookData* hook = NULL); TrackingHookData* hook = NULL);
+2 -1
View File
@@ -66,7 +66,8 @@ class BSlowMenu : public BMenu {
protected: protected:
virtual bool AddDynamicItem(add_state state); virtual bool AddDynamicItem(add_state state);
// this is the callback from BMenu, you shouldn't need to override this // this is the callback from BMenu, you shouldn't need to
// override this
bool fMenuBuilt; bool fMenuBuilt;
}; };
+24 -15
View File
@@ -315,8 +315,8 @@ BStatusWindow::RemoveStatusItem(thread_id thread)
} }
if (winner != NULL) { if (winner != NULL) {
// The height by which the other views will have to be moved (in pixel // The height by which the other views will have to be moved
// count). // (in pixel count).
float height = winner->Bounds().Height() + 1; float height = winner->Bounds().Height() + 1;
fViewList.RemoveItem(winner); fViewList.RemoveItem(winner);
winner->RemoveSelf(); winner->RemoveSelf();
@@ -460,7 +460,8 @@ BStatusView::BStatusView(BRect bounds, thread_id thread, StatusWindowState type)
break; break;
case kCreateLinkState: case kCreateLinkState:
caption = B_TRANSLATE("Preparing to create links" B_UTF8_ELLIPSIS); caption = B_TRANSLATE("Preparing to create links"
B_UTF8_ELLIPSIS);
id = R_MoveStatusBitmap; id = R_MoveStatusBitmap;
break; break;
@@ -470,16 +471,19 @@ BStatusView::BStatusView(BRect bounds, thread_id thread, StatusWindowState type)
break; break;
case kVolumeState: case kVolumeState:
caption = B_TRANSLATE("Searching for disks to mount" B_UTF8_ELLIPSIS); caption = B_TRANSLATE("Searching for disks to mount"
B_UTF8_ELLIPSIS);
break; break;
case kDeleteState: case kDeleteState:
caption = B_TRANSLATE("Preparing to delete items" B_UTF8_ELLIPSIS); caption = B_TRANSLATE("Preparing to delete items"
B_UTF8_ELLIPSIS);
id = R_TrashStatusBitmap; id = R_TrashStatusBitmap;
break; break;
case kRestoreFromTrashState: case kRestoreFromTrashState:
caption = B_TRANSLATE("Preparing to restore items" B_UTF8_ELLIPSIS); caption = B_TRANSLATE("Preparing to restore items"
B_UTF8_ELLIPSIS);
break; break;
default: default:
@@ -506,8 +510,10 @@ BStatusView::BStatusView(BRect bounds, thread_id thread, StatusWindowState type)
+ fh.descent + f.top); + fh.descent + f.top);
} }
if (id != 0) if (id != 0) {
GetTrackerResources()->GetBitmapResource(B_MESSAGE_TYPE, id, &fBitmap); GetTrackerResources()->GetBitmapResource(B_MESSAGE_TYPE, id,
&fBitmap);
}
rect = Bounds(); rect = Bounds();
rect.left = rect.right - buttonWidth * 2 - 7; rect.left = rect.right - buttonWidth * 2 - 7;
@@ -550,8 +556,8 @@ BStatusView::Init()
fLastSpeedReferenceSize = 0; fLastSpeedReferenceSize = 0;
fEstimatedFinishReferenceSize = 0; fEstimatedFinishReferenceSize = 0;
fProcessStartTime = fLastSpeedReferenceTime = fEstimatedFinishReferenceTime fProcessStartTime = fLastSpeedReferenceTime
= system_time(); = fEstimatedFinishReferenceTime = system_time();
} }
@@ -584,7 +590,8 @@ BStatusView::InitStatus(int32 totalItems, off_t totalSize,
break; break;
case kCreateLinkState: case kCreateLinkState:
fStatusBar->Reset(B_TRANSLATE("Creating links: "), buffer.String()); fStatusBar->Reset(B_TRANSLATE("Creating links: "),
buffer.String());
break; break;
case kMoveState: case kMoveState:
@@ -592,7 +599,8 @@ BStatusView::InitStatus(int32 totalItems, off_t totalSize,
break; break;
case kTrashState: case kTrashState:
fStatusBar->Reset(B_TRANSLATE("Emptying Trash" B_UTF8_ELLIPSIS " "), fStatusBar->Reset(
B_TRANSLATE("Emptying Trash" B_UTF8_ELLIPSIS " "),
buffer.String()); buffer.String());
break; break;
@@ -619,7 +627,8 @@ BStatusView::Draw(BRect updateRect)
{ {
if (fBitmap) { if (fBitmap) {
BPoint location; BPoint location;
location.x = (fStatusBar->Frame().left - fBitmap->Bounds().Width()) / 2; location.x = (fStatusBar->Frame().left
- fBitmap->Bounds().Width()) / 2;
location.y = (Bounds().Height()- fBitmap->Bounds().Height()) / 2; location.y = (Bounds().Height()- fBitmap->Bounds().Height()) / 2;
DrawBitmap(fBitmap, location); DrawBitmap(fBitmap, location);
} }
@@ -695,7 +704,8 @@ BStatusView::_DestinationString(float* _width)
BString BString
BStatusView::_StatusString(float availableSpace, float fontSize, float* _width) BStatusView::_StatusString(float availableSpace, float fontSize,
float* _width)
{ {
BFont font; BFont font;
GetFont(&font); GetFont(&font);
@@ -970,4 +980,3 @@ BStatusView::SetWasCanceled()
{ {
fWasCanceled = true; fWasCanceled = true;
} }
+21 -14
View File
@@ -48,7 +48,8 @@ DelayedTask::~DelayedTask()
{ {
} }
OneShotDelayedTask::OneShotDelayedTask(FunctionObject* functor, bigtime_t delay) OneShotDelayedTask::OneShotDelayedTask(FunctionObject* functor,
bigtime_t delay)
: DelayedTask(delay), : DelayedTask(delay),
fFunctor(functor) fFunctor(functor)
{ {
@@ -293,8 +294,9 @@ TaskLoop::RunWhenIdle(FunctionObjectWithResult<bool>* functor,
class AccumulatedOneShotDelayedTask : public OneShotDelayedTask { class AccumulatedOneShotDelayedTask : public OneShotDelayedTask {
// supports accumulating functors // supports accumulating functors
public: public:
AccumulatedOneShotDelayedTask(AccumulatingFunctionObject* functor, bigtime_t delay, AccumulatedOneShotDelayedTask(AccumulatingFunctionObject* functor,
bigtime_t maxAccumulatingTime = 0, int32 maxAccumulateCount = 0) bigtime_t delay, bigtime_t maxAccumulatingTime = 0,
int32 maxAccumulateCount = 0)
: OneShotDelayedTask(functor, delay), : OneShotDelayedTask(functor, delay),
maxAccumulateCount(maxAccumulateCount), maxAccumulateCount(maxAccumulateCount),
accumulateCount(1), accumulateCount(1),
@@ -308,19 +310,24 @@ public:
// don't accumulate if too may accumulated already // don't accumulate if too may accumulated already
return false; return false;
if (maxAccumulatingTime && system_time() > initialTime + maxAccumulatingTime) if (maxAccumulatingTime && system_time() > initialTime
+ maxAccumulatingTime) {
// don't accumulate if too late past initial task // don't accumulate if too late past initial task
return false; return false;
return static_cast<AccumulatingFunctionObject*>(fFunctor)->CanAccumulate(accumulateThis);
} }
virtual void Accumulate(AccumulatingFunctionObject* accumulateThis, bigtime_t delay) return static_cast<AccumulatingFunctionObject*>(fFunctor)->
CanAccumulate(accumulateThis);
}
virtual void Accumulate(AccumulatingFunctionObject* accumulateThis,
bigtime_t delay)
{ {
fRunAfter = system_time() + delay; fRunAfter = system_time() + delay;
// reset fRunAfter // reset fRunAfter
accumulateCount++; accumulateCount++;
static_cast<AccumulatingFunctionObject*>(fFunctor)->Accumulate(accumulateThis); static_cast<AccumulatingFunctionObject*>(fFunctor)->
Accumulate(accumulateThis);
} }
private: private:
@@ -331,8 +338,8 @@ private:
}; };
void void
TaskLoop::AccumulatedRunLater(AccumulatingFunctionObject* functor, bigtime_t delay, TaskLoop::AccumulatedRunLater(AccumulatingFunctionObject* functor,
bigtime_t maxAccumulatingTime, int32 maxAccumulateCount) bigtime_t delay, bigtime_t maxAccumulatingTime, int32 maxAccumulateCount)
{ {
AutoLock<BLocker> autoLock(&fLock); AutoLock<BLocker> autoLock(&fLock);
if (!autoLock.IsLocked()) { if (!autoLock.IsLocked()) {
@@ -351,8 +358,8 @@ TaskLoop::AccumulatedRunLater(AccumulatingFunctionObject* functor, bigtime_t del
return; return;
} }
} }
RunLater(new AccumulatedOneShotDelayedTask(functor, delay, maxAccumulatingTime, RunLater(new AccumulatedOneShotDelayedTask(functor, delay,
maxAccumulateCount)); maxAccumulatingTime, maxAccumulateCount));
} }
@@ -479,8 +486,8 @@ StandAloneTaskLoop::StartPulsingIfNeeded()
ASSERT(fLock.IsLocked()); ASSERT(fLock.IsLocked());
if (fScanThread < 0) { if (fScanThread < 0) {
// no loop thread yet, spawn one // no loop thread yet, spawn one
fScanThread = spawn_thread(StandAloneTaskLoop::RunBinder, "TrackerTaskLoop", fScanThread = spawn_thread(StandAloneTaskLoop::RunBinder,
B_LOW_PRIORITY, this); "TrackerTaskLoop", B_LOW_PRIORITY, this);
resume_thread(fScanThread); resume_thread(fScanThread);
} }
} }
+2 -4
View File
@@ -47,7 +47,6 @@ All rights reserved.
namespace BPrivate { namespace BPrivate {
// Task flavors // Task flavors
class DelayedTask { class DelayedTask {
@@ -110,8 +109,8 @@ protected:
// until functor returns true // until functor returns true
class RunWhenIdleTask : public PeriodicDelayedTask { class RunWhenIdleTask : public PeriodicDelayedTask {
public: public:
RunWhenIdleTask(FunctionObjectWithResult<bool>* functor, bigtime_t initialDelay, RunWhenIdleTask(FunctionObjectWithResult<bool>* functor,
bigtime_t idleFor, bigtime_t heartBeat); bigtime_t initialDelay, bigtime_t idleFor, bigtime_t heartBeat);
virtual ~RunWhenIdleTask(); virtual ~RunWhenIdleTask();
virtual bool RunIfNeeded(bigtime_t currentTime); virtual bool RunIfNeeded(bigtime_t currentTime);
@@ -256,7 +255,6 @@ DelayedTask::RunAfterTime() const
return fRunAfter; return fRunAfter;
} }
} // namespace BPrivate } // namespace BPrivate
using namespace BPrivate; using namespace BPrivate;
+2 -1
View File
@@ -168,7 +168,8 @@ TemplatesMenu::BuildMenu(bool addItems)
BMessage* message = new BMessage(kNewEntryFromTemplate); BMessage* message = new BMessage(kNewEntryFromTemplate);
message->AddRef("refs_template", &ref); message->AddRef("refs_template", &ref);
message->AddString("name", fileName); message->AddString("name", fileName);
AddItem(new IconMenuItem(fileName, message, &nodeInfo, B_MINI_ICON)); AddItem(new IconMenuItem(fileName, message, &nodeInfo,
B_MINI_ICON));
} }
} }
} }
+11 -7
View File
@@ -184,7 +184,8 @@ IconSpewer::DrawSomeNew()
} }
if (numDrawn) { if (numDrawn) {
sprintf(buffer, "average draw time %Ld us per icon", watch.ElapsedTime() / numDrawn); sprintf(buffer, "average draw time %Ld us per icon",
watch.ElapsedTime() / numDrawn);
view->DrawString(buffer, BPoint(20, bounds.bottom - 30)); view->DrawString(buffer, BPoint(20, bounds.bottom - 30));
} }
@@ -204,8 +205,9 @@ IconSpewer::DrawSomeNew()
if (model.IsDirectory()) if (model.IsDirectory())
entry.GetPath(&currentPath); entry.GetPath(&currentPath);
IconCache::sIconCache->Draw(&model, view, BPoint(column * (kIconSize + 2), IconCache::sIconCache->Draw(&model, view,
row * (kIconSize + 2)), kNormalIcon, kIconSize, true); BPoint(column * (kIconSize + 2), row * (kIconSize + 2)),
kNormalIcon, kIconSize, true);
target->Unlock(); target->Unlock();
numDrawn++; numDrawn++;
} }
@@ -239,7 +241,8 @@ IconSpewer::DrawSomeOld()
view->DrawString(buffer, BPoint(20, bounds.bottom - 20)); view->DrawString(buffer, BPoint(20, bounds.bottom - 20));
} }
if (numDrawn) { if (numDrawn) {
sprintf(buffer, "average draw time %Ld us per icon", watch.ElapsedTime() / numDrawn); sprintf(buffer, "average draw time %Ld us per icon",
watch.ElapsedTime() / numDrawn);
view->DrawString(buffer, BPoint(20, bounds.bottom - 30)); view->DrawString(buffer, BPoint(20, bounds.bottom - 30));
} }
sprintf(buffer, "directory: %s", currentPath.Path()); sprintf(buffer, "directory: %s", currentPath.Path());
@@ -259,7 +262,8 @@ IconSpewer::DrawSomeOld()
entry.GetPath(&currentPath); entry.GetPath(&currentPath);
BIconCache::LockIconCache(); BIconCache::LockIconCache();
BIconCache* iconCache = BIconCache::GetIconCache(&model, kIconSize); BIconCache* iconCache
= BIconCache::GetIconCache(&model, kIconSize);
iconCache->Draw(view, BPoint(column * (kIconSize + 2), iconCache->Draw(view, BPoint(column * (kIconSize + 2),
row * (kIconSize + 2)), B_NORMAL_ICON, kIconSize, true); row * (kIconSize + 2)), B_NORMAL_ICON, kIconSize, true);
BIconCache::UnlockIconCache(); BIconCache::UnlockIconCache();
@@ -310,8 +314,8 @@ IconSpewer::NextRef()
IconTestWindow::IconTestWindow() IconTestWindow::IconTestWindow()
: BWindow(BRect(100, 100, 500, 600), "icon cache test", B_TITLED_WINDOW_LOOK, : BWindow(BRect(100, 100, 500, 600), "icon cache test",
B_NORMAL_WINDOW_FEEL, 0), B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, 0),
iconSpewer(modifiers() == 0) iconSpewer(modifiers() == 0)
{ {
iconSpewer.SetTarget(this); iconSpewer.SetTarget(this);
+22 -15
View File
@@ -91,7 +91,8 @@ BTextWidget::Compare(const BTextWidget& with, BPoseView* view) const
const char* const char*
BTextWidget::Text(const BPoseView* view) const BTextWidget::Text(const BPoseView* view) const
{ {
StringAttributeText* textAttribute = dynamic_cast<StringAttributeText*>(fText); StringAttributeText* textAttribute
= dynamic_cast<StringAttributeText*>(fText);
if (textAttribute == NULL) if (textAttribute == NULL)
return NULL; return NULL;
@@ -146,7 +147,8 @@ BTextWidget::CalcRectCommon(BPoint poseLoc, const BColumn* column,
break; break;
case B_ALIGN_CENTER: case B_ALIGN_CENTER:
result.left = poseLoc.x + (column->Width() / 2) - (textWidth / 2); result.left = poseLoc.x + (column->Width() / 2)
- (textWidth / 2);
if (result.left < 0) if (result.left < 0)
result.left = 0; result.left = 0;
result.right = result.left + textWidth + 1; result.right = result.left + textWidth + 1;
@@ -277,8 +279,8 @@ TextViewFilter(BMessage* message, BHandler**, BMessageFilter* filter)
if (message->FindInt8("byte", (int8*)&key) != B_OK) if (message->FindInt8("byte", (int8*)&key) != B_OK)
return B_DISPATCH_MESSAGE; return B_DISPATCH_MESSAGE;
BPoseView* poseView = dynamic_cast<BContainerWindow*>(filter->Looper())-> BPoseView* poseView = dynamic_cast<BContainerWindow*>(
PoseView(); filter->Looper())->PoseView();
if (key == B_RETURN || key == B_ESCAPE) { if (key == B_RETURN || key == B_ESCAPE) {
poseView->CommitActivePose(key == B_RETURN); poseView->CommitActivePose(key == B_RETURN);
@@ -302,7 +304,8 @@ TextViewFilter(BMessage* message, BHandler**, BMessageFilter* filter)
// find the text editing view // find the text editing view
BView* scrollView = poseView->FindView("BorderView"); BView* scrollView = poseView->FindView("BorderView");
if (scrollView != NULL) { if (scrollView != NULL) {
BTextView* textView = dynamic_cast<BTextView*>(scrollView->FindView("WidgetTextView")); BTextView* textView = dynamic_cast<BTextView*>(
scrollView->FindView("WidgetTextView"));
if (textView != NULL) { if (textView != NULL) {
BRect rect = scrollView->Frame(); BRect rect = scrollView->Frame();
@@ -343,8 +346,8 @@ BTextWidget::StartEdit(BRect bounds, BPoseView* view, BPose* pose)
BFont font; BFont font;
view->GetFont(&font); view->GetFont(&font);
BTextView* textView = new BTextView(rect, "WidgetTextView", textRect, &font, 0, BTextView* textView = new BTextView(rect, "WidgetTextView", textRect,
B_FOLLOW_ALL, B_WILL_DRAW); &font, 0, B_FOLLOW_ALL, B_WILL_DRAW);
textView->SetWordWrap(false); textView->SetWordWrap(false);
DisallowMetaKeys(textView); DisallowMetaKeys(textView);
@@ -375,8 +378,8 @@ BTextWidget::StartEdit(BRect bounds, BPoseView* view, BPose* pose)
textView->MoveTo(rect.LeftTop()); textView->MoveTo(rect.LeftTop());
textView->ResizeTo(rect.Width(), rect.Height()); textView->ResizeTo(rect.Width(), rect.Height());
BScrollView* scrollView = new BScrollView("BorderView", textView, 0, 0, false, BScrollView* scrollView = new BScrollView("BorderView", textView, 0, 0,
false, B_PLAIN_BORDER); false, false, B_PLAIN_BORDER);
view->AddChild(scrollView); view->AddChild(scrollView);
// configure text view // configure text view
@@ -406,9 +409,10 @@ BTextWidget::StartEdit(BRect bounds, BPoseView* view, BPose* pose)
ASSERT(view->Window()); // how can I not have a Window here??? ASSERT(view->Window()); // how can I not have a Window here???
if (view->Window()) if (view->Window()) {
// force immediate redraw so TextView appears instantly // force immediate redraw so TextView appears instantly
view->Window()->UpdateIfNeeded(); view->Window()->UpdateIfNeeded();
}
} }
@@ -422,7 +426,8 @@ BTextWidget::StopEdit(bool saveChanges, BPoint poseLoc, BPoseView* view,
if (!scrollView) if (!scrollView)
return; return;
BTextView* textView = dynamic_cast<BTextView*>(scrollView->FindView("WidgetTextView")); BTextView* textView = dynamic_cast<BTextView*>(
scrollView->FindView("WidgetTextView"));
ASSERT(textView); ASSERT(textView);
if (!textView) if (!textView)
return; return;
@@ -454,8 +459,8 @@ BTextWidget::StopEdit(bool saveChanges, BPoint poseLoc, BPoseView* view,
void void
BTextWidget::CheckAndUpdate(BPoint loc, const BColumn* column, BPoseView* view, BTextWidget::CheckAndUpdate(BPoint loc, const BColumn* column,
bool visible) BPoseView* view, bool visible)
{ {
BRect oldRect; BRect oldRect;
if (view->ViewMode() != kListMode) if (view->ViewMode() != kListMode)
@@ -474,7 +479,8 @@ BTextWidget::CheckAndUpdate(BPoint loc, const BColumn* column, BPoseView* view,
void void
BTextWidget::SelectAll(BPoseView* view) BTextWidget::SelectAll(BPoseView* view)
{ {
BTextView* text = dynamic_cast<BTextView*>(view->FindView("WidgetTextView")); BTextView* text = dynamic_cast<BTextView*>(
view->FindView("WidgetTextView"));
if (text) if (text)
text->SelectAll(); text->SelectAll();
} }
@@ -482,7 +488,8 @@ BTextWidget::SelectAll(BPoseView* view)
void void
BTextWidget::Draw(BRect eraseRect, BRect textRect, float, BPoseView* view, BTextWidget::Draw(BRect eraseRect, BRect textRect, float, BPoseView* view,
BView* drawView, bool selected, uint32 clipboardMode, BPoint offset, bool direct) BView* drawView, bool selected, uint32 clipboardMode, BPoint offset,
bool direct)
{ {
textRect.OffsetBy(offset); textRect.OffsetBy(offset);
+4 -2
View File
@@ -52,7 +52,8 @@ public:
void Draw(BRect widgetRect, BRect widgetTextRect, float width, BPoseView*, void Draw(BRect widgetRect, BRect widgetTextRect, float width, BPoseView*,
bool selected, uint32 clipboardMode); bool selected, uint32 clipboardMode);
void Draw(BRect widgetRect, BRect widgetTextRect, float width, BPoseView*, void Draw(BRect widgetRect, BRect widgetTextRect, float width, BPoseView*,
BView* drawView, bool selected, uint32 clipboardMode, BPoint offset, bool direct); BView* drawView, bool selected, uint32 clipboardMode, BPoint offset,
bool direct);
// second call is used for offscreen drawing, where PoseView // second call is used for offscreen drawing, where PoseView
// and current drawing view are different // and current drawing view are different
@@ -72,7 +73,8 @@ public:
// we can invalidate properly // we can invalidate properly
void StartEdit(BRect bounds, BPoseView*, BPose*); void StartEdit(BRect bounds, BPoseView*, BPose*);
void StopEdit(bool saveChanges, BPoint loc, BPoseView*, BPose*, int32 index); void StopEdit(bool saveChanges, BPoint loc, BPoseView*, BPose*,
int32 index);
void SelectAll(BPoseView* view); void SelectAll(BPoseView* view);
void CheckAndUpdate(BPoint, const BColumn*, BPoseView*, bool visible); void CheckAndUpdate(BPoint, const BColumn*, BPoseView*, bool visible);
+4 -2
View File
@@ -103,7 +103,8 @@ Thread::Run()
void void
ThreadSequence::Launch(BObjectList<FunctionObject>* list, bool async, int32 priority) ThreadSequence::Launch(BObjectList<FunctionObject>* list, bool async,
int32 priority)
{ {
if (!async) { if (!async) {
// if not async, don't even create a thread, just do it right away // if not async, don't even create a thread, just do it right away
@@ -113,7 +114,8 @@ ThreadSequence::Launch(BObjectList<FunctionObject>* list, bool async, int32 prio
} }
ThreadSequence::ThreadSequence(BObjectList<FunctionObject>* list, int32 priority) ThreadSequence::ThreadSequence(BObjectList<FunctionObject>* list,
int32 priority)
: SimpleThread(priority), : SimpleThread(priority),
fFunctorList(list) fFunctorList(list)
{ {
+18 -9
View File
@@ -95,9 +95,11 @@ private:
// would use SingleParamFunctionObjectWithResult, except mwcc won't handle this // would use SingleParamFunctionObjectWithResult, except mwcc won't handle this
template <class Param1> template <class Param1>
class SingleParamFunctionObjectWorkaround : public FunctionObjectWithResult<status_t> { class SingleParamFunctionObjectWorkaround : public
FunctionObjectWithResult<status_t> {
public: public:
SingleParamFunctionObjectWorkaround(status_t (*function)(Param1), Param1 param1) SingleParamFunctionObjectWorkaround(
status_t (*function)(Param1), Param1 param1)
: fFunction(function), : fFunction(function),
fParam1(param1) fParam1(param1)
{ {
@@ -115,7 +117,8 @@ private:
}; };
template <class T> template <class T>
class SimpleMemberFunctionObjectWorkaround : public FunctionObjectWithResult<status_t> { class SimpleMemberFunctionObjectWorkaround : public
FunctionObjectWithResult<status_t> {
public: public:
SimpleMemberFunctionObjectWorkaround(status_t (T::*function)(), T* onThis) SimpleMemberFunctionObjectWorkaround(status_t (T::*function)(), T* onThis)
: fFunction(function), : fFunction(function),
@@ -135,7 +138,8 @@ private:
template <class Param1, class Param2> template <class Param1, class Param2>
class TwoParamFunctionObjectWorkaround : public FunctionObjectWithResult<status_t> { class TwoParamFunctionObjectWorkaround : public
FunctionObjectWithResult<status_t> {
public: public:
TwoParamFunctionObjectWorkaround(status_t (*callThis)(Param1, Param2), TwoParamFunctionObjectWorkaround(status_t (*callThis)(Param1, Param2),
Param1 param1, Param2 param2) Param1 param1, Param2 param2)
@@ -158,9 +162,11 @@ private:
template <class Param1, class Param2, class Param3> template <class Param1, class Param2, class Param3>
class ThreeParamFunctionObjectWorkaround : public FunctionObjectWithResult<status_t> { class ThreeParamFunctionObjectWorkaround : public
FunctionObjectWithResult<status_t> {
public: public:
ThreeParamFunctionObjectWorkaround(status_t (*callThis)(Param1, Param2, Param3), ThreeParamFunctionObjectWorkaround(
status_t (*callThis)(Param1, Param2, Param3),
Param1 param1, Param2 param2, Param3 param3) Param1 param1, Param2 param2, Param3 param3)
: function(callThis), : function(callThis),
fParam1(param1), fParam1(param1),
@@ -183,9 +189,11 @@ private:
template <class Param1, class Param2, class Param3, class Param4> template <class Param1, class Param2, class Param3, class Param4>
class FourParamFunctionObjectWorkaround : public FunctionObjectWithResult<status_t> { class FourParamFunctionObjectWorkaround : public
FunctionObjectWithResult<status_t> {
public: public:
FourParamFunctionObjectWorkaround(status_t (*callThis)(Param1, Param2, Param3, Param4), FourParamFunctionObjectWorkaround(
status_t (*callThis)(Param1, Param2, Param3, Param4),
Param1 param1, Param2 param2, Param3 param3, Param4 param4) Param1 param1, Param2 param2, Param3 param3, Param4 param4)
: function(callThis), : function(callThis),
fParam1(param1), fParam1(param1),
@@ -267,7 +275,8 @@ template<class View>
class MouseDownThread { class MouseDownThread {
public: public:
static void TrackMouse(View* view, void (View::*)(BPoint), static void TrackMouse(View* view, void (View::*)(BPoint),
void (View::*)(BPoint, uint32) = 0, bigtime_t pressingPeriod = 100000); void (View::*)(BPoint, uint32) = 0,
bigtime_t pressingPeriod = 100000);
protected: protected:
MouseDownThread(View* view, void (View::*)(BPoint), MouseDownThread(View* view, void (View::*)(BPoint),
+50 -27
View File
@@ -109,7 +109,8 @@ BTitleView::BTitleView(BRect frame, BPoseView* view)
fPreviouslyClickedColumnTitle(0), fPreviouslyClickedColumnTitle(0),
fTrackingState(NULL) fTrackingState(NULL)
{ {
sTitleBackground = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), 0.88f); // 216 -> 220 sTitleBackground = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), 0.88f);
// 216 -> 220
sDarkTitleBackground = tint_color(sTitleBackground, B_DARKEN_1_TINT); sDarkTitleBackground = tint_color(sTitleBackground, B_DARKEN_1_TINT);
sShineColor = tint_color(sTitleBackground, B_LIGHTEN_MAX_TINT); sShineColor = tint_color(sTitleBackground, B_LIGHTEN_MAX_TINT);
sLightShadowColor = tint_color(sTitleBackground, B_DARKEN_2_TINT); sLightShadowColor = tint_color(sTitleBackground, B_DARKEN_2_TINT);
@@ -210,9 +211,8 @@ BTitleView::Draw(BRect /*updateRect*/, bool useOffscreen, bool updateOnly,
ASSERT(sOffscreen); ASSERT(sOffscreen);
BRect frame(bounds); BRect frame(bounds);
frame.right += frame.left; frame.right += frame.left;
// this is kind of messy way of avoiding being clipped by the ammount the // ToDo: this is kind of messy way of avoiding being clipped
// title is scrolled to the left // by the amount the title is scrolled to the left
// ToDo: fix this
view = sOffscreen->BeginUsing(frame); view = sOffscreen->BeginUsing(frame);
view->SetOrigin(-bounds.left, 0); view->SetOrigin(-bounds.left, 0);
view->SetLowColor(LowColor()); view->SetLowColor(LowColor());
@@ -238,10 +238,12 @@ BTitleView::Draw(BRect /*updateRect*/, bool useOffscreen, bool updateOnly,
view->BeginLineArray(4); view->BeginLineArray(4);
view->AddLine(bounds.LeftTop(), bounds.RightTop(), sShadowColor); view->AddLine(bounds.LeftTop(), bounds.RightTop(), sShadowColor);
view->AddLine(bounds.LeftBottom(), bounds.RightBottom(), sShadowColor); view->AddLine(bounds.LeftBottom(), bounds.RightBottom(),
sShadowColor);
// draw lighter gray and white inset lines // draw lighter gray and white inset lines
bounds.InsetBy(0, 1); bounds.InsetBy(0, 1);
view->AddLine(bounds.LeftBottom(), bounds.RightBottom(), sLightShadowColor); view->AddLine(bounds.LeftBottom(), bounds.RightBottom(),
sLightShadowColor);
view->AddLine(bounds.LeftTop(), bounds.RightTop(), sShineColor); view->AddLine(bounds.LeftTop(), bounds.RightTop(), sShineColor);
view->EndLineArray(); view->EndLineArray();
} }
@@ -263,7 +265,8 @@ BTitleView::Draw(BRect /*updateRect*/, bool useOffscreen, bool updateOnly,
bounds = Bounds(); bounds = Bounds();
minx--; minx--;
view->SetHighColor(sLightShadowColor); view->SetHighColor(sLightShadowColor);
view->StrokeLine(BPoint(minx, bounds.top), BPoint(minx, bounds.bottom - 1)); view->StrokeLine(BPoint(minx, bounds.top),
BPoint(minx, bounds.bottom - 1));
} else { } else {
// first and last shades before and after first column // first and last shades before and after first column
maxx++; maxx++;
@@ -277,8 +280,10 @@ BTitleView::Draw(BRect /*updateRect*/, bool useOffscreen, bool updateOnly,
} }
#if !(APP_SERVER_CLEARS_BACKGROUND) #if !(APP_SERVER_CLEARS_BACKGROUND)
FillRect(BRect(bounds.left, bounds.top + 1, minx - 1, bounds.bottom - 1), B_SOLID_LOW); FillRect(BRect(bounds.left, bounds.top + 1, minx - 1, bounds.bottom - 1),
FillRect(BRect(maxx + 1, bounds.top + 1, bounds.right, bounds.bottom - 1), B_SOLID_LOW); B_SOLID_LOW);
FillRect(BRect(maxx + 1, bounds.top + 1, bounds.right, bounds.bottom - 1),
B_SOLID_LOW);
#endif #endif
if (useOffscreen) { if (useOffscreen) {
@@ -334,8 +339,10 @@ BTitleView::MouseDown(BPoint where)
bool force = static_cast<bool>(buttons & B_TERTIARY_MOUSE_BUTTON); bool force = static_cast<bool>(buttons & B_TERTIARY_MOUSE_BUTTON);
if (force || buttons & B_PRIMARY_MOUSE_BUTTON) { if (force || buttons & B_PRIMARY_MOUSE_BUTTON) {
if (force || fPreviouslyClickedColumnTitle != 0) { if (force || fPreviouslyClickedColumnTitle != 0) {
if (force || system_time() - fPreviousLeftClickTime < doubleClickSpeed) { if (force || system_time() - fPreviousLeftClickTime
if (fPoseView->ResizeColumnToWidest(resizedTitle->Column())) { < doubleClickSpeed) {
if (fPoseView->
ResizeColumnToWidest(resizedTitle->Column())) {
Invalidate(); Invalidate();
return; return;
} }
@@ -347,7 +354,8 @@ BTitleView::MouseDown(BPoint where)
} else if (!title) } else if (!title)
return; return;
SetMouseEventMask(B_POINTER_EVENTS, B_NO_POINTER_HISTORY | B_LOCK_WINDOW_FOCUS); SetMouseEventMask(B_POINTER_EVENTS,
B_NO_POINTER_HISTORY | B_LOCK_WINDOW_FOCUS);
// track the mouse // track the mouse
if (resizedTitle) { if (resizedTitle) {
@@ -467,7 +475,8 @@ BColumnTitle::InColumnResizeArea(BPoint where) const
BRect BRect
BColumnTitle::Bounds() const BColumnTitle::Bounds() const
{ {
BRect bounds(fColumn->Offset() - kTitleColumnLeftExtraMargin, 0, 0, kTitleViewHeight); BRect bounds(fColumn->Offset() - kTitleColumnLeftExtraMargin, 0, 0,
kTitleViewHeight);
bounds.right = bounds.left + fColumn->Width() + kTitleColumnExtraMargin; bounds.right = bounds.left + fColumn->Width() + kTitleColumnExtraMargin;
return bounds; return bounds;
@@ -512,7 +521,8 @@ BColumnTitle::Draw(BView* view, bool pressed)
break; break;
case B_ALIGN_RIGHT: case B_ALIGN_RIGHT:
loc.x = bounds.right - resultingWidth - kTitleColumnRightExtraMargin; loc.x = bounds.right - resultingWidth
- kTitleColumnRightExtraMargin;
break; break;
} }
@@ -520,8 +530,10 @@ BColumnTitle::Draw(BView* view, bool pressed)
view->DrawString(titleString.String(), loc); view->DrawString(titleString.String(), loc);
// show sort columns // show sort columns
bool secondary = (fColumn->AttrHash() == fParent->PoseView()->SecondarySort()); bool secondary
if (secondary || (fColumn->AttrHash() == fParent->PoseView()->PrimarySort())) { = (fColumn->AttrHash() == fParent->PoseView()->SecondarySort());
if (secondary
|| (fColumn->AttrHash() == fParent->PoseView()->PrimarySort())) {
BPoint center(loc.x - 6, roundf((bounds.top + bounds.bottom) / 2.0)); BPoint center(loc.x - 6, roundf((bounds.top + bounds.bottom) / 2.0));
BPoint triangle[3]; BPoint triangle[3];
@@ -539,10 +551,12 @@ BColumnTitle::Draw(BView* view, bool pressed)
view->SetFlags(flags | B_SUBPIXEL_PRECISE); view->SetFlags(flags | B_SUBPIXEL_PRECISE);
if (secondary) { if (secondary) {
view->SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), 1.3)); view->SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
1.3));
view->FillTriangle(triangle[0], triangle[1], triangle[2]); view->FillTriangle(triangle[0], triangle[1], triangle[2]);
} else { } else {
view->SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), 1.6)); view->SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
1.6));
view->FillTriangle(triangle[0], triangle[1], triangle[2]); view->FillTriangle(triangle[0], triangle[1], triangle[2]);
} }
@@ -626,7 +640,8 @@ ColumnResizeState::ColumnResizeState(BTitleView* view, BColumnTitle* title,
BPoint where, bigtime_t pastClickTime) BPoint where, bigtime_t pastClickTime)
: ColumnTrackState(view, title, where, pastClickTime), : ColumnTrackState(view, title, where, pastClickTime),
fLastLineDrawPos(-1), fLastLineDrawPos(-1),
fInitialTrackOffset((title->fColumn->Offset() + title->fColumn->Width()) - where.x) fInitialTrackOffset((title->fColumn->Offset() + title->fColumn->Width())
- where.x)
{ {
DrawLine(); DrawLine();
} }
@@ -635,7 +650,8 @@ ColumnResizeState::ColumnResizeState(BTitleView* view, BColumnTitle* title,
bool bool
ColumnResizeState::ValueChanged(BPoint where) ColumnResizeState::ValueChanged(BPoint where)
{ {
float newWidth = where.x + fInitialTrackOffset - fTitle->fColumn->Offset(); float newWidth = where.x + fInitialTrackOffset
- fTitle->fColumn->Offset();
if (newWidth < kMinColumnWidth) if (newWidth < kMinColumnWidth)
newWidth = kMinColumnWidth; newWidth = kMinColumnWidth;
@@ -646,7 +662,8 @@ ColumnResizeState::ValueChanged(BPoint where)
void void
ColumnResizeState::Moved(BPoint where, uint32) ColumnResizeState::Moved(BPoint where, uint32)
{ {
float newWidth = where.x + fInitialTrackOffset - fTitle->fColumn->Offset(); float newWidth = where.x + fInitialTrackOffset
- fTitle->fColumn->Offset();
if (newWidth < kMinColumnWidth) if (newWidth < kMinColumnWidth)
newWidth = kMinColumnWidth; newWidth = kMinColumnWidth;
@@ -692,7 +709,8 @@ ColumnResizeState::DrawLine()
fLastLineDrawPos = poseViewBounds.left; fLastLineDrawPos = poseViewBounds.left;
// draw the line in the new location // draw the line in the new location
_DrawLine(poseView, poseViewBounds.LeftTop(), poseViewBounds.LeftBottom()); _DrawLine(poseView, poseViewBounds.LeftTop(),
poseViewBounds.LeftBottom());
} }
@@ -740,7 +758,8 @@ ColumnDragState::Moved(BPoint where, uint32)
? fTitleView->FindColumnTitle(where) : 0; ? fTitleView->FindColumnTitle(where) : 0;
BRect titleBoundsWithMargin(titleBounds); BRect titleBoundsWithMargin(titleBounds);
titleBoundsWithMargin.InsetBy(0, -kRemoveTitleMargin); titleBoundsWithMargin.InsetBy(0, -kRemoveTitleMargin);
bool inMarginRect = overTitleView || titleBoundsWithMargin.Contains(where); bool inMarginRect = overTitleView
|| titleBoundsWithMargin.Contains(where);
bool drawOutline = false; bool drawOutline = false;
bool undrawOutline = false; bool undrawOutline = false;
@@ -773,7 +792,8 @@ ColumnDragState::Moved(BPoint where, uint32)
fColumnArchive.Seek(0, SEEK_SET); fColumnArchive.Seek(0, SEEK_SET);
fTitle->Column()->ArchiveToStream(&fColumnArchive); fTitle->Column()->ArchiveToStream(&fColumnArchive);
fInitialMouseTrackOffset -= fTitle->Bounds().left; fInitialMouseTrackOffset -= fTitle->Bounds().left;
if (fTitleView->PoseView()->RemoveColumn(fTitle->Column(), false)) { if (fTitleView->PoseView()->RemoveColumn(fTitle->Column(),
false)) {
fTitle = 0; fTitle = 0;
fTitleView->BeginRectTracking(rect); fTitleView->BeginRectTracking(rect);
fTrackingRemovedColumn = true; fTrackingRemovedColumn = true;
@@ -783,8 +803,10 @@ ColumnDragState::Moved(BPoint where, uint32)
// over a different column // over a different column
&& (overTitle->Bounds().left >= fTitle->Bounds().right && (overTitle->Bounds().left >= fTitle->Bounds().right
// over the one to the right // over the one to the right
|| where.x < overTitle->Bounds().left + fTitle->Bounds().Width())){ || where.x < overTitle->Bounds().left
// over the one to the left, far enough to not snap right back + fTitle->Bounds().Width())) {
// over the one to the left, far enough to not snap
// right back
BColumn* column = fTitle->Column(); BColumn* column = fTitle->Column();
fInitialMouseTrackOffset -= fTitle->Bounds().left; fInitialMouseTrackOffset -= fTitle->Bounds().left;
@@ -873,7 +895,8 @@ ColumnDragState::DrawOutline(float pos)
{ {
BRect outline(fTitle->Bounds()); BRect outline(fTitle->Bounds());
outline.OffsetBy(pos, 0); outline.OffsetBy(pos, 0);
fTitleView->Draw(fTitleView->Bounds(), true, false, fTitle, _DrawOutline, outline); fTitleView->Draw(fTitleView->Bounds(), true, false, fTitle, _DrawOutline,
outline);
} }
+75 -46
View File
@@ -160,8 +160,8 @@ InitIconPreloader()
if (IconCache::sIconCache != NULL) if (IconCache::sIconCache != NULL)
return; return;
// only start the node preloader if its Tracker or the Deskbar itself - don't // only start the node preloader if its Tracker or the Deskbar itself,
// start it for file panels // don't start it for file panels
bool preload = dynamic_cast<TTracker*>(be_app) != NULL; bool preload = dynamic_cast<TTracker*>(be_app) != NULL;
if (!preload) { if (!preload) {
@@ -171,8 +171,11 @@ InitIconPreloader()
&& !strcmp(info.signature, kDeskbarSignature)) && !strcmp(info.signature, kDeskbarSignature))
preload = true; preload = true;
} }
if (preload)
gPreloader = NodePreloader::InstallNodePreloader("NodePreloader", be_app); if (preload) {
gPreloader = NodePreloader::InstallNodePreloader("NodePreloader",
be_app);
}
IconCache::sIconCache = new IconCache(); IconCache::sIconCache = new IconCache();
@@ -245,7 +248,8 @@ TTracker::TTracker()
SetMallocLeakChecking(true); SetMallocLeakChecking(true);
#endif #endif
//This is how often it should update the free space bar on the volume icons // This is how often it should update the free space bar on the
// volume icons
SetPulseRate(1000000); SetPulseRate(1000000);
gLaunchLooper = new LaunchLooper(); gLaunchLooper = new LaunchLooper();
@@ -302,25 +306,33 @@ TTracker::QuitRequested()
BEntry entry; BEntry entry;
BPath path; BPath path;
const entry_ref* ref = window->TargetModel()->EntryRef(); const entry_ref* ref = window->TargetModel()->EntryRef();
if (entry.SetTo(ref) == B_OK && entry.GetPath(&path) == B_OK) { if (entry.SetTo(ref) == B_OK
int8 flags = window->IsMinimized() ? kOpenWindowMinimized : kOpenWindowNoFlags; && entry.GetPath(&path) == B_OK) {
uint32 deviceFlags = GetVolumeFlags(window->TargetModel()); int8 flags = window->IsMinimized()
? kOpenWindowMinimized : kOpenWindowNoFlags;
uint32 deviceFlags
= GetVolumeFlags(window->TargetModel());
// save state for every window which is // save state for every window which is
// a) already open on another workspace // a) already open on another workspace
// b) on a volume not capable of writing attributes // b) on a volume not capable of writing attributes
if (window != FindContainerWindow(ref) if (window != FindContainerWindow(ref)
|| (deviceFlags & (B_FS_HAS_ATTR | B_FS_IS_READONLY)) != B_FS_HAS_ATTR) { || (deviceFlags
& (B_FS_HAS_ATTR | B_FS_IS_READONLY))
!= B_FS_HAS_ATTR) {
BMessage stateMessage; BMessage stateMessage;
window->SaveState(stateMessage); window->SaveState(stateMessage);
window->SetSaveStateEnabled(false); window->SetSaveStateEnabled(false);
// This is to prevent its state to be saved to the node when closed. // This is to prevent its state to be saved
// to the node when closed.
message.AddMessage("window state", &stateMessage); message.AddMessage("window state", &stateMessage);
flags |= kOpenWindowHasState; flags |= kOpenWindowHasState;
} }
const char* target; const char* target;
bool pathAlreadyExists = false; bool pathAlreadyExists = false;
for (int32 index = 0;message.FindString("paths", index, &target) == B_OK;index++) { for (int32 index = 0;
message.FindString("paths", index, &target)
== B_OK; index++) {
if (!strcmp(target,path.Path())) { if (!strcmp(target,path.Path())) {
pathAlreadyExists = true; pathAlreadyExists = true;
break; break;
@@ -345,7 +357,8 @@ TTracker::QuitRequested()
size_t size = (size_t)message.FlattenedSize(); size_t size = (size_t)message.FlattenedSize();
char* buffer = new char[size]; char* buffer = new char[size];
message.Flatten(buffer, (ssize_t)size); message.Flatten(buffer, (ssize_t)size);
deskDir.WriteAttr(kAttrOpenWindows, B_MESSAGE_TYPE, 0, buffer, size); deskDir.WriteAttr(kAttrOpenWindows, B_MESSAGE_TYPE, 0, buffer,
size);
delete [] buffer; delete [] buffer;
} else } else
deskDir.RemoveAttr(kAttrOpenWindows); deskDir.RemoveAttr(kAttrOpenWindows);
@@ -446,8 +459,8 @@ TTracker::MessageReceived(BMessage* message)
// Someone (probably the deskbar) has requested a list of // Someone (probably the deskbar) has requested a list of
// mountable volumes. // mountable volumes.
BMessage reply; BMessage reply;
AutoMounterLoop()->EachMountableItemAndFloppy(&AddMountableItemToMessage, AutoMounterLoop()->EachMountableItemAndFloppy(
&reply); &AddMountableItemToMessage, &reply);
message->SendReply(&reply); message->SendReply(&reply);
break; break;
} }
@@ -550,7 +563,8 @@ TTracker::SetDefaultPrinter(const BMessage* message)
if (count <= 0) if (count <= 0)
return; return;
// will make the first item the default printer, disregards any other files // will make the first item the default printer, disregards any
// other files
entry_ref ref; entry_ref ref;
ASSERT(message->FindRef("refs", 0, &ref) == B_OK); ASSERT(message->FindRef("refs", 0, &ref) == B_OK);
if (message->FindRef("refs", 0, &ref) != B_OK) if (message->FindRef("refs", 0, &ref) != B_OK)
@@ -610,10 +624,12 @@ TTracker::MoveRefsToTrash(const BMessage* message)
template <class T, class FT> template <class T, class FT>
class EntryAndNodeDoSoonWithMessageFunctor : public FunctionObjectWithResult<bool> { class EntryAndNodeDoSoonWithMessageFunctor : public
FunctionObjectWithResult<bool> {
public: public:
EntryAndNodeDoSoonWithMessageFunctor(FT func, T* target, const entry_ref* child, EntryAndNodeDoSoonWithMessageFunctor(FT func, T* target,
const node_ref* parent, const BMessage* message) const entry_ref* child, const node_ref* parent,
const BMessage* message)
: fFunc(func), : fFunc(func),
fTarget(target), fTarget(target),
fNode(*parent), fNode(*parent),
@@ -625,8 +641,10 @@ public:
} }
virtual ~EntryAndNodeDoSoonWithMessageFunctor() {} virtual ~EntryAndNodeDoSoonWithMessageFunctor() {}
virtual void operator()() virtual void operator()() {
{ result = (fTarget->*fFunc)(&fEntry, &fNode, fSendMessage ? &fMessage : NULL); } result = (fTarget->*fFunc)(&fEntry, &fNode,
fSendMessage ? &fMessage : NULL);
}
protected: protected:
FT fFunc; FT fFunc;
@@ -651,8 +669,8 @@ TTracker::LaunchAndCloseParentIfOK(const entry_ref* launchThis,
// synchronous launch, we are already in our own thread // synchronous launch, we are already in our own thread
if (TrackerLaunch(&refsReceived, false) == B_OK) { if (TrackerLaunch(&refsReceived, false) == B_OK) {
// if launched fine, close parent window in a bit // if launched fine, close parent window in a bit
fTaskLoop->RunLater(NewMemberFunctionObject(&TTracker::CloseParent, this, *closeThis), fTaskLoop->RunLater(NewMemberFunctionObject(&TTracker::CloseParent,
1000000); this, *closeThis), 1000000);
} }
return false; return false;
} }
@@ -674,15 +692,18 @@ TTracker::OpenRef(const entry_ref* ref, const node_ref* nodeToClose,
model = new Model(ref, false); model = new Model(ref, false);
if (model->IsSymLink() && !model->LinkTo()) { if (model->IsSymLink() && !model->LinkTo()) {
model->GetPreferredAppForBrokenSymLink(brokenLinkPreferredApp); model->GetPreferredAppForBrokenSymLink(brokenLinkPreferredApp);
if (brokenLinkPreferredApp.Length() && brokenLinkPreferredApp != kTrackerSignature) if (brokenLinkPreferredApp.Length()
&& brokenLinkPreferredApp != kTrackerSignature) {
brokenLinkWithSpecificHandler = true; brokenLinkWithSpecificHandler = true;
} }
}
if (!brokenLinkWithSpecificHandler) { if (!brokenLinkWithSpecificHandler) {
delete model; delete model;
BAlert* alert = new BAlert("", BAlert* alert = new BAlert("",
B_TRANSLATE("There was an error resolving the link."), B_TRANSLATE("There was an error resolving the link."),
B_TRANSLATE("Cancel"), 0, 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT); B_TRANSLATE("Cancel"), 0, 0, B_WIDTH_AS_USUAL,
B_WARNING_ALERT);
alert->SetShortcut(0, B_ESCAPE); alert->SetShortcut(0, B_ESCAPE);
alert->Go(); alert->Go();
return result; return result;
@@ -715,7 +736,8 @@ TTracker::OpenRef(const entry_ref* ref, const node_ref* nodeToClose,
if (openAsContainer || selector == kRunOpenWithWindow) { if (openAsContainer || selector == kRunOpenWithWindow) {
// special case opening plain folders, queries or using open with // special case opening plain folders, queries or using open with
OpenContainerWindow(model, 0, selector, kRestoreDecor); // window adopts model OpenContainerWindow(model, 0, selector, kRestoreDecor);
// window adopts model
if (nodeToClose) if (nodeToClose)
CloseParentWaitingForChildSoon(ref, nodeToClose); CloseParentWaitingForChildSoon(ref, nodeToClose);
} else if (model->IsQueryTemplate()) { } else if (model->IsQueryTemplate()) {
@@ -742,8 +764,9 @@ TTracker::OpenRef(const entry_ref* ref, const node_ref* nodeToClose,
} }
refsReceived.AddRef("refs", ref); refsReceived.AddRef("refs", ref);
if (brokenLinkWithSpecificHandler) if (brokenLinkWithSpecificHandler)
// This cruft is to support a hacky workaround for double-clicking // This cruft is to support a hacky workaround for
// broken refs for cifs; should get fixed in R5 // double-clicking broken refs for cifs; should get fixed
// in R5
LaunchBrokenLink(brokenLinkPreferredApp.String(), &refsReceived); LaunchBrokenLink(brokenLinkPreferredApp.String(), &refsReceived);
else else
TrackerLaunch(&refsReceived, true); TrackerLaunch(&refsReceived, true);
@@ -779,13 +802,13 @@ TTracker::RefsReceived(BMessage* message)
case kOpenWith: case kOpenWith:
{ {
// Open With resulted in passing refs and a handler, open the files // Open With resulted in passing refs and a handler,
// with the handling app // open the files with the handling app
message->RemoveName("handler"); message->RemoveName("handler");
// have to find out if handling app is the Tracker // have to find out if handling app is the Tracker
// if it is, just pass it to the active Tracker, no matter which Tracker // if it is, just pass it to the active Tracker,
// was chosen to handle the refs // no matter which Tracker was chosen to handle the refs
char signature[B_MIME_TYPE_LENGTH]; char signature[B_MIME_TYPE_LENGTH];
signature[0] = '\0'; signature[0] = '\0';
{ {
@@ -795,20 +818,21 @@ TTracker::RefsReceived(BMessage* message)
} }
if (strcasecmp(signature, kTrackerSignature) != 0) { if (strcasecmp(signature, kTrackerSignature) != 0) {
// handling app not Tracker, pass entries to the apps RefsReceived // handling app not Tracker, pass entries to the apps
// RefsReceived
TrackerLaunch(&handlingApp, message, true); TrackerLaunch(&handlingApp, message, true);
break; break;
} }
// fall thru, opening refs by the Tracker, as if they were double clicked } // fall thru, opening refs by the Tracker as if they were
} // double-clicked
case kOpen: case kOpen:
{ {
// copy over "Poses" messenger so that refs received recipients know // copy over "Poses" messenger so that refs received
// where the open came from // recipients know where the open came from
BMessage* bundleThis = NULL; BMessage* bundleThis = NULL;
BMessenger messenger; BMessenger messenger;
if (message->FindMessenger("TrackerViewToken", &messenger) == B_OK) { if (message->FindMessenger("TrackerViewToken", &messenger)
== B_OK) {
bundleThis = new BMessage(); bundleThis = new BMessage();
bundleThis->AddMessenger("TrackerViewToken", messenger); bundleThis->AddMessenger("TrackerViewToken", messenger);
} }
@@ -826,7 +850,8 @@ TTracker::RefsReceived(BMessage* message)
message->FindData("nodeRefToSelect", B_RAW_TYPE, index, message->FindData("nodeRefToSelect", B_RAW_TYPE, index,
(const void**)&nodeToSelect, &numBytes); (const void**)&nodeToSelect, &numBytes);
OpenRef(&ref, nodeToClose, nodeToSelect, selector, bundleThis); OpenRef(&ref, nodeToClose, nodeToSelect, selector,
bundleThis);
} }
delete bundleThis; delete bundleThis;
@@ -1104,8 +1129,8 @@ TTracker::QueryActiveForDevice(dev_t device)
void void
TTracker::CloseActiveQueryWindows(dev_t device) TTracker::CloseActiveQueryWindows(dev_t device)
{ {
// used when trying to unmount a volume - an active query would prevent that from // used when trying to unmount a volume - an active query would prevent
// happening // that from happening
bool closed = false; bool closed = false;
AutoLock<WindowList> lock(fWindowList); AutoLock<WindowList> lock(fWindowList);
for (int32 index = fWindowList.CountItems(); index >= 0; index--) { for (int32 index = fWindowList.CountItems(); index >= 0; index--) {
@@ -1136,7 +1161,8 @@ TTracker::SaveAllPoseLocations()
int32 numWindows = fWindowList.CountItems(); int32 numWindows = fWindowList.CountItems();
for (int32 windowIndex = 0; windowIndex < numWindows; windowIndex++) { for (int32 windowIndex = 0; windowIndex < numWindows; windowIndex++) {
BContainerWindow* window BContainerWindow* window
= dynamic_cast<BContainerWindow*>(fWindowList.ItemAt(windowIndex)); = dynamic_cast<BContainerWindow*>
(fWindowList.ItemAt(windowIndex));
if (window) { if (window) {
AutoLock<BWindow> lock(window); AutoLock<BWindow> lock(window);
@@ -1281,9 +1307,10 @@ TTracker::_OpenPreviouslyOpenedWindows(const char* pathFilter)
BMessage state; BMessage state;
bool restoreStateFromMessage = false; bool restoreStateFromMessage = false;
if ((flags & kOpenWindowHasState) != 0 if ((flags & kOpenWindowHasState) != 0
&& message.FindMessage("window state", stateMessageCounter++, && message.FindMessage("window state",
&state) == B_OK) stateMessageCounter++, &state) == B_OK) {
restoreStateFromMessage = true; restoreStateFromMessage = true;
}
if (restoreStateFromMessage) { if (restoreStateFromMessage) {
OpenContainerWindow(model, 0, kOpen, kRestoreWorkspace OpenContainerWindow(model, 0, kOpen, kRestoreWorkspace
@@ -1356,7 +1383,8 @@ TTracker::ReadyToRun()
message.AddInt32("opcode", B_ENTRY_CREATED); message.AddInt32("opcode", B_ENTRY_CREATED);
message.AddInt32("device", model.NodeRef()->device); message.AddInt32("device", model.NodeRef()->device);
message.AddInt64("node", model.NodeRef()->node); message.AddInt64("node", model.NodeRef()->node);
message.AddInt64("directory", model.EntryRef()->directory); message.AddInt64("directory",
model.EntryRef()->directory);
message.AddString("name", model.EntryRef()->name); message.AddString("name", model.EntryRef()->name);
deskWindow->PostMessage(&message, deskWindow->PoseView()); deskWindow->PostMessage(&message, deskWindow->PoseView());
} }
@@ -1426,9 +1454,10 @@ TTracker::CloseParentWaitingForChild(const entry_ref* child,
AutoLock<WindowList> lock(&fWindowList); AutoLock<WindowList> lock(&fWindowList);
BContainerWindow* parentWindow = FindContainerWindow(parent); BContainerWindow* parentWindow = FindContainerWindow(parent);
if (!parentWindow) if (!parentWindow) {
// parent window already closed, give up // parent window already closed, give up
return true; return true;
}
// If child is a symbolic link, dereference it, so that // If child is a symbolic link, dereference it, so that
// FindContainerWindow will succeed. // FindContainerWindow will succeed.
+14 -10
View File
@@ -137,8 +137,10 @@ class TTracker : public BApplication {
void ShowSettingsWindow(); void ShowSettingsWindow();
BContainerWindow* FindContainerWindow(const node_ref*, int32 number = 0) const; BContainerWindow* FindContainerWindow(const node_ref*,
BContainerWindow* FindContainerWindow(const entry_ref*, int32 number = 0) const; int32 number = 0) const;
BContainerWindow* FindContainerWindow(const entry_ref*,
int32 number = 0) const;
BContainerWindow* FindParentContainerWindow(const entry_ref*) const; BContainerWindow* FindParentContainerWindow(const entry_ref*) const;
// right now works just on plain windows, not on query windows // right now works just on plain windows, not on query windows
@@ -176,12 +178,12 @@ class TTracker : public BApplication {
bool InstallMimeIfNeeded(const char* type, int32 bitsID, bool InstallMimeIfNeeded(const char* type, int32 bitsID,
const char* shortDescription, const char* longDescription, const char* shortDescription, const char* longDescription,
const char* preferredAppSignature, uint32 forceMask = 0); const char* preferredAppSignature, uint32 forceMask = 0);
// used by InitMimeTypes - checks if a metamime of a given <type> is // used by InitMimeTypes - checks if a metamime of a given <type>
// installed and if it has all the specified attributes; if not, the // is installed and if it has all the specified attributes;
// whole mime type is installed and all attributes are set; nulls can // if not, the whole mime type is installed and all attributes
// be passed for attributes that don't matter; returns true if anything // are set; nulls can be passed for attributes that don't matter;
// had to be changed // returns true if anything had to be changed <forceMask> can be
// <forceMask> can be used to forcibly set a metamime attribute, even if it exists // used to forcibly set a metamime attribute, even if it exists
void InstallDefaultTemplates(); void InstallDefaultTemplates();
void InstallTemporaryBackgroundImages(); void InstallTemporaryBackgroundImages();
@@ -196,7 +198,8 @@ class TTracker : public BApplication {
void MoveRefsToTrash(const BMessage*); void MoveRefsToTrash(const BMessage*);
void OpenContainerWindow(Model*, BMessage* refsList = NULL, void OpenContainerWindow(Model*, BMessage* refsList = NULL,
OpenSelector openSelector = kOpen, uint32 openFlags = 0, OpenSelector openSelector = kOpen, uint32 openFlags = 0,
bool checkAlreadyOpen = true, const BMessage* stateMessage = NULL); bool checkAlreadyOpen = true,
const BMessage* stateMessage = NULL);
// pass either a Model or a list of entries to open // pass either a Model or a list of entries to open
void _OpenPreviouslyOpenedWindows(const char* pathFilter = NULL); void _OpenPreviouslyOpenedWindows(const char* pathFilter = NULL);
@@ -208,7 +211,8 @@ class TTracker : public BApplication {
BDeskWindow* GetDeskWindow() const; BDeskWindow* GetDeskWindow() const;
status_t OpenRef(const entry_ref*, const node_ref* nodeToClose = NULL, status_t OpenRef(const entry_ref*, const node_ref* nodeToClose = NULL,
const node_ref* nodeToSelect = NULL, OpenSelector selector = kOpen, const node_ref* nodeToSelect = NULL,
OpenSelector selector = kOpen,
const BMessage* messageToBundle = NULL); const BMessage* messageToBundle = NULL);
MimeTypeList* fMimeTypeList; MimeTypeList* fMimeTypeList;
+123 -98
View File
@@ -94,15 +94,16 @@ const char* kPeopleSignature = "application/x-vnd.Be-PEPL";
// the following templates are in big endian and we rely on the Tracker // the following templates are in big endian and we rely on the Tracker
// translation support to swap them on little endian machines // translation support to swap them on little endian machines
// //
// in case there is an attribute (B_RECT_TYPE) that gets swapped by the media (unzip, // in case there is an attribute (B_RECT_TYPE) that gets swapped by the media
// file system endianness swapping, etc., the correct endianness for the // (unzip, file system endianness swapping, etc., the correct endianness for
// correct machine has to be used here // the correct machine has to be used here
const BRect kDefaultFrame(40, 40, 695, 350); const BRect kDefaultFrame(40, 40, 695, 350);
const int32 kDefaultQueryTemplateCount = 3; const int32 kDefaultQueryTemplateCount = 3;
const AttributeTemplate kDefaultQueryTemplate[] = const AttributeTemplate kDefaultQueryTemplate[] =
/* /boot/home/config/settings/Tracker/DefaultQueryTemplates/application_octet-stream */ /* /boot/home/config/settings/Tracker/DefaultQueryTemplates/
application_octet-stream */
{ {
{ {
// default frame // default frame
@@ -117,8 +118,8 @@ const AttributeTemplate kDefaultQueryTemplate[] =
B_RAW_TYPE, B_RAW_TYPE,
49, 49,
"o^\365R\000\000\000\012Tlst\000\000\000\000\000\000\000\000\000\000" "o^\365R\000\000\000\012Tlst\000\000\000\000\000\000\000\000\000\000"
"\000\000\000\000\000\000\000\000\000\000\357\323\335RCSTR\000\000\000" "\000\000\000\000\000\000\000\000\000\000\357\323\335RCSTR\000\000"
"\000\000\000\000\000\000" "\000\000\000\000\000\000\000"
}, },
{ {
// attr: _trk/columns // attr: _trk/columns
@@ -138,7 +139,8 @@ const AttributeTemplate kDefaultQueryTemplate[] =
}; };
const AttributeTemplate kBookmarkQueryTemplate[] = const AttributeTemplate kBookmarkQueryTemplate[] =
/* /boot/home/config/settings/Tracker/DefaultQueryTemplates/application_x-vnd.Be-bookmark */ /* /boot/home/config/settings/Tracker/DefaultQueryTemplates/
application_x-vnd.Be-bookmark */
{ {
{ {
// default frame // default frame
@@ -163,16 +165,17 @@ const AttributeTemplate kBookmarkQueryTemplate[] =
163, 163,
"O\362VR\000\000\000\025\000\000\000\005Title\000B \000\000C+\000\000" "O\362VR\000\000\000\025\000\000\000\005Title\000B \000\000C+\000\000"
"\000\000\000\000\000\000\000\012META:title\000w\373\175RCSTR\000\001" "\000\000\000\000\000\000\000\012META:title\000w\373\175RCSTR\000\001"
"O\362VR\000\000\000\025\000\000\000\003URL\000Cb\000\000C\217\200\000" "O\362VR\000\000\000\025\000\000\000\003URL\000Cb\000\000C\217\200"
"\000\000\000\000\000\000\000\010META:url\000\343[TRCSTR\000\001O\362" "\000\000\000\000\000\000\000\000\010META:url\000\343[TRCSTR\000\001O"
"VR\000\000\000\025\000\000\000\010Keywords\000D\004\000\000C\002\000" "\362VR\000\000\000\025\000\000\000\010Keywords\000D\004\000\000C\002"
"\000\000\000\000\000\000\000\000\011META:keyw\000\333\363\334RCSTR" "\000\000\000\000\000\000\000\000\000\011META:keyw\000\333\363\334"
"\000\001" "RCSTR\000\001"
} }
}; };
const AttributeTemplate kPersonQueryTemplate[] = const AttributeTemplate kPersonQueryTemplate[] =
/* /boot/home/config/settings/Tracker/DefaultQueryTemplates/application_x-vnd.Be-bookmark */ /* /boot/home/config/settings/Tracker/DefaultQueryTemplates/
application_x-vnd.Be-bookmark */
{ {
{ {
// default frame // default frame
@@ -187,8 +190,8 @@ const AttributeTemplate kPersonQueryTemplate[] =
B_RAW_TYPE, B_RAW_TYPE,
49, 49,
"o^\365R\000\000\000\012Tlst\000\000\000\000\000\000\000\000\000\000" "o^\365R\000\000\000\012Tlst\000\000\000\000\000\000\000\000\000\000"
"\000\000\000\000\000\000\000\000\000\000\357\323\335RCSTR\000\000\000" "\000\000\000\000\000\000\000\000\000\000\357\323\335RCSTR\000\000"
"\000\000\000\000\000\000" "\000\000\000\000\000\000\000"
}, },
{ {
// attr: _trk/columns // attr: _trk/columns
@@ -201,14 +204,15 @@ const AttributeTemplate kPersonQueryTemplate[] =
"\000B\264\000\000\000\000\000\000\000\000\000\013META:wphone\000C_" "\000B\264\000\000\000\000\000\000\000\000\000\013META:wphone\000C_"
"uRCSTR\000\001O\362VR\000\000\000\025\000\000\000\006E-mail\000C\211" "uRCSTR\000\001O\362VR\000\000\000\025\000\000\000\006E-mail\000C\211"
"\200\000B\272\000\000\000\000\000\000\000\000\000\012META:email\000" "\200\000B\272\000\000\000\000\000\000\000\000\000\012META:email\000"
"sW\337RCSTR\000\001O\362VR\000\000\000\025\000\000\000\007Company\000" "sW\337RCSTR\000\001O\362VR\000\000\000\025\000\000\000\007Company"
"C\277\200\000B\360\000\000\000\000\000\000\000\000\000\014META:com" "\000C\277\200\000B\360\000\000\000\000\000\000\000\000\000\014"
"pany\000CS\174RCSTR\000\001" "META:company\000CS\174RCSTR\000\001"
}, },
}; };
const AttributeTemplate kEmailQueryTemplate[] = const AttributeTemplate kEmailQueryTemplate[] =
/* /boot/home/config/settings/Tracker/DefaultQueryTemplates/text_x-email */ /* /boot/home/config/settings/Tracker/DefaultQueryTemplates/
text_x-email */
{ {
{ {
// default frame // default frame
@@ -231,15 +235,15 @@ const AttributeTemplate kEmailQueryTemplate[] =
kAttrColumns_be, kAttrColumns_be,
B_RAW_TYPE, B_RAW_TYPE,
222, 222,
"O\362VR\000\000\000\025\000\000\000\007Subject\000B \000\000B\334\000" "O\362VR\000\000\000\025\000\000\000\007Subject\000B \000\000B\334"
"\000\000\000\000\000\000\000\000\014MAIL:subject\000\343\173\337RC" "\000\000\000\000\000\000\000\000\000\014MAIL:subject\000\343\173\337"
"STR\000\000O\362VR\000\000\000\025\000\000\000\004From\000C%\000\000" "RCSTR\000\000O\362VR\000\000\000\025\000\000\000\004From\000C%\000"
"C\031\000\000\000\000\000\000\000\000\000\011MAIL:from\000\317s_RC" "\000C\031\000\000\000\000\000\000\000\000\000\011MAIL:from\000\317"
"STR\000\000O\362VR\000\000\000\025\000\000\000\004When\000C\246\200" "s_RCSTR\000\000O\362VR\000\000\000\025\000\000\000\004When\000C\246"
"\000B\360\000\000\000\000\000\000\000\000\000\011MAIL:when\000\366" "\200\000B\360\000\000\000\000\000\000\000\000\000\011MAIL:when\000"
"_\377ETIME\000\000O\362VR\000\000\000\025\000\000\000\006Status\000" "\366_\377ETIME\000\000O\362VR\000\000\000\025\000\000\000\006Status"
"C\352\000\000BH\000\000\000\000\000\001\000\000\000\013MAIL:status" "\000C\352\000\000BH\000\000\000\000\000\001\000\000\000\013"
"\000G\363\134RCSTR\000\001" "MAIL:status\000G\363\134RCSTR\000\001"
}, },
}; };
@@ -289,8 +293,10 @@ ExtraAttributeLazyInstaller::AddExtraAttribute(const char* publicName,
{ {
for (int32 index = 0; ; index++) { for (int32 index = 0; ; index++) {
const char* oldPublicName; const char* oldPublicName;
if (fExtraAttrs.FindString("attr:public_name", index, &oldPublicName) != B_OK) if (fExtraAttrs.FindString("attr:public_name", index, &oldPublicName)
!= B_OK) {
break; break;
}
if (strcmp(oldPublicName, publicName) == 0) if (strcmp(oldPublicName, publicName) == 0)
// already got this extra atribute, no work left // already got this extra atribute, no work left
@@ -360,7 +366,8 @@ TTracker::InstallMimeIfNeeded(const char* type, int32 bitsID,
// be passed for attributes that don't matter; returns true if anything // be passed for attributes that don't matter; returns true if anything
// had to be changed // had to be changed
BBitmap vectorIcon(BRect(0, 0, 31, 31), B_BITMAP_NO_SERVER_LINK, B_RGBA32); BBitmap vectorIcon(BRect(0, 0, 31, 31), B_BITMAP_NO_SERVER_LINK,
B_RGBA32);
BBitmap largeIcon(BRect(0, 0, 31, 31), B_BITMAP_NO_SERVER_LINK, B_CMAP8); BBitmap largeIcon(BRect(0, 0, 31, 31), B_BITMAP_NO_SERVER_LINK, B_CMAP8);
BBitmap miniIcon(BRect(0, 0, 15, 15), B_BITMAP_NO_SERVER_LINK, B_CMAP8); BBitmap miniIcon(BRect(0, 0, 15, 15), B_BITMAP_NO_SERVER_LINK, B_CMAP8);
char tmp[B_MIME_TYPE_LENGTH]; char tmp[B_MIME_TYPE_LENGTH];
@@ -447,12 +454,12 @@ TTracker::InitMimeTypes()
// install a couple of extra fields for bookmark // install a couple of extra fields for bookmark
ExtraAttributeLazyInstaller installer(B_BOOKMARK_MIMETYPE); ExtraAttributeLazyInstaller installer(B_BOOKMARK_MIMETYPE);
installer.AddExtraAttribute("URL", "META:url", B_STRING_TYPE, true, true, installer.AddExtraAttribute("URL", "META:url", B_STRING_TYPE,
170, B_ALIGN_LEFT, false); true, true, 170, B_ALIGN_LEFT, false);
installer.AddExtraAttribute("Keywords", "META:keyw", B_STRING_TYPE, true, true, installer.AddExtraAttribute("Keywords", "META:keyw", B_STRING_TYPE,
130, B_ALIGN_LEFT, false); true, true, 130, B_ALIGN_LEFT, false);
installer.AddExtraAttribute("Title", "META:title", B_STRING_TYPE, true, true, installer.AddExtraAttribute("Title", "META:title", B_STRING_TYPE,
130, B_ALIGN_LEFT, false); true, true, 130, B_ALIGN_LEFT, false);
} }
InstallMimeIfNeeded(B_PERSON_MIMETYPE, R_PersonIcon, InstallMimeIfNeeded(B_PERSON_MIMETYPE, R_PersonIcon,
@@ -460,34 +467,34 @@ TTracker::InitMimeTypes()
{ {
ExtraAttributeLazyInstaller installer(B_PERSON_MIMETYPE); ExtraAttributeLazyInstaller installer(B_PERSON_MIMETYPE);
installer.AddExtraAttribute("Contact name", kAttrName, B_STRING_TYPE, true, true, installer.AddExtraAttribute("Contact name", kAttrName, B_STRING_TYPE,
120, B_ALIGN_LEFT, false); true, true, 120, B_ALIGN_LEFT, false);
installer.AddExtraAttribute("Company", kAttrCompany, B_STRING_TYPE, true, true, installer.AddExtraAttribute("Company", kAttrCompany, B_STRING_TYPE,
120, B_ALIGN_LEFT, false); true, true, 120, B_ALIGN_LEFT, false);
installer.AddExtraAttribute("Address", kAttrAddress, B_STRING_TYPE, true, true, installer.AddExtraAttribute("Address", kAttrAddress, B_STRING_TYPE,
120, B_ALIGN_LEFT, false); true, true, 120, B_ALIGN_LEFT, false);
installer.AddExtraAttribute("City", kAttrCity, B_STRING_TYPE, true, true, installer.AddExtraAttribute("City", kAttrCity, B_STRING_TYPE,
90, B_ALIGN_LEFT, false); true, true, 90, B_ALIGN_LEFT, false);
installer.AddExtraAttribute("State", kAttrState, B_STRING_TYPE, true, true, installer.AddExtraAttribute("State", kAttrState, B_STRING_TYPE,
50, B_ALIGN_LEFT, false); true, true, 50, B_ALIGN_LEFT, false);
installer.AddExtraAttribute("Zip", kAttrZip, B_STRING_TYPE, true, true, installer.AddExtraAttribute("Zip", kAttrZip, B_STRING_TYPE,
50, B_ALIGN_LEFT, false); true, true, 50, B_ALIGN_LEFT, false);
installer.AddExtraAttribute("Country", kAttrCountry, B_STRING_TYPE, true, true, installer.AddExtraAttribute("Country", kAttrCountry, B_STRING_TYPE,
120, B_ALIGN_LEFT, false); true, true, 120, B_ALIGN_LEFT, false);
installer.AddExtraAttribute("E-mail", kAttrEmail, B_STRING_TYPE, true, true, installer.AddExtraAttribute("E-mail", kAttrEmail, B_STRING_TYPE,
120, B_ALIGN_LEFT, false); true, true, 120, B_ALIGN_LEFT, false);
installer.AddExtraAttribute("Home phone", kAttrHomePhone, B_STRING_TYPE, true, true, installer.AddExtraAttribute("Home phone", kAttrHomePhone,
90, B_ALIGN_LEFT, false); B_STRING_TYPE, true, true, 90, B_ALIGN_LEFT, false);
installer.AddExtraAttribute("Work phone", kAttrWorkPhone, B_STRING_TYPE, true, true, installer.AddExtraAttribute("Work phone", kAttrWorkPhone,
90, B_ALIGN_LEFT, false); B_STRING_TYPE, true, true, 90, B_ALIGN_LEFT, false);
installer.AddExtraAttribute("Fax", kAttrFax, B_STRING_TYPE, true, true, installer.AddExtraAttribute("Fax", kAttrFax, B_STRING_TYPE,
90, B_ALIGN_LEFT, false); true, true, 90, B_ALIGN_LEFT, false);
installer.AddExtraAttribute("URL", kAttrURL, B_STRING_TYPE, true, true, installer.AddExtraAttribute("URL", kAttrURL, B_STRING_TYPE,
120, B_ALIGN_LEFT, false); true, true, 120, B_ALIGN_LEFT, false);
installer.AddExtraAttribute("Group", kAttrGroup, B_STRING_TYPE, true, true, installer.AddExtraAttribute("Group", kAttrGroup, B_STRING_TYPE,
120, B_ALIGN_LEFT, false); true, true, 120, B_ALIGN_LEFT, false);
installer.AddExtraAttribute("Nickname", kAttrNickname, B_STRING_TYPE, true, true, installer.AddExtraAttribute("Nickname", kAttrNickname, B_STRING_TYPE,
120, B_ALIGN_LEFT, false); true, true, 120, B_ALIGN_LEFT, false);
} }
InstallMimeIfNeeded(B_PRINTER_SPOOL_MIMETYPE, R_SpoolFileIcon, InstallMimeIfNeeded(B_PRINTER_SPOOL_MIMETYPE, R_SpoolFileIcon,
@@ -496,43 +503,49 @@ TTracker::InitMimeTypes()
{ {
#if B_BEOS_VERSION_DANO #if B_BEOS_VERSION_DANO
ExtraAttributeLazyInstaller installer(B_PRINTER_SPOOL_MIMETYPE); ExtraAttributeLazyInstaller installer(B_PRINTER_SPOOL_MIMETYPE);
installer.AddExtraAttribute("Status", PSRV_SPOOL_ATTR_STATUS, B_STRING_TYPE, true, false, installer.AddExtraAttribute("Status", PSRV_SPOOL_ATTR_STATUS,
60, B_ALIGN_LEFT, false); B_STRING_TYPE, true, false, 60, B_ALIGN_LEFT, false);
installer.AddExtraAttribute("Page count", PSRV_SPOOL_ATTR_PAGECOUNT, B_INT32_TYPE, true, false, installer.AddExtraAttribute("Page count", PSRV_SPOOL_ATTR_PAGECOUNT,
40, B_ALIGN_RIGHT, false); B_INT32_TYPE, true, false, 40, B_ALIGN_RIGHT, false);
installer.AddExtraAttribute("Description", PSRV_SPOOL_ATTR_DESCRIPTION, B_STRING_TYPE, true, true, installer.AddExtraAttribute("Description",
100, B_ALIGN_LEFT, false); PSRV_SPOOL_ATTR_DESCRIPTION, B_STRING_TYPE, true, true, 100,
installer.AddExtraAttribute("Printer name", PSRV_SPOOL_ATTR_PRINTER, B_STRING_TYPE, true, false, B_ALIGN_LEFT, false);
80, B_ALIGN_LEFT, false); installer.AddExtraAttribute("Printer name", PSRV_SPOOL_ATTR_PRINTER,
installer.AddExtraAttribute("Job creator type", PSRV_SPOOL_ATTR_MIMETYPE, B_ASCII_TYPE, true, false, B_STRING_TYPE, true, false, 80, B_ALIGN_LEFT, false);
60, B_ALIGN_LEFT, false); installer.AddExtraAttribute("Job creator type",
PSRV_SPOOL_ATTR_MIMETYPE, B_ASCII_TYPE, true, false, 60,
B_ALIGN_LEFT, false);
#else #else
ExtraAttributeLazyInstaller installer(B_PRINTER_SPOOL_MIMETYPE); ExtraAttributeLazyInstaller installer(B_PRINTER_SPOOL_MIMETYPE);
installer.AddExtraAttribute("Page count", "_spool/Page Count", B_INT32_TYPE, true, false, installer.AddExtraAttribute("Page count", "_spool/Page Count",
40, B_ALIGN_RIGHT, false); B_INT32_TYPE, true, false, 40, B_ALIGN_RIGHT, false);
installer.AddExtraAttribute("Description", "_spool/Description", B_ASCII_TYPE, true, true, installer.AddExtraAttribute("Description", "_spool/Description",
100, B_ALIGN_LEFT, false); B_ASCII_TYPE, true, true, 100, B_ALIGN_LEFT, false);
installer.AddExtraAttribute("Printer name", "_spool/Printer", B_ASCII_TYPE, true, false, installer.AddExtraAttribute("Printer name", "_spool/Printer",
80, B_ALIGN_LEFT, false); B_ASCII_TYPE, true, false, 80, B_ALIGN_LEFT, false);
installer.AddExtraAttribute("Job creator type", "_spool/MimeType", B_ASCII_TYPE, true, false, installer.AddExtraAttribute("Job creator type", "_spool/MimeType",
60, B_ALIGN_LEFT, false); B_ASCII_TYPE, true, false, 60, B_ALIGN_LEFT, false);
#endif #endif
} }
InstallMimeIfNeeded(B_PRINTER_MIMETYPE, R_GenericPrinterIcon, InstallMimeIfNeeded(B_PRINTER_MIMETYPE, R_GenericPrinterIcon,
"Printer", "Printer queue.", kTrackerSignature /*application/x-vnd.Be-PRNT*/); "Printer", "Printer queue.", kTrackerSignature);
// application/x-vnd.Be-PRNT
// for now set tracker as a default handler for the printer because we // for now set tracker as a default handler for the printer because we
// just want to open it as a folder // just want to open it as a folder
#if B_BEOS_VERSION_DANO #if B_BEOS_VERSION_DANO
{ {
ExtraAttributeLazyInstaller installer(B_PRINTER_MIMETYPE); ExtraAttributeLazyInstaller installer(B_PRINTER_MIMETYPE);
installer.AddExtraAttribute("Driver", PSRV_PRINTER_ATTR_DRV_NAME, B_STRING_TYPE, true, false, installer.AddExtraAttribute("Driver", PSRV_PRINTER_ATTR_DRV_NAME,
120, B_ALIGN_LEFT, false); B_STRING_TYPE, true, false, 120, B_ALIGN_LEFT, false);
installer.AddExtraAttribute("Transport", PSRV_PRINTER_ATTR_TRANSPORT, B_STRING_TYPE, true, false, installer.AddExtraAttribute("Transport",
PSRV_PRINTER_ATTR_TRANSPORT, B_STRING_TYPE, true, false,
60, B_ALIGN_RIGHT, false); 60, B_ALIGN_RIGHT, false);
installer.AddExtraAttribute("Connection", PSRV_PRINTER_ATTR_CNX, B_STRING_TYPE, true, false, installer.AddExtraAttribute("Connection",
PSRV_PRINTER_ATTR_CNX, B_STRING_TYPE, true, false,
40, B_ALIGN_LEFT, false); 40, B_ALIGN_LEFT, false);
installer.AddExtraAttribute("Description", PSRV_PRINTER_ATTR_COMMENTS, B_STRING_TYPE, true, true, installer.AddExtraAttribute("Description",
PSRV_PRINTER_ATTR_COMMENTS, B_STRING_TYPE, true, true,
140, B_ALIGN_LEFT, false); 140, B_ALIGN_LEFT, false);
} }
#endif #endif
@@ -570,36 +583,48 @@ TTracker::InstallDefaultTemplates()
BString query(kQueryTemplates); BString query(kQueryTemplates);
query += "/application_octet-stream"; query += "/application_octet-stream";
if (!BContainerWindow::DefaultStateSourceNode(query.String(), &node, false)) if (!BContainerWindow::DefaultStateSourceNode(query.String(),
if (BContainerWindow::DefaultStateSourceNode(query.String(), &node, true)) { &node, false)) {
if (BContainerWindow::DefaultStateSourceNode(query.String(),
&node, true)) {
AttributeStreamFileNode fileNode(&node); AttributeStreamFileNode fileNode(&node);
AttributeStreamTemplateNode tmp(kDefaultQueryTemplate, 3); AttributeStreamTemplateNode tmp(kDefaultQueryTemplate, 3);
fileNode << tmp; fileNode << tmp;
} }
}
(query = kQueryTemplates) += "/application_x-vnd.Be-bookmark"; (query = kQueryTemplates) += "/application_x-vnd.Be-bookmark";
if (!BContainerWindow::DefaultStateSourceNode(query.String(), &node, false)) if (!BContainerWindow::DefaultStateSourceNode(query.String(),
if (BContainerWindow::DefaultStateSourceNode(query.String(), &node, true)) { &node, false)) {
if (BContainerWindow::DefaultStateSourceNode(query.String(),
&node, true)) {
AttributeStreamFileNode fileNode(&node); AttributeStreamFileNode fileNode(&node);
AttributeStreamTemplateNode tmp(kBookmarkQueryTemplate, 3); AttributeStreamTemplateNode tmp(kBookmarkQueryTemplate, 3);
fileNode << tmp; fileNode << tmp;
} }
}
(query = kQueryTemplates) += "/application_x-person"; (query = kQueryTemplates) += "/application_x-person";
if (!BContainerWindow::DefaultStateSourceNode(query.String(), &node, false)) if (!BContainerWindow::DefaultStateSourceNode(query.String(),
if (BContainerWindow::DefaultStateSourceNode(query.String(), &node, true)) { &node, false)) {
if (BContainerWindow::DefaultStateSourceNode(query.String(),
&node, true)) {
AttributeStreamFileNode fileNode(&node); AttributeStreamFileNode fileNode(&node);
AttributeStreamTemplateNode tmp(kPersonQueryTemplate, 3); AttributeStreamTemplateNode tmp(kPersonQueryTemplate, 3);
fileNode << tmp; fileNode << tmp;
} }
}
(query = kQueryTemplates) += "/text_x-email"; (query = kQueryTemplates) += "/text_x-email";
if (!BContainerWindow::DefaultStateSourceNode(query.String(), &node, false)) if (!BContainerWindow::DefaultStateSourceNode(query.String(),
if (BContainerWindow::DefaultStateSourceNode(query.String(), &node, true)) { &node, false)) {
if (BContainerWindow::DefaultStateSourceNode(query.String(),
&node, true)) {
AttributeStreamFileNode fileNode(&node); AttributeStreamFileNode fileNode(&node);
AttributeStreamTemplateNode tmp(kEmailQueryTemplate, 3); AttributeStreamTemplateNode tmp(kEmailQueryTemplate, 3);
fileNode << tmp; fileNode << tmp;
} }
}
} }
@@ -612,8 +637,8 @@ TTracker::InstallTemporaryBackgroundImages()
status_t status = find_directory(B_SYSTEM_DATA_DIRECTORY, &path); status_t status = find_directory(B_SYSTEM_DATA_DIRECTORY, &path);
if (status < B_OK) { if (status < B_OK) {
// TODO: this error shouldn't be shown to the regular user // TODO: this error shouldn't be shown to the regular user
BString errorMessage(B_TRANSLATE("At %func \nfind_directory() failed. " BString errorMessage(B_TRANSLATE("At %func \nfind_directory() "
"\nReason: %error")); "failed. \nReason: %error"));
errorMessage.ReplaceFirst("%func", __PRETTY_FUNCTION__); errorMessage.ReplaceFirst("%func", __PRETTY_FUNCTION__);
errorMessage.ReplaceFirst("%error", strerror(status)); errorMessage.ReplaceFirst("%error", strerror(status));
(new BAlert("AlertError", errorMessage.String(), B_TRANSLATE("OK"), (new BAlert("AlertError", errorMessage.String(), B_TRANSLATE("OK"),
+13 -8
View File
@@ -101,7 +101,8 @@ status_t
TTracker::GetSupportedSuites(BMessage* data) TTracker::GetSupportedSuites(BMessage* data)
{ {
data->AddString("suites", kTrackerSuites); data->AddString("suites", kTrackerSuites);
BPropertyInfo propertyInfo(const_cast<property_info*>(kTrackerPropertyList)); BPropertyInfo propertyInfo(const_cast<property_info*>
(kTrackerPropertyList));
data->AddFlat("messages", &propertyInfo); data->AddFlat("messages", &propertyInfo);
return _inherited::GetSupportedSuites(data); return _inherited::GetSupportedSuites(data);
@@ -112,9 +113,11 @@ BHandler*
TTracker::ResolveSpecifier(BMessage* message, int32 index, TTracker::ResolveSpecifier(BMessage* message, int32 index,
BMessage* specifier, int32 form, const char* property) BMessage* specifier, int32 form, const char* property)
{ {
BPropertyInfo propertyInfo(const_cast<property_info*>(kTrackerPropertyList)); BPropertyInfo propertyInfo(const_cast<property_info*>
(kTrackerPropertyList));
int32 result = propertyInfo.FindMatch(message, index, specifier, form, property); int32 result = propertyInfo.FindMatch(message, index, specifier, form,
property);
if (result < 0) { if (result < 0) {
//PRINT(("FindMatch result %d %s\n", result, strerror(result))); //PRINT(("FindMatch result %d %s\n", result, strerror(result)));
return _inherited::ResolveSpecifier(message, index, specifier, return _inherited::ResolveSpecifier(message, index, specifier,
@@ -155,7 +158,8 @@ TTracker::HandleScriptingMessage(BMessage* message)
switch (message->what) { switch (message->what) {
case B_CREATE_PROPERTY: case B_CREATE_PROPERTY:
handled = CreateProperty(message, &specifier, form, property, &reply); handled = CreateProperty(message, &specifier, form, property,
&reply);
break; break;
case B_GET_PROPERTY: case B_GET_PROPERTY:
@@ -163,7 +167,8 @@ TTracker::HandleScriptingMessage(BMessage* message)
break; break;
case B_SET_PROPERTY: case B_SET_PROPERTY:
handled = SetProperty(message, &specifier, form, property, &reply); handled = SetProperty(message, &specifier, form, property,
&reply);
break; break;
case B_COUNT_PROPERTIES: case B_COUNT_PROPERTIES:
@@ -189,7 +194,7 @@ TTracker::HandleScriptingMessage(BMessage* message)
bool bool
TTracker::CreateProperty(BMessage* message, BMessage* , int32 form, TTracker::CreateProperty(BMessage* message, BMessage*, int32 form,
const char* property, BMessage* reply) const char* property, BMessage* reply)
{ {
bool handled = false; bool handled = false;
@@ -226,8 +231,8 @@ TTracker::DeleteProperty(BMessage* /*specifier*/, int32 form,
const char* property, BMessage* /*reply*/) const char* property, BMessage* /*reply*/)
{ {
if (strcmp(property, kPropertyTrash) == 0) { if (strcmp(property, kPropertyTrash) == 0) {
// deleting on a selection is handled as removing a part of the selection // deleting on a selection is handled as removing a part of the
// not to be confused with deleting a selected item // selection not to be confused with deleting a selected item
if (form != B_DIRECT_SPECIFIER) if (form != B_DIRECT_SPECIFIER)
// only support direct specifier // only support direct specifier

Some files were not shown because too many files have changed in this diff Show More