Ignore:
Timestamp:
02/20/13 20:17:38 (12 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

The basic logic of the delay codes table works (re #154)

Location:
src/mlx/gui
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/gui/delaycodes.py

    r433 r435  
    3737    class DelayCodeTableBase(gtk.VBox, gtk.Scrollable):
    3838        """PyGObject-specific base class for the delay code table."""
    39 
    40             # if alloc is not None:
    41             #     import gi.repository.cairo
    42             #     allocation1 = gi.repository.cairo.RectangleInt()
    43             #     allocation1.x = allocation.x
    44             #     allocation1.y = allocation.y
    45             #     allocation1.width = allocation.width
    46             #     allocation1.height = height = alloc[3] - allocation.y
    47             #     allocation = allocation1
    48 
    49 
    50 
    5139        __gproperties__ = {
    5240            "vscroll-policy" : ( gtk.ScrollablePolicy,
     
    112100            elif prop.name=="hadjustment":
    113101                self._viewport.set_hadjustment(value)
     102                self._treeView.set_hadjustment(value)
    114103            else:
    115104                raise AttributeError("mlx.gui.delaycodes.DelayCodeTableBase: property %s is not handled in do_set_property" %
    116105                                     (prop.name,))
     106
     107        def setStyle(self):
     108            """Set the style of the event box from the treeview."""
     109
     110    class Alignment(gtk.Alignment):
     111        """An alignment that remembers the width it was given."""
     112        def __init__(self, xalign = 0.0, yalign=0.0,
     113                     xscale = 0.0, yscale = 0.0 ):
     114            """Construct the alignment."""
     115            super(Alignment, self).__init__(xalign = xalign, yalign = yalign,
     116                                            xscale = xscale, yscale = yscale)
     117            self.allocatedWidth = 0
     118
     119        def do_size_allocate(self, allocation):
     120            """Called with the new size allocation."""
     121            self.allocatedWidth = allocation.width
     122            gtk.Alignment.do_size_allocate(self, allocation)
    117123
    118124#------------------------------------------------------------------------------
     
    146152            self._viewport.set_hadjustment(hAdjustment)
    147153            self._viewport.set_vadjustment(vAdjustment)
     154            self._treeView.set_hadjustment(hAdjustment)
    148155
    149156        def _do_size_allocate(self, widget, allocation):
     
    152159            Calls allocate_column_sizes()."""
    153160            self.allocate_column_sizes(allocation)
     161
     162        def setStyle(self):
     163            """Set the style of the event box from the treeview."""
     164            style = self._treeView.rc_get_style()
     165            self._eventBox.modify_bg(0, style.bg[2])
     166            self._eventBox.modify_fg(0, style.fg[2])
     167
     168
     169    class Alignment(gtk.Alignment):
     170        """An alignment that remembers the width it was given."""
     171        def __init__(self, xalign = 0.0, yalign=0.0,
     172                     xscale = 0.0, yscale = 0.0 ):
     173            """Construct the alignment."""
     174            super(Alignment, self).__init__(xalign = xalign, yalign = yalign,
     175                                            xscale = xscale, yscale = yscale)
     176            self.allocatedWidth = 0
     177            self.connect("size-allocate", self._do_size_allocate)
     178
     179        def _do_size_allocate(self, widget, allocation):
     180            """Called with the new size allocation."""
     181            self.allocatedWidth = allocation.width
     182
     183#------------------------------------------------------------------------------
     184
     185CAPTION = 1
     186
     187DELAYCODE = 2
     188
     189_data = ( ["Num", "Code", "Reason", "Description"],
     190          [ (CAPTION, "Others"),
     191            (DELAYCODE, ("      6", "OA  ", "NO GATES/STAND AVAILABLE",
     192                         "Due to own airline activity")),
     193            (DELAYCODE, ("9", "SG", "SCHEDULED GROUND TIME",
     194                         "Planned turnaround time less than declared minimum")),
     195            (CAPTION, "Passenger and baggage"),
     196            (DELAYCODE, ("11", "PD", "LATE CHECK-IN",
     197                         "Check-in reopened for late passengers")),
     198            (DELAYCODE, ("12", "PL", "LATE CHECK-IN",
     199                         "Check-in not completed by flight closure time")),
     200            (DELAYCODE, ("13", "PE", "CHECK-IN ERROR",
     201                         "Error with passenger or baggage details")) ] )
    154202
    155203#------------------------------------------------------------------------------
     
    161209        super(DelayCodeTable, self).__init__()
    162210
    163         self._listStore = gtk.ListStore(str, str, str, str)
     211        (headers, rows) = _data
     212        numColumns = len(headers) + 1
     213        numRows = len(rows)
     214
     215        self._listStore = gtk.ListStore(str, str)
    164216        self._treeView = gtk.TreeView(self._listStore)
    165         column = gtk.TreeViewColumn("IATA", gtk.CellRendererText())
     217        self._treeView.set_rules_hint(True)
     218
     219        column = gtk.TreeViewColumn("", gtk.CellRendererText())
    166220        column.set_sizing(TREE_VIEW_COLUMN_FIXED)
    167221        self._treeView.append_column(column)
    168         column = gtk.TreeViewColumn("Description", gtk.CellRendererText())
    169         column.set_sizing(TREE_VIEW_COLUMN_FIXED)
    170         self._treeView.append_column(column)
     222
     223        for header in headers:
     224            column = gtk.TreeViewColumn(header, gtk.CellRendererText())
     225            column.set_sizing(TREE_VIEW_COLUMN_FIXED)
     226            self._treeView.append_column(column)
    171227
    172228        self.pack_start(self._treeView, False, False, 0)
    173229
    174         self._table = gtk.Table(10, 2)
    175         for i in range(0, 10):
    176             self._table.attach(gtk.Label("ZZZ" + `i`), 0, 1, i, i+1)
    177             self._table.attach(gtk.Label("AAA" + `i`), 1, 2, i, i+1)
     230        self._alignments = []
     231
     232        self._eventBox = gtk.EventBox()
     233
     234        self._table = gtk.Table(numRows, numColumns)
     235        self._table.set_homogeneous(False)
     236        self._table.set_col_spacings(16)
     237        self._table.set_row_spacings(4)
     238
     239        firstDelayCodeRow = True
     240        for i in range(0, numRows):
     241            (type, elements) = rows[i]
     242            if type==CAPTION:
     243                alignment = gtk.Alignment(xalign = 0.0, yalign = 0.5,
     244                                          xscale = 1.0)
     245                label = gtk.Label("<b>" + elements + "</b>")
     246                label.set_use_markup(True)
     247                label.set_alignment(0.0, 0.5)
     248                alignment.add(label)
     249                self._table.attach(alignment, 1, numColumns, i, i+1)
     250                self._table.set_row_spacing(i, 8)
     251            elif type==DELAYCODE:
     252                alignment = Alignment(xalign = 0.5, yalign = 0.5, xscale = 1.0)
     253                alignment.add(gtk.CheckButton())
     254                self._table.attach(alignment, 0, 1, i, i+1)
     255                if firstDelayCodeRow:
     256                    self._alignments.append(alignment)
     257
     258                for j in range(0, len(elements)):
     259                    label = gtk.Label(elements[j])
     260                    label.set_alignment(1.0 if j==0 else 0.0, 0.5)
     261                    alignment = Alignment(xalign = 0.5, yalign = 0.5,
     262                                          xscale = 1.0)
     263                    alignment.add(label)
     264                    self._table.attach(alignment, j+1, j+2, i, i+1)
     265                    if firstDelayCodeRow:
     266                        self._alignments.append(alignment)
     267                firstDelayCodeRow = False
    178268
    179269        self._viewport = self._createViewport()
    180         self._viewport.add(self._table)
     270        self._eventBox.add(self._table)
     271        self._viewport.add(self._eventBox)
    181272        self._viewport.set_shadow_type(SHADOW_NONE)
    182273
     
    189280        if allocation.width!=self._previousWidth:
    190281            self._previousWidth = allocation.width
    191             column0 = self._treeView.get_column(0)
    192             column0.set_fixed_width(allocation.width/2)
    193             column1 = self._treeView.get_column(1)
    194             column1.set_fixed_width(allocation.width/2)
    195 
    196 #------------------------------------------------------------------------------
     282            index = 0
     283            for alignment in self._alignments:
     284                column = self._treeView.get_column(index)
     285                width = alignment.allocatedWidth + (8 if index==0 else 16)
     286                column.set_fixed_width(width)
     287                index += 1
     288
     289
     290#------------------------------------------------------------------------------
  • src/mlx/gui/flight.py

    r413 r435  
    368368    def _loginClicked(self, button):
    369369        """Called when the login button was clicked."""
    370         print "mlx.flight.LoginPage: logged in"
     370        print "mlx.flight.LoginPage: logging in"
    371371        self._wizard.login(self._handleLoginResult,
    372372                           self._pilotID.get_text(),
  • src/mlx/gui/info.py

    r434 r435  
    168168        self._flightDefects.set_sensitive(True)
    169169        self._delayWindow.set_sensitive(True)
     170        self._delayTable.setStyle()
    170171
    171172    def disable(self):
     
    174175        self._flightDefects.set_sensitive(False)
    175176        self._delayWindow.set_sensitive(False)
     177        self._delayTable.setStyle()
    176178
    177179    def reset(self):
Note: See TracChangeset for help on using the changeset viewer.