~ubuntu-branches/ubuntu/saucy/filezilla/saucy-proposed

« back to all changes in this revision

Viewing changes to src/interface/filelistctrl.cpp

  • Committer: Package Import Robot
  • Author(s): Adrien Cunin
  • Date: 2012-12-07 17:17:17 UTC
  • mfrom: (1.1.31)
  • Revision ID: package-import@ubuntu.com-20121207171717-nt6as62u4pa1uv11
Tags: 3.6.0.2-1ubuntu1
* Merge from Debian experimental. Remaining Ubuntu change:
   - Added debian/patches/11_use-decimal-si-by-default.patch in order to
     comply with UnitsPolicy

Show diffs side-by-side

added added

removed removed

Lines of Context:
81
81
 
82
82
                return wxListCtrlEx::MSWWindowProc(nMsg, wParam, lParam);
83
83
        }
84
 
        
 
84
 
85
85
        return wxListCtrlEx::MSWWindowProc(nMsg, wParam, lParam);
86
86
}
87
87
 
102
102
 
103
103
                if (!m_pFilelistStatusBar)
104
104
                        return true;
105
 
                
 
105
 
106
106
                if (wxGetKeyState(WXK_CONTROL) && wxGetKeyState(WXK_SHIFT))
107
107
                {
108
108
                        // The behavior of Ctrl+Shift+Click is highly erratic.
210
210
{
211
211
public:
212
212
        virtual void OnNavigationEvent(bool forward) = 0;
 
213
        virtual ~CGtkEventCallbackProxyBase() {}
213
214
};
214
215
 
215
216
template <class CFileData> class CGtkEventCallbackProxy : public CGtkEventCallbackProxyBase
277
278
        GtkWidget* widget = GetMainWindow()->GetConnectWidget();
278
279
        g_signal_connect(widget, "button_release_event", G_CALLBACK(gtk_button_release_event), m_gtkEventCallbackProxy.Value());
279
280
#endif
 
281
 
 
282
        m_genericTypes[genericTypes::file] = _("File");
 
283
        m_genericTypes[genericTypes::directory] = _("Directory");
280
284
}
281
285
 
282
286
template<class CFileData> CFileListCtrl<CFileData>::~CFileListCtrl()
321
325
 
322
326
#ifndef __WXMSW__
323
327
                // GetNextItem is O(n) if nothing is selected, GetSelectedItemCount() is O(1)
324
 
                if (GetSelectedItemCount())             
 
328
                if (GetSelectedItemCount())
325
329
#endif
326
330
                {
327
331
                        int item = -1;
343
347
                m_sortColumn = column;
344
348
                std::vector<unsigned int>::iterator start = m_indexMapping.begin();
345
349
                if (m_hasParent)
346
 
                        start++;
 
350
                        ++start;
347
351
                std::reverse(start, m_indexMapping.end());
348
352
 
349
353
                if (updateSelections)
368
372
 
369
373
        std::vector<unsigned int>::iterator start = m_indexMapping.begin();
370
374
        if (m_hasParent)
371
 
                start++;
 
375
                ++start;
372
376
        CSortComparisonObject object = GetSortComparisonObject();
373
377
        std::sort(start, m_indexMapping.end(), object);
374
378
        object.Destroy();
460
464
        RefreshListOnly(false);
461
465
}
462
466
 
 
467
static wxString GetExt(const wxString& file)
 
468
{
 
469
        wxString ret;
 
470
 
 
471
        int pos = file.Find('.', true);
 
472
        if (pos > 0 && file[pos + 1] != 0) // Does neither starts nor end with dot
 
473
                ret = file.Mid(pos + 1);
 
474
 
 
475
        return ret;
 
476
}
 
477
 
463
478
template<class CFileData> wxString CFileListCtrl<CFileData>::GetType(wxString name, bool dir, const wxString& path /*=_T("")*/)
464
479
{
465
480
#ifdef __WXMSW__
466
 
        wxString ext = wxFileName(name).GetExt();
 
481
        wxString ext = GetExt(name);
467
482
        ext.MakeLower();
468
483
        std::map<wxString, wxString>::iterator typeIter = m_fileTypeMap.find(ext);
469
484
        if (typeIter != m_fileTypeMap.end())
471
486
 
472
487
        wxString type;
473
488
        int flags = SHGFI_TYPENAME;
474
 
        if (path == _T(""))
 
489
        if (path.IsEmpty())
475
490
                flags |= SHGFI_USEFILEATTRIBUTES;
476
491
        else if (path == _T("\\"))
477
492
                name += _T("\\");
486
501
                sizeof(shFinfo),
487
502
                flags))
488
503
        {
489
 
                type = shFinfo.szTypeName;
490
 
                if (type == _T(""))
 
504
                if (!*shFinfo.szTypeName)
491
505
                {
492
 
                        type = ext;
493
 
                        type.MakeUpper();
494
 
                        if (!type.IsEmpty())
 
506
                        if (!ext.IsEmpty())
495
507
                        {
 
508
                                type = ext;
 
509
                                type.MakeUpper();
496
510
                                type += _T("-");
497
511
                                type += _("file");
498
512
                        }
499
513
                        else
500
 
                                type = _("File");
 
514
                                type = m_genericTypes[genericTypes::file];
501
515
                }
502
516
                else
503
517
                {
504
 
                        if (!dir && ext != _T(""))
 
518
                        type = shFinfo.szTypeName;
 
519
                        if (!dir && !ext.IsEmpty())
505
520
                                m_fileTypeMap[ext.MakeLower()] = type;
506
521
                }
507
522
        }
508
523
        else
509
524
        {
510
 
                type = ext;
511
 
                type.MakeUpper();
512
 
                if (!type.IsEmpty())
 
525
                if (!ext.IsEmpty())
513
526
                {
 
527
                        type = ext;
 
528
                        type.MakeUpper();
514
529
                        type += _T("-");
515
530
                        type += _("file");
516
531
                }
517
532
                else
518
 
                        type = _("File");
 
533
                        type = m_genericTypes[genericTypes::file];
519
534
        }
520
535
        return type;
521
536
#else
522
537
        if (dir)
523
 
                return _("Directory");
 
538
                return m_genericTypes[genericTypes::directory];
524
539
 
525
540
        int pos = name.Find('.', true);
526
541
        if (pos < 1 || !name[pos + 1]) // Starts or ends with dot
527
 
                return _("File");
 
542
                return m_genericTypes[genericTypes::file];
528
543
        wxString ext = name.Mid(pos + 1);
529
544
        wxString lower_ext = ext.Lower();
530
545