1 | # Common things for the GUI
|
---|
2 |
|
---|
3 | import os
|
---|
4 |
|
---|
5 | appIndicator = False
|
---|
6 |
|
---|
7 | if os.name=="nt" or "FORCE_PYGTK" in os.environ:
|
---|
8 | print "Using PyGTK"
|
---|
9 | pygobject = False
|
---|
10 | import pygtk
|
---|
11 | import gtk.gdk as gdk
|
---|
12 | import gtk
|
---|
13 | import gobject
|
---|
14 | import pango
|
---|
15 | try:
|
---|
16 | import appindicator
|
---|
17 | appIndicator = True
|
---|
18 | except Exception, e:
|
---|
19 | pass
|
---|
20 |
|
---|
21 | MESSAGETYPE_ERROR = gtk.MESSAGE_ERROR
|
---|
22 | MESSAGETYPE_QUESTION = gtk.MESSAGE_QUESTION
|
---|
23 | BUTTONSTYPE_OK = gtk.BUTTONS_OK
|
---|
24 | BUTTONSTYPE_YES_NO = gtk.BUTTONS_YES_NO
|
---|
25 | RESPONSETYPE_YES = gtk.RESPONSE_YES
|
---|
26 | else:
|
---|
27 | print "Using PyGObject"
|
---|
28 | pygobject = True
|
---|
29 | from gi.repository import Gdk as gdk
|
---|
30 | from gi.repository import Gtk as gtk
|
---|
31 | from gi.repository import GObject as gobject
|
---|
32 | from gi.repository import AppIndicator3 as appindicator
|
---|
33 | from gi.repository import Pango as pango
|
---|
34 | appIndicator = True
|
---|
35 |
|
---|
36 | MESSAGETYPE_ERROR = gtk.MessageType.ERROR
|
---|
37 | MESSAGETYPE_QUESTION = gtk.MessageType.QUESTION
|
---|
38 | BUTTONSTYPE_OK = gtk.ButtonsType.OK
|
---|
39 | BUTTONSTYPE_YES_NO = gtk.ButtonsType.YES_NO
|
---|
40 | RESPONSETYPE_YES = gtk.ResponseType.YES
|
---|
41 |
|
---|
42 | import cairo
|
---|
43 |
|
---|
44 | #------------------------------------------------------------------------------
|
---|
45 |
|
---|
46 | class FlightStatusHandler(object):
|
---|
47 | """Base class for objects that handle the flight status in some way."""
|
---|
48 | def __init__(self):
|
---|
49 | self._stage = None
|
---|
50 | self._rating = 100
|
---|
51 | self._noGoReason = None
|
---|
52 |
|
---|
53 | def resetFlightStatus(self):
|
---|
54 | """Reset the flight status."""
|
---|
55 | self._stage = None
|
---|
56 | self._rating = 100
|
---|
57 | self._noGoReason = None
|
---|
58 | self._updateFlightStatus()
|
---|
59 |
|
---|
60 | def setStage(self, stage):
|
---|
61 | """Set the stage of the flight."""
|
---|
62 | if stage!=self._stage:
|
---|
63 | self._stage = stage
|
---|
64 | self._updateFlightStatus()
|
---|
65 |
|
---|
66 | def setRating(self, rating):
|
---|
67 | """Set the rating to the given value."""
|
---|
68 | if rating!=self._rating:
|
---|
69 | self._rating = rating
|
---|
70 | if self._noGoReason is None:
|
---|
71 | self._updateFlightStatus()
|
---|
72 |
|
---|
73 | def setNoGo(self, reason):
|
---|
74 | """Set a No-Go condition with the given reason."""
|
---|
75 | if self._noGoReason is None:
|
---|
76 | self._noGoReason = reason
|
---|
77 | self._updateFlightStatus()
|
---|
78 |
|
---|
79 | #------------------------------------------------------------------------------
|
---|