[linux-audio-dev] Re: a bit off topic: GUI-lib-programming (how does it usually work?)

Lars Luthman larsl at users.sourceforge.net
Sun Mar 5 15:31:16 UTC 2006


On Mon, 2006-03-06 at 02:00 +1100, Loki Davison wrote:
> On 3/6/06, Julien Claassen <julien at c-lab.de> wrote:
> > Hi!
> >   I know, this may be a bit off topic. But I've a dificulty:
> >   I'm currently programming a textbase "GUI"-lib. I want the programming API
> > to be similar to on of a real GUI-lib (gtk, you name them).
> >   Now I'm wondering, there are menus. Menus have menuitems and if you click
> > on
> > one, something should happen. How is this "something should happen" part
> > usually done?
> 
> It's done by registering a call back. In current gtk versions this is
> done by having actions and they have a label and are associated with a
> particular function. Using the python bindings
> http://www.pygtk.org/pygtk2tutorial/sec-UIManager.html explains the
> general idea for menus. There is an example there. All buttons etc in
> gtk work the same i.e with call backs being registered.

Also, if you are using C++ it is nice to be able to use any callable
object as a callback instead of only function pointers, so you can
register member functions and your own functors. That can be done using
some template tricks. libsigc++ is great implementation of this (it is
used by gtkmm), and I think there is something similar in Boost as well.

-- 
Lars Luthman
PGP key:     http://www.student.nada.kth.se/~d00-llu/pgp_key.php
Fingerprint: FCA7 C790 19B9 322D EB7A  E1B3 4371 4650 04C7 7E2E
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://lists.linuxaudio.org/pipermail/linux-audio-dev/attachments/20060305/a0ec4c22/attachment.pgp>


More information about the Linux-audio-dev mailing list