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