Code: Select all
#!/usr/bin/perl
use strict;
# Main project file name.
my $main_pb = 'main.pb';
# Visual Designer's project file.
my $common_pb = 'Common.pb';
# Poor man's dos2unix.
system "/usr/bin/perl", "-pi", '-e', 's/\r\n/\n/g', $main_pb, $common_pb;
my $common;
my $inside_balloontip = undef;
my $balloontip_src;
open COMMON, "< $common_pb"
or die "Error: Unable to open common file: $common_pb: $!\n";
while (my $line = <COMMON>) {
if ($line =~ m/^Procedure BalloonTip/) {
$inside_balloontip = 1;
$balloontip_src .= $line;
$balloontip_src .= "\n\tCompilerIf #PB_Compiler_OS = #PB_OS_Windows\n";
next;
}
if ($inside_balloontip) {
if ($line =~ m/^EndProcedure/) {
my $balloontip_otheros =<<OTHEROS;
CompilerElse
GadgetToolTip(Gadget, Text\$)
CompilerEndIf
OTHEROS
$common .= $balloontip_src . $balloontip_otheros . "\n$line";
$inside_balloontip = undef;
} else {
$balloontip_src .= "\t$line";
}
next;
}
# Uncomment this line to turn a Frame3DGadget (given id #Calendar) in
# your source into a CalendarGadget. This way you can place it using the
# Visual Designer even though it doesn't support calendar gadgets.
# $line =~ s/^(\s*)Frame3DGadget(\(#Calendar)/${1}CalendarGadget$2/;
$common .= $line;
}
close COMMON;
open COMMON, "> $common_pb"
or die "Error: Unable to open Common file for writing: $common_pb: $!\n";
print COMMON $common;
close COMMON;

