summaryrefslogtreecommitdiffstats
path: root/textw/keyboard_text.py
blob: 52ecffb2cc2f065c114306a3311f36970fea0e63 (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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#
# keyboard_text: text mode keyboard setup dialogs
#
# Copyright (C) 2001, 2002  Red Hat, Inc.  All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

import isys
from snack import *
from constants_text import *
from flags import flags

from constants import *
import gettext
_ = lambda x: gettext.ldgettext("anaconda", x)

import logging
log = logging.getLogger("anaconda")

class KeyboardWindow:
    def __call__(self, screen, anaconda):
        if flags.serial or flags.virtpconsole:
	    return INSTALL_NOOP
        keyboards = anaconda.id.keyboard.modelDict.keys()
        keyboards.sort ()

	if anaconda.id.keyboard.beenset:
	    default = anaconda.id.keyboard.get ()
	else:
	    default = anaconda.id.instLanguage.getDefaultKeyboard()

        if default not in keyboards:
            default = 'us'

        (button, choice) = \
            ListboxChoiceWindow(screen, _("Keyboard Selection"),
                                _("Which model keyboard is attached to this computer?"), keyboards, 
                                buttons = [TEXT_OK_BUTTON, TEXT_BACK_BUTTON], width = 30, scroll = 1, height = 8,
                                default = default, help = "kybd")
        
        if button == TEXT_BACK_CHECK:
            return INSTALL_BACK

        anaconda.id.keyboard.set (keyboards[choice])
        anaconda.id.keyboard.beenset = 1

        anaconda.id.keyboard.activate()

        # FIXME: eventually, kbd.activate will do this
	try:
	    isys.loadKeymap(keyboards[choice])
	except SystemError, (errno, msg):
	    log.error("Could not install keymap %s: %s" % (keyboards[choice], msg))
        return INSTALL_OK