<?xml version="1.0" encoding="UTF-8"?>
<?include .\defines.wxi ?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Product Id="*" Name="$(var.ProductName)" Language="1033" Version="$(var.ProductVersion)" Manufacturer="$(var.Manufacturer)" UpgradeCode="$(var.UpgradeCode)">
    <Package Id="*" Description="$(var.ProductName)" Comments="Contact: your local administrator" InstallerVersion="405" Compressed="yes" Keywords="TEXT,EDITOR,GNOME" Languages="1033" Manufacturer="$(var.Manufacturer)" InstallScope="perMachine"/>
    <Icon Id="icon.ico" SourceFile="$(var.TopDir)\gedit\resources\pixmaps\gedit.ico"/>
    <Property Id="ARPPRODUCTICON" Value="icon.ico" />
    <Media Id="1" Cabinet="data.cab" EmbedCab="yes" />

    <!-- Features -->
    <Feature Id="gedit" Title="gedit" Level="1">
      <ComponentGroupRef Id="binaries" />
      <ComponentGroupRef Id="startMenuShortcuts" />
      <ComponentGroupRef Id="licenseFiles" />
    </Feature>

    <!-- UI -->
    <Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR" />
    <WixVariable Id="WixUIBannerBmp" Value="$(var.TopDir)\win32\installer\WixUIBannerBmp.bmp" />
    <WixVariable Id="WixUIDialogBmp" Value="$(var.TopDir)\win32\installer\WixUIDialogBmp.bmp" />
    <WixVariable Id="WixUILicenseRtf" Value="$(var.LicenseFile)" />
    <Condition Message="[ProductName] requires that your computer is running at least Windows 7">VersionNT&gt;=601</Condition>

    <UI>
      <UIRef Id="WixUI_InstallDir" />
    </UI>

    <!-- Installer actions -->
    <CustomAction Id="SetCompileSchemasCommand" Property="CompileSchemas" Value="&quot;[INSTALLDIR]bin\glib-compile-schemas.exe&quot; &quot;[INSTALLDIR]share\glib-2.0\schemas&quot;"/>
    <CustomAction Id="CompileSchemas" BinaryKey="WixCA" DllEntry="CAQuietExec" Return="ignore" Execute="deferred" Impersonate="no" />
    <CustomAction Id="SetUpdateIconCacheCommand" Property="UpdateIconCache" Value="&quot;[INSTALLDIR]bin\gtk-update-icon-cache-3.0.exe&quot; &quot;[INSTALLDIR]share\icons\hicolor&quot;"/>
    <CustomAction Id="UpdateIconCache" BinaryKey="WixCA" DllEntry="CAQuietExec" Return="ignore" Execute="deferred" Impersonate="no" />
    <CustomAction Id="SetUpdatePixbufLoadersCommand" Property="UpdatePixbufLoaders" Value="&quot;[INSTALLDIR]bin\gdk-pixbuf-query-loaders.exe&quot; --update-cache"/>
    <CustomAction Id="UpdatePixbufLoaders" BinaryKey="WixCA" DllEntry="CAQuietExec" Return="ignore" Execute="deferred" Impersonate="no" />

    <InstallExecuteSequence>
      <RemoveExistingProducts Before="InstallInitialize" />
      <Custom Action="SetCompileSchemasCommand" After="InstallFiles">Not Installed</Custom>
      <Custom Action="CompileSchemas" After="SetCompileSchemasCommand">Not Installed</Custom>
      <Custom Action="SetUpdateIconCacheCommand" After="CompileSchemas">Not Installed</Custom>
      <Custom Action="UpdateIconCache" After="SetUpdateIconCacheCommand">Not Installed</Custom>
      <Custom Action="SetUpdatePixbufLoadersCommand" After="UpdateIconCache">Not Installed</Custom>
      <Custom Action="UpdatePixbufLoaders" After="SetUpdatePixbufLoadersCommand">Not Installed</Custom>
    </InstallExecuteSequence>

  </Product>

  <!-- Directory Tree -->
  <Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="$(var.PlatformProgramFilesFolder)" Name="$(var.PlatformProgramFilesFolder)">
        <Directory Name="gedit" Id="gedit_dir">
          <Directory Id="INSTALLDIR">
            <Directory Name="license" Id="gedit_license" />
          </Directory>
        </Directory>
      </Directory>
      <Directory Id="ProgramMenuFolder">
        <Directory Id="ProgramMenuDir" Name="gedit Text Editor" />
      </Directory>
    </Directory>
  </Fragment>

  <!-- Components -->
  <Fragment>
    <ComponentGroup Id="startMenuShortcuts">
      <Component Id="programShortcuts" Guid="{A071C7AE-C657-4FAD-B0CC-11A6D794D0D3}" Directory="ProgramMenuDir">
        <RegistryValue Key="Software\[Manufacturer]\[ProductName]" Root="HKCU" Type="string" Value="[INSTALLDIR]" Name="InstallPath" />
        <Shortcut Id="geditExec" Name="gedit Text Editor" Description="gedit Text Editor" Target="[INSTALLDIR]\bin\gedit.exe" />
        <Shortcut Id="uninstallProduct" Name="Uninstall gedit Text Editor" Arguments="/x [ProductCode]" Description="Uninstall gedit Text Editor" Target="[System64Folder]msiexec.exe" />
        <RemoveFolder Id="ProgramMenuDir" On="uninstall" />
      </Component>
    </ComponentGroup>

    <ComponentGroup Id="licenseFiles" Directory="gedit_license">
      <Component Id="COPYING.rtf" Guid="*">
        <File Id="COPYING.rtf" Name="COPYING.rtf" Source="$(var.LicenseFile)" />
      </Component>
    </ComponentGroup>
  </Fragment>
</Wix>
