Re-Added directory based Next/Previous file functionality. Now, if tracker scripting is unavailable, user will still be able to use Next/Previous file commands and the slideshow feature

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8067 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Matthew Wilber
2004-06-19 17:37:10 +00:00
parent 972f6755d1
commit 2041038abe
2 changed files with 62 additions and 1 deletions
+61 -1
View File
@@ -1922,12 +1922,72 @@ ShowImageView::SetTrackerSelectionToCurrent()
fTrackerMessenger.SendMessage(&setsel); fTrackerMessenger.SendMessage(&setsel);
} }
bool
ShowImageView::FindNextImageByDir(entry_ref *in_current, entry_ref *out_image, bool next, bool rewind)
{
ASSERT(next || !rewind);
BEntry curImage(in_current);
entry_ref entry, *ref;
BDirectory parent;
BList entries;
bool found = false;
int32 cur;
if (curImage.GetParent(&parent) != B_OK)
return false;
while (parent.GetNextRef(&entry) == B_OK) {
if (entry != *in_current) {
entries.AddItem(new entry_ref(entry));
} else {
// insert current ref, so we can find it easily after sorting
entries.AddItem(in_current);
}
}
entries.SortItems(CompareEntries);
cur = entries.IndexOf(in_current);
ASSERT(cur >= 0);
// remove it so FreeEntries() does not delete it
entries.RemoveItem(in_current);
if (next) {
// find the next image in the list
if (rewind) cur = 0; // start with first
for (; (ref = (entry_ref*)entries.ItemAt(cur)) != NULL; cur ++) {
if (IsImage(ref)) {
found = true;
*out_image = (const entry_ref)*ref;
break;
}
}
} else {
// find the previous image in the list
cur --;
for (; cur >= 0; cur --) {
ref = (entry_ref*)entries.ItemAt(cur);
if (IsImage(ref)) {
found = true;
*out_image = (const entry_ref)*ref;
break;
}
}
}
FreeEntries(&entries);
return found;
}
bool bool
ShowImageView::FindNextImage(entry_ref *in_current, entry_ref *ref, bool next, bool rewind) ShowImageView::FindNextImage(entry_ref *in_current, entry_ref *ref, bool next, bool rewind)
{ {
// Based on similar function from BeMail! // Based on similar function from BeMail!
if (!fTrackerMessenger.IsValid()) if (!fTrackerMessenger.IsValid())
return false; // If tracker scripting is not available,
// fall back on directory searching code
return FindNextImageByDir(in_current, ref, next, rewind);
// //
// Ask the Tracker what the next/prev file in the window is. // Ask the Tracker what the next/prev file in the window is.
+1
View File
@@ -164,6 +164,7 @@ private:
static int CompareEntries(const void* a, const void* b); static int CompareEntries(const void* a, const void* b);
void FreeEntries(BList* entries); void FreeEntries(BList* entries);
void SetTrackerSelectionToCurrent(); void SetTrackerSelectionToCurrent();
bool FindNextImageByDir(entry_ref *in_current, entry_ref *out_image, bool next, bool rewind);
bool FindNextImage(entry_ref *in_current, entry_ref *out_image, bool next, bool rewind); bool FindNextImage(entry_ref *in_current, entry_ref *out_image, bool next, bool rewind);
bool ShowNextImage(bool next, bool rewind); bool ShowNextImage(bool next, bool rewind);
bool FirstFile(); bool FirstFile();