News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

External application end event

Started by LETARTARE, May 25, 2022, 01:53:05 PM

Previous topic - Next topic

LETARTARE

Is there an event that signals to 'CB' the end of an external application launched from the 'Tools' menu?
explanation : I launch 'Poedit' from the 'Tools' menu and I would like to be warned in 'CB' of its closing.
CB-13834, plugins-sdk-2.25.0 : Collector-2.6.5, AddOnForQt-5.1.2
1- Win7 Business Pack1 64bits : wx-3.2.8, gcc-15.2.0,
2- OpenSuse::Leap-15.6-64bits : wx-3.2.8;gtk3-u, gcc-15.2.0,
=> !! The messages are translated by 'Deepl'

BlueHazzard

Do you want to be warned in codeblocks that po edit is closed, or that po edit is still open when you close codeblocks

Anyway at the moment there is not such functionality. Also i think this would be quite complicated...

LETARTARE

I want be warned when 'Poedit' is closed.
CB-13834, plugins-sdk-2.25.0 : Collector-2.6.5, AddOnForQt-5.1.2
1- Win7 Business Pack1 64bits : wx-3.2.8, gcc-15.2.0,
2- OpenSuse::Leap-15.6-64bits : wx-3.2.8;gtk3-u, gcc-15.2.0,
=> !! The messages are translated by 'Deepl'

BlueHazzard

And also probably prevent the closing?

LETARTARE

#4
No.
When I close 'Poedit', it has already saved two files '*.po' and '*.mo' and these are the two files I want to recover next automatically.
CB-13834, plugins-sdk-2.25.0 : Collector-2.6.5, AddOnForQt-5.1.2
1- Win7 Business Pack1 64bits : wx-3.2.8, gcc-15.2.0,
2- OpenSuse::Leap-15.6-64bits : wx-3.2.8;gtk3-u, gcc-15.2.0,
=> !! The messages are translated by 'Deepl'

LETARTARE

1- The only event that handles the termination of an executable in 'CB' is
Quote'cbEVT_PIPEDPROCESS_TERMINATED'.
2- in 'ToolsManager::Execute(...)' then you have to use the option
Quote'LAUNCH_VISIBLE' to use a 'PipedProcess'
3- then the event ending is reserved for the parent in 'PipedProcess::OnTerminate(...)' by 'wxPostEvent(m_Parent, event)'
4- I then added  'Manager::Get()->ProcessEvent(event)'
and I can get this event from a 'CB' plugin.

But I don't know if there are side effects, and if this modification is possible in 'CB' !

What do you think?
CB-13834, plugins-sdk-2.25.0 : Collector-2.6.5, AddOnForQt-5.1.2
1- Win7 Business Pack1 64bits : wx-3.2.8, gcc-15.2.0,
2- OpenSuse::Leap-15.6-64bits : wx-3.2.8;gtk3-u, gcc-15.2.0,
=> !! The messages are translated by 'Deepl'

Pecan

#6
Quote from: LETARTARE on May 25, 2022, 01:53:05 PM
Is there an event that signals to 'CB' the end of an external application launched from the 'Tools' menu?
explanation : I launch 'Poedit' from the 'Tools' menu and I would like to be warned in 'CB' of its closing.

You could run your own wrapper program from the tools menu that wxExecutes then waits for the poedit process. Just the fact that it returned means that poedit ended.

It also gives you control over return codes from poedit and the ability to start/stop subsequent programs.

LETARTARE

@Pecan :Thanks

I will try this track.
CB-13834, plugins-sdk-2.25.0 : Collector-2.6.5, AddOnForQt-5.1.2
1- Win7 Business Pack1 64bits : wx-3.2.8, gcc-15.2.0,
2- OpenSuse::Leap-15.6-64bits : wx-3.2.8;gtk3-u, gcc-15.2.0,
=> !! The messages are translated by 'Deepl'

BlueHazzard

Also, do the files exists, or are they generated by po edit?

I would need some event handling about changes in files. And i am willing to work on this...

LETARTARE

#9
In the 1st solution I had added
Quote'Manager::Get()->ProcessEvent(event)'
to
Quote'PipedProcess::OnTerminate(...)'
In a 2nd solution I added 
Quote'Manager::Get()->ProcessEvent(event)'
at the end of
Quote'ToolsManager::OnToolTerminated(CodeBlocksEvent& event)'
Both work well for me.

In the plugin 'CB' I proposed in 'https://github.com/LETARTARE/CB_Collector'; :
1- I generated the file 'project_name.po' in the 'CB' editor,
2- I call by program the menu 'Tools->Poedit'  with parameter 'project_name.po'
3- from 'Poedit, I translate strings then i create 'project_name.mo' and quit
4- on return,
     - if I have translated strings, I get a warning from 'CB' to reload 'project_name.po' which has been
        modified : I reload
     - otherwise nothing to do
5- I want to be notified when 'Poedit' is closed to copy the file ''project_name.po'' to another directory

Actually, I use 'cbEVT_EDITOR_MODIFIED' but it is not satisfactory.
CB-13834, plugins-sdk-2.25.0 : Collector-2.6.5, AddOnForQt-5.1.2
1- Win7 Business Pack1 64bits : wx-3.2.8, gcc-15.2.0,
2- OpenSuse::Leap-15.6-64bits : wx-3.2.8;gtk3-u, gcc-15.2.0,
=> !! The messages are translated by 'Deepl'

LETARTARE

Quote from: Pecan on May 25, 2022, 06:23:45 PM
You could run your own wrapper program from the tools menu that wxExecutes then waits for the poedit process. Just the fact that it returned means that poedit ended.
Thanks very much.

I already had a synchronous wrapper to run 'xgettext' and 'wxrc', so this simplified the code, avoiding event monitoring.
CB-13834, plugins-sdk-2.25.0 : Collector-2.6.5, AddOnForQt-5.1.2
1- Win7 Business Pack1 64bits : wx-3.2.8, gcc-15.2.0,
2- OpenSuse::Leap-15.6-64bits : wx-3.2.8;gtk3-u, gcc-15.2.0,
=> !! The messages are translated by 'Deepl'

Miguel Gimenez

You can replace the call to poedit with a batch file calling poedit followed by the copy command.