source: src/mlx/gui/info.py@ 97:f885322fb296

Last change on this file since 97:f885322fb296 was 97:f885322fb296, checked in by István Váradi <ivaradi@…>, 13 years ago

The PIREP can be created and sent.

File size: 6.1 KB
Line 
1#The Flight Info tab
2
3from common import *
4
5class FlightInfo(gtk.VBox):
6 """The flight info tab."""
7 @staticmethod
8 def _createCommentArea(label):
9 """Create a comment area.
10
11 Returns a tuple of two items:
12 - the top-level widget of the comment area, and
13 - the comment text editor."""
14
15 frame = gtk.Frame(label = label)
16 label = frame.get_label_widget()
17 label.set_use_underline(True)
18
19 alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
20 xscale = 1.0, yscale = 1.0)
21 alignment.set_padding(padding_top = 4, padding_bottom = 4,
22 padding_left = 8, padding_right = 8)
23
24 scroller = gtk.ScrolledWindow()
25 # FIXME: these should be constants
26 scroller.set_policy(gtk.PolicyType.AUTOMATIC if pygobject
27 else gtk.POLICY_AUTOMATIC,
28 gtk.PolicyType.AUTOMATIC if pygobject
29 else gtk.POLICY_AUTOMATIC)
30 scroller.set_shadow_type(gtk.ShadowType.IN if pygobject
31 else gtk.SHADOW_IN)
32 comments = gtk.TextView()
33 scroller.add(comments)
34 alignment.add(scroller)
35 frame.add(alignment)
36
37 label.set_mnemonic_widget(comments)
38
39 return (frame, comments)
40
41 def __init__(self, gui):
42 """Construct the flight info tab."""
43 super(FlightInfo, self).__init__()
44 self._gui = gui
45
46 self._commentsAlignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
47 xscale = 1.0, yscale = 1.0)
48 commentsBox = gtk.HBox()
49
50 (frame, self._comments) = FlightInfo._createCommentArea("_Comments")
51 commentsBox.pack_start(frame, True, True, 8)
52
53 (frame, self._flightDefects) = FlightInfo._createCommentArea("Flight _defects")
54 commentsBox.pack_start(frame, True, True, 8)
55
56 self._commentsAlignment.add(commentsBox)
57 self.pack_start(self._commentsAlignment, True, True, 8)
58
59 frame = gtk.Frame(label = "Delay codes")
60 label = frame.get_label_widget()
61 label.set_use_underline(True)
62
63 alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
64 xscale = 0.0, yscale = 0.0)
65 alignment.set_padding(padding_top = 4, padding_bottom = 4,
66 padding_left = 8, padding_right = 8)
67
68 table = gtk.Table(5, 2)
69 table.set_col_spacings(16)
70
71 self._loadingProblems = gtk.CheckButton("L_oading problems")
72 self._loadingProblems.set_use_underline(True)
73 table.attach(self._loadingProblems, 0, 1, 0, 1)
74
75 self._vatsimProblem = gtk.CheckButton("_VATSIM problem")
76 self._vatsimProblem.set_use_underline(True)
77 table.attach(self._vatsimProblem, 1, 2, 0, 1)
78
79 self._netProblems = gtk.CheckButton("_Net problems")
80 self._netProblems.set_use_underline(True)
81 table.attach(self._netProblems, 0, 1, 1, 2)
82
83 self._controllersFault = gtk.CheckButton("Controllers _fault")
84 self._controllersFault.set_use_underline(True)
85 table.attach(self._controllersFault, 1, 2, 1, 2)
86
87 self._systemCrash = gtk.CheckButton("S_ystem crash/freeze")
88 self._systemCrash.set_use_underline(True)
89 table.attach(self._systemCrash, 0, 1, 2, 3)
90
91 self._navigationProblem = gtk.CheckButton("Navi_gation problem")
92 self._navigationProblem.set_use_underline(True)
93 table.attach(self._navigationProblem, 1, 2, 2, 3)
94
95 self._trafficProblems = gtk.CheckButton("T_raffic problems")
96 self._trafficProblems.set_use_underline(True)
97 table.attach(self._trafficProblems, 0, 1, 3, 4)
98
99 self._apronProblem = gtk.CheckButton("_Apron navigation problem")
100 self._apronProblem.set_use_underline(True)
101 table.attach(self._apronProblem, 1, 2, 3, 4)
102
103 self._weatherProblems = gtk.CheckButton("_Weather problems")
104 self._weatherProblems.set_use_underline(True)
105 table.attach(self._weatherProblems, 0, 1, 4, 5)
106
107 self._personalReasons = gtk.CheckButton("_Personal reasons")
108 self._personalReasons.set_use_underline(True)
109 table.attach(self._personalReasons, 1, 2, 4, 5)
110
111 alignment.add(table)
112 frame.add(alignment)
113
114 self._delayAlignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
115 xscale = 0.0, yscale = 0.0)
116 self._delayAlignment.add(frame)
117
118 self.pack_start(self._delayAlignment, False, False, 8)
119
120 @property
121 def comments(self):
122 """Get the comments."""
123 buffer = self._comments.get_buffer()
124 return text2unicode(buffer.get_text(buffer.get_start_iter(),
125 buffer.get_end_iter(), True))
126
127 @property
128 def flightDefects(self):
129 """Get the flight defects."""
130 buffer = self._flightDefects.get_buffer()
131 return text2unicode(buffer.get_text(buffer.get_start_iter(),
132 buffer.get_end_iter(), True))
133
134 def enable(self):
135 """Enable the flight info tab."""
136 #gobject.idle_add(self.set_sensitive, True)
137 self._commentsAlignment.set_sensitive(True)
138 self._delayAlignment.set_sensitive(True)
139
140 def disable(self):
141 """Enable the flight info tab."""
142 #gobject.idle_add(self.set_sensitive, False)
143 self._commentsAlignment.set_sensitive(False)
144 self._delayAlignment.set_sensitive(False)
145
146 def reset(self):
147 """Reset the flight info tab."""
148 self._comments.get_buffer().set_text("")
149 self._flightDefects.get_buffer().set_text("")
150
151 self._loadingProblems.set_active(False)
152 self._vatsimProblem.set_active(False)
153 self._netProblems.set_active(False)
154 self._controllersFault.set_active(False)
155 self._systemCrash.set_active(False)
156 self._navigationProblem.set_active(False)
157 self._trafficProblems.set_active(False)
158 self._apronProblem.set_active(False)
159 self._weatherProblems.set_active(False)
160 self._personalReasons.set_active(False)
Note: See TracBrowser for help on using the repository browser.