Changeset 149:aab353620d1c


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

Added the handling of the PIREP directory preference

Location:
src/mlx
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/config.py

    r148 r149  
    4242        self._flareTimeFromFS = False
    4343        self._syncFSTime = False
     44
     45        self._pirepDirectory = None
    4446       
    4547        self._autoUpdate = True       
     
    160162        if syncFSTime!=self._syncFSTime:
    161163            self._syncFSTime = syncFSTime
     164            self._modified = True
     165
     166    @property
     167    def pirepDirectory(self):
     168        """Get the directory offered by default when saving a PIREP."""
     169        return self._pirepDirectory
     170
     171    @pirepDirectory.setter
     172    def pirepDirectory(self, pirepDirectory):
     173        """Get the directory offered by default when saving a PIREP."""
     174        if pirepDirectory!=self._pirepDirectory and \
     175           (pirepDirectory!="" or self._pirepDirectory is not None):
     176            self._pirepDirectory = None if pirepDirectory=="" \
     177                                   else pirepDirectory
    162178            self._modified = True
    163179
     
    231247                                            "syncFSTime",
    232248                                            False)
     249        self._pirepDirectory = self._get(config, "general",
     250                                         "pirepDirectory", None)
    233251
    234252        self._messageTypeLevels = {}
     
    269287        config.set("general", "syncFSTime",
    270288                   "yes" if self._syncFSTime else "no")
     289
     290        if self._pirepDirectory is not None:
     291            config.set("general", "pirepDirectory", self._pirepDirectory)
    271292
    272293        config.add_section(Config._messageTypesSection)
  • 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            
  • src/mlx/i18n.py

    r148 r149  
    128128        self.add("button_yes", "_Yes")
    129129        self.add("button_no", "_No")
     130        self.add("button_browse", "Browse...")
    130131       
    131132        self.add("menu_file", "File")
     
    621622                 "If this is checked the flight simulator's internal clock "
    622623                 "will always be synchronized to the computer's clock.")
     624        self.add("prefs_pirepDirectory",
     625                 "_PIREP directory:")
     626        self.add("prefs_pirepDirectory_tooltip",
     627                 "The directory that will be offered by default when "
     628                 "saving a PIREP.")
     629        self.add("prefs_pirepDirectory_browser_title",
     630                 "Select PIREP directory")
    623631        self.add("prefs_update_auto", "Update the program auto_matically")
    624632        self.add("prefs_update_auto_tooltip",
     
    671679        self.add("button_yes", "_Igen")
    672680        self.add("button_no", "_Nem")
     681        self.add("button_browse", "Keresés...")
    673682       
    674683        self.add("menu_file", "Fájl")
     
    11741183                 "Ha ez bejelölöd, a szimulátor belső óráját a program "
    11751184                 "szinkronban tartja a számítógép órájával.")
     1185        self.add("prefs_pirepDirectory",
     1186                 "_PIREP-ek könyvtára:")
     1187        self.add("prefs_pirepDirectory_tooltip",
     1188                 "Az itt megadott könyvtárt ajánlja majd fel a program "
     1189                 "a PIREP-ek mentésekor.")
     1190        self.add("prefs_pirepDirectory_browser_title",
     1191                 "Válaszd ki a PIREP-ek könyvtárát")
    11761192        self.add("prefs_update_auto",
    11771193                 "Frissítsd a programot _automatikusan")
Note: See TracChangeset for help on using the changeset viewer.