Author Topic: cbEVT_WORKSPACE_CLOSE_BEGIN new event  (Read 9513 times)

Offline earlgrey

  • Multiple posting newcomer
  • *
  • Posts: 101
cbEVT_WORKSPACE_CLOSE_BEGIN new event
« on: September 14, 2015, 03:04:17 pm »
I need this event for a plugin.

I define the event in "src/include/sdk_events.h" and "src/sdk/sdk_events.cpp"

1) I fire it in the ProjectManager::CloseWorkspace() method. ( see code below ) - Is that correct ?

2) Are you ok for a patch ?

Code
bool ProjectManager::CloseWorkspace()
{
    bool result = false;
    m_IsClosingWorkspace = true;
    if (m_pWorkspace)
    {
        if (!m_ui->QueryCloseWorkspace())
        {
            m_IsClosingWorkspace = false;
            return false;
        }
        //  ----------------------------------------------------------------->>
        // Fire-up cbEVT_WORKSPACE_CLOSE_BEGIN event
        CodeBlocksEvent event(cbEVT_WORKSPACE_CLOSE_BEGIN);
        Manager::Get()->GetPluginManager()->NotifyPlugins(event);
        //  -----------------------------------------------------------------<<
        // m_ui->QueryCloseWorkspace asked for saving workspace AND projects, no need to do again
        if (!CloseAllProjects(true))
        {
            m_IsClosingWorkspace = false;
            return false;
        }
        delete m_pWorkspace;
        m_pWorkspace = nullptr;

        m_ui->CloseWorkspace();
        result = true;
    }
    else
        result = CloseAllProjects(false);
    m_IsClosingWorkspace = false;
    WorkspaceChanged();
    return result;
}
« Last Edit: September 14, 2015, 03:06:37 pm by earlgrey »
* OS = Debian Buster - Linux 4.19.06 x64 SMP
* C::B = svn11267 wx-3.0.4 - Linux, unicode 64 bit

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: cbEVT_WORKSPACE_CLOSE_BEGIN new event
« Reply #1 on: September 14, 2015, 09:24:40 pm »
First you'll have to describe your use case.
Then we might consider if we want to add it or not.  ;D
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline earlgrey

  • Multiple posting newcomer
  • *
  • Posts: 101
Re: cbEVT_WORKSPACE_CLOSE_BEGIN new event
« Reply #2 on: September 14, 2015, 11:20:20 pm »
I work on OpenFilesListPlus plugin, an enhanced version of OpenFilesList plugin.

- Each project stores which sub-panel each of its files belongs to
- The workspace stores the sub-panels layout

For saving the sub-panels layout, I have to detect the workspace closing time.
Unfortunately I did not succeed in this using the existing cbEVT_WORKSPACE_LOADING_COMPLETE and cbEVT_WORKSPACE_CHANGED events.
Adding the cbEVT_WORKSPACE_CLOSE_BEGIN appears to be the best way for achieving my goal.

And incidentally it is only a few lines of code, so please add :)

Regards ~
* OS = Debian Buster - Linux 4.19.06 x64 SMP
* C::B = svn11267 wx-3.0.4 - Linux, unicode 64 bit

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: cbEVT_WORKSPACE_CLOSE_BEGIN new event
« Reply #3 on: September 14, 2015, 11:51:01 pm »
What happens if multiple projects are loaded without a workspace? I mean one by one. Will it still work?

Offline earlgrey

  • Multiple posting newcomer
  • *
  • Posts: 101
Re: cbEVT_WORKSPACE_CLOSE_BEGIN new event
« Reply #4 on: September 15, 2015, 12:11:16 am »
What happens if multiple projects are loaded without a workspace? I mean one by one. Will it still work?

"Bulk" sub-panel is always present, with or without workspace loaded. So in your use case, all opened files will appear in the bulk sub-panel.

( Your is case is also the same as if a workspace not defining any sub-panel were loaded ).

* OS = Debian Buster - Linux 4.19.06 x64 SMP
* C::B = svn11267 wx-3.0.4 - Linux, unicode 64 bit

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: cbEVT_WORKSPACE_CLOSE_BEGIN new event
« Reply #5 on: September 15, 2015, 12:58:00 am »
Ok, post a patch, but you must provide the workspace_close_end/finished kind of event, for symmetry.

Do you really need to get an event before the workspace has been closed?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline earlgrey

  • Multiple posting newcomer
  • *
  • Posts: 101
Re: cbEVT_WORKSPACE_CLOSE_BEGIN new event
« Reply #6 on: September 15, 2015, 05:08:38 pm »
Ok thanx, that's great

I will post the patch soon.
* OS = Debian Buster - Linux 4.19.06 x64 SMP
* C::B = svn11267 wx-3.0.4 - Linux, unicode 64 bit

Offline earlgrey

  • Multiple posting newcomer
  • *
  • Posts: 101
Re: cbEVT_WORKSPACE_CLOSE_BEGIN new event
« Reply #7 on: September 19, 2015, 07:00:25 am »
Here is the patch for svn10499 :
Files modified : sdk_events.h - sdk_events.cpp - projectmanager.cpp

Code
cd svn10499/trunk
patch -R -p2 < svn10499.cbEVT_WORKSPACE_CLOSE.patch

( Hey, the new forum server rocks ! )
« Last Edit: September 19, 2015, 08:07:19 am by earlgrey »
* OS = Debian Buster - Linux 4.19.06 x64 SMP
* C::B = svn11267 wx-3.0.4 - Linux, unicode 64 bit

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: cbEVT_WORKSPACE_CLOSE_BEGIN new event
« Reply #8 on: September 19, 2015, 12:30:15 pm »
OK, I'll push it some time next week.

p.s. Don't use -R when generating patches.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline earlgrey

  • Multiple posting newcomer
  • *
  • Posts: 101
Re: cbEVT_WORKSPACE_CLOSE_BEGIN new event
« Reply #9 on: September 20, 2015, 08:27:41 pm »
OK, I'll push it some time next week.
Thanks - Great, when done I shall announce some usable version for testing & feedback

p.s. Don't use -R when generating patches.
Noticed -

* OS = Debian Buster - Linux 4.19.06 x64 SMP
* C::B = svn11267 wx-3.0.4 - Linux, unicode 64 bit

Offline earlgrey

  • Multiple posting newcomer
  • *
  • Posts: 101
Re: cbEVT_WORKSPACE_CLOSE_BEGIN new event
« Reply #10 on: December 27, 2015, 10:02:58 pm »
OK, I'll push it some time next week.
p.s. Don't use -R when generating patches.

You did replace some "_CLOSE_" words in my patch by "_CLOSING_" ones, but in sdk_events.h :
Code
extern EVTIMPORT const wxEventType cbEVT_WORKSPACE_CLOSING_BEGIN;
#define EVT_WORKSPACE_CLOSING_BEGIN(fn) DECLARE_EVENT_TABLE_ENTRY( cbEVT_WORKSPACE_CLOSE_BEGIN, -1, -1, (wxObjectEventFunction)(wxEventFunction)(CodeBlocksEventFunction)&fn, (wxObject *) NULL ),
extern EVTIMPORT const wxEventType cbEVT_WORKSPACE_CLOSING_COMPLETE;
#define EVT_WORKSPACE_CLOSING_COMPLETE(fn) DECLARE_EVENT_TABLE_ENTRY( cbEVT_WORKSPACE_CLOSE_COMPLETE, -1, -1, (wxObjectEventFunction)(wxEventFunction)(CodeBlocksEventFunction)&fn, (wxObject *) NULL ),
you forgot "_CLOSE_" words in the DECLARE_EVENT_TABLE_ENTRY(...), so these macros wont be usable.
 
* OS = Debian Buster - Linux 4.19.06 x64 SMP
* C::B = svn11267 wx-3.0.4 - Linux, unicode 64 bit

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: cbEVT_WORKSPACE_CLOSE_BEGIN new event
« Reply #11 on: December 29, 2015, 07:33:23 pm »
Should be fixed in trunk.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline earlgrey

  • Multiple posting newcomer
  • *
  • Posts: 101
Re: cbEVT_WORKSPACE_CLOSE_BEGIN new event
« Reply #12 on: December 29, 2015, 08:46:33 pm »
Thx
* OS = Debian Buster - Linux 4.19.06 x64 SMP
* C::B = svn11267 wx-3.0.4 - Linux, unicode 64 bit