I can believe you. There is no chance for this to work.
This is the code that registers the context menu items. Obviously the items don't reuse the ids from the main menu.
And I couldn't see any code that takes these ids.
menu->Append(idMenuCompileFromProjectManager, _("Build"));
menu->Append(idMenuRebuildFromProjectManager, _("Rebuild"));
menu->Append(idMenuCleanFromProjectManager, _("Clean"));
The dependence on the plugin load order is another nail in the coffin of this change! 8)
I ask that you check, you'll see!
For
menu->Append(idMenuCompileFromProjectManager, _("Build"));
menu->Append(idMenuRebuildFromProjectManager, _("Rebuild"));
menu->Append(idMenuCleanFromProjectManager, _("Clean"));
A little higher in the Dispatcher:
void CompilerGCC::Dispatcher(wxCommandEvent& event)
{
m_EventId = event.GetId();
// Manager::Get()->GetMessageManager()->Log(wxT("Dispatcher")));
if (m_EventId == idMenuRun)
OnRun(event);
else if (m_EventId == idMenuCompileAndRun)
OnCompileAndRun(event);
else if (m_EventId == idMenuCompile)
OnCompile(event);
else if (m_EventId == idMenuCompileFromProjectManager)
OnCompile(event);
else if (m_EventId == idMenuCompileFile)
OnCompileFile(event);
else if (m_EventId == idMenuCompileFileFromProjectManager)
OnCompileFile(event);
else if (m_EventId == idMenuCleanFileFromProjectManager)
OnCleanFile(event);
else if (m_EventId == idMenuRebuild)
OnRebuild(event);
else if (m_EventId == idMenuRebuildFromProjectManager)
OnRebuild(event);
....
we recover the same id's
idMenuCompileFromProjectManager
idMenuCleanFileFromProjectManager
idMenuRebuildFromProjectManager
triggers
OnCompile(event);
OnRebuild(event);
Take a look at the CompilerGCC::BuildStateManagement function.
I will try to understand how it works to use.
@MortenMacFly
Thank you for taking the time to test this plugin.
Is it possible to use the 'Build log' to display messages generated by the pre-generate ?
This would be more consistent than display them in 'Code::Blocks log'.
@oBFusCATed
when it has never requested them
See 2-
1- It retrieves the ids menus created by the plugin 'CompilerGcc' by :
void QtPregen::BuildMenu(wxMenuBar* menuBar)
{
if (!IsAttached())
return;
int pos = menuBar->FindMenu(_("Build"));
if (pos !=-1) {
wxMenu * builder = menuBar->GetMenu(pos);
m_IdBuild = builder->FindItem(_("Build"));
m_IdCompile = builder->FindItem(_("Compile current file"));
m_IdRun = builder->FindItem(_("Run"));
m_IdBuildRun = builder->FindItem(_("Build and run"));
m_IdRebuild = builder->FindItem(_("Rebuild"));
m_IdClean = builder->FindItem(_("Clean"));
}
}
2- It retrieves the ids context menus created by the plugin 'CompilerGcc' by :
void QtPregen::BuildModuleMenu(const ModuleType type, wxMenu* menu, const FileTreeData* data)
{
if (!IsAttached())
return;
// we 're only interested in m_project manager's menus
if (!menu || type != mtProjectManager)
return;
// right click on item menu ...else -> 0
if (data) {
FileTreeData::FileTreeDataKind typedata = data->GetKind();
// ... click project
bool preproject = typedata == FileTreeData::ftdkProject ;
// ... click file
bool prefile = typedata == FileTreeData::ftdkFile ;
if (preproject) {
// popup menu on a project
m_IdpClean = menu->FindItem(_("Clean"));
m_IdpBuild = menu->FindItem(_("Build"));
m_IdpRebuild = menu->FindItem(_("Rebuild"));
}
else
if (prefile) {
// popup menu on a file
m_IdfBuild = menu->FindItem(_("Build file"));
m_IdfClean = menu->FindItem(_("Clean file"));
}
}
}
3- Id are used to select the treatment in :
void QtPregen::OnPrebuild(CodeBlocksEvent& event)
{
int eventId = event.GetId();
....
}
Note that from one session to another, id's remain the same!
While compiling a new version of svn 'Code::Block'.
Obviously we need to implement this feature as a new event that is fired at the correct time and it doesn't depend on a state variable.
Well, how so ?
This is how you send and event:
CodeBlocksEvent evt(<event type>, <parameters>);
Manager::Get()->ProcessEvent(evt);
And you have to create one or more new events.
To see how to do it inspect the sdk_events.h/cpp files to see how the other events are declared/defined.
Copy/paste/modify the code until it fits you needs and post a patch.
Hello,
- new 'QtPregenForCB-0.4.2'
- it uses a new organization for use of two new events:
'cbEVT_PRECOMPILER_STARTED' and
'cbEVT_PRECOMPILE_FILE'
I adapted 'CompilerGCC' to have a state machine with a state of more
bsTargetPreGen
see 'CompilerGCC::GetNextStateBasedOnJob()' and 'CompilerGCC::BuildStateManagement()'
I provide a patch to svn 10118, see to :
https://github.com/LETARTARE/QtPregenForCB (https://github.com/LETARTARE/QtPregenForCB)
Best regards
@ofuscated
1- Why don't you use an enum instead of s_rebuild struct
yes it's possible, as I used three boolean, I have to use eight enums par exemple :
enum cbFutureBuild
{
fbNone = 0,
fbBuild,
fbClean,
fbRebuild,
fbWorkspaceBuild,
fbWorkspaceClean,
fbWorkspaceReBuild
};
2-The names of the events continue to be horrible
you are right : names must remember that this happens BEFORE COMPILATION
'cbEVT_BEFORE_COMPILING_ALL'
'cbEVT_BEFORE_COMPILING_FILE'
??
3-Check the style guide
is corrected
4-Don't put LETARTARE everywhere
this is done
5- Are you sure that you want to get an event
yes, i have to generate the files required by Qt structure, BEFORE the compilation starts : see green
http://doc.qt.digia.com/qq/34/qt-build-system.png (http://doc.qt.digia.com/qq/34/qt-build-system.png)
But I will try to use 'cbEVT_COMPILER_STARTED' instead of 'cbEVT_BEFORE_COMPILING_ALL'
I will provide the patch if you agree ?
If you wish to adapt 'AddOnForQt' to the last sdk-2.16.0 (with cb-12524)
1- By editing "Project->Build Options...->Custom variables" of project, you must replace the old variable 'cb = $(#sdk...)' => 'cb = $(#sdk2160)'
2- Create the global variable 'sdk2160' must contain the address of 'cb-12524-2160\src' => exemple :
#sdk2160="...\315\Sdk\cb-12524-2160\src"
3- Change the file 'manisfest.xml'
...
<SdkVersion major="2" minor="16" release="0" />
...
<Value description="Compilling Qt software with this plugin (sdk 2.16.0)" />
...