Re: Signals in Gtk+



Owen Taylor <otaylor@redhat.com> writes:

| > I need attributed signals. By this a widget would be able to say "yes
| > I want the timer signal, but only those running with 40 Hz".

|  gtk_signal_connect (GTK_OBJECT (forty_hz_timer), "expired",
|                      callback1, widget_a);
| 
|  gtk_signal_connect (GTK_OBJECT (fifty_hz_timer), "expired",
|                      callback2, widget_b);

I had something like this in mind:

  gtk_message_connect (GTK_OBJECT (widget_a), "clock", timer1, 40,
                       callback1);
  gtk_message_connect (GTK_OBJECT (widget_b), "clock", timer1, 50,
                       callback2);

This is not a signal any longer, but a message, because the client
reacts only on the signal, if the source (timer1) and the attribute
(Hz) matches.

But I am not sure if it makes sense to use signals for timer events,
because I do not know the overhead for a signal. An alternative can
be:

- writing a timer object
- the timer object does a gtk_input_add for the clock process
- the timer object has a `define' function to set the timeouts
- the timer object has a 'connect' function to register callbacks
  for the different timer events

What I tried to avoid is defining a new callback register function,
which possibly does not fit very well into the rest of the callback
stuff.

| Or are you saying you want a single object to generate both
| 40Hz and 50Hz signals?

Yes. When I use different objects for each timer, I have to put them
into a timer group, because they need to be synchronised.

-- 
/* In the beginning was the Word: */
typedef long SCM;



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