Ticket #4730: showimage.patch
File showimage.patch, 3.2 KB (added by , 15 years ago) |
---|
-
src/apps/showimage/ShowImageView.cpp
2217 2217 2218 2218 2219 2219 bool 2220 ShowImageView::_FindNextImageByDir(entry_ref *in_current, entry_ref *out_image, bool next, bool rewind) 2220 ShowImageView::_FindNextImage(entry_ref *in_current, entry_ref *ref, bool next, 2221 bool rewind) 2221 2222 { 2222 ASSERT(next || !rewind); 2223 BEntry curImage(in_current); 2224 entry_ref entry, *ref; 2225 BDirectory parent; 2226 BList entries; 2227 bool found = false; 2228 int32 cur; 2229 2230 if (curImage.GetParent(&parent) != B_OK) { 2223 // Based on GetTrackerWindowFile function from BeMail 2224 if (!fTrackerMessenger.IsValid()) 2231 2225 return false; 2232 }2233 2226 2234 // insert current ref, so we can find it easily after sorting2235 entries.AddItem(in_current);2236 2237 while (parent.GetNextRef(&entry) == B_OK) {2238 if (entry != *in_current) {2239 entries.AddItem(new entry_ref(entry));2240 }2241 }2242 2243 entries.SortItems(_CompareEntries);2244 2245 cur = entries.IndexOf(in_current);2246 ASSERT(cur >= 0);2247 2248 // remove it so _FreeEntries() does not delete it2249 entries.RemoveItem(in_current);2250 2251 if (next) {2252 // find the next image in the list2253 if (rewind) cur = 0; // start with first2254 for (; (ref = (entry_ref*)entries.ItemAt(cur)) != NULL; cur ++) {2255 if (_IsImage(ref)) {2256 found = true;2257 *out_image = (const entry_ref)*ref;2258 break;2259 }2260 }2261 } else {2262 // find the previous image in the list2263 cur --;2264 for (; cur >= 0; cur --) {2265 ref = (entry_ref*)entries.ItemAt(cur);2266 if (_IsImage(ref)) {2267 found = true;2268 *out_image = (const entry_ref)*ref;2269 break;2270 }2271 }2272 }2273 2274 _FreeEntries(&entries);2275 return found;2276 }2277 2278 bool2279 ShowImageView::_FindNextImage(entry_ref *in_current, entry_ref *ref, bool next, bool rewind)2280 {2281 // Based on similar function from BeMail!2282 if (!fTrackerMessenger.IsValid())2283 // If tracker scripting is not available,2284 // fall back on directory searching code2285 return _FindNextImageByDir(in_current, ref, next, rewind);2286 2287 2227 // 2288 2228 // Ask the Tracker what the next/prev file in the window is. 2289 2229 // Continue asking for the next reference until a valid … … 2312 2252 2313 2253 BMessage reply; 2314 2254 if (fTrackerMessenger.SendMessage(&request, &reply) != B_OK) 2315 return _FindNextImageByDir(in_current, ref, next, rewind);;2255 return false; 2316 2256 if (reply.FindRef("result", &nextRef) != B_OK) 2317 return _FindNextImageByDir(in_current, ref, next, rewind);;2257 return false; 2318 2258 2319 2259 if (_IsImage(&nextRef)) 2320 2260 foundRef = true; -
src/apps/showimage/ShowImageView.h
167 167 static int _CompareEntries(const void* a, const void* b); 168 168 void _FreeEntries(BList* entries); 169 169 void _SetTrackerSelectionToCurrent(); 170 bool _FindNextImageByDir(entry_ref *in_current, entry_ref *out_image,171 bool next, bool rewind);172 170 bool _FindNextImage(entry_ref *in_current, entry_ref *out_image, 173 171 bool next, bool rewind); 174 172 bool _ShowNextImage(bool next, bool rewind);