PHP-GTK2 Cookbook Forum
Welcome, Guest
Please Login or Register.    Lost Password?
Custom signal? (1 viewing) (1) Guest
Go to bottom Post Reply Favoured: 0
TOPIC: Custom signal?
#96
prggr (User)
Fresh Boarder
Posts: 3
graphgraph
User Offline Click here to see the profile of this user
Custom signal? 5 Months, 3 Weeks ago Karma: 0  
Is there any way to emit a custom signal? I'm working on a widget which contains other widgets. It can handle the signals of the children just fine, but in some cases I want it to catch a child signal, do some processing, then emit its own signal for another hunk of code to catch and process. Is this even possible? I've gone looking all over the place in the docs, but can't find anything about sending out your own signals. Any ideas?

Thanks!
 
  The administrator has disabled public write access.
#97
kksou (Admin)
Admin
Posts: 232
graph
User Online Now Click here to see the profile of this user
Re:Custom signal? 5 Months, 3 Weeks ago Karma: 7  
Hi Prggr,

Don't think it's possible to emit a custom signal (at least for now).

However,
1) You can subclass an existing widget, and the extended widget will inherit all the corresponding signals.

2) Signals can propagate from one to the other. With careful design, you can let the signal propagate through all your children and do the appropriate signal handling you desired.

If you can give a bit more details on what you have in mind, I might be able to come out with some sample codes.

Regards,
/kksou
 
  The administrator has disabled public write access.
#98
auroraeosrose (User)
Fresh Boarder
Posts: 2
graphgraph
User Offline Click here to see the profile of this user
Re:Custom signal? 5 Months, 3 Weeks ago Karma: 0  
With the 2.0.0 release custom signals are now possible!

The demos/examples has a signals demonstration
http://cvs.php.net/viewvc.cgi/php-gtk/demos/examples/signals.php?view=markup

You define custom signals by extending a class and adding some "magic" property called $__gsignals. This should be an array of signal name to signal values. If you use 'override' you can override original signal handlers (like clicked). Otherwise you need to set an array of GObject signal types, a return type (optionally) for your signal handler, and an array of argument types for your signal handler. You don't have to, but you can create magic methods with the name __do_{name of signal, with any - replaced by _} that will be called every time your signal is emitted.

Then you "register" your new class as a GType using GObject::register_type('{name of class here');

Finally you use emit (or emit with args) to actually send your custom signal.

Have fun!
 
  The administrator has disabled public write access.
Go to top Post Reply
Powered by FireBoardget the latest posts directly to your desktop

Copyright © 2006-2008. kksou.com. All Rights Reserved