guile-user
[Top][All Lists]
Advanced

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

Re: [OT?] libglade, guile-gtk and glade-xml-signal-autoconnect


From: Bill Gribble
Subject: Re: [OT?] libglade, guile-gtk and glade-xml-signal-autoconnect
Date: 30 Jan 2002 07:51:16 -0600

On Tue, 2002-01-29 at 13:30, Brett Viren wrote:
 > (let ((xml (glade-xml-new "file.glade")))
> ;;...
>   (glade-xml-signal-autoconnect       xml)
> ;; ...
> )
> 
> The only problem is that if I attach signal handler names to widget
> signals inside the glade app and then define these as functions in my
> .scm file, they are not picked up.  It works to ask the XML object for
> a particular widget and then do a (gtk-signal-connect ...) but this is
> tedious.

The current behavior is that the C function binding for the specified
name is used by autoconnect.  i.e., you can't directly specify a scheme
function name in the signal handler slot in the Glade file.  This
preserves the semantics that libglade expects.  So, for example, if you
use 'gtk_main_quit' as the signal handler for a widget you will still
quit the app.  

It would be nice to have a way to specify that the function name is
Scheme rather than C.  Since libglade seems to silently drop things that
don't map to C functions, you could have a naming convention that signal
handlers starting with scm: are treated as Scheme functions and invoked
via a wrapper.  autoconnect could be wrapped with a little test that
makes those connections. 

However, the guile-gtk wrappers make assumptions about the availability
of lexical closure for signal handlers.  For example, the 'widget'
argument is always omitted, with the assumption that an anonymous
function will be used as the handler:

  (gtk-signal-connect 
    widget "clicked"
    (lambda () 
      (simple-format #t "widget ~A was clicked.\n" widget)))

The Scheme handler for the "clicked" signal is arity 0, but the C
function is arity 1. If you wanted the handler to be a top-level
function, the handler would have to figure out a way to determine what
the "widget" argument to the C handler would have been.

I find the current behavior convenient, because I like using anonymous
functions as signal handlers.

What would happen if you used a generic Scheme function-caller as the
signal handler, and put a literal C string with quotes in the "data"
field?  the string could be the Scheme function name.  This might not
work at all, I'm just thinking out loud. 

b.g.









> 
> So, what I'd like to know is if this is expected behavior, or if I am
> missing something.  Eg, do these signal handler symbols live in some
> other "namespace" (right term?) than the default?
> 
> I am using guile 1.4.1, glade 0.6.2, libglade 0.17, libguilegnome 0.20
> on Debian x86.
>  
> Attached are glade and scm files showing what I mean.  The signal
> handler I told Glade to use with the button's signal is
> "button-clicked-callback" and is defined in button.scm.
> 
> Thanks for any enlightenment, and apologies if this is too far afield
> for this list.
> 
> -Brett
> 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]