Index: /trunk/MagicSoft/Mars/mmain/MBrowser.cc
===================================================================
--- /trunk/MagicSoft/Mars/mmain/MBrowser.cc	(revision 718)
+++ /trunk/MagicSoft/Mars/mmain/MBrowser.cc	(revision 719)
@@ -8,8 +8,8 @@
 #include <TGMsgBox.h>       // TGMsgBox
 #include <TGListBox.h>      // TGListBox
+#include <TGComboBox.h>     // TGComboBox
 #include <TGFSContainer.h>  // TGFileContainer
 
-// FIXME: Move to MAGIC.h
-#define S_ISDIR(m) ((m)&0170000 == 0040000)
+#include <sys/stat.h>       // S_ISDIR
 
 #include <iostream.h>
@@ -19,5 +19,6 @@
     M_PBUTTON_CDIR_UP     = 0x1001,
     M_PBUTTON_LIST_MODE   = 0x1002,
-    M_PBUTTON_DETAIL_MODE = 0x1003
+    M_PBUTTON_DETAIL_MODE = 0x1003,
+    M_DIRBOX              = 0x1004
 };
 
@@ -64,12 +65,10 @@
 
     fTop1 = new TGHorizontalFrame (fFrameTop, 300, 100 ) ;
+    fTop2 = new TGHorizontalFrame (fFrameTop, 300, 100 ) ;
+    fTop3 = new TGHorizontalFrame (fFrameTop, 300, 100 ) ;
+
     fFrameTop->AddFrame (fTop1, new TGLayoutHints(kLHintsCenterX, 10, 10, 5, 5) );
-
-    fTop2 = new TGHorizontalFrame (fFrameTop, 300, 100 ) ;
     fFrameTop->AddFrame (fTop2, new TGLayoutHints(kLHintsCenterX, 10, 10, 5, 5) );
-
-    fTop3 = new TGHorizontalFrame (fFrameTop, 300, 100 ) ;
     fFrameTop->AddFrame (fTop3, new TGLayoutHints(kLHintsCenterX, 10, 10, 5, 5) );
-
     AddFrame(fFrameTop, new TGLayoutHints (kLHintsTop ) ) ;
 
@@ -83,75 +82,71 @@
     //    create the first tab
 
-  fTab = new TGTab ( fFrameLow, 400, 400 ) ;   
-
-  TGCompositeFrame *tf = fTab->AddTab("Input File") ; 
-  
-  fTabF1 = new TGCompositeFrame (tf, 100, 100, kHorizontalFrame) ; 
-  //  tf->AddFrame(fTabF1, fLayTab ) ; 
-
-  fTabF1a = new TGCompositeFrame (tf, 100, 100, kHorizontalFrame) ; 
-  tf->AddFrame(fTabF1a,  new TGLayoutHints ( kLHintsTop | kLHintsLeft | kLHintsExpandX, 5, 5, 5, 5 ) ) ; 
-
-  fTabF1b = new TGCompositeFrame (tf, 100, 100, kVerticalFrame) ; 
-  //  tf->AddFrame(fTabF1b,  new TGLayoutHints ( kLHintsTop | kLHintsLeft | kLHintsExpandX | kLHintsExpandY  , 5, 5, 5, 5 ) ) ; 
-  tf->AddFrame(fTabF1b,  new TGLayoutHints ( kLHintsExpandX | kLHintsExpandY  , 5, 5, 5, 5 ) ) ; 
-
-  fDir = new TGListBox(fTabF1a, -1) ; 
-  fDir->Resize(350,20) ;
-  char temp[100] ; 
-  //  sprintf ( temp, "%s", START_DIRECTORY ) ; 
-  sprintf ( temp, "%s", gSystem->WorkingDirectory()  ) ; 
-  fDir->AddEntry(temp, 1) ; 
-  fTabF1a->AddFrame( fDir, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 5, 5, 5, 5 ) ) ; 
-
-  fPicCdup = fClient->GetPicture("tb_uplevel.xpm") ; 
-  fCdup = new TGPictureButton(fTabF1a, fPicCdup, M_PBUTTON_CDIR_UP ) ; 
-  fCdup->SetToolTipText("One Level up!") ; 
-  fCdup->Associate(this) ; 
-  fTabF1a->AddFrame (fCdup, new TGLayoutHints(kLHintsLeft | kLHintsTop, 5, 5, 5, 5) ) ; 
-
-  fPicList = fClient->GetPicture("tb_list.xpm") ; 
-  fListMode = new TGPictureButton(fTabF1a, fPicList, M_PBUTTON_LIST_MODE ) ; 
-  fListMode->SetToolTipText("List Mode") ; 
-  fListMode->Associate(this) ; 
-  fListMode->SetState(kButtonUp) ; 
-  fListMode->AllowStayDown(kTRUE) ; 
-  fListMode->AllowStayDown(kTRUE) ;  fTabF1a->AddFrame (fListMode, new TGLayoutHints(kLHintsLeft | kLHintsTop, 5, 5, 5, 5) ) ;
-
-  fPicDetail = fClient->GetPicture("tb_details.xpm") ; 
-  fDetail = new TGPictureButton(fTabF1a, fPicDetail, M_PBUTTON_DETAIL_MODE ) ; 
-  fDetail->SetToolTipText("Details Mode") ; 
-  fDetail->Associate(this) ; 
-  fDetail->SetState(kButtonEngaged) ; 
-  fDetail->AllowStayDown(kTRUE) ; 
-  fTabF1a->AddFrame (fDetail, new TGLayoutHints(kLHintsLeft | kLHintsTop, 5, 5, 5, 5) ) ; 
-
-  fFileView = new TGListView(fTabF1b, 540, 380 ) ; 
-  fFileCont = new TGFileContainer(fFileView->GetViewPort(), 100, 100,
-				  kVerticalFrame, fgWhitePixel) ; 
-
-  fFileCont->Associate(this) ; 
-  fFileView->GetViewPort()->SetBackgroundColor(fgWhitePixel) ; 
-  fFileView->SetContainer(fFileCont) ; 
-  fFileCont->SetFilter("*") ; 
-  //  fFileCont->ChangeDirectory(START_DIRECTORY) ; 
-  fFileCont->ChangeDirectory(gSystem->WorkingDirectory()) ; 
-  fFileView->SetViewMode(kLVDetails); 
-  fFileCont->Sort(kSortByName) ; 
-
-  fTabF1b->AddFrame(fFileView, new TGLayoutHints(kLHintsTop | kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5) ) ; 
-
-  tf->AddFrame(fTabF1, fLayTab) ;
- 
-  fFrameLow->AddFrame ( fTab, new TGLayoutHints(kLHintsBottom | kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5) ); 
-
-  AddFrame(fFrameLow, new TGLayoutHints (kLHintsExpandX|kLHintsExpandY) ) ; 
-
-  //
-  //   Map the window, set up the layout, etc. 
-  //
-
-  SetWMSizeHints(400, 350, 1000, 1000, 10, 10 ) ;      // set the smallest and biggest size of the Main frame
-} 
+    fTab = new TGTab ( fFrameLow, 400, 400 ) ;
+
+    TGCompositeFrame *tf = fTab->AddTab("Input File") ;
+
+    fTabF1  = new TGCompositeFrame (tf, 100, 100, kHorizontalFrame) ;
+    fTabF1a = new TGCompositeFrame(tf, 100, 100, kHorizontalFrame);
+    fTabF1b = new TGCompositeFrame(tf, 100, 100, kVerticalFrame);
+
+    tf->AddFrame(fTabF1a,  new TGLayoutHints ( kLHintsTop | kLHintsLeft | kLHintsExpandX, 5, 5, 5, 5 ) ) ;
+    tf->AddFrame(fTabF1b,  new TGLayoutHints ( kLHintsExpandX | kLHintsExpandY  , 5, 5, 5, 5 ) ) ;
+
+    fDir = new TGComboBox(fTabF1a, M_DIRBOX);
+    fDir->Resize(350, 20) ;
+    fDir->Associate(this);
+
+    fPicCdup   = fClient->GetPicture("tb_uplevel.xpm");
+    fPicList   = fClient->GetPicture("tb_list.xpm");
+    fPicDetail = fClient->GetPicture("tb_details.xpm") ;
+
+    fCdup = new TGPictureButton(fTabF1a, fPicCdup, M_PBUTTON_CDIR_UP ) ;
+    fCdup->SetToolTipText("One Level up!") ;
+    fCdup->Associate(this) ;
+
+    fListMode = new TGPictureButton(fTabF1a, fPicList, M_PBUTTON_LIST_MODE);
+    fListMode->SetToolTipText("List Mode") ;
+    fListMode->Associate(this);
+    fListMode->SetState(kButtonUp);
+    fListMode->AllowStayDown(kTRUE);
+
+    fDetail = new TGPictureButton(fTabF1a, fPicDetail, M_PBUTTON_DETAIL_MODE ) ;
+    fDetail->SetToolTipText("Details Mode") ;
+    fDetail->Associate(this) ;
+    fDetail->SetState(kButtonEngaged) ;
+    fDetail->AllowStayDown(kTRUE) ;
+
+    fTabF1a->AddFrame(fDir,      new TGLayoutHints(kLHintsTop|kLHintsLeft|kLHintsExpandX, 5, 5, 5, 5)) ;
+    fTabF1a->AddFrame(fCdup,     new TGLayoutHints(kLHintsLeft|kLHintsTop, 5, 5, 5, 5));
+    fTabF1a->AddFrame(fListMode, new TGLayoutHints(kLHintsLeft|kLHintsTop, 5, 5, 5, 5));
+    fTabF1a->AddFrame(fDetail,   new TGLayoutHints(kLHintsLeft|kLHintsTop, 5, 5, 5, 5));
+
+    fFileView = new TGListView(fTabF1b, 540, 380 ) ;
+    fFileCont = new TGFileContainer(fFileView->GetViewPort(), 100, 100,
+                                    kVerticalFrame, fgWhitePixel) ;
+
+    fFileCont->Associate(this) ;
+    fFileView->GetViewPort()->SetBackgroundColor(fgWhitePixel) ;
+    fFileView->SetContainer(fFileCont) ;
+    fFileCont->SetFilter("*") ;
+//    fFileCont->ChangeDirectory(gSystem->WorkingDirectory()) ;
+    fFileView->SetViewMode(kLVDetails);
+    fFileCont->Sort(kSortByName) ;
+
+    fTabF1b->AddFrame(fFileView, new TGLayoutHints(kLHintsTop | kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5) ) ;
+
+    tf->AddFrame(fTabF1, fLayTab) ;
+
+    fFrameLow->AddFrame ( fTab, new TGLayoutHints(kLHintsBottom | kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5) );
+
+    AddFrame(fFrameLow, new TGLayoutHints (kLHintsExpandX|kLHintsExpandY) ) ;
+
+    ChangeDir();
+    //
+    //   Map the window, set up the layout, etc.
+    //
+
+    SetWMSizeHints(400, 350, 1000, 1000, 10, 10 ) ;      // set the smallest and biggest size of the Main frame
+}
 
 
@@ -236,4 +231,18 @@
 }
 
+void MBrowser::ChangeDir(const char *txt)
+{
+    fFileCont->ChangeDirectory(txt?txt:gSystem->WorkingDirectory());
+
+    const char  *dir = fFileCont->GetDirectory();
+    //    const UInt_t num = fDir->GetSelected()+1;
+
+    //
+    // FIXME: This is a big workaround!
+    //
+    fDir->InsertEntry(dir, -1/*num*/, -1);
+    fDir->Select(-1/*num*/);
+}
+
 Bool_t MBrowser::ProcessMessage(Long_t msg, Long_t parm1, Long_t)
 {     
@@ -253,16 +262,5 @@
 	      //  goto the parent directory
               //
-              gSystem->ChangeDirectory("..") ;
-              fDir->RemoveEntry(1) ;
-              {
-                  const char *dir = gSystem->WorkingDirectory();
-
-                  fDir->AddEntry(dir, 1);
-                  fDir->MapSubwindows();
-                  fDir->Layout();
-
-                  fFileCont->ChangeDirectory(dir);
-                  fFileCont->DisplayDirectory();
-              }
+              ChangeDir("..");
 	      return kTRUE;
 	    
@@ -279,6 +277,14 @@
           return kTRUE;
 
+      case kCM_COMBOBOX:
+          //
+          // FIXME: Don't add the new entry to the list!
+          // But to do this we need the number of entries in the list.
+          //
+          if (parm1 == M_DIRBOX)
+              ChangeDir(((TGTextLBEntry*)fDir->GetSelectedEntry())->GetText()->GetString());
+          return kTRUE;
+
 	case kCM_MENU:
-
 	  if (parm1==M_FILE_CLOSE)
               CloseWindow();
@@ -312,18 +318,12 @@
 
           const char *str = item->GetItemName()->GetString();
-          const char *dir = gSystem->WorkingDirectory();
-
-          if (S_ISDIR(item->GetType()))   // file is directory
+
+          //
+          // if the user choose a directory
+          // change to this directory
+          //
+          if (S_ISDIR(item->GetType())) 
           {
-              //
-              //  goto directory
-              //
-              fFileCont->ChangeDirectory(str);
-              gSystem->ChangeDirectory(str);
-
-              fDir->RemoveEntry(1);
-              fDir->AddEntry(dir, 1);
-              fDir->MapSubwindows();
-              fDir->Layout();
+              ChangeDir(str);
               return kTRUE;
           }
@@ -335,7 +335,8 @@
           const char *extension=strrchr(str, '.');
 
-
           if (!extension)
               return kTRUE;
+
+          const char *dir = fFileCont->GetDirectory();
 
           if (!strcasecmp(extension, ".ps")) // postscript file
Index: /trunk/MagicSoft/Mars/mmain/MBrowser.h
===================================================================
--- /trunk/MagicSoft/Mars/mmain/MBrowser.h	(revision 718)
+++ /trunk/MagicSoft/Mars/mmain/MBrowser.h	(revision 719)
@@ -13,4 +13,5 @@
 class TGPopupMenu;
 class TGTab;
+class TGComboBox;
 class TGTextButton;
 class TGListBox;
@@ -47,5 +48,5 @@
     TGCompositeFrame  *fTabF1a;    // subpart of the file selector in low window
     TGCompositeFrame  *fTabF1b;    // subpart of the file selector in low window
-    TGListBox         *fDir;
+    TGComboBox        *fDir;
     TGPictureButton   *fCdup;
     TGPictureButton   *fListMode;
@@ -73,4 +74,6 @@
     void DisplInfo(const char *txt);
 
+    void ChangeDir(const char *txt=NULL);
+
     TGHorizontalFrame *fTop1;
     TGHorizontalFrame *fTop2;
