[Geany] event system
blackdog
blackdog at xxxxx
Tue Jul 31 13:02:59 UTC 2007
I'd like to run this possible implementation past you, i have a working
test, which if it's ok with you I'll fill out with the other events and
then submit a patch, so here goes ...
First in document.c the addition of
g_signal_connect((GtkWidget*) doc_list[idx].sci, "sci-notify",
G_CALLBACK(on_plugin_notification),
GINT_TO_POINTER(idx));
on_plugin_notification is in editor.c and is a copy of
on_editor_notifcation except each of the case's delegates to a plugin
handler, for example ...
case SCN_CHARADDED:
printf("getting notificaiton from sci\n");
plugins_on_char_added(idx, nt->ch);
break;
plugins_on_char_added (and the other possible events) are defined in
plugins.c like this
void plugins_on_char_added(gint idx,char ch)
{
GList *item;
ScintillaObject *sci = doc_list[idx].sci;
for (item = plugin_list; item != NULL; item = g_list_next(item))
{
Plugin *plugin = item->data;
if (plugin->onCharAdded) {
printf("trying to call my plugin \n");
plugin->onCharAdded(sci,ch);
}
}
}
and that's about it, the module the Plugin struct is modified as per
other events,
typedef struct Plugin
{
GModule *module;
gchar *filename; // plugin
filename (/path/libname.so) PluginFields fields;
PluginInfo* (*info) (); /* Returns plugin name,
description */ void (*init) (GeanyData *data); /* Called
when the plugin is enabled */ void (*cleanup)
(); /* Called when the plugin is disabled or when Geany
exits */ void (*onCharAdded)(ScintillaObject *sci,char c); }
Plugin;
Is this approach acceptable? It seems to me the cleanest way to do it,
and it seems to be working.
cheers
bd
On Tue, 31 Jul 2007 12:04:37 +0100
Nick Treleaven <nick.treleaven at btinternet.com> wrote:
> On 07/31/2007 03:31:05 AM, blackdog wrote:
> >
> > Hang on, being a bit stupid here, I guess I could just hook
> > into the Gtk event system with g_signal_connect, as I think you can
> > have
> > more than one event attached.
> >
> Sounds good, I haven't needed any callbacks so far, but in your
> example for autocompletion I guess this could work well.
>
> > On Mon, 30 Jul 2007 21:59:06 -0400
> > blackdog <blackdog at ipowerhouse.com> wrote:
> >
> > >
> > > With the advent of the plugin system i think it would be very
> > useful
> > > if geany had a method of firing events for plugins. Right now I
> > have
> > > implemented the sci_ functions in the plugin interface but of
> > course
> > > this is one way traffic.
> > > [...]
>
> > > Anyone been thinking along these lines? Similarly for key events
> > too.
> > >
> No, I haven't started anything.
>
> Regards,
> Nick
>
> _______________________________________________
> Geany mailing list
> Geany at uvena.de
> http://uvena.de/cgi-bin/mailman/listinfo/geany
--
http://www.blackdog-haxe.com/
"It is no measure of health to be well adjusted to a profoundly sick
society." --Jiddu Krishnamurti
--
http://www.blackdog-haxe.com/
"It is no measure of health to be well adjusted to a profoundly sick
society." --Jiddu Krishnamurti
More information about the Users
mailing list