summaryrefslogtreecommitdiff
path: root/libcaribou/ikeyboard-object.vala
blob: c63a46e678e1a8257b46708cb201400409f6e809 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
namespace Caribou {
	/**
	 * Common interface providing access to keys.
	 *
	 * This is implemented by all the keyboard components.
	 */
    public interface IKeyboardObject : Object {
        public abstract IKeyboardObject[] get_children ();

        public signal void key_clicked (KeyModel key);
        public signal void key_pressed (KeyModel key);
        public signal void key_released (KeyModel key);

        public virtual KeyModel[] get_keys () {
            Gee.ArrayList<KeyModel> keys = new Gee.ArrayList<KeyModel> ();
            foreach (IKeyboardObject obj in get_children ()) {
                KeyModel[] obj_keys = obj.get_keys();
                foreach (KeyModel key in obj_keys) {
                    keys.add(key);
                }
            }
            return (KeyModel[]) keys.to_array ();
        }
    }
}