now monitor the directory if settings file is not found, and vice et versa
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14115 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -65,27 +65,59 @@ SSInputFilter::SSInputFilter()
|
|||||||
fCurrent(NONE),
|
fCurrent(NONE),
|
||||||
fEnabled(false),
|
fEnabled(false),
|
||||||
fFrameNum(0),
|
fFrameNum(0),
|
||||||
fRunner(NULL) {
|
fRunner(NULL),
|
||||||
|
fWatchingDirectory(false),
|
||||||
|
fWatchingFile(false) {
|
||||||
CALLED();
|
CALLED();
|
||||||
fSSController = new SSController(this);
|
fSSController = new SSController(this);
|
||||||
fSSController->Run();
|
fSSController->Run();
|
||||||
|
|
||||||
ReloadSettings();
|
ReloadSettings();
|
||||||
BEntry entry(fPref.GetPath().Path());
|
|
||||||
entry.GetNodeRef(&fPrefNodeRef);
|
|
||||||
watch_node(&fPrefNodeRef, B_WATCH_ALL, NULL, fSSController);
|
|
||||||
be_roster->StartWatching(fSSController);
|
be_roster->StartWatching(fSSController);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SSInputFilter::~SSInputFilter() {
|
SSInputFilter::~SSInputFilter() {
|
||||||
delete fRunner;
|
delete fRunner;
|
||||||
watch_node(&fPrefNodeRef, B_STOP_WATCHING, NULL);
|
if (fWatchingFile)
|
||||||
|
watch_node(&fPrefNodeRef, B_STOP_WATCHING, NULL);
|
||||||
|
if (fWatchingDirectory)
|
||||||
|
watch_node(&fPrefDirNodeRef, B_STOP_WATCHING, NULL);
|
||||||
be_roster->StopWatching(fSSController);
|
be_roster->StopWatching(fSSController);
|
||||||
delete fSSController;
|
delete fSSController;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
SSInputFilter::WatchPreferences() {
|
||||||
|
BEntry entry(fPref.GetPath().Path());
|
||||||
|
if (entry.Exists()) {
|
||||||
|
if (fWatchingFile)
|
||||||
|
return;
|
||||||
|
if (fWatchingDirectory) {
|
||||||
|
watch_node(&fPrefDirNodeRef, B_STOP_WATCHING, NULL);
|
||||||
|
fWatchingDirectory = false;
|
||||||
|
}
|
||||||
|
entry.GetNodeRef(&fPrefNodeRef);
|
||||||
|
watch_node(&fPrefNodeRef, B_WATCH_ALL, NULL, fSSController);
|
||||||
|
fWatchingFile = true;
|
||||||
|
} else {
|
||||||
|
if (fWatchingDirectory)
|
||||||
|
return;
|
||||||
|
if (fWatchingFile) {
|
||||||
|
watch_node(&fPrefNodeRef, B_STOP_WATCHING, NULL);
|
||||||
|
fWatchingFile = false;
|
||||||
|
}
|
||||||
|
BEntry dir;
|
||||||
|
entry.GetParent(&dir);
|
||||||
|
dir.GetNodeRef(&fPrefDirNodeRef);
|
||||||
|
watch_node(&fPrefDirNodeRef, B_WATCH_ALL, NULL, fSSController);
|
||||||
|
fWatchingDirectory = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SSInputFilter::Invoke()
|
SSInputFilter::Invoke()
|
||||||
{
|
{
|
||||||
@@ -113,6 +145,7 @@ SSInputFilter::ReloadSettings()
|
|||||||
if (fRunner->InitCheck() != B_OK) {
|
if (fRunner->InitCheck() != B_OK) {
|
||||||
SERIAL_PRINT(("fRunner init failed\n"));
|
SERIAL_PRINT(("fRunner init failed\n"));
|
||||||
}
|
}
|
||||||
|
WatchPreferences();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -45,9 +45,11 @@ private:
|
|||||||
uint32 fFrameNum; // Used so that we don't update the screen coord's so often
|
uint32 fFrameNum; // Used so that we don't update the screen coord's so often
|
||||||
// Ideally, we would get a message when the screen changes. R5 doesn't do this.
|
// Ideally, we would get a message when the screen changes. R5 doesn't do this.
|
||||||
SSController *fSSController;
|
SSController *fSSController;
|
||||||
node_ref fPrefNodeRef;
|
node_ref fPrefNodeRef, fPrefDirNodeRef;
|
||||||
BMessageRunner *fRunner;
|
BMessageRunner *fRunner;
|
||||||
|
bool fWatchingDirectory, fWatchingFile;
|
||||||
|
|
||||||
|
void WatchPreferences();
|
||||||
void UpdateRectangles();
|
void UpdateRectangles();
|
||||||
void Cornered(arrowDirection pos);
|
void Cornered(arrowDirection pos);
|
||||||
void Invoke();
|
void Invoke();
|
||||||
|
|||||||
Reference in New Issue
Block a user