-public import "ecere"
-import "SplitWindow"
+import "ecere"
+import "EDE"
+import "ExplorerWindow"
-import "ExplorerTree" // meant to be called ExplorerTools
-import "Finder"
-import "Search" // meant to be called ExplorerSearch
-import "Panels"
+//import "Finder"
+//import "Search"
+//import "Panels"
/*
#ifdef __WIN32__
#endif
*/
-enum ExplorerToolId
-{
- none,
- newWindow, goBack, goForward, goUp, goHome,
- browse,
- panelTree, panelSearch,
- addressBar,
- refreshView,
- viewList, viewDetails, viewIcons, viewCards, viewShowcase, viewCustom,
- previewPictures
-};
-
-static char * toolIconNames[] =
-{
- "<: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 */
-
- ""
-};
-
-class ToolButton : Button
-{
- size = Size { 24, 24 };
-
- property int toolId
- {
- set
- {
- bitmap = BitmapResource { fileName = toolIconNames[value], alphaBlend = true };
- id = value;
- }
- }
-
- bool TestToolBar::NotifyClicked(ToolButton button, int x, int y, Modifiers mods)
- {
- NotifyToolClick(this.parent, this, button.id);
- return true;
- }
-}
-
-class ToggleToolButton : ToolButton
-{
- toggle = true;
- size = Size { 24, 24 };
-
- bool TestToolBar::NotifyClicked(ToggleToolButton button, int x, int y, Modifiers mods)
- {
- NotifyToolClick(this.parent, this, button.id);
- return true;
- }
-}
-
-class GroupToggleToolButton : ToolButton
-{
- toggle = true;
- size = Size { 24, 24 };
- GroupToggleToolButton * selected;
- bool TestToolBar::NotifyClicked(GroupToggleToolButton button, int x, int y, Modifiers mods)
- {
- bool configured = (bool)button.selected;
- bool preselection = (configured && (*button.selected));
- bool reclick = preselection ? (*button.selected == button) : false;
- if(configured && preselection && !reclick)
- {
- (*button.selected).checked = false;
- *button.selected = button;
- }
- NotifyToolClick(this.parent, this, button.id);
- return true;
- }
-}
-
-class OptionToolButton : ToolButton
-{
- toggle = true;
- size = Size { 24, 24 };
- OptionToolButton * selected;
- bool TestToolBar::NotifyClicked(OptionToolButton button, int x, int y, Modifiers mods)
- {
- bool configured = (bool)button.selected;
- bool preselection = (configured && (*button.selected));
- bool reclick = preselection ? (*button.selected == button) : false;
- if(configured && !preselection)
- *button.selected = button;
- else if(configured && !reclick)
- {
- (*button.selected).checked = false;
- *button.selected = button;
- }
- button.checked = true;
- if(!reclick)
- NotifyToolClick(this.parent, this, button.id);
- return true;
- }
-}
-
-class TestToolBar : Window
-{
- int xL, xR;
-
- borderStyle = bevel;
- inactive = true;
- background = activeBorder;
- size = Size { h = 32 };
- anchor = Anchor { left = 0, top = 0, right = 0 };
+DummyFileSystemCacheWindow dw;// { size = { 200, 200 } };
- virtual void Window::NotifyToolClick(TestToolBar toolBar, int id);
- xL = 0;
-
- ToolButton newWindow { this, anchor = { left = (xL += 20) }, toolId = ExplorerToolId::newWindow };
-
- ToolButton goBack { this, anchor = { left = (xL += 46) }, toolId = ExplorerToolId::goBack };
- ToolButton goForward { this, anchor = { left = (xL += 26) }, toolId = ExplorerToolId::goForward };
- ToolButton goUp { this, anchor = { left = (xL += 30) }, toolId = ExplorerToolId::goUp };
- ToolButton goHome { this, anchor = { left = (xL += 30) }, toolId = ExplorerToolId::goHome };
-
- GroupToggleToolButton panelTree { this, anchor = { left = (xL += 46) }, toolId = ExplorerToolId::panelTree, selected = &selectedPanel, checked = true };
- GroupToggleToolButton panelSearch { this, anchor = { left = (xL += 26) }, toolId = ExplorerToolId::panelSearch, selected = &selectedPanel };
- GroupToggleToolButton selectedPanel;
- selectedPanel = panelTree;
-
- xR = 0;
-
- OptionToolButton viewList { this, anchor = { right = (xR += 20) }, toolId = ExplorerToolId::viewList, selected = &selectedView, checked = true };
- OptionToolButton viewDetails { this, anchor = { right = (xR += 26) }, toolId = ExplorerToolId::viewDetails, selected = &selectedView };
- OptionToolButton viewIcons { this, anchor = { right = (xR += 26) }, toolId = ExplorerToolId::viewIcons, selected = &selectedView };
- OptionToolButton viewTiles { this, anchor = { right = (xR += 26) }, toolId = ExplorerToolId::viewCards, selected = &selectedView };
- OptionToolButton viewShowcase { this, anchor = { right = (xR += 26) }, toolId = ExplorerToolId::viewShowcase, selected = &selectedView };
- OptionToolButton selectedView;
- selectedView = viewList;
-
- ToggleToolButton previewPictures { this, anchor = { right = (xR += 46) }, toolId = ExplorerToolId::previewPictures };
-
- ToolButton refreshView { this, anchor = { right = (xR += 46) }, toolId = ExplorerToolId::refreshView };
-
- EditBox addressBar
- {
- this, master;
- size = { w = 250 }, anchor = { left = (xL += 30), right = (xR += 30) }, id = ExplorerToolId::addressBar;
- };
-
- /*DropBox tileSet
- {
- this,
- anchor = { left = (xPos += 88) };
- inactive = true;
-
- bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
- {
- return true;
- }
- };*/
-
- TestToolBar()
- {
- /*tileSet.AddString("Forest").tag = 0;
- tileSet.AddString("Winter").tag = 0;
- tileSet.AddString("Wasteland").tag = 0;*/
- }
-};
-
-class ExplorerWindow : Window
+class Explorer : GuiApplication
{
- text = "Ecere Explorer";
- background = activeBorder;
- borderStyle = sizable;
- hasMaximize = true;
- hasMinimize = true;
- hasClose = true;
- hasMenuBar = true;
- tabCycle = true;
- size = Size { 888, 840 };
-
- bool userMode;
- bool clipboard;
-
- int treeSplit;
- int searchSplit;
-
- ExplorerToolId lastViewId;
-
- menu = Menu { };
-
- Menu fileMenu { menu, "File", f };
- Menu windowMenu { menu, "Window", w };
- MenuItem newWindow
- {
- windowMenu, "New Window", n;
-
- bool NotifySelect(MenuItem selection, Modifiers mods)
- {
- ExplorerWindow { }.Create();
- return true;
- }
- };
-
- TestToolBar toolBar
- {
- this;
-
- void NotifyToolClick(TestToolBar toolBar, int id)
- {
- ExplorerToolId toolId = (ExplorerToolId)id;
- switch(toolId)
- {
- case none:
- break;
- case newWindow:
- ExplorerWindow { }.Create();
- break;
- case goBack:
- case goForward:
- break;
- case goUp:
- {
- ExplorerFileBranch branch = tree.branch;
- if(branch && branch.parent)
- tree.Select(branch.parent);
- break;
- }
- case panelTree:
- if(tree.visible)
- {
- split.leftPane = null;
- split.visible = false;
- tree.visible = false;
- treeSplit = split.split;
- split.OnResize(split.size.w, split.size.h);
- }
- else
- {
- if(search.visible)
- {
- search.visible = false;
- searchSplit = split.split;
- }
- tree.visible = true;
- split.leftPane = tree;
- split.visible = true;
- split.split = treeSplit;
- split.OnResize(split.size.w, split.size.h);
- SwitchViews(lastViewId);
- }
- break;
- case panelSearch:
- if(search.visible)
- {
- split.leftPane = null;
- split.visible = false;
- search.visible = false;
- searchSplit = split.split;
- split.OnResize(split.size.w, split.size.h);
- SwitchViews(lastViewId);
- }
- else
- {
- if(tree.visible)
- {
- tree.visible = false;
- treeSplit = split.split;
- }
- search.visible = true;
- split.leftPane = search;
- split.visible = true;
- split.split = searchSplit;
-
- view = ExplorerSearchViewTree { viewHolder, this };
- view.previewPictures = toolBar.previewPictures.checked;
- view.anchor = Anchor { left = 0, top = 0, bottom = 0, right = 0 };
- view.NotifyItemOpen = ViewNotifyItemOpen;
- view.Create();
- search.view = (ExplorerSearchViewTree)view;
-
- split.OnResize(split.size.w, split.size.h);
- }
- break;
- case refreshView:
- if(view)
- view.Refresh();
- break;
- case previewPictures:
- if(view)
- view.previewPictures = toolBar.previewPictures.checked;
- break;
- case viewList:
- case viewDetails:
- case viewIcons:
- case viewCards:
- case viewShowcase:
- SwitchViews(toolId);
- break;
- }
- }
- };
-
- void SwitchViews(ExplorerToolId viewId)
- {
- ExplorerFileBranch branch = tree.branch;
- view.Destroy(0);
- switch(viewId)
- {
- case viewList: view = ExplorerViewList { parent = viewHolder, master = this }; break;
- case viewDetails: view = ExplorerViewDetails { parent = viewHolder, master = this }; break;
- case viewIcons: view = ExplorerViewIcons { parent = viewHolder, master = this }; break;
- case viewCards: view = ExplorerViewCards { parent = viewHolder, master = this }; break;
- case viewShowcase: view = ExplorerViewShowcase { parent = viewHolder, master = this }; break;
- }
- view.tabCycle = true;
- view.previewPictures = toolBar.previewPictures.checked;
- view.anchor = Anchor { left = 0, top = 0, bottom = 0, right = 0 };
- view.NotifyItemOpen = ViewNotifyItemOpen;
- view.Create();
- view.Load(branch);
- lastViewId = viewId;
- }
-
- Window deep
- {
- this;
- borderStyle = deep;
- tabCycle = true;
- anchor = Anchor { left = 0, top = 34, right = 0, bottom = 0 };
- };
-
- ExplorerTree tree
- {
- deep, this;
- //visible = false;
- tabCycle = true;
- size = Size { 624, 268 };
- anchor = Anchor { left = 0, top = 0, bottom = 0 };
- text = "Browser", hotKey = Key { e, alt = true };
- NotifyBranchSelect = TreeNotifyBranchSelect;
- };
-
- ExplorerView view;
+ //skin = "Acovel";
- ExplorerSearch search
+ bool Init()
{
- deep, this;
- visible = false;
- tabCycle = true;
- size = Size { 624, 268 };
- anchor = Anchor { left = 0, top = 0, bottom = 0 };
- };
+ int c, argc = this.argc;
+ int openArgsStartAt = 0;
+ QuickPathTool searchPath { };
+ char * findWhat = null;
+ Array<String> comparedPaths = null;
- ExplorerViewSearch results;
+ SetLoggingMode(debug, null);
- bool TreeNotifyBranchSelect(ExplorerTree tree, ExplorerFileBranch branch)
- {
- if(branch)
+ for(c = 1; c < argc; c++)
{
- char path[MAX_LOCATION];
- branch.GetPath(path);
- toolBar.addressBar.contents = path;
- view.Load(branch);
- }
- return true;
- }
-
- bool ViewNotifyItemOpen(ExplorerView view, ExplorerFileItem item)
- {
- ExplorerFileBranch branch = tree.branch;
- if(item && branch)
- {
- if(item.type.isFolderType)
- {
- ExplorerFileBranch child;
-
- if(!branch.loaded || !branch.childrenLoaded)
- BranchLoad(branch, tree.tree);
-
- for(child = branch.children.first; child; child = child.next)
- if(!strcmp(child.name, item.name))
- break;
-
- if(child)
- {
- if(branch.row.collapsed)
- child.row.collapsed = true;
- child.EnsureVisible(false);
- tree.Select(child);
- }
- }
- else
+ if(!strcmp(argv[c], "#"))
{
- char path[MAX_LOCATION];
- branch.GetPath(path);
- PathCat(path, item.name);
- ShellOpen(path);
- }
- }
- }
-
- Window viewHolder
- {
- parent = deep, master = this;
- tabCycle = true;
- anchor = Anchor { top = 0, bottom = 0, right = 0 };
- };
-
- SplitWindow split
- {
- deep, this;
- leftPane = tree, rightPane = viewHolder;
- split = 300;
- };
-
- void GoToLocation(char * location)
- {
- int c;
- char * temp;
- char step[MAX_LOCATION];
-
- StringArray steps { growingFactor = 4 };
- ExplorerFileBranch last = null;
-
- temp = CopyString(location);
- while(strlen(temp))
- {
- GetLastDirectory(temp, step);
- StripLastDirectory(temp, temp);
- steps.Add(CopyString(step));
- }
-
- for(c = steps._count - 1; c >= 0; c--)
- {
- last = tree.Find(steps._[c], last);
- if(!last)
+ argc = c;
break;
- tree.Select(last);
+ }
}
-
- delete temp;
- delete steps;
- }
-
- void SearchLocation(char * location)
- {
- GoToLocation(location);
- search.location.editBox.contents = location;
- }
-
- bool OnPostCreate()
- {
- userMode = true;
- return true;
- }
-
- ExplorerWindow()
- {
- userMode = false;
- treeSplit = 300;
- searchSplit = 200;
-
- view = ExplorerViewList
- {
- parent = viewHolder, master = this;
- tabCycle = true;
- previewPictures = toolBar.previewPictures.checked;
- anchor = Anchor { left = 0, top = 0, bottom = 0, right = 0 };
- NotifyItemOpen = ViewNotifyItemOpen;
- };
- lastViewId = viewList;
-
- tree.Load();
- view.Load(tree.root);
- }
-
- void InitTree()
- {
- }
-
- void InitSearch()
- {
- }
-}
-
-class ExplorerApp : GuiApplication
-{
- //skin = "Acovel";
-
- 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];
+ openArgsStartAt = 2;
else if(!strcmpi(argv[1], "find") && argc > 2)
{
- char * unquoted;
if(argv[2][0] == '\"')
- StripQuotes(argv[2], unquoted);
+ {
+ findWhat = new char[strlen(argv[2])+1];
+ StripQuotes(argv[2], findWhat);
+ }
else
- unquoted = argv[2];
- findWhat = CopyString(unquoted);
+ findWhat = CopyString(argv[2]);
if(argc > 3)
{
if(!strcmpi(argv[3], "in") && argc > 4)
}
else
searchPath = ""; // same
- }
+ }
else if(!strcmpi(argv[1], "search") && argc > 2)
searchPath = argv[2];
+ else if(!strcmpi(argv[1], "compare") && argc > 2)
+ {
+ QuickPathTool goPath { };
+ comparedPaths = { };
+ if(argc == 3)
+ {
+ goPath = ""; // current dir
+ comparedPaths.Add(CopyString((const char *)goPath)); // TODO: Review whether this gets freed?
+ }
+ for(c = 2; c < argc; c++)
+ {
+ const char * s;
+ goPath = argv[c];
+ s = goPath;
+ if(s)
+ comparedPaths.Add(CopyString(s));
+ }
+ if(comparedPaths.count < 2)
+ PrintLn("compare requires at least 2 existing directories to work.");
+ }
else if(!strcmpi(argv[1], "image") && argc > 2)
;
else if(!strcmpi(argv[1], "slides") && argc > 2)
;
else
- goPath = argv[1];
+ openArgsStartAt = 1;
}
else
- goPath = "";
- if(goPath)
+ openArgsStartAt = -1;
+
+ if(openArgsStartAt)
+ {
+ QuickPathTool goPath { };
+ for(c = openArgsStartAt; c < argc; c++)
+ {
+ goPath = openArgsStartAt == -1 ? "" : argv[c];
+ if(goPath)
+ {
+ ExplorerWindow explorerWnd { };
+ explorerWnd.Create();
+ explorerWnd.location = goPath;//explorerWnd.GoTo(goPath, false, false);
+ }
+ if(openArgsStartAt == -1)
+ break;
+ }
+ }
+ else if(searchPath)
{
ExplorerWindow explorerWnd { };
explorerWnd.Create();
- explorerWnd.GoToLocation(goPath);
+ //explorerWnd.SearchLocation(searchPath);
}
- else if(searchPath)
+ else if(comparedPaths && comparedPaths.count > 1)
{
+ // compare /s1/library/dummies /s1/library/movies /s1/oldlib/movies "/home/redj/.gvfs/d02-2tb on kimji/library/movies"
ExplorerWindow explorerWnd { };
explorerWnd.Create();
- explorerWnd.SearchLocation(searchPath);
+ explorerWnd.view.columnsCompareStyle = true;
+ explorerWnd.comparedLocations = comparedPaths;
+ comparedPaths = null;
+ // delete comparedPaths;
+ }
+ if(comparedPaths)
+ {
+ comparedPaths.Free();
+ delete comparedPaths;
}
return true;
}
{
char path[MAX_LOCATION];
- property char *
+ property const char *
{
set
{
- char * unquoted;
GetWorkingDir(path, MAX_LOCATION);
if(value[0] == '\"')
+ {
+ char * unquoted = new char[strlen(value) + 1];
StripQuotes(value, unquoted);
+ PathCat(path, unquoted);
+ delete unquoted;
+ }
else
- unquoted = value;
- PathCat(path, unquoted);
+ PathCat(path, value);
if(!FileExists(path))
{
// this incomplete functionality is not quite at it's place in this class
StripLastDirectory(path, path);
if(FileExists(path))
{
- // TODO: message location does not exist,
+ // TODO: message location does not exist,
// this higher location exists though
// go there?
break;
}
if(!len)
{
- // TODO: message location does not exist,
+ // TODO: message location does not exist,
// unable to select alternate location
}
path[0] = '\0';
delete original;
}
}
- get { return path[0] ? path : null; }
+ get { return path[0] ? (char*)path : null; }
}
- property bool { get { return (bool)path[0]; } }
+ property bool { get { return path[0] != '\0'; } }
};
-define app = ((ExplorerApp)__thisModule);
+define app = ((Explorer)__thisModule);