source: src/mlx/gui/info.py@ 536:5ea6830f0470

Last change on this file since 536:5ea6830f0470 was 441:226907f421a6, checked in by István Váradi <ivaradi@…>, 12 years ago

Made the delay code table to be as wide as the window (re #154)

File size: 5.3 KB
Line 
1
2from common import *
3
4from mlx.gui.delaycodes import DelayCodeTable
5
6from mlx.i18n import xstr
7import mlx.const as const
8
9#------------------------------------------------------------------------------
10
11## @package mlx.gui.info
12#
13# The flight info tab.
14#
15# This module implements to \ref FlightInfo class, which is the widget for the
16# extra information related to the flight. It contains text areas for the
17# comments and the flight defects at the top next to each other, and the frame
18# for the delay codes at the bottom in the centre.
19
20#------------------------------------------------------------------------------
21
22class FlightInfo(gtk.VBox):
23 """The flight info tab."""
24 @staticmethod
25 def _createCommentArea(label):
26 """Create a comment area.
27
28 Returns a tuple of two items:
29 - the top-level widget of the comment area, and
30 - the comment text editor."""
31
32 frame = gtk.Frame(label = label)
33 label = frame.get_label_widget()
34 label.set_use_underline(True)
35
36 alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
37 xscale = 1.0, yscale = 1.0)
38 alignment.set_padding(padding_top = 4, padding_bottom = 4,
39 padding_left = 8, padding_right = 8)
40
41 scroller = gtk.ScrolledWindow()
42 scroller.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC)
43 scroller.set_shadow_type(SHADOW_IN)
44
45 comments = gtk.TextView()
46 comments.set_wrap_mode(WRAP_WORD)
47 scroller.add(comments)
48 alignment.add(scroller)
49 frame.add(alignment)
50
51 label.set_mnemonic_widget(comments)
52
53 return (frame, comments)
54
55 def __init__(self, gui):
56 """Construct the flight info tab."""
57 super(FlightInfo, self).__init__()
58 self._gui = gui
59
60 self._commentsAlignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
61 xscale = 1.0, yscale = 1.0)
62 commentsBox = gtk.HBox()
63
64 (frame, self._comments) = FlightInfo._createCommentArea(xstr("info_comments"))
65 commentsBox.pack_start(frame, True, True, 8)
66 self._comments.get_buffer().connect("changed", self._commentsChanged)
67
68 (frame, self._flightDefects) = \
69 FlightInfo._createCommentArea(xstr("info_defects"))
70 commentsBox.pack_start(frame, True, True, 8)
71
72 self._commentsAlignment.add(commentsBox)
73 self.pack_start(self._commentsAlignment, True, True, 8)
74
75 frame = gtk.Frame(label = xstr("info_delay"))
76 label = frame.get_label_widget()
77 label.set_use_underline(True)
78
79 alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
80 xscale = 1.0, yscale = 1.0)
81 alignment.set_padding(padding_top = 4, padding_bottom = 4,
82 padding_left = 8, padding_right = 8)
83
84 self._delayCodeTable = table = DelayCodeTable()
85 self._delayWindow = scrolledWindow = gtk.ScrolledWindow()
86 scrolledWindow.add(table)
87 scrolledWindow.set_size_request(-1, 185)
88 scrolledWindow.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC)
89 scrolledWindow.set_shadow_type(SHADOW_IN)
90
91 alignment.add(scrolledWindow)
92 frame.add(alignment)
93
94 self._delayAlignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
95 xscale = 1.0, yscale = 1.0)
96 self._delayAlignment.add(frame)
97 self._delayAlignment.set_padding(padding_top = 0, padding_bottom = 0,
98 padding_left = 8, padding_right = 8)
99
100 self.pack_start(self._delayAlignment, False, False, 8)
101
102 @property
103 def comments(self):
104 """Get the comments."""
105 buffer = self._comments.get_buffer()
106 return text2unicode(buffer.get_text(buffer.get_start_iter(),
107 buffer.get_end_iter(), True))
108
109 @property
110 def hasComments(self):
111 """Get whether there is any text in comments field."""
112 return self._comments.get_buffer().get_char_count()>0
113
114 @property
115 def flightDefects(self):
116 """Get the flight defects."""
117 buffer = self._flightDefects.get_buffer()
118 return text2unicode(buffer.get_text(buffer.get_start_iter(),
119 buffer.get_end_iter(), True))
120
121 @property
122 def delayCodes(self):
123 """Get the list of delay codes checked by the user."""
124 return self._delayCodeTable.delayCodes
125
126 def enable(self, aircraftType):
127 """Enable the flight info tab."""
128 self._comments.set_sensitive(True)
129 self._flightDefects.set_sensitive(True)
130 self._delayCodeTable.setType(aircraftType)
131 self._delayWindow.set_sensitive(True)
132 self._delayCodeTable.setStyle()
133
134 def disable(self):
135 """Enable the flight info tab."""
136 self._comments.set_sensitive(False)
137 self._flightDefects.set_sensitive(False)
138 self._delayWindow.set_sensitive(False)
139 self._delayCodeTable.setStyle()
140
141 def reset(self):
142 """Reset the flight info tab."""
143 self._comments.get_buffer().set_text("")
144 self._flightDefects.get_buffer().set_text("")
145 self._delayCodeTable.reset()
146
147 def _commentsChanged(self, textbuffer):
148 """Called when the comments have changed."""
149 self._gui.updateRTO(inLoop = True)
Note: See TracBrowser for help on using the repository browser.