Developer forums (C::B DEVELOPMENT STRICTLY!) > Development

[SOLVED]request for a new CodeblocksEvent type : end of a 'multiple files add'

(1/4) > >>

orel:
Hi CB developers !!

I am requesting a new CodeblocksEvent type since i can't find a correct way to do one thing, i don't know if this new type would be useful to other plugin developers. I give myself the permission to request it because for sure it would be very easy to implement!

I am currently developing SVNInside, an plugin integrating svn in CB and i fall on the following problem :

I registered cbEVT_PROJECT_FILE_ADDED in SVNInside because i need to refresh the svn tree of the project when a file is added, then i must execute an 'svn status' command asynchronously on the newly added file in order to display its current svn status. What i am actually doing is calling 'svn status' on every file of the project, thus refreshing the whole svn tree while having the status of the newly added file.
The difference in time between calling 'svn status' on one file or on all project files is relatively the same because the most time is taken by creating a new process and waiting for its output. That's why i am refreshing the whole project.

As executing such a command asyncronously takes a relatively long time, it really freezes CB when the user add multiple files because i have no clue when all files are added!!

I have 2 solutions for the moment :
     
* refreshing the whole tree after receiving each cbEVT_PROJECT_FILE_ADDED --> very long
* finding a hack that gets the time between each cbEVT_PROJECT_FILE_ADDED event and then calling 'svn status' when this value is more than a well-chosen step !! but this solution won't work each case and like i said it is really a hack and bad programming

What would really change my life :D would be to register against a new CB_evt telling me when all files as been added. Its little name could be something like cbEVT_PROJECT_ALL_FILES_ADDED !!
You see, i event found a name for you !! This event would be sent at the end of the for loop sending each cbEVT_PROJECT_FILE_ADDED in ProjectManager::AddMultipleFilesToProject ().

What do you CB developers think of that, or any solution i could implement to make this trick easier?

kkez:
If it's not hard to add the event, then i would go that way.

If it's not so easy, this is my solution:
1) start a timer each time a file is added (5 seconds can be the time span)
2) if a file is added and the timer is on, cancel the timer and recreate it (or simply reset it)
3) at the end of the timer, refresh the svn tree

I don't know if there's a timer/countdown class in wxwidgets, i hope so..

Pecan:
I've found these hooks to be helpful:

    // -- Project events
    // EVT_PROJECT_OPEN(       BrowseTracker::OnProjectOpened)
    ////Manager::Get()->RegisterEventSink(cbEVT_PROJECT_OPEN, new cbEventFunctor<BrowseTracker, CodeBlocksEvent>(this, &BrowseTracker::OnProjectOpened));
    // EVT_PROJECT_ACTIVATE(   BrowseTracker::OnProjectActivated)
    Manager::Get()->RegisterEventSink(cbEVT_PROJECT_ACTIVATE, new cbEventFunctor<BrowseTracker, CodeBlocksEvent>(this, &BrowseTracker::OnProjectActivated));

orel:
Kkez :

your solution with the timer is exactly the same than my second one :D. That's not that bad but i don't like those sort of hack because my svn command won't be executed before the timer ends. It is really a loss of time, even in an asynchronous process. Maybe you will find i am little bit dandy with that !


--- Quote from: Pecan on November 29, 2007, 11:05:11 pm ---I've found these hooks to be helpful:

    // -- Project events
    // EVT_PROJECT_OPEN(       BrowseTracker::OnProjectOpened)
    ////Manager::Get()->RegisterEventSink(cbEVT_PROJECT_OPEN, new cbEventFunctor<BrowseTracker, CodeBlocksEvent>(this, &BrowseTracker::OnProjectOpened));
    // EVT_PROJECT_ACTIVATE(   BrowseTracker::OnProjectActivated)
    Manager::Get()->RegisterEventSink(cbEVT_PROJECT_ACTIVATE, new cbEventFunctor<BrowseTracker, CodeBlocksEvent>(this, &BrowseTracker::OnProjectActivated));

--- End quote ---

How will this help me with my problem?? :shock:

kkez:

--- Quote from: orel on November 30, 2007, 12:26:47 am ---your solution with the timer is exactly the same than my second one :D. That's not that bad but i don't like those sort of hack because my svn command won't be executed before the timer ends. It is really a loss of time, even in an asynchronous process. Maybe you will find i am little bit dandy with that !
--- End quote ---
Well, no. I don't "get the time between each cbEVT_PROJECT_FILE_ADDED event", i hardcode it (which is easier and safe, why should a file take 5 seconds to be added?)


--- Quote ---That's not that bad but i don't like those sort of hack because my svn command won't be executed before the timer ends. Maybe you will find i am little bit dandy with that !
--- End quote ---
:)

Navigation

[0] Message Index

[#] Next page

Go to full version