Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGFileBrowser.cxx
Go to the documentation of this file.
1// @(#)root/gui:$Id$
2// Author: Bertrand Bellenot 26/09/2007
3
4/*************************************************************************
5 * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#include "TROOT.h"
13#include "TSystem.h"
14#include "TApplication.h"
15#include "TGClient.h"
16#include "TGListTree.h"
17#include "TGLayout.h"
18#include "TGComboBox.h"
19#include "TContextMenu.h"
20#include "TGTextEntry.h"
21#include "TGTab.h"
22#include "TGLabel.h"
23#include "TSystemDirectory.h"
24#include "TGMimeTypes.h"
25#include "TClass.h"
26#include "TQClass.h"
27#include "TObjString.h"
28#include "TObjArray.h"
29#include "TInterpreter.h"
30#include "TRegexp.h"
31#include "TEnv.h"
32#include "TImage.h"
33#include "TBrowser.h"
34#include "TRemoteObject.h"
35#include "TKey.h"
36#include "TKeyMapFile.h"
37#include "TVirtualPad.h"
38#include "Getline.h"
39
40#include "TGFileBrowser.h"
41#include "TRootBrowser.h"
42#include "TGInputDialog.h"
43
44#include "TVirtualPadEditor.h"
45#include "TGedEditor.h"
46#include "TBaseClass.h"
47#include "TVirtualX.h"
48
49#include "RConfigure.h"
50
51#include <cstdio>
52#include <ctime>
53#include <cstring>
54#include <cstdlib>
55
56#ifdef WIN32
57const char rootdir[] = "\\";
58#else
59const char rootdir[] = "/";
60#endif
61
62const char *filters[] = {
63 "",
64 "*.*",
65 "*.[C|c|h]*",
66 "*.root",
67 "*.txt"
68};
69
70
71/** \class TCursorSwitcher
72 \ingroup guiwidgets
73
74Helper class used to change the cursor in a method and restore the
75original one when going out of the method scope.
76
77*/
78
79
80///////////////////////////////////////////////////////////////////////////////
82private:
85public:
86 TCursorSwitcher(TGWindow *w1, TGWindow *w2) : fW1(w1), fW2(w2) {
87 if (w1) gVirtualX->SetCursor(w1->GetId(), gVirtualX->CreateCursor(kWatch));
88 if (w2) gVirtualX->SetCursor(w2->GetId(), gVirtualX->CreateCursor(kWatch));
89 }
91 if (fW1) gVirtualX->SetCursor(fW1->GetId(), gVirtualX->CreateCursor(kPointer));
92 if (fW2) gVirtualX->SetCursor(fW2->GetId(), gVirtualX->CreateCursor(kPointer));
93 }
94};
95
96
97/** \class TGFileBrowser
98 \ingroup guiwidgets
99
100System file browser, used as TRootBrowser plug-in.
101This class is the real core of the ROOT browser.
102
103*/
104
105
106
107////////////////////////////////////////////////////////////////////////////////
108/// TGFileBrowser constructor.
109
111 : TGMainFrame(p, w, h), TBrowserImp(b), fNewBrowser(0)
112{
113 if (p && p != gClient->GetDefaultRoot())
114 fNewBrowser = (TRootBrowser *)p->GetMainFrame();
115 if (fNewBrowser)
118 Resize(w, h);
119 if (fBrowser) Show();
120}
121
122////////////////////////////////////////////////////////////////////////////////
123/// Create the actual file browser.
124
126{
127 fCachedPic = 0;
129
130 fTopFrame = new TGHorizontalFrame(this, 100, 30);
132 TGTextEntry *dropt_entry = fDrawOption->GetTextEntry();
133 dropt_entry->SetToolTipText("Object Draw Option", 300);
134 fDrawOption->Resize(80, 20);
136 lb->Resize(lb->GetWidth(), 120);
137 Int_t dropt = 1;
138 fDrawOption->AddEntry("", dropt++);
139 fDrawOption->AddEntry("box", dropt++);
140 fDrawOption->AddEntry("colz", dropt++);
141 fDrawOption->AddEntry("lego", dropt++);
142 fDrawOption->AddEntry("lego1", dropt++);
143 fDrawOption->AddEntry("lego2", dropt++);
144 fDrawOption->AddEntry("same", dropt++);
145 fDrawOption->AddEntry("surf", dropt++);
146 fDrawOption->AddEntry("surf1", dropt++);
147 fDrawOption->AddEntry("surf2", dropt++);
148 fDrawOption->AddEntry("surf3", dropt++);
149 fDrawOption->AddEntry("surf4", dropt++);
150 fDrawOption->AddEntry("surf5", dropt++);
151 fDrawOption->AddEntry("text", dropt++);
153 kLHintsRight, 2, 2, 2, 2));
154 fTopFrame->AddFrame(new TGLabel(fTopFrame, "Draw Option:"),
156 5, 2, 2, 2));
157
158 fSortButton = new TGPictureButton(fTopFrame, "bld_sortup.png");
159 fSortButton->SetStyle(gClient->GetStyle());
160 fSortButton->SetToolTipText("Sort Alphabetically\n(Current folder only)");
162 kLHintsLeft, 2, 2, 2, 2));
163 fSortButton->Connect("Clicked()", "TGFileBrowser", this, "ToggleSort()");
164
165 fFilterButton = new TGPictureButton(fTopFrame, "filter.png");
166 fFilterButton->SetStyle(gClient->GetStyle());
167 fFilterButton->SetToolTipText("Filter Content");
169 kLHintsLeft, 2, 2, 2, 2));
170 fFilterButton->Connect("Clicked()", "TGFileBrowser", this, "RequestFilter()");
171
172 fRefreshButton = new TGPictureButton(fTopFrame, "refresh.png");
173 fRefreshButton->SetStyle(gClient->GetStyle());
174 fRefreshButton->SetToolTipText("Refresh Current Folder");
176 kLHintsLeft, 2, 5, 2, 2));
177 fRefreshButton->Connect("Clicked()", "TGFileBrowser", this, "Refresh()");
178
180 kLHintsExpandX, 2, 2, 2, 2));
181 fCanvas = new TGCanvas(this, 100, 100);
185 fListTree->Connect("DoubleClicked(TGListTreeItem *, Int_t)",
186 "TGFileBrowser", this, "DoubleClicked(TGListTreeItem *, Int_t)");
187 fListTree->Connect("Clicked(TGListTreeItem *, Int_t, Int_t, Int_t)",
188 "TGFileBrowser", this, "Clicked(TGListTreeItem *, Int_t, Int_t, Int_t)");
189 fListTree->Connect("Checked(TObject*, Bool_t)", "TGFileBrowser",
190 this, "Checked(TObject*, Bool_t)");
191
192 fRootIcon = gClient->GetPicture("rootdb_t.xpm");
193 fFileIcon = gClient->GetPicture("doc_t.xpm");
194
195 fBotFrame = new TGHorizontalFrame(this, 100, 30);
196 fBotFrame->AddFrame(new TGLabel(fBotFrame, "Filter: "),
198 2, 2, 2, 2));
199 fFileType = new TGComboBox(fBotFrame, " All Files (*.*)");
200 Int_t ftype = 1;
201 fFileType->AddEntry(" All Files (*.*)", ftype++);
202 fFileType->AddEntry(" C/C++ Files (*.c;*.cxx;*.h;...)", ftype++);
203 fFileType->AddEntry(" ROOT Files (*.root)", ftype++);
204 fFileType->AddEntry(" Text Files (*.txt)", ftype++);
205 fFileType->Resize(200, 20);
207 kLHintsExpandX, 2, 2, 2, 2));
208 fFileType->Connect("Selected(Int_t)", "TGFileBrowser", this,
209 "ApplyFilter(Int_t)");
210 fFileType->GetTextEntry()->Connect("ReturnPressed()", "TGFileBrowser",
211 this, "ApplyFilter(Int_t = -1)");
213 kLHintsExpandX, 2, 2, 2, 2));
214
215 fContextMenu = new TContextMenu("FileBrowserContextMenu");
216 fFilter = nullptr;
217 fGroupSize = 1000;
218 fListLevel = 0;
219 fCurrentDir = 0;
220 fRootDir = 0;
221 fDir = nullptr;
222 fFile = nullptr;
223 fNKeys = 0;
224 fCnt = 0;
225 fFilterStr = "*";
226
227 TString gv = gEnv->GetValue("Browser.GroupView", "1000");
228 Int_t igv = atoi(gv.Data());
229 if (igv > 10)
230 fGroupSize = igv;
231
232 if (gEnv->GetValue("Browser.ShowHidden", 0))
234 else
236
238
239 TQObject::Connect("TPad", "Modified()",
240 "TGFileBrowser", this, "PadModified()");
241
242 fListLevel = 0;
245 MapWindow();
246}
247
248////////////////////////////////////////////////////////////////////////////////
249/// Destructor.
250
252{
253 TQObject::Disconnect("TPad", "Modified()");
254
255 delete fContextMenu;
256 delete fListTree;
257 delete fFilter;
258 delete fDir;
259 delete fFile;
261 if (fCachedPic && (fCachedPic != fFileIcon))
264 Cleanup();
265}
266
267////////////////////////////////////////////////////////////////////////////////
268/// Helper function checking if a class has a graphic properties editor.
269
271{
272 TBaseClass *base;
273 TList* bcl = cl->GetListOfBases();
274 TIter next(bcl);
275 while ((base = (TBaseClass*) next())) {
276 cl = base->GetClassPointer();
277 if (cl && TClass::GetClass(Form("%sEditor", cl->GetName())))
278 return kTRUE;
279 if (cl && IsObjectEditable(cl))
280 return kTRUE;
281 }
282 return kFALSE;
283}
284
285////////////////////////////////////////////////////////////////////////////////
286/// Format the tooltip information, based on the object passed in argument.
287
288static const char *FormatToolTip(TObject *obj, Int_t maxlen=0)
289{
290 static TString infos;
291 if (!obj) {
292 infos.Clear();
293 return 0;
294 }
295 infos = obj->GetName();
296 if (obj->GetTitle()) {
297 infos += "\n";
298 infos += obj->GetTitle();
299 }
300 if (maxlen > 0 && infos.Length() > maxlen) {
301 infos.Remove(maxlen - 3);
302 infos += "...";
303 }
304 TString objinfo = obj->GetObjectInfo(1, 1);
305 if (!objinfo.IsNull() && !objinfo.BeginsWith("x=")) {
306 Long64_t bsize, fsize, objsize;
307 objsize = objinfo.Atoll();
308 if (objsize > 0) {
309 infos += "\n";
310 bsize = fsize = objsize;
311 if (fsize > 1024) {
312 fsize /= 1024;
313 if (fsize > 1024) {
314 // 3.7MB is more informative than just 3MB
315 infos += TString::Format("Size: %lld.%lldM", fsize/1024,
316 (fsize%1024)/103);
317 } else {
318 infos += TString::Format("Size: %lld.%lldK", bsize/1024,
319 (bsize%1024)/103);
320 }
321 } else {
322 infos += TString::Format("Size: %lld bytes", bsize);
323 }
324 }
325 }
326 return infos.Data();
327}
328
329/**************************************************************************/
330// TBrowserImp virtuals
331/**************************************************************************/
332
333////////////////////////////////////////////////////////////////////////////////
334/// Add items to the browser. This function has to be called
335/// by the Browse() member function of objects when they are
336/// called by a browser. If check < 0 (default) no check box is drawn,
337/// if 0 then unchecked checkbox is added, if 1 checked checkbox is added.
338
339void TGFileBrowser::Add(TObject *obj, const char *name, Int_t check)
340{
341 if (fListLevel && !strcmp(fListLevel->GetText(), "Classes") &&
343 !strcmp(fListLevel->GetParent()->GetText(), "root")) {
344 // Browsing list of root classes...
345 }
346 else {
347 if (obj && obj->InheritsFrom("TApplication"))
348 fListLevel = 0;
349 if (obj && obj->InheritsFrom("TSystemDirectory"))
350 return;
351 }
352 if (fListLevel) {
353 TString oname = "";
354 if (name)
355 oname = name;
356 else if (obj)
357 oname = obj->GetName();
358 // check if the current item is filtered
359 auto it = fFilteredItems.find(fListLevel);
360 if (it != fFilteredItems.end()) {
361 // check if the item (object) name match the filter
362 const char *filter = it->second.c_str();
363 TRegexp re(filter, kTRUE);
364 // if not, simply return, so no item will be added
365 if (oname.Index(re) == kNPOS) return;
366 }
367 }
368 const TGPicture *pic = nullptr;
369 if (obj && obj->InheritsFrom("TKey") && (obj->IsA() != TClass::Class()))
370 AddKey(fListLevel, obj, name);
371 else if (obj) {
372 GetObjPicture(&pic, obj);
373 if (!name) name = obj->GetName();
374 if (check > -1) {
377 pic, pic, kTRUE);
378 if ((pic != fFileIcon) && (pic != fCachedPic))
379 fClient->FreePicture(pic);
380 if (item) fListTree->CheckItem(item, (Bool_t)check);
381 fListTree->SetToolTipItem(item, FormatToolTip(obj, 32));
382 }
383 }
384 else {
385 // special case for remote object
386 Bool_t isRemote = kFALSE;
387 if (obj->InheritsFrom("TRemoteObject"))
388 isRemote = kTRUE;
389 else if (fListLevel) {
390 // check also if one of its parents is a remote object
392 while (top->GetParent()) {
393 TObject *tobj = (TObject *) top->GetUserData();
394 if (tobj && (tobj->InheritsFrom("TRemoteObject") ||
395 tobj->InheritsFrom("TApplicationRemote"))) {
396 isRemote = kTRUE;
397 break;
398 }
399 top = top->GetParent();
400 }
401 }
402 if (isRemote) {
403 TRemoteObject *robj = (TRemoteObject *)obj;
404 if (!strcmp(robj->GetClassName(), "TKey")) {
405 AddKey(fListLevel, obj, name);
406 }
407 else {
408 TString fname = name;
409 // add the remote object only if not already in the list
410 if (!fShowHidden && fname.BeginsWith("."))
411 return;
412 AddRemoteFile(obj);
413 }
414 }
415 else {
417 TGListTreeItem *item = fListTree->AddItem(fListLevel, name, obj, pic, pic);
418 if ((pic != fFileIcon) && (pic != fCachedPic))
419 fClient->FreePicture(pic);
420 if (item && obj && obj->InheritsFrom("TObject"))
421 item->SetDNDSource(kTRUE);
422 fListTree->SetToolTipItem(item, FormatToolTip(obj, 32));
423 }
424 }
425 }
426 }
427}
428
429////////////////////////////////////////////////////////////////////////////////
430/// Add remote file in list tree.
431
433{
434 Bool_t is_link;
435 Int_t type;
437 const TGPicture *spic;
438 TGPicture *pic;
439
440 FileStat_t sbuf;
441
442 TRemoteObject *robj = (TRemoteObject *)obj;
443
444 robj->GetFileStat(&sbuf);
445 is_link = sbuf.fIsLink;
446 type = sbuf.fMode;
447 filename = robj->GetName();
448 if (R_ISDIR(type) || fFilter == 0 ||
449 (fFilter && filename.Index(*fFilter) != kNPOS)) {
450
451 GetFilePictures(&spic, type, is_link, filename);
452
453 pic = (TGPicture*)spic; pic->AddReference();
454
457 fListTree->AddItem(fListLevel, filename, obj, pic, pic);
458 }
459}
460
461////////////////////////////////////////////////////////////////////////////////
462/// Browse object. This, in turn, will trigger the calling of
463/// TBrowser::Add() which will fill the IconBox and the tree.
464/// Emits signal "BrowseObj(TObject*)".
465
467{
468 if (fNewBrowser)
470 if (obj != gROOT) {
472 fListLevel = 0;
473 Add(obj);
476 if (obj->IsFolder())
480 }
481 }
482 if (fBrowser) obj->Browse(fBrowser);
483 if (obj == gROOT) {
484 TList *volumes = gSystem->GetVolumes("all");
485 TList *curvol = gSystem->GetVolumes("cur");
486 if (volumes && curvol) {
487 const char *curdrive;
488 TNamed *named = (TNamed *)curvol->At(0);
489 if (named)
490 curdrive = named->GetName();
491 else
492 curdrive = "C:";
493 TIter next(volumes);
494 TNamed *drive;
495 while ((drive = (TNamed *)next())) {
496 AddFSDirectory(TString::Format("%s\\", drive->GetName()), drive->GetTitle(),
497 (strcmp(drive->GetName(), curdrive) == 0) ?
498 "SetRootDir" : "Add");
499 }
500 delete volumes;
501 delete curvol;
502 }
503 else {
504 AddFSDirectory("/");
505 }
507 if (gROOT->GetListOfFiles() && !gROOT->GetListOfFiles()->IsEmpty())
508 Selected(0);
509 }
510}
511
512////////////////////////////////////////////////////////////////////////////////
513/// Emits signal when double clicking on icon.
514
516{
517 if (fNewBrowser)
518 fNewBrowser->Checked(obj, checked);
519}
520
521////////////////////////////////////////////////////////////////////////////////
522/// returns drawing option
523
528
529////////////////////////////////////////////////////////////////////////////////
530/// Determine the file picture for the given file type.
531
533 Bool_t is_link, const char *name)
534{
535 static TString cached_ext;
536 static const TGPicture *cached_spic = 0;
537 const char *ext = name ? strrchr(name, '.') : 0;
538 TString sname = name ? name : " ";
539 *pic = 0;
540
541 if (ext && cached_spic && (cached_ext == ext)) {
542 *pic = cached_spic;
543 return;
544 }
545
546 if (R_ISREG(file_type)) {
547 *pic = gClient->GetMimeTypeList()->GetIcon(name, kTRUE);
548
549 if (*pic) {
550 if (ext) {
551 cached_ext = ext;
552 cached_spic = *pic;
553 return;
554 }
555 }
556 } else {
557 *pic = 0;
558 }
559
560 if (*pic == 0) {
561 *pic = gClient->GetPicture("doc_t.xpm");
562
563 if (R_ISREG(file_type) && (file_type) & kS_IXUSR) {
564 *pic = gClient->GetPicture("app_t.xpm");
565 }
566 if (R_ISDIR(file_type)) {
567 *pic = gClient->GetPicture("folder_t.xpm");
568 }
569 if(sname.EndsWith(".root")) {
570 *pic = gClient->GetPicture("rootdb_t.xpm");
571 }
572
573 }
574 if (is_link) {
575 *pic = gClient->GetPicture("slink_t.xpm");
576 }
577
578 cached_spic = 0;
579 cached_ext = "";
580}
581
582////////////////////////////////////////////////////////////////////////////////
583/// Recursively remove object.
584
586{
587 TGListTreeItem *itm = nullptr, *item = nullptr;
588 if (obj->InheritsFrom("TFile")) {
589 itm = fListTree->FindChildByData(0, gROOT->GetListOfFiles());
590 if (itm)
591 item = fListTree->FindChildByData(itm, obj);
592 if (item) {
593 // if the item to be deleted has a filter,
594 // delete its entry in the map
595 if (CheckFiltered(item))
596 fFilteredItems.erase(item);
597 fListTree->DeleteItem(item);
598 }
599 itm = fRootDir ? fRootDir->GetFirstChild() : nullptr;
600 while (itm) {
601 item = fListTree->FindItemByObj(itm, obj);
602 if (item) {
604 item->SetUserData(0);
605 }
606 itm = itm->GetNextSibling();
607 }
608 }
609 if (!obj->InheritsFrom("TFile") && fRootDir) {
610 item = fListTree->FindItemByObj(fRootDir, obj);
611 // if the item to be deleted has a filter, delete its entry in the map
612 if (item && CheckFiltered(item))
613 fFilteredItems.erase(item);
615 }
616 //fListTree->ClearViewPort();
617}
618
619////////////////////////////////////////////////////////////////////////////////
620/// Refresh content of the list tree.
621
623{
624 TTimer::SingleShot(200, "TGFileBrowser", this, "Update()");
625}
626
627////////////////////////////////////////////////////////////////////////////////
628/// Update content of the list tree.
629
631{
632 Long64_t size = 0;
633 Long_t id = 0, flags = 0, modtime = 0;
634 char path[1024];
636 if (!item) item = fRootDir;
637 if (!item) return;
638 //fListTree->DeleteChildren(item);
639 TGListTreeItem *curr = fListTree->GetSelected(); // GetCurrent() ??
640 if (curr) {
641 TObject *obj = (TObject *) curr->GetUserData();
642 if (obj && ROOT::Detail::HasBeenDeleted(obj)) {
643 // if the item to be deleted has a filter,
644 // delete its entry in the map
645 if (CheckFiltered(curr))
646 fFilteredItems.erase(curr);
647 fListTree->DeleteItem(curr);
648 curr = 0;
649 obj = 0;
650 }
651 else if (obj && !ROOT::Detail::HasBeenDeleted(obj) &&
652 obj->InheritsFrom("TObjString") && curr->GetParent()) {
654 if (strlen(path) > 1) {
655 TString dirpath = FullPathName(curr->GetParent());
656 Int_t res = gSystem->GetPathInfo(dirpath.Data(), &id, &size,
657 &flags, &modtime);
658 if ((res == 0) && (flags & 2)) {
659 TString fullpath = FullPathName(curr);
660 if (gSystem->AccessPathName(fullpath.Data())) {
661 // if the item to be deleted has a filter,
662 // delete its entry in the map
663 if (CheckFiltered(curr))
664 fFilteredItems.erase(curr);
665 fListTree->DeleteItem(curr);
666 curr = 0;
667 obj = 0;
668 }
669 }
670 }
671 }
672 }
673 TString actpath = FullPathName(item);
674 flags = id = size = modtime = 0;
675 if (gSystem->GetPathInfo(actpath.Data(), &id, &size, &flags, &modtime) == 0) {
676 Int_t isdir = (Int_t)flags & 2;
677
678 TString savdir = gSystem->WorkingDirectory();
679 if (isdir) {
680 TGListTreeItem *del = 0, *itm = item->GetFirstChild();
681 while (itm) {
682 fListTree->GetPathnameFromItem(itm, path);
683 if (strlen(path) > 1) {
684 TString recpath = FullPathName(itm);
685 if (gSystem->AccessPathName(recpath.Data())) {
686 del = itm;
687 itm = itm->GetNextSibling();
688 // if the item to be deleted has a filter,
689 // delete its entry in the map
690 if (CheckFiltered(del))
691 fFilteredItems.erase(del);
693 }
694 }
695 if (del)
696 del = 0;
697 else
698 itm = itm->GetNextSibling();
699 }
700 }
701 }
703 DoubleClicked(item, 1);
704 fListLevel = sav;
706}
707
708/**************************************************************************/
709// Other
710/**************************************************************************/
711
712////////////////////////////////////////////////////////////////////////////////
713/// Add file system directory in the list tree.
714
715void TGFileBrowser::AddFSDirectory(const char *entry, const char *path,
716 Option_t *opt)
717{
718 TGListTreeItem *item = 0;
719 if ((opt == 0) || (!opt[0])) {
720 if (fRootDir == 0 && !fListTree->FindChildByName(0, rootdir))
722 return;
723 }
724 if (strstr(opt, "SetRootDir")) {
725 if (!fListTree->FindChildByName(0, entry))
726 item = fRootDir = fListTree->AddItem(0, entry);
727 }
728 else if (strstr(opt, "Add")) {
729 // MT: i give up! wanted to place entries for selected
730 // directories like home, pwd, alice-macros.
731 // TGListTreeItem *lti = fListTree->AddItem(0, entry);
732 //
733 if (!fListTree->FindChildByName(0, entry))
734 item = fListTree->AddItem(0, entry);
735 }
736 if (item && path) {
737 TString infos = path;
738 item->SetTipText(path);
739 TGPicture *pic = 0;
740 if (infos.Contains("Removable"))
741 pic = (TGPicture *)gClient->GetPicture("fdisk_t.xpm");
742 else if (infos.Contains("Local"))
743 pic = (TGPicture *)gClient->GetPicture("hdisk_t.xpm");
744 else if (infos.Contains("CD"))
745 pic = (TGPicture *)gClient->GetPicture("cdrom_t.xpm");
746 else if (infos.Contains("Network"))
747 pic = (TGPicture *)gClient->GetPicture("netdisk_t.xpm");
748 if (pic) {
749 item->SetPictures(pic, pic);
750 gClient->FreePicture(pic);
751 }
752 }
753}
754
755////////////////////////////////////////////////////////////////////////////////
756/// display content of ROOT file
757
759{
760 // Int_t from, to;
761 TGListTreeItem *where;
762 static TGListTreeItem *olditem = itm;
763 static TGListTreeItem *item = itm;
764 const TGPicture *pic;
765
766 if (itm == 0) return;
767
768 if ((fCnt == 0) || (olditem != itm)) {
769 olditem = item = itm;
770 }
771 if (!name) name = obj->GetName();
772 if (fNKeys > fGroupSize) {
773 where = itm->GetFirstChild();
774 while (where) {
775 if (fListTree->FindItemByObj(where, obj))
776 return;
777 where = where->GetNextSibling();
778 }
779 }
780 if ((fNKeys > fGroupSize) && (fCnt % fGroupSize == 0)) {
781 if (item != itm) {
782 TString newname = TString::Format("%s-%s", item->GetText(), name);
783 item->Rename(newname.Data());
784 }
785 item = fListTree->AddItem(itm, name);
786 item->SetDNDSource(kTRUE);
787 }
788 if ((fCnt > fGroupSize) && (fCnt >= fNKeys-1)) {
789 TString newname = TString::Format("%s-%s", item->GetText(), name);
790 item->Rename(newname.Data());
791 }
792 GetObjPicture(&pic, obj);
793 if (!fListTree->FindChildByName(item, name)) {
794 TGListTreeItem *it = fListTree->AddItem(item, name, obj, pic, pic);
795 if (pic && (pic != fFileIcon) && (pic != fCachedPic))
796 fClient->FreePicture(pic);
797 it->SetDNDSource(kTRUE);
798 it->SetTipText(FormatToolTip(obj, 32));
799 }
800 fCnt++;
801}
802
803////////////////////////////////////////////////////////////////////////////////
804/// Apply filter selected in combo box to the file tree view.
805
807{
808 // Long64_t size;
809 // Long_t fid, flags, modtime;
810
811 if (fFilter)
812 delete fFilter;
813 fFilter = nullptr;
814 if ((id > 1) && (id < 5))
815 fFilter = new TRegexp(filters[id], kTRUE);
816 else if ((id < 0) || (id > 4)) {
818 if (lbe) {
819 const char *text = lbe->GetTitle();
820 fFilter = new TRegexp(text, kTRUE);
821 }
822 }
824 if (!item)
825 item = fRootDir;
826 if (!item) return;
828 DoubleClicked(item, 1);
829 //fListTree->AdjustPosition(item);
831}
832
833////////////////////////////////////////////////////////////////////////////////
834/// Make object associated with item the current directory.
835
837{
838 if (item) {
839 TGListTreeItem *i = item;
840 while (i) {
841 TObject *obj = (TObject*) i->GetUserData();
842 if ((obj) && obj->InheritsFrom("TDirectory")) {
843 ((TDirectory *)obj)->cd();
844 break;
845 }
846 i = i->GetParent();
847 }
848 }
849}
850
851////////////////////////////////////////////////////////////////////////////////
852/// Check if the current list tree item points to a remote object.
853
855{
856 if (!item) return;
857 TObject *obj = (TObject *) item->GetUserData();
858 if (obj) {
859 if (obj->InheritsFrom("TApplicationRemote")) {
860 if (!gApplication->GetAppRemote()) {
861 gROOT->ProcessLine(TString::Format(".R %s", item->GetText()));
862 if (gApplication->GetAppRemote()) {
863 Getlinem(kInit, TString::Format("\n%s:root [0]",
865 }
866 }
867 }
868 if (item->GetParent() && item->GetParent()->GetUserData() &&
869 ((TObject *)item->GetParent()->GetUserData())->InheritsFrom("TApplicationRemote")) {
870 // switch to remote session
871 if (!gApplication->GetAppRemote()) {
872 gROOT->ProcessLine(TString::Format(".R %s", item->GetParent()->GetText()));
873 if (gApplication->GetAppRemote()) {
874 Getlinem(kInit, TString::Format("\n%s:root [0]",
876 }
877 }
878 else if (!strcmp(item->GetText(), "ROOT Files")) {
879 // update list of files opened in the remote session
881 gApplication->ProcessLine("((TApplicationServer *)gApplication)->BrowseFile(0);");
882 }
883 }
884 else {
885 // check if the listtree item is from a local session or
886 // from a remote session, then switch to the session it belongs to
887 TGListTreeItem *top = item;
888 while (top->GetParent()) {
889 top = top->GetParent();
890 }
891 TObject *topobj = (TObject *) top->GetUserData();
892 if (topobj && topobj->InheritsFrom("TApplicationRemote")) {
893 // it belongs to a remote session
894 if (!gApplication->GetAppRemote()) {
895 // switch to remote session if not already in
896 gROOT->ProcessLine(TString::Format(".R %s", top->GetText()));
897 if (gApplication->GetAppRemote()) {
898 Getlinem(kInit, TString::Format("\n%s:root [0]",
900 }
901 }
902 }
903 else if (gApplication->GetAppRemote()) {
904 // switch back to local session if not already in
906 Getlinem(kInit, "\nroot [0]");
907 }
908 }
909 }
910 else if (gApplication->GetAppRemote()) {
911 // switch back to local session if not already in
913 Getlinem(kInit, "\nroot [0]");
914 }
915}
916
917////////////////////////////////////////////////////////////////////////////////
918/// Check if there is a filter active on the children of the list tree item.
919/// If the but argument is true, the "filter" button state is set accordingly,
920/// and its tooltip will show the filter used.
921
923{
924 Bool_t found = kFALSE;
925 TString filter;
926 // if there is no filter (the map is empty) then just return
927 if (fFilteredItems.empty())
928 return kFALSE;
929 auto it = fFilteredItems.find(item);
930 if (it != fFilteredItems.end()) {
931 // if the item is in the map, take the filter regexp string
932 filter = it->second.c_str();
933 fFilterStr = filter;
934 found = kTRUE;
935 }
936 if (but) {
937 // if the but argument is true, change the button state
938 // to reflect the filtering state
940 if (found) {
941 // format the tooltip to display the regexp used as filter
942 filter.Prepend("Showing only \'");
943 filter += "\'";
945 }
946 else {
947 // reset the tooltip text
948 fFilterButton->SetToolTipText("Filter Content...");
949 }
950 }
951 return found;
952}
953
954////////////////////////////////////////////////////////////////////////////////
955/// Check if the list tree item children are alphabetically sorted.
956/// If the but argument is true, the "sort" button state is set accordingly.
957
959{
960 Bool_t found = kFALSE;
961 TGListTreeItem *i, *itm;
962 if (item->GetFirstChild())
963 itm = item;
964 else
965 itm = item->GetParent();
966 for (sLTI_i p=fSortedItems.begin(); p!=fSortedItems.end(); ++p) {
967 i = (TGListTreeItem *)(*p);
968 if (itm == i) {
969 found = kTRUE;
970 break;
971 }
972 }
973 if (but) fSortButton->SetState(found ? kButtonEngaged : kButtonUp);
974 return found;
975}
976
977////////////////////////////////////////////////////////////////////////////////
978/// Process mouse clicks in TGListTree.
979
981{
982 char path[1024];
983 Long64_t size = 0;
984 Long_t id = 0, flags = 0, modtime = 0;
985 fListLevel = item;
986 if (!item) return;
987 CheckSorted(item, kTRUE);
988 CheckFiltered(item, kTRUE);
989 CheckRemote(item);
990 TObject *selected = 0;
991 TString fullpath = FullPathName(item);
992 TObject *obj = (TObject *) item->GetUserData();
993 if (obj && (!obj->InheritsFrom("TObjString") ||
994 gSystem->AccessPathName(fullpath.Data()))) {
995 if (obj->InheritsFrom("TKey") && (obj->IsA() != TClass::Class())) {
996 Chdir(item);
997 const char *clname = ((TKey *)obj)->GetClassName();
998 if (clname && strcmp(clname, "TGeoManager")) {
999 TClass *cl = TClass::GetClass(clname);
1000 TString name = ((TKey *)obj)->GetName();
1001 name += ";";
1002 name += ((TKey *)obj)->GetCycle();
1003 void *add = gDirectory->FindObjectAny((char *) name.Data());
1004 if (add && cl->IsTObject()) {
1005 obj = (TObject*)add;
1006 // don't change the user data, to avoid deletion of the
1007 // list tree item by RecursiveRemove()
1008 // it is better to read the object each time anyway,
1009 // as it may have changed in the file
1010 if (obj->InheritsFrom("TDirectory") || obj->InheritsFrom("TList"))
1011 item->SetUserData(obj);
1012 }
1013 }
1014 }
1015 if (obj->InheritsFrom("TLeaf") ||
1016 obj->InheritsFrom("TBranch")) {
1017 Chdir(item);
1018 }
1019 if (btn == kButton3)
1020 fContextMenu->Popup(x, y, obj, fBrowser);
1021 selected = obj;
1022 }
1023 else {
1024 fListTree->GetPathnameFromItem(item, path);
1025 if (strlen(path) > 3) {
1026 if (gSystem->GetPathInfo(fullpath.Data(), &id, &size, &flags, &modtime) == 0) {
1027 if (flags & 2) {
1028 fCurrentDir = item;
1029 if (btn == kButton3) {
1030 if (fDir) delete fDir;
1031 fDir = new TSystemDirectory(item->GetText(), fullpath.Data());
1033 }
1034 }
1035 else {
1036 fCurrentDir = item->GetParent();
1037 if (btn == kButton3) {
1038 if (fFile) delete fFile;
1039 fFile = new TSystemFile(item->GetText(), fullpath.Data());
1041 }
1042 }
1043 }
1044 }
1045 }
1047 if (selected && (selected->IsA() != TClass::Class())) {
1048 if (selected->InheritsFrom("TLeaf"))
1049 selected = (TObject *)gROOT->ProcessLine(TString::Format("((TLeaf *)0x%zx)->GetBranch()->GetTree();", (size_t)selected));
1050 if (selected->InheritsFrom("TBranch"))
1051 selected = (TObject *)gROOT->ProcessLine(TString::Format("((TBranch *)0x%zx)->GetTree();", (size_t)selected));
1052 if (selected->InheritsFrom("TTree")) {
1053 // if a tree not attached to any directory (e.g. in a TFolder)
1054 // then attach it to the current directory (gDirectory)
1055 TDirectory *tdir = (TDirectory *)gROOT->ProcessLine(TString::Format("((TTree *)0x%zx)->GetDirectory();", (size_t)selected));
1056 if (!tdir) {
1057 gROOT->ProcessLine(TString::Format("((TTree *)0x%zx)->SetDirectory(gDirectory);", (size_t)selected));
1058 }
1059 }
1060 }
1061 if (selected && gPad && IsObjectEditable(selected->IsA())) {
1063 if (ved) {
1064 TGedEditor *ged = (TGedEditor *)ved;
1065 ged->SetModel(gPad, selected, kButton1Down);
1066 }
1067 }
1068}
1069
1070////////////////////////////////////////////////////////////////////////////////
1071/// returns an absolute path
1072
1074{
1075 TGListTreeItem *parent, *itm = item;
1076 TString dirname = itm->GetText();
1077
1078 while ((parent=itm->GetParent())) {
1079 gSystem->PrependPathName(parent->GetText(), dirname);
1080 itm = parent;
1081 }
1082 gSystem->ExpandPathName(dirname);
1083#ifdef R__WIN32
1084 // only handle .lnk files on Windows
1085 while (dirname.Contains(".lnk")) {
1086 Ssiz_t idx = dirname.Index(".lnk") + 4;
1087 TString resolved = dirname;
1088 resolved.Remove(idx);
1089 gSystem->ExpandPathName(resolved);
1090 dirname = resolved.Append(dirname.Remove(0, idx));
1091 }
1092#endif
1093 return dirname;
1094}
1095
1096////////////////////////////////////////////////////////////////////////////////
1097/// returns the directory path
1098
1100{
1101 TString dirname;
1102 TString fullpath = FullPathName(item);
1103
1104#ifdef WIN32
1105 char winDrive[256];
1106 char winDir[256];
1107 char winName[256];
1108 char winExt[256];
1109 _splitpath(fullpath.Data(), winDrive, winDir, winName, winExt);
1110 dirname = TString::Format("%s%s", winDrive, winDir);
1111#else
1112 dirname = gSystem->GetDirName(fullpath);
1113#endif
1114 return dirname;
1115}
1116
1117////////////////////////////////////////////////////////////////////////////////
1118/// Returns true if given a text file
1119/// Uses the specification given on p86 of the Camel book
1120/// - Text files have no NULLs in the first block
1121/// - and less than 30% of characters with high bit set
1122
1123static Bool_t IsTextFile(const char *candidate)
1124{
1125 Int_t i;
1126 Int_t nchars;
1127 Int_t weirdcount = 0;
1128 char buffer[512];
1129 FILE *infile;
1130 FileStat_t buf;
1131
1132 if (gSystem->GetPathInfo(candidate, buf) || !(buf.fMode & kS_IFREG))
1133 return kFALSE;
1134
1135 infile = fopen(candidate, "r");
1136 if (infile) {
1137 // Read a block
1138 nchars = fread(buffer, 1, 512, infile);
1139 fclose (infile);
1140 // Examine the block
1141 for (i = 0; i < nchars; i++) {
1142 if (buffer[i] & 128)
1143 weirdcount++;
1144 if (buffer[i] == '\0')
1145 // No NULLs in text files
1146 return kFALSE;
1147 }
1148 if ((nchars > 0) && ((weirdcount * 100 / nchars) > 30))
1149 return kFALSE;
1150 } else {
1151 // Couldn't open it. Not a text file then
1152 return kFALSE;
1153 }
1154 return kTRUE;
1155}
1156
1157////////////////////////////////////////////////////////////////////////////////
1158/// Create a symlink (shortcut on Windows) icon by merging the picture
1159/// passed as argument and the slink_t.xpm icon (small arrow)
1160
1161static const TGPicture *MakeLinkPic(const TGPicture *pic)
1162{
1163 if (pic) {
1164 auto img1 = TImage::Create();
1165 if (!img1) return pic;
1166 img1->SetImage(((const TGPicture *)pic)->GetPicture(),
1167 ((const TGPicture *)pic)->GetMask());
1168 auto img2 = TImage::Open("slink_t.xpm");
1169 if (img2) img1->Merge(img2);
1170 TString lnk_name = ((const TGPicture *)pic)->GetName();
1171 lnk_name.Prepend("lnk_");
1172 auto merged = gClient->GetPicturePool()->GetPicture(lnk_name.Data(),
1174 if (img2) delete img2;
1175 delete img1;
1176 return merged;
1177 }
1178 return pic;
1179}
1180
1181////////////////////////////////////////////////////////////////////////////////
1182/// Process double clicks in TGListTree.
1183
1185{
1186 const TGPicture *pic=0;
1187 TString dirname = DirName(item);
1188 TString fullpath = FullPathName(item);
1189 TGListTreeItem *itm;
1190 FileStat_t sbuf;
1191 Long64_t size;
1192 Long_t id, flags, modtime;
1193 char action[512];
1194 TString act;
1195 Bool_t is_link = kFALSE;
1196 if (!gSystem->GetPathInfo(item->GetText(), sbuf) && sbuf.fIsLink) {
1197 is_link = kTRUE;
1198 fullpath = item->GetText();
1199 gSystem->ExpandPathName(fullpath);
1200 }
1201
1202 if (fNewBrowser)
1204 TCursorSwitcher switcher(this, fListTree);
1205 fListLevel = item;
1206 CheckSorted(item, kTRUE);
1207 CheckFiltered(item, kTRUE);
1208 CheckRemote(item);
1209 TGListTreeItem *pitem = item->GetParent();
1210 TObject *obj = (TObject *) item->GetUserData();
1211 if (obj && !obj->InheritsFrom("TSystemFile")) {
1212 TString ext = obj->GetName();
1213 if (obj->InheritsFrom("TDirectory") && (obj->IsA() != TClass::Class())) {
1214 if (((TDirectory *)obj)->GetListOfKeys())
1215 fNKeys = ((TDirectory *)obj)->GetListOfKeys()->GetEntries();
1216 else
1217 fNKeys = 0;
1218 }
1219 else if (obj->InheritsFrom("TKey") && (obj->IsA() != TClass::Class())) {
1220 Chdir(item);
1221 const char *clname = ((TKey *)obj)->GetClassName();
1222 if (clname) {
1223 TClass *cl = TClass::GetClass(clname);
1224 TString name = ((TKey *)obj)->GetName();
1225 name += ";";
1226 name += ((TKey *)obj)->GetCycle();
1227 void *add = gDirectory->FindObjectAny((char *) name.Data());
1228 if (add && cl->IsTObject()) {
1229 obj = (TObject*)add;
1230 // don't change the user data, to avoid deletion of the
1231 // list tree item by RecursiveRemove()
1232 // it is better to read the object each time anyway,
1233 // as it may have changed in the file
1234 if (obj->InheritsFrom("TDirectory") || obj->InheritsFrom("TList"))
1235 item->SetUserData(obj);
1236 }
1237 }
1238 }
1239 else if (obj->InheritsFrom("TLeaf") || obj->InheritsFrom("TBranch")) {
1240 Chdir(item);
1241 }
1242 else if (obj->InheritsFrom("TRemoteObject")) {
1243 // the real object is a TKey
1244 TRemoteObject *robj = (TRemoteObject *)obj;
1245 if (!strcmp(robj->GetClassName(), "TKey")) {
1246 TGListTreeItem *parent = item;
1247 TRemoteObject *probj = (TRemoteObject *)parent->GetUserData();
1248 // find the TFile remote object containing the TKey
1249 while ( probj && strcmp(probj->GetClassName(), "TFile")) {
1250 parent = parent->GetParent();
1251 probj = (TRemoteObject *)parent->GetUserData();
1252 }
1253 if (probj && !strcmp(probj->GetClassName(), "TFile")) {
1254 // remotely browse file (remotely call TFile::cd())
1257 TString::Format("((TApplicationServer *)gApplication)->BrowseFile(\"%s\");",
1258 probj->GetName()));
1259 gSystem->Sleep(250);
1260 }
1261 }
1262 if (gClient->GetMimeTypeList()->GetAction(obj->GetName(), action)) {
1263 act = action;
1264 act.ReplaceAll("%s", obj->GetName());
1265 if ((act[0] != '!') && (strcmp(pitem->GetText(), "ROOT Files"))) {
1266 // special case for remote object: remote process
1269 }
1270 }
1271 if ((ext.EndsWith(".root")) && (strcmp(pitem->GetText(), "ROOT Files"))) {
1273 gApplication->ProcessLine("((TApplicationServer *)gApplication)->BrowseFile(0);");
1274 }
1275 }
1276 if (!obj->InheritsFrom("TObjString") ||
1277 gSystem->AccessPathName(fullpath.Data())) {
1279 fDblClick = kTRUE;
1280 if (gClient->GetMimeTypeList()->GetAction(obj->IsA()->GetName(), action)) {
1281 act = action;
1282 if (fBrowser && act.Contains("->Browse()")) obj->Browse(fBrowser);
1283 else if (act.Contains("->Draw()")) obj->Draw(GetDrawOption());
1284 else {
1285 if (act.Contains("%s")) act.ReplaceAll("%s", obj->GetName());
1286 else act.Prepend(obj->GetName());
1287 gInterpreter->SaveGlobalsContext();
1288 if (act[0] == '!') {
1289 act.Remove(0, 1);
1290 gSystem->Exec(act.Data());
1291 } else {
1292 // special case for remote object: remote process
1293 if (obj->InheritsFrom("TRemoteObject"))
1296 }
1297 }
1298 }
1299 else if (obj->InheritsFrom("TCanvas") && fNewBrowser &&
1302 // avoid potential crash when drawing a canvas with the same name
1303 // than a canvas already embedded in one of the browser's tab
1304 obj->DrawClone();
1305 } else if (fBrowser && !obj->InheritsFrom("TFormula"))
1306 obj->Browse(fBrowser);
1307 fDblClick = kFALSE;
1308 fNKeys = 0;
1309 fCnt = 0;
1311 if (gPad) gPad->Update();
1312 return;
1313 }
1314 }
1315 flags = id = size = modtime = 0;
1316 if (gSystem->GetPathInfo(fullpath.Data(), &id, &size, &flags, &modtime) != 0)
1317 return;
1318 Int_t isdir = (Int_t)flags & 2;
1319
1320 TString savdir = gSystem->WorkingDirectory();
1321 if (isdir) {
1322 fCurrentDir = item;
1323 //fListTree->DeleteChildren(item);
1324 TSystemDirectory dir(item->GetText(),FullPathName(item));
1325 TList *files = dir.GetListOfFiles();
1326 if (files) {
1327 files->Sort();
1328 TIter next(files);
1329 TSystemFile *file;
1330 TString fname, pname;
1331 // directories first
1332 //fListTree->DeleteChildren(item);
1333 while ((file=(TSystemFile*)next())) {
1334 fname = file->GetName();
1335 if (file->IsDirectory()) {
1336 if (!fShowHidden && fname.BeginsWith("."))
1337 continue;
1338 if ((fname!="..") && (fname!=".")) { // skip it
1339 if (!fListTree->FindChildByName(item, fname)) {
1340 itm = fListTree->AddItem(item, fname);
1341 if (!gSystem->GetPathInfo(fname, sbuf) &&
1342 sbuf.fIsLink) {
1343 // change the pictures if it is a symlink
1344 // (shortcut on Windows)
1345 const TGPicture *opened = 0, *l_opened = 0;
1346 const TGPicture *closed = 0, *l_closed = 0;
1347 opened = fClient->GetPicture("ofolder_t.xpm");
1348 if (opened) l_opened = MakeLinkPic(opened);
1349 closed = fClient->GetPicture("folder_t.xpm");
1350 if (closed) l_closed = MakeLinkPic(closed);
1351 if (l_opened && l_closed)
1352 itm->SetPictures(l_opened, l_closed);
1353 if (opened) fClient->FreePicture(opened);
1354 if (closed) fClient->FreePicture(closed);
1355 if (l_opened) fClient->FreePicture(l_opened);
1356 if (l_closed) fClient->FreePicture(l_closed);
1357 }
1358 // uncomment line below to set directories as
1359 // DND targets
1360 //itm->SetDNDTarget(kTRUE);
1361 itm->SetUserData(0);
1362 }
1363 }
1364 }
1365 }
1366 // then files...
1367 TIter nextf(files);
1368 while ((file=(TSystemFile*)nextf())) {
1369 fname = pname = file->GetName();
1370 if (!file->IsDirectory() && (fFilter == 0 ||
1371 (fFilter && fname.Index(*fFilter) != kNPOS))) {
1372 if (!fShowHidden && fname.BeginsWith("."))
1373 continue;
1374 size = modtime = 0;
1375 if (gSystem->GetPathInfo(fname, sbuf) == 0) {
1376 size = sbuf.fSize;
1377 modtime = sbuf.fMtime;
1378 }
1379 if (sbuf.fIsLink && pname.EndsWith(".lnk"))
1380 pname.Remove(pname.Length()-4);
1381 pic = gClient->GetMimeTypeList()->GetIcon(pname, kTRUE);
1382 if (!pic)
1383 pic = fFileIcon;
1384 if (sbuf.fIsLink)
1385 pic = MakeLinkPic(pic);
1386 if (!fListTree->FindChildByName(item, fname)) {
1387 itm = fListTree->AddItem(item, fname, pic, pic);
1388 if (pic != fFileIcon)
1389 fClient->FreePicture(pic);
1390 if (sbuf.fIsLink) {
1391 TString fullname = file->GetName();
1392 gSystem->ExpandPathName(fullname);
1393 itm->SetUserData(new TObjString(TString::Format("file://%s\r\n",fullname.Data())), kTRUE);
1394 } else {
1395 itm->SetUserData(new TObjString(TString::Format("file://%s/%s\r\n",
1396 gSystem->UnixPathName(file->GetTitle()),
1397 file->GetName())), kTRUE);
1398 }
1399 itm->SetDNDSource(kTRUE);
1400 if (size && modtime) {
1401 char *tiptext = FormatFileInfo(fname.Data(), size, modtime);
1402 itm->SetTipText(tiptext);
1403 delete [] tiptext;
1404 }
1405 }
1406 }
1407 }
1408 files->Delete();
1409 delete files;
1410 }
1411 }
1412 else {
1413 TString lnkname = item->GetText();
1414 if (is_link && lnkname.EndsWith(".lnk"))
1415 lnkname.Remove(lnkname.Length()-4);
1416 fCurrentDir = item->GetParent();
1417 TSystemFile f(lnkname.Data(), fullpath.Data());
1418 TString fname = f.GetName();
1419 if (fname.EndsWith(".root")) {
1420 TDirectory *rfile = 0;
1421 gSystem->ChangeDirectory(dirname.Data());
1422 rfile = (TDirectory *)gROOT->GetListOfFiles()->FindObject(obj);
1423 if (!rfile) {
1424 rfile = (TDirectory *)gROOT->ProcessLine(TString::Format("new TFile(\"%s\")",fname.Data()));
1425 }
1426 if (rfile) {
1427 // replace actual user data (TObjString) by the TDirectory...
1428 if (item->GetUserData()) {
1429 // first delete the data to avoid memory leaks
1430 TObject *obj2 = static_cast<TObject *>(item->GetUserData());
1431 // only delete TObjString as they are the only objects
1432 // created who have to be deleted
1433 TObjString *ostr = dynamic_cast<TObjString *>(obj2);
1434 if (ostr) delete ostr;
1435 }
1436 item->SetUserData(rfile);
1437 fNKeys = rfile->GetListOfKeys()->GetEntries();
1438 fCnt = 0;
1439 if (fBrowser) rfile->Browse(fBrowser);
1440 fNKeys = 0;
1441 fCnt = 0;
1442 }
1443 }
1444 else if (fname.EndsWith(".png")) {
1445 gSystem->ChangeDirectory(dirname.Data());
1447 gSystem->ChangeDirectory(savdir.Data());
1448 }
1449 else if (IsTextFile(fullpath.Data())) {
1450 gSystem->ChangeDirectory(dirname.Data());
1451 if (fNewBrowser) {
1452 TGFrameElement *fe = 0;
1453 TGTab *tabRight = fNewBrowser->GetTabRight();
1454 TGCompositeFrame *frame = tabRight->GetCurrentContainer();
1455 if (frame)
1456 fe = (TGFrameElement *)frame->GetList()->First();
1457 if (fe) {
1459 TString fullname = f.GetTitle();
1460 fullname.ReplaceAll("\\", "\\\\");
1461 if (embed->InheritsFrom("TGTextEditor")) {
1462 gROOT->ProcessLine(TString::Format("((TGTextEditor *)0x%zx)->LoadFile(\"%s\");",
1463 (size_t)embed, fullname.Data()));
1464 }
1465 else if (embed->InheritsFrom("TGTextEdit")) {
1466 gROOT->ProcessLine(TString::Format("((TGTextEdit *)0x%zx)->LoadFile(\"%s\");",
1467 (size_t)embed, fullname.Data()));
1468 }
1469 else {
1471 }
1472 }
1473 else {
1475 }
1476 }
1477 gSystem->ChangeDirectory(savdir.Data());
1478 }
1479 else {
1480 gSystem->ChangeDirectory(dirname.Data());
1482 gSystem->ChangeDirectory(savdir.Data());
1483 }
1484 }
1485 //gSystem->ChangeDirectory(savdir.Data());
1487}
1488
1489////////////////////////////////////////////////////////////////////////////////
1490/// Execute default action for selected object (action is specified
1491/// in the $HOME/.root.mimes or $ROOTSYS/etc/root.mimes file.
1492
1494{
1495 char action[512];
1496 TString act;
1497 TString ext = obj->GetName();
1499
1500 if (gClient->GetMimeTypeList()->GetAction(obj->GetName(), action)) {
1501 act = action;
1502 act.ReplaceAll("%s", obj->GetName());
1503 gInterpreter->SaveGlobalsContext();
1504
1505 if (act[0] == '!') {
1506 act.Remove(0, 1);
1507 gSystem->Exec(act.Data());
1508 return 0;
1509 } else {
1510 // special case for remote object: remote process
1511 if (obj->InheritsFrom("TRemoteObject"))
1513
1514 const Long_t res = gApplication->ProcessLine(act.Data());
1515#ifdef R__HAS_COCOA
1516 if (act.Contains(".x") || act.Contains(".X")) {
1517 if (gPad) gPad->Update();
1518 }
1519#endif
1520 return res;
1521 }
1522 }
1523 return 0;
1524}
1525
1526////////////////////////////////////////////////////////////////////////////////
1527/// Format file information to be displayed in the tooltip.
1528
1529char *TGFileBrowser::FormatFileInfo(const char *fname, Long64_t size, Long_t modtime)
1530{
1531 Long64_t fsize, bsize;
1532 TString infos = fname;
1533 infos += "\n";
1534
1535 fsize = bsize = size;
1536 if (fsize > 1024) {
1537 fsize /= 1024;
1538 if (fsize > 1024) {
1539 // 3.7MB is more informative than just 3MB
1540 infos += TString::Format("Size: %lld.%lldM", fsize/1024, (fsize%1024)/103);
1541 } else {
1542 infos += TString::Format("Size: %lld.%lldK", bsize/1024, (bsize%1024)/103);
1543 }
1544 } else {
1545 infos += TString::Format("Size: %lld", bsize);
1546 }
1547 struct tm *newtime;
1548 time_t loctime = (time_t) modtime;
1549 newtime = localtime(&loctime);
1550 if (newtime) {
1551 infos += "\n";
1552 infos += TString::Format("%d-%02d-%02d %02d:%02d",
1553 newtime->tm_year + 1900,
1554 newtime->tm_mon+1, newtime->tm_mday,
1555 newtime->tm_hour, newtime->tm_min);
1556 }
1557 return StrDup(infos.Data());
1558}
1559
1560////////////////////////////////////////////////////////////////////////////////
1561/// Retrieve icons associated with class "name". Association is made
1562/// via the user's ~/.root.mimes file or via $ROOTSYS/etc/root.mimes.
1563
1565{
1566 const char *clname = nullptr;
1567 TClass *objClass = nullptr;
1568 static TImage *im = nullptr;
1569 if (!im) {
1570 im = TImage::Create();
1571 }
1572
1573 if (obj->IsA() == TClass::Class()) {
1574 objClass = obj->IsA();
1575 if (objClass)
1576 clname = objClass->GetName();
1577 }
1578 else if (obj->InheritsFrom("TKey")) {
1579 clname = ((TKey *)obj)->GetClassName();
1580 }
1581 else if (obj->InheritsFrom("TKeyMapFile")) {
1582 clname = ((TKeyMapFile *)obj)->GetTitle();
1583 }
1584 else if (obj->InheritsFrom("TRemoteObject")) {
1585 // special case for remote object: get real object class
1586 TRemoteObject *robj = (TRemoteObject *)obj;
1587 if (!strcmp(robj->GetClassName(), "TKey"))
1588 clname = robj->GetKeyClassName();
1589 else
1590 clname = robj->GetClassName();
1591 }
1592 else {
1593 objClass = obj->IsA();
1594 if (objClass)
1595 clname = objClass->GetName();
1596 }
1597 if (!clname) {
1598 clname = "Unknown";
1599 }
1600 const char *name = obj->GetIconName() ? obj->GetIconName() : clname;
1601 TString xpm_magic(name, 3);
1602 Bool_t xpm = xpm_magic == "/* ";
1603 const char *iconname = xpm ? obj->GetName() : name;
1604
1605 if (obj->IsA()->InheritsFrom("TGeoVolume")) {
1606 iconname = obj->GetIconName() ? obj->GetIconName() : obj->IsA()->GetName();
1607 }
1608
1609 if (fCachedPicName == iconname) {
1610 *pic = fCachedPic;
1611 return;
1612 }
1613 *pic = gClient->GetMimeTypeList()->GetIcon(iconname, kTRUE);
1614 if (!(*pic) && xpm) {
1615 if (im && im->SetImageBuffer((char**)&name, TImage::kXpm)) {
1616 im->Scale(im->GetWidth()/4, im->GetHeight()/4);
1617 *pic = gClient->GetPicturePool()->GetPicture(iconname, TGWindow::GetImagePixmap(im), TGWindow::GetImageMask(im));
1618 }
1619 gClient->GetMimeTypeList()->AddType("[thumbnail]", iconname, iconname, iconname, "->Browse()");
1620 return;
1621 }
1622 if (fCachedPic && (fCachedPic != fFileIcon))
1624 if (*pic == 0) {
1625 if (!obj->IsFolder())
1626 *pic = fFileIcon;
1627 }
1628 fCachedPic = *pic;
1629 fCachedPicName = iconname;
1630}
1631
1632////////////////////////////////////////////////////////////////////////////////
1633/// Go to the directory "path" and open all the parent list tree items.
1634
1635void TGFileBrowser::GotoDir(const char *path)
1636{
1637 TGListTreeItem *item, *itm;
1638 ULong_t id;
1639 Long_t bsize, blocks, bfree;
1640 Bool_t expand = kTRUE;
1641 TString sPath(gSystem->UnixPathName(path));
1642 item = fRootDir;
1643 if (item == 0) return;
1644 fListTree->OpenItem(item);
1645 TObjArray *tokens = sPath.Tokenize("/");
1646 if (tokens->IsEmpty()) {
1647 fListTree->HighlightItem(item);
1648 DoubleClicked(item, 1);
1649 delete tokens;
1652 return;
1653 }
1654 // if the Browser.ExpandDirectories option is set to "no", then don't
1655 // expand the parent directory tree (for example on nfs)
1656 TString str = gEnv->GetValue("Browser.ExpandDirectories", "yes");
1657 str.ToLower();
1658 expand = (str == "yes") ? kTRUE : kFALSE;
1659 TString first = ((TObjString*)tokens->At(0))->GetName();
1660 // always prevent expanding the parent directory tree on afs
1661 if (first == "afs")
1662 expand = kFALSE;
1663 // check also AFS_SUPER_MAGIC, NFS_SUPER_MAGIC, FUSE_SUPER_MAGIC,
1664 // CIFS_MAGIC_NUMBER and SMB_SUPER_MAGIC
1665 if (!gSystem->GetFsInfo(path, (Long_t *)&id, &bsize, &blocks, &bfree))
1666 if (id == 0x5346414f || id == 0x6969 || id == 0x65735546 || id == 0xff534d42 || id == 0x517b)
1667 expand = kFALSE;
1668 if (first.Length() == 2 && first.EndsWith(":")) {
1669 TList *curvol = gSystem->GetVolumes("cur");
1670 if (curvol) {
1671 TNamed *drive = (TNamed *)curvol->At(0);
1672 if (first == drive->GetName()) {
1673 TString infos = drive->GetTitle();
1674 if (infos.Contains("Network"))
1675 expand = kFALSE;
1676 }
1677 delete curvol;
1678 }
1679 }
1680 for (Int_t i = 0; i < tokens->GetEntriesFast(); ++i) {
1681 TString token = ((TObjString*)tokens->At(i))->GetName();
1682 if (token.Length() == 2 && token.EndsWith(":")) {
1683 token.Append("\\");
1684 itm = fListTree->FindChildByName(0, token);
1685 if (itm) {
1686 item = itm;
1687 fListTree->OpenItem(item);
1688 if (expand)
1689 DoubleClicked(item, 1);
1690 }
1691 continue;
1692 }
1693 itm = fListTree->FindChildByName(item, token);
1694 if (itm) {
1695 item = itm;
1696 fListTree->OpenItem(item);
1697 if (expand)
1698 DoubleClicked(item, 1);
1699 }
1700 else {
1701 itm = fListTree->AddItem(item, token);
1702 item = itm;
1703 fListTree->OpenItem(item);
1704 if (expand)
1705 DoubleClicked(item, 1);
1706 }
1707 }
1708 fListTree->HighlightItem(item);
1709 DoubleClicked(item, 1);
1710 delete tokens;
1713}
1714
1715////////////////////////////////////////////////////////////////////////////////
1716/// Slot used to switch to the tab containing the current pad/canvas (gPad)
1717/// used e.g. when drawing a histogram by double-clicking on its list tree
1718/// item in a root file.
1719
1721{
1722 if (fDblClick && fNewBrowser) {
1723 Int_t i;
1724 TGTab *tabRight = fNewBrowser->GetTabRight();
1725 for (i=0;i<tabRight->GetNumberOfTabs();++i) {
1726 TGFrameElement *fe = 0;
1727 TGCompositeFrame *embed = 0;
1728 TGCompositeFrame *frame = tabRight->GetTabContainer(i);
1729 if (frame)
1730 fe = (TGFrameElement *)frame->GetList()->First();
1731 if (fe)
1732 embed = (TGCompositeFrame *)fe->fFrame;
1733 if (embed && embed->InheritsFrom("TRootCanvas")) {
1734 ULongptr_t canvas = gROOT->ProcessLine(TString::Format("((TRootCanvas *)0x%zx)->Canvas();",
1735 (size_t)embed));
1736 if ((canvas) && (canvas == (ULongptr_t)gPad ||
1737 canvas == (ULongptr_t)gPad->GetCanvas())) {
1738 tabRight->SetTab(i, kTRUE);
1739 break;
1740 }
1741 }
1742 }
1743 }
1744}
1745
1746////////////////////////////////////////////////////////////////////////////////
1747/// Open a dialog box asking for a string to be used as filter (regexp), and
1748/// add an entry in the map of filtered entries. Entering "*" or empty string
1749/// ("") will disable filtering on the current list tree item.
1750
1752{
1753 char filter[1024];
1754 if (!fListLevel)
1755 return;
1756 // initialize with previous (active) filter string
1757 snprintf(filter, sizeof(filter), "%s", fFilterStr.Data());
1758 new TGInputDialog(gClient->GetRoot(), this,
1759 "Enter filter expression:\n(empty string \"\" or \"*\" to remove filter)",
1760 filter, filter);
1761 // if user pressed cancel, update the status of the current list tree
1762 // item and return
1763 if ((filter[0] == 0) && (filter[1] == 0)) {
1765 return;
1766 }
1767 else if (((filter[0] == 0) && (filter[1] == 1)) || !strcmp(filter, "*")) {
1768 // if user entered "*" or "", just disable filtering for the current
1769 // list tree item
1772 } else {
1773 // if user entered a string different from "*", use it to create an
1774 // entry in the filter map
1775 fFilterStr = filter;
1777 // if there is already a filter on this item, delete it
1780 // insert a new entry for the current list tree item
1781 fFilteredItems.emplace(fListLevel, filter);
1782 }
1783 // finally update the list tree
1788}
1789
1790////////////////////////////////////////////////////////////////////////////////
1791/// A ROOT File has been selected in TGFileBrowser.
1792
1794{
1795 TGListTreeItem *itm = fListTree->FindChildByData(0, gROOT->GetListOfFiles());
1796 if (itm) {
1798 fListLevel = itm;
1801 BrowseObj(gROOT->GetListOfFiles());
1804 }
1805}
1806
1807////////////////////////////////////////////////////////////////////////////////
1808/// Toggle the sort mode and set the "sort button" state accordingly.
1809
1811{
1812 if (!fListLevel) return;
1813 TString itemname;
1814 TGListTreeItem *item = fListLevel;
1815 if (!fListLevel->GetFirstChild()) {
1816 item = fListLevel->GetParent();
1817 itemname = fListLevel->GetText();
1818 }
1819 if (!item)
1820 return;
1821 Bool_t is_sorted = CheckSorted(item);
1822 if (!is_sorted) {
1823 //alphabetical sorting
1824 fListTree->SortChildren(item);
1825 fSortedItems.push_back(item);
1827 } else {
1829 DoubleClicked(item, 1);
1830 fSortedItems.remove(item);
1832 gClient->NeedRedraw(fListTree, kTRUE);
1833 gClient->HandleInput();
1834 if (itemname.Length() > 0) {
1835 TGListTreeItem *itm = fListTree->FindChildByName(item, itemname);
1836 if (itm) {
1838 Clicked(itm, 1, 0, 0);
1839 itm->SetActive(kTRUE);
1840 fListTree->SetSelected(itm);
1842 }
1843 }
1844 }
1847}
1848
1849
@ kButton1Down
Definition Buttons.h:17
@ kWatch
Definition GuiTypes.h:376
@ kPointer
Definition GuiTypes.h:376
@ kHorizontalFrame
Definition GuiTypes.h:383
@ kButton3
Definition GuiTypes.h:215
#define b(i)
Definition RSha256.hxx:100
#define f(i)
Definition RSha256.hxx:104
#define h(i)
Definition RSha256.hxx:106
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
bool Bool_t
Boolean (0=false, 1=true) (bool)
Definition RtypesCore.h:78
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:60
unsigned long ULong_t
Unsigned long integer 4 bytes (unsigned long). Size depends on architecture.
Definition RtypesCore.h:70
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
Definition RtypesCore.h:69
unsigned long ULongptr_t
Unsigned integer large enough to hold a pointer (platform-dependent)
Definition RtypesCore.h:91
constexpr Bool_t kFALSE
Definition RtypesCore.h:109
constexpr Ssiz_t kNPOS
The equivalent of std::string::npos for the ROOT class TString.
Definition RtypesCore.h:132
long long Long64_t
Portable signed long integer 8 bytes.
Definition RtypesCore.h:84
constexpr Bool_t kTRUE
Definition RtypesCore.h:108
const char Option_t
Option string (const char)
Definition RtypesCore.h:81
R__EXTERN TApplication * gApplication
#define gDirectory
Definition TDirectory.h:385
R__EXTERN TEnv * gEnv
Definition TEnv.h:126
@ kButtonUp
Definition TGButton.h:53
@ kButtonEngaged
Definition TGButton.h:55
#define gClient
Definition TGClient.h:157
const char * filters[]
static Bool_t IsObjectEditable(TClass *cl)
Helper function checking if a class has a graphic properties editor.
static const TGPicture * MakeLinkPic(const TGPicture *pic)
Create a symlink (shortcut on Windows) icon by merging the picture passed as argument and the slink_t...
static const char * FormatToolTip(TObject *obj, Int_t maxlen=0)
Format the tooltip information, based on the object passed in argument.
const char rootdir[]
static Bool_t IsTextFile(const char *candidate)
Returns true if given a text file Uses the specification given on p86 of the Camel book.
@ kDeepCleanup
Definition TGFrame.h:42
@ kLHintsRight
Definition TGLayout.h:26
@ kLHintsExpandY
Definition TGLayout.h:31
@ kLHintsLeft
Definition TGLayout.h:24
@ kLHintsCenterY
Definition TGLayout.h:28
@ kLHintsTop
Definition TGLayout.h:27
@ kLHintsExpandX
Definition TGLayout.h:30
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t del
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
Option_t Option_t TPoint TPoint const char text
char name[80]
Definition TGX11.cxx:142
#define gInterpreter
#define gROOT
Definition TROOT.h:417
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2571
char * StrDup(const char *str)
Duplicate the string str.
Definition TString.cxx:2639
Bool_t R_ISREG(Int_t mode)
Definition TSystem.h:126
Bool_t R_ISDIR(Int_t mode)
Definition TSystem.h:123
R__EXTERN TSystem * gSystem
Definition TSystem.h:582
@ kS_IXUSR
Definition TSystem.h:112
@ kS_IFREG
Definition TSystem.h:101
#define gPad
#define gVirtualX
Definition TVirtualX.h:379
virtual Longptr_t ProcessLine(const char *line, Bool_t sync=kFALSE, Int_t *error=nullptr)
Process a single command line, either a C++ statement or an interpreter command starting with a "....
TApplication * GetAppRemote() const
virtual const char * ApplicationName() const
Each class (see TClass) has a linked list of its base class(es).
Definition TBaseClass.h:33
TClass * GetClassPointer(Bool_t load=kTRUE)
Get pointer to the base class TClass.
ABC describing GUI independent browser implementation protocol.
Definition TBrowserImp.h:29
TBrowser * fBrowser
TBrowser associated with this implementation.
Definition TBrowserImp.h:32
Using a TBrowser one can browse all ROOT objects.
Definition TBrowser.h:37
void SetDrawOption(Option_t *option="") override
Set drawing option for object.
Definition TBrowser.h:106
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:84
static TClass * Class()
TList * GetListOfBases()
Return list containing the TBaseClass(es) of a class.
Definition TClass.cxx:3699
Bool_t IsTObject() const
Return kTRUE is the class inherits from TObject.
Definition TClass.cxx:6106
Bool_t InheritsFrom(const char *cl) const override
Return kTRUE if this class inherits from a class with name "classname".
Definition TClass.cxx:4995
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
Definition TClass.cxx:2999
virtual Int_t GetEntries() const
This class provides an interface to context sensitive popup menus.
virtual void Popup(Int_t x, Int_t y, TObject *obj, TVirtualPad *c=nullptr, TVirtualPad *p=nullptr)
Popup context menu at given location in canvas c and pad p for selected object.
Helper class used to change the cursor in a method and restore the original one when going out of the...
TCursorSwitcher(TGWindow *w1, TGWindow *w2)
Describe directory structure in memory.
Definition TDirectory.h:45
TObject * FindObject(const char *name) const override
Find object by name in the list of memory objects.
virtual TList * GetListOfKeys() const
Definition TDirectory.h:224
void Browse(TBrowser *b) override
Browse the content of the directory.
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition TEnv.cxx:511
virtual void SetToolTipText(const char *text, Long_t delayms=400)
Set tool tip text associated with this button.
Definition TGButton.cxx:439
virtual void SetStyle(UInt_t newstyle)
Set the button style (modern or classic).
Definition TGButton.cxx:265
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
Set button state.
Definition TGButton.cxx:229
A frame containing two scrollbars (a horizontal and a vertical) and a viewport.
Definition TGCanvas.h:192
const TGPicture * GetPicture(const char *name)
Get picture from the picture pool.
Definition TGClient.cxx:289
void FreePicture(const TGPicture *pic)
Free picture resource.
Definition TGClient.cxx:317
A combobox (also known as a drop down listbox) allows the selection of one item out of a list of item...
Definition TGComboBox.h:47
virtual TGLBEntry * GetSelectedEntry() const
Definition TGComboBox.h:115
virtual TGTextEntry * GetTextEntry() const
Definition TGComboBox.h:111
virtual void AddEntry(TGString *s, Int_t id)
Definition TGComboBox.h:86
virtual TGListBox * GetListBox() const
Definition TGComboBox.h:110
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:289
TGDimension GetDefaultSize() const override
std::cout << fWidth << "x" << fHeight << std::endl;
Definition TGFrame.h:318
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1110
virtual TList * GetList() const
Definition TGFrame.h:312
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition TGFrame.cxx:960
void MapSubwindows() override
Map all sub windows that are part of the composite frame.
Definition TGFrame.cxx:1157
void SetCleanup(Int_t mode=kLocalCleanup) override
Turn on automatic cleanup of child frames in dtor.
Definition TGFrame.cxx:1065
virtual void ClearViewPort()
Clear view port and redraw full content.
Definition TGCanvas.cxx:888
TGListTreeItem * fRootDir
Root (list tree) directory.
Int_t fGroupSize
total number of items when icon box switched to "global view" mode
Bool_t CheckFiltered(TGListTreeItem *item, Bool_t but=kFALSE)
Check if there is a filter active on the children of the list tree item.
TString DirName(TGListTreeItem *item)
returns the directory path
TSystemFile * fFile
Actual (selected) system file.
TGHorizontalFrame * fBotFrame
Bottom horizontal frame.
void GetObjPicture(const TGPicture **pic, TObject *obj)
Retrieve icons associated with class "name".
TGListTree * fListTree
Main list tree.
void AddKey(TGListTreeItem *itm, TObject *obj, const char *name=nullptr)
display content of ROOT file
TGFileBrowser(const TGWindow *p, TBrowser *b=nullptr, UInt_t w=200, UInt_t h=400)
TGFileBrowser constructor.
void CreateBrowser()
Create the actual file browser.
Bool_t fShowHidden
kTRUE to display hidden files
Bool_t fDblClick
kTRUE if user double-clicked on a list tree item
TGListTreeItem * fCurrentDir
Current (list tree) directory.
Bool_t CheckSorted(TGListTreeItem *item, Bool_t but=kFALSE)
Check if the list tree item children are alphabetically sorted.
void Clicked(TGListTreeItem *item, Int_t btn, Int_t x, Int_t y)
Process mouse clicks in TGListTree.
void DoubleClicked(TGListTreeItem *item, Int_t btn)
Process double clicks in TGListTree.
void BrowseObj(TObject *obj) override
Browse object.
void ApplyFilter(Int_t id)
Apply filter selected in combo box to the file tree view.
TGPictureButton * fFilterButton
"Filter" button
void PadModified()
Slot used to switch to the tab containing the current pad/canvas (gPad) used e.g.
void GotoDir(const char *path)
Go to the directory "path" and open all the parent list tree items.
void RecursiveRemove(TObject *obj) override
Recursively remove object.
void ToggleSort()
Toggle the sort mode and set the "sort button" state accordingly.
TGListTreeItem * fListLevel
Current list tree level.
void AddRemoteFile(TObject *obj)
Add remote file in list tree.
TString fFilterStr
Filter expression string.
TRegexp * fFilter
Regular expression used to filter files.
void GetFilePictures(const TGPicture **pic, Int_t file_type, Bool_t is_link, const char *name)
Determine the file picture for the given file type.
TSystemDirectory * fDir
Actual (selected) system directory.
Long_t fCnt
Counters for keys inside a Root file.
void Add(TObject *obj, const char *name=nullptr, Int_t check=-1) override
Add items to the browser.
sLTI_t fSortedItems
List of sorted list-tree items.
~TGFileBrowser() override
Destructor.
const TGPicture * fCachedPic
Cached picture.
void RequestFilter()
Open a dialog box asking for a string to be used as filter (regexp), and add an entry in the map of f...
TGComboBox * fFileType
File type combobox.
TGCanvas * fCanvas
Canvas for the list tree.
TContextMenu * fContextMenu
pointer to context menu
TRootBrowser * fNewBrowser
Pointer back to the Browser.
char * FormatFileInfo(const char *fname, Long64_t size, Long_t modtime)
Format file information to be displayed in the tooltip.
TString FullPathName(TGListTreeItem *item)
returns an absolute path
TGPictureButton * fSortButton
"Sort" button
TGComboBox * fDrawOption
Draw options combobox.
void Checked(TObject *obj, Bool_t check)
Emits signal when double clicking on icon.
const TGPicture * fFileIcon
System files icon.
Option_t * GetDrawOption() const override
returns drawing option
TGPictureButton * fRefreshButton
"Refresh" button
void CheckRemote(TGListTreeItem *item)
Check if the current list tree item points to a remote object.
void Update()
Update content of the list tree.
const TGPicture * fRootIcon
Root files icon.
void Selected(char *)
A ROOT File has been selected in TGFileBrowser.
void Show() override
void AddFSDirectory(const char *entry, const char *path=nullptr, Option_t *opt="")
Add file system directory in the list tree.
void Refresh(Bool_t force=kFALSE) override
Refresh content of the list tree.
TString fCachedPicName
Cached picture name.
mFiltered_t fFilteredItems
List of filtered list-tree items.
Long_t XXExecuteDefaultAction(TObject *obj)
Execute default action for selected object (action is specified in the $HOME/.root....
void Chdir(TGListTreeItem *item)
Make object associated with item the current directory.
sLTI_t::iterator sLTI_i
TGHorizontalFrame * fTopFrame
Top horizontal frame.
TGFrame * fFrame
Definition TGLayout.h:112
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:598
void MapWindow() override
map window
Definition TGFrame.h:206
UInt_t GetWidth() const
Definition TGFrame.h:226
A composite frame that layout their children in horizontal way.
Definition TGFrame.h:387
Input Dialog Widget.
This class handles GUI labels.
Definition TGLabel.h:24
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
A listbox is a box, possibly with scrollbar, containing entries.
Definition TGListBox.h:221
void Resize(UInt_t w, UInt_t h) override
Resize the listbox widget.
TGListTreeItem * GetFirstChild() const
Definition TGListTree.h:61
void Rename(const char *new_name)
Definition TGListTree.h:73
virtual const char * GetText() const =0
TGListTreeItem * GetNextSibling() const
Definition TGListTree.h:64
TGListTreeItem * GetParent() const
Definition TGListTree.h:60
virtual void SetTipText(const char *)
Definition TGListTree.h:79
virtual void SetActive(Bool_t)
Definition TGListTree.h:71
void SetDNDSource(Bool_t onoff)
Definition TGListTree.h:110
virtual void SetPictures(const TGPicture *, const TGPicture *)
Definition TGListTree.h:85
virtual void * GetUserData() const =0
virtual void SetUserData(void *, Bool_t=kFALSE)
Definition TGListTree.h:81
A list tree is a widget that can contain a number of items arranged in a tree structure.
Definition TGListTree.h:197
TGListTreeItem * FindItemByObj(TGListTreeItem *item, void *ptr)
Find item with fUserData == ptr.
void ClearHighlighted()
Un highlight items.
void AddItem(TGListTreeItem *parent, TGListTreeItem *item)
Add given item to list tree.
Int_t DeleteChildren(TGListTreeItem *item)
Delete children of item from list.
void CheckItem(TGListTreeItem *item, Bool_t check=kTRUE)
Set check button state for the node 'item'.
void OpenItem(TGListTreeItem *item)
Open item in list tree (i.e. show child items).
TGListTreeItem * GetSelected() const
Definition TGListTree.h:392
Int_t RecursiveDeleteItem(TGListTreeItem *item, void *userData)
Delete item with fUserData == ptr.
Int_t DeleteItem(TGListTreeItem *item)
Delete item from list tree.
void SetSelected(TGListTreeItem *item)
Definition TGListTree.h:363
TGListTreeItem * GetFirstItem() const
Definition TGListTree.h:391
TGListTreeItem * FindChildByName(TGListTreeItem *item, const char *name)
Find child of item by name.
Int_t SortChildren(TGListTreeItem *item)
Sort children of item.
void AdjustPosition(TGListTreeItem *item)
Move content to position of item.
void HighlightItem(TGListTreeItem *item)
Highlight item.
TGListTreeItem * FindChildByData(TGListTreeItem *item, void *userData)
Find child of item by userData.
void SetToolTipItem(TGListTreeItem *item, const char *string)
Set tooltip text for this item.
void GetPathnameFromItem(TGListTreeItem *item, char *path, Int_t depth=0)
Get pathname from item.
Defines top level windows that interact with the system Window Manager.
Definition TGFrame.h:399
TGClient * fClient
Connection to display server.
Definition TGObject.h:25
Handle_t GetId() const
Definition TGObject.h:41
Yield an action as soon as it is clicked.
Definition TGButton.h:228
The TGPicture class implements pictures and icons used in the different GUI elements and widgets.
Definition TGPicture.h:25
Pixmap_t GetPicture() const
Definition TGPicture.h:54
A tab widget contains a set of composite frames each with a little tab with a name (like a set of fol...
Definition TGTab.h:46
TGCompositeFrame * GetCurrentContainer() const
Definition TGTab.h:95
TGTabElement * GetTabTab(Int_t tabIndex) const
Return the tab element of tab with index tabIndex.
Definition TGTab.cxx:660
Int_t GetNumberOfTabs() const
Return number of tabs.
Definition TGTab.cxx:706
virtual Bool_t SetTab(Int_t tabIndex, Bool_t emit=kTRUE)
Brings the composite frame with the index tabIndex to the front and generate the following event if t...
Definition TGTab.cxx:555
TGCompositeFrame * GetTabContainer(Int_t tabIndex) const
Return container of tab with index tabIndex.
Definition TGTab.cxx:611
A TGTextEntry is a one line text input widget.
Definition TGTextEntry.h:24
const char * GetText() const
virtual void SetToolTipText(const char *text, Long_t delayms=500)
Set tool tip text associated with this text entry.
Text string listbox entries.
Definition TGListBox.h:48
const char * GetTitle() const override
Returns title of object.
Definition TGListBox.h:81
ROOT GUI Window base class.
Definition TGWindow.h:24
static Pixmap_t GetImagePixmap(TImage *img)
Returns image pixmap.
Definition TGWindow.cxx:409
static Pixmap_t GetImageMask(TImage *img)
Returns image mask pixmap (alpha channel).
Definition TGWindow.cxx:434
const char * GetName() const override
Return unique name, used in SavePrimitive methods.
Definition TGWindow.cxx:336
virtual void SetModel(TVirtualPad *pad, TObject *obj, Int_t event, Bool_t force=kFALSE)
Activate object editors according to the selected object.
An abstract interface to image processing library.
Definition TImage.h:30
static TImage * Open(const char *file, EImageFileTypes type=kUnknown)
Open a specified image file.
Definition TImage.cxx:123
@ kXpm
Definition TImage.h:38
virtual UInt_t GetWidth() const
Definition TImage.h:246
static TImage * Create()
Create an image.
Definition TImage.cxx:34
virtual Bool_t SetImageBuffer(char **, EImageFileTypes=TImage::kPng)
Definition TImage.h:264
virtual UInt_t GetHeight() const
Definition TImage.h:247
Utility class for browsing TMapFile objects.
Definition TKeyMapFile.h:20
Book space in a file, create I/O buffers, to fill them, (un)compress them.
Definition TKey.h:28
A doubly linked list.
Definition TList.h:38
TObject * First() const override
Return the first object in the list. Returns 0 when list is empty.
Definition TList.cxx:789
void Delete(Option_t *option="") override
Remove all objects from the list AND delete all heap based objects.
Definition TList.cxx:600
TObject * At(Int_t idx) const override
Returns the object at position idx. Returns 0 if idx is out of range.
Definition TList.cxx:487
virtual void Sort(Bool_t order=kSortAscending)
Sort linked list.
Definition TList.cxx:1067
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
const char * GetTitle() const override
Returns title of object.
Definition TNamed.h:50
An array of TObjects.
Definition TObjArray.h:31
Int_t GetEntriesFast() const
Definition TObjArray.h:58
TObject * At(Int_t idx) const override
Definition TObjArray.h:170
Bool_t IsEmpty() const override
Definition TObjArray.h:65
Collectable string class.
Definition TObjString.h:28
Mother of all ROOT objects.
Definition TObject.h:42
virtual Bool_t IsFolder() const
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects).
Definition TObject.cxx:578
virtual const char * GetName() const
Returns name of object.
Definition TObject.cxx:461
virtual void Browse(TBrowser *b)
Browse object. May be overridden for another default action.
Definition TObject.cxx:217
virtual const char * GetIconName() const
Returns mime type name of object.
Definition TObject.cxx:471
virtual TObject * DrawClone(Option_t *option="") const
Draw a clone of this object in the current selected pad with: gROOT->SetSelectedPad(c1).
Definition TObject.cxx:318
virtual char * GetObjectInfo(Int_t px, Int_t py) const
Returns string containing info about the object at position (px,py).
Definition TObject.cxx:490
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:886
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition TObject.cxx:548
virtual const char * GetTitle() const
Returns title of object.
Definition TObject.cxx:506
virtual TClass * IsA() const
Definition TObject.h:248
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition TObject.cxx:292
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot.
Definition TQObject.cxx:865
Bool_t Disconnect(const char *signal=nullptr, void *receiver=nullptr, const char *slot=nullptr)
Disconnects signal of this object from slot of receiver.
void AddReference()
Definition TRefCnt.h:40
Regular expression class.
Definition TRegexp.h:31
The TRemoteObject class provides protocol for browsing ROOT objects from a remote ROOT session.
const char * GetClassName() const
Bool_t GetFileStat(FileStat_t *sbuf)
Get remote file status.
const char * GetKeyClassName() const
This class creates a ROOT object browser, constituted by three main tabs.
void SetActBrowser(TBrowserImp *b)
virtual void Checked(TObject *obj, Bool_t check)
Emits signal when double clicking on icon.
TGTab * GetTabRight() const
Basic string class.
Definition TString.h:137
Ssiz_t Length() const
Definition TString.h:426
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Definition TString.cxx:2325
void Clear()
Clear string without changing its capacity.
Definition TString.cxx:1242
const char * Data() const
Definition TString.h:385
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition TString.h:714
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
Definition TString.cxx:2345
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Definition TString.h:633
TString & Prepend(const char *cs)
Definition TString.h:683
Bool_t IsNull() const
Definition TString.h:423
TString & Remove(Ssiz_t pos)
Definition TString.h:695
TString & Append(const char *cs)
Definition TString.h:582
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2460
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:642
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition TString.h:661
Long64_t Atoll() const
Return long long value of string.
Definition TString.cxx:2095
Describes an Operating System directory for the browser.
virtual TList * GetListOfFiles() const
Returns a TList of TSystemFile objects representing the contents of the directory.
A TSystemFile describes an operating system file.
Definition TSystemFile.h:29
virtual Bool_t IsDirectory(const char *dir=nullptr) const
Check if object is a directory.
virtual int GetFsInfo(const char *path, Long_t *id, Long_t *bsize, Long_t *blocks, Long_t *bfree)
Get info about a file system: fs type, block size, number of blocks, number of free blocks.
Definition TSystem.cxx:1494
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
Definition TSystem.cxx:1296
virtual Int_t Exec(const char *shellcmd)
Execute a command.
Definition TSystem.cxx:656
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.
Definition TSystem.cxx:1420
virtual TList * GetVolumes(Option_t *) const
Definition TSystem.h:475
virtual const char * PrependPathName(const char *dir, TString &name)
Concatenate a directory and a file name.
Definition TSystem.cxx:1097
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
Definition TSystem.cxx:1318
virtual Bool_t ChangeDirectory(const char *path)
Change directory.
Definition TSystem.cxx:877
virtual const char * UnixPathName(const char *unixpathname)
Convert from a local pathname to a Unix pathname.
Definition TSystem.cxx:1078
virtual void Sleep(UInt_t milliSec)
Sleep milliSec milli seconds.
Definition TSystem.cxx:440
virtual const char * WorkingDirectory()
Return working directory.
Definition TSystem.cxx:886
virtual TString GetDirName(const char *pathname)
Return the directory name in pathname.
Definition TSystem.cxx:1047
static void SingleShot(Int_t milliSec, const char *receiver_class, void *receiver, const char *method)
This static function calls a slot after a given time interval.
Definition TTimer.cxx:261
Abstract base class used by ROOT graphics editor.
static TVirtualPadEditor * GetPadEditor(Bool_t load=kTRUE)
Returns the pad editor dialog. Static method.
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
R__ALWAYS_INLINE bool HasBeenDeleted(const TObject *obj)
Check if the TObject's memory has been deleted.
Definition TObject.h:409
Int_t fMode
Definition TSystem.h:135
Long64_t fSize
Definition TSystem.h:138
Long_t fMtime
Definition TSystem.h:139
Bool_t fIsLink
Definition TSystem.h:140