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

From: Lars Luthman <larsl@email-addr-hidden>
Date: Sun Mar 05 2006 - 17:31:16 EET

On Mon, 2006-03-06 at 02:00 +1100, Loki Davison wrote:
> On 3/6/06, Julien Claassen <julien@email-addr-hidden-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

Received on Sun Mar 5 20:15:07 2006

This archive was generated by hypermail 2.1.8 : Sun Mar 05 2006 - 20:15:07 EET