On Wed, 01 Aug 2007 16:28:39 +0100, Nick Treleaven nick.treleaven@btinternet.com wrote:
Hi,
Then something like:
// callback func called by all editors when a signal arises void on_editor_notification(GtkWidget *editor, gint scn, gpointer lscn, gpointer user_data) { SCNotification *nt; ScintillaObject *sci; gint idx;
idx = GPOINTER_TO_INT(user_data); sci = doc_list[idx].sci;
nt = lscn;
plugins_sci_notify(editor, scn, nt, idx);
Where plugins_sci_notify() calls any plugin that has an on_sci_notify symbol.
Why don't we just use the signal framework from Glib/GTK? My suggestion: Let's define a bunch of available signals like "plugin::sci-notify" "plugin::build-complete" "plugin::show-auto-complete-list" ... Then every plugin can connect to these signals using the g_signal_connect() family. Within the core of Geany, we emit the signal at the appropriate place (e.g. in the signal handler of sci-notify we emit plugin::sci-notify) and so the signal handler within the plugin is called. The only difficult thing probably will be to define the signals.
I came across this way of signal usage while writing a panel plugin for the Xfce panel. There are (at least) these signals for the plugins available: "configure-plugin" "free-data" "save"
configure-plugin is used to tell the plugin it should show its configuration dialog, save is when the plugin settings should be saved and free-data is fired when the panel is about to remove the plugin.
Another possibility could be to let the plugins set function pointers for several pre-defined actions to functions within the plugin. But this would be nothing else than a more simple way of defining signals and connecting handlers to them. So, I suggest we use the existing and working signals framework from GLib/GTK.
What do you think?
Regards, Enrico