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 |
langs = [] |
95 |
default = language.getDefault() |
96 |
langs.append(default) |
97 |
language.setSupported(langs) |
98 |
language.setDefault(default) |
99 |
return INSTALL_OK |
100 |
|
101 |
class LanguageDefaultWindow: |
102 |
def __call__(self,screen, language): |
103 |
langs = language.getSupported () |
104 |
current = language.getDefault() |
105 |
|
106 |
if not langs or len(langs) <= 1: |
107 |
language.setDefault(current) |
108 |
return INSTALL_NOOP |
109 |
|
110 |
langs.sort() |
111 |
|
112 |
height = min((screen.height - 16, len(langs))) |
113 |
|
114 |
buttons = [TEXT_OK_BUTTON, TEXT_BACK_BUTTON] |
115 |
|
116 |
(button, choice) = ListboxChoiceWindow(screen, _("Default Language"), |
117 |
_("Choose the default language for this system: "), langs, |
118 |
buttons, width = 30, default = current, scroll = 1, |
119 |
height = height, help = "langdefault") |
120 |
|
121 |
if (button == TEXT_BACK_CHECK): |
122 |
return INSTALL_BACK |
123 |
|
124 |
language.setDefault (langs[choice]) |
125 |
return INSTALL_OK |
126 |
|