[Gambas-user] Question: Is it possible to build 'plugins/add ons' for Gambas applications
Willy Raets
willy at ...2734...
Thu Oct 4 17:30:32 CEST 2012
On Wed, 2012-10-03 at 12:22 +0200, Ron wrote:
> On 3-10-2012 2:58, Willy Raets wrote:
> >> Hi Willy,
Hi Bruce,
Thanks for sending the applications and post. Made me think over the
current project and where to go with it with the plugins.
The application is currently in Gambas2 but will be completely redone in
Gambas3 from scratch.
It is a sort of self sustainable building design aid.
In current version user can store certain information as preferences in
a preferences file (text file). Things like location, latitude and
longitude, Solar panel width, length, Watt peak and more.
This information, if made preferred by user, is used default in
calculations on forms to calculate things like insolation values of the
solar installation.
These calculation results can be stored as preference as well, to be
used in other calculations (this run or any other time in future). Like
another calculation form could based on insolation values and
consumption determine size of installation.
So with this as a start point I can use the preferences file as way of
data transfer.
My application doesn't need data from the plugins.
All it needs is to do is install the plugin.
This would involve:
1. Creating a menu item in the plugin menu named after the plugin
2. Start the plugin when menu item is clicked
3. Add name of plugin to preferences file in section [plugins] so
application knows witch plugins are installed to load.
Plugin developers only need to be able to read the preferences file so
they can use values there for their developed calculation forms.
So what they need is a short document explaining the location and syntax
of the preferences file.
If they would like to store specific plugin user preferences they best
use their own plugin preferences file.
So in short,communication from my app is read and write to preferences
file.
Communication from plugin is read from my apps preferences file and
write to plugin preferences file (something plugin developer takes care
of not me). First I was thinking one file for all but skipped that idea.
See attached illustration I tried making
-> within the green is the part I take care (application + file)
-> full arrow is data transfer + direction (from-to)
-> dotted arrow is data transfer plugin only (will go to own plugin file)
The plugin is a seperate application running, but behaving as if it is
part of the current application (as it starts from menu of my
application and uses its preferences).
This way, a plugin developer doesn't need to know how my application is
build up or dive into the code of it but can simply work with data
already custom calculated by the user using my application.
Thanks a lot, your post has helped me getting things clear in my head.
> >>
> >> The concept is feasible, but requires some effort on your part to
> >> implement the following:
> >> 1) a plug in manager for your app to let the user register and start the
> >> plug in.
> > That is what I kind of figured out :)
> >
> >> 2) an object model for your app data that safely exposes the data in
> >> some way:
> >> a) dbus?
> >> b) directly passing the data to the plug-in?
> >> c) using interface files?
> >> 3) if you want to allow the plug in to modify the data, then some sort
> >> of interface to recognize modification requests and apply them
> >> (judiciously of course). Again, gb.dbus messaging and gb.signal look
> >> the most sophisticated approach.
> Willy,
>
> I'm also looking at some way of creating plugins/define an api for my
> project! (domotiga)
> So people can code a plugin as a gambas component, place it in a
> directory (plugins) and the main software will scan/find and register it.
>
> I looked at this info also...
> http://www.gambasforge.org/code-55-application-modulaire--des-plugins-pour-votre-appli.html
> but haven't got it to work just yet the way I want it.
> So keep me posted if you want, when you succeed in creating a POC ;)
Hi Ron,
Thanks for this example (glad I know some French). I've had a short look
at it but haven't tried it yet.
The component.load seems an interesting approach.
I've only used component to check if Gambas components are loaded,
would it work for Gambas applications as well, or does it have to be a
library/component.
For my needs the plugins written could be a normal GUI 1 from
application. Can component.load do that.
Must give it a try as soon as I'm back home...
I will keep you posted on my progress, probably try and make a simple
example first
Willy
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Plugin.png
Type: image/png
Size: 29971 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20121004/6928853b/attachment.png>
More information about the User
mailing list