Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Plugins development => Topic started by: dieterg on March 30, 2011, 10:38:04 am

Title: No cbEVT_PROJECT_FILE_ADDED event when adding a file using the file wizard
Post by: dieterg on March 30, 2011, 10:38:04 am
Hello all,

I'm developing a simple plugin which contains a file browser with which you can quickly filter on filenames containing a specific substring (handy for large projects with lots of files on lots of different places, I have it for Visual Studio and use it all the time). The file browser contains a suffix tree to perform the search on but in order to keep it up to date I need to listen to the cbEVT_PROJECT_* events. All seems to work well except for the cbEVT_PROJECT_FILE_ADDED. The event gets fired when I add an existing file to the project but not if I add a new file to the project using the file wizard.

After some research I came to the conclusion that adding an existing file uses ProjectManager::AddMultipleFilesToProject() which indeed fires the event but the wizard directly calls cbProject::AddFile() which does not fires such event. Maybe there is some good reason to have cbProject::AddFile() not fire the cbEVT_PROJECT_FILE_ADDED event but otherwise wouldn't it be better to have only cbProject::AddFile() fire this event (the actual place where the adding happens) and remove it from ProjectManager::AddMultipleFilesToProject(), etc? This way no such events can be missed any more and no "secondary" functions such as ProjectManager::AddMultipleFilesToProject() which use cbProject::AddFile() have to remember to to fire the event.
Title: Re: No cbEVT_PROJECT_FILE_ADDED event when adding a file using the file wizard
Post by: oBFusCATed on March 30, 2011, 11:06:34 am
I'm developing a simple plugin which contains a file browser with which you can quickly filter on filenames containing a specific substring (handy for large projects with lots of files on lots of different places, I have it for Visual Studio and use it all the time). The file browser contains a suffix tree to perform the search on but in order to keep it up to date I need to listen to the cbEVT_PROJECT_* events. All seems to work well except for the cbEVT_PROJECT_FILE_ADDED.
Have you tried the dialog shown with alt+g?
Why would you need a tree? As far as I can tell simple iteration is fast enough...
Or your project is too big? How much files are we talking about?

(Sorry for the Off)
Title: Re: No cbEVT_PROJECT_FILE_ADDED event when adding a file using the file wizard
Post by: dieterg on March 30, 2011, 11:32:42 am
Have you tried the dialog shown with alt+g?

I didn't know about that one. That's almost exactly what I had in mind. Thanks for pointing that out.

Why would you need a tree? As far as I can tell simple iteration is fast enough...
Or your project is too big? How much files are we talking about?

That was just some playing around from my part.  :D


Even if I my immediate need for this event has been eliminated (yet I will still use my implementation for I like it better :lol: and contains some small extras compared to ALT-G dialog), I still think my remarks remains valid since others might still run into this issue.