Re: Are there such tings like custom signals?

On Mon, 23 Jan 2012 08:41:22 -0700
Michael Torrie <torriem gmail com> wrote:
On 01/23/2012 02:18 AM, Manuel Ferrero wrote:
Il 20/01/2012 18.08, Jack ha scritto:

However, that is separate from knowing that the button has been
pushed, so you can then start the communications. For this, is
there any reason to use a custom signal? Wouldn't it be easier to
catch the standard signal emitted when a button is pushed, by
attaching a call-back routine?

Infact there is no need for a custom signal once you know about
GIOChannel. But my question was intended for general cases. If I
need to trigger a complicated task when a button is pushed I'll
write a callback to manage the standard signal in which I'll start
my $COMPLEX_PROCESS then return. The question was about how to
write $COMPLEX_PROCESS: it doesn't involve GUI so it doesn't have
any standard signal, but I'd like to have the signal-callback
paradigm and I was wondering if GTK gives me some tool or if I have
to rely on an external infrastructure for it.

GTK indeed gives you a tool for generating your own signals.  You can
then catch them normally.

This runs the risk of being horribly misunderstood.  You don't "catch"
emissions from GSignal objects, you connect to them (you "catch" unix/C
asynchronous signals and interrupts).  And rather than "generating" a
GSignal, you implement a GObject which registers the signal in its
class init function to connect to, and emit on the signal.

But the OP's reference to GIOChannels (which don't use GSignals) may
indicate that he wants something different, namely to execute an event
in a glib main loop.  g_idle_add() is available for that.


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