ROOT logo
// @(#)root/gui:$Id: TGFileDialog.cxx 27475 2009-02-18 10:04:21Z bellenot $
// Author: Fons Rademakers   20/01/98

/*************************************************************************
 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TGFileDialog                                                         //
//                                                                      //
// This class creates a file selection dialog. It contains a combo box  //
// to select the desired directory. A listview with the different       //
// files in the current directory and a combo box with which you can    //
// select a filter (on file extensions).                                //
// When creating a file dialog one passes a pointer to a TGFileInfo     //
// object. In this object you can set the fFileTypes and fIniDir to     //
// specify the list of file types for the filter combo box and the      //
// initial directory. When the TGFileDialog ctor returns the selected   //
// file name can be found in the TGFileInfo::fFilename field and the    //
// selected directory in TGFileInfo::fIniDir. The fFilename and         //
// fIniDir are deleted by the TGFileInfo dtor.                          //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#include "TGFileDialog.h"
#include "TGLabel.h"
#include "TGButton.h"
#include "TGTextEntry.h"
#include "TGComboBox.h"
#include "TGListView.h"
#include "TGFSContainer.h"
#include "TGFSComboBox.h"
#include "TGMsgBox.h"
#include "TSystem.h"
#include "TGInputDialog.h"
#include "TObjString.h"

#include <sys/stat.h>

enum EFileFialog {
   kIDF_CDUP,
   kIDF_NEW_FOLDER,
   kIDF_LIST,
   kIDF_DETAILS,
   kIDF_CHECKB,
   kIDF_FSLB,
   kIDF_FTYPESLB,
   kIDF_OK,
   kIDF_CANCEL
};

static const char *gDefTypes[] = { "All files",     "*",
                                   "ROOT files",    "*.root",
                                   "ROOT macros",   "*.C",
                                    0,               0 };

static TGFileInfo gInfo;


ClassImp(TGFileDialog)

//______________________________________________________________________________
TGFileInfo::~TGFileInfo()
{
   // TGFileInfo Destructor.

   delete [] fFilename;
   delete [] fIniDir;
   if ( fFileNamesList != 0 ) {
      fFileNamesList->Delete();
      delete fFileNamesList;
   }
}

//______________________________________________________________________________
void TGFileInfo::SetMultipleSelection(Bool_t option)
{
   // Turn on/off multiple selection.

   if ( fMultipleSelection != option ) {
      fMultipleSelection = option;
      if ( fMultipleSelection == kTRUE )
         fFileNamesList = new TList();
      else {
         fFileNamesList->Delete();
         delete fFileNamesList;
         fFileNamesList = 0;
      }
   }
}

//______________________________________________________________________________
TGFileDialog::TGFileDialog(const TGWindow *p, const TGWindow *main,
                           EFileDialogMode dlg_type, TGFileInfo *file_info) :
   TGTransientFrame(p, main, 10, 10, kVerticalFrame)
{
   // Create a file selection dialog. Depending on the dlg_type it can be
   // used for opening or saving a file.

   SetCleanup(kDeepCleanup);
   Connect("CloseWindow()", "TGFileDialog", this, "CloseWindow()");
   DontCallClose();

   int i;

   if (!p && !main) {
      MakeZombie();
      return;
   }
   if (!file_info) {
      Error("TGFileDialog", "file_info argument not set");
      fFileInfo = &gInfo;
      if (fFileInfo->fIniDir) {
         delete [] fFileInfo->fIniDir;
         fFileInfo->fIniDir = 0;
      }
      if (fFileInfo->fFilename) {
         delete [] fFileInfo->fFilename;
         fFileInfo->fFilename = 0;
      }
      fFileInfo->fFileTypeIdx = 0;
   } else
      fFileInfo = file_info;

   if (!fFileInfo->fFileTypes)
      fFileInfo->fFileTypes = gDefTypes;

   if (!fFileInfo->fIniDir)
      fFileInfo->fIniDir = StrDup(".");

   TGHorizontalFrame *fHtop = new TGHorizontalFrame(this, 10, 10);
   
   //--- top toolbar elements
   TGLabel *fLookin = new TGLabel(fHtop, new TGHotString((dlg_type == kFDSave)
                                                  ? "S&ave in:" : "&Look in:"));
   fTreeLB = new TGFSComboBox(fHtop, kIDF_FSLB);
   fTreeLB->Associate(this);

   fPcdup = fClient->GetPicture("tb_uplevel.xpm");
   fPnewf = fClient->GetPicture("tb_newfolder.xpm");
   fPlist = fClient->GetPicture("tb_list.xpm");
   fPdetails = fClient->GetPicture("tb_details.xpm");

   if (!(fPcdup && fPnewf && fPlist && fPdetails))
      Error("TGFileDialog", "missing toolbar pixmap(s).\n");

   fCdup    = new TGPictureButton(fHtop, fPcdup, kIDF_CDUP);
   fNewf    = new TGPictureButton(fHtop, fPnewf, kIDF_NEW_FOLDER);
   fList    = new TGPictureButton(fHtop, fPlist, kIDF_LIST);
   fDetails = new TGPictureButton(fHtop, fPdetails, kIDF_DETAILS);

   fCdup->SetToolTipText("Up One Level");
   fNewf->SetToolTipText("Create New Folder");
   fList->SetToolTipText("List");
   fDetails->SetToolTipText("Details");

   fCdup->Associate(this);
   fNewf->Associate(this);
   fList->Associate(this);
   fDetails->Associate(this);

   fList->AllowStayDown(kTRUE);
   fDetails->AllowStayDown(kTRUE);

   fTreeLB->Resize(200, fTreeLB->GetDefaultHeight());

   fHtop->AddFrame(fLookin, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 2, 5, 2, 2));
   fHtop->AddFrame(fTreeLB, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 3, 0, 2, 2));
   fHtop->AddFrame(fCdup, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 0, 2, 2));
   fHtop->AddFrame(fNewf, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 0, 2, 2));
   fHtop->AddFrame(fList, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 0, 2, 2));
   fHtop->AddFrame(fDetails, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 0, 8, 2, 2));

   if (dlg_type == kFDSave) {
      fCheckB = new TGCheckButton(fHtop, "&Overwrite", kIDF_CHECKB);
      fCheckB->SetToolTipText("Overwrite a file without displaying a message if selected");
   } else {
      fCheckB = new TGCheckButton(fHtop, "&Multiple files", kIDF_CHECKB);
      fCheckB->SetToolTipText("Allows multiple file selection when SHIFT is pressed");
      fCheckB->Connect("Toggled(Bool_t)","TGFileInfo",fFileInfo,"SetMultipleSelection(Bool_t)");
   }
   fHtop->AddFrame(fCheckB, new TGLayoutHints(kLHintsLeft | kLHintsCenterY));
   fCheckB->SetOn(fFileInfo->fMultipleSelection);
   AddFrame(fHtop, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 4, 4, 3, 1));

   //--- file view

   fFv = new TGListView(this, 400, 161);

   fFc = new TGFileContainer(fFv->GetViewPort(),
                             10, 10, kHorizontalFrame, fgWhitePixel);
   fFc->Associate(this);

   fFv->GetViewPort()->SetBackgroundColor(fgWhitePixel);
   fFv->SetContainer(fFc);
   fFv->SetViewMode(kLVList);
   fFv->SetIncrements(1, 19); // set vertical scroll one line height at a time

   TGTextButton** buttons = fFv->GetHeaderButtons();
   if (buttons) {
      buttons[0]->Connect("Clicked()", "TGFileContainer", fFc, "Sort(=kSortByName)");
      buttons[1]->Connect("Clicked()", "TGFileContainer", fFc, "Sort(=kSortByType)");
      buttons[2]->Connect("Clicked()", "TGFileContainer", fFc, "Sort(=kSortBySize)");
      buttons[3]->Connect("Clicked()", "TGFileContainer", fFc, "Sort(=kSortByOwner)");
      buttons[4]->Connect("Clicked()", "TGFileContainer", fFc, "Sort(=kSortByGroup)");
      buttons[5]->Connect("Clicked()", "TGFileContainer", fFc, "Sort(=kSortByDate)");
   }

   fFc->SetFilter(fFileInfo->fFileTypes[fFileInfo->fFileTypeIdx+1]);
   fFc->Sort(kSortByName);
   fFc->ChangeDirectory(fFileInfo->fIniDir);
   fFc->SetMultipleSelection(fFileInfo->fMultipleSelection);
   fTreeLB->Update(fFc->GetDirectory());

   fList->SetState(kButtonEngaged);

   AddFrame(fFv, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 4, 4, 3, 1));

   if (dlg_type == kFDOpen) {
      fCheckB->Connect("Toggled(Bool_t)","TGFileContainer",fFc,"SetMultipleSelection(Bool_t)");
      fCheckB->Connect("Toggled(Bool_t)","TGFileContainer",fFc,"UnSelectAll()");
   }
   
   //--- file name and types

   TGHorizontalFrame *fHf = new TGHorizontalFrame(this, 10, 10);

   TGVerticalFrame *fVf = new TGVerticalFrame(fHf, 10, 10);

   TGHorizontalFrame *fHfname = new TGHorizontalFrame(fVf, 10, 10);

   TGLabel *fLfname = new TGLabel(fHfname, new TGHotString("File &name:"));
   fTbfname = new TGTextBuffer(1034);
   fName = new TGTextEntry(fHfname, fTbfname);
   fName->Resize(230, fName->GetDefaultHeight());
   fName->Associate(this);

   fHfname->AddFrame(fLfname, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 2, 5, 2, 2));
   fHfname->AddFrame(fName, new TGLayoutHints(kLHintsRight | kLHintsCenterY, 0, 20, 2, 2));

   fVf->AddFrame(fHfname, new TGLayoutHints(kLHintsLeft | kLHintsCenterY | kLHintsExpandX));

   TGHorizontalFrame *fHftype = new TGHorizontalFrame(fVf, 10, 10);

   TGLabel *fLftypes = new TGLabel(fHftype, new TGHotString("Files of &type:"));
   fTypes = new TGComboBox(fHftype, kIDF_FTYPESLB);
   fTypes->Associate(this);
   fTypes->Resize(230, fName->GetDefaultHeight());

   char s[64];
   for (i = 0; fFileInfo->fFileTypes[i] != 0; i += 2) {
      sprintf(s, "%s (%s)", fFileInfo->fFileTypes[i], fFileInfo->fFileTypes[i+1]);
      fTypes->AddEntry(s, i);
   }
   fTypes->Select(fFileInfo->fFileTypeIdx);

   // Show all items in combobox without scrollbar
   //TGDimension fw = fTypes->GetListBox()->GetContainer()->GetDefaultSize();
   //fTypes->GetListBox()->Resize(fw.fWidth, fw.fHeight);

   if (fFileInfo->fFilename && fFileInfo->fFilename[0])
      fTbfname->AddText(0, fFileInfo->fFilename);
   else
      fTbfname->Clear();

   fHftype->AddFrame(fLftypes, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 2, 5, 2, 2));
   fHftype->AddFrame(fTypes, new TGLayoutHints(kLHintsRight | kLHintsCenterY, 0, 20, 2, 2));

   fVf->AddFrame(fHftype, new TGLayoutHints(kLHintsLeft | kLHintsCenterY | kLHintsExpandX));

   fHf->AddFrame(fVf, new TGLayoutHints(kLHintsLeft | kLHintsCenterY | kLHintsExpandX));

   //--- Open/Save and Cancel buttons

   TGVerticalFrame *fVbf = new TGVerticalFrame(fHf, 10, 10, kFixedWidth);

   fOk = new TGTextButton(fVbf, new TGHotString((dlg_type == kFDSave)
                                                 ? "&Save" : "&Open"), kIDF_OK);
   fCancel = new TGTextButton(fVbf, new TGHotString("Cancel"), kIDF_CANCEL);

   fOk->Associate(this);
   fCancel->Associate(this);

   fVbf->AddFrame(fOk, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0, 0, 2, 2));
   fVbf->AddFrame(fCancel, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0, 0, 2, 2));

   UInt_t width = TMath::Max(fOk->GetDefaultWidth(), fCancel->GetDefaultWidth()) + 20;
   fVbf->Resize(width + 20, fVbf->GetDefaultHeight());

   fHf->AddFrame(fVbf, new TGLayoutHints(kLHintsLeft | kLHintsCenterY));

   AddFrame(fHf, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 4, 4, 3, 1));
   SetEditDisabled(kEditDisable);

   MapSubwindows();

   TGDimension size = GetDefaultSize();

   Resize(size);

   //---- position relative to the parent's window

   CenterOnParent();

   //---- make the message box non-resizable

   SetWMSize(size.fWidth, size.fHeight);
   SetWMSizeHints(size.fWidth, size.fHeight, size.fWidth, size.fHeight, 0, 0);

   const char *wname = (dlg_type == kFDSave) ? "Save As..." : "Open";
   SetWindowName(wname);
   SetIconName(wname);
   SetClassHints("FileDialog", "FileDialog");

   SetMWMHints(kMWMDecorAll | kMWMDecorResizeH  | kMWMDecorMaximize |
                              kMWMDecorMinimize | kMWMDecorMenu,
               kMWMFuncAll |  kMWMFuncResize    | kMWMFuncMaximize |
                              kMWMFuncMinimize,
               kMWMInputModeless);

   MapWindow();
   fFc->DisplayDirectory();
   fClient->WaitFor(this);
}

//______________________________________________________________________________
TGFileDialog::~TGFileDialog()
{
   // Delete file dialog.

   if (IsZombie()) return;
   TString str = fCheckB->GetString();
   if (str.Contains("Multiple")) 
      fCheckB->Disconnect("Toggled(Bool_t)");
   fClient->FreePicture(fPcdup);
   fClient->FreePicture(fPnewf);
   fClient->FreePicture(fPlist);
   fClient->FreePicture(fPdetails);
   delete fFc; 
}

//______________________________________________________________________________
void TGFileDialog::CloseWindow()
{
   // Close file dialog.

   fFileInfo->fFilename = 0;
   if (fFileInfo->fFileNamesList != 0) {
      fFileInfo->fFileNamesList->Delete();
      fFileInfo->fFileNamesList = 0;
   }
   DeleteWindow();
}

//______________________________________________________________________________
Bool_t TGFileDialog::ProcessMessage(Long_t msg, Long_t parm1, Long_t)
{
   // Process messages generated by the user input in the file dialog.

   if (!fFc->GetDisplayStat()) return kTRUE;  // Cancel button was pressed
   
   TGTreeLBEntry *e;
   TGTextLBEntry *te;
   TGFileItem *f;
   void *p = 0;
   TString txt;
   TString sdir = gSystem->WorkingDirectory();

   switch (GET_MSG(msg)) {
      case kC_COMMAND:
         switch (GET_SUBMSG(msg)) {
            case kCM_BUTTON:
               switch (parm1) {
                  case kIDF_OK:
                     // same code as under kTE_ENTER
                     if (fTbfname->GetTextLength() == 0) {
                        txt = "Please provide file name or use \"Cancel\"";
                        new TGMsgBox(fClient->GetRoot(), GetMainFrame(),
                                     "Missing File Name", txt, kMBIconExclamation,
                                     kMBOk);
                        return kTRUE;
                     } else if (!gSystem->AccessPathName(fTbfname->GetString(), kFileExists) &&
                                !strcmp(fOk->GetTitle(), "Save") &&
                                (!(fCheckB->GetState() == kButtonDown))) {
                        Int_t ret;
                        txt = TString::Format("File name %s already exists, OK to overwrite it?",
                                              fTbfname->GetString());
                        new TGMsgBox(fClient->GetRoot(), GetMainFrame(),
                                     "File Name Exist", txt.Data(), kMBIconExclamation,
                                     kMBYes | kMBNo, &ret);
                        if (ret == kMBNo)
                           return kTRUE;
                     }
                     if (fFileInfo->fMultipleSelection) {
                        fFileInfo->fFilename = 0;
                     }
                     else {
                        if (gSystem->IsAbsoluteFileName(fTbfname->GetString()))
                           fFileInfo->fFilename = StrDup(fTbfname->GetString());
                        else
                           fFileInfo->fFilename = gSystem->ConcatFileName(fFc->GetDirectory(),
                                                                          fTbfname->GetString());
                        fFileInfo->fFilename = StrDup(gSystem->UnixPathName(fFileInfo->fFilename));
                     }
                     if (fCheckB && (fCheckB->GetState() == kButtonDown))
                        fFileInfo->fOverwrite = kTRUE;
                     else
                        fFileInfo->fOverwrite = kFALSE;
                     DeleteWindow();
                     break;

                  case kIDF_CANCEL:
                     fFileInfo->fFilename = 0;
                     if (fFc->GetDisplayStat()) 
                        fFc->SetDisplayStat(kFALSE);
                     if (fFileInfo->fFileNamesList != 0) {
                        fFileInfo->fFileNamesList->Delete();
                        fFileInfo->fFileNamesList = 0;
                     }
                     DeleteWindow();
                     return kTRUE;   //no need to redraw fFc
                     break;

                  case kIDF_CDUP:
                     fFc->ChangeDirectory("..");
                     fTreeLB->Update(fFc->GetDirectory());
                     if (fFileInfo->fIniDir) delete [] fFileInfo->fIniDir;
                     fFileInfo->fIniDir = StrDup(fFc->GetDirectory());
                     break;

                  case kIDF_NEW_FOLDER: {
                     char answer[128];
                     strcpy(answer, "(empty)");
                     new TGInputDialog(gClient->GetRoot(), GetMainFrame(),
                                       "Enter directory name:",
                                       answer/*"(empty)"*/, answer);

                     while ( strcmp(answer, "(empty)") == 0 ) {
                        new TGMsgBox(gClient->GetRoot(), GetMainFrame(), "Error",
                                     "Please enter a valid directory name.",
                                     kMBIconStop, kMBOk);
                        new TGInputDialog(gClient->GetRoot(), GetMainFrame(),
                                          "Enter directory name:",
                                          answer, answer);
                     }
                     if ( strcmp(answer, "") == 0 )  // Cancel button was pressed
                        break;
                     
                     if (strcmp(gSystem->WorkingDirectory(),fFc->GetDirectory())) {
                        gSystem->cd(fFc->GetDirectory());
                     }
                     if ( gSystem->MakeDirectory(answer) != 0 )
                        new TGMsgBox(gClient->GetRoot(), GetMainFrame(), "Error", 
                                     TString::Format("Directory name \'%s\' already exists!", answer),
                                     kMBIconStop, kMBOk);
                     else {
                        fFc->DisplayDirectory();
                     }
                     gSystem->ChangeDirectory(sdir.Data());
                     break;
                  }

                  case kIDF_LIST:
                     fFv->SetViewMode(kLVList);
                     fDetails->SetState(kButtonUp);
                     break;

                  case kIDF_DETAILS:
                     fFv->SetViewMode(kLVDetails);
                     fList->SetState(kButtonUp);
                     break;
               }
               break;

            case kCM_COMBOBOX:
               switch (parm1) {
                  case kIDF_FSLB:
                     e = (TGTreeLBEntry *) fTreeLB->GetSelectedEntry();
                     if (e) {
                        fFc->ChangeDirectory(e->GetPath()->GetString());
                        fTreeLB->Update(fFc->GetDirectory());
                        if (fFileInfo->fIniDir) delete [] fFileInfo->fIniDir;
                        fFileInfo->fIniDir = StrDup(fFc->GetDirectory());
                     }
                     break;

                  case kIDF_FTYPESLB:
                     te = (TGTextLBEntry *) fTypes->GetSelectedEntry();
                     if (te) {
                        //fTbfname->Clear();
                        //fTbfname->AddText(0, fFileInfo->fFileTypes[te->EntryId()+1]);
                        fFileInfo->fFileTypeIdx = te->EntryId();
                        fFc->SetFilter(fFileInfo->fFileTypes[fFileInfo->fFileTypeIdx+1]);
                        fFc->DisplayDirectory();
                        fClient->NeedRedraw(fName);
                     }
                     break;
               }
               break;

            default:
               break;
         } // switch(GET_SUBMSG(msg))
         break;

      case kC_CONTAINER:
         switch (GET_SUBMSG(msg)) {
            case kCT_ITEMCLICK:
               if (parm1 == kButton1) {
                  if (fFc->NumSelected() > 0) {
                     if ( fFileInfo->fMultipleSelection == kFALSE ) {
                        TGLVEntry *e2 = (TGLVEntry *) fFc->GetNextSelected(&p);
                        fTbfname->Clear();
                        fTbfname->AddText(0, e2->GetItemName()->GetString());
                        fClient->NeedRedraw(fName);
                     }
                     else {
                        TString tmpString;
                        TList *tmp = fFc->GetSelectedItems();
                        TObjString *el;
                        TIter next(tmp);
                        if ( fFileInfo->fFileNamesList != 0 ) {
                           fFileInfo->fFileNamesList->Delete();
                        }
                        else {
                           fFileInfo->fFileNamesList = new TList();
                        }
                        while ((el = (TObjString *) next())) {
                           tmpString += "\"" + el->GetString() + "\" ";
                           fFileInfo->fFileNamesList->Add(new TObjString(
                              gSystem->ConcatFileName(fFc->GetDirectory(),
                                                      el->GetString())));
                        }
                        fTbfname->Clear();
                        fTbfname->AddText(0, tmpString);
                        fClient->NeedRedraw(fName);
                     }
                  }
               }
               break;

            case kCT_ITEMDBLCLICK:

               if (parm1 == kButton1) {
                  if (fFc->NumSelected() == 1) {
                     f = (TGFileItem *) fFc->GetNextSelected(&p);
                     if (R_ISDIR(f->GetType())) {
                        fFc->ChangeDirectory(f->GetItemName()->GetString());
                        fTreeLB->Update(fFc->GetDirectory());
                        if (fFileInfo->fIniDir) delete [] fFileInfo->fIniDir;
                        fFileInfo->fIniDir = StrDup(fFc->GetDirectory());
                     } else {
                        if (!strcmp(fOk->GetTitle(), "Save") &&
                            (!(fCheckB->GetState() == kButtonDown))) {

                           Int_t ret;
                           txt = TString::Format("File name %s already exists, OK to overwrite it?",
                                                 fTbfname->GetString());
                           new TGMsgBox(fClient->GetRoot(), GetMainFrame(),
                                        "File Name Exist", txt.Data(), kMBIconExclamation,
                                        kMBYes | kMBNo, &ret);
                           if (ret == kMBNo)
                              return kTRUE;
                        }
                        if (gSystem->IsAbsoluteFileName(fTbfname->GetString()))
                           fFileInfo->fFilename = StrDup(fTbfname->GetString());
                        else
                           fFileInfo->fFilename = gSystem->ConcatFileName(fFc->GetDirectory(),
                                                                          fTbfname->GetString());
                        if (fCheckB && (fCheckB->GetState() == kButtonDown))
                           fFileInfo->fOverwrite = kTRUE;
                        else
                           fFileInfo->fOverwrite = kFALSE;

                        DeleteWindow();
                     }
                  }
               }

               break;

            default:
               break;

         } // switch(GET_SUBMSG(msg))
         break;

      case kC_TEXTENTRY:
         switch (GET_SUBMSG(msg)) {
            case kTE_ENTER:
               // same code as under kIDF_OK
               if (fTbfname->GetTextLength() == 0) {
                  const char *txt2 = "Please provide file name or use \"Cancel\"";
                  new TGMsgBox(fClient->GetRoot(), GetMainFrame(),
                               "Missing File Name", txt2, kMBIconExclamation,
                               kMBOk);
                  return kTRUE;
               } else if (!gSystem->AccessPathName(fTbfname->GetString(), kFileExists) &&
                          !strcmp(fOk->GetTitle(), "Save") &&
                          (!(fCheckB->GetState() == kButtonDown))) {
                  Int_t ret;
                  txt = TString::Format("File name %s already exists, OK to overwrite it?",
                                        fTbfname->GetString());
                  new TGMsgBox(fClient->GetRoot(), GetMainFrame(),
                               "File Name Exist", txt.Data(), kMBIconExclamation,
                               kMBYes | kMBNo, &ret);
                  if (ret == kMBNo)
                     return kTRUE;
               }
               fFileInfo->fFilename = gSystem->ConcatFileName(fFc->GetDirectory(),
                                                              fTbfname->GetString());
               if (fCheckB && (fCheckB->GetState() == kButtonDown))
                  fFileInfo->fOverwrite = kTRUE;
               else
                  fFileInfo->fOverwrite = kFALSE;
               DeleteWindow();
               break;

            default:
               break;
         }
         break;

      default:
         break;

   } // switch(GET_MSG(msg))

   fClient->NeedRedraw(fFc);
   return kTRUE;
}
 TGFileDialog.cxx:1
 TGFileDialog.cxx:2
 TGFileDialog.cxx:3
 TGFileDialog.cxx:4
 TGFileDialog.cxx:5
 TGFileDialog.cxx:6
 TGFileDialog.cxx:7
 TGFileDialog.cxx:8
 TGFileDialog.cxx:9
 TGFileDialog.cxx:10
 TGFileDialog.cxx:11
 TGFileDialog.cxx:12
 TGFileDialog.cxx:13
 TGFileDialog.cxx:14
 TGFileDialog.cxx:15
 TGFileDialog.cxx:16
 TGFileDialog.cxx:17
 TGFileDialog.cxx:18
 TGFileDialog.cxx:19
 TGFileDialog.cxx:20
 TGFileDialog.cxx:21
 TGFileDialog.cxx:22
 TGFileDialog.cxx:23
 TGFileDialog.cxx:24
 TGFileDialog.cxx:25
 TGFileDialog.cxx:26
 TGFileDialog.cxx:27
 TGFileDialog.cxx:28
 TGFileDialog.cxx:29
 TGFileDialog.cxx:30
 TGFileDialog.cxx:31
 TGFileDialog.cxx:32
 TGFileDialog.cxx:33
 TGFileDialog.cxx:34
 TGFileDialog.cxx:35
 TGFileDialog.cxx:36
 TGFileDialog.cxx:37
 TGFileDialog.cxx:38
 TGFileDialog.cxx:39
 TGFileDialog.cxx:40
 TGFileDialog.cxx:41
 TGFileDialog.cxx:42
 TGFileDialog.cxx:43
 TGFileDialog.cxx:44
 TGFileDialog.cxx:45
 TGFileDialog.cxx:46
 TGFileDialog.cxx:47
 TGFileDialog.cxx:48
 TGFileDialog.cxx:49
 TGFileDialog.cxx:50
 TGFileDialog.cxx:51
 TGFileDialog.cxx:52
 TGFileDialog.cxx:53
 TGFileDialog.cxx:54
 TGFileDialog.cxx:55
 TGFileDialog.cxx:56
 TGFileDialog.cxx:57
 TGFileDialog.cxx:58
 TGFileDialog.cxx:59
 TGFileDialog.cxx:60
 TGFileDialog.cxx:61
 TGFileDialog.cxx:62
 TGFileDialog.cxx:63
 TGFileDialog.cxx:64
 TGFileDialog.cxx:65
 TGFileDialog.cxx:66
 TGFileDialog.cxx:67
 TGFileDialog.cxx:68
 TGFileDialog.cxx:69
 TGFileDialog.cxx:70
 TGFileDialog.cxx:71
 TGFileDialog.cxx:72
 TGFileDialog.cxx:73
 TGFileDialog.cxx:74
 TGFileDialog.cxx:75
 TGFileDialog.cxx:76
 TGFileDialog.cxx:77
 TGFileDialog.cxx:78
 TGFileDialog.cxx:79
 TGFileDialog.cxx:80
 TGFileDialog.cxx:81
 TGFileDialog.cxx:82
 TGFileDialog.cxx:83
 TGFileDialog.cxx:84
 TGFileDialog.cxx:85
 TGFileDialog.cxx:86
 TGFileDialog.cxx:87
 TGFileDialog.cxx:88
 TGFileDialog.cxx:89
 TGFileDialog.cxx:90
 TGFileDialog.cxx:91
 TGFileDialog.cxx:92
 TGFileDialog.cxx:93
 TGFileDialog.cxx:94
 TGFileDialog.cxx:95
 TGFileDialog.cxx:96
 TGFileDialog.cxx:97
 TGFileDialog.cxx:98
 TGFileDialog.cxx:99
 TGFileDialog.cxx:100
 TGFileDialog.cxx:101
 TGFileDialog.cxx:102
 TGFileDialog.cxx:103
 TGFileDialog.cxx:104
 TGFileDialog.cxx:105
 TGFileDialog.cxx:106
 TGFileDialog.cxx:107
 TGFileDialog.cxx:108
 TGFileDialog.cxx:109
 TGFileDialog.cxx:110
 TGFileDialog.cxx:111
 TGFileDialog.cxx:112
 TGFileDialog.cxx:113
 TGFileDialog.cxx:114
 TGFileDialog.cxx:115
 TGFileDialog.cxx:116
 TGFileDialog.cxx:117
 TGFileDialog.cxx:118
 TGFileDialog.cxx:119
 TGFileDialog.cxx:120
 TGFileDialog.cxx:121
 TGFileDialog.cxx:122
 TGFileDialog.cxx:123
 TGFileDialog.cxx:124
 TGFileDialog.cxx:125
 TGFileDialog.cxx:126
 TGFileDialog.cxx:127
 TGFileDialog.cxx:128
 TGFileDialog.cxx:129
 TGFileDialog.cxx:130
 TGFileDialog.cxx:131
 TGFileDialog.cxx:132
 TGFileDialog.cxx:133
 TGFileDialog.cxx:134
 TGFileDialog.cxx:135
 TGFileDialog.cxx:136
 TGFileDialog.cxx:137
 TGFileDialog.cxx:138
 TGFileDialog.cxx:139
 TGFileDialog.cxx:140
 TGFileDialog.cxx:141
 TGFileDialog.cxx:142
 TGFileDialog.cxx:143
 TGFileDialog.cxx:144
 TGFileDialog.cxx:145
 TGFileDialog.cxx:146
 TGFileDialog.cxx:147
 TGFileDialog.cxx:148
 TGFileDialog.cxx:149
 TGFileDialog.cxx:150
 TGFileDialog.cxx:151
 TGFileDialog.cxx:152
 TGFileDialog.cxx:153
 TGFileDialog.cxx:154
 TGFileDialog.cxx:155
 TGFileDialog.cxx:156
 TGFileDialog.cxx:157
 TGFileDialog.cxx:158
 TGFileDialog.cxx:159
 TGFileDialog.cxx:160
 TGFileDialog.cxx:161
 TGFileDialog.cxx:162
 TGFileDialog.cxx:163
 TGFileDialog.cxx:164
 TGFileDialog.cxx:165
 TGFileDialog.cxx:166
 TGFileDialog.cxx:167
 TGFileDialog.cxx:168
 TGFileDialog.cxx:169
 TGFileDialog.cxx:170
 TGFileDialog.cxx:171
 TGFileDialog.cxx:172
 TGFileDialog.cxx:173
 TGFileDialog.cxx:174
 TGFileDialog.cxx:175
 TGFileDialog.cxx:176
 TGFileDialog.cxx:177
 TGFileDialog.cxx:178
 TGFileDialog.cxx:179
 TGFileDialog.cxx:180
 TGFileDialog.cxx:181
 TGFileDialog.cxx:182
 TGFileDialog.cxx:183
 TGFileDialog.cxx:184
 TGFileDialog.cxx:185
 TGFileDialog.cxx:186
 TGFileDialog.cxx:187
 TGFileDialog.cxx:188
 TGFileDialog.cxx:189
 TGFileDialog.cxx:190
 TGFileDialog.cxx:191
 TGFileDialog.cxx:192
 TGFileDialog.cxx:193
 TGFileDialog.cxx:194
 TGFileDialog.cxx:195
 TGFileDialog.cxx:196
 TGFileDialog.cxx:197
 TGFileDialog.cxx:198
 TGFileDialog.cxx:199
 TGFileDialog.cxx:200
 TGFileDialog.cxx:201
 TGFileDialog.cxx:202
 TGFileDialog.cxx:203
 TGFileDialog.cxx:204
 TGFileDialog.cxx:205
 TGFileDialog.cxx:206
 TGFileDialog.cxx:207
 TGFileDialog.cxx:208
 TGFileDialog.cxx:209
 TGFileDialog.cxx:210
 TGFileDialog.cxx:211
 TGFileDialog.cxx:212
 TGFileDialog.cxx:213
 TGFileDialog.cxx:214
 TGFileDialog.cxx:215
 TGFileDialog.cxx:216
 TGFileDialog.cxx:217
 TGFileDialog.cxx:218
 TGFileDialog.cxx:219
 TGFileDialog.cxx:220
 TGFileDialog.cxx:221
 TGFileDialog.cxx:222
 TGFileDialog.cxx:223
 TGFileDialog.cxx:224
 TGFileDialog.cxx:225
 TGFileDialog.cxx:226
 TGFileDialog.cxx:227
 TGFileDialog.cxx:228
 TGFileDialog.cxx:229
 TGFileDialog.cxx:230
 TGFileDialog.cxx:231
 TGFileDialog.cxx:232
 TGFileDialog.cxx:233
 TGFileDialog.cxx:234
 TGFileDialog.cxx:235
 TGFileDialog.cxx:236
 TGFileDialog.cxx:237
 TGFileDialog.cxx:238
 TGFileDialog.cxx:239
 TGFileDialog.cxx:240
 TGFileDialog.cxx:241
 TGFileDialog.cxx:242
 TGFileDialog.cxx:243
 TGFileDialog.cxx:244
 TGFileDialog.cxx:245
 TGFileDialog.cxx:246
 TGFileDialog.cxx:247
 TGFileDialog.cxx:248
 TGFileDialog.cxx:249
 TGFileDialog.cxx:250
 TGFileDialog.cxx:251
 TGFileDialog.cxx:252
 TGFileDialog.cxx:253
 TGFileDialog.cxx:254
 TGFileDialog.cxx:255
 TGFileDialog.cxx:256
 TGFileDialog.cxx:257
 TGFileDialog.cxx:258
 TGFileDialog.cxx:259
 TGFileDialog.cxx:260
 TGFileDialog.cxx:261
 TGFileDialog.cxx:262
 TGFileDialog.cxx:263
 TGFileDialog.cxx:264
 TGFileDialog.cxx:265
 TGFileDialog.cxx:266
 TGFileDialog.cxx:267
 TGFileDialog.cxx:268
 TGFileDialog.cxx:269
 TGFileDialog.cxx:270
 TGFileDialog.cxx:271
 TGFileDialog.cxx:272
 TGFileDialog.cxx:273
 TGFileDialog.cxx:274
 TGFileDialog.cxx:275
 TGFileDialog.cxx:276
 TGFileDialog.cxx:277
 TGFileDialog.cxx:278
 TGFileDialog.cxx:279
 TGFileDialog.cxx:280
 TGFileDialog.cxx:281
 TGFileDialog.cxx:282
 TGFileDialog.cxx:283
 TGFileDialog.cxx:284
 TGFileDialog.cxx:285
 TGFileDialog.cxx:286
 TGFileDialog.cxx:287
 TGFileDialog.cxx:288
 TGFileDialog.cxx:289
 TGFileDialog.cxx:290
 TGFileDialog.cxx:291
 TGFileDialog.cxx:292
 TGFileDialog.cxx:293
 TGFileDialog.cxx:294
 TGFileDialog.cxx:295
 TGFileDialog.cxx:296
 TGFileDialog.cxx:297
 TGFileDialog.cxx:298
 TGFileDialog.cxx:299
 TGFileDialog.cxx:300
 TGFileDialog.cxx:301
 TGFileDialog.cxx:302
 TGFileDialog.cxx:303
 TGFileDialog.cxx:304
 TGFileDialog.cxx:305
 TGFileDialog.cxx:306
 TGFileDialog.cxx:307
 TGFileDialog.cxx:308
 TGFileDialog.cxx:309
 TGFileDialog.cxx:310
 TGFileDialog.cxx:311
 TGFileDialog.cxx:312
 TGFileDialog.cxx:313
 TGFileDialog.cxx:314
 TGFileDialog.cxx:315
 TGFileDialog.cxx:316
 TGFileDialog.cxx:317
 TGFileDialog.cxx:318
 TGFileDialog.cxx:319
 TGFileDialog.cxx:320
 TGFileDialog.cxx:321
 TGFileDialog.cxx:322
 TGFileDialog.cxx:323
 TGFileDialog.cxx:324
 TGFileDialog.cxx:325
 TGFileDialog.cxx:326
 TGFileDialog.cxx:327
 TGFileDialog.cxx:328
 TGFileDialog.cxx:329
 TGFileDialog.cxx:330
 TGFileDialog.cxx:331
 TGFileDialog.cxx:332
 TGFileDialog.cxx:333
 TGFileDialog.cxx:334
 TGFileDialog.cxx:335
 TGFileDialog.cxx:336
 TGFileDialog.cxx:337
 TGFileDialog.cxx:338
 TGFileDialog.cxx:339
 TGFileDialog.cxx:340
 TGFileDialog.cxx:341
 TGFileDialog.cxx:342
 TGFileDialog.cxx:343
 TGFileDialog.cxx:344
 TGFileDialog.cxx:345
 TGFileDialog.cxx:346
 TGFileDialog.cxx:347
 TGFileDialog.cxx:348
 TGFileDialog.cxx:349
 TGFileDialog.cxx:350
 TGFileDialog.cxx:351
 TGFileDialog.cxx:352
 TGFileDialog.cxx:353
 TGFileDialog.cxx:354
 TGFileDialog.cxx:355
 TGFileDialog.cxx:356
 TGFileDialog.cxx:357
 TGFileDialog.cxx:358
 TGFileDialog.cxx:359
 TGFileDialog.cxx:360
 TGFileDialog.cxx:361
 TGFileDialog.cxx:362
 TGFileDialog.cxx:363
 TGFileDialog.cxx:364
 TGFileDialog.cxx:365
 TGFileDialog.cxx:366
 TGFileDialog.cxx:367
 TGFileDialog.cxx:368
 TGFileDialog.cxx:369
 TGFileDialog.cxx:370
 TGFileDialog.cxx:371
 TGFileDialog.cxx:372
 TGFileDialog.cxx:373
 TGFileDialog.cxx:374
 TGFileDialog.cxx:375
 TGFileDialog.cxx:376
 TGFileDialog.cxx:377
 TGFileDialog.cxx:378
 TGFileDialog.cxx:379
 TGFileDialog.cxx:380
 TGFileDialog.cxx:381
 TGFileDialog.cxx:382
 TGFileDialog.cxx:383
 TGFileDialog.cxx:384
 TGFileDialog.cxx:385
 TGFileDialog.cxx:386
 TGFileDialog.cxx:387
 TGFileDialog.cxx:388
 TGFileDialog.cxx:389
 TGFileDialog.cxx:390
 TGFileDialog.cxx:391
 TGFileDialog.cxx:392
 TGFileDialog.cxx:393
 TGFileDialog.cxx:394
 TGFileDialog.cxx:395
 TGFileDialog.cxx:396
 TGFileDialog.cxx:397
 TGFileDialog.cxx:398
 TGFileDialog.cxx:399
 TGFileDialog.cxx:400
 TGFileDialog.cxx:401
 TGFileDialog.cxx:402
 TGFileDialog.cxx:403
 TGFileDialog.cxx:404
 TGFileDialog.cxx:405
 TGFileDialog.cxx:406
 TGFileDialog.cxx:407
 TGFileDialog.cxx:408
 TGFileDialog.cxx:409
 TGFileDialog.cxx:410
 TGFileDialog.cxx:411
 TGFileDialog.cxx:412
 TGFileDialog.cxx:413
 TGFileDialog.cxx:414
 TGFileDialog.cxx:415
 TGFileDialog.cxx:416
 TGFileDialog.cxx:417
 TGFileDialog.cxx:418
 TGFileDialog.cxx:419
 TGFileDialog.cxx:420
 TGFileDialog.cxx:421
 TGFileDialog.cxx:422
 TGFileDialog.cxx:423
 TGFileDialog.cxx:424
 TGFileDialog.cxx:425
 TGFileDialog.cxx:426
 TGFileDialog.cxx:427
 TGFileDialog.cxx:428
 TGFileDialog.cxx:429
 TGFileDialog.cxx:430
 TGFileDialog.cxx:431
 TGFileDialog.cxx:432
 TGFileDialog.cxx:433
 TGFileDialog.cxx:434
 TGFileDialog.cxx:435
 TGFileDialog.cxx:436
 TGFileDialog.cxx:437
 TGFileDialog.cxx:438
 TGFileDialog.cxx:439
 TGFileDialog.cxx:440
 TGFileDialog.cxx:441
 TGFileDialog.cxx:442
 TGFileDialog.cxx:443
 TGFileDialog.cxx:444
 TGFileDialog.cxx:445
 TGFileDialog.cxx:446
 TGFileDialog.cxx:447
 TGFileDialog.cxx:448
 TGFileDialog.cxx:449
 TGFileDialog.cxx:450
 TGFileDialog.cxx:451
 TGFileDialog.cxx:452
 TGFileDialog.cxx:453
 TGFileDialog.cxx:454
 TGFileDialog.cxx:455
 TGFileDialog.cxx:456
 TGFileDialog.cxx:457
 TGFileDialog.cxx:458
 TGFileDialog.cxx:459
 TGFileDialog.cxx:460
 TGFileDialog.cxx:461
 TGFileDialog.cxx:462
 TGFileDialog.cxx:463
 TGFileDialog.cxx:464
 TGFileDialog.cxx:465
 TGFileDialog.cxx:466
 TGFileDialog.cxx:467
 TGFileDialog.cxx:468
 TGFileDialog.cxx:469
 TGFileDialog.cxx:470
 TGFileDialog.cxx:471
 TGFileDialog.cxx:472
 TGFileDialog.cxx:473
 TGFileDialog.cxx:474
 TGFileDialog.cxx:475
 TGFileDialog.cxx:476
 TGFileDialog.cxx:477
 TGFileDialog.cxx:478
 TGFileDialog.cxx:479
 TGFileDialog.cxx:480
 TGFileDialog.cxx:481
 TGFileDialog.cxx:482
 TGFileDialog.cxx:483
 TGFileDialog.cxx:484
 TGFileDialog.cxx:485
 TGFileDialog.cxx:486
 TGFileDialog.cxx:487
 TGFileDialog.cxx:488
 TGFileDialog.cxx:489
 TGFileDialog.cxx:490
 TGFileDialog.cxx:491
 TGFileDialog.cxx:492
 TGFileDialog.cxx:493
 TGFileDialog.cxx:494
 TGFileDialog.cxx:495
 TGFileDialog.cxx:496
 TGFileDialog.cxx:497
 TGFileDialog.cxx:498
 TGFileDialog.cxx:499
 TGFileDialog.cxx:500
 TGFileDialog.cxx:501
 TGFileDialog.cxx:502
 TGFileDialog.cxx:503
 TGFileDialog.cxx:504
 TGFileDialog.cxx:505
 TGFileDialog.cxx:506
 TGFileDialog.cxx:507
 TGFileDialog.cxx:508
 TGFileDialog.cxx:509
 TGFileDialog.cxx:510
 TGFileDialog.cxx:511
 TGFileDialog.cxx:512
 TGFileDialog.cxx:513
 TGFileDialog.cxx:514
 TGFileDialog.cxx:515
 TGFileDialog.cxx:516
 TGFileDialog.cxx:517
 TGFileDialog.cxx:518
 TGFileDialog.cxx:519
 TGFileDialog.cxx:520
 TGFileDialog.cxx:521
 TGFileDialog.cxx:522
 TGFileDialog.cxx:523
 TGFileDialog.cxx:524
 TGFileDialog.cxx:525
 TGFileDialog.cxx:526
 TGFileDialog.cxx:527
 TGFileDialog.cxx:528
 TGFileDialog.cxx:529
 TGFileDialog.cxx:530
 TGFileDialog.cxx:531
 TGFileDialog.cxx:532
 TGFileDialog.cxx:533
 TGFileDialog.cxx:534
 TGFileDialog.cxx:535
 TGFileDialog.cxx:536
 TGFileDialog.cxx:537
 TGFileDialog.cxx:538
 TGFileDialog.cxx:539
 TGFileDialog.cxx:540
 TGFileDialog.cxx:541
 TGFileDialog.cxx:542
 TGFileDialog.cxx:543
 TGFileDialog.cxx:544
 TGFileDialog.cxx:545
 TGFileDialog.cxx:546
 TGFileDialog.cxx:547
 TGFileDialog.cxx:548
 TGFileDialog.cxx:549
 TGFileDialog.cxx:550
 TGFileDialog.cxx:551
 TGFileDialog.cxx:552
 TGFileDialog.cxx:553
 TGFileDialog.cxx:554
 TGFileDialog.cxx:555
 TGFileDialog.cxx:556
 TGFileDialog.cxx:557
 TGFileDialog.cxx:558
 TGFileDialog.cxx:559
 TGFileDialog.cxx:560
 TGFileDialog.cxx:561
 TGFileDialog.cxx:562
 TGFileDialog.cxx:563
 TGFileDialog.cxx:564
 TGFileDialog.cxx:565
 TGFileDialog.cxx:566
 TGFileDialog.cxx:567
 TGFileDialog.cxx:568
 TGFileDialog.cxx:569
 TGFileDialog.cxx:570
 TGFileDialog.cxx:571
 TGFileDialog.cxx:572
 TGFileDialog.cxx:573
 TGFileDialog.cxx:574
 TGFileDialog.cxx:575
 TGFileDialog.cxx:576
 TGFileDialog.cxx:577
 TGFileDialog.cxx:578
 TGFileDialog.cxx:579
 TGFileDialog.cxx:580
 TGFileDialog.cxx:581
 TGFileDialog.cxx:582
 TGFileDialog.cxx:583
 TGFileDialog.cxx:584
 TGFileDialog.cxx:585
 TGFileDialog.cxx:586
 TGFileDialog.cxx:587
 TGFileDialog.cxx:588
 TGFileDialog.cxx:589
 TGFileDialog.cxx:590
 TGFileDialog.cxx:591
 TGFileDialog.cxx:592
 TGFileDialog.cxx:593
 TGFileDialog.cxx:594
 TGFileDialog.cxx:595
 TGFileDialog.cxx:596
 TGFileDialog.cxx:597
 TGFileDialog.cxx:598
 TGFileDialog.cxx:599
 TGFileDialog.cxx:600
 TGFileDialog.cxx:601
 TGFileDialog.cxx:602
 TGFileDialog.cxx:603
 TGFileDialog.cxx:604
 TGFileDialog.cxx:605
 TGFileDialog.cxx:606
 TGFileDialog.cxx:607
 TGFileDialog.cxx:608
 TGFileDialog.cxx:609
 TGFileDialog.cxx:610
 TGFileDialog.cxx:611
 TGFileDialog.cxx:612
 TGFileDialog.cxx:613
 TGFileDialog.cxx:614
 TGFileDialog.cxx:615
 TGFileDialog.cxx:616
 TGFileDialog.cxx:617
 TGFileDialog.cxx:618
 TGFileDialog.cxx:619
 TGFileDialog.cxx:620
 TGFileDialog.cxx:621
 TGFileDialog.cxx:622
 TGFileDialog.cxx:623
 TGFileDialog.cxx:624
 TGFileDialog.cxx:625
 TGFileDialog.cxx:626
 TGFileDialog.cxx:627
 TGFileDialog.cxx:628
 TGFileDialog.cxx:629
 TGFileDialog.cxx:630
 TGFileDialog.cxx:631
 TGFileDialog.cxx:632
 TGFileDialog.cxx:633
 TGFileDialog.cxx:634
 TGFileDialog.cxx:635
 TGFileDialog.cxx:636