Author Topic: Plugins saving extra project settings?  (Read 5381 times)

Offline Kazade

  • Multiple posting newcomer
  • *
  • Posts: 73
Plugins saving extra project settings?
« on: February 17, 2009, 11:37:57 am »
I'm working on my unit testing plugin and it's going pretty well, but I've hit a small roadblock (well... two.. actually three) that I need some help with....

Basically, a project can have unit testing enabled or disabled. When you enable unit testing on a project, you get a new virtual folder called "Tests" and you get a load of funky menu items in the project manager (run all tests, add test etc.). Disabling unit testing on a project removes the "Tests" folder and will remove any test source files and build targets that were added to the project. At the moment I'm classing a project as having unit testing enabled if it has a "Tests" virtual folder... it works, but it's not very robust (if a project already has a custom Tests virtual folder everything will break). So my questions:

1. Can I save a "unit_testing_enabled" flag in the project file somehow - if so, can someone point me in the right direction?
2. Is there any way to specify a new build target type? (I noticed that the current list is an enum.. so I'm pretty sure I can't extend it - I can work around it if it's not possible)
3. When I remove the "Tests" folder using project->VirtualFolderDeleted() the folder is deleted (because it's not contained in the GetVirtualFolders() list) *but* it's still displayed in the tree view. How do I refresh the tree to reflect the change?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9699
Re: Plugins saving extra project settings?
« Reply #1 on: February 17, 2009, 08:12:08 pm »
1. Can I save a "unit_testing_enabled" flag in the project file somehow - if so, can someone point me in the right direction?
Yes - have a look at e.g. the wxSmith/envvars plugin how to do so.

2. Is there any way to specify a new build target type? (I noticed that the current list is an enum.. so I'm pretty sure I can't extend it - I can work around it if it's not possible)
No, this would require a modification in the core. The question is if you really need that taken into account that you can save your settings in an own node.

3. When I remove the "Tests" folder using project->VirtualFolderDeleted() the folder is deleted (because it's not contained in the GetVirtualFolders() list) *but* it's still displayed in the tree view. How do I refresh the tree to reflect the change?
You need to refresh the tree view, too. Hence I don't remember the name of the method atm... (no sources here, sorry...)

Just for the record: Do you have plans to release this plugin?
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 Kazade

  • Multiple posting newcomer
  • *
  • Posts: 73
Re: Plugins saving extra project settings?
« Reply #2 on: February 18, 2009, 01:52:48 pm »
1. Can I save a "unit_testing_enabled" flag in the project file somehow - if so, can someone point me in the right direction?
Yes - have a look at e.g. the wxSmith/envvars plugin how to do so.

Cool, I'll take a look thanks!

2. Is there any way to specify a new build target type? (I noticed that the current list is an enum.. so I'm pretty sure I can't extend it - I can work around it if it's not possible)
No, this would require a modification in the core. The question is if you really need that taken into account that you can save your settings in an own node.

OK, thought that would be the case.

3. When I remove the "Tests" folder using project->VirtualFolderDeleted() the folder is deleted (because it's not contained in the GetVirtualFolders() list) *but* it's still displayed in the tree view. How do I refresh the tree to reflect the change?
You need to refresh the tree view, too. Hence I don't remember the name of the method atm... (no sources here, sorry...)

Found it. ProjectManager->RebuildTree(); It's working perfectly now ;) Although it's strange that I don't need to call it after adding a virtual folder, only removing it.

Just for the record: Do you have plans to release this plugin?

Yes definitely, as soon as it does something useful. :)