Changeset 855:c1d387ee73d6
- Timestamp:
- 05/21/17 18:09:39 (8 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
locale/en/mlx.po
r854 r855 2055 2055 msgid "pirepView_tab_log_tooltip" 2056 2056 msgstr "The flight log." 2057 2058 msgid "pirepView_tab_messages" 2059 msgstr "_Message" 2060 2061 msgid "pirepView_tab_messages_tooltip" 2062 msgstr "The message sent by the reviewer." 2063 2064 msgid "pirep_messages" 2065 msgstr "Message" 2057 2066 2058 2067 msgid "pirepEdit_title" -
locale/hu/mlx.po
r854 r855 2070 2070 msgid "pirepView_tab_log_tooltip" 2071 2071 msgstr "A repülési napló." 2072 2073 msgid "pirepView_tab_messages" 2074 msgstr "Ü_zenet" 2075 2076 msgid "pirepView_tab_messages_tooltip" 2077 msgstr "A javító üzenete." 2078 2079 msgid "pirep_messages" 2080 msgstr "Üzenet" 2072 2081 2073 2082 msgid "pirepEdit_title" -
src/mlx/gui/flightlist.py
r854 r855 668 668 669 669 if returned: 670 gui.view PIREP(result.pirep)670 gui.viewMessagedPIREP(result.pirep) 671 671 672 672 def _closeClicked(self, button): -
src/mlx/gui/gui.py
r854 r855 186 186 187 187 self._pirepViewer = PIREPViewer(self) 188 self._messagedPIREPViewer = PIREPViewer(self, showMessages = True) 188 189 189 190 self._pirepEditor = PIREPEditor(self) … … 1313 1314 self._pirepViewer.run() 1314 1315 self._pirepViewer.hide() 1316 1317 def viewMessagedPIREP(self, pirep): 1318 """Display the PIREP viewer window with the given PIREP containing 1319 messages as well.""" 1320 self._messagedPIREPViewer.setPIREP(pirep) 1321 self._messagedPIREPViewer.show_all() 1322 self._messagedPIREPViewer.run() 1323 self._messagedPIREPViewer.hide() 1315 1324 1316 1325 def editPIREP(self, pirep): -
src/mlx/gui/pirep.py
r853 r855 26 26 #------------------------------------------------------------------------------ 27 27 28 class MessageFrame(gtk.Frame): 29 """A frame containing the information about a PIREP message. 30 31 It consists of a text view with the heading information (author, time) and 32 another text view with the actual message.""" 33 def __init__(self, message, senderPID, senderName): 34 """Construct the frame.""" 35 gtk.Frame.__init__(self) 36 37 vbox = gtk.VBox() 38 39 self._heading = heading = gtk.TextView() 40 heading.set_editable(False) 41 heading.set_can_focus(False) 42 heading.set_wrap_mode(WRAP_WORD) 43 44 buffer = heading.get_buffer() 45 self._headingTag = buffer.create_tag("heading", weight=WEIGHT_BOLD) 46 buffer.set_text("%s - %s" % (senderPID, senderName)) 47 buffer.apply_tag(self._headingTag, 48 buffer.get_start_iter(), buffer.get_end_iter()) 49 50 headingAlignment = gtk.Alignment(xalign = 0.0, yalign = 0.0, 51 xscale = 1.0, yscale = 0.0) 52 headingAlignment.set_padding(padding_top = 0, padding_bottom = 0, 53 padding_left = 2, padding_right = 2) 54 headingAlignment.add(heading) 55 vbox.pack_start(headingAlignment, True, True, 4) 56 57 self._messageView = messageView = gtk.TextView() 58 messageView.set_wrap_mode(WRAP_WORD) 59 messageView.set_accepts_tab(False) 60 messageView.set_size_request(-1, 60) 61 62 buffer = messageView.get_buffer() 63 buffer.set_text(message) 64 65 vbox.pack_start(messageView, True, True, 4) 66 67 self.add(vbox) 68 self.show_all() 69 70 if pygobject: 71 styleContext = self.get_style_context() 72 color = styleContext.get_background_color(gtk.StateFlags.NORMAL) 73 heading.override_background_color(0, color) 74 else: 75 style = self.rc_get_style() 76 heading.modify_base(0, style.bg[0]) 77 78 79 #------------------------------------------------------------------------------- 80 81 class MessagesWidget(gtk.Frame): 82 """The widget for the messages.""" 83 @staticmethod 84 def getFaultFrame(alignment): 85 """Get the fault frame from the given alignment.""" 86 return alignment.get_children()[0] 87 88 def __init__(self, gui): 89 gtk.Frame.__init__(self) 90 91 self._gui = gui 92 self.set_label(xstr("pirep_messages")) 93 label = self.get_label_widget() 94 label.set_use_underline(True) 95 96 alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5, 97 xscale = 1.0, yscale = 1.0) 98 alignment.set_padding(padding_top = 4, padding_bottom = 4, 99 padding_left = 4, padding_right = 4) 100 101 self._outerBox = outerBox = gtk.EventBox() 102 outerBox.add(alignment) 103 104 self._innerBox = innerBox = gtk.EventBox() 105 alignment.add(self._innerBox) 106 107 alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5, 108 xscale = 1.0, yscale = 1.0) 109 alignment.set_padding(padding_top = 0, padding_bottom = 0, 110 padding_left = 0, padding_right = 0) 111 112 innerBox.add(alignment) 113 114 scroller = gtk.ScrolledWindow() 115 scroller.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC) 116 scroller.set_shadow_type(SHADOW_NONE) 117 118 self._messages = gtk.VBox() 119 self._messages.set_homogeneous(False) 120 scroller.add_with_viewport(self._messages) 121 122 alignment.add(scroller) 123 124 self._messageWidgets = [] 125 126 self.add(outerBox) 127 self.show_all() 128 129 def addMessage(self, message): 130 """Add a message from the given sender.""" 131 132 alignment = gtk.Alignment(xalign = 0.0, yalign = 0.0, 133 xscale = 1.0, yscale = 0.0) 134 alignment.set_padding(padding_top = 2, padding_bottom = 2, 135 padding_left = 4, padding_right = 4) 136 137 messageFrame = MessageFrame(message.message, 138 message.senderPID, 139 message.senderName) 140 141 alignment.add(messageFrame) 142 self._messages.pack_start(alignment, False, False, 4) 143 self._messages.show_all() 144 145 self._messageWidgets.append((alignment, messageFrame)) 146 147 def reset(self): 148 """Reset the widget by removing all messages.""" 149 for (alignment, messageFrame) in self._messageWidgets: 150 self._messages.remove(alignment) 151 self._messages.show_all() 152 153 self._messageWidgets = [] 154 155 #------------------------------------------------------------------------------ 156 28 157 class PIREPViewer(gtk.Dialog): 29 158 """The dialog for PIREP viewing.""" … … 143 272 label.set_text("%02d:%02d" % (tm.tm_hour, tm.tm_min)) 144 273 145 def __init__(self, gui ):274 def __init__(self, gui, showMessages = False): 146 275 """Construct the PIREP viewer.""" 147 276 super(PIREPViewer, self).__init__(title = WINDOW_TITLE_BASE + … … 176 305 label.set_tooltip_text(xstr("pirepView_tab_log_tooltip")) 177 306 self._notebook.append_page(logTab, label) 307 308 self._showMessages = showMessages 309 if showMessages: 310 messagesTab = self._buildMessagesTab() 311 label = gtk.Label(xstr("pirepView_tab_messages")) 312 label.set_use_underline(True) 313 label.set_tooltip_text(xstr("pirepView_tab_messages_tooltip")) 314 self._notebook.append_page(messagesTab, label) 178 315 179 316 self._okButton = self.add_button(xstr("button_ok"), RESPONSETYPE_OK) … … 271 408 lineIndex += 1 272 409 410 if self._showMessages: 411 self._messages.reset() 412 for message in pirep.messages: 413 self._messages.addMessage(message) 414 273 415 self._notebook.set_current_page(0) 274 416 self._okButton.grab_default() … … 624 766 addFaultTag(self._log.get_buffer()) 625 767 mainBox.pack_start(logWindow, True, True, 0) 768 769 return mainBox 770 771 def _buildMessagesTab(self): 772 """Build the messages tab.""" 773 mainBox = gtk.VBox() 774 775 self._messages = MessagesWidget(self._gui) 776 mainBox.pack_start(self._messages, True, True, 0) 626 777 627 778 return mainBox -
src/mlx/pirep.py
r854 r855 23 23 class PIREP(object): 24 24 """A pilot's report of a flight.""" 25 class Message(object): 26 """A message belonging to the PIREP.""" 27 @staticmethod 28 def fromMessageData(messageData): 29 """Construct a message from a JSON message data.""" 30 message = messageData["message"] 31 senderPID = messageData["senderPID"] 32 senderName = messageData["senderName"] 33 34 return PIREP.Message(message, senderPID, senderName) 35 36 def __init__(self, message, senderPID, senderName): 37 """Construct the message object.""" 38 self.message = message 39 self.senderPID = senderPID 40 self.senderName = senderName 41 25 42 _flightTypes = { const.FLIGHTTYPE_SCHEDULED : "SCHEDULED", 26 43 const.FLIGHTTYPE_OLDTIMER : "OT", … … 159 176 self.faultLineIndexes = logger.faultLineIndexes 160 177 178 self.messages = [] 179 161 180 def setupFromPIREPData(self, pirepData, bookedFlight): 162 181 … … 248 267 numLogLines += 1 249 268 break 269 270 self.messages = [] 271 for messageData in pirepData["messages"]: 272 self.messages.append(PIREP.Message.fromMessageData(messageData)) 250 273 251 274 @property
Note:
See TracChangeset
for help on using the changeset viewer.