1 |
# |
2 |
# language_text.py: text mode language selection dialog |
3 |
# |
4 |
# Copyright 2001-2002 Red Hat, Inc. |
5 |
# |
6 |
# This software may be freely redistributed under the terms of the GNU |
7 |
# library public license. |
8 |
# |
9 |
# You should have received a copy of the GNU Library Public License |
10 |
# along with this program; if not, write to the Free Software |
11 |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
12 |
# |
13 |
|
14 |
import os |
15 |
import isys |
16 |
import iutil |
17 |
import time |
18 |
from snack import * |
19 |
from constants_text import * |
20 |
from flags import flags |
21 |
|
22 |
from rhpl.log import * |
23 |
from rhpl.translate import _ |
24 |
|
25 |
class LanguageWindow: |
26 |
def __call__(self, screen, textInterface, instLanguage): |
27 |
languages = instLanguage.available () |
28 |
|
29 |
current = instLanguage.getCurrent() |
30 |
|
31 |
height = min((8, len(languages))) |
32 |
buttons = [TEXT_OK_BUTTON, TEXT_BACK_BUTTON] |
33 |
|
34 |
translated = [] |
35 |
for lang in languages: |
36 |
translated.append (_(lang)) |
37 |
(button, choice) = \ |
38 |
ListboxChoiceWindow(screen, _("Language Selection"), |
39 |
_("What language would you like to use during the " |
40 |
"installation process?"), translated, |
41 |
buttons, width = 30, default = _(current), scroll = 1, |
42 |
height = height, help = "lang") |
43 |
|
44 |
if button == TEXT_BACK_CHECK: |
45 |
return INSTALL_BACK |
46 |
|
47 |
choice = languages[choice] |
48 |
|
49 |
if ((instLanguage.getFontFile(choice) == "None")): |
50 |
ButtonChoiceWindow(screen, "Language Unavailable", |
51 |
"%s display is unavailable in text mode. The " |
52 |
"installation will continue in English." % (choice,), |
53 |
buttons=[TEXT_OK_BUTTON]) |
54 |
instLanguage.setRuntimeDefaults(choice) |
55 |
return INSTALL_OK |
56 |
|
57 |
if (flags.setupFilesystems and |
58 |
instLanguage.getFontFile(choice) == "bterm" |
59 |
and not flags.serial and not flags.virtpconsole |
60 |
and not isys.isPsudoTTY(0) |
61 |
and not isys.isVioConsole()): |
62 |
# bterm to the rescue... have to shut down the screen and |
63 |
# create a new one, though (and do a sleep) |
64 |
log("starting bterm") |
65 |
try: |
66 |
screen.finish() |
67 |
rc = isys.startBterm() |
68 |
time.sleep(1) |
69 |
except Exception, e: |
70 |
log("got an exception starting bterm: %s" %(e,)) |
71 |
rc = 1 |
72 |
newscreen = SnackScreen() |
73 |
textInterface.setScreen(newscreen) |
74 |
screen = newscreen |
75 |
|
76 |
if rc == 1: |
77 |
ButtonChoiceWindow(screen, "Language Unavailable", |
78 |
"%s display is unavailable in text mode. " |
79 |
"The installation will continue in " |
80 |
"English." % (choice,), |
81 |
buttons=[TEXT_OK_BUTTON]) |
82 |
instLanguage.setRuntimeDefaults(choice) |
83 |
return INSTALL_OK |
84 |
|
85 |
|
86 |
instLanguage.setRuntimeLanguage(choice) |
87 |
|
88 |
textInterface.drawFrame() |
89 |
|
90 |
return INSTALL_OK |
91 |
|
92 |
class LanguageSupportWindow: |
93 |
def __call__(self, screen, language): |
94 |
|
95 |
langs = [] |
96 |
default = language.getDefault() |
97 |
langs.append(default) |
98 |
language.setSupported(langs) |
99 |
language.setDefault(default) |
100 |
return INSTALL_OK |
101 |
|
102 |
|
103 |
class LanguageDefaultWindow: |
104 |
def __call__(self,screen, language): |
105 |
langs = language.getSupported () |
106 |
current = language.getDefault() |
107 |
|
108 |
if not langs or len(langs) <= 1: |
109 |
language.setDefault(current) |
110 |
return INSTALL_NOOP |
111 |
|
112 |
langs.sort() |
113 |
|
114 |
height = min((screen.height - 16, len(langs))) |
115 |
|
116 |
buttons = [TEXT_OK_BUTTON, TEXT_BACK_BUTTON] |
117 |
|
118 |
(button, choice) = ListboxChoiceWindow(screen, _("Default Language"), |
119 |
_("Choose the default language for this system: "), langs, |
120 |
buttons, width = 30, default = current, scroll = 1, |
121 |
height = height, help = "langdefault") |
122 |
|
123 |
if (button == TEXT_BACK_CHECK): |
124 |
return INSTALL_BACK |
125 |
|
126 |
language.setDefault (langs[choice]) |
127 |
return INSTALL_OK |
128 |
|