[gimp] Installer: ported install script to Inno Setup 6, add per-user install support



commit d7799efd0d8686b2259e327a481f1cf887d601b5
Author: Jernej Simončič <jernej|s-gitstuff eternallybored org>
Date:   Sat Jun 15 23:55:44 2019 +0200

    Installer: ported install script to Inno Setup 6, add per-user install support
    
    Rewrote file association handling to work both for all users and per-user
    
    (cherry picked from commit fa1d71f714bae94601b66156c615663e5e0e9d85)

 build/windows/installer/32on64.isi         |   6 +-
 build/windows/installer/MessageWithURL.isi |   4 +-
 build/windows/installer/associations.isi   | 353 +++--------------------------
 build/windows/installer/associations.list  |  66 ++++++
 build/windows/installer/compile.bat        |   4 +-
 build/windows/installer/files.isi          |   2 +-
 build/windows/installer/gimp3264.iss       | 166 ++------------
 build/windows/installer/rebootcontinue.isi |   1 -
 build/windows/installer/uninst.isi         |  66 ++++++
 build/windows/installer/utils.isi          |  29 +++
 10 files changed, 229 insertions(+), 468 deletions(-)
---
diff --git a/build/windows/installer/32on64.isi b/build/windows/installer/32on64.isi
index eb70a76b95..827a2a0f77 100644
--- a/build/windows/installer/32on64.isi
+++ b/build/windows/installer/32on64.isi
@@ -1,7 +1,7 @@
 #if 0
 [Files]
 #endif
-//process list of 32bit GIMP files that are installed on x64 (for TWAIN and Python support)
+//process list of 32bit GIMP files that are installed on x64 (for TWAIN support)
 #pragma option -e-
 
 #define protected
@@ -19,11 +19,11 @@
 #sub DoActualWork
        #if Copy(FileLine,Len(FileLine),1)=="\"
                //include whole directory
-Source: "{#SRC_DIR}\{#FileLine}*"; DestDir: "{app}\32\{#Copy(FileLine,1,Len(FileLine)-1)}"; Components: 
gimp32on64; Flags: recursesubdirs restartreplace replacesameversion uninsrestartdelete
+Source: "{#SRC_DIR}\{#FileLine}*"; DestDir: "{app}\32\{#Copy(FileLine,1,Len(FileLine)-1)}"; Components: 
gimp32on64; Flags: recursesubdirs restartreplace replacesameversion uninsrestartdelete ignoreversion
        #else
                //include files from a certain directory
                #define OutputDir Copy(FileLine,1,RPos("\",FileLine)-1)
-Source: "{#SRC_DIR}\{#FileLine}"; DestDir: "{app}\32\{#OutputDir}"; Components: gimp32on64; Flags: 
restartreplace replacesameversion uninsrestartdelete
+Source: "{#SRC_DIR}\{#FileLine}"; DestDir: "{app}\32\{#OutputDir}"; Components: gimp32on64; Flags: 
restartreplace replacesameversion uninsrestartdelete ignoreversion
        #endif
 #endsub
 
diff --git a/build/windows/installer/MessageWithURL.isi b/build/windows/installer/MessageWithURL.isi
index 508faac25c..a9cd49427f 100644
--- a/build/windows/installer/MessageWithURL.isi
+++ b/build/windows/installer/MessageWithURL.isi
@@ -223,7 +223,7 @@ begin
        begin
                Left := ScaleX(MWU_LEFTBORDER);
                Top := ScaleY(MWU_TOPBORDER);
-               Center := False;
+               Center := False; //!!! Inno6
                Stretch := False;
                AutoSize := True;
                Bitmap.Width := GetSystemMetrics(SM_CXICON);
@@ -488,7 +488,7 @@ begin
 
        Message_SetUpButtons(Button, ButtonText, ButtonWidth, DefaultButton, CancelButton, MessageForm);
 
-       MessageForm.Center;
+       //MessageForm.Center; //!!! Inno6
 
        MessageForm.OnKeyUp := @Message_KeyUp; //needed for keyboard access of URL labels
        MessageForm.KeyPreView := True;
diff --git a/build/windows/installer/associations.isi b/build/windows/installer/associations.isi
old mode 100644
new mode 100755
index 71ad4c8691..79b2058baa
--- a/build/windows/installer/associations.isi
+++ b/build/windows/installer/associations.isi
@@ -1,318 +1,39 @@
-#if 0
-//for syntax highlighting
-[Code]
+[Registry]
+#pragma option -e-
+
+#define protected
+
+#define FileHandle
+#define FileLine
+
+#define Line=0
+
+#sub ProcessAssociation
+       #if !defined(Finished)
+               #if Copy(FileLine,1,1)=="#" || FileLine==""
+                       //skip comments and empty lines
+               #else
+                       #pragma message "Processing associations.list: " + FileLine
+;
+Root: HKA; Subkey: "Software\Classes\.{#FileLine}"; ValueType: string; ValueName: ""; ValueData: 
"GIMP2.{#FileLine}"; Flags: uninsdeletevalue
+Root: HKA; Subkey: "Software\Classes\.{#FileLine}\OpenWithProgids"; ValueType: string; ValueName: 
"GIMP2.{#FileLine}"; ValueData: ""; Flags: uninsdeletevalue
+Root: HKA; Subkey: "Software\Classes\GIMP2.{#FileLine}"; ValueType: string; ValueName: ""; ValueData: "GIMP 
{#ICON_VERSION}"; Flags: uninsdeletekey
+Root: HKA; Subkey: "Software\Classes\GIMP2.{#FileLine}\DefaultIcon"; ValueType: string; ValueName: ""; 
ValueData: "{app}\bin\gimp-{#MAJOR}.{#MINOR}.exe,1"
+Root: HKA; Subkey: "Software\Classes\GIMP2.{#FileLine}\shell\open\command"; ValueType: string; ValueName: 
""; ValueData: """{app}\bin\gimp-{#MAJOR}.{#MINOR}.exe"" ""%1"""
+               #endif
+       #endif
+#endsub
+
+#for {FileHandle = FileOpen(AddBackslash(SourcePath)+"associations.list"); \
+  FileHandle && !FileEof(FileHandle); FileLine = FileRead(FileHandle)} \
+  ProcessAssociation
+#if FileHandle
+  #expr FileClose(FileHandle)
 #endif
+;special case for .ico files
+Root: HKA; Subkey: "Software\Classes\.ico"; ValueType: string; ValueName: ""; ValueData: "GIMP2.ico"; Flags: 
uninsdeletevalue
+Root: HKA; Subkey: "Software\Classes\.ico\OpenWithProgids"; ValueType: string; ValueName: "GIMP2.ico"; 
ValueData: ""; Flags: uninsdeletevalue
+Root: HKA; Subkey: "Software\Classes\GIMP2.ico"; ValueType: string; ValueName: ""; ValueData: "GIMP 
{#ICON_VERSION}"; Flags: uninsdeletekey
+Root: HKA; Subkey: "Software\Classes\GIMP2.ico\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: 
"%1"
+Root: HKA; Subkey: "Software\Classes\GIMP2.ico\shell\open\command"; ValueType: string; ValueName: ""; 
ValueData: """{app}\bin\gimp-{#MAJOR}.{#MINOR}.exe"" ""%1"""
 
-//Encode registry keys saved to uninst.inf
-function Encode(pText: String): String;
-begin
-       pText := Replace('%','%25', pText);
-       Result := Replace('\','%5c', pText);
-end;
-
-//reverse encoding done by Encode
-function Decode(pText: String): String;
-var p: Integer;
-       tmp: String;
-begin
-       if Pos('%',pText) = 0 then
-               Result := pText
-       else
-       begin           
-               Result := '';
-               while Length(pText) > 0 do
-               begin
-                       p := Pos('%',pText);
-                       if p = 0 then
-                       begin
-                               Result := Result + pText;
-                               break;
-                       end;
-                       Result := Result + Copy(pText,1,p-1);
-                       tmp := '$' + Copy(pText,p+1,2);
-                       Result := Result + Chr(StrToIntDef(tmp,32));
-                       pText := Copy(pText,p+3,Length(pText));
-               end;
-       end;
-end;
-
-
-function Associations_Write(const pSubKey,pValue,pData: String): Boolean;
-begin
-       Result := RegWriteStringValue(HKCR,pSubKey,pValue,pData)
-       SaveToUninstInf('RegVal:HKCR/'+pSubKey+'\'+Encode(pValue));
-end;
-
-
-function Associations_Read(const pSubKey,pValue: String; var pData: String): Boolean;
-begin
-       Result := RegQueryStringValue(HKCR,pSubKey,pValue,pData)
-end;
-
-
-procedure Association_Fix(const pKey: String);
-begin
-       if RegKeyExists(HKCR,pKey+'\shell\Open with GIMP') then
-       begin
-               if RegDeleteKeyIncludingSubkeys(HKCR,pKey+'\shell\Open with GIMP') then
-                       DebugMsg('Association_Fix','Removed leftover Open with GIMP from ' + pKey)
-               else
-                       DebugMsg('Association_Fix','Failed removing leftover Open with GIMP from ' + pKey)
-       end;
-end;
-
-
-procedure Associations_Create();
-var i,j: Integer;
-       sIconFile: String;
-begin
-
-       for i := 0 to GetArrayLength(Associations.Association) - 1 do
-       begin
-               for j := 0 to GetArrayLength(Associations.Association[i].Extensions) - 1 do
-               begin                   
-
-                       if Associations.Association[i].Selected then //user wants to use the GIMP as default 
program for this type of image
-                       begin
-
-                               DebugMsg('Create associations',Associations.Association[i].Extensions[j]);
-
-                               StatusLabel(CustomMessage('SettingUpAssociations'), 
Associations.Association[i].Description + ' ('
-                                           + Associations.Association[i].Extensions[j]+')');
-
-                               SaveToUninstInf('RegKeyEmpty:HKCR/GIMP-{#ASSOC_VERSION}-'+
-                                               Associations.Association[i].Extensions[0]);
-                               SaveToUninstInf('RegKeyEmpty:HKCR/GIMP-{#ASSOC_VERSION}-'+
-                                               Associations.Association[i].Extensions[0]+'\DefaultIcon');
-                               SaveToUninstInf('RegKeyEmpty:HKCR/GIMP-{#ASSOC_VERSION}-'+
-                                               Associations.Association[i].Extensions[0]+'\shell');
-                               SaveToUninstInf('RegKeyEmpty:HKCR/GIMP-{#ASSOC_VERSION}-'+
-                                               Associations.Association[i].Extensions[0]+'\shell\open');
-                               SaveToUninstInf('RegKeyEmpty:HKCR/GIMP-{#ASSOC_VERSION}-'+
-                                               
Associations.Association[i].Extensions[0]+'\shell\open\command');
-                               
SaveToUninstInf('RegKeyEmpty:HKCR/.'+Associations.Association[i].Extensions[j]);
-
-                               if not 
Associations_Write('GIMP-{#ASSOC_VERSION}-'+Associations.Association[i].Extensions[0],'',
-                                                         Associations.Association[i].Description) then
-                                       continue; //something's very wrong in user's registry if any of these 
continues are called
-
-                               if Associations.Association[i].Extensions[0] <> 'ico' then //special case for 
icons
-                                       sIconFile := 
ExpandConstant('{app}\bin\gimp-{#MAJOR}.{#MINOR}.exe')+',1'
-                               else
-                                       sIconFile := '%1';
-
-                               if not 
Associations_Write('GIMP-{#ASSOC_VERSION}-'+Associations.Association[i].Extensions[0]+'\DefaultIcon',
-                                                         '',sIconFile) then
-                                       continue;
-
-                               if not 
Associations_Write('GIMP-{#ASSOC_VERSION}-'+Associations.Association[i].Extensions[0]+'\shell\open\command',
-                                                         
'','"'+ExpandConstant('{app}\bin\gimp-{#MAJOR}.{#MINOR}.exe')+'" "%1"') then
-                                       continue;
-
-                               if not Associations_Write('.'+Associations.Association[i].Extensions[j],'',
-                                                         
'GIMP-{#ASSOC_VERSION}-'+Associations.Association[i].Extensions[0]) then
-                                       continue;
-
-                       end else //add "Open with GIMP" to another program's association
-                       begin
-
-                               if Associations.Association[i].AssociatedElsewhere <> '' then
-                               begin
-
-                                       DebugMsg('Adding Open with 
GIMP',Associations.Association[i].Extensions[j]);
-
-                                       
SaveToUninstInf('RegKey:HKCR/'+Associations.Association[i].AssociatedElsewhere+
-                                                       '\shell\'+CustomMessage('OpenWithGIMP'));
-
-                                       if not 
Associations_Write(Associations.Association[i].AssociatedElsewhere+'\shell\'+
-                                                                 CustomMessage('OpenWithGIMP'),
-                                                                 '',CustomMessage('OpenWithGimp')) then
-                                               continue;
-
-                                       if not 
Associations_Write(Associations.Association[i].AssociatedElsewhere+'\shell\'+
-                                                                 CustomMessage('OpenWithGIMP')+'\command','',
-                                                                 
'"'+ExpandConstant('{app}\bin\gimp-{#MAJOR}.{#MINOR}.exe')+'" "%1"') then
-                                               continue;
-                               end else
-                               begin
-                                       DebugMsg('Skipping 
association',Associations.Association[i].Extensions[j]);
-                                       //TODO: decide what to do here (user doesn't want to associate file 
type with GIMP, and there's no existing assoc.)
-                               end;
-
-                       end;
-
-               end;
-       end;
-end;
-
-
-procedure Associations_Init();
-var i,j,c,d,iNumAssoc: Integer;
-       sAssociation,sExt,sCheck: String;
-       CmdLineAssoc: TArrayOfString;
-       CmdLine: String;
-begin
-       iNumAssoc := 0;
-       while IniKeyExists('File Associations', IntToStr(iNumAssoc + 1), SetupINI) do
-               iNumAssoc := iNumAssoc + 1;
-
-       DebugMsg('Associations_Init','Found ' + IntToStr(iNumAssoc) + ' associations');
-
-       SetArrayLength(Associations.Association,iNumAssoc);
-
-       CmdLine := ExpandConstant('{param:assoc|}');
-       if CmdLine <> '' then
-       begin
-               DebugMsg('Associations_Init','Associations requested through command-line: ' + CmdLine);
-               Explode(CmdLineAssoc,LowerCase(CmdLine),',');
-       end;
-       
-       for i := 1 to iNumAssoc do
-       begin
-               sAssociation := GetIniString('File Associations',IntToStr(i),'',SetupINI);
-
-               DebugMsg('Associations Init',sAssociation);
-               
-               d := Pos(':',sAssociation);
-               if d = 0 then
-               begin
-                       DebugMsg('InitAssociations',': not found');
-                       MsgBox(FmtMessage(CustomMessage('InternalError'),['10']),mbError,MB_OK);
-                       exit;
-               end;
-
-               Associations.Association[i-1].Description := Copy(sAssociation,1,d-1); //split description
-               sAssociation := Copy(sAssociation,d+1,Length(sAssociation));
-
-               Explode(Associations.Association[i-1].Extensions, LowerCase(sAssociation), ':'); //split 
extensions
-
-               Associations.Association[i-1].Associated := False; //initialize structure (not sure if 
needed, but better safe than sorry)
-               Associations.Association[i-1].Selected := False;
-               Associations.Association[i-1].AssociatedElsewhere := '';
-
-               for j := 0 to GetArrayLength(Associations.Association[i - 1].Extensions) - 1 do
-               begin
-                       sExt := LowerCase(Associations.Association[i-1].Extensions[j]);
-
-                       for c := 0 to GetArrayLength(CmdLineAssoc) - 1 do //association requested through 
command line
-                               if CmdLineAssoc[c] = sExt then
-                                       Associations.Association[i-1].Selected := True;
-       
-                       sCheck := '';
-                       if Associations_Read('.'+sExt,'',sCheck) then //check if anything else claims this 
association
-                       begin
-                               if (Pos('GIMP-{#ASSOC_VERSION}',sCheck) = 1) //already associated by this 
version of GIMP
-                                  or (Pos('GIMP-2.0',sCheck) = 1) //associated by previous GIMP version
-                                  then 
-                               begin
-                                       Associations.Association[i-1].Associated := True;
-                                       Associations.Association[i-1].Selected := True;
-                                       DebugMsg('InitAssociations','Associated in 
registry:'+Associations.Association[i-1].Extensions[0]);
-                               end else
-                               begin                                      //associated by something else
-                                       if RegKeyExists(HKCR,sCheck) or 
RegKeyExists(HKCU,'SOFTWARE\Classes\'+sCheck) then //ensure that "something else"
-                                       begin                                                                 
             //still actually exists
-                                               Associations.Association[i-1].AssociatedElsewhere := sCheck;
-                                               Association_Fix(sCheck);  //clean up after old broken 
installers
-                                       end;
-                               end;
-                       end else
-                       begin
-                       
-                               if Pos('GIMP',Associations.Association[i-1].Description) > 0 then
-                                       Associations.Association[i-1].Selected := True; //select GIMP's types 
by default if it's not associated by anything yet
-
-                       end;
-               end;
-       end;
-end;
-
-
-procedure Associations_OnClick(Sender: TObject);
-var i,j: Integer;
-       ext: String;
-begin
-       DebugMsg('Associations_OnClick','');
-
-       for i := 0 to GetArrayLength(Associations.Association) - 1 do
-       begin
-               if TNewCheckListbox(Sender).Selected[i] then
-               begin
-                       ext := '';
-                       for j := 0 to GetArrayLength(Associations.Association[i].Extensions) - 1 do
-                               ext := ext + LowerCase(Associations.Association[i].Extensions[j]) + ', ';
-                       ext := Copy(ext, 1, Length(ext) - 2);
-                       
-                       Associations.AssociationsPage.lblAssocInfo2.Caption := 
#13+CustomMessage('SelectAssociationsExtensions')+' ' + ext;
-
-               end;
-               if TNewCheckListbox(Sender).Checked[i] then
-                       Associations.Association[i].Selected := True
-               else
-                       Associations.Association[i].Selected := False;
-       end;
-end;
-
-
-procedure Associations_SelectAll(Sender: TObject);
-var i: Integer;
-       SelAll, UnSelAll: String;
-begin
-
-       SelAll := CustomMessage('SelectAssociationsSelectAll')
-       UnselAll := CustomMessage('SelectAssociationsUnselectAll');
-
-       if TNewButton(Sender).Caption = SelAll then
-       begin
-       
-               for i := 0 to GetArrayLength(Associations.Association) - 1 do
-                       Associations.AssociationsPage.clbAssociations.Checked[i] := True;
-
-               TNewButton(Sender).Caption := UnselAll;
-
-       end else
-       begin
-
-               for i := 0 to GetArrayLength(Associations.Association) - 1 do
-                       if Associations.Association[i].Associated = False then //don't uncheck associations 
that are already active
-                               Associations.AssociationsPage.clbAssociations.Checked[i] := False;
-
-               TNewButton(Sender).Caption := SelAll;
-
-       end;
-
-       Associations_OnClick(Associations.AssociationsPage.clbAssociations);
-
-end;
-
-
-procedure Associations_SelectUnused(Sender: TObject);
-var i: Integer;
-begin
-
-       for i := 0 to GetArrayLength(Associations.Association) - 1 do
-               if Associations.Association[i].AssociatedElsewhere = '' then
-                       Associations.AssociationsPage.clbAssociations.Checked[i] := True;
-
-       Associations_OnClick(Associations.AssociationsPage.clbAssociations);
-
-end;
-
-
-function Associations_GetSelected(): String;
-var Selected: String;
-       i: Integer;
-begin
-
-       Selected := '';
-
-       for i := 0 to GetArrayLength(Associations.Association) - 1 do
-               if Associations.Association[i].Selected then
-                       if Selected = '' then
-                               Selected := Associations.Association[i].Extensions[0]
-                       else
-                               Selected := Selected + ',' + Associations.Association[i].Extensions[0];
-
-       Result := Selected;
-
-end;
diff --git a/build/windows/installer/associations.list b/build/windows/installer/associations.list
new file mode 100755
index 0000000000..a40c0fdd90
--- /dev/null
+++ b/build/windows/installer/associations.list
@@ -0,0 +1,66 @@
+bmp
+dds
+g3
+cel
+dcm
+dicom
+exr
+gif
+heif
+heic
+jp2
+j2k
+j2c
+jpc
+pcx
+pcc
+pdf
+png
+pnm
+ppm
+pgm
+pbm
+pfm
+ps
+eps
+psp
+tub
+pspimage
+im1
+im8
+im24
+im32
+rs
+ras
+svg
+tga
+vda
+icb
+vst
+tif
+tiff
+webp
+wmf
+apm
+xpm
+xwd
+fit
+fits
+fli
+flc
+jpg
+jpeg
+jpe
+psd
+sgi
+rgb
+rgba
+bw
+icon
+pix
+matte
+mask
+alpha
+als
+xbm
+ora
diff --git a/build/windows/installer/compile.bat b/build/windows/installer/compile.bat
index 7bd3bcefec..951b3d7472 100755
--- a/build/windows/installer/compile.bat
+++ b/build/windows/installer/compile.bat
@@ -12,7 +12,7 @@ set DEPS32=%~6
 set DEPS64=%~7
 
 if [%INNOPATH%]==[] (
-FOR /F "usebackq tokens=5,* skip=2" %%A IN (`REG QUERY 
"HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\Inno Setup 5_is1" /v "Inno Setup: App Path" 
/reg:32`) DO set INNOPATH=%%B
+FOR /F "usebackq tokens=5,* skip=2" %%A IN (`REG QUERY 
"HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\Inno Setup 6_is1" /v "Inno Setup: App Path" 
/reg:32`) DO set INNOPATH=%%B
 )
 if not exist "%INNOPATH%\iscc.exe" goto noinno
 
@@ -32,7 +32,7 @@ shift
 goto doparams
 :paramsdone
 
-"%INNOPATH%\iscc.exe" -DVERSION="%VER%" -DGIMP_DIR="%GIMP_BASE%" -DDIR32="%GIMP32%" -DDIR64="%GIMP64%" 
-DDEPS_DIR="%DEPS_BASE%" -DDDIR32="%DEPS32%" -DDDIR64="%DEPS64%" %PARAMS% gimp3264.iss
+"%INNOPATH%\iscc.exe" -DVERSION="%VER%" -DGIMP_DIR="%GIMP_BASE%" -DDIR32="%GIMP32%" -DDIR64="%GIMP64%" 
-DDEPS_DIR="%DEPS_BASE%" -DDDIR32="%DEPS32%" -DDDIR64="%DEPS64%" %PARAMS% gimp3264_6.iss
 goto :eof
 
 :help
diff --git a/build/windows/installer/files.isi b/build/windows/installer/files.isi
index 8ee18bfd4d..d4c74c0867 100644
--- a/build/windows/installer/files.isi
+++ b/build/windows/installer/files.isi
@@ -15,7 +15,7 @@
 Source: "{#GIMP_DIR}\{#DIR}\*.dll"; DestDir: "{app}"; Components: gimp{#PLATFORM}; Flags: recursesubdirs 
restartreplace ignoreversion uninsrestartdelete
 Source: "{#GIMP_DIR}\{#DIR}\*.exe"; DestDir: "{app}"; Excludes: 
"\lib\gimp\2.0\plug-ins\twain\twain.exe,\lib\gimp\2.0\plug-ins\file-ps\file-ps.exe,\lib\gimp\2.0\plug-ins\file-mng\file-mng.exe,\bin\gimp.exe,\bin\gimp-console.exe";
 Components: gimp{#PLATFORM}; Flags: recursesubdirs restartreplace ignoreversion uninsrestartdelete
 #ifdef DEBUG_SYMBOLS
-Source: "{#GIMP_DIR}\{#DIR}\*.debug"; DestDir: "{app}"; Components: gimp{#PLATFORM} and debug; Flags: 
recursesubdirs restartreplace uninsrestartdelete
+Source: "{#GIMP_DIR}\{#DIR}\*.debug"; DestDir: "{app}"; Components: gimp{#PLATFORM} and debug; Flags: 
recursesubdirs restartreplace uninsrestartdelete ignoreversion
 #endif
 
 Source: "{#GIMP_DIR}\{#DIR}\lib\gimp\2.0\plug-ins\file-ps\file-ps.exe"; DestDir: 
"{app}\lib\gimp\2.0\plug-ins\file-ps"; Components: gs and gimp{#PLATFORM}; Flags: restartreplace 
ignoreversion uninsrestartdelete
diff --git a/build/windows/installer/gimp3264.iss b/build/windows/installer/gimp3264.iss
index d3cf54cce4..84659c444f 100755
--- a/build/windows/installer/gimp3264.iss
+++ b/build/windows/installer/gimp3264.iss
@@ -23,7 +23,7 @@
 ;.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.;
 ;
 ;Install script for GIMP and GTK+
-;requires Inno Setup 5.4.2 unicode + ISPP
+;requires Inno Setup 6
 ;
 ;See directories.isi 
 ;
@@ -80,9 +80,18 @@
 #pragma option -e+
 
 #ifndef VERSION
-       #define VERSION "2.7.0"
-       #define REVISION "20100414"
+       #define DEVEL "is6"
+       #define VERSION "2.10.12"
        #define NOFILES
+       #define GIMP_DIR "W:\msys64-gtk2\opt\output\2.10.12"
+       #define DIR32 "i686-w64-mingw32"
+       #define DIR64 "x86_64-w64-mingw32" 
+       #define DEPS_DIR "W:\msys64-gtk2\opt\comb"
+       #define DDIR32 "mingw32"
+       #define DDIR64 "mingw64"
+       #define PYTHON 
+       #define DEBUG_SYMBOLS 
+       #define NOCOMPRESSION
 #endif
 
 #include "directories.isi"
@@ -113,11 +122,11 @@ AlwaysShowDirOnReadyPage=yes
 ChangesEnvironment=yes
 
 #if Defined(DEVEL) && DEVEL != ""
-DefaultDirName={pf}\GIMP {#MAJOR}.{#MINOR}
+DefaultDirName={autopf}\GIMP {#MAJOR}.{#MINOR}
 LZMANumBlockThreads=4
 LZMABlockSize=76800
 #else
-DefaultDirName={pf}\GIMP {#MAJOR}
+DefaultDirName={autopf}\GIMP {#MAJOR}
 #endif
 
 ;AllowNoIcons=true
@@ -160,6 +169,8 @@ OutputBaseFileName=gimp-{#VERSION}-setup
 OutputBaseFileName=gimp-{#VERSION}-{#REVISION}-setup
 #endif
 
+PrivilegesRequiredOverridesAllowed=dialog
+
 [Languages]
 Name: "en"; MessagesFile: "compiler:Default.isl,lang\en.setup.isl"
 Name: "ca"; MessagesFile: "compiler:Languages\Catalan.isl,lang\ca.setup.isl"
@@ -229,8 +240,8 @@ Name: desktopicon; Description: "{cm:AdditionalIconsDesktop}"; GroupDescription:
 
 [Icons]
 #define ICON_VERSION=MAJOR + "." + MINOR + "." + MICRO
-Name: "{commonprograms}\GIMP {#ICON_VERSION}"; Filename: "{app}\bin\gimp-{#MAJOR}.{#MINOR}.exe"; WorkingDir: 
"%USERPROFILE%"; Comment: "GIMP {#VERSION}"
-Name: "{commondesktop}\GIMP {#ICON_VERSION}"; Filename: "{app}\bin\gimp-{#MAJOR}.{#MINOR}.exe"; WorkingDir: 
"%USERPROFILE%"; Comment: "GIMP {#VERSION}"; Tasks: desktopicon
+Name: "{autoprograms}\GIMP {#ICON_VERSION}"; Filename: "{app}\bin\gimp-{#MAJOR}.{#MINOR}.exe"; WorkingDir: 
"%USERPROFILE%"; Comment: "GIMP {#VERSION}"
+Name: "{autodesktop}\GIMP {#ICON_VERSION}"; Filename: "{app}\bin\gimp-{#MAJOR}.{#MINOR}.exe"; WorkingDir: 
"%USERPROFILE%"; Comment: "GIMP {#VERSION}"; Tasks: desktopicon
 
 [Files]
 ;setup files
@@ -548,10 +559,9 @@ Type: filesandordirs; Name: "{app}\lib\babl-0.1"
 Type: filesandordirs; Name: "{app}\lib\gegl-0.4"
 
 [Registry]
-;fix broken toolbox icons
-Root: HKLM; Subkey: "Software\Classes\.svg"; ValueType: string; ValueName: "Content Type"; ValueData: 
"image/svg+xml"; Flags: noerror createvalueifdoesntexist
 ;remove LIBTHAI_DICTDIR variable set by original 2.10.8 installer
-Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; ValueType: none; 
ValueName: "LIBTHAI_DICTDIR"; Flags: deletevalue uninsdeletevalue
+Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; ValueType: none; 
ValueName: "LIBTHAI_DICTDIR"; Flags: deletevalue uninsdeletevalue noerror
+#include "associations.isi"
 
 [UninstallDelete]
 Type: files; Name: "{app}\uninst\uninst.inf"
@@ -584,6 +594,7 @@ procedure ComponentsListOnClick(pSender: TObject); forward;
 procedure SaveToUninstInf(const pText: AnsiString); forward;
 procedure CreateRunOnceEntry; forward;
 function RestartSetupAfterReboot(): Boolean; forward;
+procedure AssociationsCleanUp(); forward;
 
 const
        CP_ACP = 0;
@@ -621,21 +632,6 @@ var
 
        WelcomeBitmapBottom: TBitmapImage;
 
-       Associations: record
-               AssociationsPage: record
-                       Page: TWizardPage;
-                       clbAssociations: TNewCheckListBox;
-                       lblAssocInfo2: TNewStaticText;
-               end;
-               Association: array of record
-                       Description: String;
-                       Extensions: TArrayOfString;
-                       Selected: Boolean;
-                       Associated: Boolean;
-                       AssociatedElsewhere: String;
-               end;
-       end;
-
        //pgSimple: TWizardPage;
        btnInstall, btnCustomize: TNewButton;
 
@@ -763,9 +759,6 @@ begin
 end;
 
 
-#include "associations.isi"
-
-
 procedure PreparePyGimp();
 var PyGimpInterp,Interp: String;
 begin
@@ -902,104 +895,11 @@ end;
 
 
 procedure InitCustomPages();
-var lblAssocInfo: TNewStaticText;
-       btnSelectAll,btnSelectUnused: TNewButton;
-       i,ButtonWidth: Integer;
+var    i,ButtonWidth: Integer;
        ButtonText: TArrayOfString;
        MeasureLabel: TNewStaticText;
        //lblInfo: TNewStaticText;
 begin
-       DebugMsg('InitCustomPages','pgAssociations');
-       Associations.AssociationsPage.Page := 
CreateCustomPage(wpSelectComponents,CustomMessage('SelectAssociationsCaption'),CustomMessage('SelectAssociationsCaption'));
-
-       lblAssocInfo := TNewStaticText.Create(Associations.AssociationsPage.Page);
-       with lblAssocInfo do
-       begin
-               Parent := Associations.AssociationsPage.Page.Surface;
-               Left := 0;
-               Top := 0;
-               Width := Associations.AssociationsPage.Page.SurfaceWidth;
-               Height := ScaleY(13);
-               WordWrap := True;
-               AutoSize := True;
-               Caption := 
CustomMessage('SelectAssociationsInfo1')+#13+CustomMessage('SelectAssociationsInfo2')+#13;
-       end;    
-       Associations.AssociationsPage.lblAssocInfo2 := 
TNewStaticText.Create(Associations.AssociationsPage.Page);
-       with Associations.AssociationsPage.lblAssocInfo2 do
-       begin
-               Parent := Associations.AssociationsPage.Page.Surface;
-               Left := 0;
-               Width := Associations.AssociationsPage.Page.SurfaceWidth;
-               Height := 13;
-               AutoSize := True;
-               Caption := #13+CustomMessage('SelectAssociationsExtensions');
-       end;
-       
-       Associations.AssociationsPage.clbAssociations := 
TNewCheckListBox.Create(Associations.AssociationsPage.Page);
-       with Associations.AssociationsPage.clbAssociations do
-       begin
-               Parent := Associations.AssociationsPage.Page.Surface;
-               Left := 0;
-               Top := lblAssocInfo.Top + lblAssocInfo.Height;
-               Width := Associations.AssociationsPage.Page.SurfaceWidth;
-               Height := Associations.AssociationsPage.Page.SurfaceHeight - lblAssocInfo.Height - 
Associations.AssociationsPage.lblAssocInfo2.Height - ScaleX(8);
-               TabOrder := 1;
-               Flat := True;
-
-                // the box's height, minus the 2-pixel border, has to be a
-                // multiple of the item height, which has to be even, otherwise
-                // clicking the last visible item may scroll to the next item,
-                // causing it to be toggled.  see bug #786840.
-                MinItemHeight := ScaleY(16) / 2 * 2;
-                Height := (Height - 4) / MinItemHeight * MinItemHeight + 4;
-
-               Associations.AssociationsPage.lblAssocInfo2.Top := Height + Top;
-
-               OnClick := @Associations_OnClick;
-
-               for i := 0 to GetArrayLength(Associations.Association) - 1 do
-                       AddCheckBox(Associations.Association[i].Description,
-                                   '',
-                                   0,
-                                   Associations.Association[i].Selected,
-                                   not Associations.Association[i].Associated, //don't allow unchecking 
associations that are already present
-                                   False,
-                                   False,
-                                   nil
-                                  );                   
-
-       end;
-
-       SetArrayLength(ButtonText, 3);
-       ButtonText[0] := CustomMessage('SelectAssociationsSelectUnused');
-       ButtonText[1] := CustomMessage('SelectAssociationsSelectAll');
-       ButtonText[2] := CustomMessage('SelectAssociationsUnselectAll');
-       ButtonWidth := GetButtonWidth(ButtonText, WizardForm.NextButton.Width);
-
-       btnSelectUnused := TNewButton.Create(Associations.AssociationsPage.Page);
-       with btnSelectUnused do
-       begin
-               Parent := Associations.AssociationsPage.Page.Surface;
-               Width := ButtonWidth;
-               Left := Associations.AssociationsPage.Page.SurfaceWidth - Width * 2;
-               Height := WizardForm.NextButton.Height;
-               Top := Associations.AssociationsPage.clbAssociations.Top + 
Associations.AssociationsPage.clbAssociations.Height + ScaleX(8);
-               Caption := CustomMessage('SelectAssociationsSelectUnused');
-               OnClick := @Associations_SelectUnused;
-       end;
-
-       btnSelectAll := TNewButton.Create(Associations.AssociationsPage.Page);
-       with btnSelectAll do
-       begin
-               Parent := Associations.AssociationsPage.Page.Surface;
-               Width := ButtonWidth;
-               Left := Associations.AssociationsPage.Page.SurfaceWidth - Width;
-               Height := WizardForm.NextButton.Height;
-               Top := Associations.AssociationsPage.clbAssociations.Top + 
Associations.AssociationsPage.clbAssociations.Height + ScaleX(8);
-               Caption := CustomMessage('SelectAssociationsSelectAll');
-               OnClick := @Associations_SelectAll;
-       end;
-
        DebugMsg('InitCustomPages','wpLicense');
 
        btnInstall := TNewButton.Create(WizardForm);
@@ -1304,23 +1204,6 @@ begin
        sText := sText + ParseReadyMemoText(pSpace,pMemoTypeInfo);
        sText := sText + '\sb100' + ParseReadyMemoText(pSpace,pMemoComponentsInfo);
 
-       for i := 0 to GetArrayLength(Associations.Association) - 1 do
-               if Associations.Association[i].Selected then
-                       bShowAssoc := True;
-
-       if bShowAssoc then
-       begin
-               sText := sText + '\sb100\b '+Unicode2RTF(CustomMessage('ReadyMemoAssociations'))+'\par 
\sb0\li284\b0 '; //which file types to associate
-
-               for i := 0 to GetArrayLength(Associations.Association) - 1 do                                 
                  
-                       if Associations.Association[i].Selected then
-                               for j := 0 to GetArrayLength(Associations.Association[i].Extensions) - 1 do
-                                       sText := sText + LowerCase(Associations.Association[i].Extensions[j]) 
+ ', ';
-                                       
-               sText := Copy(sText, 1, Length(sText) - 2) + '\par \pard';
-
-       end;
-
        If pMemoTasksInfo<>'' then
                sText := sText + '\sb100' + ParseReadyMemoText(pSpace,pMemoTasksInfo);
                
@@ -1635,13 +1518,12 @@ begin
                ssInstall:
                begin
                        RemoveDebugFiles();
+                       AssociationsCleanup();
                end;
                ssPostInstall:
                begin
-                       Associations_Create();
                        PreparePyGimp();
                        PrepareGimpEnvironment();
-                       //PrepareGimpRC();
                end;
        end;
 end;
@@ -1802,8 +1684,6 @@ begin
                exit;
        end;
 
-       Associations_Init();
-
        //if InstallMode <> imRebootContinue then
        //      SuppressibleMsgBox(CustomMessage('UninstallWarning'),mbError,MB_OK,IDOK);
 
diff --git a/build/windows/installer/rebootcontinue.isi b/build/windows/installer/rebootcontinue.isi
index 2097ad0bdd..0cec212434 100644
--- a/build/windows/installer/rebootcontinue.isi
+++ b/build/windows/installer/rebootcontinue.isi
@@ -40,7 +40,6 @@ begin
        SetupRestartData := AddParam(SetupRestartData, 'TYPE', Quote(WizardSetupType(False)));
        SetupRestartData := AddParam(SetupRestartData, 'COMPONENTS', Quote(WizardSelectedComponents(False)));
        SetupRestartData := AddParam(SetupRestartData, 'TASKS', Quote(WizardSelectedTasks(False)));
-       SetupRestartData := AddParam(SetupRestartData, 'ASSOC', Quote(Associations_GetSelected()));
 
        if Force32bitInstall then
                SetupRestartData := AddSimpleParam(SetupRestartData, '32');
diff --git a/build/windows/installer/uninst.isi b/build/windows/installer/uninst.isi
index b70a69fd0e..29231cd0df 100644
--- a/build/windows/installer/uninst.isi
+++ b/build/windows/installer/uninst.isi
@@ -219,6 +219,10 @@ uninst.inf documentation:
 
 Directives are parsed from the end of the file backwards as the first step of uninstall.
 
+IMPORTANT: From GIMP 2.10.12 onwards (Inno Setup 6 with support for per-user install), Registry keys 
referring to HKCR will be
+processed by the installer as the first step of install (and the entries will be removed from uninst.inf), 
since file associations
+code was rewritten.
+
 *)
 procedure ParseUninstInf();
 var i,d: Integer;
@@ -267,3 +271,65 @@ begin
        end;
 end;
 
+
+procedure AssociationsCleanUp();
+var i, d, countNew,countUI: Integer;
+       asTemp, asNew: TArrayOfString;
+       sKey,sVal: String;
+       iRootKey: Integer;
+begin
+       if FileExists(ExpandConstant('{app}\uninst\uninst.inf')) then
+       begin
+               DebugMsg('AssociationsCleanUp','Parsing old uninst.inf');
+               LoadStringsFromFile(ExpandConstant('{app}\uninst\uninst.inf'),asTemp);
+
+               countNew := 0;
+               countUI := 0;
+               SetArrayLength(asNew, GetArrayLength(asTemp));
+               SetArrayLength(asUninstInf, GetArrayLength(asTemp));
+
+               for i := 0 to GetArrayLength(asTemp) - 1 do //extract associations-related entries from 
uninst.inf
+               begin
+
+                       if (Length(asTemp[i]) = 0) or (asTemp[i][1] = '#') then //comment/empty line
+                       begin
+                               asNew[countNew] := asTemp[i];
+                               Inc(countNew);
+                               continue;
+                       end;
+
+                       d := Pos(':',asTemp[i]);
+                       if d = 0 then //something wrong, ignore
+                               continue;
+
+                       if Copy(asTemp[i],1,3) = 'Reg' then
+                       begin
+
+                               sVal := 'nil';
+                               if not SplitRegParams(Copy(asTemp[i], d + 1, 
Length(asTemp[i])),iRootKey,sKey,sVal) then
+                                       continue; //malformed line, ignore
+
+                               if iRootKey = HKCR then //old association, prepare for cleanup
+                               begin
+                                       DebugMsg('AssociationsCleanUp','Preparing for cleanup: '+asTemp[i]);
+                                       asUninstInf[countUI] := asTemp[i];
+                                       Inc(countUI);
+                                       continue;
+                               end;
+                               
+                       end;
+
+                       //something else, keep for new uninst.inf
+                       asNew[countNew] := asTemp[i];
+                       Inc(countNew);
+
+               end;
+
+               SetArrayLength(asNew, countNew);
+               SetArrayLength(asUninstInf, countUI);
+
+               SaveStringsToUTF8File(ExpandConstant('{app}\uninst\uninst.inf'), asNew, False); //replace 
uninst.inf with a cleaned one
+               
+               ParseUninstInf(); //remove old associations
+       end;
+end;
diff --git a/build/windows/installer/utils.isi b/build/windows/installer/utils.isi
index dc04c26bb5..1dbc0f163a 100644
--- a/build/windows/installer/utils.isi
+++ b/build/windows/installer/utils.isi
@@ -146,3 +146,32 @@ begin
        WizardForm.FilenameLabel.Caption := Status2;
        WizardForm.Refresh();
 end;
+
+
+//reverse encoding done by Encode
+function Decode(pText: String): String;
+var p: Integer;
+       tmp: String;
+begin
+       if Pos('%',pText) = 0 then
+               Result := pText
+       else
+       begin           
+               Result := '';
+               while Length(pText) > 0 do
+               begin
+                       p := Pos('%',pText);
+                       if p = 0 then
+                       begin
+                               Result := Result + pText;
+                               break;
+                       end;
+                       Result := Result + Copy(pText,1,p-1);
+                       tmp := '$' + Copy(pText,p+1,2);
+                       Result := Result + Chr(StrToIntDef(tmp,32));
+                       pText := Copy(pText,p+3,Length(pText));
+               end;
+       end;
+end;
+
+


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]