6 define title = "Ecere Explorer (Debug)";
8 define title = "Ecere Explorer";
12 define backgroundColor = Color { 30, 40, 50 }; //Color { 20, 20, 60 };
13 define foregroundColor = lightGray; //white;
14 define selectionColor = lightYellow;
15 define selectionText = Color { 20, 30, 40 };
16 define toolBarBackgroundColor = backgroundColor;//white; //Color { 240, 240, 250 };
17 define toolBarForegroundColor = foregroundColor;//white; //Color { 240, 240, 250 };
19 define backgroundColor = beige;//white; //Color { 128, 145, 175 }; //200, 224, 224 }; //lightGray;
20 define foregroundColor = black;
21 define selectionColor = app.currentSkin.selectionColor;
22 define selectionText = app.currentSkin.selectionText;
23 define toolBarBackgroundColor = backgroundColor;//white; //Color { 240, 240, 250 };
24 define toolBarForegroundColor = foregroundColor;//white; //Color { 240, 240, 250 };
29 newWindow, goBack, goForward, goUp, goHome,
32 panelTree, panelSearch,
35 viewList, viewDetails, viewIcons, viewCards, viewShowcase, viewTree, viewCustom,
42 inFileContentMatchCase,
43 inFileContentMatchWord,
51 class ExplorerWindow : Window
54 background = backgroundColor;
55 borderStyle = sizable;
62 minClientSize = { 600, 300 };
63 nativeDecorations = true;
73 ExplorerToolId lastViewId;
78 Array<HistoryItem> history { };
83 Menu fileMenu { menu, "File", f };
84 Menu windowMenu { menu, "Window", w };
85 MenuItem itemNewWindow
87 windowMenu, "New Window", n;
89 bool NotifySelect(MenuItem selection, Modifiers mods)
91 ExplorerWindow { }.Create();
96 IconBag<ExplorerToolId> iconBag
98 //window = guiApp.desktop;
103 "<:ecere>emblems/unreadable.png", /* none */
105 "<:ecere>actions/windowNew.png", /* newWindow */
106 "<:ecere>actions/goPrevious.png", /* goBack */
107 "<:ecere>actions/goNext.png", /* goForward */
108 "<:ecere>actions/goUp.png", /* goUp */
109 "<:ecere>actions/goHome.png", /* goHome */
110 "<:ecere>mimeTypes/file.png", /* newFile */
111 "<:ecere>actions/folderNew.png", /* newFolder */
113 ":browse.png", /* browse */
115 ":panel-tree.png", /* panelTree */
116 "<:ecere>actions/editFind.png", /* panelSearch */
120 "<:ecere>actions/viewRefresh.png", /* refresh */
122 ":view-list.png", /* viewList */
123 ":view-details.png", /* viewDetails */
124 ":view-icons.png", /* viewIcons */
125 ":view-cards.png", /* viewCards */
126 ":view-showcase-right.png", /* viewShowcase */
127 ":panel-tree.png", /* viewTree */
128 ":view-custom.png", /* viewCustom */
130 "<:ecere>mimeTypes/image.png", /* previewPictures */
132 "", /* searchInFileName */
133 "<:ecere>emblems/unreadable.png", /* inFileNameMatchCase */
134 "<:ecere>emblems/unreadable.png", /* inFileNameMatchWord */
135 "", /* searchInFileContent */
136 "<:ecere>emblems/unreadable.png", /* inFileContentMatchCase */
137 "<:ecere>emblems/unreadable.png", /* inFileContentMatchWord */
138 ":browse.png", /* searchInSubDirs */
139 "<:ecere>actions/editFind.png", /* searchStart */
140 "<:ecere>emblems/unreadable.png", /* searchStop */
141 "<:ecere>emblems/unreadable.png" /* hasHeader */
149 direction = vertical;
150 background = backgroundColor;
154 anchor = { left = 0, top = 0, right = 0, bottom = 0 };
158 ToolBar/*<ExplorerToolId>*/ toolBar
164 background = toolBarBackgroundColor;
169 void NotifyToolClick(ToolButton button)
171 ExplorerToolId id = (ExplorerToolId)button.id;
177 ExplorerWindow { }.Create();
181 historyIndex += id == goBack ? -1 : 1;
182 GoToHistoryIndex(false, false, false);
186 char * home = getenv("HOME");
187 if(home && home[0] && FileExists(home).isDirectory)
188 GoTo(home, false, false);
193 char * path = view.path;
194 char * newPath = new char[strlen(path)+1];
195 StripLastDirectory(path, newPath);
201 GoTo(newPath, false, false);
206 if(CreateNewFileDialog { master = this, parent = parent, currentDirectory = view.path }.Modal() == ok )
210 if(CreateDirectoryDialog { master = this, parent = parent, currentDirectory = view.path }.Modal() == ok )
215 //ToggleSearchMode(false);
216 tree.visible = button.checked;
217 split.visible = button.checked;
220 split.rightPane = view;
221 view.anchor = { top = 0, bottom = 0, right = 0 };
222 GoTo(addressBar.path, false, false);
227 split.rightPane = null;
228 view.anchor = { left = 2, top = 0, bottom = 0, right = 0 };
230 //search.visible = !button.checked;
231 panels.size = { panels.size.w, panels.size.h }; // TOFIX : another Stacker fix needed
234 ToggleSearchMode(button.checked);
236 //tree.visible = false; //!button.checked;
237 //split.visible = false; //!button.checked;
240 /*split.rightPane = view;
241 view.anchor = { top = 0, bottom = 0, right = 0 };*/
242 //split.rightPane = null;
243 //view.anchor = { left = 2, top = 0, bottom = 0, right = 0 };
246 searchInFileName.Activate();
250 //split.rightPane = null;
251 //view.anchor = { left = 2, top = 0, bottom = 0, right = 0 };
253 GoTo(addressBar.path, false, false);
255 //panels.size = { panels.size.w, panels.size.h }; // TOFIX : another Stacker fix needed
260 case previewPictures:
261 view.previewPictures = button.checked;
265 view.details = false;
266 view.treeBranches = false;
271 view.treeBranches = false;
276 //SwitchViews(toolId);
277 view.details = false;
278 view.treeBranches = false;
282 view.preview = button.checked;
286 view.treeBranches = button.checked;
290 view.hasHeader ^= true;
297 Window { toolBar, size = { w = 8 }, inactive = true };
298 ToolButton goBack { toolBar, this, id = ExplorerToolId::goBack, hotKey = { left, alt = true }, disabled = true };
299 Window { toolBar, size = { w = 2 }, inactive = true };
300 ToolButton goForward { toolBar, this, id = ExplorerToolId::goForward, hotKey = { right, alt = true }, disabled = true };
301 Window { toolBar, size = { w = 2 }, inactive = true };
302 ToolButton refresh { toolBar, this, id = ExplorerToolId::refresh, hotKey = { r, ctrl = true } };
303 Window { toolBar, size = { w = 2 }, inactive = true };
304 ToolButton goHome { toolBar, this, id = ExplorerToolId::goHome, hotKey = { h, ctrl = true } };
305 Window { toolBar, size = { w = 8 }, inactive = true };
309 size = { 300, 22 }, id = ExplorerToolId::addressBar;
310 typeExpected = directory;
312 background = toolBarBackgroundColor;
313 foreground = toolBarForegroundColor;
314 selectionColor = selectionColor;
315 selectionText = selectionText;
317 bool OnKeyDown(Key key, unichar ch)
319 if((SmartKey)key == enter)
321 // how to make enter effect a modification
322 // how to implement in PathBox
327 bool NotifyModified(PathBox pathBox)
329 GoTo(pathBox.path, false, false);
333 FlipStacker { toolBar, spring = previous };
334 Window { toolBar, size = { w = 8 }, inactive = true };
335 ToolButton newFile { toolBar, this, id = ExplorerToolId::newFile, hotKey = { n, ctrl = true } };
336 Window { toolBar, size = { w = 2 }, inactive = true };
337 ToolButton newFolder { toolBar, this, id = ExplorerToolId::newFolder, hotKey = { d, ctrl = true } };
338 Window { toolBar, size = { w = 8 }, inactive = true };
339 ToolButton goUp { toolBar, this, id = ExplorerToolId::goUp, hotKey = { up, alt = true } };
340 Window { toolBar, size = { w = 8 }, inactive = true };
341 //GroupToggleToolButton selectedPanel;
342 ToggleToolButton panelTree { toolBar, this, id = ExplorerToolId::panelTree, hotKey = { t, ctrl = true }/*, selected = &selectedPanel*//*, checked = true*/ };
343 ToggleToolButton panelSearch { toolBar, this, id = ExplorerToolId::panelSearch, hotKey = { f, ctrl = true }/*, selected = &selectedPanel*/ };
344 //selectedPanel = panelTree;
345 Window { toolBar, size = { w = 8 }, inactive = true };
346 /*OptionToolButton selectedView;
347 OptionToolButton viewList { toolBar, this, id = ExplorerToolId::viewList, selected = &selectedView, checked = true };
348 OptionToolButton viewDetails { toolBar, this, id = ExplorerToolId::viewDetails, selected = &selectedView };
349 OptionToolButton viewIcons { toolBar, this, id = ExplorerToolId::viewIcons, selected = &selectedView };
350 OptionToolButton viewTiles { toolBar, this, id = ExplorerToolId::viewCards, selected = &selectedView };
351 OptionToolButton viewShowcase { toolBar, this, id = ExplorerToolId::viewShowcase, selected = &selectedView };
352 OptionToolButton viewTree { toolBar, this, id = ExplorerToolId::viewTree, selected = &selectedView };
353 selectedView = viewList;*/
354 //ToggleToolButton viewList { toolBar, this, id = ExplorerToolId::viewList, checked = true };
355 ToggleToolButton viewDetails { toolBar, this, id = ExplorerToolId::viewDetails };
356 //ToggleToolButton viewIcons { toolBar, this, id = ExplorerToolId::viewIcons };
357 //ToggleToolButton viewTiles { toolBar, this, id = ExplorerToolId::viewCards };
358 ToggleToolButton viewShowcase { toolBar, this, id = ExplorerToolId::viewShowcase };
359 ToggleToolButton viewTree { toolBar, this, id = ExplorerToolId::viewTree };
360 Window { toolBar, size = { w = 8 }, inactive = true };
361 ToggleToolButton previewPictures { toolBar, this, id = ExplorerToolId::previewPictures };
363 Window { toolBar, size = { w = 8 }, inactive = true };
364 ToolButton hasHeader { toolBar, this, id = ExplorerToolId::hasHeader };
365 Window { toolBar, size = { w = 8 }, inactive = true };
366 ToolButton newWindow { toolBar, this, id = ExplorerToolId::newWindow, hotKey = { w, ctrl = true } };
367 Window { toolBar, size = { w = 8 }, inactive = true };
372 iconBag.window = null;
376 bool OnLoadGraphics()
382 void OnUnloadGraphics()
391 direction = horizontal;
399 //size = { h = 400 };
402 FlipStacker flipStack { stack, spring = previous };
404 //Window searchSpace { stack, size = { h = 32 }, background = toolBarBackgroundColor, inactive = true, opacity = 0.0f };
406 ToolBar/*<ExplorerToolId>*/ searchBar
413 background = toolBarBackgroundColor;
417 void NotifyToolClick(ToolButton button)
419 ExplorerToolId id = (ExplorerToolId)button.id;
436 Window { searchBar, size = { w = 8 }, inactive = true };
437 Label { searchBar, this, labeledWindow = searchInFileName};
438 Window { searchBar, size = { w = 2 }, inactive = true };
439 EditBox searchInFileName
442 size = { 200, 22 }, id = ExplorerToolId::searchInFileName;
444 background = toolBarBackgroundColor;
445 foreground = toolBarForegroundColor;
446 selectionColor = selectionColor;
447 selectionText = selectionText;
450 bool NotifyKeyDown(EditBox editBox, Key key, unichar ch)
452 if((SmartKey)key == enter)
457 /*bool NotifyActivate(Window window, bool active, Window previous)
461 toolBar.focusHolder = window;
466 Window { searchBar, size = { w = 2 }, inactive = true };
468 ToggleToolButton inFileNameMatchCase { searchBar, this, id = ExplorerToolId::inFileNameMatchCase };
470 ToggleToolButton inFileNameMatchWord { searchBar, this, id = ExplorerToolId::inFileNameMatchWord };
471 Window { searchBar, size = { w = 8 }, inactive = true };
472 Label { searchBar, this, labeledWindow = searchInFileContent};
473 Window { searchBar, size = { w = 2 }, inactive = true };
474 EditBox searchInFileContent
477 size = { 200, 22 }, id = ExplorerToolId::searchInFileContent;
479 background = toolBarBackgroundColor;
480 foreground = toolBarForegroundColor;
481 selectionColor = selectionColor;
482 selectionText = selectionText;
483 text = "File Content:";
485 bool NotifyKeyDown(EditBox editBox, Key key, unichar ch)
487 if((SmartKey)key == enter)
492 /*bool NotifyActivate(Window window, bool active, Window previous)
495 toolBar.focusHolder = window;
499 FlipStacker { searchBar, spring = previous };
500 ToggleToolButton inFileContentMatchCase { searchBar, this, id = ExplorerToolId::inFileContentMatchCase };
501 ToggleToolButton inFileContentMatchWord { searchBar, this, id = ExplorerToolId::inFileContentMatchWord };
502 Window { searchBar, size = { w = 8 }, inactive = true };
503 ToggleToolButton searchInSubDirs { searchBar, this, id = ExplorerToolId::searchInSubDirs, checked = true };
504 Window { searchBar, size = { w = 8 }, inactive = true };
505 ToolButton searchStart { searchBar, this, id = ExplorerToolId::searchStart, hotKey = { s, ctrl = true } };
506 Window { searchBar, size = { w = 8 }, inactive = true };
507 ToolButton searchStop { searchBar, this, id = ExplorerToolId::searchStop, hotKey = { escape }, disabled = true; };
508 Window { searchBar, size = { w = 8 }, inactive = true };
512 //Window { searchBar, size = { h = 1 } };
514 /*SearchPanel searchPanel
526 background = backgroundColor;
529 /*Tree*/FileSystemBox tree//;
534 background = backgroundColor;
535 foreground = foregroundColor;
536 selectionColor = selectionColor;
537 selectionText = selectionText;
541 //anchor = { left = 0, top = 0, bottom = 0 };
547 bool NotifyNodeSelect(FileSystemBox box, FileSystemBoxSelection selection)
551 FileSystemNode node = selection.node;
554 char p[MAX_LOCATION];
556 GoTo(node.path, false, true);
562 /*bool NotifyActivate(Window window, bool active, Window previous)
565 toolBar.focusHolder = window;
574 leftPane = tree;//, rightPane = view;
582 background = backgroundColor;
583 foreground = foregroundColor;
584 selectionColor = selectionColor;
585 selectionText = selectionText;
589 //anchor = { left = 2, top = 0, bottom = 0, right = 0 };
591 locationBox = addressBar;
592 navigateFolders = true;
596 bool NotifyNodeOpen(FileSystemBox box, FileSystemBoxSelection selection)
598 FileSystemNode node = selection.node;
603 char path[MAX_LOCATION];
605 char command[MAX_LOCATION];
607 /*_FileType t = node.type;
608 if(t == ewsFile || t == epjFile ||
609 t == ecFile || t == ehFile ||
610 t == cppFile || t == hppFile ||
611 t == cFile || t == hFile ||
612 t == textFile || t == webFile)*/
613 sprintf(command, "gnome-open \"%s\"", path);
615 sprintf(command, "%s", path);*/
622 else if(node.type.isFolder)
623 GoTo(node.path, true, false);
625 UpdateHistoryItem(selection);
629 bool NotifyNodeSelect(FileSystemBox box, FileSystemBoxSelection selection)
631 UpdateHistoryItem(selection);
635 /*bool NotifyActivate(Window window, bool active, Window previous)
638 toolBar.focusHolder = window;
643 FileSystemSearch searchThread
645 owner = this, fsb = view, tree = tree/*, searchPanel = this*/;
647 /*bool ExplorerWindow::NotifyUpdateSearchLocation(FileSystemSearch search, char * location)
649 char string[MAX_LOCATION + 2048];
650 sprintf(string, "%s (Searching %s)", title, location);
651 PrintLn(string); //view.results.text = string;
656 bool ExplorerWindow::NotifySearchTerminated(FileSystemSearch search)
658 searchStop.disabled = true;
663 void ToggleSearchMode(bool inSearch)
666 //search.visible = inSearch;
667 //panelSearch.checked = inSearch; // <------ this is toggling panelSearch even though it shouldn't
668 //searchSpace.visible = !inSearch;
669 searchBar.visible = inSearch;
670 history[historyIndex].inSearch = inSearch;
671 size = { size.w, size.h };
672 view.pathColumn = inSearch;
674 searchThread.InitResults();*/
675 if(inSearch && /*(*/searchInFileName.contents[0]/* || searchInFileContents.contents[0])*/)
685 tree.path = "/"; // this should be available as a parameter
686 treeInitialized = true;
688 tree.SelectLocation(view.path);
694 if(searchBar.visible)
704 void GoTo(char * location, bool viewIsAtLocation, bool treeIsAtLocation)
706 HistoryItem item = null;
707 if(!history.count || fstrcmp(history[historyIndex].path, location))
710 for(c = 0; c < history.count; c++)
711 if(!fstrcmp(history[c].path, location))
713 if(c == history.count)
715 item = { path = CopyString(location) };
718 while(historyIndex < history.count-1)
720 delete history[history.count-1].path;
725 historyIndex = history.count-1;
730 GoToHistoryIndex(viewIsAtLocation, treeIsAtLocation, item != null);
733 void GoToHistoryIndex(bool viewIsAtLocation, bool treeIsAtLocation, bool updateHistoryItem)
735 HistoryItem item = history[historyIndex];
737 goBack.disabled = historyIndex == 0;
738 goForward.disabled = historyIndex == history.count-1;
739 goUp.disabled = !fstrcmp(item.path, "/");
741 if(!viewIsAtLocation)
743 if(item.inSearch != panelSearch.checked)
745 ToggleSearchMode(item.inSearch);
755 view.path = item.path;
756 item.holdRecordingSelection = true;
757 view.SelectMultipleByPath(item.selection);
760 if(tree.visible && !treeIsAtLocation)
761 tree.SelectLocation(item.path);
763 if(updateHistoryItem)
764 UpdateHistoryItem(view.selection);
767 void UpdateHistoryItem(FileSystemBoxSelection selection)
769 HistoryItem item = history[historyIndex];
771 if(!item.holdRecordingSelection)
773 if(selection.node || (selection.nodes && selection.nodes.count))
775 item.selection.Free();
776 if(selection.nodes.count)
778 for(node : selection.nodes)
779 item.selection.Add(CopyString(node.path));
781 else if(selection.node)
782 item.selection.Add(CopyString(selection.node.path));
786 item.holdRecordingSelection = false;
792 searchThread.active = true;
794 searchThread.optionSubdirs = searchInSubDirs.checked == true;
795 searchThread.optionTree = view.treeBranches; //(options.subdirs.checked && options.tree.checked);
796 searchThread.optionBrowser = tree.visible; //(options.subdirs.checked && options.browser.checked);
798 searchThread.optionNameMatchCase = inFileNameMatchCase.checked;
800 searchThread.optionNameMatchCase = false;
802 searchThread.optionNameMatchWord = inFileNameMatchWord.checked;
803 searchThread.optionContentMatchCase = inFileContentMatchCase.checked;
804 searchThread.optionContentMatchWord = inFileContentMatchWord.checked;
806 strcpy(searchThread.location, view.path);
807 strcpy(searchThread.nameSearch, searchInFileName.contents);
808 strcpy(searchThread.contentSearch, searchInFileContent.contents);
810 //actions.startStop.text = "Stop Search";
811 //actions.clear.disabled = false;
812 //view.results.Clear();
813 //view.results.hasHeader = !searchThread.optionTree;
814 //view.results.treeBranches = searchThread.optionTree;
815 //view.browser.Clear();
816 //ToggleBrowserDisplay(searchThread.optionBrowser);
818 //view.browser.text = "Browser";
820 char string[MAX_LOCATION + 2048];
821 sprintf(string, "%s (Searching %s)", title, view.path);
822 //PrintLn(string); //view.results.text = string;
825 searchThread.InitResults();
826 searchThread.Create();
827 searchStop.disabled = false;
833 if(searchThread.active)
835 searchThread.terminate = true;
836 //searchStop.disabled = true;
845 /*ExplorerSearch search
850 size = Size { 624, 268 };
851 anchor = Anchor { left = 0, top = 0, bottom = 0 };
854 ExplorerViewSearch results;*/
858 parent = deep, master = this;
860 anchor = Anchor { top = 0, bottom = 0, right = 0 };
863 // Preview / Showcase
864 /*PreviewArea previewArea
869 //FlipStacker flipPanels { panels, spring = previous };
871 /*bool TreeNotifyBranchSelect(ExplorerTree tree, ExplorerFileBranch branch)
875 char path[MAX_LOCATION];
876 branch.GetPath(path);
877 toolBar.addressBar.contents = path;
883 /*bool ViewNotifyItemOpen(ExplorerView view, ExplorerFileItem item)
885 ExplorerFileBranch branch = tree.branch;
888 if(item.type.isFolderType)
890 ExplorerFileBranch child;
892 if(!branch.loaded || !branch.childrenLoaded)
893 BranchLoad(branch, tree.tree);
895 for(child = branch.children.first; child; child = child.next)
896 if(!strcmp(child.name, item.name))
901 if(branch.row.collapsed)
902 child.row.collapsed = true;
903 child.EnsureVisible(false);
909 char path[MAX_LOCATION];
910 branch.GetPath(path);
911 PathCat(path, item.name);
917 /*void SwitchViews(ExplorerToolId viewId)
919 ExplorerFileBranch branch = tree.branch;
923 case viewList: view = ExplorerViewList { parent = viewHolder, master = this }; break;
924 case viewDetails: view = ExplorerViewDetails { parent = viewHolder, master = this }; break;
925 case viewIcons: view = ExplorerViewIcons { parent = viewHolder, master = this }; break;
926 case viewCards: view = ExplorerViewCards { parent = viewHolder, master = this }; break;
927 case viewShowcase: view = ExplorerViewShowcase { parent = viewHolder, master = this }; break;
929 view.tabCycle = true;
930 view.previewPictures = toolBar.previewPictures.checked;
931 view.anchor = Anchor { left = 0, top = 0, bottom = 0, right = 0 };
932 view.NotifyItemOpen = ViewNotifyItemOpen;
938 /*void SearchLocation(char * location)
941 search.location.editBox.contents = location;
947 addressBar.path = view.path;
952 bool OnClose(bool parentClosing)
965 view = ExplorerViewList
967 parent = viewHolder, master = this;
969 previewPictures = toolBar.previewPictures.checked;
970 anchor = Anchor { left = 0, top = 0, bottom = 0, right = 0 };
971 NotifyItemOpen = ViewNotifyItemOpen;
973 lastViewId = viewList;
976 view.Load(tree.root);
988 //class TreeFileSystemBox : FileSystemBox { }
993 bool holdRecordingSelection;
995 Array<String> selection { };