Thread Druckdialog in MacOs X (8 answers)
Opened by Spieler at 2007-10-24 17:54

ptk
 2007-10-25 23:17
#101354 #101354
User since
2003-11-28
3645 Artikel
ModeratorIn
[default_avatar]
Hier ist es. Das Argument in der Zeile durch ein gültiges Pod bei dir ersetzen.

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
main->_print_pod_unix("/usr/local/lib/perl5/5.8.8/pod/perl.pod");

sub _print_pod_unix {
my($w, $path) = @_;
if (is_in_path("pod2man") && is_in_path("groff")) {
my $pod2ps_pipe = "pod2man $path | groff -man -Tps";

if ($^O eq 'darwin') {
my $cmd = "$pod2ps_pipe | /usr/bin/open -a Preview -f";
system($cmd) == 0
or $w->_die_dialog("Error while executing <$cmd>. Status code is $?");
return 1;
}

# XXX maybe determine user's environment (GNOME vs. KDE vs. plain X11)?
my $gv = is_in_path("gv")
|| is_in_path("ghostview")
|| is_in_path("ggv") # newer versions seem to work
|| is_in_path("kghostview");
if ($gv) {
# $w->_need_File_Temp;
use File::Temp;

my($fh,$fname) = File::Temp::tempfile(SUFFIX => ".ps");
system("$pod2ps_pipe > $fname");
push @tempfiles, $fname;
my $pid = fork;
if (!defined $pid) {
die "Can't fork: $!";
}
if ($pid == 0) {
exec($gv, $fname);
warn "Exec of $gv $fname failed: $!";
CORE::exit(1);
}
push @gv_pids, $pid;
return 1;
}
}
return 0;
}

sub is_in_path {
my($prog) = @_;
require Config;
my $sep = $Config::Config{'path_sep'} || ':';
foreach (split(/$sep/o, $ENV{PATH})) {
if ($^O eq 'MSWin32') {
return "$_\\$prog"
if (-x "$_\\$prog.bat" ||
-x "$_\\$prog.com" ||
-x "$_\\$prog.exe" ||
-x "$_\\$prog.cmd"
);
} else {
return "$_/$prog" if (-x "$_/$prog" && !-d "$_/$prog");
}
}
undef;
}

View full thread Druckdialog in MacOs X