Ticket #4730: showimage.patch

File showimage.patch, 3.2 KB (added by idefix, 15 years ago)

[patch] remove ShowImageView::_FindNextImageByDir

  • src/apps/showimage/ShowImageView.cpp

     
    22172217
    22182218
    22192219bool
    2220 ShowImageView::_FindNextImageByDir(entry_ref *in_current, entry_ref *out_image, bool next, bool rewind)
     2220ShowImageView::_FindNextImage(entry_ref *in_current, entry_ref *ref, bool next,
     2221    bool rewind)
    22212222{
    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())
    22312225        return false;
    2232     }
    22332226
    2234     // insert current ref, so we can find it easily after sorting
    2235     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 it
    2249     entries.RemoveItem(in_current);
    2250 
    2251     if (next) {
    2252         // find the next image in the list
    2253         if (rewind) cur = 0; // start with first
    2254         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 list
    2263         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 bool
    2279 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 code
    2285         return _FindNextImageByDir(in_current, ref, next, rewind);
    2286 
    22872227    //
    22882228    //  Ask the Tracker what the next/prev file in the window is.
    22892229    //  Continue asking for the next reference until a valid
     
    23122252
    23132253        BMessage reply;
    23142254        if (fTrackerMessenger.SendMessage(&request, &reply) != B_OK)
    2315             return _FindNextImageByDir(in_current, ref, next, rewind);;
     2255            return false;
    23162256        if (reply.FindRef("result", &nextRef) != B_OK)
    2317             return _FindNextImageByDir(in_current, ref, next, rewind);;
     2257            return false;
    23182258
    23192259        if (_IsImage(&nextRef))
    23202260            foundRef = true;
  • src/apps/showimage/ShowImageView.h

     
    167167        static int _CompareEntries(const void* a, const void* b);
    168168        void _FreeEntries(BList* entries);
    169169        void _SetTrackerSelectionToCurrent();
    170         bool _FindNextImageByDir(entry_ref *in_current, entry_ref *out_image,
    171                 bool next, bool rewind);
    172170        bool _FindNextImage(entry_ref *in_current, entry_ref *out_image,
    173171                bool next, bool rewind);
    174172        bool _ShowNextImage(bool next, bool rewind);