Add AppUserModelID to start menu shortcuts

This commit is contained in:
Kovid Goyal 2024-11-08 11:13:32 +05:30
parent c27e613837
commit f207de192f
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 28 additions and 14 deletions

View File

@ -113,9 +113,14 @@ def initialize_constants():
nv = re.search(r'numeric_version\s+=\s+\((\d+), (\d+), (\d+)\)', src) nv = re.search(r'numeric_version\s+=\s+\((\d+), (\d+), (\d+)\)', src)
calibre_constants['version' calibre_constants['version'
] = '%s.%s.%s' % (nv.group(1), nv.group(2), nv.group(3)) ] = '%s.%s.%s' % (nv.group(1), nv.group(2), nv.group(3))
calibre_constants['appname'] = re.search( def get_str_assign(which):
r'__appname__\s+=\s+(u{0,1})[\'"]([^\'"]+)[\'"]', src pat = r'__appname__\s+=\s+(u{0,1})[\'"]([^\'"]+)[\'"]'.replace('__appname__', which)
).group(2) return re.search(pat, src).group(2)
calibre_constants['appname'] = get_str_assign('__appname__')
calibre_constants['MAIN_APP_UID'] = get_str_assign('MAIN_APP_UID')
calibre_constants['VIEWER_APP_UID'] = get_str_assign('VIEWER_APP_UID')
calibre_constants['EDITOR_APP_UID'] = get_str_assign('EDITOR_APP_UID')
epsrc = re.compile(r'entry_points = (\{.*?\})', epsrc = re.compile(r'entry_points = (\{.*?\})',
re.DOTALL).search(read_cal_file('linux.py')).group(1) re.DOTALL).search(read_cal_file('linux.py')).group(1)
entry_points = eval(epsrc, {'__appname__': calibre_constants['appname']}) entry_points = eval(epsrc, {'__appname__': calibre_constants['appname']})

View File

@ -1,4 +1,4 @@
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util" xmlns:ui="http://wixtoolset.org/schemas/v4/wxs/ui"> <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util" xmlns:ui="http://wixtoolset.org/schemas/v4/wxs/ui">
<Package Name="{app}{x64}" UpgradeCode="{upgrade_code}" Language="1033" Codepage="1252" Version="{version}" Manufacturer="Kovid Goyal" InstallerVersion="300" Scope="perMachine"> <Package Name="{app}{x64}" UpgradeCode="{upgrade_code}" Language="1033" Codepage="1252" Version="{version}" Manufacturer="Kovid Goyal" InstallerVersion="300" Scope="perMachine">
@ -7,7 +7,7 @@
<!-- Disable creation of system restore points on calibre installs. Speeds <!-- Disable creation of system restore points on calibre installs. Speeds
up the install. We dont need system restore since we dont install any up the install. We dont need system restore since we dont install any
system DLLs/components anyway (apart from start menu entries) --> system DLLs/components anyway (apart from start menu entries) -->
<Property Id="MSIFASTINSTALL" Value="3" /> <Property Id="MSIFASTINSTALL" Value="3" />
<Media Id="1" Cabinet="{app}.cab" CompressionLevel="{compression}" EmbedCab="yes" /> <Media Id="1" Cabinet="{app}.cab" CompressionLevel="{compression}" EmbedCab="yes" />
<!-- The following line ensures that DLLs are replaced even if <!-- The following line ensures that DLLs are replaced even if
@ -39,7 +39,7 @@
<RegistrySearch Id="calibreInstDir" Type="raw" Root="HKLM" Key="Software\{app}{x64}\Installer" Name="InstallPath" /> <RegistrySearch Id="calibreInstDir" Type="raw" Root="HKLM" Key="Software\{app}{x64}\Installer" Name="InstallPath" />
</Property> </Property>
<Icon Id="main_icon" SourceFile="{main_icon}" /> <Icon Id="main_icon" SourceFile="{main_icon}" />
<!-- <Icon Id="viewer_icon" SourceFile="{viewer_icon}"/> --> <!-- <Icon Id="viewer_icon" SourceFile="{viewer_icon}"/> -->
@ -63,7 +63,7 @@
<RegistryValue Root="HKLM" Key="Software\{app}{x64}\Installer" Name="InstallPath" Type="string" Value="[APPLICATIONFOLDER]" KeyPath="yes" /> <RegistryValue Root="HKLM" Key="Software\{app}{x64}\Installer" Name="InstallPath" Type="string" Value="[APPLICATIONFOLDER]" KeyPath="yes" />
</Component> </Component>
<Component Id="calibreProtocol"> <Component Id="calibreProtocol">
<RegistryKey Root="HKCR" Key="calibre" ForceDeleteOnUninstall="yes"> <RegistryKey Root="HKCR" Key="calibre" ForceDeleteOnUninstall="yes">
<RegistryValue Type="string" Value="URL:calibre Protocol" KeyPath="yes" /> <RegistryValue Type="string" Value="URL:calibre Protocol" KeyPath="yes" />
<RegistryValue Type="string" Name="URL Protocol" Value="" /> <RegistryValue Type="string" Name="URL Protocol" Value="" />
<RegistryKey Key="DefaultIcon"> <RegistryKey Key="DefaultIcon">
@ -78,9 +78,15 @@
<DirectoryRef Id="ApplicationProgramsFolder"> <DirectoryRef Id="ApplicationProgramsFolder">
<Component Id="StartMenuShortcuts"> <Component Id="StartMenuShortcuts">
<Shortcut Id="s1" Name="{app}{x64} - E-book management" Description="Manage your e-book collection, read or edit your e-books and download news" Target="[#{exe_map[calibre]}]" WorkingDirectory="APPLICATIONFOLDER" /> <Shortcut Id="s1" Name="{app}{x64} - E-book management" Description="Manage your e-book collection, read or edit your e-books and download news" Target="[#{exe_map[calibre]}]" WorkingDirectory="APPLICATIONFOLDER">
<Shortcut Id="s2" Name="E-book viewer{x64}" Description="Viewer for all the major e-book formats" Target="[#{exe_map[ebook-viewer]}]" WorkingDirectory="APPLICATIONFOLDER" /> <ShortcutProperty Key="System.AppUserModel.ID" Value="{main_app_uid}"/>
<Shortcut Id="s4" Name="Edit E-book{x64}" Description="Edit e-books" Target="[#{exe_map[ebook-edit]}]" WorkingDirectory="APPLICATIONFOLDER" /> </Shortcut>
<Shortcut Id="s2" Name="E-book viewer{x64}" Description="Viewer for all the major e-book formats" Target="[#{exe_map[ebook-viewer]}]" WorkingDirectory="APPLICATIONFOLDER">
<ShortcutProperty Key="System.AppUserModel.ID" Value="{viewer_app_uid}"/>
</Shortcut>
<Shortcut Id="s4" Name="Edit E-book{x64}" Description="Edit e-books" Target="[#{exe_map[ebook-edit]}]" WorkingDirectory="APPLICATIONFOLDER">
<ShortcutProperty Key="System.AppUserModel.ID" Value="{editor_app_uid}"/>
</Shortcut>
<Shortcut Id="s3" Name="LRF viewer{x64}" Description="Viewer for LRF format e-books" Target="[#{exe_map[lrfviewer]}]" WorkingDirectory="APPLICATIONFOLDER" /> <Shortcut Id="s3" Name="LRF viewer{x64}" Description="Viewer for LRF format e-books" Target="[#{exe_map[lrfviewer]}]" WorkingDirectory="APPLICATIONFOLDER" />
<util:InternetShortcut Id="OnlineDocumentationShortcut" Name="User Manual" Type="url" Target="https://manual.calibre-ebook.com" /> <util:InternetShortcut Id="OnlineDocumentationShortcut" Name="User Manual" Type="url" Target="https://manual.calibre-ebook.com" />
<util:InternetShortcut Id="GetInvolvedS" Name="Get Involved" Type="url" Target="https://calibre-ebook.com/get-involved" /> <util:InternetShortcut Id="GetInvolvedS" Name="Get Involved" Type="url" Target="https://calibre-ebook.com/get-involved" />
@ -94,7 +100,7 @@
<Component Id="DesktopShortcut"> <Component Id="DesktopShortcut">
<Shortcut Id="ds1" Name="{app}{x64} - E-book management" Description="Manage your e-book collection, read or edit your e-books and download news" Target="[#{exe_map[calibre]}]" WorkingDirectory="APPLICATIONFOLDER" /> <Shortcut Id="ds1" Name="{app}{x64} - E-book management" Description="Manage your e-book collection, read or edit your e-books and download news" Target="[#{exe_map[calibre]}]" WorkingDirectory="APPLICATIONFOLDER" />
<RegistryValue Root="HKCU" Key="Software\Microsoft\{app}{x64}" Name="desktop_shortcut_installed" Type="integer" Value="1" KeyPath="yes" /> <RegistryValue Root="HKCU" Key="Software\Microsoft\{app}{x64}" Name="desktop_shortcut_installed" Type="integer" Value="1" KeyPath="yes" />
</Component> </Component>
</StandardDirectory> </StandardDirectory>
@ -140,12 +146,12 @@
<InstallExecuteSequence> <InstallExecuteSequence>
<Custom Action="PreventDowngrading" After="FindRelatedProducts" Condition="NEWPRODUCTFOUND" /> <Custom Action="PreventDowngrading" After="FindRelatedProducts" Condition="NEWPRODUCTFOUND" />
<Custom Action="OverwriteWixSetDefaultPerMachineFolder" After="WixSetDefaultPerMachineFolder" /> <Custom Action="OverwriteWixSetDefaultPerMachineFolder" After="WixSetDefaultPerMachineFolder" />
<RemoveExistingProducts After="InstallFinalize" /> <RemoveExistingProducts After="InstallFinalize" />
</InstallExecuteSequence> </InstallExecuteSequence>
<InstallUISequence> <InstallUISequence>
<Custom Action="PreventDowngrading" After="FindRelatedProducts" Condition="NEWPRODUCTFOUND" /> <Custom Action="PreventDowngrading" After="FindRelatedProducts" Condition="NEWPRODUCTFOUND" />
<Custom Action="OverwriteWixSetDefaultPerMachineFolder" After="WixSetDefaultPerMachineFolder" /> <Custom Action="OverwriteWixSetDefaultPerMachineFolder" After="WixSetDefaultPerMachineFolder" />
</InstallUISequence> </InstallUISequence>
<UI> <UI>
@ -155,7 +161,7 @@
</UI> </UI>
<!-- <!--
Set default folder name. For a per-machine installation, the default Set default folder name. For a per-machine installation, the default
installation location will be [ProgramFilesFolder][ApplicationFolderName] installation location will be [ProgramFilesFolder][ApplicationFolderName]
and the user will be able to change it in the setup UI. and the user will be able to change it in the setup UI.

View File

@ -51,6 +51,9 @@ def create_installer(env, compression_level='9'):
x64=' 64bit' if is64bit else '', x64=' 64bit' if is64bit else '',
compression='high', compression='high',
app_components=components, app_components=components,
main_app_uid=calibre_constants['MAIN_APP_UID'],
viewer_app_uid=calibre_constants['VIEWER_APP_UID'],
editor_app_uid=calibre_constants['EDITOR_APP_UID'],
exe_map=smap, exe_map=smap,
main_icon=j(env.src_root, 'icons', 'library.ico'), main_icon=j(env.src_root, 'icons', 'library.ico'),
viewer_icon=j(env.src_root, 'icons', 'viewer.ico'), viewer_icon=j(env.src_root, 'icons', 'viewer.ico'),