Author Topic: External application end event  (Read 4414 times)

Offline LETARTARE

  • Lives here!
  • ****
  • Posts: 531
  • L'ami de l'homme.The friend of man.
    • LETARTARE
External application end event
« 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.
CB-13483, plugins-sdk-2.25.0 : Collector-2.0.0, AddOnForQt-3.9.1
1-Win7 Business Pack1 64bits : wx-3.2.4, gcc-8.1.0,
2-OpenSuse::Leap-15.4-64bits : wx-3.2.4;gtk3, gcc-8.2.1,
=> !! The messages are translated by Deepl

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: External application end event
« Reply #1 on: May 25, 2022, 02:29:01 pm »
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...

Offline LETARTARE

  • Lives here!
  • ****
  • Posts: 531
  • L'ami de l'homme.The friend of man.
    • LETARTARE
Re: External application end event
« Reply #2 on: May 25, 2022, 02:30:52 pm »
I want be warned when 'Poedit' is closed.
CB-13483, plugins-sdk-2.25.0 : Collector-2.0.0, AddOnForQt-3.9.1
1-Win7 Business Pack1 64bits : wx-3.2.4, gcc-8.1.0,
2-OpenSuse::Leap-15.4-64bits : wx-3.2.4;gtk3, gcc-8.2.1,
=> !! The messages are translated by Deepl

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: External application end event
« Reply #3 on: May 25, 2022, 02:36:54 pm »
And also probably prevent the closing?

Offline LETARTARE

  • Lives here!
  • ****
  • Posts: 531
  • L'ami de l'homme.The friend of man.
    • LETARTARE
Re: External application end event
« Reply #4 on: May 25, 2022, 02:46:00 pm »
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.
« Last Edit: May 25, 2022, 02:48:53 pm by LETARTARE »
CB-13483, plugins-sdk-2.25.0 : Collector-2.0.0, AddOnForQt-3.9.1
1-Win7 Business Pack1 64bits : wx-3.2.4, gcc-8.1.0,
2-OpenSuse::Leap-15.4-64bits : wx-3.2.4;gtk3, gcc-8.2.1,
=> !! The messages are translated by Deepl

Offline LETARTARE

  • Lives here!
  • ****
  • Posts: 531
  • L'ami de l'homme.The friend of man.
    • LETARTARE
Re: External application end event
« Reply #5 on: May 25, 2022, 05:48:41 pm »
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
Code
'PipedProcess::OnTerminate(...)' 
by
Code
'wxPostEvent(m_Parent, event)'
4- I then added 
Code
'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-13483, plugins-sdk-2.25.0 : Collector-2.0.0, AddOnForQt-3.9.1
1-Win7 Business Pack1 64bits : wx-3.2.4, gcc-8.1.0,
2-OpenSuse::Leap-15.4-64bits : wx-3.2.4;gtk3, gcc-8.2.1,
=> !! The messages are translated by Deepl

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2750
Re: External application end event
« Reply #6 on: May 25, 2022, 06:23:45 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.
« Last Edit: May 25, 2022, 06:27:15 pm by Pecan »

Offline LETARTARE

  • Lives here!
  • ****
  • Posts: 531
  • L'ami de l'homme.The friend of man.
    • LETARTARE
Re: External application end event
« Reply #7 on: May 25, 2022, 07:22:20 pm »
@Pecan :Thanks

I will try this track.
CB-13483, plugins-sdk-2.25.0 : Collector-2.0.0, AddOnForQt-3.9.1
1-Win7 Business Pack1 64bits : wx-3.2.4, gcc-8.1.0,
2-OpenSuse::Leap-15.4-64bits : wx-3.2.4;gtk3, gcc-8.2.1,
=> !! The messages are translated by Deepl

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: External application end event
« Reply #8 on: May 25, 2022, 09:34:35 pm »
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...

Offline LETARTARE

  • Lives here!
  • ****
  • Posts: 531
  • L'ami de l'homme.The friend of man.
    • LETARTARE
Re: External application end event
« Reply #9 on: May 25, 2022, 10:53:56 pm »
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.
« Last Edit: May 25, 2022, 10:58:41 pm by LETARTARE »
CB-13483, plugins-sdk-2.25.0 : Collector-2.0.0, AddOnForQt-3.9.1
1-Win7 Business Pack1 64bits : wx-3.2.4, gcc-8.1.0,
2-OpenSuse::Leap-15.4-64bits : wx-3.2.4;gtk3, gcc-8.2.1,
=> !! The messages are translated by Deepl

Offline LETARTARE

  • Lives here!
  • ****
  • Posts: 531
  • L'ami de l'homme.The friend of man.
    • LETARTARE
Re: External application end event
« Reply #10 on: May 26, 2022, 08:33:04 am »
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-13483, plugins-sdk-2.25.0 : Collector-2.0.0, AddOnForQt-3.9.1
1-Win7 Business Pack1 64bits : wx-3.2.4, gcc-8.1.0,
2-OpenSuse::Leap-15.4-64bits : wx-3.2.4;gtk3, gcc-8.2.1,
=> !! The messages are translated by Deepl

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1553
Re: External application end event
« Reply #11 on: May 26, 2022, 09:07:18 am »
You can replace the call to poedit with a batch file calling poedit followed by the copy command.