summaryrefslogtreecommitdiffstats
path: root/iw/timezone.py
blob: 8f8b6673fa1bbe689532960636bde7c4fc44022d (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
from gtk import *
from iw import *
from gnome.ui import GnomeCanvas
from gui import _

import timezonemap

class Map (GnomeCanvas):
    def __init__ (self, map):
        self._o = map

class List (GtkScrolledWindow):
    def __init__ (self, list):
        self._o = list

class Status (GtkStatusbar):
    def __init__ (self, bar):
        self._o = bar

class Option (GtkOptionMenu):
    def __init__ (self, option):
        self._o = option

class TimezoneWindow (InstallWindow):

    def __init__ (self, ics):
	InstallWindow.__init__ (self, ics)

        ics.setTitle (_("Time Zone Selection"))
        ics.setNextEnabled (1)
        ics.readHTML ("timezone")

	self.timeZones = ("-12:00",
                          "-11:00",
                          "-10:00",
                          "-09:30",
                          "-09:00",
                          "-08:30",
                          "-08:00",
                          "-07:00",
                          "-06:00",
                          "-05:00",
                          "-04:00",
                          "-03:30",
                          "-03:00",
                          "-02:00",
                          "-01:00",
                          "",
                          "+01:00",
                          "+02:00",
                          "+03:00",
                          "+03:30",
                          "+04:00",
                          "+04:30",
                          "+05:00",
                          "+05:30",
                          "+06:00",
                          "+06:30",
                          "+07:00",
                          "+08:00",
                          "+09:00",
                          "+09:30",
                          "+10:00",
                          "+10:30",
                          "+11:00",
                          "+11:30",
                          "+12:00",
                          "+13:00",
                          "+14:00")
                    

    def getNext (self):
	if self.__dict__.has_key('list'):
	    self.todo.setTimezoneInfo (self.list.get_text (self.list.selection[0], 0),
				       self.systemUTC.get_active ())
        return None

    def fixUp (self):
	pass

    def getScreen (self):
        try:
            f = open ("/usr/share/anaconda/map480.png")
            f.close ()
        except:
            path = "gnome-map/map480.png"
        else:
            path = "/usr/share/anaconda/map480.png"
        
	nb = GtkNotebook ()

        mainBox = GtkVBox (FALSE, 5)

        tz = timezonemap.new (path)
        self.tz = tz
        map = Map (tz.map)
        swList = List (tz.citylist)
        self.list = swList.children ()[0]

	rc = self.todo.getTimezoneInfo()
	if rc:
	    (self.default, asUTC, asArc) = rc
	else:
	    self.default = "America/New_York"
	    asUTC = 0

	self.list.connect ("draw", lambda widget, area, self=self: 
	                             self.tz.setcurrent (self.default))

        status = Status (tz.statusbar)
        views = Option (tz.views)

        label = GtkLabel (_("View:"))
        hbox = GtkHBox (FALSE, 5)
        hbox.pack_start (label, FALSE)
        hbox.pack_start (views, FALSE)
        im = self.ics.readPixmap ("timezone.png")
        if im:
            im.render ()
            pix = im.make_pixmap ()
            a = GtkAlignment ()
            a.add (pix)
            a.set (1.0, 0.0, 0.0, 0.0)
            hbox.pack_start (a, TRUE)
        
        frame = GtkFrame ()
        frame.set_shadow_type (SHADOW_IN)
        frame.add (map)
        
        mainBox.pack_start (hbox, FALSE)
        box = GtkVBox (FALSE, 0)
        box.pack_start (frame, FALSE)
        box.pack_start (status, FALSE)
        mainBox.pack_start (box, FALSE)
        mainBox.pack_start (swList, TRUE)

	tzBox = GtkVBox (FALSE)
        sw = GtkScrolledWindow ()
        sw.set_policy (POLICY_AUTOMATIC, POLICY_AUTOMATIC)
	list = GtkCList (1)
        list.set_selection_mode (SELECTION_BROWSE)
        list.freeze ()
        for zone in self.timeZones:
            list.append (("UTC %s" % (zone,),))
        list.columns_autosize ()
        list.thaw ()
        list.select_row (15, 0)
        sw.add (list)
        tzBox.pack_start (sw)
        align = GtkAlignment (0, 0)
        daylightCB = GtkCheckButton (_("Use Daylight Saving Time"))
        align.add (daylightCB)
        tzBox.pack_start (align, FALSE)
        tzBox.set_border_width (5)
        

        mainBox.set_border_width (5)
	nb.append_page (mainBox, GtkLabel (_("Location")))
        nb.append_page (tzBox, GtkLabel (_("UTC Offset")))

        box = GtkVBox (FALSE, 5)
        box.pack_start (nb)
        self.systemUTC = GtkCheckButton (_("System clock uses UTC"))
        self.systemUTC.set_active (asUTC)
        align = GtkAlignment (0, 0)
        align.add (self.systemUTC)
        box.pack_start (align, FALSE)
        box.set_border_width (5)
        return box