Question on emission hooks



Hello,

I've read the tutorial on http://le-hacker.org/papers/gobject about gobject's signals, properties, etc. and started to play a little on my project with this.

What I don't understand completely are the emission hooks, from the tutorial I can say that a special callback can be connected to a signal and will be called on *any* emission of that signal. I have various gobjects subclasses defined on my project and checked their "notify" signal id, all gave me the number "1".

This value is then feeded to the g_signal_add_emission_hook, so any gobject "notify" signal will trigger the same emission hook, am I correct?

I tried this code:

------------------------------------------------------------------
static gboolean
notify_emission_hook (GSignalInvocationHint *ihint,
		      guint                  n_param_values,
		      const GValue          *param_values,
		      gpointer               data)
{
  g_message ("HOOK!!!");
  return TRUE;
}


g_signal_add_emission_hook (g_signal_lookup("notify", GWP_TYPE_SHIP),
			    0, /* detail */
			    notify_emission_hook,
			    NULL, /* data */
			    (GDestroyNotify) NULL);
--------------------------------------------------------------


And on console I got this message:

GLib-GObject-WARNING **: gsignal.c:829: invalid signal id `1'

I suppose the signal id '1' is valid, but I don't understand why this message appear, can somebody explain me all this? my head is a mess :-)

Regards,
--
Lucas Di Pentima - Santa Fe, Argentina - Jabber ID: lucas lunix com ar
LUNIX: Soluciones en GNU/Linux - http://www.lunix.com.ar
GnuPG Public Key:
http://random.sks.keyserver.penguin.de:11371/pks/lookup?op=get&search=0x6AA54FC9
Key fingerprint = BD3B 08C4 661A 8C3B 1855  740C 8F98 3FCF 6AA5 4FC9

Attachment: signature.asc
Description: OpenPGP digital signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]