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