Implemented rewind functionality so that slide show no longer stops when it reaches the last file in the directory

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7453 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Matthew Wilber
2004-05-07 23:25:11 +00:00
parent b541da436f
commit efc10d5e6a
+16 -13
View File
@@ -1925,9 +1925,7 @@ ShowImageView::SetTrackerSelectionToCurrent()
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)
{ {
// shamelessly stolen, I mean copied from BeMail! // Based on similar function from BeMail!
// XXX rewind is not implemented yet => slide show will stop with last image
if (!fTrackerMessenger.IsValid()) if (!fTrackerMessenger.IsValid())
return false; return false;
@@ -1942,27 +1940,32 @@ ShowImageView::FindNextImage(entry_ref *in_current, entry_ref *ref, bool next, b
{ {
BMessage request(B_GET_PROPERTY); BMessage request(B_GET_PROPERTY);
BMessage spc; BMessage spc;
if (next) if (rewind)
spc.what = B_DIRECT_SPECIFIER;
else if (next)
spc.what = 'snxt'; spc.what = 'snxt';
else else
spc.what = 'sprv'; spc.what = 'sprv';
spc.AddString("property", "Entry"); spc.AddString("property", "Entry");
if (rewind)
// if rewinding, ask for the ref to the
// first item in the directory
spc.AddInt32("data", 0);
else
spc.AddRef("data", &nextRef); spc.AddRef("data", &nextRef);
request.AddSpecifier(&spc); request.AddSpecifier(&spc);
BMessage reply; BMessage reply;
if (fTrackerMessenger.SendMessage(&request, &reply) != B_OK) { if (fTrackerMessenger.SendMessage(&request, &reply) != B_OK)
return false; return false;
} if (reply.FindRef("result", &nextRef) != B_OK)
if (reply.FindRef("result", &nextRef) != B_OK) {
return false; return false;
}
if (IsImage(&nextRef)) { if (IsImage(&nextRef))
foundRef = true; foundRef = true;
}
rewind = false;
// stop asking for the first ref in the directory
} }
*ref = nextRef; *ref = nextRef;