⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gtk-signals.html

📁 该压缩包包含了GTK+的大量API函数
💻 HTML
📖 第 1 页 / 共 5 页
字号:
HREF=../glib/glib-basic-types.html#GUINT>guint</A> signal_id,                                             <AHREF="gtk-signals.html#GTKEMISSIONHOOK">GtkEmissionHook</A> hook_func,                                             <AHREF=../glib/glib-basic-types.html#GPOINTER>gpointer</A> data);<AHREF=../glib/glib-basic-types.html#GUINT>guint</A>       <AHREF="gtk-signals.html#GTK-SIGNAL-ADD-EMISSION-HOOK-FULL">gtk_signal_add_emission_hook_full</A>                                            (<AHREF=../glib/glib-basic-types.html#GUINT>guint</A> signal_id,                                             <AHREF="gtk-signals.html#GTKEMISSIONHOOK">GtkEmissionHook</A> hook_func,                                             <AHREF=../glib/glib-basic-types.html#GPOINTER>gpointer</A> data,                                             <AHREF=../glib/glib-datasets.html#GDESTROYNOTIFY>GDestroyNotify</A> destroy);void        <AHREF="gtk-signals.html#GTK-SIGNAL-REMOVE-EMISSION-HOOK">gtk_signal_remove_emission_hook</A> (<AHREF=../glib/glib-basic-types.html#GUINT>guint</A> signal_id,                                             <AHREF=../glib/glib-basic-types.html#GUINT>guint</A> hook_id);</PRE></TD></TR></TABLE></DIV><DIVCLASS="REFSECT1"><ANAME="AEN7803"></A><H2>Description</H2><DIVCLASS="REFSECT2"><ANAME="AEN7805"></A><H3>What are signals?</H3><P>Signals are a way to get notification when something happensand to customize object behavior according to theuser's needs.Every <ICLASS="WORDASWORD">signal</I> is uniquely identified by a name,"class_name::signal_name", where signal_name might be something like"clicked" and class_name might be "GtkButton".  Note that some other classmay also define a "clicked" callback, so long as it doesn't derive from<AHREF="gtkbutton.html">GtkButton</A>.</P><P>When they are created, they are also assigned a unique positive integer,the signal id (1 is the first signal id- 0 is used to flag an error).Each is also tied to an array of types that describesthe prototype of the function pointer(s) (handlers) you mayconnect to the signal.  Finally, every signal hasa default handler that is given by a function pointerin its class structure:  it is run by default whenever thesignal is emitted.  (It is possible that a signal willbe emitted and a user-defined handler will prevent the default handlerfrom being run.)</P><P>Signals are used by everyone, but they are onlycreated on a per class basis-- so you should callcall <AHREF="gtk-signals.html#GTK-SIGNAL-NEW">gtk_signal_new</A>() unless you are writinga new <AHREF="gtkobject.html">GtkObject</A> type.  However, if you want to make a new signalfor an existing type, you may use <AHREF="gtkobject.html#GTK-OBJECT-CLASS-USER-SIGNAL-NEW">gtk_object_class_user_signal_new</A>()to create a signal that doesn't correspond to a class's builtinmethods.</P></DIV><HR><DIVCLASS="REFSECT2"><ANAME="AEN7815"></A><H3>How are signals used?</H3><P>There are two basic actions in the signal handling game.If you want notification of an event, you must <ICLASS="EMPHASIS">connect</I>a function pointer and a data pointer to that signal;  the data pointerwill be passed as the last argument to the function (so long as youare using the default marshalling functions).You will receive a connection id, a unique positive integercorresponding to that attachment.</P><P>Functions that want to notify the user of certain actions,<ICLASS="EMPHASIS">emit</I> signals.</P></DIV><HR><DIVCLASS="REFSECT2"><ANAME="AEN7821"></A><H3>Basic Terminology</H3><P></P><DIVCLASS="VARIABLELIST"><DL><DT>signal</DT><DD><P>A class method, e.g. GtkButton::clicked.More precisely it is a unique class-branch/signal-name pair.This means you may not define a signal handler for a class whichderives from GtkButton that is called clicked,but it is okay to share signals names if they are separate inthe class tree.</P></DD><DT>default handler</DT><DD><P>The object's internal method which is invokedwhen the signal is emitted.</P></DD><DT>user-defined handler</DT><DD><P>A function pointer and data connectedto a signal (for a particular object).</P><P>There are really two types: those which are connectednormally, and those which are connected by one of the connect_after functions.  The connect_after handlersare always run after the default handler.</P><P>Many toolkits refer to these as <ICLASS="WORDASWORD">callbacks</I>.</P></DD><DT>emission</DT><DD><P>the whole process of emitting a signal,including the invocation of allthe different handler types mentioned above.</P></DD><DT>signal id</DT><DD><P>The unique positive (nonzero) integerused to identify a signal.  It can be used instead of a name to many functions for a slight performanceimprovement.</P></DD><DT>connection id</DT><DD><P>The unique positive (nonzero) integerused to identify the connection of a user-defined handlerto a signal.  Notice that it is allowed to connect thesame function-pointer/user-data pair twice, sothere is no guarantee that a function-pointer/user-datamaps to a unique connection id.</P></DD></DL></DIV></DIV><HR><DIVCLASS="REFSECT2"><ANAME="AEN7851"></A><H3>A brief note on how they work.</H3><P>The functions responsible for translating an array of GtkArgsto your C compiler's normal semantics are called Marshallers.They are identified bygtk_marshal_return_value__parameter_list()for example a C function returning a gboolean and taking a gintcan be invoked by using gtk_marshal_BOOL__INT().Not all possibly combinations of return/params are available,of course, so if you are writing a <AHREF="gtkobject.html">GtkObject</A> with parametersyou might have to write a marshaller.</P></DIV></DIV><DIVCLASS="REFSECT1"><ANAME="AEN7858"></A><H2>Details</H2><DIVCLASS="REFSECT2"><ANAME="AEN7860"></A><H3><ANAME="GTK-SIGNAL-OFFSET-CAPS"></A>GTK_SIGNAL_OFFSET()</H3><TABLEBORDER="0"BGCOLOR="#D6E8FF"WIDTH="100%"CELLPADDING="6"><TR><TD><PRECLASS="PROGRAMLISTING">#define GTK_SIGNAL_OFFSET(struct, field)	(GTK_STRUCT_OFFSET (struct, field))</PRE></TD></TR></TABLE><P></P><DIVCLASS="INFORMALTABLE"><ANAME="AEN7865"></A><P></P><TABLEBORDER="0"WIDTH="100%"BGCOLOR="#FFD0D0"CELLSPACING="0"CELLPADDING="4"CLASS="CALSTABLE"><TBODY><TR><TDWIDTH="20%"ALIGN="RIGHT"VALIGN="TOP"><TTCLASS="PARAMETER"><I>struct</I></TT>&nbsp;:</TD><TDWIDTH="80%"ALIGN="LEFT"VALIGN="TOP">&nbsp;</TD></TR><TR><TDWIDTH="20%"ALIGN="RIGHT"VALIGN="TOP"><TTCLASS="PARAMETER"><I>field</I></TT>&nbsp;:</TD><TDWIDTH="80%"ALIGN="LEFT"VALIGN="TOP">&nbsp;</TD></TR></TBODY></TABLE><P></P></DIV></DIV><HR><DIVCLASS="REFSECT2"><ANAME="AEN7878"></A><H3><ANAME="GTKSIGNALMARSHAL"></A>GtkSignalMarshal ()</H3><TABLEBORDER="0"BGCOLOR="#D6E8FF"WIDTH="100%"CELLPADDING="6"><TR><TD><PRECLASS="PROGRAMLISTING">void        (*GtkSignalMarshal)             (<AHREF="gtkobject.html">GtkObject</A> *object,                                             <AHREF=../glib/glib-basic-types.html#GPOINTER>gpointer</A> data,                                             <AHREF=../glib/glib-basic-types.html#GUINT>guint</A> nparams,                                             <AHREF="gtk-types.html#GTKARG">GtkArg</A> *args,                                             <AHREF="gtk-types.html#GTKTYPE">GtkType</A> *arg_types,                                             <AHREF="gtk-types.html#GTKTYPE">GtkType</A> return_type);</PRE></TD></TR></TABLE><P>This is currently a hack left in for a scheme wrapper library.It may be removed.</P><P>Don't use it.</P><DIVCLASS="INFORMALTABLE"><ANAME="AEN7890"></A><P></P><TABLEBORDER="0"WIDTH="100%"BGCOLOR="#FFD0D0"CELLSPACING="0"CELLPADDING="4"CLASS="CALSTABLE"><TBODY><TR><TDWIDTH="20%"ALIGN="RIGHT"VALIGN="TOP"><TTCLASS="PARAMETER"><I>object</I></TT>&nbsp;:</TD><TDWIDTH="80%"ALIGN="LEFT"VALIGN="TOP">The object which emits the signal.</TD></TR><TR><TDWIDTH="20%"ALIGN="RIGHT"VALIGN="TOP"><TTCLASS="PARAMETER"><I>data</I></TT>&nbsp;:</TD><TDWIDTH="80%"ALIGN="LEFT"VALIGN="TOP">The user data associated with the hook.</TD></TR><TR><TDWIDTH="20%"ALIGN="RIGHT"VALIGN="TOP"><TTCLASS="PARAMETER"><I>nparams</I></TT>&nbsp;:</TD><TDWIDTH="80%"ALIGN="LEFT"VALIGN="TOP">The number of parameters to the function.</TD></TR><TR><TDWIDTH="20%"ALIGN="RIGHT"VALIGN="TOP"><TTCLASS="PARAMETER"><I>args</I></TT>&nbsp;:</TD><TDWIDTH="80%"ALIGN="LEFT"VALIGN="TOP">The actual values of the arguments.</TD></TR><TR><TDWIDTH="20%"ALIGN="RIGHT"VALIGN="TOP"><TTCLASS="PARAMETER"><I>arg_types</I></TT>&nbsp;:</TD><TDWIDTH="80%"ALIGN="LEFT"VALIGN="TOP">The types of the arguments.</TD></TR><TR><TDWIDTH="20%"ALIGN="RIGHT"VALIGN="TOP"><TTCLASS="PARAMETER"><I>return_type</I></TT>&nbsp;:</TD><TDWIDTH="80%"ALIGN="LEFT"VALIGN="TOP">The type of the return value from the functionor GTK_TYPE_NONE for no return value.&#13;</TD></TR></TBODY></TABLE><P></P></DIV></DIV><HR><DIVCLASS="REFSECT2"><ANAME="AEN7920"></A><H3><ANAME="GTKSIGNALDESTROY"></A>GtkSignalDestroy ()</H3><TABLEBORDER="0"BGCOLOR="#D6E8FF"WIDTH="100%"CELLPADDING="6"><TR><TD><PRECLASS="PROGRAMLISTING">void        (*GtkSignalDestroy)             (<AHREF=../glib/glib-basic-types.html#GPOINTER>gpointer</A> data);</PRE></TD></TR></TABLE><P>A function which you can use to clean up when thesignal handler is destroyed.</P><P>For example, if your handler requires a few variablesthat you made into a struct and allocated (using <AHREF=../glib/glib-memory-allocation.html#G-NEW>g_new</A>()or something), then you will probably want to freeit as soon as the hook is destroyed.  This willallow you to do that. (For this in particularit is convenient to pass <AHREF=../glib/glib-memory-allocation.html#G-FREE>g_free</A>() as a <AHREF="gtk-signals.html#GTKSIGNALDESTROY">GtkSignalDestroy</A>function).</P><DIVCLASS="INFORMALTABLE"><ANAME="AEN7930"></A><P></P><TABLEBORDER="0"WIDTH="100%"BGCOLOR="#FFD0D0"CELLSPACING="0"CELLPADDING="4"CLASS="CALSTABLE"><TBODY><TR><TDWIDTH="20%"ALIGN="RIGHT"VALIGN="TOP"><TTCLASS="PARAMETER"><I>data</I></TT>&nbsp;:</TD><TDWIDTH="80%"ALIGN="LEFT"VALIGN="TOP">The user data associated with the hook that is beingdestroyed.&#13;</TD></TR></TBODY></TABLE><P></P></DIV></DIV><HR><DIVCLASS="REFSECT2"><ANAME="AEN7939"></A><H3><ANAME="GTKEMISSIONHOOK"></A>GtkEmissionHook ()</H3><TABLEBORDER="0"BGCOLOR="#D6E8FF"WIDTH="100%"CELLPADDING="6"><TR><TD><PRECLASS="PROGRAMLISTING"><AHREF=../glib/glib-basic-types.html#GBOOLEAN>gboolean</A>    (*GtkEmissionHook)              (<AHREF="gtkobject.html">GtkObject</A> *object,                                             <AHREF=../glib/glib-basic-types.html#GUINT>guint</A> signal_id,                                             <AHREF=../glib/glib-basic-types.html#GUINT>guint</A> n_params,                                             <AHREF="gtk-types.html#GTKARG">GtkArg</A> *params,                                             <AHREF=../glib/glib-basic-types.html#GPOINTER>gpointer</A> data);</PRE></TD></TR></TABLE><P>A simple function pointer to get invoked when thesignal is emitted.  This allows you tie a hook to the signal type,so that it will trap all emissions of that signal, from any object.</P><P>You may not attach these to signals created with theGTK_RUN_NO_HOOKS flag.</P><DIVCLASS="INFORMALTABLE"><ANAME="AEN7952"></A><P></P><TABLEBORDER="0"WIDTH="100%"BGCOLOR="#FFD0D0"CELLSPACING="0"CELLPADDING="4"CLASS="CALSTABLE"><TBODY><TR><TDWIDTH="20%"ALIGN="RIGHT"VALIGN="TOP"><TTCLASS="PARAMETER"><I>object</I></TT>&nbsp;:</TD><TDWIDTH="80%"ALIGN="LEFT"VALIGN="TOP">the object which emits the signal.</TD></TR><TR><TDWIDTH="20%"ALIGN="RIGHT"VALIGN="TOP"><TTCLASS="PARAMETER"><I>signal_id</I></TT>&nbsp;:</TD><TDWIDTH="80%"ALIGN="LEFT"VALIGN="TOP">the unique integer identify the signal type.</TD></TR><TR><TDWIDTH="20%"ALIGN="RIGHT"VALIGN="TOP"><TTCLASS="PARAMETER"><I>n_params</I></TT>&nbsp;:</TD><TDWIDTH="80%"ALIGN="LEFT"VALIGN="TOP">the number of parameters to the function,not including return value.</TD></TR><TR><TDWIDTH="20%"ALIGN="RIGHT"VALIGN="TOP"><TTCLASS="PARAMETER"><I>params</I></TT>&nbsp;:</TD><TDWIDTH="80%"ALIGN="LEFT"VALIGN="TOP">the parameters to the function.  A pointer tothe return value is passed as a last element.</TD></TR><TR><TDWIDTH="20%"ALIGN="RIGHT"VALIGN="TOP"><TTCLASS="PARAMETER"><I>data</I></TT>&nbsp;:</TD><TDWIDTH="80%"ALIGN="LEFT"VALIGN="TOP">the user data associated with the hook.</TD></TR><TR><TDWIDTH="20%"ALIGN="RIGHT"VALIGN="TOP"><ICLASS="EMPHASIS">Returns</I> :</TD><TDWIDTH="80%"ALIGN="LEFT"VALIGN="TOP">whether it wished to be removed.  If it returnsTRUE, the signal hook is disconnected (and destroyed).&#13;</TD></TR></TBODY></TABLE><P></P></DIV></DIV

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -