explorer: using ShellOpen under windows and Execute for calling ide under linux until...
[ede] / explorer / src / ExplorerWindow.ec
index ad9314d..20747ee 100644 (file)
@@ -10,13 +10,17 @@ enum ExplorerToolId
    panelTree, panelSearch,
    addressBar,
    refresh,
-   viewList, viewDetails, viewIcons, viewCards, viewShowcase, viewCustom,
+   viewList, viewDetails, viewIcons, viewCards, viewShowcase, viewTree, viewCustom,
    previewPictures
 };
 
 class ExplorerWindow : Window
 {
+#ifdef _DEBUG
+   text = "Ecere Explorer (Debug)";
+#else
    text = "Ecere Explorer";
+#endif
    background = activeBorder;
    borderStyle = sizable;
    hasMaximize = true;
@@ -82,6 +86,7 @@ class ExplorerWindow : Window
          ":view-icons.png",                                       /* viewIcons */
          ":view-cards.png",                                       /* viewCards */
          ":view-showcase-right.png",                              /* viewShowcase */
+         ":panel-tree.png",                                       /* viewTree */
          ":view-custom.png",                                      /* viewCustom */
          
          "<:ecere>mimeTypes/image.png"     /* previewPictures */
@@ -120,11 +125,23 @@ class ExplorerWindow : Window
             case goBack:
             case goForward:
                break;
+            case goHome:
+            {
+               char * home = getenv("HOME");
+               if(home && home[0] && FileExists(home).isDirectory)
+                  view.path = home;
+               break;
+            }
             case goUp:
             {
                char * path = view.path;
                char * newPath = new char[strlen(path)];
                StripLastDirectory(path, newPath);
+               if(!newPath[0])
+               {
+                  newPath[0] = '/';
+                  newPath[1] = 0;
+               }
                view.path = newPath;
                delete newPath;
                break;
@@ -156,6 +173,12 @@ class ExplorerWindow : Window
             case viewCards:
             case viewShowcase:
                //SwitchViews(toolId);
+               view.treeBranches = false;
+               view.Refresh();
+               break;
+            case viewTree:
+               view.treeBranches = button.checked;
+               view.Refresh();
                break;
          }
       }
@@ -207,6 +230,7 @@ class ExplorerWindow : Window
    OptionToolButton viewIcons    { toolBar, this, id = ExplorerToolId::viewIcons, selected = &selectedView };
    OptionToolButton viewTiles    { toolBar, this, id = ExplorerToolId::viewCards, selected = &selectedView };
    OptionToolButton viewShowcase { toolBar, this, id = ExplorerToolId::viewShowcase, selected = &selectedView };
+   OptionToolButton viewTree     { toolBar, this, id = ExplorerToolId::viewTree, selected = &selectedView };
    selectedView = viewList;
    Window s9 { toolBar, size = { w = 8 } };
    ToggleToolButton previewPictures { toolBar, this, id = ExplorerToolId::previewPictures };
@@ -252,8 +276,8 @@ class ExplorerWindow : Window
       panels, this;
    };*/
 
-   /*Tree*/FileSystemBox tree
-   {
+   /*Tree*/FileSystemBox tree;
+   /*{
       panels, this;
       size = { w = 240 };
       anchor.top = 0;
@@ -263,7 +287,7 @@ class ExplorerWindow : Window
       foldersOnly = true;
       borderStyle = none;
       visible = false;
-   };
+   };*/
 
    FileSystemBox view
    {
@@ -274,6 +298,31 @@ class ExplorerWindow : Window
       locationBox = addressBar;
       navigateFolders = true;
       borderStyle = none;
+
+      multiSelect = true;
+
+      bool NotifyNodeOpen(FileSystemBox box, FileSystemNode node)
+      {
+         if(node.type.isFile)
+         {
+         #ifndef __WIN32__
+            char command[MAX_LOCATION];
+            /*_FileType t = node.type;
+            if(t == ewsFile || t == epjFile ||
+                  t == ecFile || t == ehFile ||
+                  t == cppFile || t == hppFile ||
+                  t == cFile || t == hFile ||
+                  t == textFile || t == webFile)*/
+               sprintf(command, "ide %s", node.path);
+            /*else
+               sprintf(command, "%s", node.path);*/
+            Execute(command);
+         #else
+            ShellOpen(node.path);
+         #endif
+         }
+         return true;
+      }
    };
 
    /*ExplorerSearch search