Exemplo n.º 1
0
gboolean frame_next_context_from_string(gchar *names, enum wm_frame_context *cx)
{
	gchar *p, *n;
	if(!*names)
		return FALSE;
	for(p = names; *p; p = g_utf8_next_char(p)) {
		const gunichar c = g_utf8_get_char(p);
		if(g_unichar_isspace(c))
			break;
	}
	if(p == names) {
		n = g_utf8_next_char(names);
		if(!frame_next_context_from_string(n, cx))
			return FALSE;
	} else {
		n = p;
		if(*p) {
			while(n < g_utf8_next_char(p))
				*(n++) = '\0';
		}
		*cx = frame_context_from_string(names);
		for(; *n; n = g_utf8_next_char(n)) {
			const gunichar c = g_utf8_get_char(n);
			if(!g_unichar_isspace(c))
				break;
		}
	}
	for(p = names; *n; ++p, ++n)
		*p = *n;
	*p = *n;
	return TRUE;
}
Exemplo n.º 2
0
Arquivo: mouse.c Projeto: godvmxi/obwm
gboolean mouse_bind(const gchar *buttonstr, const gchar *contextstr,
                    ObMouseAction mact, ObActionsAct *action)
{
    guint state, button;
    ObFrameContext context;
    ObMouseBinding *b;
    GSList *it;

    if (!translate_button(buttonstr, &state, &button)) {
        g_message(_("Invalid button \"%s\" in mouse binding"), buttonstr);
        return FALSE;
    }

    context = frame_context_from_string(contextstr);
    if (!context) {
        g_message(_("Invalid context \"%s\" in mouse binding"), contextstr);
        return FALSE;
    }

    for (it = bound_contexts[context]; it; it = g_slist_next(it)) {
        b = it->data;
        if (b->state == state && b->button == button) {
            b->actions[mact] = g_slist_append(b->actions[mact], action);
            return TRUE;
        }
    }

    /* add the binding */
    b = g_new0(ObMouseBinding, 1);
    b->state = state;
    b->button = button;
    b->actions[mact] = g_slist_append(NULL, action);
    bound_contexts[context] = g_slist_append(bound_contexts[context], b);

    return TRUE;
}