Ignore:
Timestamp:
12/22/12 09:05:16 (11 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

Implemented the configuration of automatic PIREP saving (re #163)

File:
1 edited

Legend:

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

    r300 r392  
    2525    # Constant to denote that the status of the Ctrl modifier is changed
    2626    CHANGED_CTRL = 1
    27    
     27
    2828    # Constant to denote that the status of the Shift modifier is changed
    2929    CHANGED_SHIFT = 2
    30    
     30
    3131    # Constant to denote that the value of the key is changed
    3232    CHANGED_KEY = 3
    33    
     33
    3434    def __init__(self, labelText, tooltips):
    3535        """Construct the hotkey widget.
     
    4242        - the shift check box."""
    4343        super(Hotkey, self).__init__()
    44        
     44
    4545        label = gtk.Label(labelText)
    4646        label.set_use_underline(True)
     
    5656        self._ctrl.connect("toggled", self._ctrlToggled)
    5757        self.pack_start(self._ctrl, False, False, 4)
    58            
     58
    5959        self._shift = gtk.CheckButton("Shift")
    6060        self._shift.set_tooltip_text(tooltips[2])
     
    121121            iter = hotkeyModel.get_iter_first()
    122122
    123         self._hotkey.set_active_iter(iter)           
     123        self._hotkey.set_active_iter(iter)
    124124
    125125        self._setting = False
     
    178178        self.add_button(xstr("button_ok"), RESPONSETYPE_ACCEPT)
    179179        self.set_resizable(False)
    180        
     180
    181181        self._gui = gui
    182182        self._settingFromConfig = False
     
    238238        self._syncFSTime.set_active(config.syncFSTime)
    239239        self._usingFS2Crew.set_active(config.usingFS2Crew)
    240        
     240
    241241        self._setSmoothing(self._iasSmoothingEnabled, self._iasSmoothingLength,
    242242                           config.iasSmoothingLength)
     
    247247        self._pirepDirectory.set_text("" if pirepDirectory is None
    248248                                      else pirepDirectory)
     249        self._pirepAutoSave.set_active(config.pirepAutoSave)
     250        if not pirepDirectory:
     251            self._pirepAutoSave.set_sensitive(False)
    249252
    250253        for messageType in const.messageTypes:
     
    263266        self._speedbrakeAtTD.set_active(config.speedbrakeAtTD)
    264267
    265         self._enableChecklists.set_active(config.enableChecklists)       
     268        self._enableChecklists.set_active(config.enableChecklists)
    266269        self._checklistHotkey.set(config.checklistHotkey)
    267270
     
    289292                                                       self._vsSmoothingLength)
    290293        config.pirepDirectory = text2unicode(self._pirepDirectory.get_text())
     294        config.pirepAutoSave = self._pirepAutoSave.get_active()
    291295
    292296        for messageType in const.messageTypes:
     
    324328
    325329        guiBox = self._createFrame(mainBox, xstr("prefs_frame_gui"))
    326        
     330
    327331        languageBox = gtk.HBox()
    328332        guiBox.pack_start(languageBox, False, False, 4)
     
    339343
    340344        self._languageComboBox = languageComboBox = \
    341             gtk.ComboBox(model = self._languageList)                   
     345            gtk.ComboBox(model = self._languageList)
    342346        cell = gtk.CellRendererText()
    343347        languageComboBox.pack_start(cell, True)
     
    362366        guiBox.pack_start(self._quitOnClose, False, False, 4)
    363367
    364         onlineBox = self._createFrame(mainBox, xstr("prefs_frame_online"))       
     368        onlineBox = self._createFrame(mainBox, xstr("prefs_frame_online"))
    365369
    366370        self._onlineGateSystem = gtk.CheckButton(xstr("prefs_onlineGateSystem"))
     
    380384        self._flareTimeFromFS.set_tooltip_text(xstr("prefs_flaretimeFromFS_tooltip"))
    381385        simulatorBox.pack_start(self._flareTimeFromFS, False, False, 4)
    382                                        
     386
    383387        self._syncFSTime = gtk.CheckButton(xstr("prefs_syncFSTime"))
    384388        self._syncFSTime.set_use_underline(True)
     
    390394        self._usingFS2Crew.set_tooltip_text(xstr("prefs_usingFS2Crew_tooltip"))
    391395        simulatorBox.pack_start(self._usingFS2Crew, False, False, 4)
    392        
     396
    393397        (iasSmoothingBox, self._iasSmoothingEnabled,
    394398         self._iasSmoothingLength) = \
     
    412416        self._pirepDirectory = gtk.Entry()
    413417        self._pirepDirectory.set_tooltip_text(xstr("prefs_pirepDirectory_tooltip"))
     418        self._pirepDirectory.connect("changed", self._pirepDirectoryChanged)
    414419        label.set_mnemonic_widget(self._pirepDirectory)
    415420        pirepBox.pack_start(self._pirepDirectory, True, True, 4)
     
    419424                                           self._pirepDirectoryButtonClicked)
    420425        pirepBox.pack_start(self._pirepDirectoryButton, False, False, 4)
    421        
     426
     427        self._pirepAutoSave = gtk.CheckButton(xstr("prefs_pirepAutoSave"))
     428        self._pirepAutoSave.set_use_underline(True)
     429        self._pirepAutoSave.set_tooltip_text(xstr("prefs_pirepAutoSave_tooltip"))
     430        mainBox.pack_start(self._pirepAutoSave, False, False, 0)
     431
    422432        return mainAlignment
    423433
     
    482492
    483493    def _getLanguage(self):
    484         """Get the language selected by the user."""       
     494        """Get the language selected by the user."""
    485495        iter = self._languageComboBox.get_active_iter()
    486496        (lang,) = self._languageList.get(iter, 1)
     
    514524        smoothingEnabled.set_active(smoothing>=2)
    515525        smoothingLength.set_value(abs(smoothing))
    516        
     526
    517527    def _getSmoothing(self, smoothingEnabled, smoothingLength):
    518528        """Get the smoothing value from the given controls.
     
    524534            value *= -1
    525535        return value
    526        
     536
    527537    def _pirepDirectoryButtonClicked(self, button):
    528538        """Called when the PIREP directory button is clicked."""
     
    539549        if directory:
    540550            dialog.select_filename(directory)
    541        
     551
    542552        result = dialog.run()
    543553        dialog.hide()
     
    545555        if result==RESPONSETYPE_OK:
    546556            self._pirepDirectory.set_text(text2unicode(dialog.get_filename()))
    547        
     557
     558    def _pirepDirectoryChanged(self, entry):
     559        """Called when the PIREP directory is changed."""
     560        if self._pirepDirectory.get_text():
     561            self._pirepAutoSave.set_sensitive(True)
     562        else:
     563            self._pirepAutoSave.set_active(False)
     564            self._pirepAutoSave.set_sensitive(False)
     565
    548566    def _buildMessages(self):
    549567        """Build the page for the message settings."""
     
    561579        table.set_homogeneous(False)
    562580        mainBox.pack_start(table, False, False, 4)
    563        
     581
    564582        label = gtk.Label(xstr("prefs_msgs_fs"))
    565583        label.set_justify(JUSTIFY_CENTER)
    566584        label.set_alignment(0.5, 1.0)
    567585        table.attach(label, 1, 2, 0, 1)
    568        
     586
    569587        label = gtk.Label(xstr("prefs_msgs_sound"))
    570588        label.set_justify(JUSTIFY_CENTER)
     
    573591
    574592        self._msgFSCheckButtons = {}
    575         self._msgSoundCheckButtons = {}       
     593        self._msgSoundCheckButtons = {}
    576594        row = 1
    577595        for messageType in const.messageTypes:
     
    589607            table.attach(alignment, 1, 2, row, row+1)
    590608            self._msgFSCheckButtons[messageType] = fsCheckButton
    591            
     609
    592610            soundCheckButton = gtk.CheckButton()
    593611            alignment = gtk.Alignment(xscale = 0.0, yscale = 0.0,
    594612                                      xalign = 0.5, yalign = 0.5)
    595613            alignment.add(soundCheckButton)
    596             table.attach(alignment, 2, 3, row, row+1)           
     614            table.attach(alignment, 2, 3, row, row+1)
    597615            self._msgSoundCheckButtons[messageType] = soundCheckButton
    598616
     
    665683                                    xstr("prefs_sounds_pilotHotkeyCtrl_tooltip"),
    666684                                    xstr("prefs_sounds_pilotHotkeyShift_tooltip")])
    667        
     685
    668686        backgroundBox.pack_start(self._pilotHotkey, False, False, 4)
    669687
     
    672690        self._enableApproachCallouts.set_tooltip_text(xstr("prefs_sounds_approachCallouts_tooltip"))
    673691        backgroundBox.pack_start(self._enableApproachCallouts, False, False, 4)
    674        
     692
    675693        self._speedbrakeAtTD = gtk.CheckButton(xstr("prefs_sounds_speedbrakeAtTD"))
    676694        self._speedbrakeAtTD.set_use_underline(True)
     
    689707        checklistBox = gtk.VBox()
    690708        checklistAlignment.add(checklistBox)
    691        
     709
    692710        self._enableChecklists = gtk.CheckButton(xstr("prefs_sounds_enableChecklists"))
    693711        self._enableChecklists.set_use_underline(True)
     
    774792        self._autoUpdate.set_tooltip_text(xstr("prefs_update_auto_tooltip"))
    775793        self._warnedAutoUpdate = False
    776        
     794
    777795        updateURLBox = gtk.HBox()
    778796        mainBox.pack_start(updateURLBox, False, False, 4)
     
    814832            dialog.hide()
    815833            self._warnedAutoUpdate = True
    816            
     834
    817835    def _updateURLChanged(self, entry):
    818836        """Called when the update URL is changed."""
Note: See TracChangeset for help on using the changeset viewer.