1 |
charliebrady |
1.1 |
# |
2 |
|
|
# timezone_text.py: text mode timezone selection dialog |
3 |
|
|
# |
4 |
|
|
# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 Red Hat, Inc. |
5 |
|
|
# All rights reserved. |
6 |
|
|
# |
7 |
|
|
# This program is free software; you can redistribute it and/or modify |
8 |
|
|
# it under the terms of the GNU General Public License as published by |
9 |
|
|
# the Free Software Foundation; either version 2 of the License, or |
10 |
|
|
# (at your option) any later version. |
11 |
|
|
# |
12 |
|
|
# This program is distributed in the hope that it will be useful, |
13 |
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
|
|
# GNU General Public License for more details. |
16 |
|
|
# |
17 |
|
|
# You should have received a copy of the GNU General Public License |
18 |
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 |
|
|
# |
20 |
|
|
|
21 |
|
|
import sys |
22 |
|
|
import string |
23 |
|
|
import iutil |
24 |
|
|
from time import * |
25 |
|
|
from snack import * |
26 |
|
|
from constants_text import * |
27 |
|
|
from bootloader import hasWindows |
28 |
|
|
from scdate.core import zonetab |
29 |
|
|
|
30 |
|
|
from constants import * |
31 |
|
|
import gettext |
32 |
|
|
_ = lambda x: gettext.ldgettext("anaconda", x) |
33 |
|
|
|
34 |
|
|
sys.path.append("/usr/share/system-config-date") |
35 |
|
|
|
36 |
|
|
class TimezoneWindow: |
37 |
|
|
|
38 |
|
|
def getTimezoneList(self): |
39 |
|
|
zt = zonetab.ZoneTab() |
40 |
|
|
zoneList = [ x.tz for x in zt.getEntries() ] |
41 |
|
|
zoneList.sort() |
42 |
|
|
return zoneList |
43 |
|
|
|
44 |
|
|
def updateSysClock(self): |
45 |
|
|
args = ["--hctosys"] |
46 |
charliebrady |
1.2 |
args.append("--utc") |
47 |
charliebrady |
1.1 |
|
48 |
|
|
iutil.execWithRedirect("hwclock", args) |
49 |
|
|
self.g.setTimer(500) |
50 |
|
|
self.updateClock() |
51 |
|
|
|
52 |
|
|
def updateClock(self): |
53 |
|
|
# disable for now |
54 |
|
|
return |
55 |
|
|
|
56 |
|
|
# if os.access("/usr/share/zoneinfo/" + self.l.current(), os.R_OK): |
57 |
|
|
# os.environ['TZ'] = self.l.current() |
58 |
|
|
# self.label.setText(self.currentTime()) |
59 |
|
|
# else: |
60 |
|
|
# self.label.setText("") |
61 |
|
|
|
62 |
|
|
def currentTime(self): |
63 |
|
|
return "Current time: " + strftime("%X %Z", localtime(time())) |
64 |
|
|
|
65 |
|
|
def __call__(self, screen, anaconda): |
66 |
|
|
timezones = self.getTimezoneList() |
67 |
|
|
(default, asUtc) = anaconda.id.timezone.getTimezoneInfo() |
68 |
|
|
if not default: |
69 |
|
|
default = anaconda.id.instLanguage.getDefaultTimeZone(anaconda.rootPath) |
70 |
|
|
|
71 |
|
|
bb = ButtonBar(screen, [TEXT_OK_BUTTON, TEXT_BACK_BUTTON]) |
72 |
|
|
t = TextboxReflowed(30, |
73 |
|
|
_("In which time zone are you located?")) |
74 |
|
|
|
75 |
|
|
if not anaconda.isKickstart and not hasWindows(anaconda.id.bootloader): |
76 |
|
|
asUtc = True |
77 |
|
|
|
78 |
|
|
# |
79 |
|
|
# disabling this for now |
80 |
|
|
# |
81 |
|
|
# self.label = Label(self.currentTime()) |
82 |
|
|
|
83 |
|
|
self.l = Listbox(5, scroll = 1, returnExit = 0) |
84 |
|
|
|
85 |
|
|
for tz in timezones: |
86 |
|
|
self.l.append(gettext.ldgettext("system-config-date", tz), tz) |
87 |
|
|
|
88 |
|
|
self.l.setCurrent(default.replace("_", " ")) |
89 |
|
|
# self.l.setCallback(self.updateClock) |
90 |
|
|
|
91 |
|
|
self.g = GridFormHelp(screen, _("Time Zone Selection"), "timezone", |
92 |
|
|
1, 5) |
93 |
|
|
self.g.add(t, 0, 0) |
94 |
|
|
# self.g.add(self.label, 0, 1, padding = (0, 1, 0, 0), anchorLeft = 1) |
95 |
|
|
self.g.add(self.l, 0, 3, padding = (0, 0, 0, 1)) |
96 |
|
|
self.g.add(bb, 0, 4, growx = 1) |
97 |
|
|
|
98 |
|
|
# disabling for now |
99 |
|
|
# self.updateClock() |
100 |
|
|
# self.updateSysClock() |
101 |
|
|
# |
102 |
|
|
# self.g.setTimer(500) |
103 |
|
|
# |
104 |
|
|
# result = "TIMER" |
105 |
|
|
# while result == "TIMER": |
106 |
|
|
# result = self.g.run() |
107 |
|
|
# if result == "TIMER": |
108 |
|
|
# self.updateClock() |
109 |
|
|
|
110 |
|
|
result = "" |
111 |
|
|
while 1: |
112 |
|
|
result = self.g.run() |
113 |
|
|
rc = bb.buttonPressed (result) |
114 |
|
|
|
115 |
|
|
if rc == TEXT_BACK_CHECK: |
116 |
|
|
screen.popWindow() |
117 |
|
|
return INSTALL_BACK |
118 |
|
|
else: |
119 |
|
|
break |
120 |
|
|
|
121 |
|
|
screen.popWindow() |
122 |
charliebrady |
1.2 |
anaconda.id.timezone.setTimezoneInfo(self.l.current().replace(" ", "_"), asUtc = 1) |
123 |
charliebrady |
1.1 |
|
124 |
|
|
return INSTALL_OK |
125 |
|
|
|
126 |
|
|
|