/[smeserver]/cdrom.image/sme9/updates/textw/timezone_text.py
ViewVC logotype

Contents of /cdrom.image/sme9/updates/textw/timezone_text.py

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download) (as text)
Tue Jul 30 21:49:21 2013 UTC (11 years, 2 months ago) by charliebrady
Branch: MAIN
Content type: text/x-python
Add upstream timezone_text.py.

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 if self.c.selected():
47 args.append("--utc")
48
49 iutil.execWithRedirect("hwclock", args)
50 self.g.setTimer(500)
51 self.updateClock()
52
53 def updateClock(self):
54 # disable for now
55 return
56
57 # if os.access("/usr/share/zoneinfo/" + self.l.current(), os.R_OK):
58 # os.environ['TZ'] = self.l.current()
59 # self.label.setText(self.currentTime())
60 # else:
61 # self.label.setText("")
62
63 def currentTime(self):
64 return "Current time: " + strftime("%X %Z", localtime(time()))
65
66 def __call__(self, screen, anaconda):
67 timezones = self.getTimezoneList()
68 (default, asUtc) = anaconda.id.timezone.getTimezoneInfo()
69 if not default:
70 default = anaconda.id.instLanguage.getDefaultTimeZone(anaconda.rootPath)
71
72 bb = ButtonBar(screen, [TEXT_OK_BUTTON, TEXT_BACK_BUTTON])
73 t = TextboxReflowed(30,
74 _("In which time zone are you located?"))
75
76 if not anaconda.isKickstart and not hasWindows(anaconda.id.bootloader):
77 asUtc = True
78
79 #
80 # disabling this for now
81 #
82 # self.label = Label(self.currentTime())
83
84 self.l = Listbox(5, scroll = 1, returnExit = 0)
85
86 for tz in timezones:
87 self.l.append(gettext.ldgettext("system-config-date", tz), tz)
88
89 self.l.setCurrent(default.replace("_", " "))
90 # self.l.setCallback(self.updateClock)
91
92 self.c = Checkbox(_("System clock uses UTC"), isOn = asUtc)
93 # self.c.setCallback(self.updateSysClock)
94
95 self.g = GridFormHelp(screen, _("Time Zone Selection"), "timezone",
96 1, 5)
97 self.g.add(t, 0, 0)
98 # self.g.add(self.label, 0, 1, padding = (0, 1, 0, 0), anchorLeft = 1)
99 self.g.add(self.c, 0, 2, padding = (0, 1, 0, 1), anchorLeft = 1)
100 self.g.add(self.l, 0, 3, padding = (0, 0, 0, 1))
101 self.g.add(bb, 0, 4, growx = 1)
102
103 # disabling for now
104 # self.updateClock()
105 # self.updateSysClock()
106 #
107 # self.g.setTimer(500)
108 #
109 # result = "TIMER"
110 # while result == "TIMER":
111 # result = self.g.run()
112 # if result == "TIMER":
113 # self.updateClock()
114
115 result = ""
116 while 1:
117 result = self.g.run()
118 rc = bb.buttonPressed (result)
119
120 if rc == TEXT_BACK_CHECK:
121 screen.popWindow()
122 return INSTALL_BACK
123 else:
124 break
125
126 screen.popWindow()
127 anaconda.id.timezone.setTimezoneInfo(self.l.current().replace(" ", "_"), asUtc = self.c.selected())
128
129 return INSTALL_OK
130
131

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed