]> sigrok.org Git - pulseview.git/blobdiff - contrib/pulseview_cross.nsi.in
Installer: Force icon cache refresh
[pulseview.git] / contrib / pulseview_cross.nsi.in
index 576cfca63a527bebcc15d3e60f576dffae8217ee..fe6b7736787cc83a5f3a6122bb623407e652973c 100644 (file)
@@ -14,8 +14,7 @@
 ## GNU General Public License for more details.
 ##
 ## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+## along with this program; if not, see <http://www.gnu.org/licenses/>.
 ##
 
 #
@@ -31,6 +30,9 @@
 # Include the "Modern UI" header, which gives us the usual Windows look-n-feel.
 !include "MUI2.nsh"
 
+# Include the file association header so that we can register file extensions.
+!include "FileAssociation.nsh"
+
 
 # --- Global stuff ------------------------------------------------------------
 
@@ -74,6 +76,20 @@ RequestExecutionLevel admin
 # Change this to where-ever you installed libsigrok.a and so on.
 !define CROSS "@CMAKE_INSTALL_PREFIX@"
 
+# Defines for WinAPI SHChangeNotify call.
+!define SHCNE_ASSOCCHANGED 0x8000000
+!define SHCNF_IDLIST 0
+
+
+# --- Functions ---------------------------------------------------------------
+
+Function register_sr_files
+       ${registerExtension} "$INSTDIR\pulseview.exe" ".sr" "sigrok session file"
+
+       # Force Windows to update the icon cache so that the icon for .sr files shows up.
+       System::Call 'Shell32::SHChangeNotify(i ${SHCNE_ASSOCCHANGED}, i ${SHCNF_IDLIST}, i 0, i 0)'
+FunctionEnd
+
 
 # --- MUI pages ---------------------------------------------------------------
 
@@ -92,6 +108,14 @@ RequestExecutionLevel admin
 # Perform the actual installation, i.e. install the files.
 !insertmacro MUI_PAGE_INSTFILES
 
+# Insert the "Show Readme" button in the finish dialog. We repurpose it for
+# registering the .sr file extension. This way, we don't need to add in-depth
+# modifications to the finish page.
+!define MUI_FINISHPAGE_SHOWREADME ""
+!define MUI_FINISHPAGE_SHOWREADME_CHECKED
+!define MUI_FINISHPAGE_SHOWREADME_TEXT "Register .sr files with PulseView"
+!define MUI_FINISHPAGE_SHOWREADME_FUNCTION register_sr_files
+
 # Show a final "We're done, click Finish to close this wizard" message.
 !insertmacro MUI_PAGE_FINISH
 
@@ -129,16 +153,16 @@ Section "PulseView (required)" Section1
        File "${CROSS}/zadig_xp.exe"
 
        # Python
-       File "${CROSS}/python32.dll"
-       File "${CROSS}/python32.zip"
+       File "${CROSS}/python34.dll"
+       File "${CROSS}/python34.zip"
+
+       SetOutPath "$INSTDIR\share"
 
        # Protocol decoders.
-       SetOutPath "$INSTDIR\decoders"
-       File /r /x "__pycache__" "${CROSS}/share/libsigrokdecode/decoders/*"
+       File /r /x "__pycache__" /x "*.pyc" "${CROSS}/share/libsigrokdecode"
 
        # Firmware files.
-       SetOutPath "$INSTDIR\firmware"
-       File /r "${CROSS}/share/sigrok-firmware/*"
+       File /r "${CROSS}/share/sigrok-firmware"
 
        # Example *.sr files.
        SetOutPath "$INSTDIR\examples"
@@ -211,22 +235,21 @@ Section "Uninstall"
        Delete "$INSTDIR\pulseview.exe"
        Delete "$INSTDIR\zadig.exe"
        Delete "$INSTDIR\zadig_xp.exe"
-       Delete "$INSTDIR\python32.dll"
-       Delete "$INSTDIR\python32.zip"
+       Delete "$INSTDIR\python34.dll"
+       Delete "$INSTDIR\python34.zip"
 
-       # Delete all decoders and everything else in decoders/.
+       # Delete all decoders and everything else in libsigrokdecode/.
        # There could be *.pyc files or __pycache__ subdirs and so on.
-       RMDir /r "$INSTDIR\decoders\*"
+       RMDir /r "$INSTDIR\share\libsigrokdecode"
 
        # Delete the firmware files.
-       RMDir /r "$INSTDIR\firmware\*"
+       RMDir /r "$INSTDIR\share\sigrok-firmware"
 
        # Delete the example *.sr files.
        RMDir /r "$INSTDIR\examples\*"
 
        # Delete the install directory and its sub-directories.
-       RMDir "$INSTDIR\decoders"
-       RMDir "$INSTDIR\firmware"
+       RMDir "$INSTDIR\share"
        RMDir "$INSTDIR\examples"
        RMDir "$INSTDIR"
 
@@ -243,6 +266,9 @@ Section "Uninstall"
        # Delete the registry key(s).
        DeleteRegKey HKLM "${REGSTR}"
 
+       # Unregister any previously registered file extension(s).
+       ${unregisterExtension} ".sr" "sigrok session file"
+
 SectionEnd