<p>I had a look at the code in <code>build.c</code> and tried to understand what it's doing. This is how I understood it:</p>
<p>If someone (a plugin) wants to re-write the build menu it would have to call <code>build_menu_update</code> and then the menu items are re-written according to the magic/selection process described above.</p>
<p>If we want to add plugins to be a build command source we would need to define a new <code>GeanyBuildSource</code>, e.g. <code>GEANY_BCS_PLUGIN</code>.</p>
<p>I'm not sure where the commands for the various sources are saved in memory. I assume the pointers to the commands are these:</p>
<pre><code>/* the various groups of commands not in the filetype struct */
static GeanyBuildCommand *ft_def = NULL;
static GeanyBuildCommand *non_ft_proj = NULL;
static GeanyBuildCommand *non_ft_pref = NULL;
static GeanyBuildCommand *non_ft_def = NULL;
static GeanyBuildCommand *exec_proj = NULL;
static GeanyBuildCommand *exec_pref = NULL;
static GeanyBuildCommand *exec_def = NULL;
</code></pre>
<p>So e.g. <code>exec_proj</code> holds the commands for the prjoject and does not point to one command but to an array of 9 commands (maximum?).</p>
<p>For the case that there is more than one active plugin wanting to be a GeanyBuildSource I wonder if it wouldn't be better to call a function which is doing the decision for the plugins and returns the list of commands that won.</p>
<p>Also if I understood it correctly the build dialog can be re-used as it saves the set commands into <code>dst</code> which in this case would need to point to the memory area for the workbench plugin (using function <code>GtkWidget *build_commands_table(GeanyDocument *doc, GeanyBuildSource dst, BuildTableData *table_data, GeanyFiletype *ft)</code>.</p>
<p>So what about exposing only one pointer, e,g, <code>GeanyBuildCommand *exec_plugins = NULL;</code> to geany-plugins and call some function which is doing the work of <code>return_cmd_if</code> for the plugins? And as <a class="user-mention" data-hovercard-user-id="811085" href="https://github.com/elextr">@elextr</a> suggested put some registration/priority handling/arm wrestling code to the shared utils lib in geany-plugins.</p>
<p>Just an idea/brainstorming. Maybe I understood some things wrong, let's see.</p>
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/geany/geany-plugins/issues/733#issuecomment-380952207">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABDrJ7sv4PDZ3O6qkXusyNf-5NMxbc1Rks5tn8kvgaJpZM4TNXBD">mute the thread</a>.<img src="https://github.com/notifications/beacon/ABDrJ-RJkL4eCHibmVeajJ-Wi39Ff_BEks5tn8kvgaJpZM4TNXBD.gif" height="1" width="1" alt="" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
<link itemprop="url" href="https://github.com/geany/geany-plugins/issues/733#issuecomment-380952207"></link>
<meta itemprop="name" content="View Issue"></meta>
</div>
<meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>
<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/geany/geany-plugins","title":"geany/geany-plugins","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/geany/geany-plugins"}},"updates":{"snippets":[{"icon":"PERSON","message":"@LarsGit223 in #733: I had a look at the code in ```build.c``` and tried to understand what it's doing. This is how I understood it:\r\n\r\nIf someone (a plugin) wants to re-write the build menu it would have to call ```build_menu_update``` and then the menu items are re-written according to the magic/selection process described above.\r\n\r\nIf we want to add plugins to be a build command source we would need to define a new ```GeanyBuildSource```, e.g. ```GEANY_BCS_PLUGIN```.\r\n\r\nI'm not sure where the commands for the various sources are saved in memory. I assume the pointers to the commands are these:\r\n```\r\n/* the various groups of commands not in the filetype struct */\r\nstatic GeanyBuildCommand *ft_def = NULL;\r\nstatic GeanyBuildCommand *non_ft_proj = NULL;\r\nstatic GeanyBuildCommand *non_ft_pref = NULL;\r\nstatic GeanyBuildCommand *non_ft_def = NULL;\r\nstatic GeanyBuildCommand *exec_proj = NULL;\r\nstatic GeanyBuildCommand *exec_pref = NULL;\r\nstatic GeanyBuildCommand *exec_def = NULL;\r\n```\r\nSo e.g. ```exec_proj``` holds the commands for the prjoject and does not point to one command but to an array of 9 commands (maximum?).\r\n\r\nFor the case that there is more than one active plugin wanting to be a GeanyBuildSource I wonder if it wouldn't be better to call a function which is doing the decision for the plugins and returns the list of commands that won.\r\n\r\nAlso if I understood it correctly the build dialog can be re-used as it saves the set commands into ```dst``` which in this case would need to point to the memory area for the workbench plugin (using function ```GtkWidget *build_commands_table(GeanyDocument *doc, GeanyBuildSource dst, BuildTableData *table_data, GeanyFiletype *ft)```.\r\n\r\nSo what about exposing only one pointer, e,g, ```GeanyBuildCommand *exec_plugins = NULL;``` to geany-plugins and call some function which is doing the work of ```return_cmd_if``` for the plugins? And as @elextr suggested put some registration/priority handling/arm wrestling code to the shared utils lib in geany-plugins. \r\n\r\nJust an idea/brainstorming. Maybe I understood some things wrong, let's see."}],"action":{"name":"View Issue","url":"https://github.com/geany/geany-plugins/issues/733#issuecomment-380952207"}}}</script>