Logo ROOT   6.16/01
Reference Guide
TGFileBrowser.cxx
Go to the documentation of this file.
1// @(#)root/gui:$Id$
2// Author: Bertrand Bellenot 26/09/2007
3
4/*************************************************************************
5 * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#include "TROOT.h"
13#include "TSystem.h"
14#include "TApplication.h"
15#include "TGClient.h"
16#include "TGListTree.h"
17#include "TGLayout.h"
18#include "TGComboBox.h"
19#include "TContextMenu.h"
20#include "TGTextEntry.h"
21#include "TGTab.h"
22#include "TGLabel.h"
23#include "TSystemDirectory.h"
24#include "TGMimeTypes.h"
25#include "TClass.h"
26#include "TQClass.h"
27#include "TDataMember.h"
28#include "TMethod.h"
29#include "TMethodArg.h"
30#include "TRealData.h"
31#include "TInterpreter.h"
32#include "TRegexp.h"
33#include "TEnv.h"
34#include "TImage.h"
35#include "TBrowser.h"
36#include "TRemoteObject.h"
37#include "TKey.h"
38#include "TKeyMapFile.h"
39#include "TVirtualPad.h"
40#include "Getline.h"
41#include <time.h>
42#include <string.h>
43#include <stdlib.h>
44
45#include "TGFileBrowser.h"
46#include "TRootBrowser.h"
47#include "TGInputDialog.h"
48
49#include "TVirtualPadEditor.h"
50#include "TGedEditor.h"
51#include "TBaseClass.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) oname = name;
354 else if (obj) oname = obj->GetName();
355 // check if the current item is filtered
357 if (it != fFilteredItems.end()) {
358 // check if the item (object) name match the filter
359 const char *filter = (const char *)(*it).second;
360 TRegexp re(filter, kTRUE);
361 // if not, simply return, so no item will be added
362 if (oname.Index(re) == kNPOS) return;
363 }
364 }
365 const TGPicture *pic=0;
366 if (obj && obj->InheritsFrom("TKey") && (obj->IsA() != TClass::Class()))
367 AddKey(fListLevel, obj, name);
368 else if (obj) {
369 GetObjPicture(&pic, obj);
370 if (!name) name = obj->GetName();
371 if (check > -1) {
374 pic, pic, kTRUE);
375 if ((pic != fFileIcon) && (pic != fCachedPic))
376 fClient->FreePicture(pic);
377 if (item) fListTree->CheckItem(item, (Bool_t)check);
378 fListTree->SetToolTipItem(item, FormatToolTip(obj, 32));
379 }
380 }
381 else {
382 // special case for remote object
383 Bool_t isRemote = kFALSE;
384 if (obj->InheritsFrom("TRemoteObject"))
385 isRemote = kTRUE;
386 else if (fListLevel) {
387 // check also if one of its parents is a remote object
389 while (top->GetParent()) {
390 TObject *tobj = (TObject *) top->GetUserData();
391 if (tobj && (tobj->InheritsFrom("TRemoteObject") ||
392 tobj->InheritsFrom("TApplicationRemote"))) {
393 isRemote = kTRUE;
394 break;
395 }
396 top = top->GetParent();
397 }
398 }
399 if (isRemote) {
400 TRemoteObject *robj = (TRemoteObject *)obj;
401 if (!strcmp(robj->GetClassName(), "TKey")) {
402 AddKey(fListLevel, obj, name);
403 }
404 else {
405 TString fname = name;
406 // add the remote object only if not already in the list
407 if (!fShowHidden && fname.BeginsWith("."))
408 return;
409 AddRemoteFile(obj);
410 }
411 }
412 else {
414 TGListTreeItem *item = fListTree->AddItem(fListLevel, name, obj, pic, pic);
415 if ((pic != fFileIcon) && (pic != fCachedPic))
416 fClient->FreePicture(pic);
417 if (item && obj && obj->InheritsFrom("TObject"))
418 item->SetDNDSource(kTRUE);
419 fListTree->SetToolTipItem(item, FormatToolTip(obj, 32));
420 }
421 }
422 }
423 }
424}
425
426////////////////////////////////////////////////////////////////////////////////
427/// Add remote file in list tree.
428
430{
431 Bool_t is_link;
432 Int_t type;
433 TString filename;
434 const TGPicture *spic;
435 TGPicture *pic;
436
437 FileStat_t sbuf;
438
439 type = 0;
440 is_link = kFALSE;
441
442 TRemoteObject *robj = (TRemoteObject *)obj;
443
444 robj->GetFileStat(&sbuf);
445 is_link = sbuf.fIsLink;
446 type = sbuf.fMode;
447 filename = robj->GetName();
448 if (R_ISDIR(type) || fFilter == 0 ||
449 (fFilter && filename.Index(*fFilter) != kNPOS)) {
450
451 GetFilePictures(&spic, type, is_link, filename);
452
453 pic = (TGPicture*)spic; pic->AddReference();
454
455 if ((!fListTree->FindChildByName(fListLevel, filename)) &&
457 fListTree->AddItem(fListLevel, filename, obj, pic, pic);
458 }
459}
460
461////////////////////////////////////////////////////////////////////////////////
462/// Browse object. This, in turn, will trigger the calling of
463/// TBrowser::Add() which will fill the IconBox and the tree.
464/// Emits signal "BrowseObj(TObject*)".
465
467{
468 if (fNewBrowser)
470 if (obj != gROOT) {
472 fListLevel = 0;
473 Add(obj);
476 if (obj->IsFolder())
480 }
481 }
482 if (fBrowser) obj->Browse(fBrowser);
483 if (obj == gROOT) {
484 TList *volumes = gSystem->GetVolumes("all");
485 TList *curvol = gSystem->GetVolumes("cur");
486 if (volumes && curvol) {
487 const char *curdrive;
488 TNamed *named = (TNamed *)curvol->At(0);
489 if (named)
490 curdrive = named->GetName();
491 else
492 curdrive = "C:";
493 TIter next(volumes);
494 TNamed *drive;
495 while ((drive = (TNamed *)next())) {
496 AddFSDirectory(TString::Format("%s\\", drive->GetName()), drive->GetTitle(),
497 (strcmp(drive->GetName(), curdrive) == 0) ?
498 "SetRootDir" : "Add");
499 }
500 delete volumes;
501 delete curvol;
502 }
503 else {
504 AddFSDirectory("/");
505 }
507 if (gROOT->GetListOfFiles() && !gROOT->GetListOfFiles()->IsEmpty())
508 Selected(0);
509 }
510}
511
512////////////////////////////////////////////////////////////////////////////////
513/// Emits signal when double clicking on icon.
514
516{
517 if (fNewBrowser)
518 fNewBrowser->Checked(obj, checked);
519}
520
521////////////////////////////////////////////////////////////////////////////////
522/// returns drawing option
523
525{
526 return fDrawOption->GetTextEntry()->GetText();
527}
528
529////////////////////////////////////////////////////////////////////////////////
530/// Determine the file picture for the given file type.
531
533 Bool_t is_link, const char *name)
534{
535 static TString cached_ext;
536 static const TGPicture *cached_spic = 0;
537 const char *ext = name ? strrchr(name, '.') : 0;
538 TString sname = name ? name : " ";
539 *pic = 0;
540
541 if (ext && cached_spic && (cached_ext == ext)) {
542 *pic = cached_spic;
543 return;
544 }
545
546 if (R_ISREG(file_type)) {
547 *pic = gClient->GetMimeTypeList()->GetIcon(name, kTRUE);
548
549 if (*pic) {
550 if (ext) {
551 cached_ext = ext;
552 cached_spic = *pic;
553 return;
554 }
555 }
556 } else {
557 *pic = 0;
558 }
559
560 if (*pic == 0) {
561 *pic = gClient->GetPicture("doc_t.xpm");
562
563 if (R_ISREG(file_type) && (file_type) & kS_IXUSR) {
564 *pic = gClient->GetPicture("app_t.xpm");
565 }
566 if (R_ISDIR(file_type)) {
567 *pic = gClient->GetPicture("folder_t.xpm");
568 }
569 if(sname.EndsWith(".root")) {
570 *pic = gClient->GetPicture("rootdb_t.xpm");
571 }
572
573 }
574 if (is_link) {
575 *pic = gClient->GetPicture("slink_t.xpm");
576 }
577
578 cached_spic = 0;
579 cached_ext = "";
580}
581
582////////////////////////////////////////////////////////////////////////////////
583/// Recursively remove object.
584
586{
587 TGListTreeItem *itm = 0, *item = 0;
588 if (obj->InheritsFrom("TFile")) {
589 itm = fListTree->FindChildByData(0, gROOT->GetListOfFiles());
590 if (itm)
591 item = fListTree->FindChildByData(itm, obj);
592 if (item) {
593 // if the item to be deleted has a filter,
594 // delete its entry in the map
595 if (CheckFiltered(item))
596 fFilteredItems.erase(item);
597 fListTree->DeleteItem(item);
598 }
599 itm = fRootDir ? fRootDir->GetFirstChild() : 0;
600 while (itm) {
601 item = fListTree->FindItemByObj(itm, obj);
602 if (item) {
604 item->SetUserData(0);
605 }
606 itm = itm->GetNextSibling();
607 }
608 }
609 if (!obj->InheritsFrom("TFile") && fRootDir) {
610 item = fListTree->FindItemByObj(fRootDir, obj);
611 // if the item to be deleted has a filter, delete its entry in the map
612 if (item && CheckFiltered(item))
613 fFilteredItems.erase(item);
615 }
616 //fListTree->ClearViewPort();
617}
618
619////////////////////////////////////////////////////////////////////////////////
620/// Refresh content of the list tree.
621
623{
624 TTimer::SingleShot(200, "TGFileBrowser", this, "Update()");
625 return; // disable refresh for the time being...
626 // coverity[unreachable]
627 TCursorSwitcher cursorSwitcher(this, fListTree);
628 static UInt_t prev = 0;
629 UInt_t curr = gROOT->GetListOfBrowsables()->GetSize();
630 if (!prev) prev = curr;
631
632 if (prev != curr) { // refresh gROOT
634 fListLevel = 0;
636 fListLevel = sav;
637 prev = curr;
638 }
639}
640
641////////////////////////////////////////////////////////////////////////////////
642/// Update content of the list tree.
643
645{
646 Long64_t size = 0;
647 Long_t id = 0, flags = 0, modtime = 0;
648 char path[1024];
650 if (!item) item = fRootDir;
651 if (!item) return;
652 //fListTree->DeleteChildren(item);
653 TGListTreeItem *curr = fListTree->GetSelected(); // GetCurrent() ??
654 if (curr) {
655 TObject *obj = (TObject *) curr->GetUserData();
656 if (obj && !obj->TestBit(kNotDeleted)) {
657 // if the item to be deleted has a filter,
658 // delete its entry in the map
659 if (CheckFiltered(curr))
660 fFilteredItems.erase(curr);
661 fListTree->DeleteItem(curr);
662 curr = 0;
663 obj = 0;
664 }
665 else if (obj && obj->TestBit(kNotDeleted) &&
666 obj->InheritsFrom("TObjString") && curr->GetParent()) {
668 if (strlen(path) > 1) {
669 TString dirpath = FullPathName(curr->GetParent());
670 Int_t res = gSystem->GetPathInfo(dirpath.Data(), &id, &size,
671 &flags, &modtime);
672 if ((res == 0) && (flags & 2)) {
673 TString fullpath = FullPathName(curr);
674 if (gSystem->AccessPathName(fullpath.Data())) {
675 // if the item to be deleted has a filter,
676 // delete its entry in the map
677 if (CheckFiltered(curr))
678 fFilteredItems.erase(curr);
679 fListTree->DeleteItem(curr);
680 curr = 0;
681 obj = 0;
682 }
683 }
684 }
685 }
686 }
687 TString actpath = FullPathName(item);
688 flags = id = size = modtime = 0;
689 if (gSystem->GetPathInfo(actpath.Data(), &id, &size, &flags, &modtime) == 0) {
690 Int_t isdir = (Int_t)flags & 2;
691
692 TString savdir = gSystem->WorkingDirectory();
693 if (isdir) {
694 TGListTreeItem *del = 0, *itm = item->GetFirstChild();
695 while (itm) {
696 fListTree->GetPathnameFromItem(itm, path);
697 if (strlen(path) > 1) {
698 TString recpath = FullPathName(itm);
699 if (gSystem->AccessPathName(recpath.Data())) {
700 del = itm;
701 itm = itm->GetNextSibling();
702 // if the item to be deleted has a filter,
703 // delete its entry in the map
704 if (CheckFiltered(del))
705 fFilteredItems.erase(del);
706 fListTree->DeleteItem(del);
707 }
708 }
709 if (del)
710 del = 0;
711 else
712 itm = itm->GetNextSibling();
713 }
714 }
715 }
717 DoubleClicked(item, 1);
718 fListLevel = sav;
720}
721
722/**************************************************************************/
723// Other
724/**************************************************************************/
725
726////////////////////////////////////////////////////////////////////////////////
727/// Add file system directory in the list tree.
728
729void TGFileBrowser::AddFSDirectory(const char *entry, const char *path,
730 Option_t *opt)
731{
732 TGListTreeItem *item = 0;
733 if ((opt == 0) || (!opt[0])) {
734 if (fRootDir == 0 && !fListTree->FindChildByName(0, rootdir))
735 item = fRootDir = fListTree->AddItem(0, rootdir);
736 return;
737 }
738 if (strstr(opt, "SetRootDir")) {
739 if (!fListTree->FindChildByName(0, entry))
740 item = fRootDir = fListTree->AddItem(0, entry);
741 }
742 else if (strstr(opt, "Add")) {
743 // MT: i give up! wanted to place entries for selected
744 // directories like home, pwd, alice-macros.
745 // TGListTreeItem *lti = fListTree->AddItem(0, entry);
746 //
747 if (!fListTree->FindChildByName(0, entry))
748 item = fListTree->AddItem(0, entry);
749 }
750 if (item && path) {
751 TString infos = path;
752 item->SetTipText(path);
753 TGPicture *pic = 0;
754 if (infos.Contains("Removable"))
755 pic = (TGPicture *)gClient->GetPicture("fdisk_t.xpm");
756 else if (infos.Contains("Local"))
757 pic = (TGPicture *)gClient->GetPicture("hdisk_t.xpm");
758 else if (infos.Contains("CD"))
759 pic = (TGPicture *)gClient->GetPicture("cdrom_t.xpm");
760 else if (infos.Contains("Network"))
761 pic = (TGPicture *)gClient->GetPicture("netdisk_t.xpm");
762 if (pic)
763 item->SetPictures(pic, pic);
764 }
765}
766
767////////////////////////////////////////////////////////////////////////////////
768/// display content of ROOT file
769
771{
772 // Int_t from, to;
773 TGListTreeItem *where;
774 static TGListTreeItem *olditem = itm;
775 static TGListTreeItem *item = itm;
776 const TGPicture *pic;
777
778 if (itm == 0) return;
779
780 if ((fCnt == 0) || (olditem != itm)) {
781 olditem = item = itm;
782 }
783 if (!name) name = obj->GetName();
784 if (fNKeys > fGroupSize) {
785 where = itm->GetFirstChild();
786 while (where) {
787 if (fListTree->FindItemByObj(where, obj))
788 return;
789 where = where->GetNextSibling();
790 }
791 }
792 if ((fNKeys > fGroupSize) && (fCnt % fGroupSize == 0)) {
793 if (item != itm) {
794 TString newname = TString::Format("%s-%s", item->GetText(), name);
795 item->Rename(newname.Data());
796 }
797 item = fListTree->AddItem(itm, name);
798 item->SetDNDSource(kTRUE);
799 }
800 if ((fCnt > fGroupSize) && (fCnt >= fNKeys-1)) {
801 TString newname = TString::Format("%s-%s", item->GetText(), name);
802 item->Rename(newname.Data());
803 }
804 GetObjPicture(&pic, obj);
805 if (!fListTree->FindChildByName(item, name)) {
806 TGListTreeItem *it = fListTree->AddItem(item, name, obj, pic, pic);
807 if (pic && (pic != fFileIcon) && (pic != fCachedPic))
808 fClient->FreePicture(pic);
809 it->SetDNDSource(kTRUE);
810 it->SetTipText(FormatToolTip(obj, 32));
811 }
812 fCnt++;
813}
814
815////////////////////////////////////////////////////////////////////////////////
816/// Apply filter selected in combo box to the file tree view.
817
819{
820 // Long64_t size;
821 // Long_t fid, flags, modtime;
822
823 if (fFilter) delete fFilter;
824 fFilter = 0;
825 if ((id > 1) && (id < 5))
826 fFilter = new TRegexp(filters[id], kTRUE);
827 else if ((id < 0) || (id > 4)) {
829 if (lbe) {
830 const char *text = lbe->GetTitle();
831 fFilter = new TRegexp(text, kTRUE);
832 }
833 }
835 if (!item)
836 item = fRootDir;
837 if (!item) return;
839 DoubleClicked(item, 1);
840 //fListTree->AdjustPosition(item);
842}
843
844////////////////////////////////////////////////////////////////////////////////
845/// Make object associated with item the current directory.
846
848{
849 if (item) {
850 TGListTreeItem *i = item;
851 while (i) {
852 TObject *obj = (TObject*) i->GetUserData();
853 if ((obj) && obj->InheritsFrom("TDirectory")) {
854 ((TDirectory *)obj)->cd();
855 break;
856 }
857 i = i->GetParent();
858 }
859 }
860}
861
862////////////////////////////////////////////////////////////////////////////////
863/// Check if the current list tree item points to a remote object.
864
866{
867 if (!item) return;
868 TObject *obj = (TObject *) item->GetUserData();
869 if (obj) {
870 if (obj->InheritsFrom("TApplicationRemote")) {
871 if (!gApplication->GetAppRemote()) {
872 gROOT->ProcessLine(TString::Format(".R %s", item->GetText()));
873 if (gApplication->GetAppRemote()) {
874 Getlinem(kInit, TString::Format("\n%s:root [0]",
876 }
877 }
878 }
879 if (item->GetParent() && item->GetParent()->GetUserData() &&
880 ((TObject *)item->GetParent()->GetUserData())->InheritsFrom("TApplicationRemote")) {
881 // switch to remote session
882 if (!gApplication->GetAppRemote()) {
883 gROOT->ProcessLine(TString::Format(".R %s", item->GetParent()->GetText()));
884 if (gApplication->GetAppRemote()) {
885 Getlinem(kInit, TString::Format("\n%s:root [0]",
887 }
888 }
889 else if (!strcmp(item->GetText(), "ROOT Files")) {
890 // update list of files opened in the remote session
892 gApplication->ProcessLine("((TApplicationServer *)gApplication)->BrowseFile(0);");
893 }
894 }
895 else {
896 // check if the listtree item is from a local session or
897 // from a remote session, then switch to the session it belongs to
898 TGListTreeItem *top = item;
899 while (top->GetParent()) {
900 top = top->GetParent();
901 }
902 TObject *topobj = (TObject *) top->GetUserData();
903 if (topobj && topobj->InheritsFrom("TApplicationRemote")) {
904 // it belongs to a remote session
905 if (!gApplication->GetAppRemote()) {
906 // switch to remote session if not already in
907 gROOT->ProcessLine(TString::Format(".R %s", top->GetText()));
908 if (gApplication->GetAppRemote()) {
909 Getlinem(kInit, TString::Format("\n%s:root [0]",
911 }
912 }
913 }
914 else if (gApplication->GetAppRemote()) {
915 // switch back to local session if not already in
917 Getlinem(kInit, "\nroot [0]");
918 }
919 }
920 }
921 else if (gApplication->GetAppRemote()) {
922 // switch back to local session if not already in
924 Getlinem(kInit, "\nroot [0]");
925 }
926}
927
928////////////////////////////////////////////////////////////////////////////////
929/// Check if there is a filter active on the children of the list tree item.
930/// If the but argument is true, the "filter" button state is set accordingly,
931/// and its tooltip will show the filter used.
932
934{
935 Bool_t found = kFALSE;
936 TString filter;
937 // if there is no filter (the map is empty) then just return
938 if (fFilteredItems.empty())
939 return kFALSE;
940 mFiltered_i it = fFilteredItems.find(item);
941 if (it != fFilteredItems.end()) {
942 // if the item is in the map, take the filter regexp string
943 filter = (const char *)(*it).second;
944 fFilterStr = filter;
945 found = kTRUE;
946 }
947 if (but) {
948 // if the but argument is true, change the button state
949 // to reflect the filtering state
951 if (found) {
952 // format the tooltip to display the regexp used as filter
953 filter.Prepend("Showing only \'");
954 filter += "\'";
956 }
957 else {
958 // reset the tooltip text
959 fFilterButton->SetToolTipText("Filter Content...");
960 }
961 }
962 return found;
963}
964
965////////////////////////////////////////////////////////////////////////////////
966/// Check if the list tree item children are alphabetically sorted.
967/// If the but argument is true, the "sort" button state is set accordingly.
968
970{
971 Bool_t found = kFALSE;
972 TGListTreeItem *i, *itm;
973 if (item->GetFirstChild())
974 itm = item;
975 else
976 itm = item->GetParent();
977 for (sLTI_i p=fSortedItems.begin(); p!=fSortedItems.end(); ++p) {
978 i = (TGListTreeItem *)(*p);
979 if (itm == i) {
980 found = kTRUE;
981 break;
982 }
983 }
984 if (but) fSortButton->SetState(found ? kButtonEngaged : kButtonUp);
985 return found;
986}
987
988////////////////////////////////////////////////////////////////////////////////
989/// Process mouse clicks in TGListTree.
990
992{
993 char path[1024];
994 Long64_t size = 0;
995 Long_t id = 0, flags = 0, modtime = 0;
996 fListLevel = item;
997 if (!item) return;
998 CheckSorted(item, kTRUE);
999 CheckFiltered(item, kTRUE);
1000 CheckRemote(item);
1001 TObject *selected = 0;
1002 TString fullpath = FullPathName(item);
1003 TObject *obj = (TObject *) item->GetUserData();
1004 if (obj && (!obj->InheritsFrom("TObjString") ||
1005 gSystem->AccessPathName(fullpath.Data()))) {
1006 if (obj->InheritsFrom("TKey") && (obj->IsA() != TClass::Class())) {
1007 Chdir(item);
1008 const char *clname = ((TKey *)obj)->GetClassName();
1009 if (clname && strcmp(clname, "TGeoManager")) {
1010 TClass *cl = TClass::GetClass(clname);
1011 TString name = ((TKey *)obj)->GetName();
1012 name += ";";
1013 name += ((TKey *)obj)->GetCycle();
1014 void *add = gDirectory->FindObjectAny((char *) name.Data());
1015 if (add && cl->IsTObject()) {
1016 obj = (TObject*)add;
1017 // don't change the user data, to avoid deletion of the
1018 // list tree item by RecursiveRemove()
1019 // it is better to read the object each time anyway,
1020 // as it may have changed in the file
1021 if (obj->InheritsFrom("TDirectory") || obj->InheritsFrom("TList"))
1022 item->SetUserData(obj);
1023 }
1024 }
1025 }
1026 if (obj->InheritsFrom("TLeaf") ||
1027 obj->InheritsFrom("TBranch")) {
1028 Chdir(item);
1029 }
1030 if (btn == kButton3)
1031 fContextMenu->Popup(x, y, obj, fBrowser);
1032 selected = obj;
1033 }
1034 else {
1035 fListTree->GetPathnameFromItem(item, path);
1036 if (strlen(path) > 3) {
1037 if (gSystem->GetPathInfo(fullpath.Data(), &id, &size, &flags, &modtime) == 0) {
1038 if (flags & 2) {
1039 fCurrentDir = item;
1040 if (btn == kButton3) {
1041 if (fDir) delete fDir;
1042 fDir = new TSystemDirectory(item->GetText(), fullpath.Data());
1044 }
1045 }
1046 else {
1047 fCurrentDir = item->GetParent();
1048 if (btn == kButton3) {
1049 if (fFile) delete fFile;
1050 fFile = new TSystemFile(item->GetText(), fullpath.Data());
1052 }
1053 }
1054 }
1055 }
1056 }
1058 if (selected && (selected->IsA() != TClass::Class())) {
1059 if (selected->InheritsFrom("TLeaf"))
1060 selected = (TObject *)gROOT->ProcessLine(TString::Format("((TLeaf *)0x%lx)->GetBranch()->GetTree();", (ULong_t)selected));
1061 if (selected->InheritsFrom("TBranch"))
1062 selected = (TObject *)gROOT->ProcessLine(TString::Format("((TBranch *)0x%lx)->GetTree();", (ULong_t)selected));
1063 if (selected->InheritsFrom("TTree")) {
1064 // if a tree not attached to any directory (e.g. in a TFolder)
1065 // then attach it to the current directory (gDirectory)
1066 TDirectory *tdir = (TDirectory *)gROOT->ProcessLine(TString::Format("((TTree *)0x%lx)->GetDirectory();", (ULong_t)selected));
1067 if (!tdir) {
1068 gROOT->ProcessLine(TString::Format("((TTree *)0x%lx)->SetDirectory(gDirectory);", (ULong_t)selected));
1069 }
1070 }
1071 }
1072 if (selected && gPad && IsObjectEditable(selected->IsA())) {
1074 if (ved) {
1075 TGedEditor *ged = (TGedEditor *)ved;
1076 ged->SetModel(gPad, selected, kButton1Down);
1077 }
1078 }
1079}
1080
1081////////////////////////////////////////////////////////////////////////////////
1082/// returns an absolute path
1083
1085{
1086 TGListTreeItem *parent, *itm = item;
1087 TString dirname = itm->GetText();
1088
1089 while ((parent=itm->GetParent())) {
1090 char *s = gSystem->ConcatFileName(parent->GetText(), dirname);
1091 dirname = s;
1092 delete [] s;
1093 itm = parent;
1094 }
1095 dirname = gSystem->ExpandPathName(dirname.Data());
1096#ifdef R__WIN32
1097 // only handle .lnk files on Windows
1098 while (dirname.Contains(".lnk")) {
1099 Ssiz_t idx = dirname.Index(".lnk") + 4;
1100 TString resolved = dirname;
1101 resolved.Remove(idx);
1102 resolved = gSystem->ExpandPathName(resolved.Data());
1103 dirname = resolved.Append(dirname.Remove(0, idx));
1104 }
1105#endif
1106 return dirname;
1107}
1108
1109////////////////////////////////////////////////////////////////////////////////
1110/// returns the directory path
1111
1113{
1114 TString dirname;
1115 TString fullpath = FullPathName(item);
1116
1117#ifdef WIN32
1118 char winDrive[256];
1119 char winDir[256];
1120 char winName[256];
1121 char winExt[256];
1122 _splitpath(fullpath.Data(), winDrive, winDir, winName, winExt);
1123 dirname = TString::Format("%s%s", winDrive, winDir);
1124#else
1125 dirname = gSystem->DirName(fullpath);
1126#endif
1127 return dirname;
1128}
1129
1130////////////////////////////////////////////////////////////////////////////////
1131/// Returns true if given a text file
1132/// Uses the specification given on p86 of the Camel book
1133/// - Text files have no NULLs in the first block
1134/// - and less than 30% of characters with high bit set
1135
1136static Bool_t IsTextFile(const char *candidate)
1137{
1138 Int_t i;
1139 Int_t nchars;
1140 Int_t weirdcount = 0;
1141 char buffer[512];
1142 FILE *infile;
1143 FileStat_t buf;
1144
1145 if (gSystem->GetPathInfo(candidate, buf) || !(buf.fMode & kS_IFREG))
1146 return kFALSE;
1147
1148 infile = fopen(candidate, "r");
1149 if (infile) {
1150 // Read a block
1151 nchars = fread(buffer, 1, 512, infile);
1152 fclose (infile);
1153 // Examine the block
1154 for (i = 0; i < nchars; i++) {
1155 if (buffer[i] & 128)
1156 weirdcount++;
1157 if (buffer[i] == '\0')
1158 // No NULLs in text files
1159 return kFALSE;
1160 }
1161 if ((nchars > 0) && ((weirdcount * 100 / nchars) > 30))
1162 return kFALSE;
1163 } else {
1164 // Couldn't open it. Not a text file then
1165 return kFALSE;
1166 }
1167 return kTRUE;
1168}
1169
1170////////////////////////////////////////////////////////////////////////////////
1171/// Create a symlink (shortcut on Windows) icon by merging the picture
1172/// passed as argument and the slink_t.xpm icon (small arrow)
1173
1174static const TGPicture *MakeLinkPic(const TGPicture *pic)
1175{
1176 const TGPicture *merged;
1177 TImage *img1, *img2;
1178 if (pic) {
1179 img1 = TImage::Create();
1180 if (img1 == 0) return pic;
1181 img1->SetImage(((const TGPicture *)pic)->GetPicture(),
1182 ((const TGPicture *)pic)->GetMask());
1183 img2 = TImage::Open("slink_t.xpm");
1184 if (img2) img1->Merge(img2);
1185 TString lnk_name = ((const TGPicture *)pic)->GetName();
1186 lnk_name.Prepend("lnk_");
1187 merged = gClient->GetPicturePool()->GetPicture(lnk_name.Data(),
1188 img1->GetPixmap(), img1->GetMask());
1189 if (img2) delete img2;
1190 delete img1;
1191 return merged;
1192 }
1193 return pic;
1194}
1195
1196////////////////////////////////////////////////////////////////////////////////
1197/// Process double clicks in TGListTree.
1198
1200{
1201 const TGPicture *pic=0;
1202 TString dirname = DirName(item);
1203 TString fullpath = FullPathName(item);
1204 TGListTreeItem *itm;
1205 FileStat_t sbuf;
1206 Long64_t size;
1207 Long_t id, flags, modtime;
1208 char action[512];
1209 TString act;
1210 Bool_t is_link = kFALSE;
1211 if (!gSystem->GetPathInfo(item->GetText(), sbuf) && sbuf.fIsLink) {
1212 is_link = kTRUE;
1213 fullpath = gSystem->ExpandPathName(item->GetText());
1214 }
1215
1216 if (fNewBrowser)
1218 TCursorSwitcher switcher(this, fListTree);
1219 fListLevel = item;
1220 CheckSorted(item, kTRUE);
1221 CheckFiltered(item, kTRUE);
1222 CheckRemote(item);
1223 TGListTreeItem *pitem = item->GetParent();
1224 TObject *obj = (TObject *) item->GetUserData();
1225 if (obj && !obj->InheritsFrom("TSystemFile")) {
1226 TString ext = obj->GetName();
1227 if (obj->InheritsFrom("TDirectory") && (obj->IsA() != TClass::Class())) {
1228 if (((TDirectory *)obj)->GetListOfKeys())
1229 fNKeys = ((TDirectory *)obj)->GetListOfKeys()->GetEntries();
1230 else
1231 fNKeys = 0;
1232 }
1233 else if (obj->InheritsFrom("TKey") && (obj->IsA() != TClass::Class())) {
1234 Chdir(item);
1235 const char *clname = ((TKey *)obj)->GetClassName();
1236 if (clname) {
1237 TClass *cl = TClass::GetClass(clname);
1238 TString name = ((TKey *)obj)->GetName();
1239 name += ";";
1240 name += ((TKey *)obj)->GetCycle();
1241 void *add = gDirectory->FindObjectAny((char *) name.Data());
1242 if (add && cl->IsTObject()) {
1243 obj = (TObject*)add;
1244 // don't change the user data, to avoid deletion of the
1245 // list tree item by RecursiveRemove()
1246 // it is better to read the object each time anyway,
1247 // as it may have changed in the file
1248 if (obj->InheritsFrom("TDirectory") || obj->InheritsFrom("TList"))
1249 item->SetUserData(obj);
1250 }
1251 }
1252 }
1253 else if (obj->InheritsFrom("TLeaf") || obj->InheritsFrom("TBranch")) {
1254 Chdir(item);
1255 }
1256 else if (obj->InheritsFrom("TRemoteObject")) {
1257 // the real object is a TKey
1258 TRemoteObject *robj = (TRemoteObject *)obj;
1259 if (!strcmp(robj->GetClassName(), "TKey")) {
1260 TGListTreeItem *parent = item;
1261 TRemoteObject *probj = (TRemoteObject *)parent->GetUserData();
1262 // find the TFile remote object containing the TKey
1263 while ( probj && strcmp(probj->GetClassName(), "TFile")) {
1264 parent = parent->GetParent();
1265 probj = (TRemoteObject *)parent->GetUserData();
1266 }
1267 if (probj && !strcmp(probj->GetClassName(), "TFile")) {
1268 // remotely browse file (remotely call TFile::cd())
1271 TString::Format("((TApplicationServer *)gApplication)->BrowseFile(\"%s\");",
1272 probj->GetName()));
1273 gSystem->Sleep(250);
1274 }
1275 }
1276 if (gClient->GetMimeTypeList()->GetAction(obj->GetName(), action)) {
1277 act = action;
1278 act.ReplaceAll("%s", obj->GetName());
1279 if ((act[0] != '!') && (strcmp(pitem->GetText(), "ROOT Files"))) {
1280 // special case for remote object: remote process
1283 }
1284 }
1285 if ((ext.EndsWith(".root")) && (strcmp(pitem->GetText(), "ROOT Files"))) {
1287 gApplication->ProcessLine("((TApplicationServer *)gApplication)->BrowseFile(0);");
1288 }
1289 }
1290 if (!obj->InheritsFrom("TObjString") ||
1291 gSystem->AccessPathName(fullpath.Data())) {
1293 fDblClick = kTRUE;
1294 if (gClient->GetMimeTypeList()->GetAction(obj->IsA()->GetName(), action)) {
1295 act = action;
1296 if (fBrowser && act.Contains("->Browse()")) obj->Browse(fBrowser);
1297 else if (act.Contains("->Draw()")) obj->Draw(GetDrawOption());
1298 else {
1299 if (act.Contains("%s")) act.ReplaceAll("%s", obj->GetName());
1300 else act.Prepend(obj->GetName());
1301 gInterpreter->SaveGlobalsContext();
1302 if (act[0] == '!') {
1303 act.Remove(0, 1);
1304 gSystem->Exec(act.Data());
1305 } else {
1306 // special case for remote object: remote process
1307 if (obj->InheritsFrom("TRemoteObject"))
1310 }
1311 }
1312 }
1313 else if (obj->InheritsFrom("TCanvas") && fNewBrowser &&
1316 // avoid potential crash when drawing a canvas with the same name
1317 // than a canvas already embedded in one of the browser's tab
1318 obj->DrawClone();
1319 }
1320 else if (fBrowser && !obj->InheritsFrom("TFormula"))
1321 obj->Browse(fBrowser);
1322 fDblClick = kFALSE;
1323 fNKeys = 0;
1324 fCnt = 0;
1326 if (gPad) gPad->Update();
1327 return;
1328 }
1329 }
1330 flags = id = size = modtime = 0;
1331 if (gSystem->GetPathInfo(fullpath.Data(), &id, &size, &flags, &modtime) != 0)
1332 return;
1333 Int_t isdir = (Int_t)flags & 2;
1334
1335 TString savdir = gSystem->WorkingDirectory();
1336 if (isdir) {
1337 fCurrentDir = item;
1338 //fListTree->DeleteChildren(item);
1339 TSystemDirectory dir(item->GetText(),FullPathName(item));
1340 TList *files = dir.GetListOfFiles();
1341 if (files) {
1342 files->Sort();
1343 TIter next(files);
1345 TString fname, pname;
1346 // directories first
1347 //fListTree->DeleteChildren(item);
1348 while ((file=(TSystemFile*)next())) {
1349 fname = file->GetName();
1350 if (file->IsDirectory()) {
1351 if (!fShowHidden && fname.BeginsWith("."))
1352 continue;
1353 if ((fname!="..") && (fname!=".")) { // skip it
1354 if (!fListTree->FindChildByName(item, fname)) {
1355 itm = fListTree->AddItem(item, fname);
1356 if (!gSystem->GetPathInfo(fname, sbuf) &&
1357 sbuf.fIsLink) {
1358 // change the pictures if it is a symlink
1359 // (shortcut on Windows)
1360 const TGPicture *opened = 0, *l_opened = 0;
1361 const TGPicture *closed = 0, *l_closed = 0;
1362 opened = fClient->GetPicture("ofolder_t.xpm");
1363 if (opened) l_opened = MakeLinkPic(opened);
1364 closed = fClient->GetPicture("folder_t.xpm");
1365 if (closed) l_closed = MakeLinkPic(closed);
1366 if (l_opened && l_closed)
1367 itm->SetPictures(l_opened, l_closed);
1368 if (opened) fClient->FreePicture(opened);
1369 if (closed) fClient->FreePicture(closed);
1370 if (l_opened) fClient->FreePicture(l_opened);
1371 if (l_closed) fClient->FreePicture(l_closed);
1372 }
1373 // uncomment line below to set directories as
1374 // DND targets
1375 //itm->SetDNDTarget(kTRUE);
1376 itm->SetUserData(0);
1377 }
1378 }
1379 }
1380 }
1381 // then files...
1382 TIter nextf(files);
1383 while ((file=(TSystemFile*)nextf())) {
1384 fname = pname = file->GetName();
1385 if (!file->IsDirectory() && (fFilter == 0 ||
1386 (fFilter && fname.Index(*fFilter) != kNPOS))) {
1387 if (!fShowHidden && fname.BeginsWith("."))
1388 continue;
1389 size = modtime = 0;
1390 if (gSystem->GetPathInfo(fname, sbuf) == 0) {
1391 size = sbuf.fSize;
1392 modtime = sbuf.fMtime;
1393 }
1394 if (sbuf.fIsLink && pname.EndsWith(".lnk"))
1395 pname.Remove(pname.Length()-4);
1396 pic = gClient->GetMimeTypeList()->GetIcon(pname, kTRUE);
1397 if (!pic)
1398 pic = fFileIcon;
1399 if (sbuf.fIsLink)
1400 pic = MakeLinkPic(pic);
1401 if (!fListTree->FindChildByName(item, fname)) {
1402 itm = fListTree->AddItem(item, fname, pic, pic);
1403 if (pic != fFileIcon)
1404 fClient->FreePicture(pic);
1405 if (sbuf.fIsLink)
1406 itm->SetUserData(new TObjString(TString::Format("file://%s\r\n",
1407 gSystem->ExpandPathName(file->GetName()))), kTRUE);
1408 else
1409 itm->SetUserData(new TObjString(TString::Format("file://%s/%s\r\n",
1410 gSystem->UnixPathName(file->GetTitle()),
1411 file->GetName())), kTRUE);
1412 itm->SetDNDSource(kTRUE);
1413 if (size && modtime) {
1414 char *tiptext = FormatFileInfo(fname.Data(), size, modtime);
1415 itm->SetTipText(tiptext);
1416 delete [] tiptext;
1417 }
1418 }
1419 }
1420 }
1421 files->Delete();
1422 delete files;
1423 }
1424 }
1425 else {
1426 TString lnkname = item->GetText();
1427 if (is_link && lnkname.EndsWith(".lnk"))
1428 lnkname.Remove(lnkname.Length()-4);
1429 fCurrentDir = item->GetParent();
1430 TSystemFile f(lnkname.Data(), fullpath.Data());
1431 TString fname = f.GetName();
1432 if (fname.EndsWith(".root")) {
1433 TDirectory *rfile = 0;
1434 gSystem->ChangeDirectory(dirname.Data());
1435 rfile = (TDirectory *)gROOT->GetListOfFiles()->FindObject(obj);
1436 if (!rfile) {
1437 rfile = (TDirectory *)gROOT->ProcessLine(TString::Format("new TFile(\"%s\")",fname.Data()));
1438 }
1439 if (rfile) {
1440 // replace actual user data (TObjString) by the TDirectory...
1441 if (item->GetUserData()) {
1442 // first delete the data to avoid memory leaks
1443 TObject *obj2 = static_cast<TObject *>(item->GetUserData());
1444 // only delete TObjString as they are the only objects
1445 // created who have to be deleted
1446 TObjString *ostr = dynamic_cast<TObjString *>(obj2);
1447 if (ostr) delete ostr;
1448 }
1449 item->SetUserData(rfile);
1450 fNKeys = rfile->GetListOfKeys()->GetEntries();
1451 fCnt = 0;
1452 if (fBrowser) rfile->Browse(fBrowser);
1453 fNKeys = 0;
1454 fCnt = 0;
1455 }
1456 }
1457 else if (fname.EndsWith(".png")) {
1458 gSystem->ChangeDirectory(dirname.Data());
1460 gSystem->ChangeDirectory(savdir.Data());
1461 }
1462 else if (IsTextFile(fullpath.Data())) {
1463 gSystem->ChangeDirectory(dirname.Data());
1464 if (fNewBrowser) {
1465 TGFrameElement *fe = 0;
1466 TGTab *tabRight = fNewBrowser->GetTabRight();
1467 TGCompositeFrame *frame = tabRight->GetCurrentContainer();
1468 if (frame)
1469 fe = (TGFrameElement *)frame->GetList()->First();
1470 if (fe) {
1472 TString fullname = f.GetTitle();
1473 fullname.ReplaceAll("\\", "\\\\");
1474 if (embed->InheritsFrom("TGTextEditor")) {
1475 gROOT->ProcessLine(TString::Format("((TGTextEditor *)0x%lx)->LoadFile(\"%s\");",
1476 (ULong_t)embed, fullname.Data()));
1477 }
1478 else if (embed->InheritsFrom("TGTextEdit")) {
1479 gROOT->ProcessLine(TString::Format("((TGTextEdit *)0x%lx)->LoadFile(\"%s\");",
1480 (ULong_t)embed, fullname.Data()));
1481 }
1482 else {
1484 }
1485 }
1486 else {
1488 }
1489 }
1490 gSystem->ChangeDirectory(savdir.Data());
1491 }
1492 else {
1493 gSystem->ChangeDirectory(dirname.Data());
1495 gSystem->ChangeDirectory(savdir.Data());
1496 }
1497 }
1498 //gSystem->ChangeDirectory(savdir.Data());
1500}
1501
1502////////////////////////////////////////////////////////////////////////////////
1503/// Execute default action for selected object (action is specified
1504/// in the $HOME/.root.mimes or $ROOTSYS/etc/root.mimes file.
1505
1507{
1508 char action[512];
1509 TString act;
1510 TString ext = obj->GetName();
1512
1513 if (gClient->GetMimeTypeList()->GetAction(obj->GetName(), action)) {
1514 act = action;
1515 act.ReplaceAll("%s", obj->GetName());
1516 gInterpreter->SaveGlobalsContext();
1517
1518 if (act[0] == '!') {
1519 act.Remove(0, 1);
1520 gSystem->Exec(act.Data());
1521 return 0;
1522 } else {
1523 // special case for remote object: remote process
1524 if (obj->InheritsFrom("TRemoteObject"))
1526
1527 const Long_t res = gApplication->ProcessLine(act.Data());
1528#ifdef R__HAS_COCOA
1529 if (act.Contains(".x") || act.Contains(".X")) {
1530 if (gPad) gPad->Update();
1531 }
1532#endif
1533 return res;
1534 }
1535 }
1536 return 0;
1537}
1538
1539////////////////////////////////////////////////////////////////////////////////
1540/// Format file information to be displayed in the tooltip.
1541
1542char *TGFileBrowser::FormatFileInfo(const char *fname, Long64_t size, Long_t modtime)
1543{
1544 Long64_t fsize, bsize;
1545 TString infos = fname;
1546 infos += "\n";
1547
1548 fsize = bsize = size;
1549 if (fsize > 1024) {
1550 fsize /= 1024;
1551 if (fsize > 1024) {
1552 // 3.7MB is more informative than just 3MB
1553 infos += TString::Format("Size: %lld.%lldM", fsize/1024, (fsize%1024)/103);
1554 } else {
1555 infos += TString::Format("Size: %lld.%lldK", bsize/1024, (bsize%1024)/103);
1556 }
1557 } else {
1558 infos += TString::Format("Size: %lld", bsize);
1559 }
1560 struct tm *newtime;
1561 time_t loctime = (time_t) modtime;
1562 newtime = localtime(&loctime);
1563 if (newtime) {
1564 infos += "\n";
1565 infos += TString::Format("%d-%02d-%02d %02d:%02d",
1566 newtime->tm_year + 1900,
1567 newtime->tm_mon+1, newtime->tm_mday,
1568 newtime->tm_hour, newtime->tm_min);
1569 }
1570 return StrDup(infos.Data());
1571}
1572
1573////////////////////////////////////////////////////////////////////////////////
1574/// Retrieve icons associated with class "name". Association is made
1575/// via the user's ~/.root.mimes file or via $ROOTSYS/etc/root.mimes.
1576
1578{
1579 const char *clname = 0;
1580 TClass *objClass = 0;
1581 static TImage *im = 0;
1582 if (!im) {
1583 im = TImage::Create();
1584 }
1585
1586 if (obj->IsA() == TClass::Class()) {
1587 objClass = obj->IsA();
1588 if (objClass)
1589 clname = objClass->GetName();
1590 }
1591 else if (obj->InheritsFrom("TKey")) {
1592 clname = ((TKey *)obj)->GetClassName();
1593 }
1594 else if (obj->InheritsFrom("TKeyMapFile")) {
1595 clname = ((TKeyMapFile *)obj)->GetTitle();
1596 }
1597 else if (obj->InheritsFrom("TRemoteObject")) {
1598 // special case for remote object: get real object class
1599 TRemoteObject *robj = (TRemoteObject *)obj;
1600 if (!strcmp(robj->GetClassName(), "TKey"))
1601 clname = robj->GetKeyClassName();
1602 else
1603 clname = robj->GetClassName();
1604 }
1605 else {
1606 objClass = obj->IsA();
1607 if (objClass)
1608 clname = objClass->GetName();
1609 }
1610 if (!clname) {
1611 clname = "Unknown";
1612 }
1613 const char *name = obj->GetIconName() ? obj->GetIconName() : clname;
1614 TString xpm_magic(name, 3);
1615 Bool_t xpm = xpm_magic == "/* ";
1616 const char *iconname = xpm ? obj->GetName() : name;
1617
1618 if (obj->IsA()->InheritsFrom("TGeoVolume")) {
1619 iconname = obj->GetIconName() ? obj->GetIconName() : obj->IsA()->GetName();
1620 }
1621
1622 if (fCachedPicName == iconname) {
1623 *pic = fCachedPic;
1624 return;
1625 }
1626 *pic = gClient->GetMimeTypeList()->GetIcon(iconname, kTRUE);
1627 if (!(*pic) && xpm) {
1628 if (im && im->SetImageBuffer((char**)&name, TImage::kXpm)) {
1629 im->Scale(im->GetWidth()/4, im->GetHeight()/4);
1630 *pic = gClient->GetPicturePool()->GetPicture(iconname, im->GetPixmap(),
1631 im->GetMask());
1632 }
1633 gClient->GetMimeTypeList()->AddType("[thumbnail]", iconname, iconname, iconname, "->Browse()");
1634 return;
1635 }
1636 if (fCachedPic && (fCachedPic != fFileIcon))
1638 if (*pic == 0) {
1639 if (!obj->IsFolder())
1640 *pic = fFileIcon;
1641 }
1642 fCachedPic = *pic;
1643 fCachedPicName = iconname;
1644}
1645
1646////////////////////////////////////////////////////////////////////////////////
1647/// Go to the directory "path" and open all the parent list tree items.
1648
1649void TGFileBrowser::GotoDir(const char *path)
1650{
1651 TGListTreeItem *item, *itm;
1652 Bool_t expand = kTRUE;
1653 TString sPath(gSystem->UnixPathName(path));
1654 item = fRootDir;
1655 if (item == 0) return;
1656 fListTree->OpenItem(item);
1657 TObjArray *tokens = sPath.Tokenize("/");
1658 if (tokens->IsEmpty()) {
1659 fListTree->HighlightItem(item);
1660 DoubleClicked(item, 1);
1661 delete tokens;
1664 return;
1665 }
1666 // if the Browser.ExpandDirectories option is set to "no", then don't
1667 // expand the parent directory tree (for example on nfs)
1668 TString str = gEnv->GetValue("Browser.ExpandDirectories", "yes");
1669 str.ToLower();
1670 expand = (str == "yes") ? kTRUE : kFALSE;
1671 TString first = ((TObjString*)tokens->At(0))->GetName();
1672 // always prevent expanding the parent directory tree on afs
1673 if (first == "afs")
1674 expand = kFALSE;
1675 if (first.Length() == 2 && first.EndsWith(":")) {
1676 TList *curvol = gSystem->GetVolumes("cur");
1677 if (curvol) {
1678 TNamed *drive = (TNamed *)curvol->At(0);
1679 if (first == drive->GetName()) {
1680 TString infos = drive->GetTitle();
1681 if (infos.Contains("Network"))
1682 expand = kFALSE;
1683 }
1684 delete curvol;
1685 }
1686 }
1687 for (Int_t i = 0; i < tokens->GetEntriesFast(); ++i) {
1688 TString token = ((TObjString*)tokens->At(i))->GetName();
1689 if (token.Length() == 2 && token.EndsWith(":")) {
1690 token.Append("\\");
1691 itm = fListTree->FindChildByName(0, token);
1692 if (itm) {
1693 item = itm;
1694 fListTree->OpenItem(item);
1695 if (expand)
1696 DoubleClicked(item, 1);
1697 }
1698 continue;
1699 }
1700 itm = fListTree->FindChildByName(item, token);
1701 if (itm) {
1702 item = itm;
1703 fListTree->OpenItem(item);
1704 if (expand)
1705 DoubleClicked(item, 1);
1706 }
1707 else {
1708 itm = fListTree->AddItem(item, token);
1709 item = itm;
1710 fListTree->OpenItem(item);
1711 if (expand)
1712 DoubleClicked(item, 1);
1713 }
1714 }
1715 fListTree->HighlightItem(item);
1716 DoubleClicked(item, 1);
1717 delete tokens;
1720}
1721
1722////////////////////////////////////////////////////////////////////////////////
1723/// Slot used to switch to the tab containing the current pad/canvas (gPad)
1724/// used e.g. when drawing a histogram by double-clicking on its list tree
1725/// item in a root file.
1726
1728{
1729 if (fDblClick && fNewBrowser) {
1730 Int_t i;
1731 TGTab *tabRight = fNewBrowser->GetTabRight();
1732 for (i=0;i<tabRight->GetNumberOfTabs();++i) {
1733 TGFrameElement *fe = 0;
1734 TGCompositeFrame *embed = 0;
1735 TGCompositeFrame *frame = tabRight->GetTabContainer(i);
1736 if (frame)
1737 fe = (TGFrameElement *)frame->GetList()->First();
1738 if (fe)
1739 embed = (TGCompositeFrame *)fe->fFrame;
1740 if (embed && embed->InheritsFrom("TRootCanvas")) {
1741 ULong_t canvas = gROOT->ProcessLine(TString::Format("((TRootCanvas *)0x%lx)->Canvas();",
1742 (ULong_t)embed));
1743 if ((canvas) && (canvas == (ULong_t)gPad ||
1744 canvas == (ULong_t)gPad->GetCanvas())) {
1745 tabRight->SetTab(i, kTRUE);
1746 break;
1747 }
1748 }
1749 }
1750 }
1751}
1752
1753////////////////////////////////////////////////////////////////////////////////
1754/// Open a dialog box asking for a string to be used as filter (regexp), and
1755/// add an entry in the map of filtered entries. Entering "*" or empty string
1756/// ("") will disable filtering on the current list tree item.
1757
1759{
1760 char filter[1024];
1761 if (!fListLevel)
1762 return;
1763 // initialize with previous (active) filter string
1764 snprintf(filter, sizeof(filter), "%s", fFilterStr.Data());
1765 new TGInputDialog(gClient->GetRoot(), this,
1766 "Enter filter expression:\n(empty string \"\" or \"*\" to remove filter)",
1767 filter, filter);
1768 // if user pressed cancel, update the status of the current list tree
1769 // item and return
1770 if ((filter[0] == 0) && (filter[1] == 0)) {
1772 return;
1773 }
1774 else if (((filter[0] == 0) && (filter[1] == 1)) || !strcmp(filter, "*")) {
1775 // if user entered "*" or "", just disable filtering for the current
1776 // list tree item
1779 }
1780 else {
1781 // if user entered a string different from "*", use it to create an
1782 // entry in the filter map
1783 fFilterStr = filter;
1785 // if there is already a filter on this item, delete it
1788 // insert a new entry for the current list tree item
1789 fFilteredItems.insert(std::make_pair(fListLevel, StrDup(filter)));
1790 }
1791 // finally update the list tree
1796}
1797
1798////////////////////////////////////////////////////////////////////////////////
1799/// A ROOT File has been selected in TGHtmlBrowser.
1800
1802{
1803 TGListTreeItem *itm = fListTree->FindChildByData(0, gROOT->GetListOfFiles());
1804 if (itm) {
1806 fListLevel = itm;
1809 BrowseObj(gROOT->GetListOfFiles());
1812 }
1813}
1814
1815////////////////////////////////////////////////////////////////////////////////
1816/// Toggle the sort mode and set the "sort button" state accordingly.
1817
1819{
1820 if (!fListLevel) return;
1821 char *itemname = 0;
1822 TGListTreeItem *item = fListLevel;
1823 if (!fListLevel->GetFirstChild()) {
1824 item = fListLevel->GetParent();
1825 itemname = StrDup(fListLevel->GetText());
1826 }
1827 if (!item) {
1828 if (itemname)
1829 delete [] itemname;
1830 return;
1831 }
1832 Bool_t is_sorted = CheckSorted(item);
1833 if (!is_sorted) {
1834 //alphabetical sorting
1835 fListTree->SortChildren(item);
1836 fSortedItems.push_back(item);
1838 }
1839 else {
1841 DoubleClicked(item, 1);
1842 fSortedItems.remove(item);
1844 gClient->NeedRedraw(fListTree, kTRUE);
1845 gClient->HandleInput();
1846 if (itemname) {
1847 TGListTreeItem *itm = fListTree->FindChildByName(item, itemname);
1848 if (itm) {
1850 Clicked(itm, 1, 0, 0);
1851 itm->SetActive(kTRUE);
1852 fListTree->SetSelected(itm);
1854 }
1855 }
1856 }
1857 if (itemname)
1858 delete [] itemname;
1861}
1862
1863
@ kButton1Down
Definition: Buttons.h:17
void Class()
Definition: Class.C:29
@ kButton3
Definition: GuiTypes.h:213
#define b(i)
Definition: RSha256.hxx:100
#define f(i)
Definition: RSha256.hxx:104
#define h(i)
Definition: RSha256.hxx:106
const Ssiz_t kNPOS
Definition: RtypesCore.h:111
int Int_t
Definition: RtypesCore.h:41
int Ssiz_t
Definition: RtypesCore.h:63
unsigned int UInt_t
Definition: RtypesCore.h:42
const Bool_t kFALSE
Definition: RtypesCore.h:88
unsigned long ULong_t
Definition: RtypesCore.h:51
long Long_t
Definition: RtypesCore.h:50
bool Bool_t
Definition: RtypesCore.h:59
long long Long64_t
Definition: RtypesCore.h:69
const Bool_t kTRUE
Definition: RtypesCore.h:87
const char Option_t
Definition: RtypesCore.h:62
#define ClassImp(name)
Definition: Rtypes.h:363
R__EXTERN TApplication * gApplication
Definition: TApplication.h:165
#define gDirectory
Definition: TDirectory.h:213
R__EXTERN TEnv * gEnv
Definition: TEnv.h:171
@ kButtonUp
Definition: TGButton.h:53
@ kButtonEngaged
Definition: TGButton.h:55
#define gClient
Definition: TGClient.h:166
const char * filters[]
static Bool_t IsObjectEditable(TClass *cl)
Helper function checking if a class has a graphic properties editor.
static const TGPicture * MakeLinkPic(const TGPicture *pic)
Create a symlink (shortcut on Windows) icon by merging the picture passed as argument and the slink_t...
static const char * FormatToolTip(TObject *obj, Int_t maxlen=0)
Format the tooltip information, based on the object passed in argument.
const char rootdir[]
static Bool_t IsTextFile(const char *candidate)
Returns true if given a text file Uses the specification given on p86 of the Camel book.
@ kDeepCleanup
Definition: TGFrame.h:51
@ kHorizontalFrame
Definition: TGFrame.h:60
@ 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
int type
Definition: TGX11.cxx:120
#define gInterpreter
Definition: TInterpreter.h:538
#define gROOT
Definition: TROOT.h:410
char * Form(const char *fmt,...)
char * StrDup(const char *str)
Duplicate the string str.
Definition: TString.cxx:2465
Bool_t R_ISREG(Int_t mode)
Definition: TSystem.h:119
Bool_t R_ISDIR(Int_t mode)
Definition: TSystem.h:116
R__EXTERN TSystem * gSystem
Definition: TSystem.h:540
@ kS_IXUSR
Definition: TSystem.h:105
@ kS_IFREG
Definition: TSystem.h:94
#define gPad
Definition: TVirtualPad.h:286
#define gVirtualX
Definition: TVirtualX.h:345
@ kWatch
Definition: TVirtualX.h:47
@ kPointer
Definition: TVirtualX.h:47
#define snprintf
Definition: civetweb.c:1540
TApplication * GetAppRemote() const
Definition: TApplication.h:145
virtual const char * ApplicationName() const
Definition: TApplication.h:123
virtual Long_t ProcessLine(const char *line, Bool_t sync=kFALSE, Int_t *error=0)
Each class (see TClass) has a linked list of its base class(es).
Definition: TBaseClass.h:33
TClass * GetClassPointer(Bool_t load=kTRUE)
Get pointer to the base class TClass.
Definition: TBaseClass.cxx:63
ABC describing GUI independent browser implementation protocol.
Definition: TBrowserImp.h:29
TBrowser * fBrowser
Definition: TBrowserImp.h:32
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:37
void SetDrawOption(Option_t *option="")
Set drawing option for object.
Definition: TBrowser.h:103
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:75
TList * GetListOfBases()
Return list containing the TBaseClass(es) of a class.
Definition: TClass.cxx:3505
Bool_t IsTObject() const
Return kTRUE is the class inherits from TObject.
Definition: TClass.cxx:5700
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:2885
virtual Int_t GetEntries() const
Definition: TCollection.h:177
This class provides an interface to context sensitive popup menus.
Definition: TContextMenu.h:40
virtual void Popup(Int_t x, Int_t y, TObject *obj, TVirtualPad *c=0, TVirtualPad *p=0)
Popup context menu at given location in canvas c and pad p for selected object.
Describe directory structure in memory.
Definition: TDirectory.h:34
virtual void Browse(TBrowser *b)
Browse the content of the directory.
Definition: TDirectory.cxx:215
virtual TList * GetListOfKeys() const
Definition: TDirectory.h:150
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:395
virtual void SetStyle(UInt_t newstyle)
Set the button style (modern or classic).
Definition: TGButton.cxx:221
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
Set button state.
Definition: TGButton.cxx:185
const TGPicture * GetPicture(const char *name)
Get picture from the picture pool.
Definition: TGClient.cxx:289
void FreePicture(const TGPicture *pic)
Free picture resource.
Definition: TGClient.cxx:308
virtual TGLBEntry * GetSelectedEntry() const
Definition: TGComboBox.h:135
virtual TGTextEntry * GetTextEntry() const
Definition: TGComboBox.h:131
virtual void AddEntry(TGString *s, Int_t id)
Definition: TGComboBox.h:106
virtual TGListBox * GetListBox() const
Definition: TGComboBox.h:130
virtual TList * GetList() const
Definition: TGFrame.h:369
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1099
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition: TGFrame.cxx:949
virtual void SetCleanup(Int_t mode=kLocalCleanup)
Turn on automatic cleanup of child frames in dtor.
Definition: TGFrame.cxx:1054
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition: TGFrame.h:375
virtual void MapSubwindows()
Map all sub windows that are part of the composite frame.
Definition: TGFrame.cxx:1146
virtual void ClearViewPort()
Clear view port and redraw full content.
Definition: TGCanvas.cxx:888
TGListTreeItem * fRootDir
Definition: TGFileBrowser.h:52
Bool_t CheckFiltered(TGListTreeItem *item, Bool_t but=kFALSE)
Check if there is a filter active on the children of the list tree item.
TString DirName(TGListTreeItem *item)
returns the directory path
TSystemFile * fFile
Definition: TGFileBrowser.h:65
TGFileBrowser(const TGWindow *p, TBrowser *b=0, UInt_t w=200, UInt_t h=400)
TGFileBrowser constructor.
TGHorizontalFrame * fBotFrame
Definition: TGFileBrowser.h:47
void GetObjPicture(const TGPicture **pic, TObject *obj)
Retrieve icons associated with class "name".
TGListTree * fListTree
Definition: TGFileBrowser.h:49
void CreateBrowser()
Create the actual file browser.
virtual void Refresh(Bool_t force=kFALSE)
Refresh content of the list tree.
void AddKey(TGListTreeItem *itm, TObject *obj, const char *name=0)
display content of ROOT file
Bool_t fShowHidden
Definition: TGFileBrowser.h:69
Bool_t fDblClick
Definition: TGFileBrowser.h:70
TGListTreeItem * fCurrentDir
Definition: TGFileBrowser.h:51
Bool_t CheckSorted(TGListTreeItem *item, Bool_t but=kFALSE)
Check if the list tree item children are alphabetically sorted.
void Clicked(TGListTreeItem *item, Int_t btn, Int_t x, Int_t y)
Process mouse clicks in TGListTree.
void AddFSDirectory(const char *entry, const char *path=0, Option_t *opt="")
Add file system directory in the list tree.
void DoubleClicked(TGListTreeItem *item, Int_t btn)
Process double clicks in TGListTree.
void ApplyFilter(Int_t id)
Apply filter selected in combo box to the file tree view.
TGPictureButton * fFilterButton
Definition: TGFileBrowser.h:58
void PadModified()
Slot used to switch to the tab containing the current pad/canvas (gPad) used e.g.
void GotoDir(const char *path)
Go to the directory "path" and open all the parent list tree items.
void ToggleSort()
Toggle the sort mode and set the "sort button" state accordingly.
TGListTreeItem * fListLevel
Definition: TGFileBrowser.h:50
void AddRemoteFile(TObject *obj)
Add remote file in list tree.
TString fFilterStr
Definition: TGFileBrowser.h:74
TRegexp * fFilter
Definition: TGFileBrowser.h:63
void GetFilePictures(const TGPicture **pic, Int_t file_type, Bool_t is_link, const char *name)
Determine the file picture for the given file type.
TSystemDirectory * fDir
Definition: TGFileBrowser.h:64
virtual void Show()
Definition: TGFileBrowser.h:86
virtual void BrowseObj(TObject *obj)
Browse object.
virtual void RecursiveRemove(TObject *obj)
Recursively remove object.
sLTI_t fSortedItems
Definition: TGFileBrowser.h:72
const TGPicture * fCachedPic
Definition: TGFileBrowser.h:61
void RequestFilter()
Open a dialog box asking for a string to be used as filter (regexp), and add an entry in the map of f...
TGComboBox * fFileType
Definition: TGFileBrowser.h:54
TGCanvas * fCanvas
Definition: TGFileBrowser.h:48
TContextMenu * fContextMenu
Definition: TGFileBrowser.h:55
TRootBrowser * fNewBrowser
Definition: TGFileBrowser.h:45
Option_t * GetDrawOption() const
returns drawing option
char * FormatFileInfo(const char *fname, Long64_t size, Long_t modtime)
Format file information to be displayed in the tooltip.
TString FullPathName(TGListTreeItem *item)
returns an absolute path
TGPictureButton * fSortButton
Definition: TGFileBrowser.h:56
TGComboBox * fDrawOption
Definition: TGFileBrowser.h:53
mFiltered_t::iterator mFiltered_i
Definition: TGFileBrowser.h:42
void Checked(TObject *obj, Bool_t check)
Emits signal when double clicking on icon.
const TGPicture * fFileIcon
Definition: TGFileBrowser.h:60
virtual ~TGFileBrowser()
Destructor.
TGPictureButton * fRefreshButton
Definition: TGFileBrowser.h:57
void CheckRemote(TGListTreeItem *item)
Check if the current list tree item points to a remote object.
void Update()
Update content of the list tree.
const TGPicture * fRootIcon
Definition: TGFileBrowser.h:59
void Selected(char *)
A ROOT File has been selected in TGHtmlBrowser.
TString fCachedPicName
Definition: TGFileBrowser.h:62
mFiltered_t fFilteredItems
Definition: TGFileBrowser.h:73
Long_t XXExecuteDefaultAction(TObject *obj)
Execute default action for selected object (action is specified in the $HOME/.root....
void Chdir(TGListTreeItem *item)
Make object associated with item the current directory.
sLTI_t::iterator sLTI_i
Definition: TGFileBrowser.h:39
TGHorizontalFrame * fTopFrame
Definition: TGFileBrowser.h:46
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:587
virtual void MapWindow()
Definition: TGFrame.h:251
UInt_t GetWidth() const
Definition: TGFrame.h:271
virtual void Resize(UInt_t w, UInt_t h)
Resize the listbox widget.
Definition: TGListBox.cxx:1419
TGListTreeItem * GetFirstChild() const
Definition: TGListTree.h:74
void Rename(const char *new_name)
Definition: TGListTree.h:86
virtual const char * GetText() const =0
TGListTreeItem * GetNextSibling() const
Definition: TGListTree.h:77
TGListTreeItem * GetParent() const
Definition: TGListTree.h:73
virtual void SetTipText(const char *)
Definition: TGListTree.h:92
virtual void SetActive(Bool_t)
Definition: TGListTree.h:84
void SetDNDSource(Bool_t onoff)
Definition: TGListTree.h:123
virtual void SetPictures(const TGPicture *, const TGPicture *)
Definition: TGListTree.h:98
virtual void * GetUserData() const =0
virtual void SetUserData(void *, Bool_t=kFALSE)
Definition: TGListTree.h:94
TGListTreeItem * FindItemByObj(TGListTreeItem *item, void *ptr)
Find item with fUserData == ptr.
void ClearHighlighted()
Un highlight items.
void AddItem(TGListTreeItem *parent, TGListTreeItem *item)
Add given item to list tree.
Int_t DeleteChildren(TGListTreeItem *item)
Delete children of item from list.
void CheckItem(TGListTreeItem *item, Bool_t check=kTRUE)
Set check button state for the node 'item'.
void OpenItem(TGListTreeItem *item)
Open item in list tree (i.e. show child items).
TGListTreeItem * GetSelected() const
Definition: TGListTree.h:397
Int_t RecursiveDeleteItem(TGListTreeItem *item, void *userData)
Delete item with fUserData == ptr.
Int_t DeleteItem(TGListTreeItem *item)
Delete item from list tree.
void SetSelected(TGListTreeItem *item)
Definition: TGListTree.h:368
TGListTreeItem * GetFirstItem() const
Definition: TGListTree.h:396
TGListTreeItem * FindChildByName(TGListTreeItem *item, const char *name)
Find child of item by name.
Int_t SortChildren(TGListTreeItem *item)
Sort children of item.
void AdjustPosition(TGListTreeItem *item)
Move content to position of item.
void HighlightItem(TGListTreeItem *item)
Highlight item.
TGListTreeItem * FindChildByData(TGListTreeItem *item, void *userData)
Find child of item by userData.
void SetToolTipItem(TGListTreeItem *item, const char *string)
Set tooltip text for this item.
void GetPathnameFromItem(TGListTreeItem *item, char *path, Int_t depth=0)
Get pathname from item.
TGClient * fClient
Definition: TGObject.h:37
Handle_t GetId() const
Definition: TGObject.h:47
Definition: TGTab.h:62
TGCompositeFrame * GetCurrentContainer() const
Definition: TGTab.h:110
TGTabElement * GetTabTab(Int_t tabIndex) const
Return the tab element of tab with index tabIndex.
Definition: TGTab.cxx:612
Int_t GetNumberOfTabs() const
Return number of tabs.
Definition: TGTab.cxx:658
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:507
TGCompositeFrame * GetTabContainer(Int_t tabIndex) const
Return container of tab with index tabIndex.
Definition: TGTab.cxx:563
const char * GetText() const
Definition: TGTextEntry.h:134
virtual void SetToolTipText(const char *text, Long_t delayms=500)
Set tool tip text associated with this text entry.
virtual const char * GetTitle() const
Returns title of object.
Definition: TGListBox.h:117
virtual const TGWindow * GetMainFrame() const
Returns top level main frame.
Definition: TGWindow.cxx:133
virtual const char * GetName() const
Return unique name, used in SavePrimitive methods.
Definition: TGWindow.cxx:221
virtual void SetModel(TVirtualPad *pad, TObject *obj, Int_t event, Bool_t force=kFALSE)
Activate object editors according to the selected object.
Definition: TGedEditor.cxx:349
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:110
@ kXpm
Definition: TImage.h:37
virtual UInt_t GetWidth() const
Definition: TImage.h:228
virtual void SetImage(const Double_t *, UInt_t, UInt_t, TImagePalette *=0)
Definition: TImage.h:116
static TImage * Create()
Create an image.
Definition: TImage.cxx:36
virtual Bool_t SetImageBuffer(char **, EImageFileTypes=TImage::kPng)
Definition: TImage.h:242
virtual void Scale(UInt_t, UInt_t)
Definition: TImage.h:141
virtual void Merge(const TImage *, const char *="alphablend", Int_t=0, Int_t=0)
Definition: TImage.h:172
virtual Pixmap_t GetPixmap()
Definition: TImage.h:235
virtual Pixmap_t GetMask()
Definition: TImage.h:236
virtual UInt_t GetHeight() const
Definition: TImage.h:229
Utility class for browsing TMapFile objects.
Definition: TKeyMapFile.h:20
Book space in a file, create I/O buffers, to fill them, (un)compress them.
Definition: TKey.h:24
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:354
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
Definition: TList.cxx:467
virtual TObject * First() const
Return the first object in the list. Returns 0 when list is empty.
Definition: TList.cxx:655
virtual void Sort(Bool_t order=kSortAscending)
Sort linked list.
Definition: TList.cxx:933
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:70
TObject * At(Int_t idx) const
Definition: TObjArray.h:165
Collectable string class.
Definition: TObjString.h:28
Mother of all ROOT objects.
Definition: TObject.h:37
virtual Bool_t IsFolder() const
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects).
Definition: TObject.cxx:473
@ kNotDeleted
object has not been deleted
Definition: TObject.h:78
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:357
virtual void Browse(TBrowser *b)
Browse object. May be overridden for another default action.
Definition: TObject.cxx:119
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition: TObject.h:172
virtual const char * GetIconName() const
Returns mime type name of object.
Definition: TObject.cxx:367
virtual TObject * DrawClone(Option_t *option="") const
Draw a clone of this object in the current selected pad for instance with: gROOT->SetSelectedPad(gPad...
Definition: TObject.cxx:219
virtual char * GetObjectInfo(Int_t px, Int_t py) const
Returns string containing info about the object at position (px,py).
Definition: TObject.cxx:386
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:694
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition: TObject.cxx:443
virtual const char * GetTitle() const
Returns title of object.
Definition: TObject.cxx:401
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition: TObject.cxx:195
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot.
Definition: TQObject.cxx:867
Bool_t Disconnect(const char *signal=0, void *receiver=0, const char *slot=0)
Disconnects signal of this object from slot of receiver.
Definition: TQObject.cxx:1025
void AddReference()
Definition: TRefCnt.h:40
Regular expression class.
Definition: TRegexp.h:31
The TRemoteObject class provides protocol for browsing ROOT objects from a remote ROOT session.
Definition: TRemoteObject.h:36
const char * GetClassName() const
Definition: TRemoteObject.h:56
Bool_t GetFileStat(FileStat_t *sbuf)
Get remote file status.
const char * GetKeyClassName() const
Definition: TRemoteObject.h:58
void SetActBrowser(TBrowserImp *b)
Definition: TRootBrowser.h:149
virtual void Checked(TObject *obj, Bool_t check)
Emits signal when double clicking on icon.
TGTab * GetTabRight() const
Definition: TRootBrowser.h:141
Basic string class.
Definition: TString.h:131
Ssiz_t Length() const
Definition: TString.h:405
void ToLower()
Change string to lower-case.
Definition: TString.cxx:1100
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Definition: TString.cxx:2152
void Clear()
Clear string without changing its capacity.
Definition: TString.cxx:1151
const char * Data() const
Definition: TString.h:364
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition: TString.h:687
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
Definition: TString.cxx:2172
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Definition: TString.h:610
TString & Prepend(const char *cs)
Definition: TString.h:656
Bool_t IsNull() const
Definition: TString.h:402
TString & Remove(Ssiz_t pos)
Definition: TString.h:668
TString & Append(const char *cs)
Definition: TString.h:559
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition: TString.cxx:2286
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:619
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition: TString.h:634
Long64_t Atoll() const
Return long long value of string.
Definition: TString.cxx:1922
Describes an Operating System directory for the browser.
virtual TList * GetListOfFiles() const
Returns a TList of TSystemFile objects representing the contents of the directory.
A TSystemFile describes an operating system file.
Definition: TSystemFile.h:29
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
Definition: TSystem.cxx:1264
virtual const char * DirName(const char *pathname)
Return the directory name in pathname.
Definition: TSystem.cxx:1013
virtual char * ConcatFileName(const char *dir, const char *name)
Concatenate a directory and a file name. User must delete returned string.
Definition: TSystem.cxx:1061
virtual Int_t Exec(const char *shellcmd)
Execute a command.
Definition: TSystem.cxx:662
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:1388
virtual TList * GetVolumes(Option_t *) const
Definition: TSystem.h:435
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:1286
virtual Bool_t ChangeDirectory(const char *path)
Change directory.
Definition: TSystem.cxx:869
virtual const char * UnixPathName(const char *unixpathname)
Convert from a Unix pathname to a local pathname.
Definition: TSystem.cxx:1053
virtual void Sleep(UInt_t milliSec)
Sleep milliSec milli seconds.
Definition: TSystem.cxx:446
virtual const char * WorkingDirectory()
Return working directory.
Definition: TSystem.cxx:878
static void SingleShot(Int_t milliSec, const char *receiver_class, void *receiver, const char *method)
This static function calls a slot after a given time interval.
Definition: TTimer.cxx:256
Abstract base class used by ROOT graphics editor.
static TVirtualPadEditor * GetPadEditor(Bool_t load=kTRUE)
Returns the pad editor dialog. Static method.
TText * text
Double_t y[n]
Definition: legend1.C:17
Double_t x[n]
Definition: legend1.C:17
static constexpr double s
UInt_t GetListOfKeys(TList &keys, TString inherits, TDirectory *dir=0)
Definition: tmvaglob.cxx:375
Definition: file.py:1
Definition: first.py:1
Int_t fMode
Definition: TSystem.h:128
Long64_t fSize
Definition: TSystem.h:131
Long_t fMtime
Definition: TSystem.h:132
Bool_t fIsLink
Definition: TSystem.h:133