Changeset 1146:0321756c76fe for src


Ignore:
Timestamp:
04/24/24 13:54:14 (7 months ago)
Author:
István Váradi <ivaradi@…>
Branch:
python3
Phase:
public
Message:

Support for delay codes that require explanations (re #386)

File:
1 edited

Legend:

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

    r1035 r1146  
    191191        self._alignments = []
    192192        self._checkButtons = []
     193        self._codesToExplain = []
    193194
    194195        self._eventBox = Gtk.EventBox()
     
    203204
    204205        self._previousWidth = 0
     206
     207    @property
     208    def _delayCodeRows(self):
     209        """Get a list of the row indexes in the delay code data table of
     210        the delay codes that are enabled."""
     211        rows = []
     212
     213        for checkButton in self._checkButtons:
     214            if checkButton.get_active():
     215                rows.append(checkButton.delayCodeRow)
     216
     217        return rows
    205218
    206219    @property
     
    210223
    211224        if self._delayCodeData is not None:
    212             codeExtractor = self._delayCodeData[0]
    213             for checkButton in self._checkButtons:
    214                 if checkButton.get_active():
    215                     codes.append(codeExtractor(checkButton.delayCodeRow))
     225            codeExtractor = self._delayCodeData[0][1]
     226            for row in self._delayCodeRows:
     227                codes.append(codeExtractor(row))
    216228
    217229        return codes
     
    337349    def _delayCodesChanged(self, button):
    338350        """Called when one of the delay codes have changed."""
    339         numDelayCodes = len(self.delayCodes)
     351        delayCodeRows = self._delayCodeRows
     352        numDelayCodes = len(delayCodeRows)
    340353        if numDelayCodes>=4:
    341354            for checkButton in self._checkButtons:
     
    346359                checkButton.set_sensitive(True)
    347360
     361        codeExtractor = self._delayCodeData[0][0]
     362        isExplanationRequired = self._delayCodeData[0][2]
     363        codesToExplain = []
     364        for row in delayCodeRows:
     365            if isExplanationRequired(row):
     366                code = codeExtractor(row)
     367                codesToExplain.append(code)
     368                if code not in self._codesToExplain:
     369                    self._info.addFault("dc_" + code,
     370                                        xstr("info_delay_explain") % (code,))
     371
     372        for code in self._codesToExplain:
     373            if code not in codesToExplain:
     374                self._info.clearFault("dc_" + code)
     375        self._codesToExplain = codesToExplain
     376
    348377        self._info.delayCodesChanged()
    349378
Note: See TracChangeset for help on using the changeset viewer.