Author Topic: Short file name - Manager window  (Read 6408 times)

Offline angshuman

  • Single posting newcomer
  • *
  • Posts: 3
Short file name - Manager window
« on: March 05, 2010, 03:09:23 am »
Is there a way in Code::Blocks to view short file names (without path) in the Manager->projects window? I have a long directory structure and when working with multiple files it takes up half of my display and thats very disturbing.

Thanks in advance.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Short file name - Manager window
« Reply #1 on: March 05, 2010, 06:35:33 am »
Is there a way in Code::Blocks to view short file names (without path) in the Manager->projects window? I have a long directory structure and when working with multiple files it takes up half of my display and thats very disturbing.
A flat hirarchie makes no sense becasue how would you handle file wirth the same name but in different directories then?

However, you have two options:

1.) If you right-click on the project, inspect the menu "project tree" and play with the options "categorize by file types" and "display folders as on disk".

2.) Use the concept of virtual folders to organise your files. Consult the C::B documentation how to do that.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline Seronis

  • Almost regular
  • **
  • Posts: 197
Re: Short file name - Manager window
« Reply #2 on: March 05, 2010, 04:54:51 pm »
Is there a way in Code::Blocks to view short file names (without path) in the Manager->projects window? I have a long directory structure and when working with multiple files it takes up half of my display and thats very disturbing.
A flat hirarchie makes no sense becasue how would you handle file wirth the same name but in different directories then?

Less than 5% of the projects I work on have over 200-300 files and less than 1% are significantly larger than that.  Not sure how many -other- users are in the same situation but that leaves 95% of the stuff I work on in a position to benifit from not worrying about the heirarchy as there just are no duplicate file names.  If short file names were supported in a few places it would make life easier for me, for the OP, and for others in the same situation.  (hint build log and build msgs)

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Short file name - Manager window
« Reply #3 on: March 05, 2010, 05:02:10 pm »
Less than 5% of the projects I work on have over 200-300 files
For me it's exactly the opposite.

However, as there is possibility of errors I see no way how this could be implemented in a bullet-proof manner. And I don't want to answer the million forum posts which post about linker errors due to e.g. en object file has been overwritten.

But probably I am missing something here...

Edit: Again: If you have both options I mentioned turned off and your folder structure is not too deep it's exactly what you want.
« Last Edit: March 05, 2010, 05:04:00 pm by MortenMacFly »
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline angshuman

  • Single posting newcomer
  • *
  • Posts: 3
Re: Short file name - Manager window
« Reply #4 on: March 05, 2010, 07:00:03 pm »
I think its a choice of preference and the workspace. Many popular editors (including slickedit and vc) have this kind of listing. I know there is a problem if multiple files have the same name - but we already have a solution for the in the default view. If we could have the choice of not seeing the full path that would really be a lot more usable.

silver24k

  • Guest
Re: Short file name - Manager window
« Reply #5 on: March 06, 2010, 07:47:08 am »
I have a simple patch for this.  It can be turned on/off by "Hide folder name" in menu "project tree".

Code
--- I:/Places/svn/svn.berlios.de/codeblocks/branches/wxpropgrid_debugger/src/include/projectmanager.h	Tue Feb 16 04:23:39 2010
+++ I:/Places/svn/svn.berlios.de/codeblocks/local/src/include/projectmanager.h Tue Feb 16 04:33:26 2010
@@ -468,6 +468,9 @@
         void OnGotoFile(wxCommandEvent& event);
         void OnViewCategorize(wxCommandEvent& event);
         void OnViewUseFolders(wxCommandEvent& event);
+        //{{YSM
+        void OnViewHideFolderName(wxCommandEvent& event);
+        //}}YSM
         void OnViewFileMasks(wxCommandEvent& event);
         void OnFindFile(wxCommandEvent& event);
         wxTreeItemId FindItem(wxTreeItemId Node, const wxString& Search) const;
@@ -495,6 +498,9 @@
         cbWorkspace* m_pWorkspace;
         bool m_TreeCategorize;
         bool m_TreeUseFolders;
+        //{{YSM
+        bool m_TreeHideFolderName;
+        //}}YSM
         FilesGroupsAndMasks* m_pFileGroups;
         int m_TreeFreezeCounter;
         bool m_IsLoadingProject;
--- I:/Places/svn/svn.berlios.de/codeblocks/branches/wxpropgrid_debugger/src/include/cbproject.h Fri Sep 18 01:06:05 2009
+++ I:/Places/svn/svn.berlios.de/codeblocks/local/src/include/cbproject.h Sat Oct 31 18:35:33 2009
@@ -109,7 +109,9 @@
           * @param useFolders If true, create folders as needed. If false, the list is flat.
           * @param fgam If not NULL, use these file groups and masks for virtual folders.
           */
-        void BuildTree(wxTreeCtrl* tree, const wxTreeItemId& root, bool categorize, bool useFolders, FilesGroupsAndMasks* fgam = 0L);
+        //{{YSM
+        void BuildTree(wxTreeCtrl* tree, const wxTreeItemId& root, bool categorize, bool useFolders, FilesGroupsAndMasks* fgam = 0L, bool hideFolderName=false);
+        //}}YSM
 
         /** This resets the project to a clear state. Like it's just been new'ed. */
         void ClearAllProperties();
--- I:/Places/svn/svn.berlios.de/codeblocks/branches/wxpropgrid_debugger/src/sdk/projectmanager.cpp Tue Feb 16 04:23:20 2010
+++ I:/Places/svn/svn.berlios.de/codeblocks/local/src/sdk/projectmanager.cpp Fri Feb 19 14:01:52 2010
@@ -110,6 +110,9 @@
 int idMenuTreeCloseWorkspace = wxNewId();
 int idMenuAddVirtualFolder = wxNewId();
 int idMenuDeleteVirtualFolder = wxNewId();
+//{{YSM
+int idMenuViewHideFolderName = wxNewId();
+//}}YSM
 
 static const int idMenuFindFile = wxNewId();
 static const int idNB = wxNewId();
@@ -203,6 +206,9 @@
     EVT_MENU(idMenuViewCategorizePopup, ProjectManager::OnViewCategorize)
     EVT_MENU(idMenuViewUseFolders, ProjectManager::OnViewUseFolders)
     EVT_MENU(idMenuViewUseFoldersPopup, ProjectManager::OnViewUseFolders)
+    //{{YSM
+    EVT_MENU(idMenuViewHideFolderName, ProjectManager::OnViewHideFolderName)
+    //}}YSM
     EVT_MENU(idMenuViewFileMasks, ProjectManager::OnViewFileMasks)
     EVT_MENU(idMenuFindFile, ProjectManager::OnFindFile)
     EVT_IDLE(ProjectManager::OnIdle)
@@ -214,6 +220,9 @@
     m_pWorkspace(0),
     m_TreeCategorize(false),
     m_TreeUseFolders(true),
+    //{{YSM
+    m_TreeHideFolderName(true),
+    //}}YSM
     m_TreeFreezeCounter(0),
     m_IsLoadingProject(false),
     m_IsLoadingWorkspace(false),
@@ -239,6 +248,9 @@
     ConfigManager *cfg = Manager::Get()->GetConfigManager(_T("project_manager"));
     m_TreeCategorize = cfg->ReadBool(_T("/categorize_tree"), true);
     m_TreeUseFolders = cfg->ReadBool(_T("/use_folders"), true);
+    //{{YSM
+    m_TreeHideFolderName = cfg->ReadBool(_T("/hide_folder_name"), true);
+    //}}YSM
 
     RebuildTree();
 
@@ -417,6 +429,10 @@
             treeprops->AppendCheckItem(idMenuViewUseFolders, _("Display folders as on disk"));
             treeprops->Check(idMenuViewCategorize, cfg->ReadBool(_T("/categorize_tree"), true));
             treeprops->Check(idMenuViewUseFolders, cfg->ReadBool(_T("/use_folders"), true));
+            //{{YSM
+            treeprops->AppendCheckItem(idMenuViewHideFolderName, _("Hide folder name"));
+            treeprops->Check(idMenuViewUseFolders, cfg->ReadBool(_T("/hide_folder_name"), true));
+            //}}YSM
             treeprops->Append(idMenuViewFileMasks, _("Edit file types && categories..."));
             menu->AppendSeparator();
             menu->Append(idMenuProjectTreeProps, _("Project tree"), treeprops);
@@ -661,8 +677,14 @@
 it differs from the block currently in CreateMenu() by the following two IDs */
             treeprops->AppendCheckItem(idMenuViewCategorizePopup, _("Categorize by file types"));
             treeprops->AppendCheckItem(idMenuViewUseFoldersPopup, _("Display folders as on disk"));
+            //{{YSM
+            treeprops->AppendCheckItem(idMenuViewHideFolderName, _("Hide folder name"));
+            //}}YSM
             treeprops->Check(idMenuViewCategorizePopup, cfg->ReadBool(_T("/categorize_tree"), true));
             treeprops->Check(idMenuViewUseFoldersPopup, cfg->ReadBool(_T("/use_folders"), true));
+            //{{YSM
+            treeprops->Check(idMenuViewHideFolderName, cfg->ReadBool(_T("/hide_folder_name"), true));
+            //}}YSM
             treeprops->Append(idMenuViewFileMasks, _("Edit file types && categories..."));
 
             menu.Append(idMenuProjectTreeProps, _("Project tree"), treeprops);
@@ -1252,7 +1274,9 @@
         cbProject* project = m_pProjects->Item(i);
         if (project)
         {
-            project->BuildTree(m_pTree, m_TreeRoot, m_TreeCategorize, m_TreeUseFolders, m_pFileGroups);
+            //{{YSM
+            project->BuildTree(m_pTree, m_TreeRoot, m_TreeCategorize, m_TreeUseFolders, m_pFileGroups, m_TreeHideFolderName);
+            //}}YSM
             m_pTree->SetItemBold(project->GetProjectNode(), project == m_pActiveProject);
         }
     }
@@ -1795,11 +1819,17 @@
 
     menu.AppendCheckItem(idMenuViewCategorizePopup, _("Categorize by file types"));
     menu.AppendCheckItem(idMenuViewUseFoldersPopup, _("Display folders as on disk"));
+    //{{YSM
+    menu.AppendCheckItem(idMenuViewHideFolderName, _("Hide folder name"));
+    //}}YSM
     menu.AppendSeparator();
     menu.Append(idMenuViewFileMasks, _("Edit file types && categories..."));
 
     menu.Check(idMenuViewCategorizePopup, m_TreeCategorize);
     menu.Check(idMenuViewUseFoldersPopup, m_TreeUseFolders);
+ //{{YSM
+    menu.Check(idMenuViewHideFolderName, m_TreeHideFolderName);
+ //}}YSM
 
     wxPoint pt = wxGetMousePosition();
     pt = m_pTree->ScreenToClient(pt);
@@ -2361,6 +2391,16 @@
     Manager::Get()->GetConfigManager(_T("project_manager"))->Write(_T("/use_folders"), m_TreeUseFolders);
     RebuildTree();
 }
+
+//{{YSM
+void ProjectManager::OnViewHideFolderName(wxCommandEvent& event)
+{
+    m_TreeHideFolderName = event.IsChecked();
+    Manager::Get()->GetAppFrame()->GetMenuBar()->Check(idMenuViewHideFolderName, m_TreeHideFolderName);
+    Manager::Get()->GetConfigManager(_T("project_manager"))->Write(_T("/hide_folder_name"), m_TreeHideFolderName);
+    RebuildTree();
+}
+//}}YSM
 
 void ProjectManager::OnViewFileMasks(wxCommandEvent& event)
 {
--- I:/Places/svn/svn.berlios.de/codeblocks/branches/wxpropgrid_debugger/src/sdk/cbproject.cpp Sat Sep 26 06:49:00 2009
+++ I:/Places/svn/svn.berlios.de/codeblocks/local/src/sdk/cbproject.cpp Tue Feb 16 21:04:12 2010
@@ -834,7 +834,10 @@
     return (*arg1)->file.GetFullPath().CompareTo((*arg2)->file.GetFullPath());
 }
 
-void cbProject::BuildTree(wxTreeCtrl* tree, const wxTreeItemId& root, bool categorize, bool useFolders, FilesGroupsAndMasks* fgam)
+//{{YSM
+//Add the , bool hideFolderName
+//}}YSM
+void cbProject::BuildTree(wxTreeCtrl* tree, const wxTreeItemId& root, bool categorize, bool useFolders, FilesGroupsAndMasks* fgam, bool hideFolderName)
 {
     if (!tree)
         return;
@@ -943,6 +946,12 @@
         }
 
         // add file in the tree
+        //{{YSM
+        if(!useFolders && folders_kind != FileTreeData::ftdkVirtualFolder && hideFolderName)
+        {
+            nodetext = f->file.GetFullName();
+        }
+        //}}YSM
         f->m_TreeItemId = AddTreeNode(tree, nodetext, parentNode, useFolders || folders_kind == FileTreeData::ftdkVirtualFolder, folders_kind, f->compile, (int)f->m_VisualState, ftd);
     }
I've some other changes in my local copy so hope I did not miss any thing in this patch ...

[attachment deleted by admin]
« Last Edit: March 06, 2010, 07:53:48 am by silver24k »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Short file name - Manager window
« Reply #6 on: March 07, 2010, 05:50:12 pm »
I have a simple patch for this.
No bad, but as the flag is incompatible with the option "show folders as on disk" it should disable this (visually) if selected and vice versa.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline angshuman

  • Single posting newcomer
  • *
  • Posts: 3
Re: Short file name - Manager window
« Reply #7 on: March 07, 2010, 06:56:00 pm »
Very cool. Thanks :)