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 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
| #include "Fichiers.hh"
const int Fichier::TAILLE_PIXBUF=256;
void Fichier::setTex(GLuint n)
{
tex=n;
}
GLuint Fichier::getTex(void)
{
return tex;
}
void Fichier::setPixbufIconPetite(Glib::RefPtr<Gdk::Pixbuf> pixbuf)
{
iconPetite=pixbuf;
}
void Fichier::setPixbufIconGrande(Glib::RefPtr<Gdk::Pixbuf> pixbuf)
{
iconGrande=pixbuf;
}
Glib::RefPtr<Gdk::Pixbuf> Fichier::getPixbufIconGrande(void)
{
return iconGrande;
}
Glib::RefPtr<Gdk::Pixbuf> Fichier::getPixbufIconPetite(void)
{
return iconPetite;
}
bool Fichier::isImage(const Glib::ustring& str)
{
int nbExt=4;
Glib::ustring extImage[]={"jpg","JPG","png","gif"};
if (str.size()<=3)
return false;
for(int i=0;i<nbExt;i++)
{
if (!( (str.substr(str.size()-3)).compare(extImage[i]) ))
return true;
}
return false;
}
bool Fichier::isImage(void)
{
Glib::ustring nom(getCheminComplet());
return Fichier::isImage(nom);
}
Glib::ustring Fichier::getCheminComplet()
{
Glib::ustring s("");
if (dossier!="/")
s=dossier+"/"+nom;
else
s=dossier+nom;
return s;
}
bool Fichier::tri(Fichier& f1, Fichier& f2)
{
Glib::ustring str1(""), str2("");
f1.getDossier()!="/" ? str1=f1.getDossier()+"/"+f1.getNom() : str1=f1.getDossier()+f1.getNom() ;
f2.getDossier()!="/" ? str2=f2.getDossier()+"/"+f2.getNom() : str2=f2.getDossier()+f2.getNom() ;
if (str1.compare(str2)<=0)
return true;
return false;
}
Glib::RefPtr<Gdk::Pixbuf> Fichier::getPixbuf(void)
{
return pixbuf;
}
Glib::ustring Fichier::getDossier(void)
{
return this->dossier;
}
void Fichier::setDossier(const Glib::ustring& d)
{
this->dossier=d;
}
Glib::ustring Fichier::getNom(void)
{
return this->nom;
}
void Fichier::setNom(const Glib::ustring& n)
{
this->nom=n;
}
int Fichier::getTaille(void)
{
return this->taille;
}
void Fichier::setTaille(int t)
{
this->taille=t;
}
void Fichier::get(Glib::ustring& d,Glib::ustring& n, int& t)
{
d=this->dossier;
n=this->nom;
t=this->taille;
}
void Fichier::set(const Glib::ustring& d, const Glib::ustring& n, int t)
{
this->dossier=d;
this->nom=n;
this->taille=t;
}
Fichier::Fichier(const Glib::ustring& d, const Glib::ustring& n, int t) : dossier(d), nom(n), taille(t)
{
Glib::ustring f;
d!="/" ? f=d+"/"+n : f=d+n;
if (Glib::file_test(f,Glib::FILE_TEST_IS_REGULAR))
{
try
{
pixbuf=Gdk::Pixbuf::create_from_file(f,Fichier::TAILLE_PIXBUF,Fichier::TAILLE_PIXBUF,true);
}
catch(Gdk::PixbufError&)
{
pixbuf.reset();
}
catch(Glib::FileError&)
{
pixbuf.reset();
}
}
}
Fichier::Fichier() : dossier(""), nom(""), taille(0)
{
}
Fichier::~Fichier()
{
if (iconGrande)
glDeleteTextures(1,&tex);
} |
Partager