Developer forums (C::B DEVELOPMENT STRICTLY!) > Plugins development

cbEVT_WORKSPACE_CLOSE_BEGIN new event

(1/3) > >>

earlgrey:
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;
}
--- End code ---

oBFusCATed:
First you'll have to describe your use case.
Then we might consider if we want to add it or not.  ;D

earlgrey:
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 ~

scarphin:
What happens if multiple projects are loaded without a workspace? I mean one by one. Will it still work?

earlgrey:

--- Quote from: scarphin 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?

--- End quote ---

"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 ).

Navigation

[0] Message Index

[#] Next page

Go to full version