| 1 | package Glade::Two::Source; | ||
| 2 | require 5.000; use strict 'vars', 'refs', 'subs'; | ||
| 3 | |||
| 4 | # Copyright (c) 1999 Dermot Musgrove <dermot.musgrove@virgin.net> | ||
| 5 | # | ||
| 6 | # This library is released under the same conditions as Perl, that | ||
| 7 | # is, either of the following: | ||
| 8 | # | ||
| 9 | # a) the GNU General Public License as published by the Free | ||
| 10 | # Software Foundation; either version 1, or (at your option) any | ||
| 11 | # later version. | ||
| 12 | # | ||
| 13 | # b) the Artistic License. | ||
| 14 | # | ||
| 15 | # If you use this library in a commercial enterprise, you are invited, | ||
| 16 | # but not required, to pay what you feel is a reasonable fee to perl.org | ||
| 17 | # to ensure that useful software is available now and in the future. | ||
| 18 | # | ||
| 19 | # (visit http://www.perl.org/ or email donors@perlmongers.org for details) | ||
| 20 | |||
| 21 | BEGIN { | ||
| 22 | use Exporter qw( ); | ||
| 23 | use Data::Dumper; | ||
| 24 | use File::Copy; # for copying generated files | ||
| 25 | use Glade::Two::Run qw( :METHODS :VARS !&_); | ||
| 26 | # Our run-time methods and vars | ||
| 27 | # but not &_ since we do that ourselves. | ||
| 28 | use File::Basename qw( basename); # in check_gettext_strings | ||
| 29 | use Text::Wrap qw( wrap $columns); # in write_gettext_strings | ||
| 30 | use File::Path qw( mkpath); # in use_Glade_Project | ||
| 31 | use vars qw( | ||
| 32 | @ISA | ||
| 33 | $PACKAGE $VERSION $AUTHOR $DATE | ||
| 34 | %fields %stubs | ||
| 35 | @EXPORT @EXPORT_OK %EXPORT_TAGS | ||
| 36 | @VARS @METHODS | ||
| 37 | $PARTYPE $LOOKUP $BOOL $MAYBE $NOT_WIDGET $NOT_PROPERTY | ||
| 38 | $DEFAULT $KEYSYM $LOOKUP_ARRAY $INT $STRING | ||
| 39 | |||
| 40 | $IGNORED_WIDGET | ||
| 41 | $NO_SUCH_WIDGET | ||
| 42 | $INTERNAL_CHILD | ||
| 43 | $UNUSED_PROPERTIES | ||
| 44 | $FIRST_PANE_FULL | ||
| 45 | $CONNECT_ID | ||
| 46 | $USES | ||
| 47 | $MISSING_METHODS | ||
| 48 | $HANDLERS | ||
| 49 | $DATA | ||
| 50 | |||
| 51 | $widgets | ||
| 52 | $data | ||
| 53 | $forms | ||
| 54 | $work | ||
| 55 | |||
| 56 | $handlers | ||
| 57 | $need_handlers | ||
| 58 | $autosubs | ||
| 59 | $subs | ||
| 60 | |||
| 61 | $radiobuttons | ||
| 62 | $radiomenuitems | ||
| 63 | $current_data | ||
| 64 | $current_name | ||
| 65 | $current_form | ||
| 66 | $current_form_name | ||
| 67 | $current_window | ||
| 68 | $current_widget | ||
| 69 | $first_form | ||
| 70 | $init_string | ||
| 71 | $failures | ||
| 72 | $Gtk | ||
| 73 | ); | ||
| 74 | $PACKAGE = __PACKAGE__; | ||
| 75 | $VERSION = q(0.01); | ||
| 76 | $AUTHOR = q(Dermot Musgrove <dermot.musgrove@virgin.net>); | ||
| 77 | $DATE = q(Sun Nov 17 06:02:01 GMT 2002 ); | ||
| 78 | @VARS = qw( | ||
| 79 | $PARTYPE $LOOKUP $BOOL $MAYBE $NOT_WIDGET $NOT_PROPERTY | ||
| 80 | $DEFAULT $KEYSYM $LOOKUP_ARRAY $INT $STRING | ||
| 81 | |||
| 82 | $IGNORED_WIDGET | ||
| 83 | $NO_SUCH_WIDGET | ||
| 84 | $INTERNAL_CHILD | ||
| 85 | $UNUSED_PROPERTIES | ||
| 86 | $FIRST_PANE_FULL | ||
| 87 | $CONNECT_ID | ||
| 88 | $USES | ||
| 89 | $MISSING_METHODS | ||
| 90 | $HANDLERS | ||
| 91 | $DATA | ||
| 92 | $WIDGET_INSTANCE | ||
| 93 | $RUN_LANG | ||
| 94 | $SOURCE_LANG | ||
| 95 | $DIAG_LANG | ||
| 96 | $CH | ||
| 97 | $WH | ||
| 98 | $C | ||
| 99 | $W | ||
| 100 | |||
| 101 | $Glade_Perl | ||
| 102 | $widgets | ||
| 103 | $data | ||
| 104 | $forms | ||
| 105 | $work | ||
| 106 | |||
| 107 | $convert | ||
| 108 | $handlers | ||
| 109 | $need_handlers | ||
| 110 | $autosubs | ||
| 111 | $subs | ||
| 112 | @use_modules | ||
| 113 | $NOFILE | ||
| 114 | $indent | ||
| 115 | $tab | ||
| 116 | |||
| 117 | $radiobuttons | ||
| 118 | $radiomenuitems | ||
| 119 | $current_data | ||
| 120 | $current_name | ||
| 121 | $current_form | ||
| 122 | $current_form_name | ||
| 123 | $current_window | ||
| 124 | $current_widget | ||
| 125 | $first_form | ||
| 126 | $init_string | ||
| 127 | |||
| 128 | $permitted_fields | ||
| 129 | $failures | ||
| 130 | $Gtk | ||
| 131 | ); | ||
| 132 | @METHODS = qw( | ||
| 133 | add_to_UI | ||
| 134 | _ | ||
| 135 | S_ | ||
| 136 | D_ | ||
| 137 | start_checking_gettext_strings | ||
| 138 | create_image | ||
| 139 | create_pixmap | ||
| 140 | missing_handler | ||
| 141 | message_box | ||
| 142 | message_box_close | ||
| 143 | show_skeleton_message | ||
| 144 | &typeKey | ||
| 145 | &keyFormat | ||
| 146 | &QuoteXMLChars | ||
| 147 | &UnQuoteXMLChars | ||
| 148 | reload_any_altered_modules | ||
| 149 | ); | ||
| 150 | $subs = ''; | ||
| 151 | $autosubs = ' destroy_Form about_Form '. | ||
| 152 | ' toplevel_hide toplevel_close toplevel_destroy '; | ||
| 153 | $LOOKUP = 2; | ||
| 154 | $BOOL = 4; | ||
| 155 | $INT = 8; | ||
| 156 | $STRING = 16; | ||
| 157 | $DEFAULT = 32; | ||
| 158 | $KEYSYM = 64; | ||
| 159 | $LOOKUP_ARRAY = 128; | ||
| 160 | $MAYBE = 256; | ||
| 161 | $NOT_WIDGET = 512; | ||
| 162 | $NOT_PROPERTY = 1024; | ||
| 163 | # Tell interpreter who we are inheriting from | ||
| 164 | @ISA = qw( | ||
| 165 | Exporter | ||
| 166 | Glade::Two::Run | ||
| 167 | ); | ||
| 168 | # These symbols (globals and functions) are always exported | ||
| 169 | @EXPORT = qw( ); | ||
| 170 | # Optionally exported package symbols (globals and functions) | ||
| 171 | @EXPORT_OK = ( @VARS, @METHODS); | ||
| 172 | # Tags (groups of symbols) to export | ||
| 173 | %EXPORT_TAGS = ( 'METHODS' => [@METHODS], | ||
| 174 | 'VARS' => [@VARS] ); | ||
| 175 | } | ||
| 176 | |||
| 177 | %fields = ( | ||
| 178 | # Insert any extra data access methods that you want to add to | ||
| 179 | # our inherited super-constructor (or overload) | ||
| 180 | USERDATA => undef, | ||
| 181 | ); | ||
| 182 | |||
| 183 | sub DESTROY { | ||
| 184 | # This sub will be called on object destruction | ||
| 185 | } # End of sub DESTROY | ||
| 186 | |||
| 187 | #=============================================================================== | ||
| 188 | #=========== Utilities to write output file ============ | ||
| 189 | #=============================================================================== | ||
| 190 | sub log_error { | ||
| 191 | my ($class, $expr, $fail, $really_die) = @_; | ||
| 192 | |||
| 193 | $really_die and die "\n\n\twhile trying to eval". | ||
| 194 | "'$expr'\n\tFAILED with Eval error '$fail'\n"; | ||
| 195 | my $form = $current_form; | ||
| 196 | $form =~ s/\$/\\\$/; | ||
| 197 | $fail =~ s/\n.*//g; | ||
| 198 | $fail =~ s/@INC.*/.../g; | ||
| 199 | $expr =~ s/($form|\$widgets->)/.../g unless $really_die; | ||
| 200 | my $call = $expr; | ||
| 201 | $call =~ s/.*?->//; | ||
| 202 | $call =~ s/(\(|->).*//; | ||
| 203 | $call =~ s/.*\{.*\} *= *//; | ||
| 204 | print "FAIL - '$expr' got '$fail'" if $really_die; | ||
| 205 | $Glade_Perl->diag_print (1, "FAIL '$expr' got '$fail'"); | ||
| 206 | if ($fail =~ /^Can't locate /) { | ||
| 207 | $failures->{$current_widget}{$MISSING_METHODS}{$call}++; | ||
| 208 | } else { | ||
| 209 | $failures->{$current_widget}{$call}{'calls'}++; | ||
| 210 | $failures->{$current_widget}{$call}{'expr'} = $expr; | ||
| 211 | $failures->{$current_widget}{$call}{'fail'} = $fail; | ||
| 212 | } | ||
| 213 | } | ||
| 214 | |||
| 215 | sub add_to_UI { | ||
| 216 | my ($class, $depth, $expr, $tofileonly, $notabs, $really_die) = @_; | ||
| 217 | my $me = (ref $class||$class)."->add_to_UI"; | ||
| 218 | my $mydebug = ($Glade_Perl->verbosity >= 3); | ||
| 219 | my $error_comment = ''; | ||
| 220 | if ($depth < 0) { | ||
| 221 | $mydebug = 1; | ||
| 222 | $depth = -$depth; | ||
| 223 | } | ||
| 224 | if ($mydebug) { | ||
| 225 | my $call = $expr; | ||
| 226 | $call =~ s/\%/\%\%/g; | ||
| 227 | $Glade_Perl->diag_print (2, "UI%s'%s'", $indent, $call); | ||
| 228 | } | ||
| 229 | unless ($Glade_Perl->source->quick_gen or $tofileonly) { | ||
| 230 | eval $expr; | ||
| 231 | } | ||
| 232 | if ($@) { | ||
| 233 | $class->log_error($expr, $@, $really_die); | ||
| 234 | # ($@ && die "\n\nin $me\n\twhile trying to eval". | ||
| 235 | # "'$expr'\n\tFAILED with Eval error '$@'\n"); | ||
| 236 | # return unless $Glade_Perl->source->with_errors; | ||
| 237 | $error_comment = "#" unless $Glade_Perl->source->with_errors; | ||
| 238 | } | ||
| 239 | if ($Glade_Perl->Writing_to_File) { | ||
| 240 | my $UI_String = $error_comment.($indent x ($depth)).$expr; | ||
| 241 | if (!$notabs && $tab) { | ||
| 242 | # replace multiple spaces with tabs | ||
| 243 | $UI_String =~ s/$tab/\t/g; | ||
| 244 | } | ||
| 245 | eval "push \@{${current_form}\{'UI_Strings'}}, \$UI_String"; | ||
| 246 | } | ||
| 247 | } | ||
| 248 | |||
| 249 | #=============================================================================== | ||
| 250 | #=========== Documentation files | ||
| 251 | #=============================================================================== | ||
| 252 | sub write_documentation { | ||
| 253 | my ($class, $force) = @_; | ||
| 254 | return unless $class->doc->write; | ||
| 255 | my $me = __PACKAGE__."->write_documentation"; | ||
| 256 | my ($string, $file); | ||
| 257 | my $count = 0; | ||
| 258 | |||
| 259 | # $class->doc->directory($class->full_Path( | ||
| 260 | # $class->doc->directory, $class->glade->directory)); | ||
| 261 | # | ||
| 262 | # if ($class->doc->directory ne $class->glade->directory) { | ||
| 263 | # unless (-d $class->doc->directory) { | ||
| 264 | # # Source directory does not exist yet so create it | ||
| 265 | # $Glade_Perl->diag_print (2, "%s- Creating documentation directory '%s' in %s", | ||
| 266 | # $indent, $class->doc->directory, $me); | ||
| 267 | # mkpath($class->doc->directory); | ||
| 268 | # } | ||
| 269 | # } | ||
| 270 | #print Dumper($class->doc); | ||
| 271 | for $file (sort keys %{$class->doc}) { | ||
| 272 | next unless $force || $class->doc->{$file}; | ||
| 273 | unless ("*$permitted_fields*directory*write*" =~ /\*$file\*/) { | ||
| 274 | $class->doc->{$file} = $class->full_Path( | ||
| 275 | $class->doc->{$file}, | ||
| 276 | $class->doc->directory); | ||
| 277 | if ($force || !-f $class->doc->{$file}) { | ||
| 278 | $class->diag_print(2, "%s- Generating documentation file '%s'", | ||
| 279 | $class->source->indent, $class->doc->{$file}); | ||
| 280 | eval "\$string = \$class->doc_$file"; | ||
| 281 | if ($@) { | ||
| 282 | print "\$string = \$class->doc_$file failed: $@\n"; | ||
| 283 | } else { | ||
| 284 | $class->save_file_from_string($class->doc->{$file}, $string); | ||
| 285 | } | ||
| 286 | $count++; | ||
| 287 | if ($class->verbosity >= 4) { | ||
| 288 | print "-----------------------------\n". | ||
| 289 | "$string\n-----------------------------\n"; | ||
| 290 | } | ||
| 291 | } | ||
| 292 | } | ||
| 293 | } | ||
| 294 | return $count; | ||
| 295 | } | ||
| 296 | |||
| 297 | sub doc_COPYING { | ||
| 298 | my ($class) = @_; | ||
| 299 | return $Glade_Perl->app->copying; | ||
| 300 | } | ||
| 301 | |||
| 302 | sub doc_Changelog { | ||
| 303 | my ($class) = @_; | ||
| 304 | return "Revision history for Glade-Perl application '".$Glade_Perl->app->name."' | ||
| 305 | -------------------------------------------------------------------- | ||
| 306 | |||
| 307 | ".$class->run_options->start_time." - ".$class->app->author." | ||
| 308 | ".$class->source->indent."- version ".$class->app->version. | ||
| 309 | " - This file was created by ".__PACKAGE__."\n"; | ||
| 310 | } | ||
| 311 | |||
| 312 | sub doc_FAQ { | ||
| 313 | my ($class) = @_; | ||
| 314 | return "Frequently Asked Questions about Glade-Perl application '".$Glade_Perl->app->name."' | ||
| 315 | -------------------------------------------------------------------- | ||
| 316 | |||
| 317 | |||
| 318 | ".$class->run_options->start_time." - ".$class->app->author." | ||
| 319 | ".$class->source->indent."- version ".$class->app->version. | ||
| 320 | " - This file was created by ".__PACKAGE__."\n"; | ||
| 321 | } | ||
| 322 | |||
| 323 | sub doc_INSTALL { | ||
| 324 | my ($class) = @_; | ||
| 325 | return "How to install Glade-Perl application '".$Glade_Perl->app->name."' | ||
| 326 | -------------------------------------------------------------------- | ||
| 327 | |||
| 328 | TO INSTALL | ||
| 329 | ---------- | ||
| 330 | There is a standard Makefile.PL to handle some checks and install the package | ||
| 331 | |||
| 332 | To install | ||
| 333 | perl Makefile.PL | ||
| 334 | make | ||
| 335 | make test | ||
| 336 | su | ||
| 337 | make install (if test was OK) | ||
| 338 | |||
| 339 | TO BUILD RPMS | ||
| 340 | ------------- | ||
| 341 | Build the RPMs by calling eg. | ||
| 342 | rpm -ta ".$class->app->name."-".$class->app->version.".tar.gz | ||
| 343 | |||
| 344 | |||
| 345 | ".$class->run_options->start_time." - ".$class->app->author." | ||
| 346 | ".$class->source->indent."- version ".$class->app->version. | ||
| 347 | " - This file was created by ".__PACKAGE__." | ||
| 348 | "; | ||
| 349 | } | ||
| 350 | |||
| 351 | sub doc_NEWS { | ||
| 352 | my ($class) = @_; | ||
| 353 | return "NEWS about Glade-Perl application '".$Glade_Perl->app->name."' | ||
| 354 | -------------------------------------------------------------------- | ||
| 355 | |||
| 356 | |||
| 357 | ".$class->run_options->start_time." - ".$class->app->author." | ||
| 358 | ".$class->source->indent."- version ".$class->app->version. | ||
| 359 | " - This file was created by ".__PACKAGE__."\n"; | ||
| 360 | } | ||
| 361 | |||
| 362 | sub doc_README { | ||
| 363 | my ($class) = @_; | ||
| 364 | return "Introduction to Glade-Perl application '".$Glade_Perl->app->name."' | ||
| 365 | -------------------------------------------------------------------- | ||
| 366 | |||
| 367 | ".$class->app->description." | ||
| 368 | |||
| 369 | |||
| 370 | ".$class->run_options->start_time." - ".$class->app->author." | ||
| 371 | ".$class->source->indent."- version ".$class->app->version. | ||
| 372 | " - This file was created by ".__PACKAGE__." | ||
| 373 | "; | ||
| 374 | } | ||
| 375 | |||
| 376 | sub doc_ROADMAP { | ||
| 377 | my ($class) = @_; | ||
| 378 | return "ROADMAP for Glade-Perl application '".$Glade_Perl->app->name."' | ||
| 379 | -------------------------------------------------------------------- | ||
| 380 | |||
| 381 | |||
| 382 | ".$class->run_options->start_time." - ".$class->app->author." | ||
| 383 | ".$class->source->indent."- version ".$class->app->version. | ||
| 384 | " - This file was created by ".__PACKAGE__."\n"; | ||
| 385 | } | ||
| 386 | |||
| 387 | sub doc_TODO { | ||
| 388 | my ($class) = @_; | ||
| 389 | return "Things to do for Glade-Perl application '".$Glade_Perl->app->name."' | ||
| 390 | -------------------------------------------------------------------- | ||
| 391 | |||
| 392 | |||
| 393 | ".$class->run_options->start_time." - ".$class->app->author." | ||
| 394 | ".$class->source->indent."- version ".$class->app->version. | ||
| 395 | " - This file was created by ".__PACKAGE__."\n"; | ||
| 396 | } | ||
| 397 | |||
| 398 | #=============================================================================== | ||
| 399 | #=========== Distribution files | ||
| 400 | #=============================================================================== | ||
| 401 | sub write_distribution { | ||
| 402 | my ($class, $force) = @_; | ||
| 403 | return unless $class->dist->write; | ||
| 404 | my $me = __PACKAGE__."::write_distribution"; | ||
| 405 | my ($string, $file); | ||
| 406 | my $exec_mode = 0755; | ||
| 407 | my $count = 0; | ||
| 408 | |||
| 409 | $class->dist->spec($class->full_Path( | ||
| 410 | ($class->dist->spec || $class->app->name.".spec"), | ||
| 411 | $class->glade->directory)); | ||
| 412 | |||
| 413 | if ($class->dist->directory ne $class->glade->directory) { | ||
| 414 | unless (-d $class->dist->directory) { | ||
| 415 | # Source directory does not exist yet so create it | ||
| 416 | $Glade_Perl->diag_print (2, "%s- Creating distribution '%s' in %s", | ||
| 417 | $indent, $class->dist->directory, $me); | ||
| 418 | mkpath($class->dist->directory); | ||
| 419 | } | ||
| 420 | } | ||
| 421 | $class->dist->spec($class->app->name.".spec"); | ||
| 422 | for $file (sort keys %{$class->dist}) { | ||
| 423 | next unless $force || $class->dist->{$file}; | ||
| 424 | unless ("*$permitted_fields*directory*write*type*compress*scripts*docs*bin_directory*test_directory*" =~ /\*$file\*/) { | ||
| 425 | $class->dist->{$file} = $class->full_Path( | ||
| 426 | $class->dist->{$file}, | ||
| 427 | $class->dist->directory); | ||
| 428 | if ($force || !-f $class->dist->{$file}) { | ||
| 429 | $class->diag_print(2, "%s- Generating distribution file '%s'", | ||
| 430 | $class->source->indent, $class->dist->{$file}); | ||
| 431 | eval "\$string = \$class->dist_$file"; | ||
| 432 | if ($class->verbosity >= 4) { | ||
| 433 | print "----------------------------- $file\n". | ||
| 434 | "$string\n". | ||
| 435 | "-----------------------------\n"; | ||
| 436 | } | ||
| 437 | if ($@) { | ||
| 438 | print "\$string = \$class->dist_$file failed: $@\n"; | ||
| 439 | } else { | ||
| 440 | $class->save_file_from_string($class->dist->{$file}, $string); | ||
| 441 | } | ||
| 442 | $count++; | ||
| 443 | if ('*test_pl*bin*' =~ /\*$file\*/) { | ||
| 444 | chmod $exec_mode, $class->dist->{$file}; | ||
| 445 | } | ||
| 446 | } | ||
| 447 | } | ||
| 448 | } | ||
| 449 | return $count; | ||
| 450 | } | ||
| 451 | |||
| 452 | sub dist_MANIFEST_SKIP { | ||
| 453 | my ($class) = @_; | ||
| 454 | |||
| 455 | my $string = "\\bRCS\\b | ||
| 456 | ^MANIFEST\\. | ||
| 457 | ^Makefile\$ | ||
| 458 | \~\$ | ||
| 459 | \.html\$ | ||
| 460 | \.old\$ | ||
| 461 | ^blib/ | ||
| 462 | ^MakeMaker-\\d | ||
| 463 | pod2html | ||
| 464 | .bak\$ | ||
| 465 | SIGS.pm | ||
| 466 | "; | ||
| 467 | $string .= "\^".(basename $class->glade->file)."\n"; | ||
| 468 | if ($class->glade->proto->{project}{output_translatable_strings}) { | ||
| 469 | $string .= "\^".$class->glade->proto->{project}{translatable_strings_file}; | ||
| 470 | }; | ||
| 471 | return $string; | ||
| 472 | } | ||
| 473 | |||
| 474 | sub dist_Makefile_PL { | ||
| 475 | my ($class) = @_; | ||
| 476 | |||
| 477 | my $name = $class->module->directory; | ||
| 478 | $name =~ s|^$class->{dist}{directory}||; | ||
| 479 | $name =~ s|^/||; | ||
| 480 | |||
| 481 | my $ui_file = $class->module->ui->file; | ||
| 482 | $ui_file =~ s|^$class->{dist}{directory}||; | ||
| 483 | $ui_file =~ s|^/||; | ||
| 484 | |||
| 485 | my $exe_files = $class->relative_path( | ||
| 486 | $class->dist->bin_directory,$class->dist->bin); | ||
| 487 | |||
| 488 | return "# | ||
| 489 | # Makefile.PL for ".$class->app->name." | ||
| 490 | #".$class->source->indent."- version ".$class->app->version. | ||
| 491 | " - This file was created by ".__PACKAGE__." | ||
| 492 | # | ||
| 493 | require 5.000; | ||
| 494 | use ExtUtils::MakeMaker; | ||
| 495 | use strict; | ||
| 496 | |||
| 497 | # Last of all generate the Makefile | ||
| 498 | WriteMakefile( | ||
| 499 | 'DISTNAME' => '".$class->app->name."', | ||
| 500 | 'NAME' => '$name', | ||
| 501 | 'VERSION_FROM' => '$ui_file', | ||
| 502 | 'EXE_FILES' => [ '$exe_files' ], | ||
| 503 | 'clean' => { FILES => '\$(EXE_FILES)' }, | ||
| 504 | 'dist' => { COMPRESS => 'gzip', SUFFIX => 'gz' } | ||
| 505 | ); | ||
| 506 | |||
| 507 | package MY; | ||
| 508 | |||
| 509 | # Pass Glade-Perl version number to pod2man | ||
| 510 | sub manifypods | ||
| 511 | { | ||
| 512 | my \$self = shift; | ||
| 513 | my \$ver = \$self->{'VERSION'} || \"\"; | ||
| 514 | local(\$_) = \$self->SUPER::manifypods(\@_); | ||
| 515 | s/pod2man\\s*\$/pod2man --release ".$class->app->name."-\$ver/m; | ||
| 516 | \$_; | ||
| 517 | } | ||
| 518 | |||
| 519 | exit(0); | ||
| 520 | |||
| 521 | # End of Makefile.PL | ||
| 522 | "; | ||
| 523 | } | ||
| 524 | |||
| 525 | sub old_dist_Makefile_PL { | ||
| 526 | my ($class) = @_; | ||
| 527 | |||
| 528 | my $name = $class->module->directory; | ||
| 529 | $name =~ s|^$class->{dist}{directory}||; | ||
| 530 | $name =~ s|^/||; | ||
| 531 | |||
| 532 | my $ui_file = $class->module->ui->file; | ||
| 533 | $ui_file =~ s|^$class->{dist}{directory}||; | ||
| 534 | $ui_file =~ s|^/||; | ||
| 535 | |||
| 536 | return "# | ||
| 537 | # Makefile.PL for ".$class->app->name." | ||
| 538 | #".$class->source->indent."- version ".$class->app->version. | ||
| 539 | " - This file was created by ".__PACKAGE__." | ||
| 540 | # | ||
| 541 | require 5.000; | ||
| 542 | use ExtUtils::MakeMaker; | ||
| 543 | use strict; | ||
| 544 | |||
| 545 | #--- Configuration section --- | ||
| 546 | |||
| 547 | my \@programs_to_install = qw(".$class->dist->scripts."); | ||
| 548 | |||
| 549 | my \@need_perl_modules = ( | ||
| 550 | # Check for Gtk2::Types rather than the Gtk supermodule | ||
| 551 | # this avoids dumping MakeMaker | ||
| 552 | {'name' => 'Gtk', | ||
| 553 | 'test' => 'Gtk2::Types', | ||
| 554 | 'version' => '".$Glade::Two::gtk_perl_depends->{'MINIMUM REQUIREMENTS'}."', | ||
| 555 | 'reason' => \"implements the perl bindings to Gtk+.\\n\". | ||
| 556 | \"The module is called Gtk2-Perl on CPAN or \". | ||
| 557 | \"module gnome2-perl in the Gnome CVS\"}, | ||
| 558 | |||
| 559 | # Check for Gnome::Types rather than the Gnome supermodule | ||
| 560 | # this avoids dumping MakeMaker | ||
| 561 | {'name' => 'Gnome', | ||
| 562 | 'test' => 'Gnome::Types', | ||
| 563 | 'version' => '".$Glade::Two::gnome_libs_depends->{'MINIMUM REQUIREMENTS'}."', | ||
| 564 | 'reason' => \"implements the perl bindings to Gnome.\\n\". | ||
| 565 | \"It is a submodule of the Gtk2-Perl package and needs to be built separately.\\n\". | ||
| 566 | \"Read the Gtk2-Perl INSTALL file for details of how to do this.\\n\". | ||
| 567 | \"Glade-Perl will still work but you will not be able to \\n\". | ||
| 568 | \"use any Gnome widgets in your Glade projects\"}, | ||
| 569 | ); | ||
| 570 | #--- End Configuration - You should not have to change anything below this line | ||
| 571 | |||
| 572 | # Allow us to suppress all program installation with the -n (library only) | ||
| 573 | # option. This is for those that don't want to mess with the configuration | ||
| 574 | # section of this file. | ||
| 575 | use Getopt::Std; | ||
| 576 | use vars qw(\$opt_n); | ||
| 577 | unless (getopts(\"n\")) { | ||
| 578 | die \"Usage: \$0 [-n]\\n\"; | ||
| 579 | } | ||
| 580 | \@programs_to_install = () if \$opt_n; | ||
| 581 | |||
| 582 | # Check for non-standard modules that are used by this library. | ||
| 583 | \$| = 1; # autoflush on | ||
| 584 | my \$missing_modules = 0; | ||
| 585 | |||
| 586 | foreach my \$mod (\@need_perl_modules) { | ||
| 587 | print \"Checking for \$mod->{'name'}..\"; | ||
| 588 | eval \"require \$mod->{'test'}\"; | ||
| 589 | if (\$@) { | ||
| 590 | \$missing_modules++; | ||
| 591 | print \" failed\\n\"; | ||
| 592 | print \"-------------------------------------------------------\". | ||
| 593 | \"\\n\$\@\\n\", | ||
| 594 | \"\$mod->{'name'} is needed, it \$mod->{'reason'}\\n\", | ||
| 595 | \"We need at least version \$mod->{'version'}\\n\". | ||
| 596 | \"-------------------------------------------------------\\n\"; | ||
| 597 | sleep(2); # Don't hurry too much | ||
| 598 | } else { | ||
| 599 | print \" ok\\n\"; | ||
| 600 | } | ||
| 601 | } | ||
| 602 | |||
| 603 | #-------------------------------------- | ||
| 604 | print \"------------------------------------------------------- | ||
| 605 | The missing modules can be obtained from CPAN. Visit | ||
| 606 | <URL:http://www.perl.com/CPAN/> to find a CPAN site near you. | ||
| 607 | -------------------------------------------------------\\n\\n\" | ||
| 608 | if \$missing_modules; | ||
| 609 | |||
| 610 | #-------------------------------------- | ||
| 611 | # Last of all generate the Makefile | ||
| 612 | WriteMakefile( | ||
| 613 | 'DISTNAME' => '".$class->app->name."', | ||
| 614 | 'NAME' => '$name', | ||
| 615 | 'VERSION_FROM' => '$ui_file', | ||
| 616 | 'EXE_FILES' => [ \@programs_to_install ], | ||
| 617 | 'clean' => { FILES => '\$(EXE_FILES)' }, | ||
| 618 | 'dist' => { COMPRESS => 'gzip', SUFFIX => 'gz' } | ||
| 619 | ); | ||
| 620 | |||
| 621 | package MY; | ||
| 622 | |||
| 623 | # Pass Glade-Perl version number to pod2man | ||
| 624 | sub manifypods | ||
| 625 | { | ||
| 626 | my \$self = shift; | ||
| 627 | my \$ver = \$self->{'VERSION'} || \"\"; | ||
| 628 | local(\$_) = \$self->SUPER::manifypods(\@_); | ||
| 629 | s/pod2man\\s*\$/pod2man --release ".$class->app->name."-\$ver/m; | ||
| 630 | \$_; | ||
| 631 | } | ||
| 632 | |||
| 633 | exit(0); | ||
| 634 | |||
| 635 | # End of Makefile.PL | ||
| 636 | "; | ||
| 637 | } | ||
| 638 | |||
| 639 | sub dist_spec { | ||
| 640 | my ($class) = @_; | ||
| 641 | my $docs; | ||
| 642 | if ($class->dist->docs) { | ||
| 643 | $docs = $class->dist->docs; | ||
| 644 | } else { | ||
| 645 | $docs = $class->doc->directory; | ||
| 646 | $docs =~ s/^$class->{glade}{directory}//; | ||
| 647 | $docs =~ s/^\///; | ||
| 648 | $docs .= "/*"; | ||
| 649 | } | ||
| 650 | my $rpm_date = `date "+%a %b %d %Y"`; | ||
| 651 | chomp $rpm_date; | ||
| 652 | return "\%define ver ".$class->app->version." | ||
| 653 | \%define rel 1 | ||
| 654 | \%define name ".$class->app->name." | ||
| 655 | \%define rlname \%{name} | ||
| 656 | \%define source0 http://\%{name}-\%{ver}.tar.gz | ||
| 657 | \%define url http:// | ||
| 658 | \%define group Application | ||
| 659 | \%define copy GPL or Artistic | ||
| 660 | \%define filelst \%{name}-\%{ver}-files | ||
| 661 | \%define confdir /etc | ||
| 662 | \%define prefix /usr | ||
| 663 | \%define arch noarch | ||
| 664 | |||
| 665 | Summary: ".$class->app->description." | ||
| 666 | |||
| 667 | Name: \%name | ||
| 668 | Version: \%ver | ||
| 669 | Release: \%rel | ||
| 670 | Copyright: \%{copy} | ||
| 671 | Packager: ".$class->app->author." | ||
| 672 | Source: \%{source0} | ||
| 673 | URL: %{url} | ||
| 674 | Group: \%{group} | ||
| 675 | BuildArch: \%{arch} | ||
| 676 | BuildRoot: /var/tmp/\%{name}-\%{ver} | ||
| 677 | |||
| 678 | \%description | ||
| 679 | ".$class->app->description." | ||
| 680 | |||
| 681 | \%prep | ||
| 682 | \%setup -n \%{rlname}-\%{ver} | ||
| 683 | |||
| 684 | \%build | ||
| 685 | if [ \$(perl -e 'print index(\$INC[0],\"\%{prefix}/lib/perl\");') -eq 0 ];then | ||
| 686 | # package is to be installed in perl root | ||
| 687 | inst_method=\"makemaker-root\" | ||
| 688 | CFLAGS=\$RPM_OPT_FLAGS perl Makefile.PL PREFIX=\%{prefix} | ||
| 689 | else | ||
| 690 | # package must go somewhere else (eg. /opt), so leave off the perl | ||
| 691 | # versioning to ease integration with automatic profile generation scripts | ||
| 692 | # if this is really a perl-version dependant package you should not omiss | ||
| 693 | # the version info... | ||
| 694 | inst_method=\"makemaker-site\" | ||
| 695 | CFLAGS=\$RPM_OPT_FLAGS perl Makefile.PL PREFIX=\%{prefix} LIB=\%{prefix}/lib/perl5 | ||
| 696 | fi | ||
| 697 | |||
| 698 | echo \$inst_method > inst_method | ||
| 699 | |||
| 700 | # get number of processors for parallel builds on SMP systems | ||
| 701 | numprocs=`cat /proc/cpuinfo | grep processor | wc | cut -c7` | ||
| 702 | if [ \"x\$numprocs\" = \"x\" -o \"x\$numprocs\" = \"x0\" ]; then | ||
| 703 | numprocs=1 | ||
| 704 | fi | ||
| 705 | |||
| 706 | make \"MAKE=make -j\$numprocs\" | ||
| 707 | |||
| 708 | \%install | ||
| 709 | rm -rf \$RPM_BUILD_ROOT | ||
| 710 | |||
| 711 | if [ \"\$(cat inst_method)\" = \"makemaker-root\" ];then | ||
| 712 | make UNINST=1 PREFIX=\$RPM_BUILD_ROOT\%{prefix} install | ||
| 713 | elif [ \"\$(cat inst_method)\" = \"makemaker-site\" ];then | ||
| 714 | make UNINST=1 PREFIX=\$RPM_BUILD_ROOT\%{prefix} LIB=\$RPM_BUILD_ROOT\%{prefix}/lib/perl5 install | ||
| 715 | fi | ||
| 716 | |||
| 717 | \%__os_install_post | ||
| 718 | find \$RPM_BUILD_ROOT -type f -print|sed -e \"s\@^\$RPM_BUILD_ROOT\@\@g\" > \%{filelst} | ||
| 719 | |||
| 720 | \%files -f \%{filelst} | ||
| 721 | \%defattr(-, root, root) | ||
| 722 | \%doc $docs | ||
| 723 | |||
| 724 | \%clean | ||
| 725 | rm -rf \$RPM_BUILD_ROOT | ||
| 726 | |||
| 727 | \%changelog | ||
| 728 | * $rpm_date - ".$class->app->author." | ||
| 729 | ".$class->source->indent."This file was created by ".__PACKAGE__."\n"; | ||
| 730 | } | ||
| 731 | |||
| 732 | sub dist_test_pl { | ||
| 733 | my ($class) = @_; | ||
| 734 | my $init_string; | ||
| 735 | if ($class->app->allow_gnome) { | ||
| 736 | $init_string .= "Gnome2->init(\"\$".$class->test->use_module."::PACKAGE\", \"\$".$class->test->use_module."::VER"."SION\");"; | ||
| 737 | } else { | ||
| 738 | $init_string .= "Gtk2->init;"; | ||
| 739 | } | ||
| 740 | |||
| 741 | return "#!/usr/bin/perl | ||
| 742 | #============================================================================== | ||
| 743 | #=== This is a test script | ||
| 744 | #============================================================================== | ||
| 745 | require 5.000; use strict 'vars', 'refs', 'subs'; | ||
| 746 | |||
| 747 | use Test; | ||
| 748 | BEGIN { plan tests => 2 }; | ||
| 749 | |||
| 750 | use ".$class->test->use_module."; | ||
| 751 | ok(1); | ||
| 752 | |||
| 753 | $init_string | ||
| 754 | my \$window = ".$class->test->first_form."->new; | ||
| 755 | ok(\$window->INSTANCE); | ||
| 756 | |||
| 757 | "; | ||
| 758 | } | ||
| 759 | |||
| 760 | sub dist_bin { | ||
| 761 | my ($class) = @_; | ||
| 762 | return "#!/usr/bin/perl | ||
| 763 | #============================================================================== | ||
| 764 | #=== This is a toplevel script | ||
| 765 | #============================================================================== | ||
| 766 | require 5.000; use strict 'vars', 'refs', 'subs'; | ||
| 767 | |||
| 768 | package ".$class->test->first_form."; | ||
| 769 | |||
| 770 | BEGIN { | ||
| 771 | use lib \"./\"; | ||
| 772 | use ".$class->test->use_module."; | ||
| 773 | use vars qw(\@ISA); | ||
| 774 | # use Carp qw(cluck); | ||
| 775 | # \$SIG{__DIE__} = \&Carp::confess; | ||
| 776 | # \$SIG{__WARN__} = \&Carp::cluck; | ||
| 777 | } | ||
| 778 | |||
| 779 | \$Glade::Two::Run::pixmaps_directory = \"".$class->glade->pixmaps_directory."\"; | ||
| 780 | |||
| 781 | select STDOUT; \$| = 1; | ||
| 782 | |||
| 783 | my \%params = ( | ||
| 784 | ); | ||
| 785 | |||
| 786 | __PACKAGE__->app_run(\%params) && exit 0; | ||
| 787 | |||
| 788 | exit 1; | ||
| 789 | |||
| 790 | 1; | ||
| 791 | |||
| 792 | __END__ |