summaryrefslogtreecommitdiff
path: root/Master/tlpkg/TeXLive/TLWinGoo.pm
diff options
context:
space:
mode:
authorSiep Kroonenberg <siepo@cybercomm.nl>2008-05-15 09:41:16 +0000
committerSiep Kroonenberg <siepo@cybercomm.nl>2008-05-15 09:41:16 +0000
commit2fd99762c5a0bb67a16df56cc53cebe999758fcc (patch)
tree511632004a37a45def3f20be615429e2e64a40f0 /Master/tlpkg/TeXLive/TLWinGoo.pm
parentc84607c998889966cc0fbefa09774fd70e17688a (diff)
Support for Windows shortcuts; demo shortcuts in install-tl
git-svn-id: svn://tug.org/texlive/trunk@8153 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg/TeXLive/TLWinGoo.pm')
-rw-r--r--Master/tlpkg/TeXLive/TLWinGoo.pm196
1 files changed, 144 insertions, 52 deletions
diff --git a/Master/tlpkg/TeXLive/TLWinGoo.pm b/Master/tlpkg/TeXLive/TLWinGoo.pm
index 7917a7fb651..5b54aa89e66 100644
--- a/Master/tlpkg/TeXLive/TLWinGoo.pm
+++ b/Master/tlpkg/TeXLive/TLWinGoo.pm
@@ -5,7 +5,7 @@
# This file is licensed under the GNU General Public License version 2
# or any later version.
-# code for broadcast_env adopted from Win32::Env:
+# code for broadcast_env adapted from Win32::Env:
# Copyright 2006 Oleg "Rowaa[SR13]" V. Volkov, all rights reserved.
# This program is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
@@ -47,14 +47,23 @@ C<TeXLive::TLWinGoo> -- Additional utilities for Windows
TeXLive::TLWinGoo::remove_texbindirs_from_path;
TeXLive::TLWinGoo::register_script_type($extension, $command);
TeXLive::TLWinGoo::unregister_script_type($extension);
- TeXLive::TLWinGoo::create_uninstaller;
- TeXLive::TLWinGoo::unregister_uninstaller;
=head2 ACTIVATING CHANGES IMMEDIATELY
TeXLive::TLWinGoo::broadcast_env;
TeXLive::TLWinGoo::update_assocs;
+=head2 SHORTCUTS
+
+ TeXLive::TLWinGoo::add_tl_shortcut($place, $name, $prog, $args, $batgui);
+ TeXLive::TLWinGoo::clear_unshortbat($texdir);
+ TeXLive::TLWinGoo::make_tl_shortcuts($texdir);
+
+=head2 UNINSTALLER
+
+ TeXLive::TLWinGoo::create_uninstaller;
+ TeXLive::TLWinGoo::unregister_uninstaller;
+
All exported functions return forward slashes.
=head2 DESCRIPTION
@@ -87,6 +96,9 @@ BEGIN {
&unregister_script_type
&broadcast_env
&update_assocs
+ &add_tl_shortcut
+ &clear_unshortbat
+ &make_tl_shortcuts
&create_uninstaller
&unregister_uninstaller
);
@@ -99,8 +111,6 @@ BEGIN {
&global_tmpdir
);
if ($^O=~/^MSWin(32|64)$/i) {
- #require Win32;
- #Win32->import( qw( GetOSVersion ) );
require Win32::API;
require Win32::TieRegistry;
Win32::TieRegistry->import( qw( $Registry
@@ -109,10 +119,13 @@ BEGIN {
$Registry->Delimiter('/');
$Registry->ArrayValues(0);
$Registry->FixSzNulls(1);
+ require Win32::Shortcut;
+ Win32::Shortcut->import( qw( SW_SHOWNORMAL SW_SHOWMINNOACTIVE ) );
}
}
use TeXLive::TLUtils;
+TeXLive::TLUtils->import( qw( mkdirhier ) );
my $is_win = $^O=~/^MSWin(32|64)$/i;
@@ -626,11 +639,15 @@ sub reg_delete_recurse {
=item C<register_script_type($extension, $command)>
-Add registry entries to associate $extension with $command and make
-$extension an executable file type. Slashes are flipped where necessary.
+Add registry entries to associate $extension with $command. Slashes
+are flipped where necessary.
=cut
+# todo:
+# split ftype and assoc
+# non-admin: add to startup script
+
sub register_script_type {
my $extension = shift;
$extension = '.'.$extension unless $extension =~ /^\./; # ensure leading dot
@@ -716,50 +733,8 @@ sub unregister_script_type {
$extension = '.'.$extension unless $extension =~ /^\./; # ensure leading dot
$extension = uc($extension);
tllog ($::LOG_DDEBUG, "unregistering $extension\n");
- my $user_env = get_user_env();
- my $system_env = get_system_env();
- my ($pathext, @newpe, $newpex, $e);
-
- # pathext
- if (!$::opt_portable) {
- tllog ($::LOG_DDEBUG, "Reverting PATHEXT\n");
- if ($is_admin) {
- $pathext = $system_env -> {'/PATHEXT'};
- @newpe = ();
- foreach $e (split(/;/,$pathext)) {
- push @newpe, $e unless (uc($e) eq $extension);
- }
- $newpex = join(";",@newpe);
- setenv_reg("PATHEXT", $newpex, "system");
-
- $pathext = $user_env -> {'/PATHEXT'};
- if ($pathext) {
- @newpe = ();
- foreach $e (split(/;/,$pathext)) {
- push @newpe, $e unless (uc($e) eq $extension);
- }
- $newpex = join(";",@newpe);
- if ($newpex eq ($system_env -> {"/PATHEXT"})) {
- unsetenv_reg("PATHEXT", "user");
- } else {
- setenv_reg("PATHEXT", $newpex, "user");
- }
- }
- } else {
- $pathext = $user_env -> {'/PATHEXT'};
- $pathext = $system_env -> {'/PATHEXT'} unless $pathext;
- @newpe = ();
- foreach $e (split(/;/,$pathext)) {
- push @newpe, $e unless (uc($e) eq $extension);
- }
- $newpex = join(";",@newpe);
- if ($newpex eq ($system_env -> {"/PATHEXT"})) {
- unsetenv_reg("PATHEXT", "user");
- } else {
- setenv_reg("PATHEXT", $newpex, "user");
- }
- }
- }
+ #my $user_env = get_user_env();
+ #my $system_env = get_system_env();
# file type
tllog ($::LOG_DDEBUG, "Deleting texlua filetype\n");
@@ -837,6 +812,122 @@ sub update_assocs() {
=pod
+=head2 SHORTCUTS
+
+=item C<add_tl_shortcut($place, $name, $prog, $args, $batgui)>
+
+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.
+
+=cut
+
+#my @shortcuts = ();
+
+sub add_tl_shortcut {
+ my ($place, $name, $prog, $args, $batgui) = @_;
+ $place =~ s!\\!/!g;
+ my $newshort = {
+ 'place' => $place,
+ 'name' => $name,
+ 'prog' => $prog,
+ 'args' => $args,
+ 'batgui' => $batgui,
+ };
+ push @shortcuts, $newshort;
+}
+
+=pod
+
+=item C<clear_unshortbat>
+
+Delete any existing shortcut remover.
+
+=cut
+
+sub clear_unshortbat {
+ my $td = shift;
+ unlink $td.'/tlpkg/installer/unshort.bat';
+}
+
+=cut
+
+=pod
+
+=item C<make_tl_shortcuts>
+
+This one does the actual shortcut creation.
+
+=cut
+
+sub make_tl_shortcuts {
+ return if $#shortcuts < 0;
+
+ # TEXDIR
+ my $tdfw = shift;
+ $tdfw =~ s![\\/]$!!;
+ my $td = $tdfw;
+ $td =~ s!/!\\!g;
+
+ # batchfile for uninstalling shortcuts
+ open UNSHORT, ">>$tdfw/tlpkg/installer/unshort.bat";
+
+ # 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;
+}
+
+=pod
+
+=head2 UNINSTALLER
+
=item C<create_uninstaller>
Writes registry entries for add/remove programs which reference
@@ -846,7 +937,7 @@ the job.
=cut
sub create_uninstaller {
- my $tdfw = shift;
+ my $tdfw = shift; # TEXDIR
$tdfw =~ s![\\/]$!!;
my $td = $tdfw;
$td =~ s!/!\\!g;
@@ -865,6 +956,7 @@ sub create_uninstaller {
\@echo off
set PERL5LIB=
\"$td\\tlpkg\\tlperl\\bin\\perl.exe\" \"$td\\texmf\\scripts\\texlive\\uninstall-win32.pl\"
+call \"$td\\tlpkg\\installer\\unshort.bat\"
copy \"$td\\tlpkg\\installer\\uninst2.bat\" \"\%TEMP\%\"
\"\%TEMP\%\\uninst2.bat\"
UNEND