1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
| void ListeCourant::listeDossierEff(void)
{
static Glib::RefPtr<Gdk::Pixbuf> pixF=Gdk::Pixbuf::create_from_file(fen.getTheme()+ICON_FICHIER,TAILLE_ICON_PETITE,TAILLE_ICON_PETITE,true);
static Glib::RefPtr<Gdk::Pixbuf> pixD=Gdk::Pixbuf::create_from_file(fen.getTheme()+ICON_DOSSIER,TAILLE_ICON_PETITE,TAILLE_ICON_PETITE,true);
string repCourant=fen.getCourant();
try
{
Glib::Dir dir(repCourant);
string name=dir.read_name();
int id=0;
while(!name.empty())
{
if (name.length() && name[0] != '.')
{
string path=Glib::build_filename(repCourant,name);
Glib::ustring nom=Glib::filename_to_utf8(name);
if (Glib::file_test(path,Glib::FILE_TEST_IS_DIR))
{
TreeModel::Row row=*(this->refTreeModel->append());
row[this->treeModel.pixbuf]=pixD;
row[this->treeModel.chemin]=repCourant;
row[this->treeModel.nom]=nom;
row[this->treeModel.type]="Dossier";
row[this->treeModel.taille]="";
row[this->treeModel.id]=id++;
Dossier d(nom);
fen.getListeDossier().push_back(d);
fen.getListeDossier().sort(Dossier::tri);
}
else if (Glib::file_test(path,Glib::FILE_TEST_IS_REGULAR) && fichierTmp(path) && formatOK(path))
{
TreeModel::Row row=*(this->refTreeModel->append());
int taille=utile::taille(path);
Fichier f(fen.getCourant(),nom,taille);
if(f.getPixbuf())
{
f.setPixbufIconPetite(f.getPixbuf()->scale_simple(TAILLE_ICON_PETITE,TAILLE_ICON_PETITE,Gdk::INTERP_BILINEAR));
row[this->treeModel.pixbuf]=f.getPixbufIconPetite();
}
else
row[this->treeModel.pixbuf]=pixF;
row[this->treeModel.chemin]=repCourant;
row[this->treeModel.nom]=f.getNom();
row[this->treeModel.type]="Fichier";
if (taille<0)
row[this->treeModel.taille]="";
else if (taille/1048576>0)
row[this->treeModel.taille]=utile::all2string(taille/1048576)+","+utile::all2string(taille-(taille/1048576)*1048576)+" Mo";
else if (taille/1024>0)
row[this->treeModel.taille]=utile::all2string(taille/1024)+","+utile::all2string(taille-(taille/1024)*1024)+" ko";
else
row[this->treeModel.taille]=utile::all2string(taille)+" o";
row[this->treeModel.id]=id++;
fen.getListeFichier().push_back(f);
fen.getListeFichier().sort(Fichier::tri);
}
}
name=dir.read_name();
fen.getGLScene().queue_draw();
}
fen.getGLScene().queue_draw();
}
catch(const Glib::FileError& ex)
{
std::cout << ex.what() << std::endl;
}
}
void ListeCourant::liste(bool clear)
{
if (clear)
refTreeModel->clear();
fen.supprimeListes();
if(!Glib::thread_supported())
Glib::thread_init();
try
{
thread=Glib::Thread::create(sigc::mem_fun(*this,&ListeCourant::listeDossierEff),true);
thread->join(); // ICI le join()
}
catch(Glib::ThreadError& e)
{
cout << e.what() << endl;
}
catch(Glib::Thread::Exit& e) {}
} |
Partager