Esempio n. 1
0
static void
gnc_gconf_general_changed (GConfClient *client,
                           guint cnxn_id,
                           GConfEntry *entry,
                           gpointer data)
{
    const gchar *key, *key_tail;
    GHookList *hook_list;

    g_once(&gcb_init_once, gcb_init, NULL);

    key = gconf_entry_get_key(entry);
    key_tail = strrchr(key, '/');
    if (key_tail != NULL)
    {
        key_tail++;
    }
    if (key_tail == NULL)
    {
        /* Should never happen. */
        g_warning("Malformed key %s:", key);
        return;
    }

    hook_list = g_hash_table_lookup(gcb_callback_hash, key_tail);
    if (hook_list != NULL)
        g_hook_list_marshal(hook_list, TRUE, gcb_call_hook, entry);
    g_hook_list_invoke(gcb_final_hook_list, TRUE);
}
Esempio n. 2
0
void
GHookListPrint(gpointer key, gpointer value, gpointer data)
{
    const char *hookName = (const char*)key;
    GHookList *hookList = (GHookList*)value;

    g_info("InitList: %s", hookName);
    g_hook_list_marshal(hookList, TRUE, GProritizedHookPrint, NULL);
}
Esempio n. 3
0
void *
gth_hook_invoke_get (const char *name,
		     gpointer    first_data,
		     ...)
{
	GthHook         *hook;
	gpointer        *marshal_data;
	int              i = 0;
	va_list          args;
	GHookMarshaller  invoke_marshaller;
	void            *value;

	hook = GET_HOOK_OR_NULL (name);
	marshal_data = g_new0 (gpointer, hook->n_args + 1);
	marshal_data[hook->n_args] = NULL;

	if (hook->n_args > 0) {
		marshal_data[i++] = first_data;
		va_start (args, first_data);
		while (i < hook->n_args)
			marshal_data[i++] = va_arg (args, gpointer);
		va_end (args);
	}

	switch (hook->n_args) {
	case 0:
		invoke_marshaller = invoke_marshaller_0_get;
		break;
	case 1:
		invoke_marshaller = invoke_marshaller_1_get;
		break;
	case 2:
		invoke_marshaller = invoke_marshaller_2_get;
		break;
	case 3:
		invoke_marshaller = invoke_marshaller_3_get;
		break;
	case 4:
		invoke_marshaller = invoke_marshaller_4_get;
		break;
	default:
		invoke_marshaller = NULL;
		break;
	}

	g_mutex_lock (&hook->mutex);
	if (invoke_marshaller != NULL)
		g_hook_list_marshal (hook->list, TRUE, invoke_marshaller, marshal_data);
	g_mutex_unlock (&hook->mutex);

	value = marshal_data[hook->n_args];

	g_free (marshal_data);

	return value;
}
Esempio n. 4
0
void
gnc_hook_run (const gchar *name, gpointer data)
{
    GncHook *hook;

    ENTER("list %s, data %p", (name == NULL ? "(null)" : name), data);
    hook = gnc_hook_lookup(name);
    if (!hook)
    {
        LEAVE("No such hook list");
        return;
    }
    g_hook_list_marshal(hook->c_danglers, TRUE, call_c_hook, data);
    if (hook->num_args == 0)
        g_hook_list_marshal(hook->scm_danglers, TRUE, call_scm_hook, data);
    else
        g_hook_list_marshal(hook->scm_danglers, TRUE, call_scm_hook_1, data);
    LEAVE("");
}
Esempio n. 5
0
void
gth_hook_invoke (const char *name,
		 gpointer    first_data,
		 ...)
{
	GthHook         *hook;
	gpointer        *marshal_data;
	int              i = 0;
	va_list          args;
	GHookMarshaller  invoke_marshaller;

	hook = GET_HOOK (name);
	marshal_data = g_new0 (gpointer, hook->n_args);

	if (first_data != NULL)
		marshal_data[i++] = first_data;

	va_start (args, first_data);
	while (i < hook->n_args)
		marshal_data[i++] = va_arg (args, gpointer);
	va_end (args);

	switch (hook->n_args) {
	case 0:
		invoke_marshaller = invoke_marshaller_0;
		break;
	case 1:
		invoke_marshaller = invoke_marshaller_1;
		break;
	case 2:
		invoke_marshaller = invoke_marshaller_2;
		break;
	case 3:
		invoke_marshaller = invoke_marshaller_3;
		break;
	case 4:
		invoke_marshaller = invoke_marshaller_4;
		break;
	default:
		invoke_marshaller = NULL;
		break;
	}

	if (invoke_marshaller != NULL)
		g_hook_list_marshal (hook->list, TRUE, invoke_marshaller, marshal_data);

	g_free (marshal_data);
}