1
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
3
# Ubuntu Keyboard Test Suite
4
# Copyright (C) 2013 Canonical
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation, either version 3 of the License, or
9
# (at your option) any later version.
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU General Public License for more details.
16
# You should have received a copy of the GNU General Public License
17
# along with this program. If not, see <http://www.gnu.org/licenses/>.
20
from ubuntu_keyboard.emulators import UbuntuKeyboardEmulatorBase
21
from ubuntu_keyboard.emulators.key import Key
25
logger = logging.getLogger(__name__)
34
class KeyPad(UbuntuKeyboardEmulatorBase):
35
"""A basic emulator that provides the details of the keys contained within.
39
def get_key_details(self):
43
def _iter_keys(key_type, label_fn):
44
for key in self.select_many(key_type):
45
with key.no_automatic_refreshing():
46
key_pos = Key.Pos(*key.globalRect)
49
contained_keys[label] = KeyPadState.NORMAL
50
key_positions[label] = key_pos
52
contained_keys[key.shifted] = KeyPadState.SHIFTED
53
key_positions[key.shifted] = key_pos
55
_iter_keys("CharKey", lambda x: x.label)
56
_iter_keys("ActionKey", lambda x: x.action)
58
return (contained_keys, key_positions)