Logo ROOT  
Reference Guide
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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#include "snprintf.h"
40#include <ctime>
41#include <cstring>
42#include <cstdlib>
43
44#include "TGFileBrowser.h"
45#include "TRootBrowser.h"
46#include "TGInputDialog.h"
47
48#include "TVirtualPadEditor.h"
49#include "TGedEditor.h"
50#include "TBaseClass.h"
51#include "TVirtualX.h"
52
53#include "RConfigure.h"
54
55#ifdef WIN32
56const char rootdir[] = "\";
57#else
58const char rootdir[] = "/";
59#endif
60
61const char *filters[] = {
62 "",
63 "*.*",
64 "*.[C|c|h]*",
65 "*.root",
66 "*.txt"
67};
68
69
70/** \class TCursorSwitcher
71 \ingroup guiwidgets
72
73Helper class used to change the cursor in a method and restore the
74original one when going out of the method scope.
75
76*/
77
78
79///////////////////////////////////////////////////////////////////////////////
81private:
84public:
86 if (w1) gVirtualX->SetCursor(w1->GetId(), gVirtualX->CreateCursor(kWatch));
87 if (w2) gVirtualX->SetCursor(w2->GetId(), gVirtualX->CreateCursor(kWatch));
88 }
90 if (fW1) gVirtualX->SetCursor(fW1->GetId(), gVirtualX->CreateCursor(kPointer));
91 if (fW2) gVirtualX->SetCursor(fW2->GetId(), gVirtualX->CreateCursor(kPointer));
92 }
93};
94
95
96/** \class TGFileBrowser
97 \ingroup guiwidgets
98
99System file browser, used as TRootBrowser plug-in.
100This class is the real core of the ROOT browser.
101
102*/
103
104
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);
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 if (TClass::GetClass("TGHtmlBrowser"))
240 TQObject::Connect("TGHtmlBrowser", "Clicked(char*)",
241 "TGFileBrowser", this, "Selected(char*)");
242
243 TQObject::Connect("TPad", "Modified()",
244 "TGFileBrowser", this, "PadModified()");
245
246 fListLevel = 0;
249 MapWindow();
250}
251
252////////////////////////////////////////////////////////////////////////////////
253/// Destructor.
254
256{
257 if (TClass::GetClass("TGHtmlBrowser"))
258 TQObject::Disconnect("TGHtmlBrowser", "Clicked(char*)");
259 TQObject::Disconnect("TPad", "Modified()");
260
261 delete fContextMenu;
262 delete fListTree;
263 delete fFilter;
264 delete fDir;
265 delete fFile;
267 if (fCachedPic && (fCachedPic != fFileIcon))
270 Cleanup();
271}
272
273////////////////////////////////////////////////////////////////////////////////
274/// Helper function checking if a class has a graphic properties editor.
275
277{
278 TBaseClass *base;
279 TList* bcl = cl->GetListOfBases();
280 TIter next(bcl);
281 while ((base = (TBaseClass*) next())) {
282 cl = base->GetClassPointer();
283 if (cl && TClass::GetClass(Form("%sEditor", cl->GetName())))
284 return kTRUE;
285 if (cl && IsObjectEditable(cl))
286 return kTRUE;
287 }
288 return kFALSE;
289}
290
291////////////////////////////////////////////////////////////////////////////////
292/// Format the tooltip information, based on the object passed in argument.
293
294static const char *FormatToolTip(TObject *obj, Int_t maxlen=0)
295{
296 static TString infos;
297 if (!obj) {
298 infos.Clear();
299 return 0;
300 }
301 infos = obj->GetName();
302 if (obj->GetTitle()) {
303 infos += "\n";
304 infos += obj->GetTitle();
305 }
306 if (maxlen > 0 && infos.Length() > maxlen) {
307 infos.Remove(maxlen - 3);
308 infos += "...";
309 }
310 TString objinfo = obj->GetObjectInfo(1, 1);
311 if (!objinfo.IsNull() && !objinfo.BeginsWith("x=")) {
312 Long64_t bsize, fsize, objsize;
313 objsize = objinfo.Atoll();
314 if (objsize > 0) {
315 infos += "\n";
316 bsize = fsize = objsize;
317 if (fsize > 1024) {
318 fsize /= 1024;
319 if (fsize > 1024) {
320 // 3.7MB is more informative than just 3MB
321 infos += TString::Format("Size: %lld.%lldM", fsize/1024,
322 (fsize%1024)/103);
323 } else {
324 infos += TString::Format("Size: %lld.%lldK", bsize/1024,
325 (bsize%1024)/103);
326 }
327 } else {
328 infos += TString::Format("Size: %lld bytes", bsize);
329 }
330 }
331 }
332 return infos.Data();
333}
334
335/**************************************************************************/
336// TBrowserImp virtuals
337/**************************************************************************/
338
339////////////////////////////////////////////////////////////////////////////////
340/// Add items to the browser. This function has to be called
341/// by the Browse() member function of objects when they are
342/// called by a browser. If check < 0 (default) no check box is drawn,
343/// if 0 then unchecked checkbox is added, if 1 checked checkbox is added.
344
345void TGFileBrowser::Add(TObject *obj, const char *name, Int_t check)
346{
347 if (fListLevel && !strcmp(fListLevel->GetText(), "Classes") &&
349 !strcmp(fListLevel->GetParent()->GetText(), "root")) {
350 // Browsing list of root classes...
351 }
352 else {
353 if (obj && obj->InheritsFrom("TApplication"))
354 fListLevel = 0;
355 if (obj && obj->InheritsFrom("TSystemDirectory"))
356 return;
357 }
358 if (fListLevel) {
359 TString oname = "";
360 if (name)
361 oname = name;
362 else if (obj)
363 oname = obj->GetName();
364 // check if the current item is filtered
365 auto it = fFilteredItems.find(fListLevel);
366 if (it != fFilteredItems.end()) {
367 // check if the item (object) name match the filter
368 const char *filter = it->second.c_str();
369 TRegexp re(filter, kTRUE);
370 // if not, simply return, so no item will be added
371 if (oname.Index(re) == kNPOS) return;
372 }
373 }
374 const TGPicture *pic = nullptr;
375 if (obj && obj->InheritsFrom("TKey") && (obj->IsA() != TClass::Class()))
376 AddKey(fListLevel, obj, name);
377 else if (obj) {
378 GetObjPicture(&pic, obj);
379 if (!name) name = obj->GetName();
380 if (check > -1) {
383 pic, pic, kTRUE);
384 if ((pic != fFileIcon) && (pic != fCachedPic))
386 if (item) fListTree->CheckItem(item, (Bool_t)check);
387 fListTree->SetToolTipItem(item, FormatToolTip(obj, 32));
388 }
389 }
390 else {
391 // special case for remote object
393 if (obj->InheritsFrom("TRemoteObject"))
394 isRemote = kTRUE;
395 else if (fListLevel) {
396 // check also if one of its parents is a remote object
398 while (top->GetParent()) {
399 TObject *tobj = (TObject *) top->GetUserData();
400 if (tobj && (tobj->InheritsFrom("TRemoteObject") ||
401 tobj->InheritsFrom("TApplicationRemote"))) {
402 isRemote = kTRUE;
403 break;
404 }
405 top = top->GetParent();
406 }
407 }
408 if (isRemote) {
410 if (!strcmp(robj->GetClassName(), "TKey")) {
411 AddKey(fListLevel, obj, name);
412 }
413 else {
415 // add the remote object only if not already in the list
416 if (!fShowHidden && fname.BeginsWith("."))
417 return;
418 AddRemoteFile(obj);
419 }
420 }
421 else {
424 if ((pic != fFileIcon) && (pic != fCachedPic))
426 if (item && obj && obj->InheritsFrom("TObject"))
427 item->SetDNDSource(kTRUE);
428 fListTree->SetToolTipItem(item, FormatToolTip(obj, 32));
429 }
430 }
431 }
432 }
433}
434
435////////////////////////////////////////////////////////////////////////////////
436/// Add remote file in list tree.
437
439{
441 Int_t type;
443 const TGPicture *spic;
444 TGPicture *pic;
445
447
449
450 robj->GetFileStat(&sbuf);
451 is_link = sbuf.fIsLink;
452 type = sbuf.fMode;
453 filename = robj->GetName();
454 if (R_ISDIR(type) || fFilter == 0 ||
455 (fFilter && filename.Index(*fFilter) != kNPOS)) {
456
458
459 pic = (TGPicture*)spic; pic->AddReference();
460
464 }
465}
466
467////////////////////////////////////////////////////////////////////////////////
468/// Browse object. This, in turn, will trigger the calling of
469/// TBrowser::Add() which will fill the IconBox and the tree.
470/// Emits signal "BrowseObj(TObject*)".
471
473{
474 if (fNewBrowser)
476 if (obj != gROOT) {
478 fListLevel = 0;
479 Add(obj);
482 if (obj->IsFolder())
486 }
487 }
488 if (fBrowser) obj->Browse(fBrowser);
489 if (obj == gROOT) {
490 TList *volumes = gSystem->GetVolumes("all");
491 TList *curvol = gSystem->GetVolumes("cur");
492 if (volumes && curvol) {
493 const char *curdrive;
494 TNamed *named = (TNamed *)curvol->At(0);
495 if (named)
496 curdrive = named->GetName();
497 else
498 curdrive = "C:";
499 TIter next(volumes);
500 TNamed *drive;
501 while ((drive = (TNamed *)next())) {
502 AddFSDirectory(TString::Format("%s\", drive->GetName()), drive->GetTitle(),
503 (strcmp(drive->GetName(), curdrive) == 0) ?
504 "SetRootDir" : "Add");
505 }
506 delete volumes;
507 delete curvol;
508 }
509 else {
510 AddFSDirectory("/");
511 }
513 if (gROOT->GetListOfFiles() && !gROOT->GetListOfFiles()->IsEmpty())
514 Selected(0);
515 }
516}
517
518////////////////////////////////////////////////////////////////////////////////
519/// Emits signal when double clicking on icon.
520
522{
523 if (fNewBrowser)
524 fNewBrowser->Checked(obj, checked);
525}
526
527////////////////////////////////////////////////////////////////////////////////
528/// returns drawing option
529
531{
532 return fDrawOption->GetTextEntry()->GetText();
533}
534
535////////////////////////////////////////////////////////////////////////////////
536/// Determine the file picture for the given file type.
537
539 Bool_t is_link, const char *name)
540{
541 static TString cached_ext;
542 static const TGPicture *cached_spic = 0;
543 const char *ext = name ? strrchr(name, '.') : 0;
544 TString sname = name ? name : " ";
545 *pic = 0;
546
547 if (ext && cached_spic && (cached_ext == ext)) {
548 *pic = cached_spic;
549 return;
550 }
551
552 if (R_ISREG(file_type)) {
553 *pic = gClient->GetMimeTypeList()->GetIcon(name, kTRUE);
554
555 if (*pic) {
556 if (ext) {
557 cached_ext = ext;
558 cached_spic = *pic;
559 return;
560 }
561 }
562 } else {
563 *pic = 0;
564 }
565
566 if (*pic == 0) {
567 *pic = gClient->GetPicture("doc_t.xpm");
568
569 if (R_ISREG(file_type) && (file_type) & kS_IXUSR) {
570 *pic = gClient->GetPicture("app_t.xpm");
571 }
572 if (R_ISDIR(file_type)) {
573 *pic = gClient->GetPicture("folder_t.xpm");
574 }
575 if(sname.EndsWith(".root")) {
576 *pic = gClient->GetPicture("rootdb_t.xpm");
577 }
578
579 }
580 if (is_link) {
581 *pic = gClient->GetPicture("slink_t.xpm");
582 }
583
584 cached_spic = 0;
585 cached_ext = "";
586}
587
588////////////////////////////////////////////////////////////////////////////////
589/// Recursively remove object.
590
592{
593 TGListTreeItem *itm = nullptr, *item = nullptr;
594 if (obj->InheritsFrom("TFile")) {
595 itm = fListTree->FindChildByData(0, gROOT->GetListOfFiles());
596 if (itm)
597 item = fListTree->FindChildByData(itm, obj);
598 if (item) {
599 // if the item to be deleted has a filter,
600 // delete its entry in the map
601 if (CheckFiltered(item))
602 fFilteredItems.erase(item);
603 fListTree->DeleteItem(item);
604 }
605 itm = fRootDir ? fRootDir->GetFirstChild() : nullptr;
606 while (itm) {
607 item = fListTree->FindItemByObj(itm, obj);
608 if (item) {
610 item->SetUserData(0);
611 }
612 itm = itm->GetNextSibling();
613 }
614 }
615 if (!obj->InheritsFrom("TFile") && fRootDir) {
616 item = fListTree->FindItemByObj(fRootDir, obj);
617 // if the item to be deleted has a filter, delete its entry in the map
618 if (item && CheckFiltered(item))
619 fFilteredItems.erase(item);
621 }
622 //fListTree->ClearViewPort();
623}
624
625////////////////////////////////////////////////////////////////////////////////
626/// Refresh content of the list tree.
627
629{
630 TTimer::SingleShot(200, "TGFileBrowser", this, "Update()");
631 return; // disable refresh for the time being...
632 // coverity[unreachable]
634 static UInt_t prev = 0;
635 UInt_t curr = gROOT->GetListOfBrowsables()->GetSize();
636 if (!prev) prev = curr;
637
638 if (prev != curr) { // refresh gROOT
640 fListLevel = 0;
642 fListLevel = sav;
643 prev = curr;
644 }
645}
646
647////////////////////////////////////////////////////////////////////////////////
648/// Update content of the list tree.
649
651{
652 Long64_t size = 0;
653 Long_t id = 0, flags = 0, modtime = 0;
654 char path[1024];
656 if (!item) item = fRootDir;
657 if (!item) return;
658 //fListTree->DeleteChildren(item);
659 TGListTreeItem *curr = fListTree->GetSelected(); // GetCurrent() ??
660 if (curr) {
661 TObject *obj = (TObject *) curr->GetUserData();
662 if (obj && ROOT::Detail::HasBeenDeleted(obj)) {
663 // if the item to be deleted has a filter,
664 // delete its entry in the map
665 if (CheckFiltered(curr))
666 fFilteredItems.erase(curr);
668 curr = 0;
669 obj = 0;
670 }
671 else if (obj && !ROOT::Detail::HasBeenDeleted(obj) &&
672 obj->InheritsFrom("TObjString") && curr->GetParent()) {
673 fListTree->GetPathnameFromItem(curr->GetParent(), path);
674 if (strlen(path) > 1) {
675 TString dirpath = FullPathName(curr->GetParent());
676 Int_t res = gSystem->GetPathInfo(dirpath.Data(), &id, &size,
677 &flags, &modtime);
678 if ((res == 0) && (flags & 2)) {
680 if (gSystem->AccessPathName(fullpath.Data())) {
681 // if the item to be deleted has a filter,
682 // delete its entry in the map
683 if (CheckFiltered(curr))
684 fFilteredItems.erase(curr);
686 curr = 0;
687 obj = 0;
688 }
689 }
690 }
691 }
692 }
694 flags = id = size = modtime = 0;
695 if (gSystem->GetPathInfo(actpath.Data(), &id, &size, &flags, &modtime) == 0) {
696 Int_t isdir = (Int_t)flags & 2;
697
699 if (isdir) {
700 TGListTreeItem *del = 0, *itm = item->GetFirstChild();
701 while (itm) {
703 if (strlen(path) > 1) {
705 if (gSystem->AccessPathName(recpath.Data())) {
706 del = itm;
707 itm = itm->GetNextSibling();
708 // if the item to be deleted has a filter,
709 // delete its entry in the map
710 if (CheckFiltered(del))
711 fFilteredItems.erase(del);
713 }
714 }
715 if (del)
716 del = 0;
717 else
718 itm = itm->GetNextSibling();
719 }
720 }
721 }
723 DoubleClicked(item, 1);
724 fListLevel = sav;
726}
727
728/**************************************************************************/
729// Other
730/**************************************************************************/
731
732////////////////////////////////////////////////////////////////////////////////
733/// Add file system directory in the list tree.
734
735void TGFileBrowser::AddFSDirectory(const char *entry, const char *path,
736 Option_t *opt)
737{
738 TGListTreeItem *item = 0;
739 if ((opt == 0) || (!opt[0])) {
740 if (fRootDir == 0 && !fListTree->FindChildByName(0, rootdir))
742 return;
743 }
744 if (strstr(opt, "SetRootDir")) {
746 item = fRootDir = fListTree->AddItem(0, entry);
747 }
748 else if (strstr(opt, "Add")) {
749 // MT: i give up! wanted to place entries for selected
750 // directories like home, pwd, alice-macros.
751 // TGListTreeItem *lti = fListTree->AddItem(0, entry);
752 //
754 item = fListTree->AddItem(0, entry);
755 }
756 if (item && path) {
757 TString infos = path;
758 item->SetTipText(path);
759 TGPicture *pic = 0;
760 if (infos.Contains("Removable"))
761 pic = (TGPicture *)gClient->GetPicture("fdisk_t.xpm");
762 else if (infos.Contains("Local"))
763 pic = (TGPicture *)gClient->GetPicture("hdisk_t.xpm");
764 else if (infos.Contains("CD"))
765 pic = (TGPicture *)gClient->GetPicture("cdrom_t.xpm");
766 else if (infos.Contains("Network"))
767 pic = (TGPicture *)gClient->GetPicture("netdisk_t.xpm");
768 if (pic)
769 item->SetPictures(pic, pic);
770 }
771}
772
773////////////////////////////////////////////////////////////////////////////////
774/// display content of ROOT file
775
777{
778 // Int_t from, to;
780 static TGListTreeItem *olditem = itm;
781 static TGListTreeItem *item = itm;
782 const TGPicture *pic;
783
784 if (itm == 0) return;
785
786 if ((fCnt == 0) || (olditem != itm)) {
787 olditem = item = itm;
788 }
789 if (!name) name = obj->GetName();
790 if (fNKeys > fGroupSize) {
791 where = itm->GetFirstChild();
792 while (where) {
793 if (fListTree->FindItemByObj(where, obj))
794 return;
795 where = where->GetNextSibling();
796 }
797 }
798 if ((fNKeys > fGroupSize) && (fCnt % fGroupSize == 0)) {
799 if (item != itm) {
800 TString newname = TString::Format("%s-%s", item->GetText(), name);
801 item->Rename(newname.Data());
802 }
803 item = fListTree->AddItem(itm, name);
804 item->SetDNDSource(kTRUE);
805 }
806 if ((fCnt > fGroupSize) && (fCnt >= fNKeys-1)) {
807 TString newname = TString::Format("%s-%s", item->GetText(), name);
808 item->Rename(newname.Data());
809 }
810 GetObjPicture(&pic, obj);
811 if (!fListTree->FindChildByName(item, name)) {
812 TGListTreeItem *it = fListTree->AddItem(item, name, obj, pic, pic);
813 if (pic && (pic != fFileIcon) && (pic != fCachedPic))
815 it->SetDNDSource(kTRUE);
816 it->SetTipText(FormatToolTip(obj, 32));
817 }
818 fCnt++;
819}
820
821////////////////////////////////////////////////////////////////////////////////
822/// Apply filter selected in combo box to the file tree view.
823
825{
826 // Long64_t size;
827 // Long_t fid, flags, modtime;
828
829 if (fFilter)
830 delete fFilter;
831 fFilter = nullptr;
832 if ((id > 1) && (id < 5))
833 fFilter = new TRegexp(filters[id], kTRUE);
834 else if ((id < 0) || (id > 4)) {
836 if (lbe) {
837 const char *text = lbe->GetTitle();
838 fFilter = new TRegexp(text, kTRUE);
839 }
840 }
842 if (!item)
843 item = fRootDir;
844 if (!item) return;
846 DoubleClicked(item, 1);
847 //fListTree->AdjustPosition(item);
849}
850
851////////////////////////////////////////////////////////////////////////////////
852/// Make object associated with item the current directory.
853
855{
856 if (item) {
857 TGListTreeItem *i = item;
858 while (i) {
859 TObject *obj = (TObject*) i->GetUserData();
860 if ((obj) && obj->InheritsFrom("TDirectory")) {
861 ((TDirectory *)obj)->cd();
862 break;
863 }
864 i = i->GetParent();
865 }
866 }
867}
868
869////////////////////////////////////////////////////////////////////////////////
870/// Check if the current list tree item points to a remote object.
871
873{
874 if (!item) return;
875 TObject *obj = (TObject *) item->GetUserData();
876 if (obj) {
877 if (obj->InheritsFrom("TApplicationRemote")) {
878 if (!gApplication->GetAppRemote()) {
879 gROOT->ProcessLine(TString::Format(".R %s", item->GetText()));
880 if (gApplication->GetAppRemote()) {
881 Getlinem(kInit, TString::Format("\n%s:root [0]",
883 }
884 }
885 }
886 if (item->GetParent() && item->GetParent()->GetUserData() &&
887 ((TObject *)item->GetParent()->GetUserData())->InheritsFrom("TApplicationRemote")) {
888 // switch to remote session
889 if (!gApplication->GetAppRemote()) {
890 gROOT->ProcessLine(TString::Format(".R %s", item->GetParent()->GetText()));
891 if (gApplication->GetAppRemote()) {
892 Getlinem(kInit, TString::Format("\n%s:root [0]",
894 }
895 }
896 else if (!strcmp(item->GetText(), "ROOT Files")) {
897 // update list of files opened in the remote session
899 gApplication->ProcessLine("((TApplicationServer *)gApplication)->BrowseFile(0);");
900 }
901 }
902 else {
903 // check if the listtree item is from a local session or
904 // from a remote session, then switch to the session it belongs to
905 TGListTreeItem *top = item;
906 while (top->GetParent()) {
907 top = top->GetParent();
908 }
909 TObject *topobj = (TObject *) top->GetUserData();
910 if (topobj && topobj->InheritsFrom("TApplicationRemote")) {
911 // it belongs to a remote session
912 if (!gApplication->GetAppRemote()) {
913 // switch to remote session if not already in
914 gROOT->ProcessLine(TString::Format(".R %s", top->GetText()));
915 if (gApplication->GetAppRemote()) {
916 Getlinem(kInit, TString::Format("\n%s:root [0]",
918 }
919 }
920 }
921 else if (gApplication->GetAppRemote()) {
922 // switch back to local session if not already in
924 Getlinem(kInit, "\nroot [0]");
925 }
926 }
927 }
928 else if (gApplication->GetAppRemote()) {
929 // switch back to local session if not already in
931 Getlinem(kInit, "\nroot [0]");
932 }
933}
934
935////////////////////////////////////////////////////////////////////////////////
936/// Check if there is a filter active on the children of the list tree item.
937/// If the but argument is true, the "filter" button state is set accordingly,
938/// and its tooltip will show the filter used.
939
941{
942 Bool_t found = kFALSE;
943 TString filter;
944 // if there is no filter (the map is empty) then just return
945 if (fFilteredItems.empty())
946 return kFALSE;
947 auto it = fFilteredItems.find(item);
948 if (it != fFilteredItems.end()) {
949 // if the item is in the map, take the filter regexp string
950 filter = it->second.c_str();
951 fFilterStr = filter;
952 found = kTRUE;
953 }
954 if (but) {
955 // if the but argument is true, change the button state
956 // to reflect the filtering state
958 if (found) {
959 // format the tooltip to display the regexp used as filter
960 filter.Prepend("Showing only \'");
961 filter += "\'";
963 }
964 else {
965 // reset the tooltip text
966 fFilterButton->SetToolTipText("Filter Content...");
967 }
968 }
969 return found;
970}
971
972////////////////////////////////////////////////////////////////////////////////
973/// Check if the list tree item children are alphabetically sorted.
974/// If the but argument is true, the "sort" button state is set accordingly.
975
977{
978 Bool_t found = kFALSE;
979 TGListTreeItem *i, *itm;
980 if (item->GetFirstChild())
981 itm = item;
982 else
983 itm = item->GetParent();
984 for (sLTI_i p=fSortedItems.begin(); p!=fSortedItems.end(); ++p) {
985 i = (TGListTreeItem *)(*p);
986 if (itm == i) {
987 found = kTRUE;
988 break;
989 }
990 }
992 return found;
993}
994
995////////////////////////////////////////////////////////////////////////////////
996/// Process mouse clicks in TGListTree.
997
999{
1000 char path[1024];
1001 Long64_t size = 0;
1002 Long_t id = 0, flags = 0, modtime = 0;
1003 fListLevel = item;
1004 if (!item) return;
1005 CheckSorted(item, kTRUE);
1006 CheckFiltered(item, kTRUE);
1007 CheckRemote(item);
1008 TObject *selected = 0;
1010 TObject *obj = (TObject *) item->GetUserData();
1011 if (obj && (!obj->InheritsFrom("TObjString") ||
1012 gSystem->AccessPathName(fullpath.Data()))) {
1013 if (obj->InheritsFrom("TKey") && (obj->IsA() != TClass::Class())) {
1014 Chdir(item);
1015 const char *clname = ((TKey *)obj)->GetClassName();
1016 if (clname && strcmp(clname, "TGeoManager")) {
1018 TString name = ((TKey *)obj)->GetName();
1019 name += ";";
1020 name += ((TKey *)obj)->GetCycle();
1021 void *add = gDirectory->FindObjectAny((char *) name.Data());
1022 if (add && cl->IsTObject()) {
1023 obj = (TObject*)add;
1024 // don't change the user data, to avoid deletion of the
1025 // list tree item by RecursiveRemove()
1026 // it is better to read the object each time anyway,
1027 // as it may have changed in the file
1028 if (obj->InheritsFrom("TDirectory") || obj->InheritsFrom("TList"))
1029 item->SetUserData(obj);
1030 }
1031 }
1032 }
1033 if (obj->InheritsFrom("TLeaf") ||
1034 obj->InheritsFrom("TBranch")) {
1035 Chdir(item);
1036 }
1037 if (btn == kButton3)
1038 fContextMenu->Popup(x, y, obj, fBrowser);
1039 selected = obj;
1040 }
1041 else {
1042 fListTree->GetPathnameFromItem(item, path);
1043 if (strlen(path) > 3) {
1044 if (gSystem->GetPathInfo(fullpath.Data(), &id, &size, &flags, &modtime) == 0) {
1045 if (flags & 2) {
1046 fCurrentDir = item;
1047 if (btn == kButton3) {
1048 if (fDir) delete fDir;
1049 fDir = new TSystemDirectory(item->GetText(), fullpath.Data());
1051 }
1052 }
1053 else {
1054 fCurrentDir = item->GetParent();
1055 if (btn == kButton3) {
1056 if (fFile) delete fFile;
1057 fFile = new TSystemFile(item->GetText(), fullpath.Data());
1059 }
1060 }
1061 }
1062 }
1063 }
1065 if (selected && (selected->IsA() != TClass::Class())) {
1066 if (selected->InheritsFrom("TLeaf"))
1067 selected = (TObject *)gROOT->ProcessLine(TString::Format("((TLeaf *)0x%zx)->GetBranch()->GetTree();", (size_t)selected));
1068 if (selected->InheritsFrom("TBranch"))
1069 selected = (TObject *)gROOT->ProcessLine(TString::Format("((TBranch *)0x%zx)->GetTree();", (size_t)selected));
1070 if (selected->InheritsFrom("TTree")) {
1071 // if a tree not attached to any directory (e.g. in a TFolder)
1072 // then attach it to the current directory (gDirectory)
1073 TDirectory *tdir = (TDirectory *)gROOT->ProcessLine(TString::Format("((TTree *)0x%zx)->GetDirectory();", (size_t)selected));
1074 if (!tdir) {
1075 gROOT->ProcessLine(TString::Format("((TTree *)0x%zx)->SetDirectory(gDirectory);", (size_t)selected));
1076 }
1077 }
1078 }
1079 if (selected && gPad && IsObjectEditable(selected->IsA())) {
1081 if (ved) {
1082 TGedEditor *ged = (TGedEditor *)ved;
1084 }
1085 }
1086}
1087
1088////////////////////////////////////////////////////////////////////////////////
1089/// returns an absolute path
1090
1092{
1093 TGListTreeItem *parent, *itm = item;
1094 TString dirname = itm->GetText();
1095
1096 while ((parent=itm->GetParent())) {
1097 char *s = gSystem->ConcatFileName(parent->GetText(), dirname);
1098 dirname = s;
1099 delete [] s;
1100 itm = parent;
1101 }
1103#ifdef R__WIN32
1104 // only handle .lnk files on Windows
1105 while (dirname.Contains(".lnk")) {
1106 Ssiz_t idx = dirname.Index(".lnk") + 4;
1108 resolved.Remove(idx);
1110 dirname = resolved.Append(dirname.Remove(0, idx));
1111 }
1112#endif
1113 return dirname;
1114}
1115
1116////////////////////////////////////////////////////////////////////////////////
1117/// returns the directory path
1118
1120{
1123
1124#ifdef WIN32
1125 char winDrive[256];
1126 char winDir[256];
1127 char winName[256];
1128 char winExt[256];
1131#else
1133#endif
1134 return dirname;
1135}
1136
1137////////////////////////////////////////////////////////////////////////////////
1138/// Returns true if given a text file
1139/// Uses the specification given on p86 of the Camel book
1140/// - Text files have no NULLs in the first block
1141/// - and less than 30% of characters with high bit set
1142
1143static Bool_t IsTextFile(const char *candidate)
1144{
1145 Int_t i;
1146 Int_t nchars;
1147 Int_t weirdcount = 0;
1148 char buffer[512];
1149 FILE *infile;
1150 FileStat_t buf;
1151
1152 if (gSystem->GetPathInfo(candidate, buf) || !(buf.fMode & kS_IFREG))
1153 return kFALSE;
1154
1155 infile = fopen(candidate, "r");
1156 if (infile) {
1157 // Read a block
1158 nchars = fread(buffer, 1, 512, infile);
1159 fclose (infile);
1160 // Examine the block
1161 for (i = 0; i < nchars; i++) {
1162 if (buffer[i] & 128)
1163 weirdcount++;
1164 if (buffer[i] == '\0')
1165 // No NULLs in text files
1166 return kFALSE;
1167 }
1168 if ((nchars > 0) && ((weirdcount * 100 / nchars) > 30))
1169 return kFALSE;
1170 } else {
1171 // Couldn't open it. Not a text file then
1172 return kFALSE;
1173 }
1174 return kTRUE;
1175}
1176
1177////////////////////////////////////////////////////////////////////////////////
1178/// Create a symlink (shortcut on Windows) icon by merging the picture
1179/// passed as argument and the slink_t.xpm icon (small arrow)
1180
1181static const TGPicture *MakeLinkPic(const TGPicture *pic)
1182{
1183 const TGPicture *merged;
1184 TImage *img1, *img2;
1185 if (pic) {
1186 img1 = TImage::Create();
1187 if (img1 == 0) return pic;
1188 img1->SetImage(((const TGPicture *)pic)->GetPicture(),
1189 ((const TGPicture *)pic)->GetMask());
1190 img2 = TImage::Open("slink_t.xpm");
1191 if (img2) img1->Merge(img2);
1192 TString lnk_name = ((const TGPicture *)pic)->GetName();
1193 lnk_name.Prepend("lnk_");
1194 merged = gClient->GetPicturePool()->GetPicture(lnk_name.Data(),
1195 img1->GetPixmap(), img1->GetMask());
1196 if (img2) delete img2;
1197 delete img1;
1198 return merged;
1199 }
1200 return pic;
1201}
1202
1203////////////////////////////////////////////////////////////////////////////////
1204/// Process double clicks in TGListTree.
1205
1207{
1208 const TGPicture *pic=0;
1209 TString dirname = DirName(item);
1213 Long64_t size;
1214 Long_t id, flags, modtime;
1215 char action[512];
1216 TString act;
1218 if (!gSystem->GetPathInfo(item->GetText(), sbuf) && sbuf.fIsLink) {
1219 is_link = kTRUE;
1220 fullpath = item->GetText();
1222 }
1223
1224 if (fNewBrowser)
1227 fListLevel = item;
1228 CheckSorted(item, kTRUE);
1229 CheckFiltered(item, kTRUE);
1230 CheckRemote(item);
1231 TGListTreeItem *pitem = item->GetParent();
1232 TObject *obj = (TObject *) item->GetUserData();
1233 if (obj && !obj->InheritsFrom("TSystemFile")) {
1234 TString ext = obj->GetName();
1235 if (obj->InheritsFrom("TDirectory") && (obj->IsA() != TClass::Class())) {
1236 if (((TDirectory *)obj)->GetListOfKeys())
1237 fNKeys = ((TDirectory *)obj)->GetListOfKeys()->GetEntries();
1238 else
1239 fNKeys = 0;
1240 }
1241 else if (obj->InheritsFrom("TKey") && (obj->IsA() != TClass::Class())) {
1242 Chdir(item);
1243 const char *clname = ((TKey *)obj)->GetClassName();
1244 if (clname) {
1246 TString name = ((TKey *)obj)->GetName();
1247 name += ";";
1248 name += ((TKey *)obj)->GetCycle();
1249 void *add = gDirectory->FindObjectAny((char *) name.Data());
1250 if (add && cl->IsTObject()) {
1251 obj = (TObject*)add;
1252 // don't change the user data, to avoid deletion of the
1253 // list tree item by RecursiveRemove()
1254 // it is better to read the object each time anyway,
1255 // as it may have changed in the file
1256 if (obj->InheritsFrom("TDirectory") || obj->InheritsFrom("TList"))
1257 item->SetUserData(obj);
1258 }
1259 }
1260 }
1261 else if (obj->InheritsFrom("TLeaf") || obj->InheritsFrom("TBranch")) {
1262 Chdir(item);
1263 }
1264 else if (obj->InheritsFrom("TRemoteObject")) {
1265 // the real object is a TKey
1267 if (!strcmp(robj->GetClassName(), "TKey")) {
1268 TGListTreeItem *parent = item;
1270 // find the TFile remote object containing the TKey
1271 while ( probj && strcmp(probj->GetClassName(), "TFile")) {
1272 parent = parent->GetParent();
1273 probj = (TRemoteObject *)parent->GetUserData();
1274 }
1275 if (probj && !strcmp(probj->GetClassName(), "TFile")) {
1276 // remotely browse file (remotely call TFile::cd())
1279 TString::Format("((TApplicationServer *)gApplication)->BrowseFile(\"%s\");",
1280 probj->GetName()));
1281 gSystem->Sleep(250);
1282 }
1283 }
1284 if (gClient->GetMimeTypeList()->GetAction(obj->GetName(), action)) {
1285 act = action;
1286 act.ReplaceAll("%s", obj->GetName());
1287 if ((act[0] != '!') && (strcmp(pitem->GetText(), "ROOT Files"))) {
1288 // special case for remote object: remote process
1290 gApplication->ProcessLine(act.Data());
1291 }
1292 }
1293 if ((ext.EndsWith(".root")) && (strcmp(pitem->GetText(), "ROOT Files"))) {
1295 gApplication->ProcessLine("((TApplicationServer *)gApplication)->BrowseFile(0);");
1296 }
1297 }
1298 if (!obj->InheritsFrom("TObjString") ||
1299 gSystem->AccessPathName(fullpath.Data())) {
1301 fDblClick = kTRUE;
1302 if (gClient->GetMimeTypeList()->GetAction(obj->IsA()->GetName(), action)) {
1303 act = action;
1304 if (fBrowser && act.Contains("->Browse()")) obj->Browse(fBrowser);
1305 else if (act.Contains("->Draw()")) obj->Draw(GetDrawOption());
1306 else {
1307 if (act.Contains("%s")) act.ReplaceAll("%s", obj->GetName());
1308 else act.Prepend(obj->GetName());
1309 gInterpreter->SaveGlobalsContext();
1310 if (act[0] == '!') {
1311 act.Remove(0, 1);
1312 gSystem->Exec(act.Data());
1313 } else {
1314 // special case for remote object: remote process
1315 if (obj->InheritsFrom("TRemoteObject"))
1317 gApplication->ProcessLine(act.Data());
1318 }
1319 }
1320 }
1321 else if (obj->InheritsFrom("TCanvas") && fNewBrowser &&
1324 // avoid potential crash when drawing a canvas with the same name
1325 // than a canvas already embedded in one of the browser's tab
1326 obj->DrawClone();
1327 } else if (fBrowser && !obj->InheritsFrom("TFormula"))
1328 obj->Browse(fBrowser);
1329 fDblClick = kFALSE;
1330 fNKeys = 0;
1331 fCnt = 0;
1333 if (gPad) gPad->Update();
1334 return;
1335 }
1336 }
1337 flags = id = size = modtime = 0;
1338 if (gSystem->GetPathInfo(fullpath.Data(), &id, &size, &flags, &modtime) != 0)
1339 return;
1340 Int_t isdir = (Int_t)flags & 2;
1341
1343 if (isdir) {
1344 fCurrentDir = item;
1345 //fListTree->DeleteChildren(item);
1346 TSystemDirectory dir(item->GetText(),FullPathName(item));
1347 TList *files = dir.GetListOfFiles();
1348 if (files) {
1349 files->Sort();
1350 TIter next(files);
1351 TSystemFile *file;
1353 // directories first
1354 //fListTree->DeleteChildren(item);
1355 while ((file=(TSystemFile*)next())) {
1356 fname = file->GetName();
1357 if (file->IsDirectory()) {
1358 if (!fShowHidden && fname.BeginsWith("."))
1359 continue;
1360 if ((fname!="..") && (fname!=".")) { // skip it
1361 if (!fListTree->FindChildByName(item, fname)) {
1362 itm = fListTree->AddItem(item, fname);
1363 if (!gSystem->GetPathInfo(fname, sbuf) &&
1364 sbuf.fIsLink) {
1365 // change the pictures if it is a symlink
1366 // (shortcut on Windows)
1367 const TGPicture *opened = 0, *l_opened = 0;
1368 const TGPicture *closed = 0, *l_closed = 0;
1369 opened = fClient->GetPicture("ofolder_t.xpm");
1371 closed = fClient->GetPicture("folder_t.xpm");
1373 if (l_opened && l_closed)
1374 itm->SetPictures(l_opened, l_closed);
1379 }
1380 // uncomment line below to set directories as
1381 // DND targets
1382 //itm->SetDNDTarget(kTRUE);
1383 itm->SetUserData(0);
1384 }
1385 }
1386 }
1387 }
1388 // then files...
1389 TIter nextf(files);
1390 while ((file=(TSystemFile*)nextf())) {
1391 fname = pname = file->GetName();
1392 if (!file->IsDirectory() && (fFilter == 0 ||
1393 (fFilter && fname.Index(*fFilter) != kNPOS))) {
1394 if (!fShowHidden && fname.BeginsWith("."))
1395 continue;
1396 size = modtime = 0;
1397 if (gSystem->GetPathInfo(fname, sbuf) == 0) {
1398 size = sbuf.fSize;
1399 modtime = sbuf.fMtime;
1400 }
1401 if (sbuf.fIsLink && pname.EndsWith(".lnk"))
1402 pname.Remove(pname.Length()-4);
1403 pic = gClient->GetMimeTypeList()->GetIcon(pname, kTRUE);
1404 if (!pic)
1405 pic = fFileIcon;
1406 if (sbuf.fIsLink)
1407 pic = MakeLinkPic(pic);
1408 if (!fListTree->FindChildByName(item, fname)) {
1409 itm = fListTree->AddItem(item, fname, pic, pic);
1410 if (pic != fFileIcon)
1412 if (sbuf.fIsLink) {
1413 TString fullname = file->GetName();
1414 gSystem->ExpandPathName(fullname);
1415 itm->SetUserData(new TObjString(TString::Format("file://%s\r\n",fullname.Data())), kTRUE);
1416 } else {
1417 itm->SetUserData(new TObjString(TString::Format("file://%s/%s\r\n",
1418 gSystem->UnixPathName(file->GetTitle()),
1419 file->GetName())), kTRUE);
1420 }
1421 itm->SetDNDSource(kTRUE);
1422 if (size && modtime) {
1423 char *tiptext = FormatFileInfo(fname.Data(), size, modtime);
1424 itm->SetTipText(tiptext);
1425 delete [] tiptext;
1426 }
1427 }
1428 }
1429 }
1430 files->Delete();
1431 delete files;
1432 }
1433 }
1434 else {
1435 TString lnkname = item->GetText();
1436 if (is_link && lnkname.EndsWith(".lnk"))
1437 lnkname.Remove(lnkname.Length()-4);
1438 fCurrentDir = item->GetParent();
1439 TSystemFile f(lnkname.Data(), fullpath.Data());
1440 TString fname = f.GetName();
1441 if (fname.EndsWith(".root")) {
1442 TDirectory *rfile = 0;
1444 rfile = (TDirectory *)gROOT->GetListOfFiles()->FindObject(obj);
1445 if (!rfile) {
1446 rfile = (TDirectory *)gROOT->ProcessLine(TString::Format("new TFile(\"%s\")",fname.Data()));
1447 }
1448 if (rfile) {
1449 // replace actual user data (TObjString) by the TDirectory...
1450 if (item->GetUserData()) {
1451 // first delete the data to avoid memory leaks
1452 TObject *obj2 = static_cast<TObject *>(item->GetUserData());
1453 // only delete TObjString as they are the only objects
1454 // created who have to be deleted
1455 TObjString *ostr = dynamic_cast<TObjString *>(obj2);
1456 if (ostr) delete ostr;
1457 }
1458 item->SetUserData(rfile);
1459 fNKeys = rfile->GetListOfKeys()->GetEntries();
1460 fCnt = 0;
1461 if (fBrowser) rfile->Browse(fBrowser);
1462 fNKeys = 0;
1463 fCnt = 0;
1464 }
1465 }
1466 else if (fname.EndsWith(".png")) {
1470 }
1471 else if (IsTextFile(fullpath.Data())) {
1473 if (fNewBrowser) {
1474 TGFrameElement *fe = 0;
1476 TGCompositeFrame *frame = tabRight->GetCurrentContainer();
1477 if (frame)
1478 fe = (TGFrameElement *)frame->GetList()->First();
1479 if (fe) {
1481 TString fullname = f.GetTitle();
1482 fullname.ReplaceAll("\", "\\");
1483 if (embed->InheritsFrom("TGTextEditor")) {
1484 gROOT->ProcessLine(TString::Format("((TGTextEditor *)0x%zx)->LoadFile(\"%s\");",
1485 (size_t)embed, fullname.Data()));
1486 }
1487 else if (embed->InheritsFrom("TGTextEdit")) {
1488 gROOT->ProcessLine(TString::Format("((TGTextEdit *)0x%zx)->LoadFile(\"%s\");",
1489 (size_t)embed, fullname.Data()));
1490 }
1491 else {
1493 }
1494 }
1495 else {
1497 }
1498 }
1500 }
1501 else {
1505 }
1506 }
1507 //gSystem->ChangeDirectory(savdir.Data());
1509}
1510
1511////////////////////////////////////////////////////////////////////////////////
1512/// Execute default action for selected object (action is specified
1513/// in the $HOME/.root.mimes or $ROOTSYS/etc/root.mimes file.
1514
1516{
1517 char action[512];
1518 TString act;
1519 TString ext = obj->GetName();
1521
1522 if (gClient->GetMimeTypeList()->GetAction(obj->GetName(), action)) {
1523 act = action;
1524 act.ReplaceAll("%s", obj->GetName());
1525 gInterpreter->SaveGlobalsContext();
1526
1527 if (act[0] == '!') {
1528 act.Remove(0, 1);
1529 gSystem->Exec(act.Data());
1530 return 0;
1531 } else {
1532 // special case for remote object: remote process
1533 if (obj->InheritsFrom("TRemoteObject"))
1535
1536 const Long_t res = gApplication->ProcessLine(act.Data());
1537#ifdef R__HAS_COCOA
1538 if (act.Contains(".x") || act.Contains(".X")) {
1539 if (gPad) gPad->Update();
1540 }
1541#endif
1542 return res;
1543 }
1544 }
1545 return 0;
1546}
1547
1548////////////////////////////////////////////////////////////////////////////////
1549/// Format file information to be displayed in the tooltip.
1550
1552{
1553 Long64_t fsize, bsize;
1555 infos += "\n";
1556
1557 fsize = bsize = size;
1558 if (fsize > 1024) {
1559 fsize /= 1024;
1560 if (fsize > 1024) {
1561 // 3.7MB is more informative than just 3MB
1562 infos += TString::Format("Size: %lld.%lldM", fsize/1024, (fsize%1024)/103);
1563 } else {
1564 infos += TString::Format("Size: %lld.%lldK", bsize/1024, (bsize%1024)/103);
1565 }
1566 } else {
1567 infos += TString::Format("Size: %lld", bsize);
1568 }
1569 struct tm *newtime;
1570 time_t loctime = (time_t) modtime;
1572 if (newtime) {
1573 infos += "\n";
1574 infos += TString::Format("%d-%02d-%02d %02d:%02d",
1575 newtime->tm_year + 1900,
1576 newtime->tm_mon+1, newtime->tm_mday,
1577 newtime->tm_hour, newtime->tm_min);
1578 }
1579 return StrDup(infos.Data());
1580}
1581
1582////////////////////////////////////////////////////////////////////////////////
1583/// Retrieve icons associated with class "name". Association is made
1584/// via the user's ~/.root.mimes file or via $ROOTSYS/etc/root.mimes.
1585
1587{
1588 const char *clname = 0;
1589 TClass *objClass = 0;
1590 static TImage *im = 0;
1591 if (!im) {
1592 im = TImage::Create();
1593 }
1594
1595 if (obj->IsA() == TClass::Class()) {
1596 objClass = obj->IsA();
1597 if (objClass)
1598 clname = objClass->GetName();
1599 }
1600 else if (obj->InheritsFrom("TKey")) {
1601 clname = ((TKey *)obj)->GetClassName();
1602 }
1603 else if (obj->InheritsFrom("TKeyMapFile")) {
1604 clname = ((TKeyMapFile *)obj)->GetTitle();
1605 }
1606 else if (obj->InheritsFrom("TRemoteObject")) {
1607 // special case for remote object: get real object class
1609 if (!strcmp(robj->GetClassName(), "TKey"))
1610 clname = robj->GetKeyClassName();
1611 else
1612 clname = robj->GetClassName();
1613 }
1614 else {
1615 objClass = obj->IsA();
1616 if (objClass)
1617 clname = objClass->GetName();
1618 }
1619 if (!clname) {
1620 clname = "Unknown";
1621 }
1622 const char *name = obj->GetIconName() ? obj->GetIconName() : clname;
1624 Bool_t xpm = xpm_magic == "/* ";
1625 const char *iconname = xpm ? obj->GetName() : name;
1626
1627 if (obj->IsA()->InheritsFrom("TGeoVolume")) {
1628 iconname = obj->GetIconName() ? obj->GetIconName() : obj->IsA()->GetName();
1629 }
1630
1631 if (fCachedPicName == iconname) {
1632 *pic = fCachedPic;
1633 return;
1634 }
1635 *pic = gClient->GetMimeTypeList()->GetIcon(iconname, kTRUE);
1636 if (!(*pic) && xpm) {
1637 if (im && im->SetImageBuffer((char**)&name, TImage::kXpm)) {
1638 im->Scale(im->GetWidth()/4, im->GetHeight()/4);
1639 *pic = gClient->GetPicturePool()->GetPicture(iconname, im->GetPixmap(),
1640 im->GetMask());
1641 }
1642 gClient->GetMimeTypeList()->AddType("[thumbnail]", iconname, iconname, iconname, "->Browse()");
1643 return;
1644 }
1645 if (fCachedPic && (fCachedPic != fFileIcon))
1647 if (*pic == 0) {
1648 if (!obj->IsFolder())
1649 *pic = fFileIcon;
1650 }
1651 fCachedPic = *pic;
1652 fCachedPicName = iconname;
1653}
1654
1655////////////////////////////////////////////////////////////////////////////////
1656/// Go to the directory "path" and open all the parent list tree items.
1657
1658void TGFileBrowser::GotoDir(const char *path)
1659{
1660 TGListTreeItem *item, *itm;
1661 ULong_t id;
1665 item = fRootDir;
1666 if (item == 0) return;
1667 fListTree->OpenItem(item);
1668 TObjArray *tokens = sPath.Tokenize("/");
1669 if (tokens->IsEmpty()) {
1670 fListTree->HighlightItem(item);
1671 DoubleClicked(item, 1);
1672 delete tokens;
1675 return;
1676 }
1677 // if the Browser.ExpandDirectories option is set to "no", then don't
1678 // expand the parent directory tree (for example on nfs)
1679 TString str = gEnv->GetValue("Browser.ExpandDirectories", "yes");
1680 str.ToLower();
1681 expand = (str == "yes") ? kTRUE : kFALSE;
1682 TString first = ((TObjString*)tokens->At(0))->GetName();
1683 // always prevent expanding the parent directory tree on afs
1684 if (first == "afs")
1685 expand = kFALSE;
1686 // check also AFS_SUPER_MAGIC, NFS_SUPER_MAGIC, FUSE_SUPER_MAGIC,
1687 // CIFS_MAGIC_NUMBER and SMB_SUPER_MAGIC
1688 if (!gSystem->GetFsInfo(path, (Long_t *)&id, &bsize, &blocks, &bfree))
1689 if (id == 0x5346414f || id == 0x6969 || id == 0x65735546 || id == 0xff534d42 || id == 0x517b)
1690 expand = kFALSE;
1691 if (first.Length() == 2 && first.EndsWith(":")) {
1692 TList *curvol = gSystem->GetVolumes("cur");
1693 if (curvol) {
1694 TNamed *drive = (TNamed *)curvol->At(0);
1695 if (first == drive->GetName()) {
1696 TString infos = drive->GetTitle();
1697 if (infos.Contains("Network"))
1698 expand = kFALSE;
1699 }
1700 delete curvol;
1701 }
1702 }
1703 for (Int_t i = 0; i < tokens->GetEntriesFast(); ++i) {
1704 TString token = ((TObjString*)tokens->At(i))->GetName();
1705 if (token.Length() == 2 && token.EndsWith(":")) {
1706 token.Append("\");
1708 if (itm) {
1709 item = itm;
1710 fListTree->OpenItem(item);
1711 if (expand)
1712 DoubleClicked(item, 1);
1713 }
1714 continue;
1715 }
1717 if (itm) {
1718 item = itm;
1719 fListTree->OpenItem(item);
1720 if (expand)
1721 DoubleClicked(item, 1);
1722 }
1723 else {
1724 itm = fListTree->AddItem(item, token);
1725 item = itm;
1726 fListTree->OpenItem(item);
1727 if (expand)
1728 DoubleClicked(item, 1);
1729 }
1730 }
1731 fListTree->HighlightItem(item);
1732 DoubleClicked(item, 1);
1733 delete tokens;
1736}
1737
1738////////////////////////////////////////////////////////////////////////////////
1739/// Slot used to switch to the tab containing the current pad/canvas (gPad)
1740/// used e.g. when drawing a histogram by double-clicking on its list tree
1741/// item in a root file.
1742
1744{
1745 if (fDblClick && fNewBrowser) {
1746 Int_t i;
1748 for (i=0;i<tabRight->GetNumberOfTabs();++i) {
1749 TGFrameElement *fe = 0;
1751 TGCompositeFrame *frame = tabRight->GetTabContainer(i);
1752 if (frame)
1753 fe = (TGFrameElement *)frame->GetList()->First();
1754 if (fe)
1755 embed = (TGCompositeFrame *)fe->fFrame;
1756 if (embed && embed->InheritsFrom("TRootCanvas")) {
1757 ULongptr_t canvas = gROOT->ProcessLine(TString::Format("((TRootCanvas *)0x%zx)->Canvas();",
1758 (size_t)embed));
1759 if ((canvas) && (canvas == (ULongptr_t)gPad ||
1760 canvas == (ULongptr_t)gPad->GetCanvas())) {
1761 tabRight->SetTab(i, kTRUE);
1762 break;
1763 }
1764 }
1765 }
1766 }
1767}
1768
1769////////////////////////////////////////////////////////////////////////////////
1770/// Open a dialog box asking for a string to be used as filter (regexp), and
1771/// add an entry in the map of filtered entries. Entering "*" or empty string
1772/// ("") will disable filtering on the current list tree item.
1773
1775{
1776 char filter[1024];
1777 if (!fListLevel)
1778 return;
1779 // initialize with previous (active) filter string
1780 snprintf(filter, sizeof(filter), "%s", fFilterStr.Data());
1781 new TGInputDialog(gClient->GetRoot(), this,
1782 "Enter filter expression:\n(empty string \"\" or \"*\" to remove filter)",
1783 filter, filter);
1784 // if user pressed cancel, update the status of the current list tree
1785 // item and return
1786 if ((filter[0] == 0) && (filter[1] == 0)) {
1788 return;
1789 }
1790 else if (((filter[0] == 0) && (filter[1] == 1)) || !strcmp(filter, "*")) {
1791 // if user entered "*" or "", just disable filtering for the current
1792 // list tree item
1795 } else {
1796 // if user entered a string different from "*", use it to create an
1797 // entry in the filter map
1798 fFilterStr = filter;
1800 // if there is already a filter on this item, delete it
1803 // insert a new entry for the current list tree item
1804 fFilteredItems.emplace(fListLevel, filter);
1805 }
1806 // finally update the list tree
1811}
1812
1813////////////////////////////////////////////////////////////////////////////////
1814/// A ROOT File has been selected in TGHtmlBrowser.
1815
1817{
1818 TGListTreeItem *itm = fListTree->FindChildByData(0, gROOT->GetListOfFiles());
1819 if (itm) {
1821 fListLevel = itm;
1824 BrowseObj(gROOT->GetListOfFiles());
1827 }
1828}
1829
1830////////////////////////////////////////////////////////////////////////////////
1831/// Toggle the sort mode and set the "sort button" state accordingly.
1832
1834{
1835 if (!fListLevel) return;
1837 TGListTreeItem *item = fListLevel;
1838 if (!fListLevel->GetFirstChild()) {
1839 item = fListLevel->GetParent();
1841 }
1842 if (!item)
1843 return;
1845 if (!is_sorted) {
1846 //alphabetical sorting
1847 fListTree->SortChildren(item);
1848 fSortedItems.push_back(item);
1850 } else {
1852 DoubleClicked(item, 1);
1853 fSortedItems.remove(item);
1855 gClient->NeedRedraw(fListTree, kTRUE);
1856 gClient->HandleInput();
1857 if (itemname.Length() > 0) {
1859 if (itm) {
1861 Clicked(itm, 1, 0, 0);
1862 itm->SetActive(kTRUE);
1865 }
1866 }
1867 }
1870}
1871
1872
@ kButton1Down
Definition Buttons.h:17
@ kWatch
Definition GuiTypes.h:375
@ kPointer
Definition GuiTypes.h:375
@ kHorizontalFrame
Definition GuiTypes.h:382
@ kButton3
Definition GuiTypes.h:214
#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
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
unsigned long ULong_t
Definition RtypesCore.h:55
long Long_t
Definition RtypesCore.h:54
unsigned long ULongptr_t
Definition RtypesCore.h:76
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
constexpr Ssiz_t kNPOS
Definition RtypesCore.h:117
long long Long64_t
Definition RtypesCore.h:69
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:374
R__EXTERN TApplication * gApplication
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
#define gDirectory
Definition TDirectory.h:384
R__EXTERN TEnv * gEnv
Definition TEnv.h:170
@ 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:110
#define gInterpreter
#define gROOT
Definition TROOT.h:406
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2489
char * StrDup(const char *str)
Duplicate the string str.
Definition TString.cxx:2557
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:572
@ kS_IXUSR
Definition TSystem.h:112
@ kS_IFREG
Definition TSystem.h:101
#define gPad
#define gVirtualX
Definition TVirtualX.h:337
#define snprintf
Definition civetweb.c:1540
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:3746
Bool_t IsTObject() const
Return kTRUE is the class inherits from TObject.
Definition TClass.cxx:6060
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:3069
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
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:445
virtual void SetStyle(UInt_t newstyle)
Set the button style (modern or classic).
Definition TGButton.cxx:271
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
Set button state.
Definition TGButton.cxx:235
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:1117
virtual TList * GetList() const
Definition TGFrame.h:312
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition TGFrame.cxx:967
void MapSubwindows() override
Map all sub windows that are part of the composite frame.
Definition TGFrame.cxx:1164
void SetCleanup(Int_t mode=kLocalCleanup) override
Turn on automatic cleanup of child frames in dtor.
Definition TGFrame.cxx:1072
virtual void ClearViewPort()
Clear view port and redraw full content.
Definition TGCanvas.cxx:891
System file browser, used as TRootBrowser plug-in.
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 TGHtmlBrowser.
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.
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:605
void MapWindow() override
map window
Definition TGFrame.h:206
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
TGListTreeItem * GetFirstChild() const
Definition TGListTree.h:61
void Rename(const char *new_name)
Definition TGListTree.h:73
virtual const char * GetText() const =0
TGListTreeItem * GetParent() const
Definition TGListTree.h:60
virtual void SetTipText(const char *)
Definition TGListTree.h:79
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:384
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:355
TGListTreeItem * GetFirstItem() const
Definition TGListTree.h:383
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
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
TGTabElement * GetTabTab(Int_t tabIndex) const
Return the tab element of tab with index tabIndex.
Definition TGTab.cxx:663
A TGTextEntry is a one line text input widget.
Definition TGTextEntry.h:24
Text string listbox entries.
Definition TGListBox.h:48
ROOT GUI Window base class.
Definition TGWindow.h:23
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:29
static TImage * Open(const char *file, EImageFileTypes type=kUnknown)
Open a specified image file.
Definition TImage.cxx:118
@ kXpm
Definition TImage.h:37
static TImage * Create()
Create an image.
Definition TImage.cxx:35
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
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
Collectable string class.
Definition TObjString.h:28
Mother of all ROOT objects.
Definition TObject.h:41
virtual Bool_t IsFolder() const
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects).
Definition TObject.cxx:573
virtual const char * GetName() const
Returns name of object.
Definition TObject.cxx:457
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:467
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:486
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:847
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition TObject.cxx:543
virtual const char * GetTitle() const
Returns title of object.
Definition TObject.cxx:501
virtual TClass * IsA() const
Definition TObject.h:247
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition TObject.cxx:293
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:869
Bool_t Disconnect(const char *signal=nullptr, void *receiver=nullptr, const char *slot=nullptr)
Disconnects signal of this object from slot of receiver.
Regular expression class.
Definition TRegexp.h:31
The TRemoteObject class provides protocol for browsing ROOT objects from a remote ROOT session.
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:139
Ssiz_t Length() const
Definition TString.h:417
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Definition TString.cxx:2244
const char * Data() const
Definition TString.h:376
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition TString.h:704
TString & Prepend(const char *cs)
Definition TString.h:673
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:2378
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:1472
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
Definition TSystem.cxx:1274
virtual char * ConcatFileName(const char *dir, const char *name)
Concatenate a directory and a file name. User must delete returned string.
Definition TSystem.cxx:1071
virtual Int_t Exec(const char *shellcmd)
Execute a command.
Definition TSystem.cxx:653
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:1398
virtual TList * GetVolumes(Option_t *) const
Definition TSystem.h:465
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:1296
virtual Bool_t ChangeDirectory(const char *path)
Change directory.
Definition TSystem.cxx:862
virtual const char * UnixPathName(const char *unixpathname)
Convert from a local pathname to a Unix pathname.
Definition TSystem.cxx:1063
virtual void Sleep(UInt_t milliSec)
Sleep milliSec milli seconds.
Definition TSystem.cxx:437
virtual const char * WorkingDirectory()
Return working directory.
Definition TSystem.cxx:871
virtual TString GetDirName(const char *pathname)
Return the directory name in pathname.
Definition TSystem.cxx:1032
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:258
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:406
Int_t fMode
Definition TSystem.h:135