Re: g_signal



John Darrington wrote:

On Thu, Nov 07, 2002 at 12:44:37PM +0200, Olexiy Avramchenko wrote:
    John Darrington wrote:
>Can someone point me to an example of how to create a g_object that
    >emits g_signals.  The `documentation' is nothing more than a list of
    >function prototypes.  Furthermore, g_signal.h is uncommented...
    >
    Look at attached example, there's an GObject derived from GtkButton.
    It emits "pushed" signal when his parent emits "clicked".

Sorry, I should have been a bit more specific.
I'm looking for an example which uses g_signal, not gtk_signal (since the latter is
deprecated).  And I need to know how to create a g_signal (using
g_signal_new).  I can't work out what all the parameters are for when
browsing the header files, hence my request for an example.

You *did not* look at the source I've posted. I dont use gtk_signal* stuff in my gtk+-2.0 apps. The example contains new GObject class; the fact it is derived from GtkButton (which is the GObject too) doesn't mean that it is not GObject.
The created class *creates* a new signal "pushed" via *g_signal_new()*.

If you want to find quickly what parameters the signal is using you need to
browse the *source* files, not the headers.
Here's the g_signal_new prototype (cut from "glib-2.0.7/gobject/gsignal.h"):

guint                 g_signal_new          (const gchar        *signal_name,
                                             GType               itype,
                                             GSignalFlags        signal_flags,
                                             guint               class_offset,
                                             GSignalAccumulator  accumulator,
                                             gpointer            accu_data,
                                             GSignalCMarshaller  c_marshaller,
                                             GType               return_type,
                                             guint               n_params,
                                             ...);


The *return_type* is the the type of the signal callback function.
*n_params* - is the number of parameters of the signal callback.
After comes an array (of size n_params) of the types of parameters.


Look one more at example I've posted.
Look at "gtkwidget.c" file from GTK+-2.0 sources - that's the good place
to learn.

Olexiy





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