[28] | 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
|
---|
[29] | 11 | import gtk.gdk as gdk
|
---|
[28] | 12 | import gtk
|
---|
| 13 | import gobject
|
---|
| 14 | try:
|
---|
| 15 | import appindicator
|
---|
| 16 | appIndicator = True
|
---|
| 17 | except Exception, e:
|
---|
| 18 | pass
|
---|
| 19 | else:
|
---|
| 20 | print "Using PyGObject"
|
---|
| 21 | pygobject = True
|
---|
[29] | 22 | from gi.repository import Gdk as gdk
|
---|
[28] | 23 | from gi.repository import Gtk as gtk
|
---|
| 24 | from gi.repository import GObject as gobject
|
---|
| 25 | from gi.repository import AppIndicator3 as appindicator
|
---|
| 26 | appIndicator = True
|
---|
| 27 |
|
---|
| 28 | import cairo
|
---|
| 29 |
|
---|
[32] | 30 | #------------------------------------------------------------------------------
|
---|
| 31 |
|
---|
| 32 | class FlightStatusHandler(object):
|
---|
| 33 | """Base class for objects that handle the flight status in some way."""
|
---|
| 34 | def __init__(self):
|
---|
| 35 | self._stage = None
|
---|
| 36 | self._rating = 100
|
---|
| 37 | self._noGoReason = None
|
---|
| 38 |
|
---|
| 39 | def resetFlightStatus(self):
|
---|
| 40 | """Reset the flight status."""
|
---|
| 41 | self._stage = None
|
---|
| 42 | self._rating = 100
|
---|
| 43 | self._noGoReason = None
|
---|
| 44 | self._updateFlightStatus()
|
---|
| 45 |
|
---|
| 46 | def setStage(self, stage):
|
---|
| 47 | """Set the stage of the flight."""
|
---|
| 48 | if stage!=self._stage:
|
---|
| 49 | self._stage = stage
|
---|
| 50 | self._updateFlightStatus()
|
---|
| 51 |
|
---|
| 52 | def setRating(self, rating):
|
---|
| 53 | """Set the rating to the given value."""
|
---|
| 54 | if rating!=self._rating:
|
---|
| 55 | self._rating = rating
|
---|
| 56 | if self._noGoReason is None:
|
---|
| 57 | self._updateFlightStatus()
|
---|
| 58 |
|
---|
| 59 | def setNoGo(self, reason):
|
---|
| 60 | """Set a No-Go condition with the given reason."""
|
---|
| 61 | if self._noGoReason is None:
|
---|
| 62 | self._noGoReason = reason
|
---|
| 63 | self._updateFlightStatus()
|
---|
| 64 |
|
---|
| 65 | #------------------------------------------------------------------------------
|
---|