diff options
author | Siep Kroonenberg <siepo@cybercomm.nl> | 2008-05-16 11:12:35 +0000 |
---|---|---|
committer | Siep Kroonenberg <siepo@cybercomm.nl> | 2008-05-16 11:12:35 +0000 |
commit | b93ac683208b416bc7869b9eba0fe4c0133691ea (patch) | |
tree | c201bebb861e1bca474ae506e4f2ae7958542e51 /Master | |
parent | 7338c490eca6b743e08a9da622f5918734104731 (diff) |
Revised shortcuts code
git-svn-id: svn://tug.org/texlive/trunk@8176 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rwxr-xr-x | Master/install-tl | 42 | ||||
-rw-r--r-- | Master/tlpkg/TeXLive/TLWinGoo.pm | 264 |
2 files changed, 173 insertions, 133 deletions
diff --git a/Master/install-tl b/Master/install-tl index 8659cd31d0c..e2eebd0a57c 100755 --- a/Master/install-tl +++ b/Master/install-tl @@ -75,9 +75,11 @@ if (win32) { &unregister_script_type &broadcast_env &update_assocs - &add_tl_shortcut - &clear_unshortbat - &make_tl_shortcuts + &add_desktop_shortcut + &add_menu_shortcut + &remove_desktop_shortcut + &remove_menu_shortcut + &init_unshortbat &create_uninstaller )); } @@ -876,8 +878,8 @@ operations might be disturbed.\n\n"; # post install actions # - # clear batchfile for uninstalling shortcuts - clear_unshortbat($vars{'TEXDIR'}) if win32; + # (re-)initialize batchfile for uninstalling shortcuts + init_unshortbat($vars{'TEXDIR'}) if win32; foreach my $package (sort keys %install) { if ($install{$package} && defined($PostInstall{$package})) { @@ -983,28 +985,38 @@ operations might be disturbed.\n\n"; } if (win32) { - add_tl_shortcut( - 'Desktop', + add_desktop_shortcut( + $vars{'TEXDIR'}, 'TeXdoc', + '', # $vars{'TEXDIR'}.'/tlpkg/doc/notes.ico', $vars{'TEXDIR'}.'/bin/win32/texdoctk.bat', - "", - 'batgui', # any non-null value ok + '', # no args + 'batgui', # any non-null value to hide command-prompt ); - add_tl_shortcut( - 'Desktop', + add_desktop_shortcut( + $vars{'TEXDIR'}, 'PS_View', + $vars{'TEXDIR'}.'/tlpkg/tlpsv/psv.exe', # icon, not prog! $vars{'TEXDIR'}.'/bin/win32/psv.bat', - "", + '', 'batgui', ); - add_tl_shortcut( + add_menu_shortcut( 'TeXLive', 'TeXLive Manager', + '', # $vars{'TEXDIR'}.'/tlpkg/doc/dummy.ico', $vars{'TEXDIR'}.'/bin/win32/tlmgr.bat', - "gui", + 'gui', 'batgui', ); - make_tl_shortcuts($vars{'TEXDIR'}); + add_menu_shortcut( + 'TeXLive', + 'TeXLive Manual', + '', # default pdf icon + $vars{'TEXDIR'}.'/texmf-doc/doc/english/texlive-en/live.pdf', + '', + '', + ); } # old installer: diff --git a/Master/tlpkg/TeXLive/TLWinGoo.pm b/Master/tlpkg/TeXLive/TLWinGoo.pm index 5b54aa89e66..c323f75455e 100644 --- a/Master/tlpkg/TeXLive/TLWinGoo.pm +++ b/Master/tlpkg/TeXLive/TLWinGoo.pm @@ -55,9 +55,13 @@ C<TeXLive::TLWinGoo> -- Additional utilities for Windows =head2 SHORTCUTS - TeXLive::TLWinGoo::add_tl_shortcut($place, $name, $prog, $args, $batgui); - TeXLive::TLWinGoo::clear_unshortbat($texdir); - TeXLive::TLWinGoo::make_tl_shortcuts($texdir); + TeXLive::TLWinGoo::add_desktop_shortcut($texdir, $name, $icon, + $prog, $args, $batgui); + TeXLive::TLWinGoo::add_menu_shortcut($place, $name, $icon, + $prog, $args, $batgui); + TeXLive::TLWinGoo::init_unshortbat($texdir); + TeXLive::TLWinGoo::remove_desktop_shortcut($name); + TeXLive::TLWinGoo::remove_menu_shortcut($place, $name); =head2 UNINSTALLER @@ -96,9 +100,11 @@ BEGIN { &unregister_script_type &broadcast_env &update_assocs - &add_tl_shortcut - &clear_unshortbat - &make_tl_shortcuts + &add_desktop_shortcut + &add_menu_shortcut + &remove_desktop_shortcut + &remove_menu_shortcut + &init_unshortbat &create_uninstaller &unregister_uninstaller ); @@ -657,37 +663,7 @@ sub register_script_type { tllog ($::LOG_DDEBUG, "Linking $extension to $command\n"); my $user_env = get_user_env(); my $system_env = get_system_env(); - my ($pathext, $found, $e, $classes_key, $k); - - # pathext - if (!$::opt_portable) { - if ($is_admin) { - # system pathext - $pathext = $system_env -> {'/PATHEXT'}; - $found = 0; - foreach $e (split(/;/,$pathext)) { - $found = 1 if (uc($e) eq $extension); - } - setenv_reg("PATHEXT", $pathext.";".$extension, "system") unless $found; - # user pathext - $pathext = $user_env -> {'/PATHEXT'}; - if ($pathext) { - $found = 0; - foreach $e (split(/;/,$pathext)) { - $found = 1 if (uc($e) eq $extension); - } - setenv_reg("PATHEXT", $pathext.";".$extension, "user") unless $found; - } - } else { # non-admin - $pathext = $user_env -> {'/PATHEXT'}; - $pathext = $system_env -> {'/PATHEXT'} if not $pathext; - $found = 0; - foreach $e (split(/;/,$pathext)) { - $found = 1 if (uc($e) eq $extension); - } - setenv_reg("PATHEXT", $pathext.";".$extension, "user") unless $found; - } - } + my ($classes_key, $k); # file type $extension = lc($extension); @@ -814,114 +790,166 @@ sub update_assocs() { =head2 SHORTCUTS -=item C<add_tl_shortcut($place, $name, $prog, $args, $batgui)> +=cut -Specify a to be added shortcut at $place (relative to -Start/Programs), with name $name, pointing to program $prog with -parameters $args (a string). $place can also be the string -'Desktop'. Use a non-null batgui parameter if the shortcut starts a -gui program via a batchfile. Then the inevitable command prompt will -be hidden rightaway, leaving only the gui program visible. +sub desktop_path() { + my ($shell_key, $deskpath); + if (admin()) { + $shell_key = $Registry->Open( + "LMachine/software/microsoft/windows/currentversion/explorer/shell folders/", + {Access => KEY_READ}); + $deskpath = $shell_key -> {"/Common Desktop"}; + } else { + $shell_key = $Registry->Open( + "CUser/software/microsoft/windows/currentversion/explorer/shell folders/", + {Access => KEY_READ}); + $deskpath = $shell_key -> {"/Desktop"}; + } + $deskpath =~ s!\\!/!g; + return $deskpath; +} + +sub menu_path() { + my ($shell_key, $menupath); + if (admin()) { + $shell_key = $Registry->Open( + "LMachine/software/microsoft/windows/currentversion/explorer/shell folders/", + {Access => KEY_READ}); + $menupath = $shell_key -> {"/Common Programs"}; + } else { + $shell_key = $Registry->Open( + "CUser/software/microsoft/windows/currentversion/explorer/shell folders/", + {Access => KEY_READ}); + $menupath = $shell_key -> {"/Programs"}; + } + $menupath =~ s!\\!/!g; + return $menupath; +} + +=pod + +=item C<add_desktop_shortcut($texdir, $name, $icon, + $prog, $args, $batgui)> + +Add a desktop shortcut, with name $name and icon $icon, pointing to +program $prog with parameters $args (a string). Use a non-null +batgui parameter if the shortcut starts a gui program via a +batchfile. Then the inevitable command prompt will be hidden +rightaway, leaving only the gui program visible. + +The parameter $texdir is merely used to locate the batchfile +unshort.bat for uninstalling desktop shortcuts, which needs to be +updated. =cut -#my @shortcuts = (); +sub add_desktop_shortcut { + my ($texdir, $name, $icon, $prog, $args, $batgui) = @_; + + # create shortcut + my ($shc, $shpath, $shfile); + $shc = new Win32::Shortcut(); + $shc->{'IconLocation'} = $icon; + $shc->{'Path'} = $prog; + $shc->{'Arguments'} = $args; + $shc->{'ShowCmd'} = SW_SHOWMINNOACTIVE if $batgui; + $shfile = desktop_path().'/'.$name.'.lnk'; + $shc->Save($shfile); + + # update batchfile for uninstalling shortcuts + open UNSHORT, ">>$texdir/tlpkg/installer/unshort.bat"; + $shfile =~ s!/!\\!g; + print UNSHORT 'del "'.$shfile."\" 2>nul\n"; + close UNSHORT; +} + +=cut -sub add_tl_shortcut { - my ($place, $name, $prog, $args, $batgui) = @_; +=pod + +=item C<add_menu_shortcut($place, $name, $icon, + $prog, $args, $batgui)> + +Add a menu shortcut at place $place (relative to Start/Programs), +with name $name and icon $icon, pointing to program $prog with +parameters $args. See above for batgui. + +=cut + +sub add_menu_shortcut { + my ($place, $name, $icon, $prog, $args, $batgui) = @_; $place =~ s!\\!/!g; - my $newshort = { - 'place' => $place, - 'name' => $name, - 'prog' => $prog, - 'args' => $args, - 'batgui' => $batgui, - }; - push @shortcuts, $newshort; + + my ($shc, $shpath, $shfile); + $shc = new Win32::Shortcut(); + $shc->{'IconLocation'} = $icon; + $shc->{'Path'} = $prog; + $shc->{'Arguments'} = $args; + $shc->{'ShowCmd'} = SW_SHOWMINNOACTIVE if $batgui; + $shpath = $place; + $shpath =~ s!\\!/!g; + $shpath = '/'.$shpath unless $shpath =~ m!^/!; + $shpath = menu_path().$shpath; + if ((-e $shpath) and not (-d $shpath)) { + next; # fail silently and don't worry about it + } elsif (not (-d $shpath)) { + return unless mkdirhier ($shpath); + } + $shfile = $shpath.'/'.$name.'.lnk'; + $shc->Save($shfile); } =pod -=item C<clear_unshortbat> +=item C<init_unshortbat($texdir)> -Delete any existing shortcut remover. +Reinitialize unshort.bat, the shortcuts uninstaller. =cut -sub clear_unshortbat { - my $td = shift; - unlink $td.'/tlpkg/installer/unshort.bat'; +sub init_unshortbat { + my $texdir = shift; + my $menupath = menu_path(); + $menupath =~ s!/!\\!g; + + # batchfile for uninstalling shortcuts + open UNSHORT, ">$texdir/tlpkg/installer/unshort.bat"; + print UNSHORT 'rmdir /s /q "'.$menupath."\\TeXLive\" 2>nul\n"; + close UNSHORT; } =cut =pod -=item C<make_tl_shortcuts> +=item C<remove_desktop_shortcut($name)> -This one does the actual shortcut creation. +For uninstallation of an individual package. We leave unshort.bat +alone because redundant entries are no big deal. =cut -sub make_tl_shortcuts { - return if $#shortcuts < 0; +sub remove_desktop_shortcut { + my $name = shift; + unlink desktop_path().'/'.$name.'.lnk'; +} - # TEXDIR - my $tdfw = shift; - $tdfw =~ s![\\/]$!!; - my $td = $tdfw; - $td =~ s!/!\\!g; +=cut - # batchfile for uninstalling shortcuts - open UNSHORT, ">>$tdfw/tlpkg/installer/unshort.bat"; +=pod - # desktop- and menu directories - my ($shell_key, $shortpath, $deskpath); - if (admin()) { - $shell_key = $Registry->Open( - "LMachine/software/microsoft/windows/currentversion/explorer/shell folders/", - {Access => KEY_READ}); - $deskpath = $shell_key -> {"/Common Desktop"}; - $shortpath = $shell_key -> {"/Common Programs"}; - } else { - $shell_key = $Registry->Open( - "CUser/software/microsoft/windows/currentversion/explorer/shell folders/", - {Access => KEY_READ}); - $deskpath = $shell_key -> {"/Desktop"}; - $shortpath = $shell_key -> {"/Programs"}; - } - my $deskpathfw = $deskpath; $deskpathfw =~ s!\\!/!g; - my $shortpathfw = $shortpath; $shortpathfw =~ s!\\!/!g; - - my @desktop_shortcuts = (); - - foreach my $s (@shortcuts) { - my ($shc, $shpath, $shfile); - $shc = new Win32::Shortcut(); - $shc->{'Path'} = $s->{'prog'}; - $shc->{'Arguments'} = $s->{'args'}; - $shc->{'ShowCmd'} = SW_SHOWMINNOACTIVE if $s->{'batgui'}; - if ($s->{'place'} =~ 'Desktop') { - $shfile = $deskpathfw.'/'.$s->{'name'}.'.lnk'; - $shc->Save($shfile); - $shfile =~ s!/!\\!g; - print UNSHORT 'del "'.$shfile."\" 2>nul\n"; - } else { - $shpath = $s->{'place'}; - $shpath =~ s!\\!/!g; - $shpath = '/'.$shpath unless $shpath =~ m!^/!; - $shpath = $shortpathfw . $shpath; - $shfile = $shpath.'/'.$s->{'name'}.'.lnk'; - if ((-e $shpath) and not (-d $shpath)) { - next; # fail silently and don't worry about it - } elsif (not (-d $shpath)) { - mkdirhier ($shpath); - } - $shc->Save($shfile); - } - } - print UNSHORT 'rmdir /s /q "'.$shortpath."\\TeXLive\" 2>nul\n"; - close UNSHORT; +=item C<remove_menu_shortcut($place, $name)> + +For uninstallation of an individual package. + +=cut + +sub remove_menu_shortcut { + my $place = shift; + my $name = shift; + $place =~ s!\\!/!g; + $place = '/'.$place unless $place =~ m!^/!; + unlink menu_path().$place.'/'.$name.'.lnk'; } =pod |