Changeset 373:cf2b6b8a3973


Ignore:
Timestamp:
12/18/12 10:08:43 (11 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
hg-Phase:
(<MercurialRepository 1 'hg:/home/ivaradi/mlx/hg' '/'>, 'public')
Message:

Added support for a secondary instance (#157)

Files:
8 edited

Legend:

Unmodified
Added
Removed
  • locale/en/mlx.po

    r349 r373  
    1212"Content-Type: text/plain; charset=utf-8\n"
    1313"Content-Transfer-Encoding: 8bit\n"
     14
     15msgid "secondary"
     16msgstr "Secondary"
    1417
    1518msgid "aircraft_b736"
  • locale/hu/mlx.po

    r349 r373  
    1313"Content-Transfer-Encoding: 8bit\n"
    1414
     15msgid "secondary"
     16msgstr "Másodlagos"
     17
    1518msgid "aircraft_b736"
    1619msgstr "Boeing 737-600"
  • mlx.nsi

    r28 r373  
    55
    66  !include "MUI.nsh"
     7  !include "nsDialogs.nsh"
     8  !include "TextFunc.nsh"
    79  !include "mlx-common.nsh"
    810
    911;--------------------------------
    1012;General
     13
     14  Var ApplicationName
     15
     16  Function .onInit
     17    StrCpy $ApplicationName "Mava Logger X"
     18  FunctionEnd
    1119
    1220  ;Name and file
     
    1725  ;Default installation folder
    1826  InstallDir "$PROGRAMFILES\MAVA Logger X"
    19  
    20   ;Get installation folder from registry if available
    21   InstallDirRegKey HKCU "Software\MAVA Logger X" ""
    2227
    2328  ;Vista redirects $SMPROGRAMS to all users without this
     
    2934  Var MUI_TEMP
    3035  Var STARTMENU_FOLDER
     36  Var Variable
     37  Var Secondary
     38  Var Secondary_State
     39  Var LinkName
     40  Var Parameters
    3141
    3242;--------------------------------
     
    4050;Pages
    4151
     52
    4253  !insertmacro MUI_PAGE_LICENSE "license.txt"
     54  Page custom optionsPage ;optionsPageLeave
    4355  !insertmacro MUI_PAGE_COMPONENTS
    4456  !insertmacro MUI_PAGE_DIRECTORY
    4557
    4658  ;Start Menu Folder Page Configuration
    47   !define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU"
    48   !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\MAVA Logger X"
    49   !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
    50  
     59  ;!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU"
     60  ;!define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\MAVA Logger X"
     61  ;!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
     62
    5163  !insertmacro MUI_PAGE_STARTMENU Application $STARTMENU_FOLDER
    5264
    5365  !insertmacro MUI_PAGE_INSTFILES
    54  
     66
    5567  !insertmacro MUI_UNPAGE_CONFIRM
    5668  !insertmacro MUI_UNPAGE_INSTFILES
    57  
     69
     70  Function optionsPage
     71     !insertmacro MUI_HEADER_TEXT "Installation Options" "Choose the options for the installation"
     72
     73     nsDialogs::Create 1018
     74     Pop $Variable
     75
     76     ${If} $Variable == error
     77         Abort
     78     ${Endif}
     79
     80     ${NSD_CreateLabel} 0 0 100% 24u "If you select the option below, the program will be installed in a way that it can be used besides another, already existing installation. Read the manual on how to set up this secondary version to avoid conflicting with the primary one."
     81     Pop $Variable
     82
     83     ${NSD_CreateCheckBox} 12 54 100% 12u "Install as secondary"
     84     Pop $Secondary
     85     ${NSD_SetState} $Secondary $Secondary_State
     86     GetFunctionAddress $Variable onSecondaryClicked
     87     nsDialogs::onClick $Secondary $Variable
     88
     89     nsDialogs::Show
     90  FunctionEnd
     91
     92  Function onSecondaryClicked
     93     Pop $Secondary
     94     ${NSD_GetState} $Secondary $Secondary_State
     95     ${If} $Secondary_State == ${BST_CHECKED}
     96         StrCpy $INSTDIR "$PROGRAMFILES\MAVA Logger X (Secondary)"
     97         StrCpy $STARTMENU_FOLDER "MAVA Logger X (Secondary)"
     98     ${Else}
     99         StrCpy $INSTDIR "$PROGRAMFILES\MAVA Logger X"
     100         StrCpy $STARTMENU_FOLDER "MAVA Logger X"
     101     ${EndIf}
     102  FunctionEnd
     103
    58104;--------------------------------
    59105;Languages
    60  
     106
    61107  !insertmacro MUI_LANGUAGE "English"
    62108
     
    67113
    68114  SetOutPath "$INSTDIR"
    69  
     115
     116  ${If} $Secondary_State == ${BST_CHECKED}
     117    StrCpy $LinkName "MAVA Logger X (Secondary)"
     118    StrCpy $Parameters "secondary"
     119  ${Else}
     120    StrCpy $LinkName "MAVA Logger X"
     121    StrCpy $Parameters ""
     122  ${EndIf}
     123
    70124  ;ADD YOUR OWN FILES HERE...
    71125  File /r dist\*.*
    72126
    73   ;Store installation folder
    74   WriteRegStr HKCU "Software\MAVA Logger X" "" $INSTDIR
    75  
     127  ;Create the uninstaller config file
     128  ${ConfigWrite} "$INSTDIR\Uninstall.conf" "StartMenuFolder=" "$STARTMENU_FOLDER" $Variable
     129  ${ConfigWrite} "$INSTDIR\Uninstall.conf" "LinkName=" "$LinkName" $Variable
     130
    76131  ;Create uninstaller
     132
    77133  WriteUninstaller "$INSTDIR\Uninstall.exe"
    78134
     
    80136    ;Create shortcuts
    81137    CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER"
    82     CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\MAVA Logger X.lnk" "$INSTDIR\runmlx.exe"
     138    CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\MAVA Logger X.lnk" "$INSTDIR\runmlx.exe" "$Parameters"
    83139    CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
    84     CreateShortCut "$DESKTOP\MAVA Logger X.lnk" "$INSTDIR\runmlx.exe"
     140    CreateShortCut "$DESKTOP\$LinkName.lnk" "$INSTDIR\runmlx.exe" "$Parameters"
    85141  !insertmacro MUI_STARTMENU_WRITE_END
    86142SectionEnd
     
    102158Section "Uninstall"
    103159
     160  ;Read the uninstaller config file
     161  ${ConfigRead} "$INSTDIR\Uninstall.conf" "StartMenuFolder=" $MUI_TEMP
     162  ${ConfigRead} "$INSTDIR\Uninstall.conf" "LinkName=" $LinkName
     163
    104164  RMDir /r "$INSTDIR"
    105165
    106   !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
    107    
    108   Delete "$DESKTOP\MAVA Logger X.lnk"
     166  Delete "$DESKTOP\$LinkName.lnk"
    109167  Delete "$SMPROGRAMS\$MUI_TEMP\MAVA Logger X.lnk"
    110168  Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk"
    111  
     169
    112170  ;Delete empty start menu parent diretories
    113171  StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP"
    114  
     172
    115173  startMenuDeleteLoop:
    116174    ClearErrors
    117175    RMDir $MUI_TEMP
    118176    GetFullPathName $MUI_TEMP "$MUI_TEMP\.."
    119    
     177
    120178    IfErrors startMenuDeleteLoopDone
    121  
     179
    122180    StrCmp $MUI_TEMP $SMPROGRAMS startMenuDeleteLoopDone startMenuDeleteLoop
    123181  startMenuDeleteLoopDone:
    124 
    125   DeleteRegKey /ifempty HKCU "Software\MAVA Logger X"
    126182SectionEnd
  • setup.py

    r287 r373  
    3939        data_files.append((os.path.join("library", path),
    4040                           glob(os.path.join(gtkRuntimeDir, path, "*"))))
    41        
     41
    4242        path = os.path.join("share", "locale", "hu", "LC_MESSAGES")
    4343        data_files.append((os.path.join("library", path),
     
    4646        data_files.append((os.path.join("library", path),
    4747                           glob(os.path.join(gtkRuntimeDir, path, "*"))))
    48        
     48
    4949    with open("mlx-common.nsh", "wt") as f:
    5050            print >>f, '!define MLX_VERSION "%s"' % (mlx.const.VERSION)
     
    8181if os.name=="nt":
    8282    mlx.update.buildManifest(os.path.join(scriptdir, "dist"))
     83    with open(os.path.join(scriptdir, "dist", "Uninstall.conf")) as f:
     84        print >> f, "startMenuFolder=MAVA Logger X"
  • src/mlx/config.py

    r298 r373  
    22
    33import const
     4from util import secondaryInstallation
    45
    56import os
    67import sys
     8import traceback
    79import ConfigParser
    810
    911## @package mlx.config
    10 # 
     12#
    1113# The handling of the configuration.
    1214#
     
    2224
    2325configPath = os.path.join(os.path.expanduser("~"),
    24                           "mlx.config" if os.name=="nt" else ".mlxrc")
     26                          "mlx.config" if os.name=="nt" else ".mlxrc") + \
     27                          ("-secondary" if secondaryInstallation else "")
    2528
    2629#-------------------------------------------------------------------------------
     
    5457        """Check if the given hotkey is not equal to the other one."""
    5558        return not self==other
    56        
     59
    5760    def __str__(self):
    5861        """Construct the hotkey to a string."""
     
    6972    # The name of the section of the checklists
    7073    SECTION="checklists"
    71    
     74
    7275    @staticmethod
    7376    def fromConfig(config, aircraftType):
     
    108111        """Determine if the checklist is not equal to the given other one."""
    109112        return not self==other
    110        
     113
    111114    def __len__(self):
    112115        """Get the length of the file list."""
     
    127130    # The name of the section of the approach callouts
    128131    SECTION="callouts"
    129    
     132
    130133    @staticmethod
    131134    def fromConfig(config, aircraftType):
     
    145148                break
    146149
    147         return ApproachCallouts(mapping)   
     150        return ApproachCallouts(mapping)
    148151
    149152    def __init__(self, mapping = None):
     
    211214
    212215    _messageTypesSection = "messageTypes"
    213    
     216
    214217    def __init__(self):
    215218        """Construct the configuration with default values."""
     
    222225        self._hideMinimizedWindow = True
    223226        self._quitOnClose = False
    224         self._onlineGateSystem = True
    225         self._onlineACARS = True
     227        self._onlineGateSystem = not secondaryInstallation
     228        self._onlineACARS = not secondaryInstallation
    226229        self._flareTimeFromFS = False
    227230        self._syncFSTime = False
     
    232235        self._pirepDirectory = None
    233236
    234         self._enableSounds = True
     237        self._enableSounds = not secondaryInstallation
    235238
    236239        self._pilotControlsSounds = True
     
    242245        self._enableChecklists = False
    243246        self._checklistHotkey = Hotkey(ctrl = True, shift = True, key = "0")
    244                
    245         self._autoUpdate = True       
     247
     248        self._autoUpdate = True
    246249        self._updateURL = Config.DEFAULT_UPDATE_URL
     250        if secondaryInstallation:
     251            self._updateURL += "/exp"
    247252
    248253        self._messageTypeLevels = {}
     
    253258            self._checklists[aircraftType] = Checklist()
    254259            self._approachCallouts[aircraftType] = ApproachCallouts()
    255            
     260
    256261        self._modified = False
    257262
     
    315320            self._hideMinimizedWindow = hideMinimizedWindow
    316321            self._modified = True
    317    
     322
    318323    @property
    319324    def quitOnClose(self):
     
    329334            self._quitOnClose = quitOnClose
    330335            self._modified = True
    331    
     336
    332337    @property
    333338    def onlineGateSystem(self):
     
    462467        return level==const.MESSAGELEVEL_FS or \
    463468               level==const.MESSAGELEVEL_BOTH
    464        
     469
    465470    def setMessageTypeLevel(self, messageType, level):
    466471        """Set the level of the given message type."""
     
    482487            self._modified = True
    483488
    484     @property 
     489    @property
    485490    def pilotControlsSounds(self):
    486491        """Get whether the pilot controls the background sounds."""
     
    529534            self._speedbrakeAtTD = speedbrakeAtTD
    530535            self._modified = True
    531        
     536
    532537    @property
    533538    def enableChecklists(self):
     
    600605    def load(self):
    601606        """Load the configuration from its default location."""
    602         config = ConfigParser.RawConfigParser()
    603         config.read(configPath)
     607        try:
     608            config = ConfigParser.RawConfigParser()
     609            config.read(configPath)
     610        except:
     611            traceback.print_exc()
     612            return
    604613
    605614        self._pilotID = self._get(config, "login", "id", "")
     
    615624        self._quitOnClose = self._getBoolean(config, "general",
    616625                                             "quitOnClose", False)
    617        
     626
    618627        self._onlineGateSystem = self._getBoolean(config, "general",
    619628                                                  "onlineGateSystem",
    620                                                   True)
     629                                                  not secondaryInstallation)
    621630        self._onlineACARS = self._getBoolean(config, "general",
    622                                              "onlineACARS", True)
     631                                             "onlineACARS",
     632                                             not secondaryInstallation)
    623633        self._flareTimeFromFS = self._getBoolean(config, "general",
    624634                                                 "flareTimeFromFS",
     
    644654                self._getMessageTypeLevel(config, messageType)
    645655
    646         self._enableSounds = self._getBoolean(config, "sounds",
    647                                               "enable", True)
     656        self._enableSounds = self._getBoolean(config, "sounds", "enable",
     657                                              not secondaryInstallation)
    648658        self._pilotControlsSounds = self._getBoolean(config, "sounds",
    649659                                                     "pilotControls", True)
     
    659669        self._checklistHotkey.set(self._get(config, "sounds",
    660670                                            "checklistHotkey", "CS0"))
    661            
     671
    662672        self._autoUpdate = self._getBoolean(config, "update", "auto", True)
    663673        self._updateURL = self._get(config, "update", "url",
    664                                     Config.DEFAULT_UPDATE_URL)
     674                                    Config.DEFAULT_UPDATE_URL +
     675                                    ("/exp" if secondaryInstallation else ""))
    665676
    666677        for aircraftType in const.aircraftTypes:
     
    714725            if messageType in self._messageTypeLevels:
    715726                option = self._getMessageTypeLevelOptionName(messageType)
    716                 level = self._messageTypeLevels[messageType]               
     727                level = self._messageTypeLevels[messageType]
    717728                config.set(Config._messageTypesSection, option,
    718729                           const.messageLevel2string(level))
     
    733744        config.set("sounds", "checklistHotkey",
    734745                   str(self._checklistHotkey))
    735        
     746
    736747        config.add_section("update")
    737748        config.set("update", "auto",
     
    760771               if config.has_option(section, option) \
    761772               else default
    762    
     773
    763774    def _get(self, config, section, option, default):
    764775        """Get the given option as a string, if found in the given config,
     
    774785            value = config.get(Config._messageTypesSection, option)
    775786            return const.string2messageLevel(value)
     787        elif secondaryInstallation:
     788            return const.MESSAGELEVEL_NONE
    776789        elif messageType in [const.MESSAGETYPE_LOGGER_ERROR,
    777790                             const.MESSAGETYPE_FAULT,
    778791                             const.MESSAGETYPE_NOGO,
    779792                             const.MESSAGETYPE_GATE_SYSTEM,
    780                              const.MESSAGETYPE_HELP]:           
     793                             const.MESSAGETYPE_HELP]:
    781794            return const.MESSAGELEVEL_BOTH
    782795        else:
  • src/mlx/gui/common.py

    r362 r373  
    22import mlx.const as _const
    33from mlx.i18n import xstr
     4
     5from mlx.util import secondaryInstallation
    46
    57import os
     
    262264
    263265WINDOW_TITLE_BASE = PROGRAM_NAME + " " + _const.VERSION
     266if secondaryInstallation:
     267    WINDOW_TITLE_BASE += " (" + xstr("secondary") + ")"
    264268
    265269#------------------------------------------------------------------------------
  • src/mlx/mlx.py

    r298 r373  
    33from i18n import setLanguage
    44from sound import initializeSound
     5from util import secondaryInstallation
    56
    67import os
     
    5152
    5253    instance.close()
    53     os.execv(programPath, args)   
     54    os.execv(programPath, args)
    5455
    5556#--------------------------------------------------------------------------------------
     
    6061
    6162    global instance
    62     instance = SingleInstance("mlx", raiseCallbackWrapper)
     63    instance = SingleInstance("mlx" + ("-secondary" if secondaryInstallation
     64                                       else ""), raiseCallbackWrapper)
    6365    if not instance: return
    6466
     
    6971
    7072    if (len(sys.argv)<=1 or sys.argv[1]!="usedeflang") and config.setupLocale():
    71         restart(["usedeflang"])
     73        restart(["usedeflang"] + (["secondary"] if secondaryInstallation else []))
    7274
    7375    setLanguage(programDirectory, config.getLanguage())
    74    
     76
    7577    from .gui.gui import GUI
    7678    gui = GUI(programDirectory, config)
    77    
     79
    7880    sys.stdout = StdIOHandler(gui)
    7981    sys.stderr = StdIOHandler(gui)
  • src/mlx/util.py

    r298 r373  
    22import math
    33import time
     4import sys
    45
    56#------------------------------------------------------------------------------
     
    2627    - the seconds as an integer
    2728    - 1.0 if the value was non-negative, -1.0 if it was negative."""
    28    
     29
    2930    if degrees<0:
    3031        degrees = -degrees
     
    3233    else:
    3334        mul = 1.0
    34        
     35
    3536    deg = int(degrees)
    3637    min = int((degrees*60.0)%60.0)
     
    125126
    126127    This function calculates the rhumb distance."""
    127    
     128
    128129    latitude1 = math.radians(latitude1)
    129130    longitude1 = math.radians(longitude1)
     
    160161    return "%.0f metres" % (visibility,) if visibility<10000 \
    161162           else "%.1f kilometres" % (visibility/1000.0,)
     163
     164#------------------------------------------------------------------------------
     165
     166secondaryInstallation="secondary" in sys.argv
Note: See TracChangeset for help on using the changeset viewer.