]>
Dogcows Code - chaz/openbox/blob - openbox/keytree.c
5 void tree_destroy(KeyBindingTree
*tree
)
10 tree_destroy(tree
->next_sibling
);
11 c
= tree
->first_child
;
15 for (it
= tree
->keylist
; it
!= NULL
; it
= it
->next
)
17 g_list_free(tree
->keylist
);
18 for (sit
= tree
->actions
; sit
!= NULL
; sit
= sit
->next
)
19 action_free(sit
->data
);
20 g_slist_free(tree
->actions
);
27 KeyBindingTree
*tree_build(GList
*keylist
)
30 KeyBindingTree
*ret
= NULL
, *p
;
32 if (g_list_length(keylist
) <= 0)
33 return NULL
; /* nothing in the list.. */
35 for (it
= g_list_last(keylist
); it
!= NULL
; it
= it
->prev
) {
37 ret
= g_new0(KeyBindingTree
, 1);
41 /* this is the first built node, the bottom node of the tree */
42 ret
->keylist
= g_list_copy(keylist
); /* shallow copy */
43 for (it
= ret
->keylist
; it
!= NULL
; it
= it
->next
) /* deep copy */
44 it
->data
= g_strdup(it
->data
);
47 if (!translate_key(it
->data
, &ret
->state
, &ret
->key
)) {
55 void tree_assimilate(KeyBindingTree
*node
)
57 KeyBindingTree
*a
, *b
, *tmp
, *last
;
59 if (keyboard_firstnode
== NULL
) {
60 /* there are no nodes at this level yet */
61 keyboard_firstnode
= node
;
63 a
= keyboard_firstnode
;
68 if (!(a
->state
== b
->state
&& a
->key
== b
->key
)) {
77 if (!(last
->state
== b
->state
&& last
->key
== b
->key
))
78 last
->next_sibling
= b
;
80 last
->first_child
= b
->first_child
;
86 KeyBindingTree
*tree_find(KeyBindingTree
*search
, gboolean
*conflict
)
88 KeyBindingTree
*a
, *b
;
92 a
= keyboard_firstnode
;
95 if (!(a
->state
== b
->state
&& a
->key
== b
->key
)) {
98 if ((a
->first_child
== NULL
) == (b
->first_child
== NULL
)) {
99 if (a
->first_child
== NULL
) {
100 /* found it! (return the actual node, not the search's) */
105 return NULL
; /* the chain status' don't match (conflict!) */
111 return NULL
; /* it just isn't in here */
This page took 0.039279 seconds and 4 git commands to generate.