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