1 | #The Flight Info tab
|
---|
2 |
|
---|
3 | from common import *
|
---|
4 |
|
---|
5 | class 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 | scroller.set_policy(gtk.PolicyType.AUTOMATIC if pygobject
|
---|
26 | else gtk.POLICY_AUTOMATIC,
|
---|
27 | gtk.PolicyType.AUTOMATIC if pygobject
|
---|
28 | else gtk.POLICY_AUTOMATIC)
|
---|
29 | scroller.set_shadow_type(gtk.ShadowType.IN if pygobject
|
---|
30 | else gtk.SHADOW_IN)
|
---|
31 | comments = gtk.TextView()
|
---|
32 | scroller.add(comments)
|
---|
33 | alignment.add(scroller)
|
---|
34 | frame.add(alignment)
|
---|
35 |
|
---|
36 | label.set_mnemonic_widget(comments)
|
---|
37 |
|
---|
38 | return (frame, comments)
|
---|
39 |
|
---|
40 | def __init__(self, gui):
|
---|
41 | """Construct the flight info tab."""
|
---|
42 | super(FlightInfo, self).__init__()
|
---|
43 | self._gui = gui
|
---|
44 |
|
---|
45 | self._commentsAlignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
46 | xscale = 1.0, yscale = 1.0)
|
---|
47 | commentsBox = gtk.HBox()
|
---|
48 |
|
---|
49 | (frame, self._comments) = FlightInfo._createCommentArea("_Comments")
|
---|
50 | commentsBox.pack_start(frame, True, True, 8)
|
---|
51 |
|
---|
52 | (frame, self._flightDefects) = FlightInfo._createCommentArea("Flight _defects")
|
---|
53 | commentsBox.pack_start(frame, True, True, 8)
|
---|
54 |
|
---|
55 | self._commentsAlignment.add(commentsBox)
|
---|
56 | self.pack_start(self._commentsAlignment, True, True, 8)
|
---|
57 |
|
---|
58 | frame = gtk.Frame(label = "Delay codes")
|
---|
59 | label = frame.get_label_widget()
|
---|
60 | label.set_use_underline(True)
|
---|
61 |
|
---|
62 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
63 | xscale = 0.0, yscale = 0.0)
|
---|
64 | alignment.set_padding(padding_top = 4, padding_bottom = 4,
|
---|
65 | padding_left = 8, padding_right = 8)
|
---|
66 |
|
---|
67 | table = gtk.Table(5, 2)
|
---|
68 | table.set_col_spacings(16)
|
---|
69 |
|
---|
70 | self._loadingProblems = gtk.CheckButton("L_oading problems")
|
---|
71 | self._loadingProblems.set_use_underline(True)
|
---|
72 | table.attach(self._loadingProblems, 0, 1, 0, 1)
|
---|
73 |
|
---|
74 | self._vatsimProblem = gtk.CheckButton("_VATSIM problem")
|
---|
75 | self._vatsimProblem.set_use_underline(True)
|
---|
76 | table.attach(self._vatsimProblem, 1, 2, 0, 1)
|
---|
77 |
|
---|
78 | self._netProblems = gtk.CheckButton("_Net problems")
|
---|
79 | self._netProblems.set_use_underline(True)
|
---|
80 | table.attach(self._netProblems, 0, 1, 1, 2)
|
---|
81 |
|
---|
82 | self._controllersFault = gtk.CheckButton("Controllers _fault")
|
---|
83 | self._controllersFault.set_use_underline(True)
|
---|
84 | table.attach(self._controllersFault, 1, 2, 1, 2)
|
---|
85 |
|
---|
86 | self._systemCrash = gtk.CheckButton("S_ystem crash/freeze")
|
---|
87 | self._systemCrash.set_use_underline(True)
|
---|
88 | table.attach(self._systemCrash, 0, 1, 2, 3)
|
---|
89 |
|
---|
90 | self._navigationProblem = gtk.CheckButton("Navi_gation problem")
|
---|
91 | self._navigationProblem.set_use_underline(True)
|
---|
92 | table.attach(self._navigationProblem, 1, 2, 2, 3)
|
---|
93 |
|
---|
94 | self._trafficProblems = gtk.CheckButton("T_raffic problems")
|
---|
95 | self._trafficProblems.set_use_underline(True)
|
---|
96 | table.attach(self._trafficProblems, 0, 1, 3, 4)
|
---|
97 |
|
---|
98 | self._apronProblem = gtk.CheckButton("_Apron navigation problem")
|
---|
99 | self._apronProblem.set_use_underline(True)
|
---|
100 | table.attach(self._apronProblem, 1, 2, 3, 4)
|
---|
101 |
|
---|
102 | self._weatherProblems = gtk.CheckButton("_Weather problems")
|
---|
103 | self._weatherProblems.set_use_underline(True)
|
---|
104 | table.attach(self._weatherProblems, 0, 1, 4, 5)
|
---|
105 |
|
---|
106 | self._personalReasons = gtk.CheckButton("_Personal reasons")
|
---|
107 | self._personalReasons.set_use_underline(True)
|
---|
108 | table.attach(self._personalReasons, 1, 2, 4, 5)
|
---|
109 |
|
---|
110 | alignment.add(table)
|
---|
111 | frame.add(alignment)
|
---|
112 |
|
---|
113 | self._delayAlignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
114 | xscale = 0.0, yscale = 0.0)
|
---|
115 | self._delayAlignment.add(frame)
|
---|
116 |
|
---|
117 | self.pack_start(self._delayAlignment, False, False, 8)
|
---|
118 |
|
---|
119 | def enable(self):
|
---|
120 | """Enable the flight info tab."""
|
---|
121 | #gobject.idle_add(self.set_sensitive, True)
|
---|
122 | self._commentsAlignment.set_sensitive(True)
|
---|
123 | self._delayAlignment.set_sensitive(True)
|
---|
124 |
|
---|
125 | def disable(self):
|
---|
126 | """Enable the flight info tab."""
|
---|
127 | #gobject.idle_add(self.set_sensitive, False)
|
---|
128 | self._commentsAlignment.set_sensitive(False)
|
---|
129 | self._delayAlignment.set_sensitive(False)
|
---|
130 |
|
---|
131 | def reset(self):
|
---|
132 | """Reset the flight info tab."""
|
---|
133 | self._comments.get_buffer().set_text("")
|
---|
134 | self._flightDefects.get_buffer().set_text("")
|
---|
135 |
|
---|
136 | self._loadingProblems.set_active(False)
|
---|
137 | self._vatsimProblem.set_active(False)
|
---|
138 | self._netProblems.set_active(False)
|
---|
139 | self._controllersFault.set_active(False)
|
---|
140 | self._systemCrash.set_active(False)
|
---|
141 | self._navigationProblem.set_active(False)
|
---|
142 | self._trafficProblems.set_active(False)
|
---|
143 | self._apronProblem.set_active(False)
|
---|
144 | self._weatherProblems.set_active(False)
|
---|
145 | self._personalReasons.set_active(False)
|
---|
146 |
|
---|