Ignore:
Timestamp:
05/04/12 17:53:57 (13 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

Added the handling of the PIREP directory preference

Location:
src/mlx/gui
Files:
2 edited

Legend:

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

    r144 r149  
    2929    RESPONSETYPE_ACCEPT = gtk.RESPONSE_ACCEPT
    3030    RESPONSETYPE_REJECT = gtk.RESPONSE_REJECT
     31    RESPONSETYPE_CANCEL = gtk.RESPONSE_CANCEL
    3132    ACCEL_VISIBLE = gtk.ACCEL_VISIBLE
    3233    CONTROL_MASK = gdk.CONTROL_MASK
     
    4344
    4445    SPIN_USER_DEFINED = gtk.SPIN_USER_DEFINED
     46
     47    FILE_CHOOSER_ACTION_SELECT_FOLDER = gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER
    4548
    4649    def text2unicode(text):
     
    6568    RESPONSETYPE_ACCEPT = gtk.ResponseType.ACCEPT
    6669    RESPONSETYPE_REJECT = gtk.ResponseType.REJECT
     70    RESPONSETYPE_CANCEL = gtk.ResponseType.CANCEL
    6771    ACCEL_VISIBLE = gtk.AccelFlags.VISIBLE
    6872    CONTROL_MASK = gdk.ModifierType.CONTROL_MASK
     
    7983
    8084    SPIN_USER_DEFINED = gtk.SpinType.USER_DEFINED
     85
     86    FILE_CHOOSER_ACTION_SELECT_FOLDER = gtk.FileChooserAction.SELECT_FOLDER
    8187
    8288    import codecs
  • src/mlx/gui/prefs.py

    r148 r149  
    7373        self._syncFSTime.set_active(config.syncFSTime)
    7474
     75        pirepDirectory = config.pirepDirectory
     76        self._pirepDirectory.set_text("" if pirepDirectory is None
     77                                      else pirepDirectory)
     78
    7579        for messageType in const.messageTypes:
    7680            level = config.getMessageTypeLevel(messageType)
     
    98102        config.flareTimeFromFS = self._flareTimeFromFS.get_active()
    99103        config.syncFSTime = self._syncFSTime.get_active()
     104        config.pirepDirectory = self._pirepDirectory.get_text()
    100105
    101106        for messageType in const.messageTypes:
     
    117122        """Build the page for the general settings."""
    118123        mainAlignment = gtk.Alignment(xalign = 0.0, yalign = 0.0,
    119                                       xscale = 0.0, yscale = 0.0)
    120         mainAlignment.set_padding(padding_top = 16, padding_bottom = 32,
    121                                   padding_left = 4, padding_right = 48)
     124                                      xscale = 1.0, yscale = 0.0)
     125        mainAlignment.set_padding(padding_top = 16, padding_bottom = 8,
     126                                  padding_left = 4, padding_right = 4)
    122127        mainBox = gtk.VBox()
    123128        mainAlignment.add(mainBox)
     
    174179        self._syncFSTime.set_tooltip_text(xstr("prefs_syncFSTime_tooltip"))
    175180        mainBox.pack_start(self._syncFSTime, False, False, 4)
    176                                        
     181
     182        pirepBox = gtk.HBox()
     183        mainBox.pack_start(pirepBox, False, False, 4)
     184
     185        label = gtk.Label(xstr("prefs_pirepDirectory"))
     186        label.set_use_underline(True)
     187        pirepBox.pack_start(label, False, False, 4)
     188
     189        self._pirepDirectory = gtk.Entry()
     190        self._pirepDirectory.set_tooltip_text(xstr("prefs_pirepDirectory_tooltip"))
     191        label.set_mnemonic_widget(self._pirepDirectory)
     192        pirepBox.pack_start(self._pirepDirectory, True, True, 4)
     193
     194        self._pirepDirectoryButton = gtk.Button(xstr("button_browse"))
     195        self._pirepDirectoryButton.connect("clicked",
     196                                           self._pirepDirectoryButtonClicked)
     197        pirepBox.pack_start(self._pirepDirectoryButton, False, False, 4)
     198       
    177199        return mainAlignment
    178200
     
    209231            dialog.hide()
    210232            self._warnedRestartNeeded = True
    211 
     233       
     234    def _pirepDirectoryButtonClicked(self, button):
     235        """Called when the PIREP directory button is clicked."""
     236        dialog = gtk.FileChooserDialog(title = WINDOW_TITLE_BASE + " - " +
     237                                       xstr("prefs_pirepDirectory_browser_title"),
     238                                       action = FILE_CHOOSER_ACTION_SELECT_FOLDER,
     239                                       buttons = (gtk.STOCK_CANCEL, RESPONSETYPE_CANCEL,
     240                                                  gtk.STOCK_OK, RESPONSETYPE_OK))
     241
     242        directory = self._pirepDirectory.get_text()
     243        if directory:
     244            dialog.select_filename(directory)
     245       
     246        result = dialog.run()
     247        dialog.hide()
     248
     249        if result==RESPONSETYPE_OK:
     250            self._pirepDirectory.set_text(dialog.get_filename())
     251       
    212252    def _buildMessages(self):
    213253        """Build the page for the message settings."""
     
    292332
    293333        mainAlignment = gtk.Alignment(xalign = 0.0, yalign = 0.0,
    294                                       xscale = 0.0, yscale = 0.0)
    295         mainAlignment.set_padding(padding_top = 16, padding_bottom = 32,
    296                                   padding_left = 4, padding_right = 48)
     334                                      xscale = 1.0, yscale = 0.0)
     335        mainAlignment.set_padding(padding_top = 16, padding_bottom = 8,
     336                                  padding_left = 4, padding_right = 4)
    297337        mainBox = gtk.VBox()
    298338        mainAlignment.add(mainBox)
     
    318358        self._updateURL.set_tooltip_text(xstr("prefs_update_url_tooltip"))
    319359        self._updateURL.connect("changed", self._updateURLChanged)
    320         updateURLBox.pack_start(self._updateURL, False, False, 4)
     360        updateURLBox.pack_start(self._updateURL, True, True, 4)
    321361
    322362        return mainAlignment
     
    350390        """Called when the update URL is changed."""
    351391        self._setOKButtonSensitivity()
    352        
    353            
Note: See TracChangeset for help on using the changeset viewer.