X-Git-Url: http://ecere.com/cgi-bin/gitweb.cgi?p=ede;a=blobdiff_plain;f=explorer%2Fsrc%2FExplorer.ec;h=58c86a2080df8e2ef7198e22e498d5803eeed404;hp=69339995ef89c1f14befa3efb836b50ce05636bb;hb=31c0bbb5b1181eb99fd55eba92dacb2ed14b3fb2;hpb=ddec1cfe7674fc97b59db1fae712107c596e6444 diff --git a/explorer/src/Explorer.ec b/explorer/src/Explorer.ec index 6933999..58c86a2 100644 --- a/explorer/src/Explorer.ec +++ b/explorer/src/Explorer.ec @@ -1,10 +1,10 @@ -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__ @@ -14,523 +14,36 @@ import "Panels" #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; - } -} +DummyFileSystemCacheWindow dw;// { size = { 200, 200 } }; -class TestToolBar : Window -{ - int xL, xR; - - borderStyle = bevel; - inactive = true; - background = activeBorder; - size = Size { h = 32 }; - anchor = Anchor { left = 0, top = 0, right = 0 }; - - 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 comparedPaths = null; - ExplorerViewSearch results; + SetLoggingMode(debug, null); - bool TreeNotifyBranchSelect(ExplorerTree tree, ExplorerFileBranch branch) - { - if(branch) - { - 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) + for(c = 1; c < argc; c++) { - if(item.type.isFolderType) + if(!strcmp(argv[c], "#")) { - 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 - { - 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; @@ -551,26 +64,94 @@ class ExplorerApp : GuiApplication } 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(goPath); + } + for(c = 2; c < argc; c++) + { + 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) + { + if(false)//(c == 1) + { + FileStats stats; + //Map linksPaths { }; + //Map> devsInodesDone { }; + //FileSystemCache cache; + // dw = { visible = false }; + ///*cache = */FileSystemCache::Cache("/", true, dw); + + // FileSystemCache::Cache("/s1", true, false, true, dw); + // FileSystemCache::Cache("/s2/0z", true, false, true, dw); + //dw.cache.Special("/s2/0z/0sort", dw); + //dw.cache.Special("/s2/library", dw); + //dw.cache.Special("/s2/mirror", dw); + // dw.cache.SpecialPrint(); + //devsInodesDone.Free(); + //delete devsInodesDone; + + /*{ + ExplorerWindow explorerWnd { testCache = dw.cache }; + explorerWnd.Create(); + explorerWnd.location = goPath;//explorerWnd.GoTo(goPath, false, false); + }*/ + // PrintLn("# of objects: ", dw.cache.objects.count); + // PrintLn("# of non single file sizes: ", dw.cache.nonSingleSizes.count); + // delete dw; + } + else + { + ExplorerWindow explorerWnd { }; + explorerWnd.Create(); + explorerWnd.location = goPath;//explorerWnd.GoTo(goPath, false, false); + } + } + } + } + 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; + // delete comparedPaths; } return true; } @@ -616,9 +197,9 @@ struct QuickPathTool 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);