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