source: src/mlx/gui/gates.py@ 452:c838eb728031

Last change on this file since 452:c838eb728031 was 300:f101bd18f39d, checked in by István Váradi <ivaradi@…>, 12 years ago

Added the module comments for the GUI

File size: 7.2 KB
Line 
1
2from mlx.gui.common import *
3
4from mlx.i18n import xstr
5import mlx.const as const
6
7#-------------------------------------------------------------------------------
8
9## @package mlx.gui.gates
10#
11# The gate status display.
12#
13# This module contains the \ref FleetGateStatus widget, which is the tab
14# displaying the status of the MAVA Fleet and the gates at LHBP. The left side
15# of the widget is the table with the list of the planes and their states. The
16# right side displays the numbers of the gates and their occupation status.
17
18#-------------------------------------------------------------------------------
19
20class FleetGateStatus(gtk.VBox):
21 """The tab to display the fleet and gate status."""
22 def __init__(self, gui):
23 """Construct the tab."""
24 super(FleetGateStatus, self).__init__()
25
26 self._gui = gui
27
28 mainAlignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
29 xscale = 1.0, yscale = 1.0)
30 mainAlignment.set_padding(padding_top = 4, padding_bottom = 4,
31 padding_left = 12, padding_right = 12)
32 self.add(mainAlignment)
33
34 self._mainBox = mainBox = gtk.VBox()
35 mainAlignment.add(mainBox)
36
37 self._statusBox = statusBox = gtk.HBox()
38 mainBox.pack_start(statusBox, True, True, 4)
39
40 fleetFrame = gtk.Frame(label = xstr("gates_fleet_title"))
41 fleetLabel = fleetFrame.get_label_widget()
42 fleetLabel.set_use_underline(True)
43 statusBox.pack_start(fleetFrame, False, False, 4)
44
45 self._fleetStore = gtk.ListStore(str, str)
46 self._fleetList = gtk.TreeView(self._fleetStore)
47 self._fleetList.set_tooltip_markup(xstr("gates_planes_tooltip"))
48 fleetLabel.set_mnemonic_widget(self._fleetList)
49 column = gtk.TreeViewColumn(xstr("gates_tailno"), gtk.CellRendererText(),
50 text = 0)
51 column.set_expand(True)
52 column.set_sort_column_id(0)
53 self._fleetList.append_column(column)
54
55 column = gtk.TreeViewColumn(xstr("gates_planestatus"), gtk.CellRendererText(),
56 markup = 1)
57 column.set_expand(True)
58 column.set_sort_column_id(1)
59 self._fleetList.append_column(column)
60
61 scrolledWindow = gtk.ScrolledWindow()
62 scrolledWindow.add(self._fleetList)
63 scrolledWindow.set_size_request(200, -1)
64 # FIXME: these should be constants in common.py
65 scrolledWindow.set_policy(gtk.PolicyType.AUTOMATIC if pygobject
66 else gtk.POLICY_AUTOMATIC,
67 gtk.PolicyType.AUTOMATIC if pygobject
68 else gtk.POLICY_AUTOMATIC)
69 scrolledWindow.set_shadow_type(gtk.ShadowType.IN if pygobject
70 else gtk.SHADOW_IN)
71
72
73 self._fleetAlignment = alignment = \
74 gtk.Alignment(xalign = 0.5, yalign = 0.0,
75 xscale = 0.0, yscale = 1.0)
76 alignment.set_padding(padding_top = 4, padding_bottom = 4,
77 padding_left = 4, padding_right = 4)
78 alignment.add(scrolledWindow)
79 fleetFrame.add(alignment)
80
81 self._gatesFrame = gatesFrame = gtk.Frame(label = xstr("gates_gates_title"))
82 statusBox.pack_start(gatesFrame, True, True, 4)
83
84 self._gatesTable = table = gtk.Table(14, 4)
85 table.set_tooltip_markup(xstr("gates_gates_tooltip"))
86 alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
87 xscale = 1.0, yscale = 1.0)
88 alignment.set_padding(padding_top = 4, padding_bottom = 4,
89 padding_left = 4, padding_right = 4)
90 alignment.add(table)
91 gatesFrame.add(alignment)
92
93 self._gateLabels = {}
94 column = 0
95 row = 0
96 for gateNumber in const.lhbpGateNumbers:
97 label = gtk.Label()
98 label.set_markup("<b>" + gateNumber + "</b>")
99 table.attach(label, column, column + 1, row, row + 1)
100
101 self._gateLabels[gateNumber] = label
102
103 if column==1 and row==12:
104 column = 2
105 row = 1
106 elif row==13:
107 column += 1
108 row = 0
109 else:
110 row += 1
111
112 button = gtk.Button(xstr("gates_refresh"))
113 button.set_use_underline(True)
114 button.set_tooltip_text(xstr("gates_refresh_tooltip"))
115 button.connect("clicked", self._refreshClicked)
116
117 alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
118 xscale = 0.0, yscale = 0.0)
119 alignment.add(button)
120 mainBox.pack_start(alignment, False, False, 4)
121
122 self._fleetList.set_sensitive(False)
123 self._gatesTable.set_sensitive(False)
124
125 def disable(self):
126 """Disable the widget."""
127 self._mainBox.set_sensitive(False)
128
129 def enable(self):
130 """Enable the widget."""
131 self._mainBox.set_sensitive(True)
132
133 def _refreshClicked(self, button):
134 """Called when the Refresh data button is clicked."""
135 self._gui.getFleet(force = True)
136
137 def handleFleet(self, fleet):
138 """Handle new fleet information.
139
140 If fleet is None, the data will be cleared."""
141 self._fleetStore.clear()
142 if fleet is None:
143 for (gateNumber, label) in self._gateLabels.iteritems():
144 label.set_markup("<b>" + gateNumber + "</b>")
145 else:
146 for plane in fleet:
147 conflicting = False
148 tailNumber = plane.tailNumber
149 if plane.status==const.PLANE_HOME:
150 status = "LHBP - %s" % (plane.gateNumber,)
151 conflicting = fleet.isGateConflicting(plane)
152 elif plane.status==const.PLANE_AWAY:
153 status = xstr("gates_plane_away")
154 elif plane.status==const.PLANE_PARKING:
155 status = xstr("gates_plane_parking")
156 else:
157 status = xstr("gates_plane_unknown")
158
159 if conflicting:
160 tailNumber = '<span foreground="red">' + tailNumber + '</span>'
161 status = '<span foreground="red">' + status + '</span>'
162
163 self._fleetStore.append([tailNumber, status])
164 # FIXME: this should be a constant in common.py
165 self._fleetStore.set_sort_column_id(0,
166 gtk.SortType.ASCENDING if pygobject
167 else gtk.SORT_ASCENDING)
168
169 occupiedGateNumbers = fleet.getOccupiedGateNumbers()
170 for gateNumber in const.lhbpGateNumbers:
171 markup = gateNumber
172 if gateNumber in occupiedGateNumbers:
173 markup = '<span foreground="orange">' + markup + '</span>'
174 markup = '<b>' + markup + '</b>'
175 self._gateLabels[gateNumber].set_markup(markup)
176
177 self._fleetList.set_sensitive(fleet is not None)
178 self._gatesTable.set_sensitive(fleet is not None)
179
180#----------------------------------------------------------------------------
Note: See TracBrowser for help on using the repository browser.