forked from AuroraMiddleware/gtk
Clarify section on g_signal_connect_swapped. (#120543, David Bourguignon)
2005-01-03 Matthias Clasen <mclasen@redhat.com> * docs/tutorial/gtk-tut.sgml: Clarify section on g_signal_connect_swapped. (#120543, David Bourguignon)
This commit is contained in:
parent
35dfce0f90
commit
af77a6b707
@ -1,5 +1,8 @@
|
|||||||
2005-01-03 Matthias Clasen <mclasen@redhat.com>
|
2005-01-03 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* docs/tutorial/gtk-tut.sgml: Clarify section on
|
||||||
|
g_signal_connect_swapped. (#120543, David Bourguignon)
|
||||||
|
|
||||||
Make gtk_icon_theme_load_icon() work independent of
|
Make gtk_icon_theme_load_icon() work independent of
|
||||||
icon factory initialization. (#162791, Tristan Van Berkom)
|
icon factory initialization. (#162791, Tristan Van Berkom)
|
||||||
|
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
2005-01-03 Matthias Clasen <mclasen@redhat.com>
|
2005-01-03 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* docs/tutorial/gtk-tut.sgml: Clarify section on
|
||||||
|
g_signal_connect_swapped. (#120543, David Bourguignon)
|
||||||
|
|
||||||
Make gtk_icon_theme_load_icon() work independent of
|
Make gtk_icon_theme_load_icon() work independent of
|
||||||
icon factory initialization. (#162791, Tristan Van Berkom)
|
icon factory initialization. (#162791, Tristan Van Berkom)
|
||||||
|
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
2005-01-03 Matthias Clasen <mclasen@redhat.com>
|
2005-01-03 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* docs/tutorial/gtk-tut.sgml: Clarify section on
|
||||||
|
g_signal_connect_swapped. (#120543, David Bourguignon)
|
||||||
|
|
||||||
Make gtk_icon_theme_load_icon() work independent of
|
Make gtk_icon_theme_load_icon() work independent of
|
||||||
icon factory initialization. (#162791, Tristan Van Berkom)
|
icon factory initialization. (#162791, Tristan Van Berkom)
|
||||||
|
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
2005-01-03 Matthias Clasen <mclasen@redhat.com>
|
2005-01-03 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* docs/tutorial/gtk-tut.sgml: Clarify section on
|
||||||
|
g_signal_connect_swapped. (#120543, David Bourguignon)
|
||||||
|
|
||||||
Make gtk_icon_theme_load_icon() work independent of
|
Make gtk_icon_theme_load_icon() work independent of
|
||||||
icon factory initialization. (#162791, Tristan Van Berkom)
|
icon factory initialization. (#162791, Tristan Van Berkom)
|
||||||
|
|
||||||
|
@ -527,11 +527,12 @@ function", and should generally be of the form</para>
|
|||||||
|
|
||||||
<programlisting role="C">
|
<programlisting role="C">
|
||||||
void callback_func( GtkWidget *widget,
|
void callback_func( GtkWidget *widget,
|
||||||
|
... /* other signal arguments */
|
||||||
gpointer callback_data );
|
gpointer callback_data );
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
|
||||||
<para>where the first argument will be a pointer to the widget that emitted
|
<para>where the first argument will be a pointer to the widget that emitted
|
||||||
the signal, and the second a pointer to the data given as the last
|
the signal, and the last a pointer to the data given as the last
|
||||||
argument to the g_signal_connect() function as shown above.</para>
|
argument to the g_signal_connect() function as shown above.</para>
|
||||||
|
|
||||||
<para>Note that the above form for a signal callback function declaration is
|
<para>Note that the above form for a signal callback function declaration is
|
||||||
@ -544,29 +545,29 @@ different calling parameters.</para>
|
|||||||
gulong g_signal_connect_swapped( gpointer *object,
|
gulong g_signal_connect_swapped( gpointer *object,
|
||||||
const gchar *name,
|
const gchar *name,
|
||||||
GCallback func,
|
GCallback func,
|
||||||
gpointer *slot_object );
|
gpointer *callback_data );
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
|
||||||
<para>g_signal_connect_swapped() is the same as g_signal_connect() except
|
<para>g_signal_connect_swapped() is the same as g_signal_connect() except
|
||||||
that the callback function only uses one argument, a pointer to a GTK
|
that the instance on which the signal is emitted and data will be swapped when
|
||||||
object. So when using this function to connect signals, the callback
|
calling the handler. So when using this function to connect signals, the callback
|
||||||
should be of the form</para>
|
should be of the form</para>
|
||||||
|
|
||||||
<programlisting role="C">
|
<programlisting role="C">
|
||||||
void callback_func( GtkObject *object );
|
void callback_func( gpointer callback_data,
|
||||||
|
... /* other signal arguments */
|
||||||
|
GtkWidget *widget);
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
|
||||||
<para>where the object is usually a widget. We usually don't setup callbacks
|
<para>where the object is usually a widget. We usually don't setup callbacks
|
||||||
for g_signal_connect_swapped() however. They are usually used to call a
|
for g_signal_connect_swapped() however. They are usually used to call a
|
||||||
GTK function that accepts a single widget or object as an argument, as
|
GTK function that accepts a single widget or object as an argument, when a signal
|
||||||
is the case in our <emphasis>helloworld</emphasis> example.</para>
|
is emitted on some <emphasis>other</emphasis> object. In the
|
||||||
|
<emphasis>helloworld</emphasis> example, we connect to the "clicked" signal
|
||||||
|
on the button, but call gtk_widget_destroy() on the window.</para>
|
||||||
|
|
||||||
<para>The purpose of having two functions to connect signals is simply to
|
<para>If your callbacks need additional data, use g_signal_connect() instead
|
||||||
allow the callbacks to have a different number of arguments. Many
|
of g_signal_connect_swapped().</para>
|
||||||
functions in the GTK library accept only a single GtkWidget pointer as
|
|
||||||
an argument, so you want to use the g_signal_connect_swapped() for
|
|
||||||
these, whereas for your functions, you may need to have additional
|
|
||||||
data supplied to the callbacks.</para>
|
|
||||||
|
|
||||||
</sect1>
|
</sect1>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user