[Geany] Plugin Events Patch

blackdog blackdog at xxxxx
Wed Aug 1 20:22:33 UTC 2007


Ok, I'm going to leave that for the masters :) It took about 15 mins
to decide I didn't know what new kind of GOBject to create to
attach the signal to.

Where I have GTK_TYPE_WIDGET (to get it to compile) you need, I think,
some kind of custom GObject.


enum {
	SCI_NOTIFY,
	LAST_SIGNAL
};

static guint plugin_signals[LAST_SIGNAL] = { 0 };

 plugin_signals[SCI_NOTIFY] = g_signal_new (
		 "sci_notify",
		 G_TYPE_FROM_CLASS(gtk_type_class (GTK_TYPE_WIDGET)),
		 G_SIGNAL_RUN_FIRST,
		 0,
		 NULL, NULL,
		 g_cclosure_marshal_VOID__INT,
		 G_TYPE_NONE, 1,
		 G_TYPE_INT);

Cheers

bd


On Wed, 1 Aug 2007 15:13:53 -0400
blackdog <blackdog at ipowerhouse.com> wrote:

> 
> Hi Enrico
> 
> I found this tutorial for defining signals, so I think i'll give it  a
> shot
> 
> 
> http://gnomejournal.org/article/36/writing-a-widget-using-cairo-and-gtk28-part-2
> 
> bd
> 
> 
> On Wed, 1 Aug 2007 19:17:37 +0200
> Enrico Tröger <enrico.troeger at uvena.de> wrote:
> 
> > On Wed, 01 Aug 2007 16:28:39 +0100, Nick Treleaven
> > <nick.treleaven at 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
> > 
> 
> 


-- 
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