explorer: introducing new explorer based on ede::FileSystemBox
authorRejean Loyer <rejean.loyer@gmail.com>
Sat, 10 Sep 2011 07:36:11 +0000 (03:36 -0400)
committerRejean Loyer <rejean.loyer@gmail.com>
Sat, 10 Sep 2011 07:36:11 +0000 (03:36 -0400)
newexplorer/explorer.epj [new file with mode: 0644]
newexplorer/res/browse.png [new file with mode: 0644]
newexplorer/res/panel-tree.png [new file with mode: 0644]
newexplorer/res/view-cards.png [new file with mode: 0644]
newexplorer/res/view-details.png [new file with mode: 0644]
newexplorer/res/view-icons.png [new file with mode: 0644]
newexplorer/res/view-list.png [new file with mode: 0644]
newexplorer/res/view-showcase-left.png [new file with mode: 0644]
newexplorer/res/view-showcase-right.png [new file with mode: 0644]
newexplorer/src/Explorer.ec [new file with mode: 0644]
newexplorer/src/ExplorerWindow.ec [new file with mode: 0644]

diff --git a/newexplorer/explorer.epj b/newexplorer/explorer.epj
new file mode 100644 (file)
index 0000000..1b4ddf3
--- /dev/null
@@ -0,0 +1,59 @@
+{
+   "Version" : 0.2,
+   "ModuleName" : "explorer",
+   "Options" : {
+      "Warnings" : "All",
+      "TargetType" : "Executable",
+      "TargetFileName" : "explorer",
+      "Libraries" : [
+         "ecere"
+      ]
+   },
+   "Configurations" : [
+      {
+         "Name" : "Debug",
+         "Options" : {
+            "Debug" : true,
+            "Optimization" : "None",
+            "PreprocessorDefinitions" : [
+               "_DEBUG"
+            ]
+         }
+      },
+      {
+         "Name" : "Release",
+         "Options" : {
+            "Debug" : false,
+            "Optimization" : "Speed"
+         }
+      }
+   ],
+   "Files" : [
+      {
+         "Folder" : "extern",
+         "Files" : [
+            "../../../sdk/extras/gui/controls/SelectorBar.ec",
+            "../../../sdk/extras/gui/controls/ToolBar.ec",
+            "../../../sdk/extras/gui/IconBag.ec"
+         ]
+      },
+      {
+         "Folder" : "src",
+         "Files" : [
+            "Explorer.ec",
+            "ExplorerWindow.ec"
+         ]
+      }
+   ],
+   "ResourcesPath" : "res",
+   "Resources" : [
+      "browse.png",
+      "panel-tree.png",
+      "view-cards.png",
+      "view-details.png",
+      "view-icons.png",
+      "view-list.png",
+      "view-showcase-left.png",
+      "view-showcase-right.png"
+   ]
+}
\ No newline at end of file
diff --git a/newexplorer/res/browse.png b/newexplorer/res/browse.png
new file mode 100644 (file)
index 0000000..f227989
Binary files /dev/null and b/newexplorer/res/browse.png differ
diff --git a/newexplorer/res/panel-tree.png b/newexplorer/res/panel-tree.png
new file mode 100644 (file)
index 0000000..11a5108
Binary files /dev/null and b/newexplorer/res/panel-tree.png differ
diff --git a/newexplorer/res/view-cards.png b/newexplorer/res/view-cards.png
new file mode 100644 (file)
index 0000000..8638b8f
Binary files /dev/null and b/newexplorer/res/view-cards.png differ
diff --git a/newexplorer/res/view-details.png b/newexplorer/res/view-details.png
new file mode 100644 (file)
index 0000000..0a52090
Binary files /dev/null and b/newexplorer/res/view-details.png differ
diff --git a/newexplorer/res/view-icons.png b/newexplorer/res/view-icons.png
new file mode 100644 (file)
index 0000000..334c518
Binary files /dev/null and b/newexplorer/res/view-icons.png differ
diff --git a/newexplorer/res/view-list.png b/newexplorer/res/view-list.png
new file mode 100644 (file)
index 0000000..43dddab
Binary files /dev/null and b/newexplorer/res/view-list.png differ
diff --git a/newexplorer/res/view-showcase-left.png b/newexplorer/res/view-showcase-left.png
new file mode 100644 (file)
index 0000000..c3e85de
Binary files /dev/null and b/newexplorer/res/view-showcase-left.png differ
diff --git a/newexplorer/res/view-showcase-right.png b/newexplorer/res/view-showcase-right.png
new file mode 100644 (file)
index 0000000..721e705
Binary files /dev/null and b/newexplorer/res/view-showcase-right.png differ
diff --git a/newexplorer/src/Explorer.ec b/newexplorer/src/Explorer.ec
new file mode 100644 (file)
index 0000000..cb9fa3d
--- /dev/null
@@ -0,0 +1,107 @@
+import "ecere"
+import "EDE"
+import "ExplorerWindow"
+
+class Explorer : GuiApplication
+{
+   bool Init()
+   {
+      QuickPathTool goPath { };
+      QuickPathTool searchPath { };
+      char * findWhat = null;
+      SetLoggingMode(debug, null);
+      if(argc > 1)
+      {
+         if(!strcmpi(argv[1], "go") && argc > 2)
+            goPath = argv[2];
+         else if(!strcmpi(argv[1], "find") && argc > 2)
+         {
+            char * unquoted;
+            if(argv[2][0] == '\"')
+               StripQuotes(argv[2], unquoted);
+            else
+               unquoted = argv[2];
+            findWhat = CopyString(unquoted);
+            if(argc > 3)
+            {
+               if(!strcmpi(argv[3], "in") && argc > 4)
+                  searchPath = argv[4];
+               else
+                  searchPath = ""; // this should make it current dir
+            }
+            else
+               searchPath = ""; // same
+         } 
+         else if(!strcmpi(argv[1], "search") && argc > 2)
+            searchPath = argv[2];
+         else if(!strcmpi(argv[1], "image") && argc > 2)
+            ;
+         else if(!strcmpi(argv[1], "slides") && argc > 2)
+            ;
+         else
+            goPath = argv[1];
+      }
+      else
+         goPath = "";
+      if(goPath)
+      {
+         ExplorerWindow explorerWnd { };
+         explorerWnd.Create();
+         //explorerWnd.GoToLocation(goPath);
+      }
+      else if(searchPath)
+      {
+         ExplorerWindow explorerWnd { };
+         explorerWnd.Create();
+         //explorerWnd.SearchLocation(searchPath);
+      }
+      return true;
+   }
+}
+
+struct QuickPathTool
+{
+   char path[MAX_LOCATION];
+
+   property char * 
+   {
+      set
+      {
+         char * unquoted;
+         GetWorkingDir(path, MAX_LOCATION);
+         if(value[0] == '\"')
+            StripQuotes(value, unquoted);
+         else
+            unquoted = value;
+         PathCat(path, unquoted);
+         if(!FileExists(path))
+         {
+            // this incomplete functionality is not quite at it's place in this class
+            int len;
+            char * original = CopyString(path);
+            while((len = strlen(path)))
+            {
+               StripLastDirectory(path, path);
+               if(FileExists(path))
+               {
+                  // TODO: message location does not exist, 
+                  //       this higher location exists though
+                  //       go there?
+                  break;
+               }
+            }
+            if(!len)
+            {
+               // TODO: message location does not exist, 
+               //       unable to select alternate location
+            }
+            path[0] = '\0';
+            delete original;
+         }
+      }
+      get { return path[0] ? path : null; }
+   }
+   property bool { get { return (bool)path[0]; } }
+};
+
+define app = ((Explorer)__thisModule);
diff --git a/newexplorer/src/ExplorerWindow.ec b/newexplorer/src/ExplorerWindow.ec
new file mode 100644 (file)
index 0000000..0bd9c17
--- /dev/null
@@ -0,0 +1,208 @@
+import "Explorer"
+import "IconBag"
+import "ToolBar"
+
+enum ExplorerToolId
+{
+   none,
+   newWindow, goBack, goForward, goUp, goHome,
+   browse,
+   panelTree, panelSearch,
+   addressBar,
+   refreshView,
+   viewList, viewDetails, viewIcons, viewCards, viewShowcase, viewCustom,
+   previewPictures
+};
+
+class ExplorerWindow : Window
+{
+   text = "Ecere Explorer";
+   background = activeBorder;
+   borderStyle = sizable;
+   hasMaximize = true;
+   hasMinimize = true;
+   hasClose = true;
+   size = { 840, 480 };
+   nativeDecorations = true;
+
+   IconBag<ExplorerToolId> iconBag
+   {
+      //window = guiApp.desktop;
+      window = this;
+      alphaBlend = true;
+      iconNames =
+      [
+         "<:ecere>emblems/unreadable.png",     /* none */
+
+         "<:ecere>actions/windowNew.png",            /* newWindow */
+         "<:ecere>actions/goPrevious.png",           /* goBack */
+         "<:ecere>actions/goNext.png",               /* goForward */
+         "<:ecere>actions/goUp.png",                 /* goUp */
+         "<:ecere>actions/goHome.png",               /* goHome */
+
+         ":browse.png",                                           /* browse */
+
+         ":panel-tree.png",                                       /* panelTree */
+         "<:ecere>actions/editFind.png",             /* panelSearch */
+
+         "<:ecere>emblems/unreadable.png",     /* addressBar */
+
+         "<:ecere>actions/viewRefresh.png",          /* refreshView */
+
+         ":view-list.png",                                        /* viewList */
+         ":view-details.png",                                     /* viewDetails */
+         ":view-icons.png",                                       /* viewIcons */
+         ":view-cards.png",                                       /* viewCards */
+         ":view-showcase-right.png",                              /* viewShowcase */
+         ":view-custom.png",                                      /* viewCustom */
+         
+         "<:ecere>mimeTypes/image.png"     /* previewPictures */
+      ];
+   };
+
+   Stacker stack
+   {
+      this;
+      gap = 0;
+      direction = vertical;
+      background = activeBorder;
+      //opacity = 1.0f;
+      
+      anchor = { left = 0, top = 0, right = 0, bottom = 0 };
+      //moveable = false;
+   };
+
+   ToolBar<ExplorerToolId> toolBar
+   {
+      stack, this;
+      iconBag = iconBag;
+      size = { h = 32 };
+      //moveable = false;
+   };
+
+   Window s1 { toolBar, size = { w = 8 } };
+   ToolButton goBack    { toolBar, this, id = ExplorerToolId::goBack };
+   Window s2 { toolBar, size = { w = 2 } };
+   ToolButton goForward { toolBar, this, id = ExplorerToolId::goForward };
+   Window s3 { toolBar, size = { w = 2 } };
+   ToolButton refreshView
+   {
+      toolBar, this, id = ExplorerToolId::refreshView;
+
+      bool NotifyClicked(Button button, int x, int y, Modifiers mods)
+      {
+         fsb.Refresh();
+         return true;
+      }
+   };
+   Window s4 { toolBar, size = { w = 2 } };
+   ToolButton goHome    { toolBar, this, id = ExplorerToolId::goHome };
+   Window s5 { toolBar, size = { w = 8 } };
+   PathBox addressBar
+   {
+      toolBar, this;
+      size = { 300, 23 }, id = ExplorerToolId::addressBar;
+      typeExpected = directory;
+
+      bool OnKeyDown(Key key, unichar ch)
+      {
+         if((SmartKey)key == enter)
+         {
+            // how to make enter effect a modification
+            // how to implement in PathBox
+         }
+         return true;
+      }
+
+      bool NotifyModified(PathBox pathBox)
+      {
+         fsb.path = pathBox.path;
+         return true;
+      }
+   };
+   Window s6 { toolBar, size = { w = 8 } };
+   ToolButton goUp
+   {
+      toolBar, this, id = ExplorerToolId::goUp;
+
+      bool NotifyClicked(Button button, int x, int y, Modifiers mods)
+      {
+         char * path = fsb.path;
+         char * newPath = new char[strlen(path)];
+         StripLastDirectory(path, newPath);
+         fsb.path = newPath;
+         delete newPath;
+         return true;
+      }
+   };
+   Window s7 { toolBar, size = { w = 8 } };
+   GroupToggleToolButton selectedPanel;
+   GroupToggleToolButton panelTree   { toolBar, this, id = ExplorerToolId::panelTree, selected = &selectedPanel, checked = true };
+   GroupToggleToolButton panelSearch { toolBar, this, id = ExplorerToolId::panelSearch, selected = &selectedPanel };
+   selectedPanel = panelTree;
+   Window s8 { toolBar, size = { w = 8 } };
+   OptionToolButton selectedView;
+   OptionToolButton viewList     { toolBar, this, id = ExplorerToolId::viewList, selected = &selectedView, checked = true };
+   OptionToolButton viewDetails  { toolBar, this, id = ExplorerToolId::viewDetails, selected = &selectedView };
+   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 };
+   selectedView = viewList;
+   Window s9 { toolBar, size = { w = 8 } };
+   ToggleToolButton previewPictures
+   {
+      toolBar, this, id = ExplorerToolId::previewPictures;
+
+      bool NotifyClicked(Button button, int x, int y, Modifiers mods)
+      {
+         fsb.previewPictures = button.checked;
+         return true;
+      }
+   };
+
+   Window s10 { toolBar, size = { w = 8 } };
+   ToolButton newWindow
+   {
+      toolBar, this, id = ExplorerToolId::newWindow;
+
+      bool NotifyClicked(Button button, int x, int y, Modifiers mods)
+      {
+         ExplorerWindow { }.Create();
+         return true;
+      }
+   };
+
+   /*void OnDestroy()
+   {
+      iconBag.window = null;
+      delete iconBag;
+   }*/
+
+   bool OnLoadGraphics()
+   {
+      iconBag.Load();
+      return true;
+   }
+
+   void OnUnloadGraphics()
+   {
+      iconBag.Unload();
+   }
+
+   FileSystemBox fsb
+   {
+      stack, this;
+      //anchor = { left = 0, top = 4, right = 0, bottom = 0 };
+      anchor.left = 0;
+      anchor.bottom = 0;
+      anchor.right = 0;
+      locationBox = addressBar;
+      navigateFolders = true;
+   };
+
+   bool OnPostCreate()
+   {
+      addressBar.path = fsb.path;
+      return true;
+   }
+}