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 | BUTTONSTYPE_OK = gtk.BUTTONS_OK
|
---|
23 | else:
|
---|
24 | print "Using PyGObject"
|
---|
25 | pygobject = True
|
---|
26 | from gi.repository import Gdk as gdk
|
---|
27 | from gi.repository import Gtk as gtk
|
---|
28 | from gi.repository import GObject as gobject
|
---|
29 | from gi.repository import AppIndicator3 as appindicator
|
---|
30 | from gi.repository import Pango as pango
|
---|
31 | appIndicator = True
|
---|
32 |
|
---|
33 | MESSAGETYPE_ERROR = gtk.MessageType.ERROR
|
---|
34 | BUTTONSTYPE_OK = gtk.ButtonsType.OK
|
---|
35 |
|
---|
36 | import cairo
|
---|
37 |
|
---|
38 | #------------------------------------------------------------------------------
|
---|
39 |
|
---|
40 | class FlightStatusHandler(object):
|
---|
41 | """Base class for objects that handle the flight status in some way."""
|
---|
42 | def __init__(self):
|
---|
43 | self._stage = None
|
---|
44 | self._rating = 100
|
---|
45 | self._noGoReason = None
|
---|
46 |
|
---|
47 | def resetFlightStatus(self):
|
---|
48 | """Reset the flight status."""
|
---|
49 | self._stage = None
|
---|
50 | self._rating = 100
|
---|
51 | self._noGoReason = None
|
---|
52 | self._updateFlightStatus()
|
---|
53 |
|
---|
54 | def setStage(self, stage):
|
---|
55 | """Set the stage of the flight."""
|
---|
56 | if stage!=self._stage:
|
---|
57 | self._stage = stage
|
---|
58 | self._updateFlightStatus()
|
---|
59 |
|
---|
60 | def setRating(self, rating):
|
---|
61 | """Set the rating to the given value."""
|
---|
62 | if rating!=self._rating:
|
---|
63 | self._rating = rating
|
---|
64 | if self._noGoReason is None:
|
---|
65 | self._updateFlightStatus()
|
---|
66 |
|
---|
67 | def setNoGo(self, reason):
|
---|
68 | """Set a No-Go condition with the given reason."""
|
---|
69 | if self._noGoReason is None:
|
---|
70 | self._noGoReason = reason
|
---|
71 | self._updateFlightStatus()
|
---|
72 |
|
---|
73 | #------------------------------------------------------------------------------
|
---|