52class TViewUpdateTimer :
public TTimer {
64class TGFileIcon :
public TGIcon {
74 TGIcon(p, pic, 0, 0, options, back) { fLpic = lpic; }
99 switch (fContainer->fSortType) {
103 type1 =
f1->GetType();
113 if (type1 < type2)
return -1;
114 if (type1 > type2)
return 1;
115 return strcmp(
f1->GetItemName()->GetString(),
127 type1 =
f1->GetType();
137 if (type1 < type2)
return -1;
138 if (type1 > type2)
return 1;
139 return strcmp(
f1->GetItemName()->GetString(),
151 type1 =
f1->GetType();
161 if (type1 < type2)
return -1;
162 if (type1 > type2)
return 1;
163 return strcmp(
f1->GetItemName()->GetString(),
169 type1 =
f1->GetType();
175 else if (
R_ISLNK(type1)) type1 = 2;
176 else if (
R_ISSOCK(type1)) type1 = 3;
177 else if (
R_ISFIFO(type1)) type1 = 4;
182 else if (
R_ISLNK(type2)) type2 = 2;
183 else if (
R_ISSOCK(type2)) type2 = 3;
184 else if (
R_ISFIFO(type2)) type2 = 4;
188 if (type1 < type2)
return -1;
189 if (type1 > type2)
return 1;
190 return strcmp(
f1->GetItemName()->GetString(),
194 if (
f1->GetSize() < f2->
GetSize())
return -1;
195 if (
f1->GetSize() > f2->
GetSize())
return 1;
196 return strcmp(
f1->GetItemName()->GetString(),
200 time_t loctimeF1 = (time_t)
f1->GetModTime();
202 struct tm tmF1 = *localtime(&loctimeF1);
206 struct tm tmF2 = *localtime(&loctimeF2);
208 if ( tmF1.tm_year != tmF2.tm_year )
209 return (tmF1.tm_year < tmF2.tm_year) ? +1 : -1;
210 else if ( tmF1.tm_mon != tmF2.tm_mon )
211 return (tmF1.tm_mon < tmF2.tm_mon) ? +1 : -1;
212 else if ( tmF1.tm_mday != tmF2.tm_mday )
213 return (tmF1.tm_mday < tmF2.tm_mday) ? +1 : -1;
214 else if ( tmF1.tm_hour != tmF2.tm_hour )
215 return (tmF1.tm_hour < tmF2.tm_hour) ? +1 : -1;
216 else if ( tmF1.tm_min != tmF2.tm_min )
217 return (tmF1.tm_min < tmF2.tm_min) ? +1 : -1;
218 else if ( tmF1.tm_sec != tmF2.tm_sec )
219 return (tmF1.tm_sec < tmF2.tm_sec) ? +1 : -1;
229Bool_t TViewUpdateTimer::Notify()
231 fContainer->HandleTimer(0);
240void TGFileIcon::DoRedraw()
243 if (fLpic) fLpic->
Draw(fId, GetBckgndGC()(), 0, 0);
267 Init(blpic, slpic, buf, viewMode);
280 Init(blpic, slpic, stat, viewMode);
313 snprintf(tmp,
sizeof(tmp),
"%c%c%c%c%c%c%c%c%c%c",
340 fsize = bsize =
fSize;
345 snprintf(tmp,
sizeof(tmp),
"%lld.%lldM", fsize/1024, (fsize%1024)/103);
347 snprintf(tmp,
sizeof(tmp),
"%lld.%lldK", bsize/1024, (bsize%1024)/103);
350 snprintf(tmp,
sizeof(tmp),
"%lld", bsize);
370 newtime = localtime(&loctime);
372 snprintf(tmp,
sizeof(tmp),
"%d-%02d-%02d %02d:%02d", newtime->tm_year + 1900,
373 newtime->tm_mon+1, newtime->tm_mday, newtime->tm_hour,
488 fRefresh =
new TViewUpdateTimer(
this, 1000);
507 Error(
"TGFileContainer",
"required pixmap(s) missing\n");
523 fRefresh =
new TViewUpdateTimer(
this, 1000);
542 Error(
"TGFileContainer",
"required pixmap(s) missing\n");
584 nw->fContainer =
this;
634 const char *ext =
name ? strrchr(
name,
'.') : 0;
638 if (
fCachePictures && ext && cached_spic && cached_lpic && (cached_ext == ext)) {
641 if (!is_link)
return;
646 if (is_link && fname.
EndsWith(
".lnk")) {
653 if (!*lpic) *lpic = *pic;
658 if (!is_link)
return;
687 if (img2) img1->
Merge(img2);
688 lnk_name = ((
const TGPicture *)*pic)->GetName();
693 if (img2)
delete img2;
701 if (img2) img1->
Merge(img2);
702 lnk_name = ((
const TGPicture *)*lpic)->GetName();
707 if (img2)
delete img2;
777 if (strcmp(
name,
".") && strcmp(
name,
".."))
801 Info(
"AddFile",
"Broken symlink of %s.",
name);
804 msg.
Form(
"Can't read file attributes of \"%s\": %s.",
826 item =
new TGFileItem(
this, lpic, slpic, spic, pic,
887 fRefresh =
new TViewUpdateTimer(
this, msec);
899 out << std::endl <<
" // container frame" << std::endl;
900 out <<
" TGFileContainer *";
911 out <<
");" << std::endl;
918 if (option && strstr(option,
"keep_names"))
919 out <<
" " <<
GetName() <<
"->SetName(\"" <<
GetName() <<
"\");" << std::endl;
921 <<
GetName() <<
");" << std::endl;
922 out <<
" " <<
GetName() <<
"->DisplayDirectory();" << std::endl;
923 out <<
" " <<
GetName() <<
"->AddFile("<< quote <<
".." << quote <<
");" << std::endl;
924 out <<
" " <<
GetName() <<
"->StopRefreshTimer();" << std::endl;
ULong_t Pixel_t
Pixel value.
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Bool_t R_ISFIFO(Int_t mode)
Bool_t R_ISSOCK(Int_t mode)
Bool_t R_ISBLK(Int_t mode)
Bool_t R_ISREG(Int_t mode)
Bool_t R_ISLNK(Int_t mode)
Bool_t R_ISDIR(Int_t mode)
R__EXTERN TSystem * gSystem
Bool_t R_ISCHR(Int_t mode)
void WriteObject(const TObject *obj, Bool_t cacheReuse=kTRUE) override
Write object to I/O buffer.
virtual void Layout()
Create layout for canvas.
const TGWindow * GetDefaultRoot() const
Returns the root (i.e.
TGMimeTypes * GetMimeTypeList() const
const TGPicture * GetPicture(const char *name)
Get picture from the picture pool.
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
TGPicturePool * GetPicturePool() const
void FreePicture(const TGPicture *pic)
Free picture resource.
virtual void MapSubwindows()
Map all sub windows that are part of the composite frame.
static TGLayoutHints * fgDefaultHints
const TGWindow * fMsgWindow
TGCanvas * GetCanvas() const
virtual void RemoveAll()
Remove all items from the container.
const TGPicture * fSlink_s
void CreateFileList()
This function creates the file list from current dir.
const TGPicture * fFolder_s
TViewUpdateTimer * fRefresh
void StopRefreshTimer()
stop refresh timer
virtual Bool_t HandleTimer(TTimer *t)
Refresh container contents.
virtual void Sort(EFSSortMode sortType)
Sort file system list view container according to sortType.
virtual void ChangeDirectory(const char *path)
Change current directory.
const TGPicture * fSlink_t
virtual void DisplayDirectory()
Display the contents of the current directory in the container.
virtual TGFileItem * AddFile(const char *name, const TGPicture *pic=nullptr, const TGPicture *lpic=nullptr)
Add file in container.
virtual TGFileItem * AddRemoteFile(TObject *obj, const TGPicture *ipic=nullptr, const TGPicture *ilpic=nullptr)
Add remote file in container.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a file container widget as a C++ statement(s) on output stream out.
void StartRefreshTimer(ULong_t msec=1000)
start refreshing
const TGPicture * fFolder_t
friend class TGFSFrameElement
virtual ~TGFileContainer()
Delete list view file container.
virtual void SetFilter(const char *filter)
Set file selection filter.
virtual void GetFilePictures(const TGPicture **pic, const TGPicture **lpic, Int_t file_type, Bool_t is_link, const char *ext, Bool_t small)
Determine the file picture for the given file type.
TGFileContainer(const TGWindow *p=nullptr, UInt_t w=1, UInt_t h=1, UInt_t options=kSunkenFrame, Pixel_t back=GetDefaultFrameBackground())
Create a list view container which will hold the contents of the current directory.
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame.
const TGPicture * fLcurrent
void Init(const TGPicture *blpic, const TGPicture *slpic, FileStat_t &stat, EListViewMode viewMode)
Common initializer for file list view item.
void SetDNDObject(TObject *obj)
Set drag and drop object.
Long_t GetModTime() const
virtual void DoRedraw()
Draw list view container item.
void SetDNDData(TDNDData *data)
Set drag and drop data.
virtual void SetViewMode(EListViewMode viewMode)
Set container item view mode.
virtual Atom_t HandleDNDEnter(Atom_t *)
Handle drag and drop enter.
TGFileItem(const TGWindow *p=nullptr, const TGPicture *bpic=nullptr, const TGPicture *blpic=nullptr, const TGPicture *spic=nullptr, const TGPicture *slpic=nullptr, TGString *name=nullptr, Int_t type=0, Long64_t size=1, Int_t uid=0, Int_t gid=0, Long_t modtime=0, EListViewMode viewMode=kLVList, UInt_t options=kVerticalFrame, Pixel_t back=GetWhitePixel())
Create a list view item.
virtual ~TGFileItem()
Destructor.
static Pixel_t GetWhitePixel()
Get white pixel value.
Bool_t IsDNDTarget() const
virtual void SendMessage(const TGWindow *w, Long_t msg, Long_t parm1, Long_t parm2)
Send message (i.e.
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
virtual UInt_t GetOptions() const
TString GetOptionString() const
Returns a frame option string - used in SavePrimitive().
void SaveUserColor(std::ostream &out, Option_t *)
Save a user color in a C++ macro file - used in SavePrimitive().
virtual void DoRedraw()
Redraw picture.
virtual void AddItem(TGLVEntry *item)
virtual void DoRedraw()
Redraw list view item.
virtual void SetViewMode(EListViewMode viewMode)
Set the view mode for this list item.
TGString * GetItemName() const
const TGPicture * GetIcon(const char *filename, Bool_t small_icon)
Return icon belonging to mime type of filename.
void FreePicture(const TGPicture *pic)
Remove picture from cache if nobody is using it anymore.
const TGPicture * GetPicture(const char *name)
Get a picture from the picture pool.
void Draw(Option_t *="")
Default Draw method for all objects.
const char * GetString() const
virtual void SetWindowName(const char *name=0)
Set window name.
virtual const TGWindow * GetMainFrame() const
Returns top level main frame.
virtual const char * GetName() const
Return unique name, used in SavePrimitive methods.
const TGWindow * GetParent() const
An abstract interface to image processing library.
static TImage * Open(const char *file, EImageFileTypes type=kUnknown)
Open a specified image file.
virtual void SetImage(const Double_t *, UInt_t, UInt_t, TImagePalette *=0)
static TImage * Create()
Create an image.
virtual void Merge(const TImage *, const char *="alphablend", Int_t=0, Int_t=0)
virtual Pixmap_t GetPixmap()
virtual Pixmap_t GetMask()
virtual void Add(TObject *obj)
virtual void Clear(Option_t *option="")
Remove all objects from the list.
virtual void Sort(Bool_t order=kSortAscending)
Sort linked list.
virtual const char * GetName() const
Returns name of object.
Mother of all ROOT objects.
virtual Bool_t IsSortable() const
virtual Int_t Compare(const TObject *obj) const
Compare abstract method.
Regular expression class.
The TRemoteObject class provides protocol for browsing ROOT objects from a remote ROOT session.
Bool_t GetFileStat(FileStat_t *sbuf)
Get remote file status.
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
const char * Data() const
TString & Prepend(const char *cs)
TString & Remove(Ssiz_t pos)
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
virtual void FreeDirectory(void *dirp)
Free a directory.
virtual void * OpenDirectory(const char *name)
Open a directory. Returns 0 if directory does not exist.
int GetPathInfo(const char *path, Long_t *id, Long_t *size, Long_t *flags, Long_t *modtime)
Get info about a file: id, size, flags, modification time.
virtual const char * GetDirEntry(void *dirp)
Get a directory entry. Returns 0 if no more entries.
virtual Bool_t ChangeDirectory(const char *path)
Change directory.
virtual void AddTimer(TTimer *t)
Add timer to list of system timers.
virtual const char * BaseName(const char *pathname)
Base name of a file name. Base name of /user/root is root.
virtual const char * WorkingDirectory()
Return working directory.
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
virtual const char * GetError()
Return system error string.
virtual UserGroup_t * GetUserInfo(Int_t uid)
Returns all user info in the UserGroup_t structure.
Handles synchronous and a-synchronous timer events.
virtual Bool_t Notify()
Notify when timer times out.