On Tue, 2006-07-25 at 21:33 -0400, muppet wrote:
On Jul 25, 2006, at 4:59 PM, Dirk Koopman wrote:1. How do I get a list of valid properties and signals for a widget?Glib::Type::list_signals() and Glib::Object::list_properties(). See the Glib::Type and Glib::Object manpages.
I've attached some code that uses this introspection to connect up signal handlers without even defining them in Glade. I have been in the habit of selecting signals in Glade and accepting the default signal handler name. Using this introspection technique, cuts out some clicking in Glade. If an application needs to handle a signal, the developer would simply implement the method. Here's how it works: Given a form from Glade and an object say $app, the code walks down the widget tree (from the top-level form window) looking for named widgets. For each named widget, the code then uses Glib::Type::list_signals and Glib::Type::list_ancestors to find all the signals that that widget could emit. For each named widget (e.g.: 'first_name') and each signal (e.g.: 'activate'), the code checks if the object has a method called <widget_name>_<signal_name> (eg: if $app->can('first_name_activate') ) and if it does, the method is hooked up using signal_connect. It might be the craziest idea I've come up with this week. But it could be useful. Cheers Grant
Attachment:
form_test.pl
Description: Perl program
Attachment:
form_test.glade
Description: application/glade