Changeset 994:e71fbf2ee978 for src


Ignore:
Timestamp:
07/04/19 17:29:58 (5 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
python3
hg-Phase:
(<MercurialRepository 1 'hg:/home/ivaradi/mlx/hg' '/'>, 'public')
Message:

Removed conditions on pygobject (re #347)

Location:
src/mlx
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/common.py

    r955 r994  
    77# Common definitions to be used by both the GUI and possible other parts
    88#
    9 # The main purpose of this module is to import Gtk+2 or 3 and related modules
    10 # and provide common names for them. There is a similator module in the GUI
    11 # part (\ref mlx.gui.common), which contains the GUI-specific names. This one
    12 # contains only what is used by other modules as well.
    13 # The variable \c pygobject tells which version of Gtk is being used. If it is
    14 # \c True, Gtk+ 3 is used via the PyGObject interface. Otherwise Gtk+ 2 is
    15 # used, which is the default on Windows or when the \c FORCE_PYGTK environment
    16 # variable is set.
    17 
    189#---------------------------------------------------------------------------------------
    1910
     
    2213#-------------------------------------------------------------------------------
    2314
    24 if "FORCE_PYGTK" in os.environ:
    25     print("Using PyGTK")
    26     pygobject = False
    27     import gobject
    28 else:
    29     print("Using PyGObject")
    30     pygobject = True
    31 
    32     from gi.repository import GObject as gobject
     15from gi.repository import GObject as gobject
    3316
    3417#-------------------------------------------------------------------------------
  • src/mlx/gui/callouts.py

    r919 r994  
    477477
    478478        menu = self._fileListPopupMenu
    479         if pygobject:
    480             menu.popup(None, None, None, None, event.button, event.time)
    481         else:
    482             menu.popup(None, None, None, event.button, event.time)
     479        menu.popup(None, None, None, None, event.button, event.time)
    483480
    484481    def _buildFileListPopupMenu(self):
  • src/mlx/gui/checklist.py

    r954 r994  
    243243        selection = self._fileList.get_selection()
    244244        (model, paths) = selection.get_selected_rows()
    245         indexes = [(path.get_indices() if pygobject else path)[0]
    246                    for path in paths]       
     245        indexes = [path.get_indices()[0] for path in paths]
    247246        indexes.sort()
    248247        if not up:
     
    273272            maxIndex = None
    274273            for path in paths:
    275                 [index] = path.get_indices() if pygobject else path
     274                [index] = path.get_indices()
    276275                if minIndex is None or index<minIndex: minIndex = index
    277276                if maxIndex is None or index>maxIndex: maxIndex = index
     
    326325
    327326        menu = self._fileListPopupMenu
    328         if pygobject:
    329             menu.popup(None, None, None, None, event.button, event.time)
    330         else:
    331             menu.popup(None, None, None, event.button, event.time)
     327        menu.popup(None, None, None, None, event.button, event.time)
    332328
    333329    def _buildFileListPopupMenu(self):
  • src/mlx/gui/common.py

    r954 r994  
    1616#
    1717# Common definitions and utilities for the GUI
    18 #
    19 # The main purpose of this module is to provide common definitions for things
    20 # that are named differently in Gtk+ 2 and 3. This way the other parts of the
    21 # GUI have to check the version in use very rarely. The variable \c pygobject
    22 # tells which version is being used. If it is \c True, Gtk+ 3 is used via the
    23 # PyGObject interface. Otherwise Gtk+ 2 is used, which is the default on
    24 # Windows or when the \c FORCE_PYGTK environment variable is set.
    25 #
    26 # Besides this there are some common utility classes and functions.
    2718
    2819#-----------------------------------------------------------------------------
     
    3021appIndicator = False
    3122
    32 if not pygobject:
    33     print("Using PyGTK")
    34     pygobject = False
    35     import pygtk
    36     pygtk.require("2.0")
    37     import gtk.gdk as gdk
    38     import gtk
    39     import pango
    40 
    41     try:
    42         import appindicator
    43         appIndicator = True
    44     except Exception as e:
    45         pass
    46 
    47     MESSAGETYPE_ERROR = gtk.MESSAGE_ERROR
    48     MESSAGETYPE_QUESTION = gtk.MESSAGE_QUESTION
    49     MESSAGETYPE_INFO = gtk.MESSAGE_INFO
    50 
    51     RESPONSETYPE_NONE = gtk.RESPONSE_NONE
    52     RESPONSETYPE_OK = gtk.RESPONSE_OK
    53     RESPONSETYPE_YES = gtk.RESPONSE_YES
    54     RESPONSETYPE_NO = gtk.RESPONSE_NO
    55     RESPONSETYPE_ACCEPT = gtk.RESPONSE_ACCEPT
    56     RESPONSETYPE_REJECT = gtk.RESPONSE_REJECT
    57     RESPONSETYPE_CANCEL = gtk.RESPONSE_CANCEL
    58 
    59     ACCEL_VISIBLE = gtk.ACCEL_VISIBLE
    60     CONTROL_MASK = gdk.CONTROL_MASK
    61     DIALOG_MODAL = gtk.DIALOG_MODAL
    62     WRAP_WORD = gtk.WRAP_WORD
    63 
    64     JUSTIFY_CENTER = gtk.JUSTIFY_CENTER
    65     JUSTIFY_LEFT = gtk.JUSTIFY_LEFT
    66 
    67     CONTROL_MASK = gdk.CONTROL_MASK
    68     SHIFT_MASK = gdk.SHIFT_MASK
    69     BUTTON1_MASK = gdk.BUTTON1_MASK
    70 
    71     SCROLL_UP = gdk.SCROLL_UP
    72     SCROLL_DOWN = gdk.SCROLL_DOWN
    73 
    74     SPIN_USER_DEFINED = gtk.SPIN_USER_DEFINED
    75 
    76     FILE_CHOOSER_ACTION_SELECT_FOLDER = gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER
    77     FILE_CHOOSER_ACTION_OPEN = gtk.FILE_CHOOSER_ACTION_OPEN
    78     FILE_CHOOSER_ACTION_SAVE = gtk.FILE_CHOOSER_ACTION_SAVE
    79 
    80     SELECTION_MULTIPLE = gtk.SELECTION_MULTIPLE
    81 
    82     SHADOW_IN = gtk.SHADOW_IN
    83     SHADOW_NONE = gtk.SHADOW_NONE
    84 
    85     POLICY_AUTOMATIC = gtk.POLICY_AUTOMATIC
    86     POLICY_NEVER = gtk.POLICY_NEVER
    87     POLICY_ALWAYS = gtk.POLICY_ALWAYS
    88 
    89     WEIGHT_NORMAL = pango.WEIGHT_NORMAL
    90     WEIGHT_BOLD = pango.WEIGHT_BOLD
    91 
    92     WINDOW_STATE_ICONIFIED = gdk.WINDOW_STATE_ICONIFIED
    93     WINDOW_STATE_WITHDRAWN = gdk.WINDOW_STATE_WITHDRAWN
    94 
    95     SORT_ASCENDING = gtk.SORT_ASCENDING
    96     SORT_DESCENDING = gtk.SORT_DESCENDING
    97 
    98     EVENT_BUTTON_PRESS = gdk.BUTTON_PRESS
    99 
    100     TREE_VIEW_COLUMN_FIXED = gtk.TREE_VIEW_COLUMN_FIXED
    101 
    102     FILL = gtk.FILL
    103     EXPAND = gtk.EXPAND
    104 
    105     UPDATE_IF_VALID = gtk.UPDATE_IF_VALID
    106 
    107     SELECTION_MULTIPLE = gtk.SELECTION_MULTIPLE
    108 
    109     WINDOW_POPUP = gtk.WINDOW_POPUP
    110 
    111     pixbuf_new_from_file = gdk.pixbuf_new_from_file
    112 
    113 else: # pygobject
    114     import gi
    115     gi.require_version("Gdk", "3.0")
    116     from gi.repository import Gdk as gdk
    117     from gi.repository import GdkPixbuf as gdkPixbuf
    118     gi.require_version("Gtk", "3.0")
    119     from gi.repository import Gtk as gtk
    120     try:
    121         gi.require_version("AppIndicator3", "0.1")
    122         from gi.repository import AppIndicator3 as appindicator
    123         appIndicator = True
    124     except:
    125         pass
    126     from gi.repository import Pango as pango
    127 
    128 
    129 
    130     MESSAGETYPE_ERROR = gtk.MessageType.ERROR
    131     MESSAGETYPE_QUESTION = gtk.MessageType.QUESTION
    132     MESSAGETYPE_INFO = gtk.MessageType.INFO
    133     RESPONSETYPE_NONE = gtk.ResponseType.NONE
    134     RESPONSETYPE_OK = gtk.ResponseType.OK
    135     RESPONSETYPE_YES = gtk.ResponseType.YES
    136     RESPONSETYPE_NO = gtk.ResponseType.NO
    137     RESPONSETYPE_ACCEPT = gtk.ResponseType.ACCEPT
    138     RESPONSETYPE_REJECT = gtk.ResponseType.REJECT
    139     RESPONSETYPE_CANCEL = gtk.ResponseType.CANCEL
    140     ACCEL_VISIBLE = gtk.AccelFlags.VISIBLE
    141     CONTROL_MASK = gdk.ModifierType.CONTROL_MASK
    142     DIALOG_MODAL = gtk.DialogFlags.MODAL
    143     WRAP_WORD = gtk.WrapMode.WORD
    144     JUSTIFY_CENTER = gtk.Justification.CENTER
    145     JUSTIFY_LEFT = gtk.Justification.LEFT
    146 
    147     CONTROL_MASK = gdk.ModifierType.CONTROL_MASK
    148     SHIFT_MASK = gdk.ModifierType.SHIFT_MASK
    149     BUTTON1_MASK = gdk.ModifierType.BUTTON1_MASK
    150 
    151     SCROLL_UP = gdk.ScrollDirection.UP
    152     SCROLL_DOWN = gdk.ScrollDirection.DOWN
    153 
    154     SPIN_USER_DEFINED = gtk.SpinType.USER_DEFINED
    155 
    156     FILE_CHOOSER_ACTION_SELECT_FOLDER = gtk.FileChooserAction.SELECT_FOLDER
    157     FILE_CHOOSER_ACTION_OPEN = gtk.FileChooserAction.OPEN
    158     FILE_CHOOSER_ACTION_SAVE = gtk.FileChooserAction.SAVE
    159 
    160     SELECTION_MULTIPLE = gtk.SelectionMode.MULTIPLE
    161 
    162     SHADOW_IN = gtk.ShadowType.IN
    163     SHADOW_NONE = gtk.ShadowType.NONE
    164 
    165     POLICY_AUTOMATIC = gtk.PolicyType.AUTOMATIC
    166     POLICY_NEVER = gtk.PolicyType.NEVER
    167     POLICY_ALWAYS = gtk.PolicyType.ALWAYS
    168 
    169     WEIGHT_NORMAL = pango.Weight.NORMAL
    170     WEIGHT_BOLD = pango.Weight.BOLD
    171 
    172     WINDOW_STATE_ICONIFIED = gdk.WindowState.ICONIFIED
    173     WINDOW_STATE_WITHDRAWN = gdk.WindowState.WITHDRAWN
    174 
    175     SORT_ASCENDING = gtk.SortType.ASCENDING
    176     SORT_DESCENDING = gtk.SortType.DESCENDING
    177 
    178     EVENT_BUTTON_PRESS = gdk.EventType.BUTTON_PRESS
    179 
    180     TREE_VIEW_COLUMN_FIXED = gtk.TreeViewColumnSizing.FIXED
    181 
    182     FILL = gtk.AttachOptions.FILL
    183     EXPAND = gtk.AttachOptions.EXPAND
    184 
    185     UPDATE_IF_VALID = gtk.SpinButtonUpdatePolicy.IF_VALID
    186 
    187     SELECTION_MULTIPLE = gtk.SelectionMode.MULTIPLE
    188 
    189     pixbuf_new_from_file = gdkPixbuf.Pixbuf.new_from_file
    190 
    191     import codecs
    192     _utf8Decoder = codecs.getdecoder("utf-8")
     23import gi
     24gi.require_version("Gdk", "3.0")
     25from gi.repository import Gdk as gdk
     26from gi.repository import GdkPixbuf as gdkPixbuf
     27gi.require_version("Gtk", "3.0")
     28from gi.repository import Gtk as gtk
     29try:
     30    gi.require_version("AppIndicator3", "0.1")
     31    from gi.repository import AppIndicator3 as appindicator
     32    appIndicator = True
     33except:
     34    pass
     35from gi.repository import Pango as pango
     36
     37
     38MESSAGETYPE_ERROR = gtk.MessageType.ERROR
     39MESSAGETYPE_QUESTION = gtk.MessageType.QUESTION
     40MESSAGETYPE_INFO = gtk.MessageType.INFO
     41RESPONSETYPE_NONE = gtk.ResponseType.NONE
     42RESPONSETYPE_OK = gtk.ResponseType.OK
     43RESPONSETYPE_YES = gtk.ResponseType.YES
     44RESPONSETYPE_NO = gtk.ResponseType.NO
     45RESPONSETYPE_ACCEPT = gtk.ResponseType.ACCEPT
     46RESPONSETYPE_REJECT = gtk.ResponseType.REJECT
     47RESPONSETYPE_CANCEL = gtk.ResponseType.CANCEL
     48ACCEL_VISIBLE = gtk.AccelFlags.VISIBLE
     49CONTROL_MASK = gdk.ModifierType.CONTROL_MASK
     50DIALOG_MODAL = gtk.DialogFlags.MODAL
     51WRAP_WORD = gtk.WrapMode.WORD
     52JUSTIFY_CENTER = gtk.Justification.CENTER
     53JUSTIFY_LEFT = gtk.Justification.LEFT
     54
     55CONTROL_MASK = gdk.ModifierType.CONTROL_MASK
     56SHIFT_MASK = gdk.ModifierType.SHIFT_MASK
     57BUTTON1_MASK = gdk.ModifierType.BUTTON1_MASK
     58
     59SCROLL_UP = gdk.ScrollDirection.UP
     60SCROLL_DOWN = gdk.ScrollDirection.DOWN
     61
     62SPIN_USER_DEFINED = gtk.SpinType.USER_DEFINED
     63
     64FILE_CHOOSER_ACTION_SELECT_FOLDER = gtk.FileChooserAction.SELECT_FOLDER
     65FILE_CHOOSER_ACTION_OPEN = gtk.FileChooserAction.OPEN
     66FILE_CHOOSER_ACTION_SAVE = gtk.FileChooserAction.SAVE
     67
     68SELECTION_MULTIPLE = gtk.SelectionMode.MULTIPLE
     69
     70SHADOW_IN = gtk.ShadowType.IN
     71SHADOW_NONE = gtk.ShadowType.NONE
     72
     73POLICY_AUTOMATIC = gtk.PolicyType.AUTOMATIC
     74POLICY_NEVER = gtk.PolicyType.NEVER
     75POLICY_ALWAYS = gtk.PolicyType.ALWAYS
     76
     77WEIGHT_NORMAL = pango.Weight.NORMAL
     78WEIGHT_BOLD = pango.Weight.BOLD
     79
     80WINDOW_STATE_ICONIFIED = gdk.WindowState.ICONIFIED
     81WINDOW_STATE_WITHDRAWN = gdk.WindowState.WITHDRAWN
     82
     83SORT_ASCENDING = gtk.SortType.ASCENDING
     84SORT_DESCENDING = gtk.SortType.DESCENDING
     85
     86EVENT_BUTTON_PRESS = gdk.EventType.BUTTON_PRESS
     87
     88TREE_VIEW_COLUMN_FIXED = gtk.TreeViewColumnSizing.FIXED
     89
     90FILL = gtk.AttachOptions.FILL
     91EXPAND = gtk.AttachOptions.EXPAND
     92
     93UPDATE_IF_VALID = gtk.SpinButtonUpdatePolicy.IF_VALID
     94
     95SELECTION_MULTIPLE = gtk.SelectionMode.MULTIPLE
     96
     97pixbuf_new_from_file = gdkPixbuf.Pixbuf.new_from_file
     98
     99import codecs
     100_utf8Decoder = codecs.getdecoder("utf-8")
    193101
    194102import cairo
  • src/mlx/gui/delaycodes.py

    r965 r994  
    1111#------------------------------------------------------------------------------
    1212
    13 if pygobject:
    14 
    15 #------------------------------------------------------------------------------
    16 
    17     class Viewport(gtk.Viewport):
    18         """Viewport implementation that alleviates the problem with improper
    19         resizing by the VBox."""
    20         def __init__(self):
    21             """Construct the viewport."""
    22             gtk.Viewport.__init__(self)
    23             self._recursive = False
     13class Viewport(gtk.Viewport):
     14    """Viewport implementation that alleviates the problem with improper
     15    resizing by the VBox."""
     16    def __init__(self):
     17        """Construct the viewport."""
     18        gtk.Viewport.__init__(self)
     19        self._recursive = False
     20        self._vboxHeight = None
     21
     22    def setVBOXHeight(self, vboxHeight):
     23        """Set the height of the VBox which will be used to calculate the
     24        viewport's height."""
     25        self._vboxHeight = vboxHeight
     26
     27    def do_size_allocate(self, allocation):
     28        """Called when the viewport's size is allocated.
     29
     30        The height in the allocation object is modified so that it is only
     31        so high to fit into the VBox."""
     32        if self._vboxHeight is not None:
     33            allocation.y += 1
     34            allocation.height = self._vboxHeight - allocation.y
    2435            self._vboxHeight = None
    25 
    26         def setVBOXHeight(self, vboxHeight):
    27             """Set the height of the VBox which will be used to calculate the
    28             viewport's height."""
    29             self._vboxHeight = vboxHeight
    30 
    31         def do_size_allocate(self, allocation):
    32             """Called when the viewport's size is allocated.
    33 
    34             The height in the allocation object is modified so that it is only
    35             so high to fit into the VBox."""
    36             if self._vboxHeight is not None:
    37                 allocation.y += 1
    38                 allocation.height = self._vboxHeight - allocation.y
    39                 self._vboxHeight = None
    40             gtk.Viewport.do_size_allocate(self, allocation)
    41 
    42     class DelayCodeTableBase(gtk.VBox, gtk.Scrollable):
    43         """PyGObject-specific base class for the delay code table."""
    44         __gproperties__ = {
    45             "vscroll-policy" : ( gtk.ScrollablePolicy,
    46                                  "vscroll-policy",
    47                                  "The vertical scrolling policy",
    48                                  gtk.ScrollablePolicy.MINIMUM,
    49                                  gobject.PARAM_READWRITE ),
    50             "vadjustment" : ( gtk.Adjustment,
    51                               "vadjustment",
    52                               "The vertical adjustment",
    53                               gobject.PARAM_READWRITE ),
    54             "hscroll-policy" : ( gtk.ScrollablePolicy,
    55                                  "hscroll-policy",
    56                                  "The horizontal scrolling policy",
    57                                  gtk.ScrollablePolicy.MINIMUM,
    58                                  gobject.PARAM_READWRITE ),
    59             "hadjustment" : ( gtk.Adjustment,
    60                               "hadjustment",
    61                               "The horizontal adjustment",
    62                               gobject.PARAM_READWRITE )  }
    63 
    64 
    65         @staticmethod
    66         def _createViewport():
    67             """Create an instance of the viewport class used by this base class."""
    68             return Viewport()
    69 
    70         def __init__(self):
    71             """Construct the delay code table."""
    72             super(DelayCodeTableBase, self).__init__()
    73 
    74         def do_size_allocate(self, allocation):
    75             """Allocate the size for the table and its children.
    76 
    77             This sets up the VBox height in the viewport and then calls the
    78             do_size_allocate() function of VBox()."""
    79             self._viewport.setVBOXHeight(allocation.height)
    80             gtk.VBox.do_size_allocate(self, allocation)
    81             self.allocate_column_sizes(allocation)
    82 
    83         def do_get_property(self, prop):
    84             """Get the value of one of the properties defined above.
    85 
    86             The request is forwarded to the viewport."""
    87             if prop.name=="vscroll-policy":
    88                 return self._viewport.get_vscroll_policy()
    89             elif prop.name=="hscroll-policy":
    90                 return self._viewport.get_hscroll_policy()
    91             elif prop.name=="vadjustment":
    92                 return self._viewport.get_vadjustment()
    93             elif prop.name=="hadjustment":
    94                 return self._viewport.get_hadjustment()
    95             else:
    96                 raise AttributeError("mlx.gui.delaycodes.DelayCodeTableBase: property %s is not handled in do_get_property" %
    97                                      (prop.name,))
    98 
    99         def do_set_property(self, prop, value):
    100             """Set the value of the adjustment properties defined above.
    101 
    102             The adjustments are forwarded to the viewport."""
    103             if prop.name=="vadjustment":
    104                 self._viewport.set_vadjustment(value)
    105             elif prop.name=="hadjustment":
    106                 self._viewport.set_hadjustment(value)
    107                 self._treeView.set_hadjustment(value)
    108             else:
    109                 raise AttributeError("mlx.gui.delaycodes.DelayCodeTableBase: property %s is not handled in do_set_property" %
    110                                      (prop.name,))
    111 
    112         def setStyle(self):
    113             """Set the style of the event box from the treeview."""
    114 
    115     class Alignment(gtk.Alignment):
    116         """An alignment that remembers the width it was given."""
    117         def __init__(self, xalign = 0.0, yalign=0.0,
    118                      xscale = 0.0, yscale = 0.0 ):
    119             """Construct the alignment."""
    120             super(Alignment, self).__init__(xalign = xalign, yalign = yalign,
    121                                             xscale = xscale, yscale = yscale)
    122             self.allocatedWidth = 0
    123 
    124         def do_size_allocate(self, allocation):
    125             """Called with the new size allocation."""
    126             self.allocatedWidth = allocation.width
    127             gtk.Alignment.do_size_allocate(self, allocation)
    128 
    129     class TreeView(gtk.TreeView):
    130         def do_size_allocate(self, allocation):
    131             allocation.height += 1
    132             gtk.TreeView.do_size_allocate(self, allocation)
    133 
    134 #------------------------------------------------------------------------------
    135 
    136 else: # pygobject
    137 
    138 #------------------------------------------------------------------------------
    139 
    140     class DelayCodeTableBase (gtk.VBox):
    141         """Base class of the delay code table for PyGtk."""
    142 
    143         __gsignals__ = {
    144             "set-scroll-adjustments": (
    145                 gobject.SIGNAL_RUN_LAST,
    146                 gobject.TYPE_NONE, (gtk.Adjustment, gtk.Adjustment))
    147                 }
    148 
    149         @staticmethod
    150         def _createViewport():
    151             """Create an instance of the viewport class used by this base class."""
    152             return gtk.Viewport()
    153 
    154         def __init__(self):
    155             """Construct the base class."""
    156             super(DelayCodeTableBase, self).__init__()
    157             self.set_set_scroll_adjustments_signal("set-scroll-adjustments")
    158             self.connect("size-allocate", self._do_size_allocate)
    159 
    160         def do_set_scroll_adjustments(self, hAdjustment, vAdjustment):
    161             """Set the adjustments on the viewport."""
    162             self._viewport.set_hadjustment(hAdjustment)
    163             self._viewport.set_vadjustment(vAdjustment)
    164             self._treeView.set_hadjustment(hAdjustment)
    165 
    166         def _do_size_allocate(self, widget, allocation):
    167             """Handler of the size-allocate signal.
    168 
    169             Calls allocate_column_sizes()."""
    170             self.allocate_column_sizes(allocation)
    171 
    172         def setStyle(self):
    173             """Set the style of the event box from the treeview."""
    174             if self._treeView is not None:
    175                 style = self._treeView.rc_get_style()
    176                 self._eventBox.modify_bg(0, style.bg[2])
    177                 self._eventBox.modify_fg(0, style.fg[2])
    178 
    179     class Alignment(gtk.Alignment):
    180         """An alignment that remembers the width it was given."""
    181         def __init__(self, xalign = 0.0, yalign=0.0,
    182                      xscale = 0.0, yscale = 0.0 ):
    183             """Construct the alignment."""
    184             super(Alignment, self).__init__(xalign = xalign, yalign = yalign,
    185                                             xscale = xscale, yscale = yscale)
    186             self.allocatedWidth = 0
    187             self.connect("size-allocate", self._do_size_allocate)
    188 
    189         def _do_size_allocate(self, widget, allocation):
    190             """Called with the new size allocation."""
    191             self.allocatedWidth = allocation.width
     36        gtk.Viewport.do_size_allocate(self, allocation)
     37
     38class DelayCodeTableBase(gtk.VBox, gtk.Scrollable):
     39    """PyGObject-specific base class for the delay code table."""
     40    __gproperties__ = {
     41        "vscroll-policy" : ( gtk.ScrollablePolicy,
     42                             "vscroll-policy",
     43                             "The vertical scrolling policy",
     44                             gtk.ScrollablePolicy.MINIMUM,
     45                             gobject.PARAM_READWRITE ),
     46        "vadjustment" : ( gtk.Adjustment,
     47                          "vadjustment",
     48                          "The vertical adjustment",
     49                          gobject.PARAM_READWRITE ),
     50        "hscroll-policy" : ( gtk.ScrollablePolicy,
     51                             "hscroll-policy",
     52                             "The horizontal scrolling policy",
     53                             gtk.ScrollablePolicy.MINIMUM,
     54                             gobject.PARAM_READWRITE ),
     55        "hadjustment" : ( gtk.Adjustment,
     56                          "hadjustment",
     57                          "The horizontal adjustment",
     58                          gobject.PARAM_READWRITE )  }
     59
     60
     61    @staticmethod
     62    def _createViewport():
     63        """Create an instance of the viewport class used by this base class."""
     64        return Viewport()
     65
     66    def __init__(self):
     67        """Construct the delay code table."""
     68        super(DelayCodeTableBase, self).__init__()
     69
     70    def do_size_allocate(self, allocation):
     71        """Allocate the size for the table and its children.
     72
     73        This sets up the VBox height in the viewport and then calls the
     74        do_size_allocate() function of VBox()."""
     75        self._viewport.setVBOXHeight(allocation.height)
     76        gtk.VBox.do_size_allocate(self, allocation)
     77        self.allocate_column_sizes(allocation)
     78
     79    def do_get_property(self, prop):
     80        """Get the value of one of the properties defined above.
     81
     82        The request is forwarded to the viewport."""
     83        if prop.name=="vscroll-policy":
     84            return self._viewport.get_vscroll_policy()
     85        elif prop.name=="hscroll-policy":
     86            return self._viewport.get_hscroll_policy()
     87        elif prop.name=="vadjustment":
     88            return self._viewport.get_vadjustment()
     89        elif prop.name=="hadjustment":
     90            return self._viewport.get_hadjustment()
     91        else:
     92            raise AttributeError("mlx.gui.delaycodes.DelayCodeTableBase: property %s is not handled in do_get_property" %
     93                                 (prop.name,))
     94
     95    def do_set_property(self, prop, value):
     96        """Set the value of the adjustment properties defined above.
     97
     98        The adjustments are forwarded to the viewport."""
     99        if prop.name=="vadjustment":
     100            self._viewport.set_vadjustment(value)
     101        elif prop.name=="hadjustment":
     102            self._viewport.set_hadjustment(value)
     103            self._treeView.set_hadjustment(value)
     104        else:
     105            raise AttributeError("mlx.gui.delaycodes.DelayCodeTableBase: property %s is not handled in do_set_property" %
     106                                 (prop.name,))
     107
     108    def setStyle(self):
     109        """Set the style of the event box from the treeview."""
     110
     111class Alignment(gtk.Alignment):
     112    """An alignment that remembers the width it was given."""
     113    def __init__(self, xalign = 0.0, yalign=0.0,
     114                 xscale = 0.0, yscale = 0.0 ):
     115        """Construct the alignment."""
     116        super(Alignment, self).__init__(xalign = xalign, yalign = yalign,
     117                                        xscale = xscale, yscale = yscale)
     118        self.allocatedWidth = 0
     119
     120    def do_size_allocate(self, allocation):
     121        """Called with the new size allocation."""
     122        self.allocatedWidth = allocation.width
     123        gtk.Alignment.do_size_allocate(self, allocation)
     124
     125class TreeView(gtk.TreeView):
     126    def do_size_allocate(self, allocation):
     127        allocation.height += 1
     128        gtk.TreeView.do_size_allocate(self, allocation)
    192129
    193130#------------------------------------------------------------------------------
  • src/mlx/gui/faultexplain.py

    r988 r994  
    5959        self.show_all()
    6060
    61         if pygobject:
    62             styleContext = self.get_style_context()
    63             color = styleContext.get_background_color(gtk.StateFlags.NORMAL)
    64             fault.override_background_color(0, color)
    65         else:
    66             style = self.rc_get_style()
    67             fault.modify_base(0, style.bg[0])
     61        styleContext = self.get_style_context()
     62        color = styleContext.get_background_color(gtk.StateFlags.NORMAL)
     63        fault.override_background_color(0, color)
    6864
    6965        self._hasExplanation = False
     
    285281        not."""
    286282        allExplained = self._numExplanations >= self._numFaults
    287         if pygobject:
    288             styleContext = self.get_style_context()
    289             if allExplained:
    290                 outerColour = innerColour = gdk.RGBA(red = 0.0, green=0.0,
    291                                                      blue=0.0, alpha=0.0)
    292             else:
    293                 outerColour = \
    294                   styleContext.get_border_color(gtk.StateFlags.DROP_ACTIVE)
    295                 innerColour = self._gui.backgroundColour
    296 
    297             self._outerBox.override_background_color(gtk.StateFlags.NORMAL,
    298                                                      outerColour)
    299             self._innerBox.override_background_color(gtk.StateFlags.NORMAL,
    300                                                      innerColour)
     283        styleContext = self.get_style_context()
     284        if allExplained:
     285            outerColour = innerColour = gdk.RGBA(red = 0.0, green=0.0,
     286                                                 blue=0.0, alpha=0.0)
    301287        else:
    302             style = self.rc_get_style()
    303             self._outerBox.modify_bg(0, style.bg[0 if allExplained else 3])
     288            outerColour = \
     289                styleContext.get_border_color(gtk.StateFlags.DROP_ACTIVE)
     290            innerColour = self._gui.backgroundColour
     291
     292        self._outerBox.override_background_color(gtk.StateFlags.NORMAL,
     293                                                 outerColour)
     294        self._innerBox.override_background_color(gtk.StateFlags.NORMAL,
     295                                                 innerColour)
    304296
    305297#-------------------------------------------------------------------------------
  • src/mlx/gui/flight.py

    r992 r994  
    121121        self._helpLabel = gtk.Label(longerHelp)
    122122        # FIXME: should be a constant in common
    123         self._helpLabel.set_justify(gtk.Justification.CENTER if pygobject
    124                                     else gtk.JUSTIFY_CENTER)
     123        self._helpLabel.set_justify(gtk.Justification.CENTER)
    125124        self._helpLabel.set_use_markup(True)
    126125        alignment.add(self._helpLabel)
     
    220219    def setStyle(self):
    221220        """Set the styles of some of the items on the page."""
    222         if pygobject:
    223             context = self.get_style_context()
    224             color = context.get_background_color(gtk.StateFlags.SELECTED)
    225             self._titleEventBox.modify_bg(0, color.to_color())
    226             color = context.get_color(gtk.StateFlags.SELECTED)
    227             self._titleLabel.modify_fg(0, color.to_color())
    228         else:
    229             style = self.rc_get_style()
    230             self._titleEventBox.modify_bg(0, style.bg[3])
    231             self._titleLabel.modify_fg(0, style.fg[3])
     221        context = self.get_style_context()
     222        color = context.get_background_color(gtk.StateFlags.SELECTED)
     223        self._titleEventBox.modify_bg(0, color.to_color())
     224        color = context.get_color(gtk.StateFlags.SELECTED)
     225        self._titleLabel.modify_fg(0, color.to_color())
    232226
    233227    def initialize(self):
     
    11671161        scrolledWindow.add(self._gateList)
    11681162        scrolledWindow.set_size_request(50, -1)
    1169         scrolledWindow.set_policy(gtk.PolicyType.AUTOMATIC if pygobject
    1170                                   else gtk.POLICY_AUTOMATIC,
    1171                                   gtk.PolicyType.AUTOMATIC if pygobject
    1172                                   else gtk.POLICY_AUTOMATIC)
    1173         scrolledWindow.set_shadow_type(gtk.ShadowType.IN if pygobject
    1174                                        else gtk.SHADOW_IN)
     1163        scrolledWindow.set_policy(gtk.PolicyType.AUTOMATIC,
     1164                                  gtk.PolicyType.AUTOMATIC)
     1165        scrolledWindow.set_shadow_type(gtk.ShadowType.IN)
    11751166
    11761167        alignment = gtk.Alignment(xalign = 0.5, yalign = 0.0, xscale = 0.0, yscale = 1.0)
     
    20122003
    20132004            selectBox = gtk.HBox()
    2014             if pygobject:
    2015                 self._selectMSFS = \
    2016                   gtk.RadioButton.new_with_mnemonic_from_widget(None,
    2017                                                                 xstr("connect_sim_msfs"))
    2018             else:
    2019                 self._selectMSFS = gtk.RadioButton(None,
    2020                                                    xstr("connect_sim_msfs"))
     2005            self._selectMSFS = \
     2006                gtk.RadioButton.new_with_mnemonic_from_widget(None,
     2007                                                              xstr("connect_sim_msfs"))
    20212008
    20222009            selectBox.pack_start(self._selectMSFS, False, False, 0);
    20232010
    2024             if pygobject:
    2025                 self._selectXPlane = \
    2026                   gtk.RadioButton.new_with_mnemonic_from_widget(self._selectMSFS,
    2027                                                                 xstr("connect_sim_xplane"))
    2028             else:
    2029                 self._selectXPlane = gtk.RadioButton(self._selectMSFS,
    2030                                                      xstr("connect_sim_xplane"))
     2011            self._selectXPlane = \
     2012                gtk.RadioButton.new_with_mnemonic_from_widget(self._selectMSFS,
     2013                                                              xstr("connect_sim_xplane"))
    20312014
    20322015            selectBox.pack_start(self._selectXPlane, False, False, 8);
     
    25102493        routeWindow = gtk.ScrolledWindow()
    25112494        routeWindow.set_size_request(400, 80)
    2512         routeWindow.set_shadow_type(gtk.ShadowType.IN if pygobject
    2513                                     else gtk.SHADOW_IN)
    2514         routeWindow.set_policy(gtk.PolicyType.AUTOMATIC if pygobject
    2515                                else gtk.POLICY_AUTOMATIC,
    2516                                gtk.PolicyType.AUTOMATIC if pygobject
    2517                                else gtk.POLICY_AUTOMATIC)
     2495        routeWindow.set_shadow_type(gtk.ShadowType.IN)
     2496        routeWindow.set_policy(gtk.PolicyType.AUTOMATIC,
     2497                               gtk.PolicyType.AUTOMATIC)
    25182498
    25192499        self._uppercasingRoute = False
     
    32673247        self._tankFigure.set_tooltip_markup(xstr("fuel_tank_tooltip"))
    32683248
    3269         if pygobject:
    3270             self._tankFigure.connect("draw", self._drawTankFigure)
    3271         else:
    3272             self._tankFigure.connect("expose_event", self._drawTankFigure)
     3249        self._tankFigure.connect("draw", self._drawTankFigure)
    32733250        self._tankFigure.connect("button_press_event", self._buttonPressed)
    32743251        self._tankFigure.connect("motion_notify_event", self._motionNotify)
     
    33243301        triangleSize = 5
    33253302
    3326         context = eventOrContext if pygobject else tankFigure.window.cairo_create()
    3327         (xOffset, yOffset) = (0, 0) if pygobject \
    3328                              else (tankFigure.allocation.x, tankFigure.allocation.y)
    3329 
    3330         width = tankFigure.get_allocated_width() if pygobject \
    3331                 else tankFigure.allocation.width
    3332         height = tankFigure.get_allocated_height() if pygobject \
    3333                  else tankFigure.allocation.height
     3303        context = eventOrContext
     3304        (xOffset, yOffset) = (0, 0)
     3305
     3306        width = tankFigure.get_allocated_width()
     3307        height = tankFigure.get_allocated_height()
    33343308
    33353309        rectangleX0 = triangleSize
     
    36453619        scrolledWindow.set_size_request(-1, 128)
    36463620        # FIXME: these constants should be in common
    3647         scrolledWindow.set_policy(gtk.PolicyType.AUTOMATIC if pygobject
    3648                                   else gtk.POLICY_AUTOMATIC,
    3649                                   gtk.PolicyType.AUTOMATIC if pygobject
    3650                                   else gtk.POLICY_AUTOMATIC)
     3621        scrolledWindow.set_policy(gtk.PolicyType.AUTOMATIC,
     3622                                  gtk.PolicyType.AUTOMATIC)
    36513623        self._notams = gtk.TextView()
    36523624        self._notams.set_editable(False)
    36533625        self._notams.set_accepts_tab(False)
    3654         self._notams.set_wrap_mode(gtk.WrapMode.WORD if pygobject else gtk.WRAP_WORD)
     3626        self._notams.set_wrap_mode(gtk.WrapMode.WORD)
    36553627        scrolledWindow.add(self._notams)
    36563628        alignment = gtk.Alignment(xalign = 0.0, yalign = 0.0,
     
    36663638        scrolledWindow = gtk.ScrolledWindow()
    36673639        scrolledWindow.set_size_request(-1, 32)
    3668         scrolledWindow.set_policy(gtk.PolicyType.AUTOMATIC if pygobject
    3669                                   else gtk.POLICY_AUTOMATIC,
    3670                                   gtk.PolicyType.AUTOMATIC if pygobject
    3671                                   else gtk.POLICY_AUTOMATIC)
     3640        scrolledWindow.set_policy(gtk.PolicyType.AUTOMATIC,
     3641                                  gtk.PolicyType.AUTOMATIC)
    36723642
    36733643        self._updatingMETAR = False
     
    36753645        self._metar = gtk.TextView()
    36763646        self._metar.set_accepts_tab(False)
    3677         self._metar.set_wrap_mode(gtk.WrapMode.WORD if pygobject else gtk.WRAP_WORD)
     3647        self._metar.set_wrap_mode(gtk.WrapMode.WORD)
    36783648        self._metar.get_buffer().connect("changed", self._metarChanged)
    36793649        self._metar.get_buffer().connect_after("insert-text", self._metarInserted)
     
    38723842        table.attach(label, 0, 1, row, row+1)
    38733843
    3874         if pygobject:
    3875             self._sid = gtk.ComboBox.new_with_model_and_entry(comboModel)
    3876         else:
    3877             self._sid = gtk.ComboBoxEntry(comboModel)
     3844        self._sid = gtk.ComboBox.new_with_model_and_entry(comboModel)
    38783845
    38793846        self._sid.set_entry_text_column(0)
     
    42384205            self._derateLabel.set_sensitive(True)
    42394206
    4240             if pygobject:
    4241                 nominal = gtk.RadioButton.\
    4242                   new_with_label_from_widget(None,
    4243                                              xstr("takeoff_derate_tupolev_nominal"))
    4244             else:
    4245                 nominal = gtk.RadioButton(None,
    4246                                           xstr("takeoff_derate_tupolev_nominal"))
     4207            nominal = gtk.RadioButton.\
     4208                new_with_label_from_widget(None,
     4209                                           xstr("takeoff_derate_tupolev_nominal"))
    42474210            nominal.set_use_underline(True)
    42484211            nominal.set_tooltip_text(xstr("takeoff_derate_tupolev_nominal_tooltip"))
    42494212            nominal.connect("toggled", self._derateChanged)
    42504213
    4251             if pygobject:
    4252                 takeoff = gtk.RadioButton.\
    4253                   new_with_label_from_widget(nominal,
    4254                                              xstr("takeoff_derate_tupolev_takeoff"))
    4255             else:
    4256                 takeoff = gtk.RadioButton(nominal,
    4257                                           xstr("takeoff_derate_tupolev_takeoff"))
     4214            takeoff = gtk.RadioButton.\
     4215                new_with_label_from_widget(nominal,
     4216                                           xstr("takeoff_derate_tupolev_takeoff"))
    42584217
    42594218            takeoff.set_use_underline(True)
     
    44624421        table.attach(label, 1, 2, row, row + 1)
    44634422
    4464         if pygobject:
    4465             self._star = gtk.ComboBox.new_with_model_and_entry(comboModel)
    4466         else:
    4467             self._star = gtk.ComboBoxEntry(comboModel)
     4423        self._star = gtk.ComboBox.new_with_model_and_entry(comboModel)
    44684424
    44694425        self._star.set_entry_text_column(0)
     
    44824438        table.attach(label, 1, 2, row, row + 1)
    44834439
    4484         if pygobject:
    4485             self._transition = gtk.ComboBox.new_with_model_and_entry(comboModel)
    4486         else:
    4487             self._transition = gtk.ComboBoxEntry(comboModel)
     4440        self._transition = gtk.ComboBox.new_with_model_and_entry(comboModel)
    44884441
    44894442        self._transition.set_entry_text_column(0)
     
    54995452            self.show_all()
    55005453            pageSizeRequest = page.size_request()
    5501             width = pageSizeRequest.width if pygobject else pageSizeRequest[0]
    5502             height = pageSizeRequest.height if pygobject else pageSizeRequest[1]
     5454            width = pageSizeRequest.width
     5455            height = pageSizeRequest.height
    55035456            maxWidth = max(maxWidth, width)
    55045457            maxHeight = max(maxHeight, height)
  • src/mlx/gui/flightlist.py

    r983 r994  
    145145            scrolledWindow.set_size_request(widthRequest, -1)
    146146        # FIXME: these should be constants in common.py
    147         scrolledWindow.set_policy(gtk.PolicyType.AUTOMATIC if pygobject
    148                                   else gtk.POLICY_AUTOMATIC,
    149                                   gtk.PolicyType.AUTOMATIC if pygobject
    150                                   else gtk.POLICY_AUTOMATIC)
    151         scrolledWindow.set_shadow_type(gtk.ShadowType.IN if pygobject
    152                                        else gtk.SHADOW_IN)
     147        scrolledWindow.set_policy(gtk.PolicyType.AUTOMATIC,
     148                                  gtk.PolicyType.AUTOMATIC)
     149        scrolledWindow.set_shadow_type(gtk.ShadowType.IN)
    153150
    154151        super(FlightList, self).__init__(xalign = 0.5, yalign = 0.0,
     
    222219            self._popupMenu = self._popupMenuProducer()
    223220        menu = self._popupMenu
    224         if pygobject:
    225             menu.popup(None, None, None, None, event.button, event.time)
    226         else:
    227             menu.popup(None, None, None, event.button, event.time)
     221        menu.popup(None, None, None, None, event.button, event.time)
    228222
    229223    def _selectionChanged(self, selection):
  • src/mlx/gui/gates.py

    r919 r994  
    6464        scrolledWindow.set_size_request(200, -1)
    6565        # FIXME: these should be constants in common.py
    66         scrolledWindow.set_policy(gtk.PolicyType.AUTOMATIC if pygobject
    67                                   else gtk.POLICY_AUTOMATIC,
    68                                   gtk.PolicyType.AUTOMATIC if pygobject
    69                                   else gtk.POLICY_AUTOMATIC)
    70         scrolledWindow.set_shadow_type(gtk.ShadowType.IN if pygobject
    71                                        else gtk.SHADOW_IN)
     66        scrolledWindow.set_policy(gtk.PolicyType.AUTOMATIC,
     67                                  gtk.PolicyType.AUTOMATIC)
     68        scrolledWindow.set_shadow_type(gtk.ShadowType.IN)
    7269
    7370
     
    165162                self._fleetStore.append([tailNumber, status])
    166163            # FIXME: this should be a constant in common.py
    167             self._fleetStore.set_sort_column_id(0,
    168                                                 gtk.SortType.ASCENDING if pygobject
    169                                                 else gtk.SORT_ASCENDING)
     164            self._fleetStore.set_sort_column_id(0, gtk.SortType.ASCENDING)
    170165
    171166            occupiedGateNumbers = fleet.getOccupiedGateNumbers()
  • src/mlx/gui/gui.py

    r954 r994  
    206206        self._statusIcon = StatusIcon(iconDirectory, self)
    207207
    208         self._busyCursor = gdk.Cursor(gdk.CursorType.WATCH if pygobject
    209                                       else gdk.WATCH)
     208        self._busyCursor = gdk.Cursor(gdk.CursorType.WATCH)
    210209
    211210        self._loadPIREPDialog = None
     
    444443        return self._flightInfo.faultsFullyExplained
    445444
    446     if pygobject:
    447         @property
    448         def backgroundColour(self):
    449             """Get the background colour of the main window."""
    450             return self._mainWindow.get_style_context().\
    451               get_background_color(gtk.StateFlags.NORMAL)
     445    @property
     446    def backgroundColour(self):
     447        """Get the background colour of the main window."""
     448        return self._mainWindow.get_style_context().\
     449            get_background_color(gtk.StateFlags.NORMAL)
    452450
    453451    def run(self):
     
    741739    def _handleMainWindowState(self, window, event):
    742740        """Hande a change in the state of the window"""
    743         iconified = gdk.WindowState.ICONIFIED if pygobject \
    744                     else gdk.WINDOW_STATE_ICONIFIED
     741        iconified = gdk.WindowState.ICONIFIED
    745742
    746743        if (event.changed_mask&WINDOW_STATE_WITHDRAWN)!=0:
     
    750747                self._statusIcon.mainWindowShown()
    751748
    752         if self.config.hideMinimizedWindow and not pygobject and \
    753            (event.changed_mask&WINDOW_STATE_ICONIFIED)!=0 and \
    754            (event.new_window_state&WINDOW_STATE_ICONIFIED)!=0:
    755             self.hideMainWindow(savePosition = False)
    756         elif (event.changed_mask&WINDOW_STATE_ICONIFIED)!=0 and \
    757              (event.new_window_state&WINDOW_STATE_ICONIFIED)==0:
     749        if (event.changed_mask&WINDOW_STATE_ICONIFIED)!=0 and \
     750           (event.new_window_state&WINDOW_STATE_ICONIFIED)==0:
    758751            self._mainWindow.present()
    759752
     
    798791            self._mainWindow.move(self._mainWindowX, self._mainWindowY)
    799792
    800         if pygobject:
    801             self._mainWindow.show()
    802         else:
    803             self._mainWindow.present()
     793        self._mainWindow.show()
    804794        self._mainWindow.deiconify()
    805795
     
    12391229        logScroller = gtk.ScrolledWindow()
    12401230        # FIXME: these should be constants in common
    1241         logScroller.set_policy(gtk.PolicyType.AUTOMATIC if pygobject
    1242                                else gtk.POLICY_AUTOMATIC,
    1243                                gtk.PolicyType.AUTOMATIC if pygobject
    1244                                else gtk.POLICY_AUTOMATIC)
    1245         logScroller.set_shadow_type(gtk.ShadowType.IN if pygobject
    1246                                     else gtk.SHADOW_IN)
     1231        logScroller.set_policy(gtk.PolicyType.AUTOMATIC,
     1232                               gtk.PolicyType.AUTOMATIC)
     1233        logScroller.set_shadow_type(gtk.ShadowType.IN)
    12471234        logView = gtk.TextView()
    12481235        logView.set_editable(False)
     
    18491836            dialog.set_license(xstr("about_license"))
    18501837
    1851             if not pygobject:
    1852                 gtk.about_dialog_set_url_hook(self._showAboutURL, None)
    1853 
    18541838            self._aboutDialog = dialog
    18551839
  • src/mlx/gui/pirep.py

    r986 r994  
    7171        self.show_all()
    7272
    73         if pygobject:
    74             styleContext = self.get_style_context()
    75             color = styleContext.get_background_color(gtk.StateFlags.NORMAL)
    76             heading.override_background_color(0, color)
    77         else:
    78             style = self.rc_get_style()
    79             heading.modify_base(0, style.bg[0])
     73        styleContext = self.get_style_context()
     74        color = styleContext.get_background_color(gtk.StateFlags.NORMAL)
     75        heading.override_background_color(0, color)
    8076
    8177
     
    12251221        # FIXME: quite the same as the SID combo box in
    12261222        # the flight wizard
    1227         if pygobject:
    1228             self._sid = gtk.ComboBox.new_with_model_and_entry(comboModel)
    1229         else:
    1230             self._sid = gtk.ComboBoxEntry(comboModel)
     1223        self._sid = gtk.ComboBox.new_with_model_and_entry(comboModel)
    12311224
    12321225        self._sid.set_entry_text_column(0)
     
    12601253
    12611254        # FIXME: quite the same as in the wizard
    1262         if pygobject:
    1263             self._star = gtk.ComboBox.new_with_model_and_entry(comboModel)
    1264         else:
    1265             self._star = gtk.ComboBoxEntry(comboModel)
     1255        self._star = gtk.ComboBox.new_with_model_and_entry(comboModel)
    12661256
    12671257        self._star.set_entry_text_column(0)
     
    12751265
    12761266        # FIXME: quite the same as in the wizard
    1277         if pygobject:
    1278             self._transition = gtk.ComboBox.new_with_model_and_entry(comboModel)
    1279         else:
    1280             self._transition = gtk.ComboBoxEntry(comboModel)
     1267        self._transition = gtk.ComboBox.new_with_model_and_entry(comboModel)
    12811268
    12821269        self._transition.set_entry_text_column(0)
  • src/mlx/gui/statusbar.py

    r919 r994  
    3030        self._connected = False
    3131       
    32         self.set_shadow_type(gtk.ShadowType.NONE if pygobject
    33                              else gtk.SHADOW_NONE)
     32        self.set_shadow_type(gtk.ShadowType.NONE)
    3433
    3534        frameAlignment = gtk.Alignment(xscale = 1.0, yscale = 1.0)
     
    5554        self._connStateArea.set_tooltip_markup(xstr("statusbar_conn_tooltip"))
    5655
    57         if pygobject:
    58             self._connStateArea.connect("draw", self._drawConnState)
    59         else:
    60             self._connStateArea.connect("expose_event", self._drawConnState)
     56        self._connStateArea.connect("draw", self._drawConnState)
    6157
    6258        alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5)
     
    130126            icon = self._connGreyIcon
    131127
    132         if pygobject:
    133             gdk.cairo_set_source_pixbuf(eventOrContext, icon, 0, 0)
    134             eventOrContext.paint()
    135         else:
    136             gc = connStateArea.get_style().fg_gc[gtk.STATE_NORMAL]
    137             drawable = connStateArea.get_window()
    138             drawable.draw_pixbuf(gc, icon, 0, 0, 0, 0)
     128        gdk.cairo_set_source_pixbuf(eventOrContext, icon, 0, 0)
     129        eventOrContext.paint()
    139130
    140131    def _updateFlightStatus(self):
  • src/mlx/gui/statusicon.py

    r919 r994  
    7474
    7575        if appIndicator:
    76             if pygobject:
    77                 indicator = appindicator.Indicator.new ("mava-logger-x", iconFile,
    78                                                         appindicator.IndicatorCategory.APPLICATION_STATUS)
    79                 indicator.set_status (appindicator.IndicatorStatus.ACTIVE)
    80             else:
    81                 indicator = appindicator.Indicator ("mava-logger-x", iconFile,
    82                                                     appindicator.CATEGORY_APPLICATION_STATUS)
    83                 indicator.set_status (appindicator.STATUS_ACTIVE)
     76            indicator = appindicator.Indicator.new ("mava-logger-x", iconFile,
     77                                                    appindicator.IndicatorCategory.APPLICATION_STATUS)
     78            indicator.set_status (appindicator.IndicatorStatus.ACTIVE)
    8479
    8580            indicator.set_menu(menu)
     
    127122        """Hide and destroy the status icon."""
    128123        if appIndicator:
    129             if pygobject:
    130                 self._indicator.set_status(appindicator.IndicatorStatus.PASSIVE)
    131             else:
    132                 self._indicator.set_status(appindicator.STATUS_PASSIVE)
     124            self._indicator.set_status(appindicator.IndicatorStatus.PASSIVE)
    133125        else:
    134126            self._statusIcon.set_visible(False)
  • src/mlx/gui/timetable.py

    r927 r994  
    107107
    108108        # FIXME: these should be constants in common.py
    109         scrolledWindow.set_policy(gtk.PolicyType.AUTOMATIC if pygobject
    110                                   else gtk.POLICY_AUTOMATIC,
    111                                   gtk.PolicyType.AUTOMATIC if pygobject
    112                                   else gtk.POLICY_AUTOMATIC)
    113         scrolledWindow.set_shadow_type(gtk.ShadowType.IN if pygobject
    114                                        else gtk.SHADOW_IN)
     109        scrolledWindow.set_policy(gtk.PolicyType.AUTOMATIC,
     110                                  gtk.PolicyType.AUTOMATIC)
     111        scrolledWindow.set_shadow_type(gtk.ShadowType.IN)
    115112
    116113        super(Timetable, self).__init__(xalign = 0.5, yalign = 0.0,
     
    191188            self._popupMenu = self._popupMenuProducer()
    192189        menu = self._popupMenu
    193         if pygobject:
    194             menu.popup(None, None, None, None, event.button, event.time)
    195         else:
    196             menu.popup(None, None, None, event.button, event.time)
     190        menu.popup(None, None, None, None, event.button, event.time)
    197191
    198192    def _selectionChanged(self, selection):
  • src/mlx/gui/update.py

    r755 r994  
    5555        window.connect("delete-event", lambda a, b: True)
    5656        window.set_deletable(False)
    57         window.set_position(gtk.WindowPosition.CENTER_ON_PARENT if pygobject
    58                             else gtk.WIN_POS_CENTER_ON_PARENT)
     57        window.set_position(gtk.WindowPosition.CENTER_ON_PARENT)
    5958
    6059        mainAlignment = gtk.Alignment(xscale = 1.0)
     
    8281            gtk.Dialog(WINDOW_TITLE_BASE + " " + xstr("update_title"),
    8382                       parentWindow,
    84                        gtk.DialogFlags.MODAL if pygobject else gtk.DIALOG_MODAL)
     83                       gtk.DialogFlags.MODAL)
    8584        sudoDialog.add_button(xstr("button_cancel"), 0)
    8685        sudoDialog.add_button(xstr("button_ok"), 1)
     
    9190
    9291        infoLabel = gtk.Label(xstr("update_needsudo"))
    93         infoLabel.set_justify(gtk.Justification.CENTER if pygobject
    94                               else gtk.JUSTIFY_CENTER)
     92        infoLabel.set_justify(gtk.Justification.CENTER)
    9593        infoLabelAlignment.add(infoLabel)
    9694        sudoDialog.vbox.pack_start(infoLabelAlignment, True, True, 4)
    9795
    98         sudoDialog.set_position(gtk.WindowPosition.CENTER_ON_PARENT if pygobject
    99                                 else gtk.WIN_POS_CENTER_ON_PARENT)
     96        sudoDialog.set_position(gtk.WindowPosition.CENTER_ON_PARENT)
    10097
    10198    def __init__(self, gui, programDirectory, updateURL, parentWindow):
  • src/mlx/gui/weighthelp.py

    r303 r994  
    7272        label.set_use_markup(True)
    7373        # FIXME: should be a constant in common
    74         label.set_justify(gtk.Justification.CENTER if pygobject
    75                           else gtk.JUSTIFY_CENTER)       
     74        label.set_justify(gtk.Justification.CENTER)
    7675        alignment.add(label)
    7776        table.attach(alignment, 1, 2, 0, 1)
     
    8584        button.connect("clicked", self._fsButtonClicked)
    8685        label = button.get_child()
    87         label.set_justify(gtk.Justification.CENTER if pygobject
    88                           else gtk.JUSTIFY_CENTER)       
     86        label.set_justify(gtk.Justification.CENTER)
    8987        alignment.add(button)
    9088        table.attach(alignment, 3, 4, 0, 1)
Note: See TracChangeset for help on using the changeset viewer.