source: src/mlx/gui/common.py@ 76:f5b2b0022cdf

Last change on this file since 76:f5b2b0022cdf was 76:f5b2b0022cdf, checked in by István Váradi <ivaradi@…>, 12 years ago

Added a Quit option to the status icon's menu and a confirmation dialog.

File size: 2.3 KB
RevLine 
[28]1# Common things for the GUI
2
3import os
4
5appIndicator = False
6
7if 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
[44]14 import pango
[28]15 try:
16 import appindicator
17 appIndicator = True
18 except Exception, e:
19 pass
[42]20
21 MESSAGETYPE_ERROR = gtk.MESSAGE_ERROR
[76]22 MESSAGETYPE_QUESTION = gtk.MESSAGE_QUESTION
[42]23 BUTTONSTYPE_OK = gtk.BUTTONS_OK
[76]24 BUTTONSTYPE_YES_NO = gtk.BUTTONS_YES_NO
25 RESPONSETYPE_YES = gtk.RESPONSE_YES
[28]26else:
27 print "Using PyGObject"
28 pygobject = True
[29]29 from gi.repository import Gdk as gdk
[28]30 from gi.repository import Gtk as gtk
31 from gi.repository import GObject as gobject
32 from gi.repository import AppIndicator3 as appindicator
[44]33 from gi.repository import Pango as pango
[28]34 appIndicator = True
[76]35
[42]36 MESSAGETYPE_ERROR = gtk.MessageType.ERROR
[76]37 MESSAGETYPE_QUESTION = gtk.MessageType.QUESTION
[42]38 BUTTONSTYPE_OK = gtk.ButtonsType.OK
[76]39 BUTTONSTYPE_YES_NO = gtk.ButtonsType.YES_NO
40 RESPONSETYPE_YES = gtk.ResponseType.YES
[42]41
[28]42import cairo
43
[32]44#------------------------------------------------------------------------------
45
46class 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#------------------------------------------------------------------------------
Note: See TracBrowser for help on using the repository browser.