Lines Matching refs:Handler
62 * handler" or "default (signal) handler", while user provided callbacks are
63 * usually just called "signal handler".
64 * The object method handler is provided at signal creation time (this most
72 * 1 - Invocation of the object method handler for %G_SIGNAL_RUN_FIRST signals
78 * 3 - Invocation of the object method handler for %G_SIGNAL_RUN_LAST signals
84 * 5 - Invocation of the object method handler for %G_SIGNAL_RUN_CLEANUP signals
96 * handler has to get unblocked exactly the same amount of times
100 * argument of the signal handler currently subject to invocation.
119 typedef struct _Handler Handler;
139 static inline Handler* handler_new (gboolean after);
142 Handler *handler);
143 static Handler* handler_lookup (gpointer instance,
147 Handler *handler,
159 static inline void handler_ref (Handler *handler);
162 Handler *handler);
239 Handler *handlers;
240 Handler *tail_before; /* normal signal handlers are appended here */
241 Handler *tail_after; /* CONNECT_AFTER handlers are appended here */
247 Handler *next;
248 Handler *prev;
258 Handler *handler;
414 static Handler*
428 Handler *handler;
430 for (handler = hlist->handlers; handler; handler = handler->next)
431 if (handler->sequential_number == handler_id)
436 return handler;
446 Handler *handler,
452 node->handler = handler;
455 handler_ref (handler);
465 handler_unref_R (node->signal_id, instance, node->handler);
486 Handler *handler;
497 for (handler = hlist ? hlist->handlers : NULL; handler; handler = handler->next)
498 if (handler->sequential_number &&
499 ((mask & G_SIGNAL_MATCH_DETAIL) || handler->detail == detail) &&
500 ((mask & G_SIGNAL_MATCH_CLOSURE) || handler->closure == closure) &&
501 ((mask & G_SIGNAL_MATCH_DATA) || handler->closure->data == data) &&
502 ((mask & G_SIGNAL_MATCH_UNBLOCKED) || handler->block_count == 0) &&
503 ((mask & G_SIGNAL_MATCH_FUNC) || (handler->closure->marshal == node->c_marshaller &&
504 handler->closure->meta_marshal == 0 &&
505 ((GCClosure*) handler->closure)->callback == func)))
507 mlist = handler_match_prepend (mlist, handler, signal_id);
525 Handler *handler;
534 for (handler = hlist->handlers; handler; handler = handler->next)
535 if (handler->sequential_number &&
536 ((mask & G_SIGNAL_MATCH_DETAIL) || handler->detail == detail) &&
537 ((mask & G_SIGNAL_MATCH_CLOSURE) || handler->closure == closure) &&
538 ((mask & G_SIGNAL_MATCH_DATA) || handler->closure->data == data) &&
539 ((mask & G_SIGNAL_MATCH_UNBLOCKED) || handler->block_count == 0) &&
540 ((mask & G_SIGNAL_MATCH_FUNC) || (handler->closure->marshal == node->c_marshaller &&
541 handler->closure->meta_marshal == 0 &&
542 ((GCClosure*) handler->closure)->callback == func)))
544 mlist = handler_match_prepend (mlist, handler, hlist->signal_id);
555 static inline Handler*
558 Handler *handler = g_slice_new (Handler);
561 g_error (G_STRLOC ": handler id overflow, %s", REPORT_BUG);
564 handler->sequential_number = g_handler_sequential_number++;
565 handler->prev = NULL;
566 handler->next = NULL;
567 handler->detail = 0;
568 handler->ref_count = 1;
569 handler->block_count = 0;
570 handler->after = after != FALSE;
571 handler->closure = NULL;
573 return handler;
577 handler_ref (Handler *handler)
579 g_return_if_fail (handler->ref_count > 0);
581 g_atomic_int_inc ((int *)&handler->ref_count);
587 Handler *handler)
591 g_return_if_fail (handler->ref_count > 0);
593 is_zero = g_atomic_int_dec_and_test ((int *)&handler->ref_count);
599 if (handler->next)
600 handler->next->prev = handler->prev;
601 if (handler->prev) /* watch out for g_signal_handlers_destroy()! */
602 handler->prev->next = handler->next;
606 hlist->handlers = handler->next;
611 /* check if we are removing the handler pointed to by tail_before */
612 if (!handler->after && (!handler->next || handler->next->after))
618 g_assert (hlist->tail_before == handler); /* paranoid */
619 hlist->tail_before = handler->prev;
623 /* check if we are removing the handler pointed to by tail_after */
624 if (!handler->next)
630 g_assert (hlist->tail_after == handler); /* paranoid */
631 hlist->tail_after = handler->prev;
637 g_closure_unref (handler->closure);
639 g_slice_free (Handler, handler);
646 Handler *handler)
650 g_assert (handler->prev == NULL && handler->next == NULL); /* paranoid */
655 hlist->handlers = handler;
656 if (!handler->after)
657 hlist->tail_before = handler;
659 else if (handler->after)
661 handler->prev = hlist->tail_after;
662 hlist->tail_after->next = handler;
668 handler->next = hlist->tail_before->next;
669 if (handler->next)
670 handler->next->prev = handler;
671 handler->prev = hlist->tail_before;
672 hlist->tail_before->next = handler;
674 else /* insert !after handler into a list of only after handlers */
676 handler->next = hlist->handlers;
677 if (handler->next)
678 handler->next->prev = handler;
679 hlist->handlers = handler;
681 hlist->tail_before = handler;
684 if (!handler->next)
685 hlist->tail_after = handler;
773 /* setup handler list binary searchable array hash table (in german, that'd be one word ;) */
1284 * the default handler is to be invoked. You should at least specify
1357 * the default handler is to be invoked. You should at least specify
1374 * off a class offset for the signal's class handler. This function
1488 * the default handler is to be invoked. You should at least specify
1646 * the default handler is to be invoked. You should at least specify
1760 * Overrides the class closure (i.e. the default handler) for the given signal
1797 * @instance_type: the instance type on which to override the class handler
1799 * @class_handler: the handler.
1801 * Overrides the class closure (i.e. the default handler) for the
2100 * @after: whether the handler should be called before or after the
2101 * default handler of the signal.
2105 * Returns: the handler id
2131 Handler *handler = handler_new (after);
2133 handler_seq_no = handler->sequential_number;
2134 handler->detail = detail;
2135 handler->closure = g_closure_ref (closure);
2137 handler_insert (signal_id, instance, handler);
2154 * @after: whether the handler should be called before or after the
2155 * default handler of the signal.
2159 * Returns: the handler id
2189 Handler *handler = handler_new (after);
2191 handler_seq_no = handler->sequential_number;
2192 handler->detail = detail;
2193 handler->closure = g_closure_ref (closure);
2195 handler_insert (signal_id, instance, handler);
2196 if (node->c_marshaller && G_CLOSURE_NEEDS_MARSHAL (handler->closure))
2197 g_closure_set_marshal (handler->closure, node->c_marshaller);
2218 * which will be called when the signal handler is disconnected and no longer
2222 * Returns: the handler id
2258 Handler *handler = handler_new (after);
2260 handler_seq_no = handler->sequential_number;
2261 handler->detail = detail;
2262 handler->closure = g_closure_ref ((swapped ? g_cclosure_new_swap : g_cclosure_new) (c_handler, data, destroy_data));
2263 g_closure_sink (handler->closure);
2264 handler_insert (signal_id, instance, handler);
2265 if (node->c_marshaller && G_CLOSURE_NEEDS_MARSHAL (handler->closure))
2266 g_closure_set_marshal (handler->closure, node->c_marshaller);
2278 * @instance: The instance to block the signal handler of.
2279 * @handler_id: Handler id of the handler to be blocked.
2281 * Blocks a handler of an instance so it will not be called during any
2283 * signal handler means to temporarily deactive it, a signal handler
2287 * The @handler_id has to be a valid signal handler id, connected to a
2294 Handler *handler;
2300 handler = handler_lookup (instance, handler_id, NULL);
2301 if (handler)
2304 if (handler->block_count >= HANDLER_MAX_BLOCK_COUNT - 1)
2305 g_error (G_STRLOC ": handler block_count overflow, %s", REPORT_BUG);
2307 handler->block_count += 1;
2310 g_warning ("%s: instance `%p' has no handler with id `%lu'", G_STRLOC, instance, handler_id);
2316 * @instance: The instance to unblock the signal handler of.
2317 * @handler_id: Handler id of the handler to be unblocked.
2320 * blocked handler is skipped during signal emissions and will not be
2322 * blocked before) reverts its "blocked" state, so the handler will be
2326 * whether the unblocked handler in question is called as part of a
2330 * The @handler_id has to be a valid id of a signal handler that is
2337 Handler *handler;
2343 handler = handler_lookup (instance, handler_id, NULL);
2344 if (handler)
2346 if (handler->block_count)
2347 handler->block_count -= 1;
2349 g_warning (G_STRLOC ": handler `%lu' of instance `%p' is not blocked", handler_id, instance);
2352 g_warning ("%s: instance `%p' has no handler with id `%lu'", G_STRLOC, instance, handler_id);
2358 * @instance: The instance to remove the signal handler from.
2359 * @handler_id: Handler id of the handler to be disconnected.
2361 * Disconnects a handler from an instance so it will not be called during
2365 * The @handler_id has to be a valid signal handler id, connected to a
2372 Handler *handler;
2379 handler = handler_lookup (instance, handler_id, &signal_id);
2380 if (handler)
2382 handler->sequential_number = 0;
2383 handler->block_count = 1;
2384 handler_unref_R (signal_id, instance, handler);
2387 g_warning ("%s: instance `%p' has no handler with id `%lu'", G_STRLOC, instance, handler_id);
2393 * @instance: The instance where a signal handler is sought.
2394 * @handler_id: the handler id.
2396 * Returns whether @handler_id is the id of a handler connected to @instance.
2398 * Returns: whether @handler_id identifies a handler connected to @instance.
2404 Handler *handler;
2410 handler = handler_lookup (instance, handler_id, NULL);
2411 connected = handler != NULL;
2436 Handler *handler = hlist->handlers;
2438 while (handler)
2440 Handler *tmp = handler;
2442 handler = tmp->next;
2461 * @instance: The instance owning the signal handler to be found.
2463 * and/or @data the handler has to match.
2464 * @signal_id: Signal the handler has to be connected to.
2465 * @detail: Signal detail the handler has to be connected to.
2466 * @closure: The closure the handler will invoke.
2467 * @func: The C closure callback of the handler (useless for non-C closures).
2468 * @data: The closure data of the handler's closure.
2470 * Finds the first signal handler that matches certain selection criteria.
2474 * If no handler was found, 0 is returned.
2476 * Returns: A valid non-0 signal handler id for a successful match.
2500 handler_seq_no = mlist->handler->sequential_number;
2527 if (mlist->handler->sequential_number)
2530 callback (instance, mlist->handler->sequential_number);
2697 * Returns: %TRUE if a handler is connected to the signal, %FALSE
2754 /* is there a non-NULL class handler? */
3109 Handler *handler_list = NULL;
3229 Handler *handler = handler_list;
3232 handler_ref (handler);
3235 Handler *tmp;
3237 if (handler->after)
3240 handler_list = handler;
3243 else if (!handler->block_count && (!handler->detail || handler->detail == detail) &&
3244 handler->sequential_number < max_sequential_handler_number)
3247 g_closure_invoke (handler->closure,
3258 tmp = emission.state == EMISSION_RUN ? handler->next : NULL;
3261 tmp = handler->next;
3266 handler_list = handler;
3267 handler = tmp;
3269 while (handler);
3305 Handler *handler = handler_list;
3308 handler_ref (handler);
3311 Handler *tmp;
3313 if (handler->after && !handler->block_count && (!handler->detail || handler->detail == detail) &&
3314 handler->sequential_number < max_sequential_handler_number)
3317 g_closure_invoke (handler->closure,
3328 tmp = emission.state == EMISSION_RUN ? handler->next : NULL;
3331 tmp = handler->next;
3335 handler_unref_R (signal_id, instance, handler);
3336 handler = tmp;
3338 while (handler);