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