usually just called "signal handler".
The object method handler is provided at signal creation time (this most
frequently happens at the end of an object class' creation), while user
-provided handlers are frequently @connected and @disconnected to/from a certain
+provided handlers are frequently connected and disconnected to/from a certain
signal on certain object instances.
</para>
<para>
to callbacks during a signal emission.
</para>
-@signal_id: The signal id of the signal invoking the callback
-@detail: The detail passed on for this emission
-@run_type: The stage the signal emission is currently in, this
+@signal_id: The signal id of the signal invoking the callback
+@detail: The detail passed on for this emission
+@run_type: The stage the signal emission is currently in, this
field will contain one of @G_SIGNAL_RUN_FIRST,
@G_SIGNAL_RUN_LAST or @G_SIGNAL_RUN_CLEANUP.
value returned by the last callback.
</para>
-@ihint: Signal invokation hint, see @GSignalInvocationHint
-@return_accu: Accumulator to collect callback return values in, this
+@ihint: Signal invokation hint, see @GSignalInvocationHint
+@return_accu: Accumulator to collect callback return values in, this
is the return value of the current signal emission
-@return_value: The return value of the most recent callback function
-@Returns: The accumulator function returns whether the signal emission
+@return_value: The return value of the most recent callback function
+@Returns: The accumulator function returns whether the signal emission
should be aborted. Returning @FALSE means to abort the
current emission and @TRUE is returned for continuation.
filled in by the g_signal_query() function.
</para>
-@signal_id: The signal id of the signal being querried, or 0 if the
+@signal_id: The signal id of the signal being querried, or 0 if the
signal to be querried was unknown
-@signal_name: The signal name
-@itype: The interface/instance type that this signal can be emitted for
-@signal_flags: The signal flags as passed in to @g_signal_new()
-@return_type: The return type for user callbacks
-@n_params: The number of parameters that user callbacks take
-@param_types: The individual parameter types for user callbacks, note that the
+@signal_name: The signal name
+@itype: The interface/instance type that this signal can be emitted for
+@signal_flags: The signal flags as passed in to @g_signal_new()
+@return_type: The return type for user callbacks
+@n_params: The number of parameters that user callbacks take
+@param_types: The individual parameter types for user callbacks, note that the
effective callback signature is:
<msgtext><programlisting>
@return_type callback (@gpointer data1,
be considered constant and have to be left untouched.
</para>
-@signal_id: The signal id of the signal to query information for
-@query: A user provided structure that is filled in with constant
+@signal_id: The signal id of the signal to query information for
+@query: A user provided structure that is filled in with constant
values upon success.
g_signal_query().
</para>
-@itype: Instance or interface type
-@n_ids: Location to store the number of signal ids for @itype
-@Returns: Newly allocated array of signal ids
+@itype: Instance or interface type
+@n_ids: Location to store the number of signal ids for @itype
+@Returns: Newly allocated array of signal ids
-<!-- ##### FUNCTION g_signal_connect_closure ##### -->
+<!-- ##### FUNCTION g_signal_connect_closure_by_id ##### -->
<para>
</para>
@instance.
</para>
-@instance: The instance to block the signal handler of
-@handler_id: Handler id of the handler to be blocked
+@instance: The instance to block the signal handler of
+@handler_id: Handler id of the handler to be blocked
+
<!-- ##### FUNCTION g_signal_handler_unblock ##### -->
<para>
signal of @instance and is currently blocked.
</para>
-@instance: The instance to unblock the signal handler of
-@handler_id: Handler id of the handler to be unblocked
+@instance: The instance to unblock the signal handler of
+@handler_id: Handler id of the handler to be unblocked
<!-- ##### FUNCTION g_signal_handler_disconnect ##### -->
@instance.
</para>
-@instance: The instance to remove the signal handler from
-@handler_id: Handler id of the handler to be disconnected
+@instance: The instance to remove the signal handler from
+@handler_id: Handler id of the handler to be disconnected
<!-- ##### FUNCTION g_signal_handler_find ##### -->
If no handler was found, 0 is returned.
</para>
-@instance: The instance owning the signal handler to be found
-@mask: Mask indicating which of @signal_id, @detail,
+@instance: The instance owning the signal handler to be found
+@mask: Mask indicating which of @signal_id, @detail,
@closure, @func and/or @data the handler has to match
-@signal_id: Signal the handler has to be connected to
-@detail: Signal detail the handler has to be connected to
-@closure: The closure the handler will invoke
-@func: The C closure callback of the handler (useless for non-C closures)
-@data: The closure data of the handler's closure
-@Returns: A valid non-0 signal handler id for a successfull match
+@signal_id: Signal the handler has to be connected to
+@detail: Signal detail the handler has to be connected to
+@closure: The closure the handler will invoke
+@func: The C closure callback of the handler (useless for non-C closures)
+@data: The closure data of the handler's closure
+@Returns: A valid non-0 signal handler id for a successfull match
<!-- ##### FUNCTION g_signal_handlers_block_matched ##### -->
otherwise.
</para>
-@instance: The instance to block handlers from
-@mask: Mask indicating which of @signal_id, @detail,
- @closure, @func and/or @data the handlers have to match
-@signal_id: Signal the handlers have to be connected to
-@detail: Signal detail the handlers have to be connected to
-@closure: The closure the handlers will invoke
-@func: The C closure callback of the handlers (useless for non-C closures)
-@data: The closure data of the handlers' closures
-@Returns: The amount of handlers that got blocked
+@instance: The instance to block handlers from
+@mask: Mask indicating which of @signal_id, @detail,
+ @closure, @func and/or @data the handlers have to match
+@signal_id: Signal the handlers have to be connected to
+@detail: Signal detail the handlers have to be connected to
+@closure: The closure the handlers will invoke
+@func: The C closure callback of the handlers (useless for non-C closures)
+@data: The closure data of the handlers' closures
+@Returns: The amount of handlers that got blocked
<!-- ##### FUNCTION g_signal_handlers_unblock_matched ##### -->
not currently blocked.
</para>
-@instance: The instance to unblock handlers from
-@mask: Mask indicating which of @signal_id, @detail,
+@instance: The instance to unblock handlers from
+@mask: Mask indicating which of @signal_id, @detail,
@closure, @func and/or @data the handlers have to match
-@signal_id: Signal the handlers have to be connected to
-@detail: Signal detail the handlers have to be connected to
-@closure: The closure the handlers will invoke
-@func: The C closure callback of the handlers (useless for non-C closures)
-@data: The closure data of the handlers' closures
-@Returns: The amount of handlers that got unblocked
+@signal_id: Signal the handlers have to be connected to
+@detail: Signal detail the handlers have to be connected to
+@closure: The closure the handlers will invoke
+@func: The C closure callback of the handlers (useless for non-C closures)
+@data: The closure data of the handlers' closures
+@Returns: The amount of handlers that got unblocked
<!-- ##### FUNCTION g_signal_handlers_disconnect_matched ##### -->
otherwise.
</para>
-@instance: The instance to remove handlers from
-@mask: Mask indicating which of @signal_id, @detail,
- @closure, @func and/or @data the handlers have to match
-@signal_id: Signal the handlers have to be connected to
-@detail: Signal detail the handlers have to be connected to
-@closure: The closure the handlers will invoke
-@func: The C closure callback of the handlers (useless for non-C closures)
-@data: The closure data of the handlers' closures
-@Returns: The amount of handlers that got disconnected
+@instance: The instance to remove handlers from
+@mask: Mask indicating which of @signal_id, @detail,
+ @closure, @func and/or @data the handlers have to match
+@signal_id: Signal the handlers have to be connected to
+@detail: Signal detail the handlers have to be connected to
+@closure: The closure the handlers will invoke
+@func: The C closure callback of the handlers (useless for non-C closures)
+@data: The closure data of the handlers' closures
+@Returns: The amount of handlers that got disconnected
<!-- ##### FUNCTION g_signal_has_handler_pending ##### -->
@hook_id:
-<!-- ##### FUNCTION g_signal_handlers_destroy ##### -->
-<para>
-
-</para>
-
-@instance:
-
-
-<!-- ##### FUNCTION g_signals_destroy ##### -->
+<!-- ##### FUNCTION g_signal_parse_name ##### -->
<para>
-
+Internal function to parse a signal names into its @signal_id
+and @detail quark.
</para>
-@itype:
+@detailed_signal: A string of the form "signal-name::detail"
+@itype: The interface/instance type taht introduced "signal-name"
+@signal_id_p: Location to store the signal id
+@detail_p: Location to stroe the detail quark
+@force_detail_quark: %TRUE forces creation of a GQuark for the detail
+@Returns: Whether the signal name could successfully be parsed and
+ @signal_id_p and @detail_p contain valid return values.
{
if (handler->next)
handler->next->prev = handler->prev;
- if (handler->prev) /* watch out for g_signal_handlers_destroy()! */
+ if (handler->prev) /* watch out for _g_signal_handlers_destroy()! */
handler->prev->next = handler->next;
else
{
}
void
-g_signals_destroy (GType itype)
+_g_signals_destroy (GType itype)
{
guint i;
G_UNLOCK (g_signal_mutex);
}
+static inline guint
+signal_parse_name (const gchar *name,
+ GType itype,
+ GQuark *detail_p,
+ gboolean force_quark)
+{
+ const gchar *colon = strchr (name, ':');
+ guint signal_id;
+
+ if (!colon)
+ {
+ signal_id = signal_id_lookup (g_quark_try_string (name), itype);
+ if (signal_id && detail_p)
+ *detail_p = 0;
+ }
+ else if (colon[1] == ':')
+ {
+ gchar buffer[32];
+ guint l = colon - name;
+
+ if (l < 32)
+ {
+ memcpy (buffer, name, l);
+ buffer[l] = 0;
+ signal_id = signal_id_lookup (g_quark_try_string (buffer), itype);
+ }
+ else
+ {
+ gchar *signal = g_new (gchar, l + 1);
+
+ memcpy (signal, name, l);
+ signal[l] = 0;
+ signal_id = signal_id_lookup (g_quark_try_string (signal), itype);
+ g_free (signal);
+ }
+
+ if (signal_id && detail_p)
+ *detail_p = colon[2] ? (force_quark ? g_quark_from_string : g_quark_try_string) (colon + 2) : 0;
+ }
+ else
+ signal_id = 0;
+ return signal_id;
+}
+
+gboolean
+g_signal_parse_name (const gchar *detailed_signal,
+ GType itype,
+ guint *signal_id_p,
+ GQuark *detail_p,
+ gboolean force_detail_quark)
+{
+ GQuark detail = 0;
+ guint signal_id;
+
+ g_return_val_if_fail (detailed_signal != NULL, FALSE);
+ g_return_val_if_fail (G_TYPE_IS_INSTANTIATABLE (itype) || G_TYPE_IS_INTERFACE (itype), FALSE);
+
+ G_LOCK (g_signal_mutex);
+ signal_id = signal_parse_name (detailed_signal, itype, &detail, force_detail_quark);
+ G_UNLOCK (g_signal_mutex);
+
+ if (signal_id)
+ {
+ if (signal_id_p)
+ *signal_id_p = signal_id;
+ if (detail_p)
+ *detail_p = detail;
+
+ return TRUE;
+ }
+ else
+ return FALSE;
+}
+
guint
g_signal_lookup (const gchar *name,
GType itype)
}
guint
-g_signal_connect_closure (gpointer instance,
- guint signal_id,
- GQuark detail,
- GClosure *closure,
- gboolean after)
+g_signal_connect_closure_by_id (gpointer instance,
+ guint signal_id,
+ GQuark detail,
+ GClosure *closure,
+ gboolean after)
{
SignalNode *node;
guint handler_id = 0;
}
void
-g_signal_handlers_destroy (gpointer instance)
+_g_signal_handlers_destroy (gpointer instance)
{
GBSearchArray *hlbsa;