| 1 | package Glade::Two::Generate; | ||
| 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 Carp qw(cluck); | ||
| 24 | $SIG{__DIE__} = \&Carp::confess; | ||
| 25 | $SIG{__WARN__} = \&Carp::cluck; | ||
| 26 | use Data::Dumper; | ||
| 27 | use XML::Parser; | ||
| 28 | use File::Path qw( mkpath); # in use_Glade_Project | ||
| 29 | use File::Basename qw( basename dirname); # in use_Glade_Project | ||
| 30 | use Cwd qw( chdir cwd); # in use_Glade_Project | ||
| 31 | use Sys::Hostname qw( hostname); # in use_Glade_Project | ||
| 32 | use Glade::Two::App qw(:VARS :METHODS); | ||
| 33 | use Glade::Two::Source qw(:VARS :METHODS); # Source writing vars and methods | ||
| 34 | use Glade::Two::Gtk qw( :VARS); | ||
| 35 | use Glade::Two::Gnome; | ||
| 36 | |||
| 37 | use Gtk2 qw( ); # Everywhere | ||
| 38 | use vars qw( | ||
| 39 | @ISA | ||
| 40 | $AUTOLOAD | ||
| 41 | $PACKAGE $VERSION $AUTHOR $DATE | ||
| 42 | @EXPORT @EXPORT_OK %EXPORT_TAGS | ||
| 43 | @VARS @METHODS | ||
| 44 | |||
| 45 | $ALL $CHILD $WIDGET $NOTE | ||
| 46 | $DEPRECATED $CONVERT_TO | ||
| 47 | $OBSOLETE $BROKEN $REMOVED | ||
| 48 | |||
| 49 | %app_fields | ||
| 50 | %stubs | ||
| 51 | $new | ||
| 52 | $seq | ||
| 53 | $changes | ||
| 54 | |||
| 55 | $gnome_libs_depends | ||
| 56 | $gtk_perl_depends | ||
| 57 | $gtk_perl_cant_do | ||
| 58 | ); | ||
| 59 | $PACKAGE = __PACKAGE__; | ||
| 60 | $VERSION = q(0.01); | ||
| 61 | $AUTHOR = q(Dermot Musgrove <dermot.musgrove@virgin.net>); | ||
| 62 | $DATE = q(Sun Nov 17 06:02:01 GMT 2002 ); | ||
| 63 | |||
| 64 | # Tell interpreter who we are inheriting from | ||
| 65 | @ISA = qw( | ||
| 66 | Exporter | ||
| 67 | Glade::Two::App | ||
| 68 | Glade::Two::Source | ||
| 69 | Glade::Two::Gtk | ||
| 70 | Glade::Two::Gnome | ||
| 71 | ); | ||
| 72 | @METHODS = qw( ); | ||
| 73 | @VARS = qw( | ||
| 74 | $gnome_libs_depends | ||
| 75 | $gtk_perl_depends | ||
| 76 | $gtk_perl_cant_do | ||
| 77 | ); | ||
| 78 | |||
| 79 | # Optionally exported package symbols (globals and functions) | ||
| 80 | @EXPORT_OK = ( @METHODS, @VARS); | ||
| 81 | # Tags (groups of symbols) to export | ||
| 82 | %EXPORT_TAGS = ( | ||
| 83 | 'METHODS' => [@METHODS] , | ||
| 84 | 'VARS' => [@VARS] | ||
| 85 | ); | ||
| 86 | #=============================================================================== | ||
| 87 | #=========== Constants and globals | ||
| 88 | #=============================================================================== | ||
| 89 | %stubs = (); | ||
| 90 | |||
| 91 | $ALL = '__ALL'; | ||
| 92 | $CHILD = '__CHILD'; | ||
| 93 | $WIDGET = '__WIDGET'; | ||
| 94 | $NOTE = '__NOTE'; # Report note | ||
| 95 | $DEPRECATED = '__DEPRECATED'; # Report and convert if poss | ||
| 96 | $CONVERT_TO = '__CONVERT_TO', # Convert widget | ||
| 97 | $OBSOLETE = '__OBSOLETE'; # Report and convert if poss | ||
| 98 | $BROKEN = '__BROKEN'; # Report and remove | ||
| 99 | $REMOVED = '__REMOVED'; # Report and remove | ||
| 100 | |||
| 101 | $USES = '__USES'; | ||
| 102 | $DATA = '__DATA'; | ||
| 103 | $IGNORED_WIDGET = '__IGNORED_WIDGET'; | ||
| 104 | $NO_SUCH_WIDGET = '__NO_SUCH_WIDGET'; | ||
| 105 | $INTERNAL_CHILD = '__INTERNAL_CHILD'; | ||
| 106 | $UNUSED_PROPERTIES = '__UNUSED_PROPERTIES'; | ||
| 107 | $FIRST_PANE_FULL = '__FIRST_PANE_FULL'; | ||
| 108 | $CONNECT_ID = '__CONNECT_ID'; | ||
| 109 | $MISSING_METHODS = '__MISSING_METHODS'; | ||
| 110 | $WIDGET_INSTANCE = '__WIDGET_INSTANCE'; | ||
| 111 | $HANDLERS = '__HANDLERS'; | ||
| 112 | |||
| 113 | $gnome_libs_depends = { | ||
| 114 | 'MINIMUM REQUIREMENTS' => '1.2.0', | ||
| 115 | }; | ||
| 116 | |||
| 117 | $gtk_perl_depends = { | ||
| 118 | 'MINIMUM REQUIREMENTS' => '0.01', | ||
| 119 | 'LATEST_CPAN' => '0.01', | ||
| 120 | 'LATEST_CVS' => '20021116', | ||
| 121 | |||
| 122 | '0.01' => '20021116', | ||
| 123 | |||
| 124 | # Those below don't work yet even in the latest CVS version | ||
| 125 | 'GnomeDbGrid' => '99999999', | ||
| 126 | 'GnomeDbList' => '99999999', | ||
| 127 | 'GnomeDbCombo' => '99999999', | ||
| 128 | 'GnomeDbReport' => '99999999', | ||
| 129 | 'GnomeDbError' => '99999999', | ||
| 130 | 'GnomeDbLogin' => '99999999', | ||
| 131 | 'GnomeDbBrowser' => '99999999', | ||
| 132 | 'GnomeDbErrorDlg' => '99999999', | ||
| 133 | 'GnomeDbLoginDlg' => '99999999', | ||
| 134 | |||
| 135 | }; | ||
| 136 | |||
| 137 | $gtk_perl_cant_do = { | ||
| 138 | # Those below will NOT work in specific version mentioned | ||
| 139 | }; | ||
| 140 | |||
| 141 | %app_fields = ( | ||
| 142 | 'type' => 'glade2perl-2', | ||
| 143 | 'widgets' => { | ||
| 144 | 'underlineable' => " ". | ||
| 145 | join(" ", ( | ||
| 146 | 'GtkLabel', | ||
| 147 | 'GtkButton', | ||
| 148 | 'GtkMenuItem') | ||
| 149 | )." ", | ||
| 150 | 'to_ignore' => join (' ', | ||
| 151 | 'Placeholder', | ||
| 152 | 'Custom', | ||
| 153 | ), | ||
| 154 | 'ignored' => 0, | ||
| 155 | 'missing' => 0, | ||
| 156 | 'gnome' => join( " ", | ||
| 157 | 'GnomeAbout', | ||
| 158 | 'GnomeApp', | ||
| 159 | 'GnomeAppBar', | ||
| 160 | 'GnomeCalculator', | ||
| 161 | 'GnomeColorPicker', | ||
| 162 | 'GnomeDateEdit', | ||
| 163 | 'GnomeDialog', | ||
| 164 | 'GnomeDock', | ||
| 165 | 'GnomeDockItem', | ||
| 166 | 'GnomeDruid', | ||
| 167 | 'GnomeDruidPageFinish', | ||
| 168 | 'GnomeDruidPageStandard', | ||
| 169 | 'GnomeDruidPageStart', | ||
| 170 | 'GnomeEntry', | ||
| 171 | 'GnomeFileEntry', | ||
| 172 | 'GnomeFontPicker', | ||
| 173 | 'GnomeHRef', | ||
| 174 | 'GnomeIconEntry', | ||
| 175 | 'GnomeIconList', | ||
| 176 | 'GnomeIconSelection', | ||
| 177 | 'GnomeLess', | ||
| 178 | 'GnomeMessageBox', | ||
| 179 | 'GnomeNumberEntry', | ||
| 180 | 'GnomePaperSelector', | ||
| 181 | 'GnomePixmap', | ||
| 182 | 'GnomePixmapEntry', | ||
| 183 | 'GnomePropertyBox', | ||
| 184 | 'GnomeSpell', | ||
| 185 | # 'GtkCalendar', # In Gtk after CVS-19990914 | ||
| 186 | 'GtkClock', | ||
| 187 | 'GtkDial', | ||
| 188 | 'GtkPixmapMenuItem', | ||
| 189 | ), | ||
| 190 | 'gnome_db' => join( " ", | ||
| 191 | 'GnomeDbGrid', | ||
| 192 | 'GnomeDbList', | ||
| 193 | 'GnomeDbCombo', | ||
| 194 | 'GnomeDbReport', | ||
| 195 | 'GnomeDbError', | ||
| 196 | 'GnomeDbLogin', | ||
| 197 | 'GnomeDbBrowser', | ||
| 198 | 'GnomeDbErrorDlg', | ||
| 199 | 'GnomeDbLoginDlg', | ||
| 200 | ), | ||
| 201 | 'concept' => '', | ||
| 202 | 'composite' => join(' ', | ||
| 203 | 'Gnome::Entry', | ||
| 204 | 'Gnome::FileEntry', | ||
| 205 | 'Gnome::NumberEntry', | ||
| 206 | 'Gnome::PixmapEntry', | ||
| 207 | 'Gtk2::Combo', | ||
| 208 | ), | ||
| 209 | 'dialogs' => join(' ', | ||
| 210 | 'Gnome2::About', | ||
| 211 | 'Gnome2::App', | ||
| 212 | 'Gnome2::Dialog', | ||
| 213 | 'Gnome2::MessageBox', | ||
| 214 | 'Gnome2::PropertyBox', | ||
| 215 | 'Gtk2::ColorSelectionDialog', | ||
| 216 | 'Gtk2::Dialog', | ||
| 217 | 'Gtk2::FileSelection', | ||
| 218 | 'Gtk2::FontSelectionDialog', | ||
| 219 | 'Gtk2::InputDialog', | ||
| 220 | ), | ||
| 221 | 'toplevel' => join(' ', | ||
| 222 | 'Gnome2::About', | ||
| 223 | 'Gnome2::App', | ||
| 224 | 'Gnome2::Dialog', | ||
| 225 | 'Gnome2::MessageBox', | ||
| 226 | 'Gnome2::PropertyBox', | ||
| 227 | 'Gtk2::Dialog', | ||
| 228 | 'Gtk2::InputDialog', | ||
| 229 | 'Gtk2::Window', | ||
| 230 | ), | ||
| 231 | }, | ||
| 232 | 'properties' => { | ||
| 233 | 'unhandled' => 0, | ||
| 234 | 'translatable_properties' => " ". | ||
| 235 | join(" ", ( | ||
| 236 | 'label', | ||
| 237 | 'title', | ||
| 238 | 'text', | ||
| 239 | 'format', | ||
| 240 | 'copyright', | ||
| 241 | 'comments', | ||
| 242 | 'preview_text', | ||
| 243 | 'tooltip') | ||
| 244 | )." ", | ||
| 245 | 'cxx' => join(' ', | ||
| 246 | 'cxx_separate_class', | ||
| 247 | 'cxx_separate_file', | ||
| 248 | 'cxx_use_heap', | ||
| 249 | 'cxx_visibility', | ||
| 250 | ), | ||
| 251 | }, | ||
| 252 | 'app' => { | ||
| 253 | 'use_modules' => undef, # Existing signal handler modules | ||
| 254 | 'allow_gnome' => undef, # Dont allow gnome widgets | ||
| 255 | 'allow_gnome_db'=> undef, # Dont allow gnome-db widgets | ||
| 256 | 'gtk2' => undef, # Don't use new gtk2 | ||
| 257 | }, | ||
| 258 | 'run_options' => { | ||
| 259 | 'name' => __PACKAGE__, | ||
| 260 | 'version' => $VERSION, | ||
| 261 | 'author' => $AUTHOR, | ||
| 262 | 'date' => $DATE, | ||
| 263 | 'my_gtk_perl' => undef, # Get the version number from Gtk2-Perl | ||
| 264 | # '0.6123' we have CPAN release 0.6123 (or equivalent) | ||
| 265 | # '19990901' we have CVS version of 1st Sep 1999 | ||
| 266 | 'my_gtk' => undef, # Get the version number from Gtk | ||
| 267 | # '1.2.10' we have release 1.2.10 (or equivalent) | ||
| 268 | # '19990901' we have CVS version of 1st Sep 1999 | ||
| 269 | 'my_gnome_libs' => undef, # Get the version number from gnome_libs | ||
| 270 | # '1.0.8' we have release 1.0.8 (or equivalent) | ||
| 271 | # '19990901' we have CVS version of 1st Sep 1999 | ||
| 272 | 'dont_show_UI' => undef, # Show UI and wait | ||
| 273 | 'my_gnome_incs' => undef, # Where the gnome include files are | ||
| 274 | 'prune' => "*". join("*", | ||
| 275 | $permitted_fields, | ||
| 276 | 'proto', | ||
| 277 | 'project', | ||
| 278 | 'widgets', | ||
| 279 | 'properties', | ||
| 280 | 'run_options', | ||
| 281 | 'module', | ||
| 282 | 'generate', | ||
| 283 | 'prune', | ||
| 284 | ). | ||
| 285 | "*", | ||
| 286 | }, | ||
| 287 | 'glade' => { | ||
| 288 | 'name_from' => undef, | ||
| 289 | 'file' => undef, | ||
| 290 | 'filep' => undef, | ||
| 291 | 'encoding' => 'ISO-8859-1', # Character encoding eg ('ISO-8859-1') | ||
| 292 | 'version' => undef, # Version of Glade that made file | ||
| 293 | 'project' => undef, # project proto | ||
| 294 | 'proto' => undef, # widget file proto | ||
| 295 | 'string' => undef, | ||
| 296 | }, | ||
| 297 | 'source' => { | ||
| 298 | 'indent' => ' ', # Source code indent per Gtk 'nesting' | ||
| 299 | 'tabwidth' => 8, # Replace each 8 spaces with a tab in sources | ||
| 300 | 'tab' => '', | ||
| 301 | 'write' => undef, # Dont write source code | ||
| 302 | 'quick_gen' => 0, # 1 = Don't perform any checks | ||
| 303 | 'with_errors' => undef, # 1 = Write source code regardless of errors | ||
| 304 | 'save_connect_id'=> 0, # 1 = generate code to save signal_connect ids | ||
| 305 | 'hierarchy' => '', # Dont generate any hierarchy | ||
| 306 | # widget... | ||
| 307 | # eg $hier->{'vbox2'}{'table1'}... | ||
| 308 | # class... startswith class | ||
| 309 | # eg $hier->{'GtkVBox'}{'vbox2'}{'GtkTable'}{'table1'}... | ||
| 310 | # both... widget and class | ||
| 311 | 'style' => 'AUTOLOAD', # Generate code using OO AUTOLOAD code | ||
| 312 | # Libglade generate libglade code | ||
| 313 | # closures generate code using closures | ||
| 314 | # Export generate non-OO code | ||
| 315 | 'LANG' => ($ENV{'LANG'} || ''), | ||
| 316 | # Which language we want the source to be in | ||
| 317 | }, | ||
| 318 | 'module' => { | ||
| 319 | 'gtk' => {}, | ||
| 320 | 'sigs' => { | ||
| 321 | 'class' => undef, | ||
| 322 | 'base' => undef, | ||
| 323 | 'file' => undef, | ||
| 324 | }, | ||
| 325 | 'ui' => { | ||
| 326 | 'class' => undef, | ||
| 327 | 'file' => undef, | ||
| 328 | }, | ||
| 329 | 'app' => { | ||
| 330 | 'class' => undef, | ||
| 331 | 'base' => undef, | ||
| 332 | 'file' => undef, | ||
| 333 | }, | ||
| 334 | 'subapp' => { | ||
| 335 | 'class' => undef, | ||
| 336 | 'file' => undef, | ||
| 337 | }, | ||
| 338 | 'libglade' => { | ||
| 339 | 'class' => undef, | ||
| 340 | 'file' => undef, | ||
| 341 | }, | ||
| 342 | 'onefile' => { | ||
| 343 | 'class' => undef, | ||
| 344 | 'file' => undef, | ||
| 345 | }, | ||
| 346 | 'pot' => { | ||
| 347 | 'class' => undef, | ||
| 348 | 'file' => undef, | ||
| 349 | }, | ||
| 350 | }, | ||
| 351 | 'test' => { | ||
| 352 | 'name' => undef, | ||
| 353 | 'directory' => undef, | ||
| 354 | 'first_form' => undef, | ||
| 355 | 'use_module' => undef, | ||
| 356 | }, | ||
| 357 | 'dist' => { | ||
| 358 | 'write' => 'True', | ||
| 359 | 'directory' => '', | ||
| 360 | 'Makefile_PL' => 'Makefile.PL', | ||
| 361 | 'MANIFEST_SKIP' => 'MANIFEST.SKIP', | ||
| 362 | 'test_directory'=> 't', | ||
| 363 | 'test_pl' => 'test.pl', | ||
| 364 | 'bin_directory' => 'bin', | ||
| 365 | 'bin' => undef, # name of bin (script) to generate | ||
| 366 | 'rpm' => undef, # Name of RPM to produce | ||
| 367 | 'spec' => undef, # Name of RPM spec file | ||
| 368 | 'type' => undef, # Type of distribution | ||
| 369 | 'compress' => undef, # How to compress the distribution | ||
| 370 | 'scripts' => undef, # Scripts that should be installed | ||
| 371 | 'docs' => undef, # Documentation that should be included | ||
| 372 | }, | ||
| 373 | 'doc' => { | ||
| 374 | 'write' => 'True', | ||
| 375 | 'directory' => 'Documentation', | ||
| 376 | 'COPYING' => 'COPYING', | ||
| 377 | 'Changelog' => 'Changelog', | ||
| 378 | 'FAQ' => 'FAQ', | ||
| 379 | 'INSTALL' => 'INSTALL', | ||
| 380 | 'NEWS' => 'NEWS', | ||
| 381 | 'README' => 'README', | ||
| 382 | 'ROADMAP' => 'ROADMAP', | ||
| 383 | 'TODO' => 'TODO', | ||
| 384 | }, | ||
| 385 | 'helper' => { | ||
| 386 | 'editors' => undef, # Editor calls that are available | ||
| 387 | 'active_editor' => undef, # Index of editor that we are using | ||
| 388 | }, | ||
| 389 | ); | ||
| 390 | |||
| 391 | sub DESTROY { | ||
| 392 | # This sub will be called on object destruction | ||
| 393 | } # End of sub DESTROY | ||
| 394 | |||
| 395 | sub AUTOLOAD { | ||
| 396 | my $self = shift; | ||
| 397 | my $class = ref($self) | ||
| 398 | or die "$self is not an object so we cannot '$AUTOLOAD'\n", | ||
| 399 | "We were called from ".join(", ", caller),"\n\n"; | ||
| 400 | my $name = $AUTOLOAD; | ||
| 401 | $name =~ s/.*://; # strip fully-qualified portion | ||
| 402 | |||
| 403 | if (exists $self->{$permitted_fields}->{$name}) { | ||
| 404 | # This allows dynamic data methods - see %fields above | ||
| 405 | # eg $class->UI('new_value'); | ||
| 406 | # or $current_value = $class->UI; | ||
| 407 | if (@_) { | ||
| 408 | return $self->{$name} = shift; | ||
| 409 | } else { | ||
| 410 | return $self->{$name}; | ||
| 411 | } | ||
| 412 | |||
| 413 | } elsif (exists $stubs{$name}) { | ||
| 414 | # This shows dynamic signal handler stub message_box - see %stubs above | ||
| 415 | __PACKAGE__->show_skeleton_message( | ||
| 416 | $AUTOLOAD."\n ("._("AUTOLOADED by")." ".__PACKAGE__.")", | ||
| 417 | [$self, @_], | ||
| 418 | __PACKAGE__, | ||
| 419 | 'pixmaps/Logo.xpm'); | ||
| 420 | |||
| 421 | } elsif ($name ne 'DESTROY'){ | ||
| 422 | die "Can't access method `$name' in class $class\n", | ||
| 423 | "We were called from ",join(", ", caller),"\n\n"; | ||
| 424 | |||
| 425 | } | ||
| 426 | } | ||
| 427 | |||
| 428 | #=============================================================================== | ||
| 429 | #=========== Generate the code | ||
| 430 | #=============================================================================== | ||
| 431 | sub new_generator { | ||
| 432 | my ($class, %params) = @_; | ||
| 433 | my $me = (ref $class||$class)."->new"; | ||
| 434 | return bless $class->get_app_options(%params), $class; | ||
| 435 | } | ||
| 436 | |||
| 437 | sub generate { | ||
| 438 | my ($class, %params) = @_; | ||
| 439 | my $me = (ref $class||$class)."->generate"; | ||
| 440 | |||
| 441 | my ($encoding, $project, $tree); | ||
| 442 | $Glade_Perl->diag->log($Glade_Perl->glade->file."2perl.log") | ||
| 443 | if $Glade_Perl->diag->log eq '1'; | ||
| 444 | |||
| 445 | # Start diagnostics | ||
| 446 | $Glade_Perl->start_log; | ||
| 447 | |||
| 448 | $Glade_Perl->Write_to_File; | ||
| 449 | $Glade_Perl->get_versions; | ||
| 450 | |||
| 451 | $Glade_Perl->glade->encoding($Glade_Perl->glade->encoding || 'ISO-8859-1'); | ||
| 452 | #print Dumper($Glade_Perl); | ||
| 453 | my $xml = $class->string_from_file($Glade_Perl->glade->file); | ||
| 454 | |||
| 455 | ($encoding, $tree) = | ||
| 456 | $class->tree_from_string($xml, $Glade_Perl->glade->encoding); | ||
| 457 | |||
| 458 | $Glade_Perl->glade->encoding($encoding); | ||
| 459 | if ($tree->[0] eq 'GTK-Interface') { | ||
| 460 | $Glade_Perl->glade->version('064'); | ||
| 461 | |||
| 462 | } elsif ($tree->[0] eq 'glade-interface') { | ||
| 463 | $Glade_Perl->glade->version('110'); | ||
| 464 | |||
| 465 | } else { | ||
| 466 | $Glade_Perl->glade->version('110'); | ||
| 467 | } | ||
| 468 | $Glade_Perl->diag_print (2, "%s- %s reported version %s", | ||
| 469 | $indent, "Glade file ".$Glade_Perl->glade->file, $Glade_Perl->glade->version); | ||
| 470 | #print Dumper($Glade_Perl->glade); | ||
| 471 | $Glade_Perl->glade->proto( | ||
| 472 | $class->proto_from_tree( | ||
| 473 | $tree->[1], | ||
| 474 | 0, | ||
| 475 | ' accelerator signal child', # store in array | ||
| 476 | ' property ', # store in hash | ||
| 477 | ' widget child signal packing ', # special | ||
| 478 | $Glade_Perl->glade->encoding)); | ||
| 479 | |||
| 480 | ($encoding, $project) = $Glade_Perl->get_glade_project(); | ||
| 481 | $class->merge_into_hash_from( | ||
| 482 | $Glade_Perl, | ||
| 483 | $project, | ||
| 484 | "Glade project file ".$Glade_Perl->glade->filep); | ||
| 485 | $class->merge_into_hash_from( | ||
| 486 | $Glade_Perl, | ||
| 487 | $Glade_Perl->get_project_options($Glade_Perl), | ||
| 488 | "Glade interface file ".$Glade_Perl->glade->file); | ||
| 489 | |||
| 490 | #print $class->string_from_proto('', ' ', 'Gtk-Interface', undef, $Glade_Perl->glade->proto); | ||
| 491 | #$Glade_Perl->diag_print(1, $Glade_Perl->glade->proto->{'project'}); | ||
| 492 | #$Glade_Perl->diag_print(1, $Glade_Perl->glade->{'project'}); | ||
| 493 | # Recursively generate the UI | ||
| 494 | $class->pre_generate_from_proto( $Glade_Perl); | ||
| 495 | my $window = $class->generate_from_proto( | ||
| 496 | $Glade_Perl->glade->proto->{'name'}, | ||
| 497 | $Glade_Perl->glade->proto->{'form'}, 0); | ||
| 498 | $class->post_generate_from_proto( $Glade_Perl); | ||
| 499 | |||
| 500 | $Glade_Perl->diag_print(4, $Glade::Two::Gtk2::enums); | ||
| 501 | $Glade_Perl->diag_print(4, $Glade::Two::Gnome::enums); | ||
| 502 | #print Dumper($Glade_Perl); | ||
| 503 | $Glade_Perl->save_app_options($Glade_Perl->glade->file); | ||
| 504 | |||
| 505 | $Glade_Perl->stop_log(); | ||
| 506 | |||
| 507 | return $window; | ||
| 508 | } | ||
| 509 | |||
| 510 | sub convert { | ||
| 511 | # signal - name, handler, object, after | ||
| 512 | # accelerator - key, modifiers, signal | ||
| 513 | # $key =~ s/^GDK_// | ||
| 514 | # internal-child add attr ' internal-child="$internal-child"' | ||
| 515 | # property name startswith 'cxx' add attr ' agent=glademm' | ||
| 516 | # If in $translatable_properties | ||
| 517 | # unless has prop 'use_stock' add attr ' translatable="yes"' | ||
| 518 | |||
| 519 | } | ||
| 520 | |||
| 521 | sub reverse_changes { | ||
| 522 | my ($class, $changes) = @_; | ||
| 523 | my ($self, $key, $work); | ||
| 524 | foreach $key (keys %{$changes}) { | ||
| 525 | if (" $OBSOLETE $REMOVED $BROKEN $CONVERT_TO " =~ / $changes->{$key} /) { | ||
| 526 | next; | ||
| 527 | |||
| 528 | } elsif (" $CONVERT_TO " =~ / $key /) { | ||
| 529 | next; | ||
| 530 | |||
| 531 | } elsif (" $WIDGET " =~ / $key /) { | ||
| 532 | $self->{$key} = $changes->{$key}; | ||
| 533 | |||
| 534 | } elsif (ref $changes->{$key} eq 'HASH') { | ||
| 535 | if ($changes->{$key}{$CONVERT_TO}) { | ||
| 536 | $self->{$changes->{$key}{$CONVERT_TO}} = | ||
| 537 | {$CONVERT_TO => $key}; | ||
| 538 | } | ||
| 539 | $work = $class->reverse_changes($changes->{$key}); | ||
| 540 | $self->{$key} = $work if keys %{$work} | ||
| 541 | |||
| 542 | } else { | ||
| 543 | $self->{$changes->{$key}} = $key; | ||
| 544 | } | ||
| 545 | } | ||
| 546 | return $self; | ||
| 547 | } | ||
| 548 | #=============================================================================== | ||
| 549 | #=========== Utilities to read XML and build the proto | ||
| 550 | #=============================================================================== | ||
| 551 | sub get_glade_project { | ||
| 552 | my ($class) =@_; | ||
| 553 | my $me = (ref $class||$class)."->get_glade_project"; | ||
| 554 | my $project = {}; | ||
| 555 | my $file = $class->glade->filep; | ||
| 556 | my ($encoding); | ||
| 557 | if ($file && -r $file) { | ||
| 558 | ($encoding, $project) = $class->simple_Proto_from_File( | ||
| 559 | $class->glade->filep, | ||
| 560 | '', 'glade-project', | ||
| 561 | $class->glade->encoding); | ||
| 562 | $class->glade->encoding($encoding); | ||
| 563 | |||
| 564 | } else { | ||
| 565 | # print "File '$file' could NOT be read\n"; | ||
| 566 | $project = {}; | ||
| 567 | } | ||
| 568 | |||
| 569 | return ($encoding, {'glade'=>{'project'=>$project}}); | ||
| 570 | } | ||
| 571 | |||
| 572 | sub get_app_options { | ||
| 573 | my ($class, %params) = @_; | ||
| 574 | my $me = (ref $class||$class)."->get_app_options"; | ||
| 575 | #print Dumper(\@_); | ||
| 576 | my $type = 'glade2perl-2'; | ||
| 577 | if (ref $Glade_Perl) { | ||
| 578 | # We have already called options() at least once somehow | ||
| 579 | $Glade_Perl->merge_into_hash_from( | ||
| 580 | $Glade_Perl, | ||
| 581 | $class->convert_old_options(\%params), | ||
| 582 | $me); | ||
| 583 | |||
| 584 | } else { | ||
| 585 | $class->SUPER::options(%params, | ||
| 586 | 'options_I18N_name' => 'Glade-Perl-Two', | ||
| 587 | 'options_defaults' => \%Glade::Two::Generate::app_fields, | ||
| 588 | 'options_key' => $Glade::Two::Generate::app_fields{type}, | ||
| 589 | 'options_global' => "\$Glade_Perl", | ||
| 590 | # 'options_report' => '$Glade_Perl->{app}{use_modules}', | ||
| 591 | ); | ||
| 592 | } | ||
| 593 | # Construct file names if Glade filename is not supplied | ||
| 594 | if ($Glade_Perl->glade->file eq $NOFILE) { | ||
| 595 | $Glade_Perl->glade->file($Glade_Perl->{$Glade_Perl->type}->mru) ; | ||
| 596 | $Glade_Perl->glade->name_from("MRU Glade file in user options file"); | ||
| 597 | |||
| 598 | } elsif ($Glade_Perl->glade->file) { | ||
| 599 | $Glade_Perl->glade->name_from("Specified as arg to $me"); | ||
| 600 | |||
| 601 | } else { | ||
| 602 | $Glade_Perl->glade->file( | ||
| 603 | $Glade_Perl->{$Glade_Perl->type}->proto->project->{glade}{file} | ||
| 604 | ); | ||
| 605 | $Glade_Perl->glade->name_from("Specified in project options file"); | ||
| 606 | } | ||
| 607 | $Glade_Perl->glade->filep( | ||
| 608 | $Glade_Perl->glade->filep || $Glade_Perl->glade->file."p"); | ||
| 609 | |||
| 610 | # Find out what versions of software we have | ||
| 611 | unless ($Glade_Perl->{$type}->my_gtk_perl && | ||
| 612 | ($Glade_Perl->{$type}->my_gtk_perl > $Gtk2::VERSION)) { | ||
| 613 | $Glade_Perl->{$type}->my_gtk_perl($Gtk2::VERSION); | ||
| 614 | } | ||
| 615 | if ( $Glade_Perl->{$type}->dont_show_UI && !$Glade_Perl->source->write) { | ||
| 616 | die "$me - Much as I like an easy life, please alter options ". | ||
| 617 | "to, at least, show_UI or write_source\n Run abandoned"; | ||
| 618 | } | ||
| 619 | $indent = $Glade_Perl->source->indent; | ||
| 620 | $tab = (' ' x $Glade_Perl->source->tabwidth); | ||
| 621 | $Glade_Perl->source->tab($tab); | ||
| 622 | |||
| 623 | return $Glade_Perl; | ||
| 624 | } | ||
| 625 | |||
| 626 | sub get_project_options { | ||
| 627 | my ($class, $proto) = @_; | ||
| 628 | my $me = (ref $class || $class)."->get_project_options"; | ||
| 629 | my $type = 'glade2perl-2'; | ||
| 630 | |||
| 631 | $Glade_Perl->diag_print(6, $proto, "Input Proto project"); | ||
| 632 | |||
| 633 | my $proj_opt = bless {}, (ref $class || $class); | ||
| 634 | |||
| 635 | #print Dumper($proto->{app}); | ||
| 636 | #print Dumper($Glade_Perl->{app}); | ||
| 637 | #print Dumper($proj_opt->{app}); | ||
| 638 | $proj_opt->{app}{allow_gnome} = ($class->normalise( | ||
| 639 | $proto->{'gnome_support'} && | ||
| 640 | $proto->{'gnome_support'} || 'False') == 1); | ||
| 641 | $proj_opt->{app}{allow_gnome_db} =($class->normalise( | ||
| 642 | $proto->{'gnome_db_support'} && | ||
| 643 | $proto->{'gnome_db_support'} || 'False') == 1); | ||
| 644 | |||
| 645 | # Remove any spaces, dots or minuses in the project name | ||
| 646 | $proj_opt->{app}{name} ||= | ||
| 647 | $class->fix_name($proto->{glade}{project}{'name'}); | ||
| 648 | |||
| 649 | # Glade assumes that all directories are named relative to the Glade | ||
| 650 | # project (.glade) file (not <project><directory>) ! | ||
| 651 | $proj_opt->{glade}{file} = $class->full_Path( | ||
| 652 | $Glade_Perl->glade->file, `pwd`); | ||
| 653 | $proj_opt->{glade}{start_directory} = dirname($proj_opt->{glade}{file}); | ||
| 654 | $proj_opt->{glade}{filep} = $class->full_Path( | ||
| 655 | $Glade_Perl->glade->filep, $proj_opt->{glade}{start_directory}); | ||
| 656 | |||
| 657 | $proj_opt->{glade}{directory} = $class->full_Path( | ||
| 658 | $proto->{directory}, | ||
| 659 | $proj_opt->{glade}{start_directory}, | ||
| 660 | $proj_opt->{glade}{start_directory}); | ||
| 661 | |||
| 662 | $proj_opt->{diag}{log} = $class->full_Path( | ||
| 663 | $Glade_Perl->diag->log, | ||
| 664 | $proj_opt->{glade}{start_directory} | ||
| 665 | ) if $Glade_Perl->diag->log and $Glade_Perl->diag->log ne $NOFILE; | ||
| 666 | |||
| 667 | $proj_opt->{$type}{xml}{project} = $class->full_Path( | ||
| 668 | $Glade_Perl->{$type}->xml->project, | ||
| 669 | `pwd`, | ||
| 670 | # $proj_opt->{glade}{directory}, | ||
| 671 | ) unless $Glade_Perl->{$type}->xml->project eq $NOFILE; | ||
| 672 | |||
| 673 | $proj_opt->{module}{directory} = $class->full_Path( | ||
| 674 | ($proto->{source_directory} || './src'), | ||
| 675 | $proj_opt->{glade}{start_directory}, | ||
| 676 | $proj_opt->{glade}{start_directory}); | ||
| 677 | |||
| 678 | $proj_opt->{glade}{pixmaps_directory} = $class->full_Path( | ||
| 679 | ($proto->{'pixmaps_directory'} || './pixmaps'), | ||
| 680 | $proj_opt->{glade}{start_directory}, | ||
| 681 | $proj_opt->{glade}{start_directory}); | ||
| 682 | |||
| 683 | if ($Glade_Perl->Writing_to_File) { | ||
| 684 | unless (-d $proj_opt->{module}{directory}) { | ||
| 685 | # Source directory does not exist yet so create it | ||
| 686 | $Glade_Perl->diag_print (2, "%s- Creating directory '%s' in %s", | ||
| 687 | $indent, $proj_opt->{module}{directory}, $me); | ||
| 688 | mkpath($proj_opt->{module}{directory}); | ||
| 689 | } | ||
| 690 | |||
| 691 | unless (-d $proj_opt->{glade}{pixmaps_directory}) { | ||
| 692 | # Pixmaps directory does not exist yet so create it | ||
| 693 | $Glade_Perl->diag_print (2, "%s- Creating directory '%s' in %s", | ||
| 694 | $indent, $proj_opt->{glade}{pixmaps_directory}, $me); | ||
| 695 | mkpath($proj_opt->{glade}{pixmaps_directory}); | ||
| 696 | } | ||
| 697 | } | ||
| 698 | |||
| 699 | my $src = $proj_opt->{module}{directory}; | ||
| 700 | |||
| 701 | $proj_opt->{module}{sigs}{class} = "$proj_opt->{app}{name}SIGS"; | ||
| 702 | $proj_opt->{module}{sigs}{base} = "$src/$proj_opt->{module}{sigs}{class}"; | ||
| 703 | $proj_opt->{module}{sigs}{file} = "$proj_opt->{module}{sigs}{base}.pm"; | ||
| 704 | |||
| 705 | $proj_opt->{module}{ui}{class} = "$proj_opt->{app}{name}UI"; | ||
| 706 | $proj_opt->{module}{ui}{base} = "$src/$proj_opt->{module}{ui}{class}"; | ||
| 707 | $proj_opt->{module}{ui}{file} = "$proj_opt->{module}{ui}{base}.pm"; | ||
| 708 | |||
| 709 | $proj_opt->{module}{app}{class} = "$proj_opt->{app}{name}"; | ||
| 710 | $proj_opt->{module}{app}{base} = "$src/$proj_opt->{module}{app}{class}"; | ||
| 711 | $proj_opt->{module}{app}{file} = "$proj_opt->{module}{app}{base}.pm"; | ||
| 712 | |||
| 713 | $proj_opt->{module}{subapp}{class} = "Sub$proj_opt->{module}{app}{class}"; | ||
| 714 | $proj_opt->{module}{subapp}{file} = "$src/$proj_opt->{module}{subapp}{class}.pm"; | ||
| 715 | |||
| 716 | $proj_opt->{module}{libglade}{class} = "$proj_opt->{app}{name}"; | ||
| 717 | $proj_opt->{module}{libglade}{file} = "$src/$proj_opt->{module}{libglade}{class}LIBGLADE.pm"; | ||
| 718 | |||
| 719 | $proj_opt->{module}{onefile}{class} = "$proj_opt->{app}{name}"; | ||
| 720 | $proj_opt->{module}{onefile}{file} = "$src/$proj_opt->{module}{onefile}{class}ONEFILE.pm"; | ||
| 721 | |||
| 722 | $proj_opt->{module}{pot}{file} = "$src/$proj_opt->{app}{name}.pot"; | ||
| 723 | |||
| 724 | $proj_opt->{app}{logo} = $class->full_Path( | ||
| 725 | $Glade_Perl->app->logo, | ||
| 726 | $proj_opt->{glade}{'pixmaps_directory'}, | ||
| 727 | ''); | ||
| 728 | |||
| 729 | $proj_opt->{$type}{logo} = $class->full_Path( | ||
| 730 | $Glade_Perl->{$type}->logo, | ||
| 731 | $proj_opt->{glade}{pixmaps_directory}, | ||
| 732 | ''); | ||
| 733 | |||
| 734 | unless (-r $proj_opt->{$type}{logo}) { | ||
| 735 | $Glade_Perl->diag_print (2, "%s- Writing our own logo to '%s' in %s", | ||
| 736 | $indent, $proj_opt->{$type}{logo}, $me); | ||
| 737 | open LOGO, ">$proj_opt->{$type}{logo}" or | ||
| 738 | die sprintf("error %s - can't open file '%s' for output", | ||
| 739 | $me, $proj_opt->{$type}{logo}); | ||
| 740 | print LOGO $class->our_logo; | ||
| 741 | close LOGO or | ||
| 742 | die sprintf("error %s - can't close file '%s'", | ||
| 743 | $me, $proj_opt->{$type}{logo}); | ||
| 744 | } | ||
| 745 | |||
| 746 | unless (-r $proj_opt->{app}{logo}) { | ||
| 747 | $Glade_Perl->diag_print (2, "%s- Writing our own logo to '%s' in %s", | ||
| 748 | $indent, $proj_opt->{app}{logo}, $me); | ||
| 749 | open LOGO, ">$proj_opt->{app}{logo}" or | ||
| 750 | die sprintf("error %s - can't open file '%s' for output", | ||
| 751 | $me, $proj_opt->{app}{logo}); | ||
| 752 | print LOGO $class->our_logo; | ||
| 753 | close LOGO or | ||
| 754 | die sprintf("error %s - can't close file '%s'", | ||
| 755 | $me, $proj_opt->{app}{logo}); | ||
| 756 | } | ||
| 757 | |||
| 758 | unless ($proj_opt->{app}{logo} && -r $proj_opt->{app}{logo}) { | ||
| 759 | $proj_opt->{app}{logo} = $proj_opt->{$type}{logo}; | ||
| 760 | } | ||
| 761 | |||
| 762 | $proj_opt->{doc}{directory} = $class->full_Path( | ||
| 763 | $proj_opt->{doc}{directory} || 'Documentation', | ||
| 764 | $proj_opt->{glade}{directory}); | ||
| 765 | |||
| 766 | unless (-d $proj_opt->{doc}{directory}) { | ||
| 767 | # Source directory does not exist yet so create it | ||
| 768 | $Glade_Perl->diag_print (2, "%s- Creating directory '%s' in %s", | ||
| 769 | $indent, $proj_opt->{doc}{directory}, $me); | ||
| 770 | mkpath($proj_opt->{doc}{directory}); | ||
| 771 | } | ||
| 772 | $proj_opt->{dist}{directory} = $class->full_Path( | ||
| 773 | $proj_opt->{dist}{directory}, | ||
| 774 | $proj_opt->{glade}{directory}); | ||
| 775 | |||
| 776 | unless (-d $proj_opt->{dist}{directory}) { | ||
| 777 | # Source directory does not exist yet so create it | ||
| 778 | $Glade_Perl->diag_print (2, "%s- Creating directory '%s' in %s", | ||
| 779 | $indent, $proj_opt->{dist}{directory}, $me); | ||
| 780 | mkpath($proj_opt->{dist}{directory}); | ||
| 781 | } | ||
| 782 | $proj_opt->{dist}{bin_directory} = $class->full_Path( | ||
| 783 | ($proj_opt->{dist}{bin_directory} || './bin'), | ||
| 784 | $proj_opt->{dist}{directory}, | ||
| 785 | $proj_opt->{dist}{directory}); | ||
| 786 | unless (-d $proj_opt->{dist}{bin_directory}) { | ||
| 787 | # bin directory does not exist yet so create it | ||
| 788 | $Glade_Perl->diag_print (2, "%s- Creating directory '%s' in %s", | ||
| 789 | $indent, $proj_opt->{dist}{bin_directory}, $me); | ||
| 790 | mkpath($proj_opt->{dist}{bin_directory}); | ||
| 791 | } | ||
| 792 | $proj_opt->{dist}{bin} = $class->full_Path( | ||
| 793 | ($proto->{glade}{project}{program_name} || 'run_'.$proj_opt->{app}{name}), | ||
| 794 | $proj_opt->{dist}{bin_directory}); | ||
| 795 | |||
| 796 | $proj_opt->{dist}{test_directory} = $class->full_Path( | ||
| 797 | ($proj_opt->{dist}{test_directory} || './t'), | ||
| 798 | $proj_opt->{dist}{directory}, | ||
| 799 | $proj_opt->{dist}{directory}); | ||
| 800 | unless (-d $proj_opt->{dist}{test_directory}) { | ||
| 801 | # bin directory does not exist yet so create it | ||
| 802 | $Glade_Perl->diag_print (2, "%s- Creating directory '%s' in %s", | ||
| 803 | $indent, $proj_opt->{dist}{test_directory}, $me); | ||
| 804 | mkpath($proj_opt->{dist}{test_directory}); | ||
| 805 | } | ||
| 806 | $proj_opt->{dist}{test_pl} = $class->full_Path( | ||
| 807 | ($proj_opt->{dist}{test_pl} || './001_use_new.t'), | ||
| 808 | $proj_opt->{dist}{test_directory}); | ||
| 809 | |||
| 810 | if ($Glade_Perl->app->author) { | ||
| 811 | $proj_opt->{app}{author} = $Glade_Perl->app->author; | ||
| 812 | } else { | ||
| 813 | my $host = hostname; | ||
| 814 | my $pwuid = [(getpwuid($<))]; | ||
| 815 | my $user = $pwuid->[0]; | ||
| 816 | my $fullname = $pwuid->[6]; | ||
| 817 | my $hostname = [split(" ", $host)]; | ||
| 818 | $proj_opt->{app}{'author'} = "$fullname <$user\@$hostname->[0]>"; | ||
| 819 | } | ||
| 820 | # Remove trailing spaces and ensure only one leading '#' | ||
| 821 | $Glade_Perl->{app}{copying} =~ s/ *$//; | ||
| 822 | if ($Glade_Perl->app->copying !~ /^#/) { | ||
| 823 | $Glade_Perl->app->copying("#".$Glade_Perl->app->copying); | ||
| 824 | } | ||
| 825 | # escape any quotes | ||
| 826 | $proj_opt->{app}{'author'} =~ s/\"/\\\"/g; | ||
| 827 | $proj_opt->{app}{'author'} =~ s/\'/\\\'/g; | ||
| 828 | |||
| 829 | $proj_opt->{app}{'version'} ||= $Glade_Perl->app->version; | ||
| 830 | $proj_opt->{app}{'date'} ||= $Glade_Perl->app->date || $Glade_Perl->{$type}->start_time; | ||
| 831 | $proj_opt->{app}{'copying'} ||= $Glade_Perl->app->copying; | ||
| 832 | $proj_opt->{app}{'description'} ||= $Glade_Perl->app->description || 'No description'; | ||
| 833 | $proj_opt->{$type}->{xml}->{set_by}=($me); | ||
| 834 | $proj_opt->{app}{'use_modules'} ||= $Glade_Perl->app->use_modules; | ||
| 835 | |||
| 836 | $proj_opt->{app}{use_modules} = | ||
| 837 | [split (/\n/, ($proj_opt->{app}{use_modules} || ''))] | ||
| 838 | unless ref $proj_opt->{app}{use_modules} eq 'ARRAY'; | ||
| 839 | #print Dumper($proto->{app}); | ||
| 840 | #print Dumper($Glade_Perl->{app}); | ||
| 841 | #print Dumper($proj_opt->{app}); | ||
| 842 | # Now change to the <project><directory> so that we can find modules | ||
| 843 | chdir $proj_opt->{glade}{directory}; | ||
| 844 | |||
| 845 | $Glade_Perl->diag_print(6, $proj_opt); | ||
| 846 | return $proj_opt; | ||
| 847 | } | ||
| 848 | |||
| 849 | sub tree_from_string { | ||
| 850 | my ($class, $xml, $encoding) = @_; | ||
| 851 | my $me = (ref $class || $class)."->tree_from_string"; | ||
| 852 | my $xml_encoding; | ||
| 853 | if ($xml =~ s/\<\?xml.*\s*encoding\=["'](.*?)['"]\s*\?\>\n*//) { | ||
| 854 | $xml_encoding = $1; | ||
| 855 | } else { | ||
| 856 | $xml_encoding = $encoding; | ||
| 857 | } | ||
| 858 | print " - Actual encoding found is '$xml_encoding'\n" | ||
| 859 | if $encoding ne $xml_encoding; | ||
| 860 | |||
| 861 | my $tree = new XML::Parser( | ||
| 862 | Style =>'Tree', | ||
| 863 | ProtocolEncoding => $xml_encoding, | ||
| 864 | ErrorContext => 2)->parse($xml); | ||
| 865 | return ($xml_encoding, $tree); | ||
| 866 | } | ||
| 867 | |||
| 868 | sub proto_from_tree { | ||
| 869 | my ($class, $tree, $depth, $array, $hash, $special, $encoding) = @_; | ||
| 870 | my $me = (ref $class||$class)."->proto_from_tree"; | ||
| 871 | |||
| 872 | # FIXME make this general for all encodings | ||
| 873 | if ($encoding && ($encoding eq 'ISO-8859-1')) { | ||
| 874 | eval "use Unicode::String qw(utf8 latin1)"; | ||
| 875 | undef $encoding if $@; # We can't use encodings correctly | ||
| 876 | } else { | ||
| 877 | undef $encoding; # We don't recognise the encodings name | ||
| 878 | } | ||
| 879 | my ($tk, $i, $ilimit); | ||
| 880 | my ($count, $np, $work, $type, $value, $attr_hash, $propkey); | ||
| 881 | my $limit = scalar(@$tree); | ||
| 882 | my $child; | ||
| 883 | $np = $tree->[0] if keys %{$tree->[0]}; | ||
| 884 | for ($count = 3; $count < $limit; $count += 4) { | ||
| 885 | $ilimit = scalar @{$tree->[$count+1]}; | ||
| 886 | $type = $tree->[$count]; | ||
| 887 | $attr_hash = $tree->[$count+1][0]; | ||
| 888 | $value = $tree->[$count+1][2]; | ||
| 889 | # FIXME make this general for all encodings | ||
| 890 | if (defined $value && $encoding && ($encoding eq 'ISO-8859-1')) { | ||
| 891 | $value = &utf8($value)->latin1; | ||
| 892 | } | ||
| 893 | # $value = $tree->[$count+1][2]; | ||
| 894 | if (" $array " =~ / $type /) { | ||
| 895 | push @{$np->{$type}}, | ||
| 896 | $class->proto_from_tree( | ||
| 897 | $tree->[$count + 1], $depth+1, | ||
| 898 | $array, $hash, $special, $encoding); | ||
| 899 | |||
| 900 | } elsif (" $hash " =~ / $type /) { | ||
| 901 | if ($ilimit <= 3) { | ||
| 902 | # We have a bottom level element (property) to add | ||
| 903 | $propkey = $attr_hash->{'name'}; | ||
| 904 | $work = $attr_hash, | ||
| 905 | delete $work->{'name'}; | ||
| 906 | $work->{'value'} = $value; | ||
| 907 | # delete $attr_hash->{'name'}; | ||
| 908 | $np->{$type}{$propkey} = $work; | ||
| 909 | # push(@{$np->{'property'}}, $work); | ||
| 910 | |||
| 911 | } else { | ||
| 912 | # We have some sub element(s) | ||
| 913 | # so call ourself to expand nested xml | ||
| 914 | # $np->{$type} = $class->proto_from_tree( | ||
| 915 | $work = $class->proto_from_tree( | ||
| 916 | $tree->[$count + 1], $depth+1, | ||
| 917 | $array, $hash, $special, $encoding); | ||
| 918 | push @{$np->{'widget'}{'child'}}, $work; | ||
| 919 | } | ||
| 920 | |||
| 921 | } elsif (" $special " =~ / $type /) { | ||
| 922 | # this is a special object (eg <widget>) that is stored | ||
| 923 | # differently depending on whether it is toplevel or not | ||
| 924 | # This is because the glade-2 structure is inconsistent. | ||
| 925 | if ($depth) { | ||
| 926 | # Usual type of widget so stored as hash | ||
| 927 | $np->{$type} = $class->proto_from_tree( | ||
| 928 | $tree->[$count + 1], $depth+1, | ||
| 929 | $array, $hash, $special, $encoding); | ||
| 930 | |||
| 931 | } else { | ||
| 932 | # Toplevel widget so push to 'form' super-element | ||
| 933 | push @{$np->{'form'}}, { | ||
| 934 | $type => $class->proto_from_tree( | ||
| 935 | $tree->[$count + 1], $depth+1, | ||
| 936 | $array, $hash, $special, $encoding) | ||
| 937 | }; | ||
| 938 | } | ||
| 939 | } elsif ($ilimit == 1) { | ||
| 940 | # this is an empty (nul string) element | ||
| 941 | $np->{$type} = ''; | ||
| 942 | |||
| 943 | } else { | ||
| 944 | print "We found a '$type' element - it has not been stored\n"; | ||
| 945 | } | ||
| 946 | } | ||
| 947 | # $depth--; | ||
| 948 | return $np; | ||
| 949 | } | ||
| 950 | |||
| 951 | #=============================================================================== | ||
| 952 | #=========== Utilities to construct the form from a Proto ==== | ||
| 953 | #=============================================================================== | ||
| 954 | sub pre_generate_from_proto { | ||
| 955 | my ($class, $proto) = @_; | ||
| 956 | my $me = (ref $class||$class)."->pre_generate_from_proto"; | ||
| 957 | |||
| 958 | $Glade_Perl->diag_print(7, $Glade_Perl->glade->proto); | ||
| 959 | |||
| 960 | my ($module); | ||
| 961 | my $options = $proto; | ||
| 962 | $indent ||= ' '; | ||
| 963 | $forms = {}; | ||
| 964 | $widgets = {}; | ||
| 965 | $current_form && eval "$current_form = {};"; | ||
| 966 | |||
| 967 | $Glade_Perl->diag_print (2, "%s- Constructing form(s) from Glade file '%s' - %s", | ||
| 968 | $indent, $proto->glade->file, $proto->glade->name_from); | ||
| 969 | $Glade::Two::Run::pixmaps_directory = $class->glade->pixmaps_directory; | ||
| 970 | |||
| 971 | foreach $module (@{$proto->app->use_modules}) { | ||
| 972 | if ($module && $module ne '') { | ||
| 973 | eval "use $module;" or | ||
| 974 | ($@ && | ||
| 975 | die "\n\nin $me\n\t".("while trying to eval"). | ||
| 976 | " 'use $module'". | ||
| 977 | "\n\t".("FAILED with Eval error")." '$@'\n"); | ||
| 978 | push @use_modules, $module; | ||
| 979 | $Glade_Perl->diag_print (2, | ||
| 980 | "%s- Use()ing existing module '%s' in %s", | ||
| 981 | $indent, $module, $me); | ||
| 982 | } | ||
| 983 | } | ||
| 984 | |||
| 985 | if ($options->app->allow_gnome) { | ||
| 986 | $Glade_Perl->diag_print (6, "%s- Use()ing Gnome2 in %s", $indent, $me); | ||
| 987 | eval "use Gnome2;"; | ||
| 988 | unless (Gnome::Stock->can('pixmap_widget')) { | ||
| 989 | $Glade_Perl->diag_print (1, | ||
| 990 | "%s- You need either to build the Gtk2-Perl Gnome2 module or ". | ||
| 991 | "uncheck the Glade 'Enable Gnome Support' project option", | ||
| 992 | $options->diag->indent); | ||
| 993 | $Glade_Perl->diag_print (1, | ||
| 994 | "%s- Continuing without Gnome2 for now although ". | ||
| 995 | "the generate run will fail if there are any Gnome2 widgets ". | ||
| 996 | "specified in your project", | ||
| 997 | $options->diag->indent); | ||
| 998 | $options->app->allow_gnome(0); | ||
| 999 | } | ||
| 1000 | Gnome2->init(__PACKAGE__, $VERSION); | ||
| 1001 | } else { | ||
| 1002 | Gtk2->init; | ||
| 1003 | } | ||
| 1004 | unless ($proto->app->allow_gnome) { | ||
| 1005 | $proto->widgets->to_ignore( | ||
| 1006 | $proto->widgets->to_ignore." ". | ||
| 1007 | $proto->widgets->gnome); | ||
| 1008 | } | ||
| 1009 | unless ($proto->app->allow_gnome_db) { | ||
| 1010 | $proto->widgets->to_ignore( | ||
| 1011 | $proto->widgets->to_ignore." ". | ||
| 1012 | $proto->widgets->gnome_db); | ||
| 1013 | } | ||
| 1014 | } | ||
| 1015 | |||
| 1016 | sub generate_from_proto { | ||
| 1017 | my ($class, $parentname, $proto, $depth, $awh, $ach) = @_; | ||
| 1018 | my $me = (ref $class || $class)."->generate_from_proto"; | ||
| 1019 | my ($name, $childname, $window, $sig); | ||
| 1020 | my ($key, $dm, $expr, $object, $packing, $item, $sig_string, @sig_strings); | ||
| 1021 | $parentname ||= "Top level application"; | ||
| 1022 | my ($wh, $ch);# = ($awh, $ach); | ||
| 1023 | $class->diag_print(7, $proto); | ||
| 1024 | if (ref $proto eq 'ARRAY') { | ||
| 1025 | foreach my $child (@{$proto}) { | ||
| 1026 | # Construct child widget | ||
| 1027 | $child->{'widget'}{name} = $child->{'widget'}{id}; | ||
| 1028 | ($wh, $ch) = $class->process_widget( | ||
| 1029 | $parentname, $child, $depth+1, $awh, $ach); | ||
| 1030 | |||
| 1031 | # Call ourself to recurse through child's children widgets | ||
| 1032 | $class->generate_from_proto( | ||
| 1033 | $child->{'widget'}{'name'}, | ||
| 1034 | $child->{'widget'}{'child'}, $depth+1, $wh, $ch); | ||
| 1035 | $class->add_to_UI($depth+1, "# ".S_("End of"). | ||
| 1036 | " $child->{'widget'}{class} '$child->{'widget'}{'name'}'"); | ||
| 1037 | $class->add_to_UI($depth+1, "#"); | ||
| 1038 | } | ||
| 1039 | } | ||
| 1040 | if ($depth == 1) { | ||
| 1041 | # We are a toplevel window so now connect all accel_labels | ||
| 1042 | # eval "print Dumper(\\\@{${current_form}\{Accel_Strings}})"; | ||
| 1043 | eval "\@sig_strings = \@{${current_form}\{Accel_Strings}}"; | ||
| 1044 | if (scalar(@sig_strings)) { | ||
| 1045 | $class->load_class("Gtk2::AccelLabel"); | ||
| 1046 | # We have some accel_labels to connect | ||
| 1047 | $class->add_to_UI($depth, "#"); | ||
| 1048 | $class->add_to_UI($depth, | ||
| 1049 | "# ".S_("Connect all accel_labels now that widgets are constructed")); | ||
| 1050 | foreach $sig_string (@sig_strings) { | ||
| 1051 | eval $sig_string; | ||
| 1052 | } | ||
| 1053 | } | ||
| 1054 | # Now connect all signals | ||
| 1055 | # eval "print Dumper(\\\@{${current_form}\{Signal_Strings}})"; | ||
| 1056 | eval "\@sig_strings = \@{${current_form}\{Signal_Strings}}"; | ||
| 1057 | if (scalar(@sig_strings)) { | ||
| 1058 | $class->load_class("Gtk2::GSignal"); | ||
| 1059 | # We have some signals to connect | ||
| 1060 | $class->add_to_UI($depth, "#"); | ||
| 1061 | $class->add_to_UI($depth, | ||
| 1062 | "# ".S_("Connect all signals now that widgets are constructed")); | ||
| 1063 | foreach $sig_string (@sig_strings) { | ||
| 1064 | eval $sig_string; | ||
| 1065 | } | ||
| 1066 | } | ||
| 1067 | } | ||
| 1068 | return ($wh, $ch); | ||
| 1069 | } | ||
| 1070 | |||
| 1071 | sub load_class { | ||
| 1072 | my ($class, $module) = @_; | ||
| 1073 | my $expr = "use $module"; | ||
| 1074 | $current_widget = $module; | ||
| 1075 | eval $expr || | ||
| 1076 | $@ && $class->log_error($expr, $@); | ||
| 1077 | |||
| 1078 | eval "${current_form}\{$USES}{'$module'}++"; | ||
| 1079 | } | ||
| 1080 | |||
| 1081 | sub add_placeholder_label { | ||
| 1082 | my ($class, $widget, $childname, $parentname, $depth) = @_; | ||
| 1083 | my $message = sprintf(S_("PH for \\\'%s\\\'"), $childname); | ||
| 1084 | |||
| 1085 | $class->add_to_UI($depth, | ||
| 1086 | "${current_form}\{'$childname'} = ". | ||
| 1087 | "new Gtk2::Label(_('$message'));"); | ||
| 1088 | # $class->add_to_UI($depth, | ||
| 1089 | # "${current_form}\{'$childname'}->set_line_wrap(1);"); | ||
| 1090 | $class->add_to_UI($depth, | ||
| 1091 | "${current_form}\{'$childname'}->show;"); | ||
| 1092 | $class->add_to_UI($depth, | ||
| 1093 | "${current_form}\{'$parentname'}->add(${current_form}\{'$childname'});"); | ||
| 1094 | } | ||
| 1095 | |||
| 1096 | sub process_widget { | ||
| 1097 | my ($class, $parentname, $proto, $depth, $awh, $ach) = @_; | ||
| 1098 | my $me = (ref $class || $class)."->process_widget"; | ||
| 1099 | my ($wh, $ch);# = ($awh, $ach); | ||
| 1100 | $class->diag_print(8, $Glade_Perl); | ||
| 1101 | if ($class->my_gtk_perl_can_do($proto->{'widget'}{'class'})) { | ||
| 1102 | unless (" $Glade_Perl->{'widgets'}{'to_ignore'} " =~ / $proto->{'widget'}{'class'} /) { | ||
| 1103 | # This is a real widget subhash so recurse to expand | ||
| 1104 | ($wh, $ch) = $class->new_widget( | ||
| 1105 | $parentname, $proto, $depth, $awh, $ach); | ||
| 1106 | |||
| 1107 | # $class->set_child_packing( | ||
| 1108 | # $parentname, $proto->{'widget'}{'name'}, $proto, $depth); | ||
| 1109 | if ($Glade_Perl->diagnostics) { | ||
| 1110 | # Check that we have used all widget properties | ||
| 1111 | $class->check_for_unused_properties($proto->{'widget'}); | ||
| 1112 | $class->check_for_unused_packing_properties( | ||
| 1113 | $proto->{'packing'}, $proto->{'widget'}{'name'}); | ||
| 1114 | } | ||
| 1115 | |||
| 1116 | } else { | ||
| 1117 | unless (" $Glade_Perl->{'widgets'}{'gnome'} " =~ / $proto->{'widget'}{'class'} /) { | ||
| 1118 | $Glade_Perl->diag_print(3, | ||
| 1119 | "warn %s in %s ignored in %s", | ||
| 1120 | $proto->{'widget'}{'class'}, $parentname, $me); | ||
| 1121 | } else { | ||
| 1122 | $Glade_Perl->diag_print(1, "error %s in %s ignored in %s", | ||
| 1123 | "$proto->{'widget'}{'class'} ($proto->{'widget'}{'name'}) and ". | ||
| 1124 | "any child widgets", ($parentname || 'Glade project'), $me); | ||
| 1125 | undef $proto->{'widget'}{'child'}; | ||
| 1126 | } | ||
| 1127 | $failures->{$IGNORED_WIDGET}{$proto->{'widget'}{'class'}}++; | ||
| 1128 | $class->add_placeholder_label($proto->{'widget'}{'class'}, | ||
| 1129 | $proto->{'widget'}{'name'}, $parentname, $depth); | ||
| 1130 | } | ||
| 1131 | } else { | ||
| 1132 | undef $proto->{'widget'}{'child'}; | ||
| 1133 | my $widget = $proto->{'widget'}{'class'}; | ||
| 1134 | $widget =~ s/^Gtk/Gtk2::/; | ||
| 1135 | # $failures->{$widget}{$NO_SUCH_WIDGET}++; | ||
| 1136 | $class->add_placeholder_label($proto->{'widget'}{'class'}, | ||
| 1137 | $proto->{'widget'}{'name'}, $parentname, $depth); | ||
| 1138 | } | ||
| 1139 | |||
| 1140 | return ($wh, $ch); | ||
| 1141 | } | ||
| 1142 | |||
| 1143 | sub new_widget { | ||
| 1144 | my ($class, $parentname, $proto, $depth, $awh, $ach) = @_; | ||
| 1145 | my $me = (ref $class || $class)."->new_widget"; | ||
| 1146 | my ($wh, $ch) = ($awh, $ach); | ||
| 1147 | my ($name, $constructor, $expr); | ||
| 1148 | unless ($proto->{'widget'}{'name'}) { | ||
| 1149 | if (defined $proto->{'placeholder'}) { | ||
| 1150 | $Glade_Perl->{'widgets'}{'ignored'}++; | ||
| 1151 | } else { | ||
| 1152 | $Glade_Perl->diag_print (2, | ||
| 1153 | "You have supplied a proto without a name to %s", $me); | ||
| 1154 | $Glade_Perl->diag_print (2, $proto); | ||
| 1155 | } | ||
| 1156 | return; | ||
| 1157 | } else { | ||
| 1158 | $name = $proto->{'widget'}{'name'}; | ||
| 1159 | } | ||
| 1160 | #print Dumper($proto); | ||
| 1161 | if ($depth == 1) { | ||
| 1162 | $name = $class->fix_name($name); | ||
| 1163 | $proto->{'widget'}{name} = $name; | ||
| 1164 | $proto->{'widget'}{id} = $name; | ||
| 1165 | if (keys %{$forms->{$name}}) { | ||
| 1166 | die "You have already defined a form called '$name'"; | ||
| 1167 | } | ||
| 1168 | $forms->{$name} = {}; | ||
| 1169 | # We are a toplevel window so create a new hash and | ||
| 1170 | # set $current_form with its name | ||
| 1171 | # All these back-slashes are really necessary as this string | ||
| 1172 | # is passed through so many others | ||
| 1173 | $current_form_name = "$name-\\\\\\\$instance"; | ||
| 1174 | $current_form = "\$forms->{'$name'}"; | ||
| 1175 | $current_data = "\$data->{'$name'}\{$DATA}"; | ||
| 1176 | $current_name = $name; | ||
| 1177 | $current_window = "\$forms->{'$name'}\{'$name'}"; | ||
| 1178 | $first_form ||= $name; | ||
| 1179 | |||
| 1180 | if ($Glade_Perl->source->hierarchy =~ /^(widget|both)/) { | ||
| 1181 | $wh = "\$forms->{'$name'}{$WH}"; | ||
| 1182 | } | ||
| 1183 | if ($Glade_Perl->source->hierarchy =~ /^(class|both)/) { | ||
| 1184 | $ch = "\$forms->{'$name'}{$CH}"; | ||
| 1185 | } | ||
| 1186 | |||
| 1187 | } else { | ||
| 1188 | $wh = "$wh\{'$name'}" if $awh; | ||
| 1189 | $ch = "$ch\{'$proto->{'widget'}{class}'}{'$name'}" if $ach; | ||
| 1190 | } | ||
| 1191 | $class->add_to_UI($depth, "#"); | ||
| 1192 | $class->add_to_UI($depth, "# ".S_("Construct a"). | ||
| 1193 | " $proto->{'widget'}{class} '$name'"); | ||
| 1194 | if (defined $proto->{'internal-child'}) { | ||
| 1195 | # We have a special way to get at the widget (we hope) | ||
| 1196 | $failures->{$INTERNAL_CHILD}{$parentname}{$proto->{'internal-child'}}++; | ||
| 1197 | } | ||
| 1198 | # if (" GtkCList GtkCTree " =~ / $proto->{'widget'}{class} /) { | ||
| 1199 | # $proto->{'widget'}{class} = "GtkTreeView"; | ||
| 1200 | # } | ||
| 1201 | my $widget_class = $proto->{'widget'}{class}; | ||
| 1202 | if ($widget_class =~ s/^Gtk/Gtk2::/) { | ||
| 1203 | $class->load_class($widget_class); | ||
| 1204 | } | ||
| 1205 | $constructor = "new_$proto->{'widget'}{class}"; | ||
| 1206 | if ($class->can($constructor)) { | ||
| 1207 | my $eval_class = __PACKAGE__;#ref $class || $class; | ||
| 1208 | # Construct the widget | ||
| 1209 | $expr = "\$widgets->{'$name'} = ". | ||
| 1210 | "$eval_class->$constructor('$parentname', \$proto, $depth);"; | ||
| 1211 | |||
| 1212 | eval $expr || | ||
| 1213 | $@ && $class->log_error($expr, $@); | ||
| 1214 | |||
| 1215 | } else { | ||
| 1216 | $class->log_error("Construct a '$constructor'" , | ||
| 1217 | sprintf("error I don't have a constructor called '%s' ". | ||
| 1218 | "- I guess that it isn't written yet :-)", | ||
| 1219 | (ref $class || $class)."->$constructor")); | ||
| 1220 | return; | ||
| 1221 | } | ||
| 1222 | if ($wh) { | ||
| 1223 | # Add to form widget hierarchy | ||
| 1224 | $class->add_to_UI($depth, | ||
| 1225 | "$wh\{$WIDGET_INSTANCE} = $current_form\{'$name'};"); | ||
| 1226 | } | ||
| 1227 | if ($ch) { | ||
| 1228 | # Add to form class hierarchy | ||
| 1229 | $class->add_to_UI($depth, | ||
| 1230 | "$ch\{$WIDGET_INSTANCE} = $current_form\{'$name'};"); | ||
| 1231 | } | ||
| 1232 | if ($Glade_Perl->source->hierarchy =~ /order/) { | ||
| 1233 | if ($depth > 1) { | ||
| 1234 | $class->add_to_UI($depth, | ||
| 1235 | "push \@{$awh\{$C}}, $current_form\{'$name'};"); | ||
| 1236 | } | ||
| 1237 | } | ||
| 1238 | foreach my $signal (@{$proto->{'widget'}{'signal'}}) { | ||
| 1239 | $class->new_signal($proto->{'widget'}{'name'}, $signal, $depth); | ||
| 1240 | } | ||
| 1241 | foreach my $accelerator (@{$proto->{'widget'}{'accelerator'}}) { | ||
| 1242 | $class->new_accelerator($proto->{'widget'}{'name'}, $accelerator, $depth); | ||
| 1243 | } | ||
| 1244 | |||
| 1245 | return ($wh, $ch); | ||
| 1246 | } | ||
| 1247 | |||
| 1248 | sub post_generate_from_proto { | ||
| 1249 | my ($class, $proto) = @_; | ||
| 1250 | my $me = (ref $class || $class)."->form_from_proto"; | ||
| 1251 | |||
| 1252 | my $save_module = $proto->test->use_module; | ||
| 1253 | my ($module); | ||
| 1254 | my $options = $proto; | ||
| 1255 | |||
| 1256 | #print Dumper($failures); | ||
| 1257 | # Now write the disk files | ||
| 1258 | if ($Glade_Perl->Writing_to_File) { | ||
| 1259 | # Load the source code gettext translations | ||
| 1260 | unless ($options->source->LANG) { | ||
| 1261 | $options->source->LANG($options->diag->LANG); | ||
| 1262 | } | ||
| 1263 | $class->load_translations('Glade-One-Perl', $options->source->LANG, | ||
| 1264 | undef, undef, $SOURCE_LANG, undef); | ||
| 1265 | # $class->load_translations('Glade-One-Perl', $options->source->LANG, undef, | ||
| 1266 | # '/home/dermot/Devel/Glade-Perl/ppo/en.mo', $SOURCE_LANG, undef); | ||
| 1267 | # $class->start_checking_gettext_strings($SOURCE_LANG); | ||
| 1268 | my $gen_type = " Style ".$options->source->style; | ||
| 1269 | if ($options->source->quick_gen) { | ||
| 1270 | $gen_type .= " with NO VALIDATION!"; | ||
| 1271 | } | ||
| 1272 | $Glade_Perl->diag_print (2, "%s- Source code will be generated for ". | ||
| 1273 | "locale <%s>%s", | ||
| 1274 | $indent, $options->source->LANG, $gen_type); | ||
| 1275 | |||
| 1276 | $proto->app->logo(basename ($proto->app->logo)); | ||
| 1277 | $module = $proto->module->directory unless $proto->module->directory eq '.'; | ||
| 1278 | $module =~ s/.*\/(.*)$/$1/; | ||
| 1279 | $module .= "::" if $module; | ||
| 1280 | |||
| 1281 | $proto->test->first_form($proto->test->first_form || $first_form); | ||
| 1282 | |||
| 1283 | #print Dumper($Glade_Perl->module->gtk); | ||
| 1284 | if ($options->source->style && $options->source->style eq "Libglade") { | ||
| 1285 | # Write source that will use libglade to show the UI | ||
| 1286 | $Glade_Perl->diag_print (2, "%s Generating libglade type code", $indent); | ||
| 1287 | $class->write_LIBGLADE($proto, $forms); | ||
| 1288 | $options->run_options->dont_show_UI(1); | ||
| 1289 | $proto->test->use_module($save_module || | ||
| 1290 | $module.$proto->test->use_module. | ||
| 1291 | $proto->module->libglade->class."LIBGLADE"); | ||
| 1292 | $proto->test->first_form($proto->test->first_form); | ||
| 1293 | $Glade_Perl->diag_print (2, | ||
| 1294 | "%s- One of the ways to run the generated source", $indent); | ||
| 1295 | $Glade_Perl->diag_print (2, | ||
| 1296 | "%s Change directory to '%s' and then enter:", | ||
| 1297 | "$indent$indent", $proto->glade->directory); | ||
| 1298 | $Glade_Perl->diag_print (2,"%s", | ||
| 1299 | "$indent$indent perl -e 'use ". | ||
| 1300 | $proto->test->use_module."; ". | ||
| 1301 | $proto->test->first_form."->app_run'"); | ||
| 1302 | |||
| 1303 | } elsif ($options->source->style && $options->source->style eq "onefile") { | ||
| 1304 | # Generate UI, handlers and pixmap subs in one file | ||
| 1305 | $Glade_Perl->diag_print (2, "%s Generating ONEFILE type code", $indent); | ||
| 1306 | $class->write_ONEFILE($proto, $forms); | ||
| 1307 | $options->run_options->dont_show_UI(1); | ||
| 1308 | $proto->test->use_module($save_module || | ||
| 1309 | $module.$proto->test->use_module. | ||
| 1310 | $proto->module->onefile->class."ONEFILE"); | ||
| 1311 | $proto->test->first_form($proto->test->first_form); | ||
| 1312 | $Glade_Perl->diag_print (2, | ||
| 1313 | "%s- One of the ways to run the generated source", $indent); | ||
| 1314 | $Glade_Perl->diag_print (2, | ||
| 1315 | "%s Change directory to '%s' and then enter:", | ||
| 1316 | "$indent$indent", $proto->glade->directory); | ||
| 1317 | $Glade_Perl->diag_print (2,"%s", | ||
| 1318 | "$indent$indent perl -e 'use ". | ||
| 1319 | $proto->test->use_module."; ". | ||
| 1320 | $proto->test->first_form."->app_run'"); | ||
| 1321 | |||
| 1322 | |||
| 1323 | } else { | ||
| 1324 | $Glade_Perl->diag_print (4, "%s- Generating UI construction code", $indent); | ||
| 1325 | $class->write_UI($proto, $forms); | ||
| 1326 | |||
| 1327 | $Glade_Perl->diag_print (4, "%s- Generating signal handler code", $indent); | ||
| 1328 | if ($options->source->style && $options->source->style =~ /split/i) { | ||
| 1329 | $class->write_split_SIGS($proto, $forms); | ||
| 1330 | $proto->test->use_module($save_module || | ||
| 1331 | $module.$proto->test->use_module. | ||
| 1332 | $proto->module->app->class. | ||
| 1333 | "_".$proto->test->first_form); | ||
| 1334 | $Glade_Perl->diag_print (2, | ||
| 1335 | "%s- Some of the ways to run the generated source", $indent); | ||
| 1336 | $Glade_Perl->diag_print (2, | ||
| 1337 | "%s Change directory to '%s' and then enter one of :", | ||
| 1338 | "$indent$indent", $proto->glade->directory); | ||
| 1339 | $Glade_Perl->diag_print (2,"%s", | ||
| 1340 | "$indent$indent perl -e 'use ". | ||
| 1341 | $proto->test->use_module."; ". | ||
| 1342 | $proto->test->first_form."->app_run'"); | ||
| 1343 | |||
| 1344 | } else { | ||
| 1345 | $class->write_SIGS($proto, $forms); | ||
| 1346 | $proto->test->use_module($save_module || | ||
| 1347 | $module.$proto->test->use_module. | ||
| 1348 | $proto->module->app->class); | ||
| 1349 | $Glade_Perl->diag_print (2, | ||
| 1350 | "%s- Some of the ways to run the generated source", $indent); | ||
| 1351 | $Glade_Perl->diag_print (2, | ||
| 1352 | "%s Change directory to '%s' and then enter one of :", | ||
| 1353 | "$indent$indent", $proto->glade->directory); | ||
| 1354 | $Glade_Perl->diag_print (2,"%s", | ||
| 1355 | "$indent$indent perl -e 'use ". | ||
| 1356 | $proto->test->use_module."; ". | ||
| 1357 | $proto->test->first_form."->app_run'"); | ||
| 1358 | $Glade_Perl->diag_print (4, "%s- Generating OO subclass code", $indent); | ||
| 1359 | $class->write_SUBCLASS($proto, $forms); | ||
| 1360 | } | ||
| 1361 | $Glade_Perl->diag_print (2, "%s", | ||
| 1362 | "$indent$indent perl -e 'use ". | ||
| 1363 | $module.$proto->module->subapp->class. | ||
| 1364 | "; Sub".$Glade_Perl->test->first_form."->app_run'"); | ||
| 1365 | $Glade_Perl->diag_print (2, "%s", | ||
| 1366 | "$indent$indent ./". | ||
| 1367 | $class->relative_path( | ||
| 1368 | $proto->dist->bin_directory, | ||
| 1369 | $proto->dist->bin) | ||
| 1370 | ); | ||
| 1371 | } | ||
| 1372 | } | ||
| 1373 | |||
| 1374 | $Glade_Perl->write_documentation; | ||
| 1375 | $Glade_Perl->write_distribution; | ||
| 1376 | |||
| 1377 | $class->report_errors if keys %$failures; | ||
| 1378 | # $object->write_missing_gettext_strings($SOURCE_LANG); | ||
| 1379 | |||
| 1380 | # $object->write_missing_gettext_strings($DIAG_LANG, "&STDOUT", "NO_HEADER"); | ||
| 1381 | |||
| 1382 | # And show UI if necessary | ||
| 1383 | unless ($Glade_Perl->Writing_Source_only) { | ||
| 1384 | #print Dumper($forms); | ||
| 1385 | $forms->{$first_form}{$first_form}->show; | ||
| 1386 | Gtk2->main; | ||
| 1387 | } | ||
| 1388 | |||
| 1389 | $Glade_Perl->test->directory($Glade_Perl->test->directory || | ||
| 1390 | $class->full_Path($Glade_Perl->glade->directory, `pwd`)); | ||
| 1391 | $Glade_Perl->test->name($Glade_Perl->test->name || $Glade_Perl->glade->{'name'}); | ||
| 1392 | |||
| 1393 | return $proto; | ||
| 1394 | } | ||
| 1395 | |||
| 1396 | #=============================================================================== | ||
| 1397 | #=========== Diagnostic utilities ============ | ||
| 1398 | #===============================================================================n_options | ||
| 1399 | sub check_for_unused_properties { | ||
| 1400 | my ($class, $proto) = @_; | ||
| 1401 | my $me = (ref $class || $class)."->check_for_unused_properties"; | ||
| 1402 | my $key; | ||
| 1403 | my ($object,$name); | ||
| 1404 | #print "$proto->{'class'} '$proto->{'name'}' ", Dumper($proto->{'widget'}{'property'}); | ||
| 1405 | foreach $key (keys %{$proto->{'property'}}) { | ||
| 1406 | if (defined $proto->{'property'}{$key}{'value'}) { | ||
| 1407 | $object = $proto->{'class'} || ''; | ||
| 1408 | $name = $proto->{'name'} || '(no name)'; | ||
| 1409 | if (" $Glade_Perl->{'properties'}{'cxx'} " =~ m/ $key /) { | ||
| 1410 | $Glade_Perl->diag_print (4, | ||
| 1411 | "warn Intentionally ignored property for %s %s {'%s'}{'%s'} => '%s' seen by %s", | ||
| 1412 | $key, $object, $name, $key, $proto->{'property'}{$key}{'value'}, $me); | ||
| 1413 | } elsif (!$Glade_Perl->source->quick_gen) { | ||
| 1414 | $Glade_Perl->diag_print (1, | ||
| 1415 | "error Unused widget property for %s {'%s'}{'%s'} => '%s' seen by %s", | ||
| 1416 | $object, $name, $key, $proto->{'property'}{$key}{'value'}, $me); | ||
| 1417 | push(@{$failures->{$UNUSED_PROPERTIES}{$current_widget}}, | ||
| 1418 | "{'$name'}{'$key'} = '$proto->{'property'}{$key}{'value'}'"); | ||
| 1419 | $Glade_Perl->properties->{'unhandled'}++; | ||
| 1420 | } | ||
| 1421 | } | ||
| 1422 | } | ||
| 1423 | #print "$proto->{'class'} '$proto->{'name'}' ", Dumper($proto->{'widget'}{'property'}); | ||
| 1424 | return $Glade_Perl->properties->unhandled; | ||
| 1425 | } | ||
| 1426 | |||
| 1427 | sub check_for_unused_packing_properties { | ||
| 1428 | my ($class, $proto, $name) = @_; | ||
| 1429 | my $me = (ref $class || $class)."->check_for_unused_packing_properties"; | ||
| 1430 | my $key; | ||
| 1431 | foreach $key (keys %{$proto->{'property'}}) { | ||
| 1432 | if (defined $proto->{'property'}{$key}{'value'}) { | ||
| 1433 | if (" $Glade_Perl->{'properties'}{'cxx'} " =~ m/ $key /) { | ||
| 1434 | $Glade_Perl->diag_print (4, | ||
| 1435 | "warn Intentionally ignored property for %s {'%s'}{'%s'} => '%s' seen by %s", | ||
| 1436 | $key, $name, $key, $proto->{'property'}{$key}{'value'}, $me); | ||
| 1437 | } elsif (!$Glade_Perl->source->quick_gen) { | ||
| 1438 | $Glade_Perl->diag_print (1, | ||
| 1439 | "error Unused packing property for {'%s'}{'%s'} => '%s' seen by %s", | ||
| 1440 | $name, $key, $proto->{'property'}{$key}{'value'}, $me); | ||
| 1441 | push(@{$failures->{$UNUSED_PROPERTIES}{$current_widget}}, | ||
| 1442 | "{'$name'}{'$key'} = '$proto->{'property'}{$key}{'value'}'"); | ||
| 1443 | $Glade_Perl->properties->{'unhandled'}++; | ||
| 1444 | } | ||
| 1445 | } | ||
| 1446 | } | ||
| 1447 | #print "$proto->{'class'} '$proto->{'name'}' ", Dumper($proto->{'widget'}{'property'}); | ||
| 1448 | return $Glade_Perl->properties->unhandled; | ||
| 1449 | } | ||
| 1450 | |||
| 1451 | sub check_for_unpacked_widgets { | ||
| 1452 | my ($class) = @_; | ||
| 1453 | my $me = (ref $class || $class)."->check_for_unpacked_widgets"; | ||
| 1454 | my $count = 0; | ||
| 1455 | my $key; | ||
| 1456 | foreach $key (keys %{$widgets}) { | ||
| 1457 | if (defined $widgets->{$key}) { | ||
| 1458 | # We have found an unpacked widget | ||
| 1459 | $count++; | ||
| 1460 | $Glade_Perl->diag_print (1, | ||
| 1461 | "error Unpacked widget '%s' has not been packed ". | ||
| 1462 | "(nor correctly added to the UI file) from %s", | ||
| 1463 | $key, $me); | ||
| 1464 | } | ||
| 1465 | } | ||
| 1466 | return $count; | ||
| 1467 | } | ||
| 1468 | |||
| 1469 | sub unhandled_signals { | ||
| 1470 | my ($class) = @_; | ||
| 1471 | my $me = (ref $class || $class)."->unhandled_signals"; | ||
| 1472 | my ($widget, $signal); | ||
| 1473 | my $count = 0; | ||
| 1474 | # FIXME This is all tosh - what do we need here? | ||
| 1475 | # FIXME Should we produce stubs for these ? if so, do this in perl_sub etc | ||
| 1476 | |||
| 1477 | foreach $widget (keys %{$need_handlers}) { | ||
| 1478 | # if (keys (%{$need_handlers->{$widget})) { | ||
| 1479 | foreach $signal (keys %{$need_handlers->{$widget}}) { | ||
| 1480 | # We have found an unhandled signal (eg from accelerator) | ||
| 1481 | $count++; | ||
| 1482 | $Glade_Perl->diag_print (1, "error Widget '%s' emits a ". | ||
| 1483 | "signal '%s' that ". | ||
| 1484 | "does not have a handler specified - in %s", | ||
| 1485 | $widget, $need_handlers->{$widget}{$signal}, $me); | ||
| 1486 | |||
| 1487 | } | ||
| 1488 | # } else { | ||
| 1489 | # # Nothing to be done | ||
| 1490 | # } | ||
| 1491 | } | ||
| 1492 | return $count; | ||
| 1493 | } | ||
| 1494 | |||
| 1495 | sub what_isa { | ||
| 1496 | my ($class, $object) = @_; | ||
| 1497 | my $isa = ''; | ||
| 1498 | eval "\$isa = \$$object\::ISA[0]"; | ||
| 1499 | if ($isa and ($isa ne "Gtk2::Widget")) { | ||
| 1500 | $isa .= $class->what_isa($isa); | ||
| 1501 | } | ||
| 1502 | return " - $isa" if $isa; | ||
| 1503 | } | ||
| 1504 | |||
| 1505 | sub report_errors { | ||
| 1506 | my ($class) = @_; | ||
| 1507 | my $failure_messages = 0; | ||
| 1508 | my $failure_widgets = 0; | ||
| 1509 | my $cant_do_widgets = scalar(keys %{$failures->{$IGNORED_WIDGET}}); | ||
| 1510 | my $isa; | ||
| 1511 | foreach my $widget (sort keys %$failures) { | ||
| 1512 | $isa = $class->what_isa($widget); | ||
| 1513 | $isa = " (ISA $isa) failed methods " if $isa; | ||
| 1514 | next if " $INTERNAL_CHILD $UNUSED_PROPERTIES $IGNORED_WIDGET " =~ / $widget /; | ||
| 1515 | $Glade_Perl->diag_print (2, $failures->{$widget}, $widget.$isa); | ||
| 1516 | $failure_widgets++; | ||
| 1517 | $failure_messages += scalar(keys %{$failures->{$widget}}); | ||
| 1518 | } | ||
| 1519 | # Look through $proto and report any unused attributes (still defined) | ||
| 1520 | if (!$Glade_Perl->source->quick_gen && $Glade_Perl->diagnostics(2)) { | ||
| 1521 | if ($Glade_Perl->widgets->ignored or $Glade_Perl->properties->unhandled or $class->check_for_unpacked_widgets or $failure_messages) { | ||
| 1522 | $Glade_Perl->diag_print (2, "%s", "-----------------------------------------------------------------------------"); | ||
| 1523 | $Glade_Perl->diag_print (2, "%s CONSISTENCY CHECKS", $indent); | ||
| 1524 | if ($Glade_Perl->properties->unhandled) { | ||
| 1525 | $Glade_Perl->diag_print (2, "%s- %s unused widget properties", $indent, $Glade_Perl->properties->unhandled); | ||
| 1526 | } | ||
| 1527 | if ($Glade_Perl->widgets->ignored) { | ||
| 1528 | $Glade_Perl->diag_print (2, "%s- %s widgets were ignored (one or more of '%s')", | ||
| 1529 | $indent, $Glade_Perl->widgets->ignored, $Glade_Perl->widgets->to_ignore); | ||
| 1530 | } | ||
| 1531 | if ($class->check_for_unpacked_widgets) { | ||
| 1532 | $Glade_Perl->diag_print (2, "%s- %s unpacked widgets", | ||
| 1533 | $indent, $class->check_for_unpacked_widgets); | ||
| 1534 | } | ||
| 1535 | if ($Glade_Perl->diagnostics(4) && $class->unhandled_signals) { | ||
| 1536 | $Glade_Perl->diag_print (4, | ||
| 1537 | "$indent- ".$class->unhandled_signals." unhandled signals"); | ||
| 1538 | } | ||
| 1539 | if ($failure_widgets) { | ||
| 1540 | $Glade_Perl->diag_print (2, "%s- %s Gtk2-Perl widgets had failure", $indent, | ||
| 1541 | $failure_widgets); | ||
| 1542 | } | ||
| 1543 | if ($cant_do_widgets) { | ||
| 1544 | $Glade_Perl->diag_print (2, "%s- %s Ignored Glade widgets", $indent, | ||
| 1545 | $cant_do_widgets); | ||
| 1546 | } | ||
| 1547 | if ($failure_messages) { | ||
| 1548 | $Glade_Perl->diag_print (2, "%s- %s failed Gtk2-Perl calls", $indent, | ||
| 1549 | $failure_messages); | ||
| 1550 | } | ||
| 1551 | $Glade_Perl->diag_print (2, "%s", "-----------------------------------------------------------------------------"); | ||
| 1552 | } | ||
| 1553 | unless ($Glade_Perl->Writing_Source_only) { | ||
| 1554 | $Glade_Perl->diag_print (2, "%s UI MESSAGES - showing missing_handler calls that you triggered, ". | ||
| 1555 | "don't worry, %s will generate dynamic stubs for them all", | ||
| 1556 | $indent, $PACKAGE); | ||
| 1557 | } | ||
| 1558 | } | ||
| 1559 | } | ||
| 1560 | |||
| 1561 | #=============================================================================== | ||
| 1562 | #=========== Project utilities ============ | ||
| 1563 | #=============================================================================== | ||
| 1564 | sub Stop_Writing_to_File { shift->Write_to_File('-1') } | ||
| 1565 | |||
| 1566 | sub Write_to_File { | ||
| 1567 | my ($class) = @_; | ||
| 1568 | my $me = __PACKAGE__."::Write_to_File"; | ||
| 1569 | my $filename = $class->source->write; | ||
| 1570 | if (fileno UI or fileno SIGS or fileno SUBCLASS or | ||
| 1571 | $class->Building_UI_only) { | ||
| 1572 | # Files are already open or we are not writing source | ||
| 1573 | if ($class->Writing_to_File) { | ||
| 1574 | if ($filename eq '-1') { | ||
| 1575 | close UI; | ||
| 1576 | close SUBCLASS; | ||
| 1577 | close SIGS; | ||
| 1578 | $class->diag_print (2, "%s- Closing output file in %s", | ||
| 1579 | $indent, $me); | ||
| 1580 | $class->source->write(undef); | ||
| 1581 | } else { | ||
| 1582 | $class->diag_print (2, "%s- Already writing to %s in %s", | ||
| 1583 | $indent, $class->Writing_to_File, $me); | ||
| 1584 | } | ||
| 1585 | } | ||
| 1586 | |||
| 1587 | } elsif ($filename && ($filename eq '1')) { | ||
| 1588 | $class->diag_print (3, "%s- Using default output files ". | ||
| 1589 | "in Glade <project><source_directory> in %s", | ||
| 1590 | $indent, $me); | ||
| 1591 | |||
| 1592 | } elsif ($filename && ($filename ne '-1')) { | ||
| 1593 | # We want to write source | ||
| 1594 | if ($filename eq 'STDOUT') { | ||
| 1595 | $class->source->write('>&STDOUT'); | ||
| 1596 | } | ||
| 1597 | $class->diag_print (2, "%s- Writing %s source to %s - in %s", | ||
| 1598 | $indent, 'UI ', $filename, $me); | ||
| 1599 | open UI, ">$filename" or | ||
| 1600 | die sprintf(( | ||
| 1601 | "error %s - can't open file '%s' for output"), | ||
| 1602 | $me, $filename); | ||
| 1603 | $class->diag_print (2, "%s- Writing %s source to %s - in %s", | ||
| 1604 | $indent, 'SUBS', $filename, $me); | ||
| 1605 | open SIGS, ">$filename" or | ||
| 1606 | die sprintf(( | ||
| 1607 | "error %s - can't open file '%s' for output"), | ||
| 1608 | $me, $filename); | ||
| 1609 | $class->diag_print (2, "%s- Writing %s source to %s - in %s", | ||
| 1610 | $indent, 'SUBCLASS', $filename, $me); | ||
| 1611 | open SUBCLASS, ">$filename" or | ||
| 1612 | die sprintf(( | ||
| 1613 | "error %s - can't open file '%s' for output"), | ||
| 1614 | $me, $filename); | ||
| 1615 | UI->autoflush(1); | ||
| 1616 | SIGS->autoflush(1); | ||
| 1617 | SUBCLASS->autoflush(1); | ||
| 1618 | } else { | ||
| 1619 | # Nothing to do | ||
| 1620 | } | ||
| 1621 | } | ||
| 1622 | |||
| 1623 | sub Writing_Source_only { shift->run_options->dont_show_UI } | ||
| 1624 | |||
| 1625 | sub get_versions { | ||
| 1626 | my ($class) = @_; | ||
| 1627 | my $type = 'glade2perl-2'; | ||
| 1628 | # We use the CPAN release date (or CVS date) for version checking | ||
| 1629 | my $cpan_date = $gtk_perl_depends->{$Gtk2::VERSION}; | ||
| 1630 | |||
| 1631 | # If we dont recognise the version number we use the latest CVS | ||
| 1632 | # version that was available at our release date | ||
| 1633 | $cpan_date ||= $gtk_perl_depends->{'LATEST_CVS'}; | ||
| 1634 | |||
| 1635 | # If we have a version number rather than CVS date we look it up again | ||
| 1636 | $cpan_date = $gtk_perl_depends->{$cpan_date} | ||
| 1637 | if ($cpan_date < 19000000); | ||
| 1638 | |||
| 1639 | if ($class->{$type}->my_gtk_perl && | ||
| 1640 | ($class->{$type}->my_gtk_perl > $cpan_date)) { | ||
| 1641 | $Glade_Perl->diag_print (2, "%s- %s reported version %s". | ||
| 1642 | " but user overrode with version %s", | ||
| 1643 | $indent, "Gtk2-Perl", "$Gtk2::VERSION (CVS $cpan_date)", | ||
| 1644 | $class->{$type}->my_gtk_perl); | ||
| 1645 | |||
| 1646 | } else { | ||
| 1647 | $class->{$type}->my_gtk_perl($cpan_date); | ||
| 1648 | $Glade_Perl->diag_print (2, "%s- %s reported version %s", | ||
| 1649 | $indent, "Gtk2-Perl", "$Gtk2::VERSION (CVS $cpan_date)"); | ||
| 1650 | } | ||
| 1651 | unless ($class->my_gtk_perl_can_do('MINIMUM REQUIREMENTS')) { | ||
| 1652 | die "You need to upgrade your Gtk2-Perl"; | ||
| 1653 | } | ||
| 1654 | |||
| 1655 | if ($class->app->allow_gnome) { | ||
| 1656 | # my $gnome1_libs_version = `gnome-config --version`; | ||
| 1657 | my $gnome2_libs_version = `pkg-config libgnome-2.0 libgnomeui-2.0 libgnomeprint-2.0 libgnomeprintui-2.0 libgnomecanvas-2.0 --libs`; | ||
| 1658 | my $gnome_libs_version = $gnome2_libs_version; | ||
| 1659 | chomp $gnome_libs_version; | ||
| 1660 | $gnome_libs_version =~ s/gnome-libs //; | ||
| 1661 | if ($class->{$type}->my_gnome_libs && | ||
| 1662 | ($class->{$type}->my_gnome_libs gt $gnome_libs_version)) { | ||
| 1663 | $Glade_Perl->diag_print (2, "%s- %s reported version %s". | ||
| 1664 | " but user overrode with version %s", | ||
| 1665 | $indent, "gnome-libs", $gnome_libs_version, | ||
| 1666 | $class->{$type}->my_gnome_libs); | ||
| 1667 | } else { | ||
| 1668 | $class->{$type}->my_gnome_libs($gnome_libs_version); | ||
| 1669 | $Glade_Perl->diag_print (2, "%s- %s reported version %s", | ||
| 1670 | $indent, "gnome-libs", $gnome_libs_version); | ||
| 1671 | } | ||
| 1672 | unless ($class->my_gnome_libs_can_do('MINIMUM REQUIREMENTS')) { | ||
| 1673 | die "You need to upgrade your gnome-libs"; | ||
| 1674 | } | ||
| 1675 | # Gnome include directories | ||
| 1676 | my $gnome_incs = `gnome-config --includedir`; | ||
| 1677 | chomp $gnome_incs; | ||
| 1678 | if ($class->{$type}->my_gnome_incs && | ||
| 1679 | $class->{$type}->my_gnome_incs ne $gnome_incs) { | ||
| 1680 | $Glade_Perl->diag_print (2, "%s- %s reported include directory '%s'". | ||
| 1681 | " but user overrode with '%s'", | ||
| 1682 | $indent, "gnome-libs", $gnome_incs, | ||
| 1683 | $class->{$type}->my_gnome_incs); | ||
| 1684 | } else { | ||
| 1685 | $class->{$type}->my_gnome_incs($gnome_incs); | ||
| 1686 | $Glade_Perl->diag_print (2, "%s- %s reported include directory '%s'", | ||
| 1687 | $indent, "gnome-libs", $gnome_incs); | ||
| 1688 | } | ||
| 1689 | } | ||
| 1690 | |||
| 1691 | if ($class->app->gtk2) { | ||
| 1692 | # my $gtk1_version = `gtk-config --version`; | ||
| 1693 | my $gtk2_version = `pkg-config --version gtk+-2.0`; | ||
| 1694 | my $gtk_version = $gtk2_version; | ||
| 1695 | chomp $gtk_version; | ||
| 1696 | $gtk_version =~ s/gtk-libs //; | ||
| 1697 | if ($class->{$type}->my_gtk && | ||
| 1698 | ($class->{$type}->my_gtk gt $gtk_version)) { | ||
| 1699 | $Glade_Perl->diag_print (2, "%s- %s reported version %s". | ||
| 1700 | " but user overrode with version %s", | ||
| 1701 | $indent, "gtk", $gtk_version, | ||
| 1702 | $class->{$type}->my_gtk); | ||
| 1703 | } else { | ||
| 1704 | $class->{$type}->my_gtk($gtk_version); | ||
| 1705 | $Glade_Perl->diag_print (2, "%s- %s reported version %s", | ||
| 1706 | $indent, "gtk", $gtk_version); | ||
| 1707 | } | ||
| 1708 | unless ($class->my_gtk_can_do('MINIMUM REQUIREMENTS')) { | ||
| 1709 | die "You need to upgrade your gtk"; | ||
| 1710 | } | ||
| 1711 | # Gnome include directories | ||
| 1712 | my $gtk_incs = `pkg-config gtk+-2.0 --cflags`; | ||
| 1713 | chomp $gtk_incs; | ||
| 1714 | if ($class->{$type}->my_gtk_incs && | ||
| 1715 | $class->{$type}->my_gtk_incs ne $gtk_incs) { | ||
| 1716 | $Glade_Perl->diag_print (2, "%s- %s reported include dir '%s'". | ||
| 1717 | " but user overrode with '%s'", | ||
| 1718 | $indent, "gtk", $gtk_incs, | ||
| 1719 | $class->{$type}->my_gtk_incs); | ||
| 1720 | } else { | ||
| 1721 | $class->{$type}->my_gtk_incs($gtk_incs); | ||
| 1722 | $Glade_Perl->diag_print (2, "%s- %s reported include dir '%s'", | ||
| 1723 | $indent, "gtk", $gtk_incs); | ||
| 1724 | } | ||
| 1725 | } | ||
| 1726 | |||
| 1727 | return $class; | ||
| 1728 | } | ||
| 1729 | |||
| 1730 | #=============================================================================== | ||
| 1731 | #=========== Version utilities ============ | ||
| 1732 | #=============================================================================== | ||
| 1733 | sub my_gtk_perl_can_do { | ||
| 1734 | my ($class, $action) = @_; | ||
| 1735 | my $depends = $gtk_perl_depends->{$action} || ''; | ||
| 1736 | my $cant_do = $gtk_perl_cant_do->{$action} || ''; | ||
| 1737 | unless ($depends or $cant_do) { | ||
| 1738 | # There is no required/cant_do information for $action | ||
| 1739 | return 1; | ||
| 1740 | } | ||
| 1741 | my ($cpan, $cvs); | ||
| 1742 | my $check = $action; | ||
| 1743 | |||
| 1744 | # Check that we have at least the minimum required | ||
| 1745 | $check = $gtk_perl_depends->{$depends} || $depends; | ||
| 1746 | if ($check and $check > $Glade_Perl->run_options->my_gtk_perl) { | ||
| 1747 | $cpan = $gtk_perl_depends->{'LATEST_CPAN'}; | ||
| 1748 | $cpan = $gtk_perl_depends->{$cpan} if $gtk_perl_depends->{$cpan}; | ||
| 1749 | if ($check > $cpan) { | ||
| 1750 | # We need a CVS version | ||
| 1751 | if ($check > $gtk_perl_depends->{'LATEST_CVS'}) { | ||
| 1752 | # The CVS version can't even do it yet | ||
| 1753 | $Glade_Perl->diag_print(1, | ||
| 1754 | "warn Gtk2-Perl dated %s cannot do '%s' (properly)". | ||
| 1755 | " and neither can the CVS version !!! - it has been ignored", | ||
| 1756 | $Glade_Perl->run_options->my_gtk_perl, $action); | ||
| 1757 | |||
| 1758 | } else { | ||
| 1759 | # We need a new CVS version | ||
| 1760 | $Glade_Perl->diag_print(1, | ||
| 1761 | "warn Gtk2-Perl dated %s cannot do '%s' (properly)". | ||
| 1762 | " we need CVS module 'gnome-perl' after %s - it has been ignored", | ||
| 1763 | $Glade_Perl->run_options->my_gtk_perl, $action, $check); | ||
| 1764 | } | ||
| 1765 | |||
| 1766 | } else { | ||
| 1767 | # We need a new CPAN version | ||
| 1768 | $Glade_Perl->diag_print(1, | ||
| 1769 | "warn Gtk2-Perl version %s cannot do '%s' (properly)". | ||
| 1770 | " we need CPAN version %s or CVS module 'gnome-perl' after %s - it has been ignored", | ||
| 1771 | $Glade_Perl->run_options->my_gtk_perl, $action, | ||
| 1772 | $gtk_perl_depends->{$action}, $check); | ||
| 1773 | } | ||
| 1774 | return undef; | ||
| 1775 | } | ||
| 1776 | |||
| 1777 | # Check that we dont have a cant_do version | ||
| 1778 | $check = $gtk_perl_depends->{$cant_do} || $cant_do; | ||
| 1779 | unless ($check and $check == $Glade_Perl->run_options->my_gtk_perl) { | ||
| 1780 | # We can do required $action in our version | ||
| 1781 | return 1; | ||
| 1782 | } else { | ||
| 1783 | # This version can't do it although earlier and later versions may | ||
| 1784 | $Glade_Perl->diag_print(1, | ||
| 1785 | "warn Gtk2-Perl dated %s cannot do '%s' (properly)". | ||
| 1786 | " although older and newer versions may - it has been ignored", | ||
| 1787 | $Glade_Perl->run_options->my_gtk_perl, $action); | ||
| 1788 | return undef; | ||
| 1789 | } | ||
| 1790 | return undef; | ||
| 1791 | } | ||
| 1792 | |||
| 1793 | sub my_gnome_libs_can_do { | ||
| 1794 | my ($class, $action) = @_; | ||
| 1795 | my $depends = $gnome_libs_depends->{$action}; | ||
| 1796 | unless ($depends and $depends gt $Glade_Perl->run_options->my_gnome_libs) { | ||
| 1797 | # There is no specified version or ours is sufficient | ||
| 1798 | return 1; | ||
| 1799 | } | ||
| 1800 | if ($depends ge 19990914) { | ||
| 1801 | # We need a CVS version | ||
| 1802 | if ($depends gt 29990000) { | ||
| 1803 | # The CVS version can't even do it yet | ||
| 1804 | $Glade_Perl->diag_print(1, | ||
| 1805 | "warn gnome_libs version %s cannot do '%s' (properly)". | ||
| 1806 | " and neither can the CVS version !!!", | ||
| 1807 | $Glade_Perl->run_options->my_gnome_libs, $action); | ||
| 1808 | } else { | ||
| 1809 | # We need a new CVS version | ||
| 1810 | $Glade_Perl->diag_print(1, | ||
| 1811 | "warn gnome_libs version %s cannot do '%s' (properly)". | ||
| 1812 | " we need CVS module 'gnome-libs' after %s", | ||
| 1813 | $Glade_Perl->run_options->my_gnome_libs, $action, $depends); | ||
| 1814 | } | ||
| 1815 | } else { | ||
| 1816 | # We need a new released version | ||
| 1817 | $Glade_Perl->diag_print(1, | ||
| 1818 | "warn gnome_libs version %s cannot do '%s' (properly)". | ||
| 1819 | " we need version %s", | ||
| 1820 | $Glade_Perl->run_options->my_gnome_libs, $action, $depends); | ||
| 1821 | } | ||
| 1822 | return undef; | ||
| 1823 | } | ||
| 1824 | |||
| 1825 | #=============================================================================== | ||
| 1826 | #=========== Utilities to construct UI ============ | ||
| 1827 | #=============================================================================== | ||
| 1828 | sub use_set_property { | ||
| 1829 | my ($class, $name, $proto, $property, $type, $depth, $method, $args, $default) = @_; | ||
| 1830 | # $method ||= "$property"; | ||
| 1831 | unless ($method) { | ||
| 1832 | if (eval "\$widgets->{'$name'}->can('$property')") { | ||
| 1833 | $method = "$property"; | ||
| 1834 | } else { | ||
| 1835 | $method = "set_$property"; | ||
| 1836 | } | ||
| 1837 | } | ||
| 1838 | #print Dumper(\@_); | ||
| 1839 | my $value = $class->use_par($proto, $property, $type|$MAYBE); | ||
| 1840 | if (defined $value) { | ||
| 1841 | if ($type & $STRING) { | ||
| 1842 | # if ((defined $default) and ($value ne $default)) { | ||
| 1843 | # $value =~ s/\n/\\n/g; # To get through add_to_UI | ||
| 1844 | # Backslash escape any single quotes (unless they are already backslashed) | ||
| 1845 | $value =~ s/(?!\\)(.)'/$1\\'/g; | ||
| 1846 | $value =~ s/^'/\\'/g; | ||
| 1847 | $class->add_to_UI($depth, "\$widgets->{'$name'}->$method(_('$value')$args);"); | ||
| 1848 | # } | ||
| 1849 | } else { | ||
| 1850 | unless (defined $default and $value == $default) { | ||
| 1851 | $class->add_to_UI($depth, "\$widgets->{'$name'}->$method('$value'$args);"); | ||
| 1852 | } | ||
| 1853 | } | ||
| 1854 | } | ||
| 1855 | } | ||
| 1856 | |||
| 1857 | sub use_set_flag { | ||
| 1858 | my ($class, $name, $proto, $property, $type, $depth, $flag, $default) = @_; | ||
| 1859 | $type ||= $BOOL; | ||
| 1860 | $flag ||= $property; | ||
| 1861 | #print Dumper(\@_); | ||
| 1862 | my $value = $class->use_par($proto, $property, $type|$MAYBE); | ||
| 1863 | if (defined $value) { | ||
| 1864 | if (!(defined $default) or ($value != $default)) { | ||
| 1865 | $class->add_to_UI($depth, "${current_form}\{'$name'}->SET_FLAGS('$flag');"); | ||
| 1866 | } | ||
| 1867 | } | ||
| 1868 | } | ||
| 1869 | |||
| 1870 | sub use_par { | ||
| 1871 | my ($class, $proto, $key, $request, $default, $dont_undef) = @_; | ||
| 1872 | my $me = (ref $class || $class)."->use_par"; | ||
| 1873 | |||
| 1874 | my $type; | ||
| 1875 | my $self; | ||
| 1876 | $request ||= $MAYBE; | ||
| 1877 | if ($request&$NOT_WIDGET) { | ||
| 1878 | $self = $proto->{'property'}{$key}{'value'}; | ||
| 1879 | delete $proto->{'property'}{$key} unless $dont_undef; | ||
| 1880 | } elsif ($request&$NOT_PROPERTY) { | ||
| 1881 | $self = $proto->{$key}; | ||
| 1882 | delete $proto->{$key} unless $dont_undef; | ||
| 1883 | } else { | ||
| 1884 | if (defined $proto->{'widget'}{'property'}{$key}) { | ||
| 1885 | $self = $proto->{'widget'}{'property'}{$key}{'value'}; | ||
| 1886 | delete $proto->{'widget'}{'property'}{$key} unless $dont_undef; | ||
| 1887 | } | ||
| 1888 | } | ||
| 1889 | unless (defined $self) { | ||
| 1890 | if (defined $default) { | ||
| 1891 | $self = $default; | ||
| 1892 | |||
| 1893 | } elsif ($request & $MAYBE) { | ||
| 1894 | return undef; | ||
| 1895 | |||
| 1896 | } else { | ||
| 1897 | # We have no value and no default to use so bail out here | ||
| 1898 | $Glade_Perl->diag_print (1, "error No value in supplied ". | ||
| 1899 | "%s and NO default was supplied in ". | ||
| 1900 | "%s called from %s line %s", | ||
| 1901 | "$proto->{'widget'}{'name'}\->{'$key'}", $me, (caller)[0], (caller)[2]); | ||
| 1902 | return undef; | ||
| 1903 | } | ||
| 1904 | } | ||
| 1905 | # We must have some sort of value to use by now | ||
| 1906 | unless ($request) { | ||
| 1907 | # Nothing to do, we are already $proto->{$key} so | ||
| 1908 | # just drop through to undef the supplied prot->{$key} | ||
| 1909 | |||
| 1910 | } elsif ($request & $DEFAULT) { | ||
| 1911 | # Nothing to do, we are already $proto->{$key} (or default) so | ||
| 1912 | # just drop through to undef the supplied prot->{$key} | ||
| 1913 | |||
| 1914 | } elsif ($request & $LOOKUP) { | ||
| 1915 | return '' unless $self; | ||
| 1916 | |||
| 1917 | my $lookup; | ||
| 1918 | # make an effort to convert from Gtk to Gtk2-Perl constant/enum name | ||
| 1919 | if ($self =~ /^GNOME/) { | ||
| 1920 | $lookup = Glade::Two::Gnome->lookup($self); | ||
| 1921 | |||
| 1922 | } else { | ||
| 1923 | $lookup = Glade::Two::Gtk->lookup($self); | ||
| 1924 | } | ||
| 1925 | unless ($lookup) { | ||
| 1926 | if (defined $default) { | ||
| 1927 | $Glade_Perl->diag_print(2, | ||
| 1928 | "warn Unable to lookup '%s' using default of '%s'", | ||
| 1929 | $self, $default); | ||
| 1930 | $self = $default; | ||
| 1931 | } else { | ||
| 1932 | $Glade_Perl->diag_print(1, | ||
| 1933 | "error Unable to lookup '%s' and no default", | ||
| 1934 | $self); | ||
| 1935 | } | ||
| 1936 | } else { | ||
| 1937 | $self = $lookup; | ||
| 1938 | } | ||
| 1939 | |||
| 1940 | } elsif ($request & $BOOL) { | ||
| 1941 | # Now convert whatever we have ended up with to a BOOL | ||
| 1942 | # undef becomes 0 (== false) | ||
| 1943 | $type = $self; | ||
| 1944 | $self = ('*true*y*yes*on*1*' =~ m/\*$self\*/i) ? '1' : '0'; | ||
| 1945 | |||
| 1946 | } elsif ($request & $KEYSYM) { | ||
| 1947 | $self =~ s/GDK_//; | ||
| 1948 | |||
| 1949 | } | ||
| 1950 | |||
| 1951 | # Backslash escape any single quotes (unless they are already backslashed) | ||
| 1952 | $self =~ s/(?!\\)(.)'/$1\\'/g; | ||
| 1953 | $self =~ s/^'/\\'/g; | ||
| 1954 | return $self; | ||
| 1955 | } | ||
| 1956 | |||
| 1957 | #=============================================================================== | ||
| 1958 | #=========== Utilities to build UI ============ | ||
| 1959 | #=============================================================================== | ||
| 1960 | sub get_internal_child { | ||
| 1961 | my ($class, $parent, $name, $proto, $depth) = @_; | ||
| 1962 | my $accessor = { | ||
| 1963 | 'color_selection' => 'colorsel', | ||
| 1964 | 'font_selection' => 'fontsel', | ||
| 1965 | # All others are unchanged | ||
| 1966 | }; | ||
| 1967 | my $type = $proto->{'internal-child'}; | ||
| 1968 | return undef unless $type; | ||
| 1969 | my $refpar; | ||
| 1970 | eval "\$refpar = (ref ${current_form}\{'$parent'})||'UNDEFINED !!';"; | ||
| 1971 | $type = $accessor->{$type} || $type; | ||
| 1972 | if ($type eq 'action_area') { | ||
| 1973 | $class->add_to_UI($depth, | ||
| 1974 | "\$widgets->{'$name'} = ${current_window}->$type;"); | ||
| 1975 | return 1; | ||
| 1976 | |||
| 1977 | # Gtk|Gnome::Dialogs have widget tree that is not reflected by | ||
| 1978 | # the methods that access them. $dialog->action_area() points to | ||
| 1979 | # a child of $dialog->vbox() and not of $dialog. | ||
| 1980 | # In any case, they cannot be used/accessed until something is | ||
| 1981 | # added to them by the automagic ->new('title', 'Button_Ok',...). | ||
| 1982 | # | ||
| 1983 | # For Gnome::Dialog and derivatives we can use ->append_button() | ||
| 1984 | # (which calls gnome_dialog_init_action_area) | ||
| 1985 | unless ($class->my_gtk_perl_can_do('gnome_dialog_append_button')) { | ||
| 1986 | # Force HButtonbox to construct its widget and add it to the VBox | ||
| 1987 | # This will look wrong (above the separator) | ||
| 1988 | return undef; | ||
| 1989 | |||
| 1990 | } else { | ||
| 1991 | # Append the buttons | ||
| 1992 | my $number_of_buttons = | ||
| 1993 | $class->frig_Gnome_Dialog_buttons($parent, $proto, $depth); | ||
| 1994 | # Return the action_area now it exists | ||
| 1995 | $class->add_to_UI($depth, | ||
| 1996 | "\$widgets->{'$name'} = ${current_window}->$type;"); | ||
| 1997 | } | ||
| 1998 | } | ||
| 1999 | |||
| 2000 | #--------------------------------------- | ||
| 2001 | if ($type eq 'notebook') { | ||
| 2002 | return undef; | ||
| 2003 | |||
| 2004 | #--------------------------------------- | ||
| 2005 | } elsif (eval "${current_form}\{'$parent'}->can('$type')" || $Glade_Perl->source->quick_gen) { | ||
| 2006 | $class->add_to_UI($depth, | ||
| 2007 | "\$widgets->{'$name'} = ${current_form}\{'$parent'}->$type;" | ||
| 2008 | ); | ||
| 2009 | # , undef, undef, 'REALLY_DIE'); | ||
| 2010 | |||
| 2011 | #--------------------------------------- | ||
| 2012 | } elsif (" $Glade_Perl->{'widgets'}{'dialogs'} "=~ m/ $refpar /) { | ||
| 2013 | # We use a dialog->add_button to get a ref to our widget | ||
| 2014 | my $label = $class->use_par($proto, 'label', $DEFAULT, ''); | ||
| 2015 | $class->add_to_UI($depth, "\$widgets->{'$name'} = ". | ||
| 2016 | #FIXME Which accel key to use??? | ||
| 2017 | "${current_form}\{'$parent'}->add_button(_('$label'), 69);"); | ||
| 2018 | |||
| 2019 | #--------------------------------------- | ||
| 2020 | } else { | ||
| 2021 | $Glade_Perl->diag_print (1, "error Don't know how to get a ref to %s ". | ||
| 2022 | "(type '%s')", | ||
| 2023 | "${current_form}\{'${name}'}", "$type in a $refpar"); | ||
| 2024 | return undef; | ||
| 2025 | } | ||
| 2026 | |||
| 2027 | # $class->add_to_UI($depth, | ||
| 2028 | # "${current_form}\{'$name'} = \$widgets->{'$name'};"); | ||
| 2029 | # Delete the $widget to show that it has been packed | ||
| 2030 | # delete $widgets->{$name}; | ||
| 2031 | |||
| 2032 | # we have constructed the widget so caller doesn't need to | ||
| 2033 | return 1; | ||
| 2034 | } | ||
| 2035 | |||
| 2036 | sub string_to_arrayref { | ||
| 2037 | my ($class, $string) = @_; | ||
| 2038 | my ($work, @elements); | ||
| 2039 | foreach $work (split(/\|/, $string)) { | ||
| 2040 | $work =~ s/\s*//g; # Trim off any whitespace | ||
| 2041 | $work = Glade::Two::Gtk->lookup($work); | ||
| 2042 | push @elements, $work; | ||
| 2043 | } | ||
| 2044 | my $arrayref_string = "[]"; | ||
| 2045 | $arrayref_string = "['".join("', '", @elements)."']" if scalar @elements; | ||
| 2046 | |||
| 2047 | return $arrayref_string; | ||
| 2048 | } | ||
| 2049 | |||
| 2050 | sub internal_pack_widget { | ||
| 2051 | my ($class, $parentname, $childname, $proto, $depth) = @_; | ||
| 2052 | my $me = (ref $class || $class)."->internal_pack_widget"; | ||
| 2053 | # return if $proto->{'internal-child'}; | ||
| 2054 | my $refpar; | ||
| 2055 | # When we add/pack/append we do it to ${current_form}->{$parentname} | ||
| 2056 | # rather than $widgets->{$parentname} so that we are sure that everything | ||
| 2057 | # is packed in the right order and we can check for duplicate names | ||
| 2058 | my $refwid = (ref $widgets->{$childname}); | ||
| 2059 | my $child_type; | ||
| 2060 | my $postpone_show; | ||
| 2061 | if ($current_form && eval "exists ${current_form}\{'$childname'}") { | ||
| 2062 | die sprintf(("\nerror %s - There is already a widget called ". | ||
| 2063 | "'%s' constructed and packed - I will not overwrite it !"), | ||
| 2064 | $me, $childname); | ||
| 2065 | } | ||
| 2066 | if ($proto->{'internal-child'}) { | ||
| 2067 | if ($widgets->{$childname}) { | ||
| 2068 | # Nothing to pack just tidy up | ||
| 2069 | delete $failures->{$INTERNAL_CHILD}{$parentname}{$proto->{'internal-child'}}; | ||
| 2070 | } | ||
| 2071 | } elsif (" $Glade_Perl->{'widgets'}{'dialogs'} $Glade_Perl->{'widgets'}{'toplevel'} " =~ m/ $refwid /) { | ||
| 2072 | # We are a window so don't have a parent to pack into | ||
| 2073 | $Glade_Perl->diag_print (4, "%s- Constructing a toplevel component ". | ||
| 2074 | "(window/dialog) '%s'", $indent, $childname); | ||
| 2075 | # $child_type = $widgets->{$childname}->type; | ||
| 2076 | # if (' toplevel dialog '=~ m/ $child_type /) { | ||
| 2077 | # Add a default delete_event signal connection | ||
| 2078 | $class->load_class("Gtk2::Tooltips;"); | ||
| 2079 | $class->add_to_UI($depth, | ||
| 2080 | "${current_form}\{'tooltips'} = new Gtk2::Tooltips;"); | ||
| 2081 | $class->load_class("Gtk2::AccelGroup;"); | ||
| 2082 | $class->add_to_UI($depth, | ||
| 2083 | "${current_form}\{'accelgroup'} = new Gtk2::AccelGroup;"); | ||
| 2084 | $class->add_to_UI($depth, | ||
| 2085 | "\$widgets->{'$childname'}->add_accel_group(${current_form}\{'accelgroup'});"); | ||
| 2086 | # "${current_form}\{'accelgroup'}->attach(\$widgets->{'$childname'});"); | ||
| 2087 | # } else { | ||
| 2088 | # die "\nerror F$me $indent- This is a $child_type type Window". | ||
| 2089 | # " - what should I do?"; | ||
| 2090 | # } | ||
| 2091 | $postpone_show = 1; | ||
| 2092 | |||
| 2093 | } else { | ||
| 2094 | # We probably have a parent to pack into somehow | ||
| 2095 | eval "\$refpar = (ref ${current_form}\{'$parentname'})||'UNDEFINED !!';"; | ||
| 2096 | $Glade_Perl->diag_print(5, "Adding %s to %s", $refwid, $refpar); | ||
| 2097 | unless (eval "exists ${current_form}\{'$parentname'}") { | ||
| 2098 | if ($Glade_Perl->source->quick_gen or 'Gtk2::Menu' eq $refwid) { | ||
| 2099 | # We are a popup menu so we don't have a root window | ||
| 2100 | # $class->add_to_UI($depth, "${first_form}->popup_enable;"); | ||
| 2101 | $class->add_to_UI($depth, | ||
| 2102 | "${current_form}\{'tooltips'} = new Gtk2::Tooltips;"); | ||
| 2103 | $class->add_to_UI($depth, | ||
| 2104 | "${current_form}\{'accelgroup'} = new Gtk2::AccelGroup;"); | ||
| 2105 | $class->add_to_UI($depth, | ||
| 2106 | "${current_form}\{'accelgroup'}->attach(\$widgets->{'$childname'});"); | ||
| 2107 | $postpone_show = 1; | ||
| 2108 | } else { | ||
| 2109 | die sprintf(("\nerror %s - Unable to find a widget called '%s' - ". | ||
| 2110 | "I can not pack widget '%s' into a non-existant widget!"), | ||
| 2111 | $me, $parentname, $childname); | ||
| 2112 | } | ||
| 2113 | } | ||
| 2114 | if ($postpone_show) { | ||
| 2115 | # Do nothing | ||
| 2116 | |||
| 2117 | #--------------------------------------- | ||
| 2118 | } elsif (' Gtk2::ImageMenuItem ' =~ m/ $refpar / && | ||
| 2119 | ' Gtk2::Image ' =~ m/ $refwid / ) { | ||
| 2120 | # $class->use_par($proto->{'packing'}, 'type', $NOT_WIDGET|$MAYBE)) { | ||
| 2121 | #print "We have a $refpar to pack into\n"; | ||
| 2122 | $class->add_to_UI($depth, | ||
| 2123 | "${current_form}\{'$parentname'}->set_image(". | ||
| 2124 | "\$widgets->{'$childname'});"); | ||
| 2125 | # $class->add_to_UI($depth, | ||
| 2126 | # "\$widgets->{'$childname'} = ". | ||
| 2127 | # "${current_form}\{'$parentname'}->get_image();"); | ||
| 2128 | |||
| 2129 | #--------------------------------------- | ||
| 2130 | } elsif (" $Glade_Perl->{'widgets'}{'composite'} " =~ m/ $refpar /) { | ||
| 2131 | # We do not need to do anything for this widget | ||
| 2132 | # $class->use_par($proto->{'packing'}, 'type', $NOT_WIDGET|$MAYBE)) { | ||
| 2133 | |||
| 2134 | #--------------------------------------- | ||
| 2135 | } elsif (' Gtk2::HPaned Gtk2::VPaned ' =~ m/ $refpar /) { | ||
| 2136 | my $resize = $class->use_par($proto->{'packing'}, 'resize', $BOOL|$NOT_WIDGET, 'False'); | ||
| 2137 | my $shrink = $class->use_par($proto->{'packing'}, 'shrink', $BOOL|$NOT_WIDGET, 'True'); | ||
| 2138 | if (eval "${current_form}\{$FIRST_PANE_FULL}{'$parentname'}") { | ||
| 2139 | $class->add_to_UI($depth, | ||
| 2140 | "${current_form}\{'$parentname'}->pack2(". | ||
| 2141 | "\$widgets->{'$childname'}, $resize, $shrink);"); | ||
| 2142 | } else { | ||
| 2143 | $class->add_to_UI($depth, | ||
| 2144 | "${current_form}\{'$parentname'}->pack1(". | ||
| 2145 | "\$widgets->{'$childname'}, $resize, $shrink);"); | ||
| 2146 | # print "${current_form}\{$FIRST_PANE_FULL}{'$parentname'} = 1;\n"; | ||
| 2147 | eval "${current_form}\{$FIRST_PANE_FULL}{'$parentname'} = 1;"; | ||
| 2148 | } | ||
| 2149 | |||
| 2150 | #--------------------------------------- | ||
| 2151 | } elsif (eval "${current_form}\{'$parentname'}->can(". | ||
| 2152 | "'pack_start')") {# and !defined $proto->{'child_name'}) { | ||
| 2153 | # We have a '$refpar' widget '$parentname' that can pack_start | ||
| 2154 | my $ignore = $class->use_par($proto, 'child_name', $DEFAULT, ''); | ||
| 2155 | my $pack_type = $class->use_par($proto->{'packing'}, 'pack_type', $LOOKUP|$NOT_WIDGET, 'start'); | ||
| 2156 | my $expand = $class->use_par($proto->{'packing'}, 'expand', $BOOL|$NOT_WIDGET, 'False'); | ||
| 2157 | my $fill = $class->use_par($proto->{'packing'}, 'fill', $BOOL|$NOT_WIDGET, 'False'); | ||
| 2158 | my $padding = $class->use_par($proto->{'packing'}, 'padding', $DEFAULT|$NOT_WIDGET, 0); | ||
| 2159 | $class->add_to_UI($depth, | ||
| 2160 | "${current_form}\{'$parentname'}->pack_$pack_type(". | ||
| 2161 | "\$widgets->{'$childname'}, $expand, $fill, $padding);"); | ||
| 2162 | |||
| 2163 | #--------------------------------------- | ||
| 2164 | } elsif (eval "${current_form}\{'$parentname'}->can(". | ||
| 2165 | "'set_child_packing')") {# and !defined $proto->{'child_name'}) { | ||
| 2166 | # We have a '$refpar' widget '$parentname' that can query_child_packing | ||
| 2167 | my $ignore = $class->use_par($proto, 'child_name', $DEFAULT, ''); | ||
| 2168 | $class->add_to_UI($depth, | ||
| 2169 | "${current_form}\{'$parentname'}->add(". | ||
| 2170 | "\$widgets->{'$childname'});"); | ||
| 2171 | |||
| 2172 | #--------------------------------------- | ||
| 2173 | } elsif ((' Gtk2::Frame ' =~ m/ $refpar /) && | ||
| 2174 | $class->use_par($proto->{'packing'}, 'type', $NOT_WIDGET|$MAYBE)) { | ||
| 2175 | $class->add_to_UI($depth, | ||
| 2176 | "${current_form}\{'$parentname'}->set_label_widget(". | ||
| 2177 | "\$widgets->{'$childname'});"); | ||
| 2178 | |||
| 2179 | #--------------------------------------- | ||
| 2180 | } elsif (' Gtk2::CList ' =~ m/ $refpar /) { | ||
| 2181 | $child_type = $class->use_par($proto, 'child_name', $DEFAULT, ''); | ||
| 2182 | # We are a CList column widget (title widget) | ||
| 2183 | $class->add_to_UI($depth, | ||
| 2184 | "${current_form}\{'$parentname'}->set_column_widget(". | ||
| 2185 | ($Glade::Two::Gtk2::CList_column || '0'). | ||
| 2186 | ", \$widgets->{'$childname'});"); | ||
| 2187 | $Glade::Two::Gtk2::CList_column++; | ||
| 2188 | |||
| 2189 | #--------------------------------------- | ||
| 2190 | } elsif (' Gtk2::CTree ' =~ m/ $refpar /) { | ||
| 2191 | $child_type = $class->use_par($proto, 'child_name', $DEFAULT, ''); | ||
| 2192 | # We are a CTree column widget (title widget) | ||
| 2193 | $class->add_to_UI($depth, | ||
| 2194 | "${current_form}\{'$parentname'}->set_column_widget(". | ||
| 2195 | ($Glade::Two::Gtk::CTree_column || '0'). | ||
| 2196 | ", \$widgets->{'$childname'});"); | ||
| 2197 | $Glade::Two::Gtk::CTree_column++; | ||
| 2198 | |||
| 2199 | #--------------------------------------- | ||
| 2200 | } elsif (' Gtk2::Layout Gtk2::Fixed ' =~ m/ $refpar /) { | ||
| 2201 | # $Glade_Perl->diag_print(2, $proto); | ||
| 2202 | my $x = $class->use_par($proto->{'packing'}, 'x', $NOT_WIDGET); | ||
| 2203 | my $y = $class->use_par($proto->{'packing'}, 'y', $NOT_WIDGET); | ||
| 2204 | # my $width = $class->use_par($proto, 'width'); | ||
| 2205 | # my $height = $class->use_par($proto, 'height'); | ||
| 2206 | $class->add_to_UI($depth, | ||
| 2207 | "${current_form}\{'$parentname'}->put(". | ||
| 2208 | "\$widgets->{'$childname'}, $x, $y);"); | ||
| 2209 | |||
| 2210 | #--------------------------------------- | ||
| 2211 | } elsif (' Gtk2::MenuBar Gtk2::Menu ' =~ m/ $refpar /) { | ||
| 2212 | # We are a menuitem | ||
| 2213 | $class->add_to_UI($depth, | ||
| 2214 | "${current_form}\{'$parentname'}->append(". | ||
| 2215 | "\$widgets->{'$childname'});"); | ||
| 2216 | |||
| 2217 | #--------------------------------------- | ||
| 2218 | } elsif (' Gtk2::MenuItem Gtk2::PixmapMenuItem ' =~ m/ $refpar /) { | ||
| 2219 | # We are a menu for a meuitem | ||
| 2220 | $class->add_to_UI($depth, | ||
| 2221 | "${current_form}\{'$parentname'}->set_submenu(". | ||
| 2222 | "\$widgets->{'$childname'});"); | ||
| 2223 | $postpone_show = 1; | ||
| 2224 | |||
| 2225 | #--------------------------------------- | ||
| 2226 | } elsif (' Gtk2::OptionMenu ' =~ m/ $refpar /) { | ||
| 2227 | # We are a menu for an optionmenu | ||
| 2228 | $class->add_to_UI($depth, | ||
| 2229 | "${current_form}\{'$parentname'}->set_menu(". | ||
| 2230 | "\$widgets->{'$childname'});"); | ||
| 2231 | $postpone_show = 1; | ||
| 2232 | |||
| 2233 | #--------------------------------------- | ||
| 2234 | } elsif (' Gtk2::Notebook ' =~ m/ $refpar /) { | ||
| 2235 | #print $childname," ",Dumper($proto->{'packing'}); | ||
| 2236 | $child_type = $class->use_par($proto->{'packing'}, 'type', $MAYBE|$NOT_WIDGET); | ||
| 2237 | if ($child_type eq 'tab') { | ||
| 2238 | # We are a notebook tab widget (eg label) so we can add the | ||
| 2239 | # previous notebook page with ourself as the label | ||
| 2240 | unless ($Glade::Two::Gtk2::nb->{$parentname}{'panes'}[$Glade::Two::Gtk2::nb->{$parentname}{'tab'}]) { | ||
| 2241 | $Glade_Perl->diag_print (1, "warn There is no widget on the ". | ||
| 2242 | "notebook page linked to notebook tab '%s' - ". | ||
| 2243 | "a Placeholder label was used instead", | ||
| 2244 | $childname); | ||
| 2245 | my $message = sprintf(S_("This is a message generated by %s\n\n". | ||
| 2246 | "No widget was specified for the page linked to\n". | ||
| 2247 | "notebook tab \"%s\"\n\n". | ||
| 2248 | "You should probably use Glade to create one"), | ||
| 2249 | $PACKAGE, $childname); | ||
| 2250 | $class->add_to_UI($depth, | ||
| 2251 | "${current_form}\{'Placeholder_label'} = ". | ||
| 2252 | "new Gtk2::Label('$message');"); | ||
| 2253 | $class->add_to_UI($depth, | ||
| 2254 | "${current_form}\{'Placeholder_label'}->show;"); | ||
| 2255 | $Glade::Two::Gtk2::nb->{$parentname}{'panes'}[$Glade::Two::Gtk2::nb->{$parentname}{'tab'}] = | ||
| 2256 | 'Placeholder_label'; | ||
| 2257 | } | ||
| 2258 | $class->add_to_UI($depth, | ||
| 2259 | "${current_form}\{'$parentname'}->append_page(". | ||
| 2260 | "${current_form}\{'$Glade::Two::Gtk2::nb->{$parentname}{'panes'}[$Glade::Two::Gtk2::nb->{$parentname}{'tab'}]'}, ". | ||
| 2261 | "\$widgets->{'$childname'});"); | ||
| 2262 | $Glade::Two::Gtk2::nb->{$parentname}{'tab'}++; | ||
| 2263 | |||
| 2264 | } else { | ||
| 2265 | # We are a notebook page so just store for adding later | ||
| 2266 | # when we get the tab widget | ||
| 2267 | push @{$Glade::Two::Gtk2::nb->{$parentname}{'panes'}}, $childname; | ||
| 2268 | $Glade::Two::Gtk2::nb->{$parentname}{'pane'}++; | ||
| 2269 | # Set some tab and menu properties | ||
| 2270 | my $menu_label = $class->use_par($proto->{'packing'}, 'menu_label', | ||
| 2271 | $STRING|$NOT_WIDGET, $depth); | ||
| 2272 | $class->add_to_UI($depth, | ||
| 2273 | "${current_form}\{'$parentname'}->set_menu_label_text(". | ||
| 2274 | "\$widgets->{'$childname'}, _('$menu_label'));"); | ||
| 2275 | my $tab_pack = $class->use_par($proto->{'packing'},'tab_pack', $LOOKUP|$NOT_WIDGET, 'start'); | ||
| 2276 | my $tab_expand = $class->use_par($proto->{'packing'},'tab_expand', $BOOL|$NOT_WIDGET, 0); | ||
| 2277 | my $tab_fill = $class->use_par($proto->{'packing'},'tab_fill', $BOOL|$NOT_WIDGET, 0); | ||
| 2278 | |||
| 2279 | $class->add_to_UI($depth, | ||
| 2280 | "${current_form}\{'$parentname'}->set_tab_label_packing(". | ||
| 2281 | "\$widgets->{'$childname'}, $tab_expand, $tab_fill, '$tab_pack');"); | ||
| 2282 | #print Dumper($proto->{'packing'}); | ||
| 2283 | } | ||
| 2284 | |||
| 2285 | #--------------------------------------- | ||
| 2286 | } elsif (' Gtk2::ScrolledWindow ' =~ m/ $refpar /) { | ||
| 2287 | # if (' Gtk2::CList Gtk2::CTree Gtk2::Text Gnome::IconList Gnome::Canvas ' =~ m/ $refwid /) { | ||
| 2288 | if (' Gtk2::CList Gtk2::CTree Gtk2::Text Gtk2::TextView ' =~ m/ $refwid /) { | ||
| 2289 | # These widgets handle their own scrolling | ||
| 2290 | # so for instance Ctree/CList column labels stay fixed | ||
| 2291 | # Gtk will flag 'Gtk-WARNING **: GtkContainerClass::add not implemented for `GtkTreeView' | ||
| 2292 | # or 'Gtk-WARNING **: gtk_scrolled_window_add(): cannot add non scrollable widget use gtk_scrolled_window_add_with_viewport() instead' | ||
| 2293 | # just ignore it - CList, CTree and Text are deprecated widgets now anyway :( | ||
| 2294 | $class->add_to_UI($depth, | ||
| 2295 | "${current_form}\{'$parentname'}->add(". | ||
| 2296 | "\$widgets->{'$childname'});"); | ||
| 2297 | |||
| 2298 | } else { | ||
| 2299 | $class->add_to_UI($depth, | ||
| 2300 | "${current_form}\{'$parentname'}->add_with_viewport(". | ||
| 2301 | "\$widgets->{'$childname'});"); | ||
| 2302 | } | ||
| 2303 | |||
| 2304 | #--------------------------------------- | ||
| 2305 | } elsif (' Gtk2::Table ' =~ m/ $refpar /) { | ||
| 2306 | # We are adding to a table so do the child packing | ||
| 2307 | my $left_attach = $class->use_par($proto->{'packing'}, 'left_attach', $NOT_WIDGET ); | ||
| 2308 | my $right_attach = $class->use_par($proto->{'packing'}, 'right_attach', $NOT_WIDGET ); | ||
| 2309 | my $top_attach = $class->use_par($proto->{'packing'}, 'top_attach', $NOT_WIDGET ); | ||
| 2310 | my $bottom_attach = $class->use_par($proto->{'packing'}, 'bottom_attach', $NOT_WIDGET); | ||
| 2311 | |||
| 2312 | my $x_options = $class->use_par($proto->{'packing'}, 'x_options', $NOT_WIDGET, 'fill|expand'); | ||
| 2313 | my $y_options = $class->use_par($proto->{'packing'}, 'y_options', $NOT_WIDGET, 'fill|expand'); | ||
| 2314 | |||
| 2315 | my $xpad = $class->use_par($proto->{'packing'}, 'xpad', $NOT_WIDGET|$DEFAULT, 0); | ||
| 2316 | my $ypad = $class->use_par($proto->{'packing'}, 'ypad', $NOT_WIDGET|$DEFAULT, 0); | ||
| 2317 | |||
| 2318 | $class->add_to_UI($depth, | ||
| 2319 | "${current_form}\{'$parentname'}->attach(". | ||
| 2320 | "\$widgets->{'$childname'}, ". | ||
| 2321 | "$left_attach, $right_attach, $top_attach, $bottom_attach, ". | ||
| 2322 | $class->string_to_arrayref($x_options).", ". | ||
| 2323 | $class->string_to_arrayref($y_options).", ". | ||
| 2324 | "$xpad, $ypad);"); | ||
| 2325 | |||
| 2326 | #--------------------------------------- | ||
| 2327 | } elsif (' Gtk2::Toolbar ' =~ m/ $refpar /) { | ||
| 2328 | # FIXME - toolbar buttons with a removed label don't have a child_name | ||
| 2329 | # but can have a sub-widget. allow for this | ||
| 2330 | # test all possibilities | ||
| 2331 | # Untested possibilities | ||
| 2332 | # 4 Other type of widget | ||
| 2333 | my $tooltip = $class->use_par($proto, 'tooltip', $DEFAULT, ''); | ||
| 2334 | if (eval "$current_form\{'$parentname'}{'tooltips'}" && | ||
| 2335 | !$tooltip && | ||
| 2336 | (' Gtk2::VSeparator Gtk2::HSeparator Gtk2::Combo Gtk2::Label ' !~ / $refwid /)) { | ||
| 2337 | $Glade_Perl->diag_print (1, | ||
| 2338 | "warn Toolbar '%s' is expecting ". | ||
| 2339 | "a tooltip but you have not set one for %s '%s'", | ||
| 2340 | $parentname, $refwid, $childname); | ||
| 2341 | } | ||
| 2342 | #print Dumper($proto); | ||
| 2343 | my $new_group = $class->use_par($proto->{'packing'}, 'new_group', $BOOL|$MAYBE|$NOT_WIDGET); | ||
| 2344 | if ($new_group) { | ||
| 2345 | $class->add_to_UI($depth, | ||
| 2346 | "${current_form}\{'$parentname'}->append_space();"); | ||
| 2347 | } | ||
| 2348 | # We must have a widget already constructed | ||
| 2349 | $class->add_to_UI($depth, | ||
| 2350 | "${current_form}\{'$parentname'}->append_widget(". | ||
| 2351 | "\$widgets->{'$childname'}, _('$tooltip'), '');"); | ||
| 2352 | |||
| 2353 | #--------------------------------------- | ||
| 2354 | } elsif (" Gnome::App "=~ m/ $refpar /) { | ||
| 2355 | my $type = $class->use_par($proto, 'child_name', $DEFAULT, ''); | ||
| 2356 | if (' Gnome::AppBar ' =~ m/ $refwid /) { | ||
| 2357 | $class->add_to_UI($depth, | ||
| 2358 | "${current_form}\{'$parentname'}->set_statusbar(". | ||
| 2359 | "\$widgets->{'$childname'});"); | ||
| 2360 | |||
| 2361 | } elsif (' GnomeApp:appbar ' =~ m/ $type /) { | ||
| 2362 | $class->add_to_UI($depth, | ||
| 2363 | "${current_form}\{'$parentname'}->set_statusbar(". | ||
| 2364 | "\$widgets->{'$childname'});"); | ||
| 2365 | |||
| 2366 | } elsif (' Gnome::Dock ' =~ m/ $refwid /) { | ||
| 2367 | # FIXME why have I commented this out? Is it because Gnome::Dock should not | ||
| 2368 | # be constructed within a Gnome::App - add Gnome::DockItems by using method | ||
| 2369 | # Gnome::App::add_docked() or Gnome::App::add_dock_item() instead? | ||
| 2370 | # $class->add_to_UI($depth, | ||
| 2371 | # "${current_form}\{'$parentname'}->set_contents(". | ||
| 2372 | # "\$widgets->{'$childname'});"); | ||
| 2373 | |||
| 2374 | } elsif (' Gtk2::MenuBar ' =~ m/ $refwid /) { | ||
| 2375 | $class->add_to_UI($depth, | ||
| 2376 | "${current_form}\{'$parentname'}->set_menus(". | ||
| 2377 | "\$widgets->{'$childname'});"); | ||
| 2378 | |||
| 2379 | } else { | ||
| 2380 | $Glade_Perl->diag_print (1, | ||
| 2381 | "error Don't know how to pack %s %s (type '%s') - what should I do?", | ||
| 2382 | $refwid, "${current_form}\{'${childname}'}{'child_name'}", $type); | ||
| 2383 | } | ||
| 2384 | |||
| 2385 | #--------------------------------------- | ||
| 2386 | } elsif (" Gnome::Dock "=~ m/ $refpar /) { | ||
| 2387 | # We are a Gnome::DockItem | ||
| 2388 | my $placement= $class->use_par($proto, 'placement', $LOOKUP, 'top'); | ||
| 2389 | my $band = $class->use_par($proto, 'band', $DEFAULT, 0); | ||
| 2390 | my $position = $class->use_par($proto, 'position', $DEFAULT, 0); | ||
| 2391 | my $offset = $class->use_par($proto, 'offset', $DEFAULT, 0); | ||
| 2392 | my $in_new_band = $class->use_par($proto, 'in_new_band', $DEFAULT, 0); | ||
| 2393 | |||
| 2394 | # 'Usage: Gnome::Dock::add_item(dock, item, placement, band_num, position, offset, in_new_band) | ||
| 2395 | # Actually should be Gnome::App->add_docked() or | ||
| 2396 | # Gnome::App->add_dock_item() if this widget is in a Gnome::App | ||
| 2397 | # I quote Damon 20000301 on glade-devel list | ||
| 2398 | # I think it was OK to treat dock items as children of the dock. | ||
| 2399 | # A GnomeDock could be used in other places besides a GnomeApp (though | ||
| 2400 | # I don't think Glade supports that completely at the moment). | ||
| 2401 | # I also had to think about GnomeDockBands, but I decided to skip those | ||
| 2402 | # in the output since they are created and destroyed automatically | ||
| 2403 | # and can't be manipulated independantly. | ||
| 2404 | # | ||
| 2405 | # I think you're right in that libglade shouldn't create a GnomeDock inside | ||
| 2406 | # a GnomeApp, and should be adding the dock items via the GnomeApp's | ||
| 2407 | # GnomeDockLayout, e.g. using gnome_app_add_docked() or gnome_app_add_dock_item(). | ||
| 2408 | |||
| 2409 | if (" Gnome::DockItem " =~/ $refwid /) { | ||
| 2410 | $class->add_to_UI($depth, | ||
| 2411 | "${current_form}\{'$parentname'}->add_item(". | ||
| 2412 | "\$widgets->{'$childname'}, '$placement', $band, ". | ||
| 2413 | "$position, $offset, $in_new_band);"); | ||
| 2414 | } else { | ||
| 2415 | # We are not a dock_item - just using set_contents | ||
| 2416 | undef $proto->{'child_name'}; | ||
| 2417 | $class->add_to_UI($depth, | ||
| 2418 | "${current_window}->set_contents(". | ||
| 2419 | "\$widgets->{'$childname'});"); | ||
| 2420 | } | ||
| 2421 | |||
| 2422 | #--------------------------------------- | ||
| 2423 | } elsif (" Gnome::Druid "=~ m/ $refpar /) { | ||
| 2424 | # We are a Gnome::DruidPage of some sort | ||
| 2425 | $class->add_to_UI($depth, | ||
| 2426 | "${current_form}\{'$parentname'}->append_page(". | ||
| 2427 | "\$widgets->{'$childname'});"); | ||
| 2428 | if (' Gnome::DruidPageStart ' =~ / $refwid /) { | ||
| 2429 | $class->add_to_UI($depth, "${current_form}\{'$parentname'}->". | ||
| 2430 | "set_page(\$widgets->{'$childname'});"); | ||
| 2431 | } | ||
| 2432 | |||
| 2433 | #--------------------------------------- | ||
| 2434 | } elsif (" Gtk2::List "=~ m/ $refpar /) { | ||
| 2435 | # We are a Gnome::DruidPage of some sort | ||
| 2436 | $class->add_to_UI($depth, | ||
| 2437 | "${current_form}\{'$parentname'}->add(\$widgets->{'$childname'});"); | ||
| 2438 | # "${current_form}\{'$parentname'}->append_items([\$widgets->{'$childname'}]);"); | ||
| 2439 | |||
| 2440 | #--------------------------------------- | ||
| 2441 | } else { | ||
| 2442 | # We are not a special case | ||
| 2443 | $class->add_to_UI($depth, "${current_form}\{'$parentname'}->add(". | ||
| 2444 | "\$widgets->{'$childname'});"); | ||
| 2445 | } | ||
| 2446 | } | ||
| 2447 | unless (!$class->use_par($proto, 'visible', $BOOL, 'True') || $postpone_show) { | ||
| 2448 | $class->add_to_UI($depth, "\$widgets->{'$childname'}->show;"); | ||
| 2449 | } | ||
| 2450 | $class->add_to_UI($depth, | ||
| 2451 | "${current_form}\{'$childname'} = \$widgets->{'$childname'};"); | ||
| 2452 | $class->set_child_packing($parentname, $childname, $proto, $depth); | ||
| 2453 | # delete $widgets->{$childname}; | ||
| 2454 | return; | ||
| 2455 | } | ||
| 2456 | |||
| 2457 | sub set_child_packing { | ||
| 2458 | my ($class, $parentname, $childname, $proto, $depth) = @_; | ||
| 2459 | my $me = (ref $class || $class)."->set_child_packing"; | ||
| 2460 | return unless $proto->{'packing'} and keys %{$proto->{'packing'}{'property'}}; | ||
| 2461 | if (eval "${current_form}\{'$parentname'}->can('set_child_packing')") { | ||
| 2462 | my $refpar; | ||
| 2463 | eval "\$refpar = ref ${current_form}\{'$parentname'}"; | ||
| 2464 | my $new_group = $class->use_par($proto->{'packing'}, 'new_group', $NOT_WIDGET|$BOOL, 'False'); | ||
| 2465 | $new_group && $class->add_to_UI($depth, | ||
| 2466 | "${current_form}\{'$parentname'}->append_space();"); | ||
| 2467 | |||
| 2468 | my $expand = $class->use_par($proto->{'packing'}, 'expand', $NOT_WIDGET|$BOOL, 'False'); | ||
| 2469 | my $fill = $class->use_par($proto->{'packing'}, 'fill', $NOT_WIDGET|$BOOL, 'False' ); | ||
| 2470 | my $padding = $class->use_par($proto->{'packing'}, 'padding', $NOT_WIDGET|$DEFAULT, 0); | ||
| 2471 | my $pack_type = $class->use_par($proto->{'packing'}, 'pack_type', $NOT_WIDGET|$LOOKUP, 'start'); | ||
| 2472 | if (defined $expand or defined $fill or defined $padding or defined $pack_type) { | ||
| 2473 | $class->add_to_UI($depth, | ||
| 2474 | "${current_form}\{'$parentname'}->set_child_packing(". | ||
| 2475 | "${current_form}\{'$childname'}, ". | ||
| 2476 | ($expand||0).", ".($fill||0).", ".($padding||0)." , '". | ||
| 2477 | ($pack_type||'start')."');"); | ||
| 2478 | } | ||
| 2479 | } else { | ||
| 2480 | $Glade_Perl->diag_print(1, "error packing information found but ". | ||
| 2481 | "${current_form}\{'$parentname'} cannot set_child_packing() ". | ||
| 2482 | "what is wrong?"); | ||
| 2483 | $Glade_Perl->diag_print(1, $proto->{'packing'}, | ||
| 2484 | "Packing information found for '$childname'"); | ||
| 2485 | #print Dumper($proto); | ||
| 2486 | } | ||
| 2487 | } | ||
| 2488 | |||
| 2489 | sub set_tooltip { | ||
| 2490 | my ($class, $parentname, $proto, $depth) = @_; | ||
| 2491 | my $me = (ref $class || $class)."->set_tooltip"; | ||
| 2492 | my $tooltip = $class->use_par($proto, 'tooltip', $DEFAULT, ''); | ||
| 2493 | |||
| 2494 | # FIXME What do we do if tooltip is '' - set or not ? | ||
| 2495 | if ($tooltip ne '') { | ||
| 2496 | $class->add_to_UI($depth, "${current_form}\{'tooltips'}->set_tip(". | ||
| 2497 | "${current_form}\{'$parentname'}, _('$tooltip'));"); | ||
| 2498 | |||
| 2499 | } elsif (!defined $proto->{'widget'}{'name'}) { | ||
| 2500 | $Glade_Perl->diag_print (1, | ||
| 2501 | "error Could not set tooltip for unnamed %s", $proto->{'widget'}{'class'}); | ||
| 2502 | |||
| 2503 | } else { | ||
| 2504 | $Glade_Perl->diag_print(6, | ||
| 2505 | "warn No tooltip specified for widget '%s'", $proto->{'widget'}{'name'}); | ||
| 2506 | # $class->add_to_UI($depth, "${current_form}\{'tooltips'}->set_tip(". | ||
| 2507 | # "${current_form}\{'$parentname'}, _('$parentname'));"); | ||
| 2508 | } | ||
| 2509 | } | ||
| 2510 | |||
| 2511 | sub set_container_properties { | ||
| 2512 | my ($class, $parent, $name, $proto, $depth) = @_; | ||
| 2513 | my $me = (ref $class || $class)."->set_container_properties"; | ||
| 2514 | # $class->use_set_property($name, $proto, 'border_width', $MAYBE, $depth); | ||
| 2515 | $class->use_set_property($name, $proto, 'border_width', $MAYBE, $depth, 'set_border_width'); | ||
| 2516 | # my $border_width = $class->use_par($proto, 'border_width'); | ||
| 2517 | # if (defined $border_width && eval "$current_form\{'$name'}->can('border_width')") { | ||
| 2518 | # $class->add_to_UI($depth, "$current_form\{'$name'}->set_border_width(". | ||
| 2519 | # "$border_width);"); | ||
| 2520 | # } | ||
| 2521 | } | ||
| 2522 | |||
| 2523 | sub xset_range_properties { | ||
| 2524 | my ($class, $parent, $name, $proto, $depth) = @_; | ||
| 2525 | my $me = (ref $class || $class)."->set_range_properties"; | ||
| 2526 | # FIXME - call this from range type widgets | ||
| 2527 | # For use by HScale, VScale, HScrollbar, VScrollbar | ||
| 2528 | # my $name = $proto->{name}; | ||
| 2529 | my $value = $class->use_par($proto, 'value', $DEFAULT, 0); | ||
| 2530 | my $lower = $class->use_par($proto, 'lower', $DEFAULT, 0); | ||
| 2531 | my $upper = $class->use_par($proto, 'upper', $DEFAULT, 0); | ||
| 2532 | my $step = $class->use_par($proto, 'step', $DEFAULT, 0); | ||
| 2533 | my $page = $class->use_par($proto, 'page', $DEFAULT, 0); | ||
| 2534 | my $page_size = $class->use_par($proto, 'page_size', $DEFAULT, 0); | ||
| 2535 | my $policy = $class->use_par($proto, 'policy', $LOOKUP); | ||
| 2536 | |||
| 2537 | $class->add_to_UI($depth, "\$widgets->{'$name'}->set_update_policy(". | ||
| 2538 | "'$policy');"); | ||
| 2539 | } | ||
| 2540 | |||
| 2541 | sub set_misc_properties { | ||
| 2542 | my ($class, $parent, $name, $proto, $depth) = @_; | ||
| 2543 | my $me = (ref $class || $class)."->set_alignment"; | ||
| 2544 | # For use by Arrow, Image, Label, (TipsQuery), Pixmap | ||
| 2545 | # Cater for all the usual properties (defaults not stored in XML file) | ||
| 2546 | # return unless ($proto->{'xalign'} || $proto->{'yalign'} || $proto->{'xpad'} || $proto->{'ypad'}); | ||
| 2547 | my $xalign = $class->use_par($proto, 'xalign'); | ||
| 2548 | my $yalign = $class->use_par($proto, 'yalign'); | ||
| 2549 | my $xpad = $class->use_par($proto, 'xpad'); | ||
| 2550 | my $ypad = $class->use_par($proto, 'ypad'); | ||
| 2551 | |||
| 2552 | if (defined $xalign || defined $yalign) { | ||
| 2553 | $class->add_to_UI($depth, "\$widgets->{'$name'}->set_alignment(". | ||
| 2554 | ($xalign||'0').", ".($yalign||'0').");"); | ||
| 2555 | } | ||
| 2556 | if (defined $xpad || defined $ypad) { | ||
| 2557 | $class->add_to_UI($depth, "\$widgets->{'$name'}->set_padding(". | ||
| 2558 | ($xpad||'0').", ".($ypad||'0').");"); | ||
| 2559 | } | ||
| 2560 | # if ($class->use_par($proto, 'visible', $BOOL|$MAYBE)) { | ||
| 2561 | # $class->add_to_UI($depth, "\$widgets->{'$name'}->show;"); | ||
| 2562 | # } | ||
| 2563 | |||
| 2564 | # if (defined $xalign || defined $yalign) { | ||
| 2565 | # $class->add_to_UI($depth, "${current_form}\{'$name'}->set_alignment(". | ||
| 2566 | # ($xalign||'0').", ".($yalign||'0').");"); | ||
| 2567 | # } | ||
| 2568 | # if (defined $xpad || defined $ypad) { | ||
| 2569 | # $class->add_to_UI($depth, "${current_form}\{'$name'}->set_padding(". | ||
| 2570 | # ($xpad||'0').", ".($ypad||'0').");"); | ||
| 2571 | # } | ||
| 2572 | # FIXME - handle padding (width & height) properly | ||
| 2573 | # $class->set_widget_properties($parent, $name, $proto, $depth); | ||
| 2574 | } | ||
| 2575 | |||
| 2576 | sub set_widget_properties { | ||
| 2577 | my ($class, $parent, $name, $proto, $depth) = @_; | ||
| 2578 | my $me = (ref $class || $class)."->set_widget_properties"; | ||
| 2579 | # For use by all widgets | ||
| 2580 | |||
| 2581 | my $width_request = $class->use_par($proto,'width_request', $MAYBE); | ||
| 2582 | my $height_request = $class->use_par($proto,'height_request', $MAYBE); | ||
| 2583 | ($width_request || $height_request) && | ||
| 2584 | $class->add_to_UI($depth, "${current_form}\{'$name'}->set_size_request(". | ||
| 2585 | ($width_request || 0).", ".($height_request || 0).");"); | ||
| 2586 | |||
| 2587 | $class->use_set_property($name, $proto, 'sensitive', $BOOL, $depth); | ||
| 2588 | $class->use_set_property($name, $proto, 'extension_events', $LOOKUP, $depth); | ||
| 2589 | |||
| 2590 | $class->use_set_flag($name, $proto, 'can_default', $BOOL, $depth, 'can-default'); | ||
| 2591 | $class->use_set_flag($name, $proto, 'can_focus', $BOOL, $depth, 'can-focus'); | ||
| 2592 | $class->use_set_flag($name, $proto, 'has_default', $BOOL, $depth, 'has-default'); | ||
| 2593 | $class->use_set_flag($name, $proto, 'has_focus', $BOOL, $depth, 'has-focus'); | ||
| 2594 | |||
| 2595 | my $events = $class->use_par($proto, 'events', $MAYBE); | ||
| 2596 | |||
| 2597 | if ( $events) { | ||
| 2598 | $class->add_to_UI($depth, "${current_form}\{'$name'}->set_events(". | ||
| 2599 | $class->string_to_arrayref($events).");"); | ||
| 2600 | } | ||
| 2601 | } | ||
| 2602 | |||
| 2603 | sub set_label_properties { | ||
| 2604 | my ($class, $parent, $name, $proto, $depth) = @_; | ||
| 2605 | my $me = (ref $class || $class)."->set_label_properties"; | ||
| 2606 | $class->use_set_property($name, $proto, 'use_markup', $BOOL, $depth); | ||
| 2607 | $class->use_set_property($name, $proto, 'use_underline', $BOOL, $depth, | ||
| 2608 | 'get_child->set_use_underline'); | ||
| 2609 | $class->use_set_property($name, $proto, 'selectable', $BOOL, $depth); | ||
| 2610 | $class->use_set_property($name, $proto, 'justify', $LOOKUP, $depth); | ||
| 2611 | $class->use_set_property($name, $proto, 'wrap', $BOOL, $depth, | ||
| 2612 | 'set_line_wrap'); | ||
| 2613 | |||
| 2614 | $class->use_set_property($name, $proto, 'label', $STRING, $depth, 'set_text'); | ||
| 2615 | |||
| 2616 | $class->set_misc_properties($parent, $name, $proto, $depth); | ||
| 2617 | } | ||
| 2618 | |||
| 2619 | sub set_button_properties { | ||
| 2620 | my ($class, $parent, $name, $proto, $depth) = @_; | ||
| 2621 | my $me = (ref $class || $class)."->set_button_properties"; | ||
| 2622 | $class->use_set_property($name, $proto, 'label', $STRING, $depth); | ||
| 2623 | $class->use_set_property($name, $proto, 'relief', $LOOKUP, $depth); | ||
| 2624 | $class->use_set_property($name, $proto, 'use_stock', $BOOL, $depth); | ||
| 2625 | $class->use_set_property($name, $proto, 'use_underline', $BOOL, $depth); | ||
| 2626 | $class->add_to_UI($depth, "\$widgets->{'$name'}->set_sensitive(". | ||
| 2627 | $class->use_par($proto, 'sensitive', $BOOL, 'True').");"); | ||
| 2628 | $class->set_label_properties($parent, $name, $proto, $depth); | ||
| 2629 | } | ||
| 2630 | |||
| 2631 | sub set_window_properties { | ||
| 2632 | my ($class, $parent, $name, $proto, $depth) = @_; | ||
| 2633 | my $me = (ref $class || $class)."->set_window_properties"; | ||
| 2634 | # For use by Window, (ColorSelectionDialog, Dialog (InputDialog), FileSelection) | ||
| 2635 | # my $title = $class->use_par($proto,'title', $DEFAULT, ''); | ||
| 2636 | # my $destroy_with_parent = $class->use_par($proto,'destroy_with_parent', $BOOL|$MAYBE); | ||
| 2637 | |||
| 2638 | $class->use_set_property($name, $proto, 'window_position', $LOOKUP, $depth, 'set_position'); | ||
| 2639 | $class->use_set_property($name, $proto, 'resizable', $BOOL, $depth); | ||
| 2640 | $class->use_set_property($name, $proto, 'modal', $BOOL, $depth); | ||
| 2641 | $class->use_set_property($name, $proto, 'destroy_with_parent', $BOOL, $depth); | ||
| 2642 | |||
| 2643 | my $icon = $class->use_par($proto, 'icon', $MAYBE); | ||
| 2644 | if (defined $icon) { | ||
| 2645 | $class->load_class("Gtk2::Gdk::Pixbuf"); | ||
| 2646 | my $image_widget_name = "${current_form}\{'$name-image'}"; | ||
| 2647 | $class->add_to_UI($depth, | ||
| 2648 | "$image_widget_name = \$class->create_pixbuf(". | ||
| 2649 | "\"$icon\", [\"\$Glade::Two::Run::pixmaps_directory\"]);"); | ||
| 2650 | $class->add_to_UI($depth, "\$widgets->{'$name'}->set_icon(". | ||
| 2651 | "$image_widget_name);"); | ||
| 2652 | |||
| 2653 | } | ||
| 2654 | |||
| 2655 | my $width = $class->use_par($proto, 'width'); | ||
| 2656 | my $height = $class->use_par($proto, 'height'); | ||
| 2657 | if ( (defined $width) || (defined $height)) { | ||
| 2658 | $class->add_to_UI($depth, "\$widgets->{'$name'}->set_size_request(". | ||
| 2659 | ($width||'0').", ".($height||'0').");"); | ||
| 2660 | } | ||
| 2661 | my $default_width = $class->use_par($proto, 'default_width'); | ||
| 2662 | my $default_height = $class->use_par($proto, 'default_height'); | ||
| 2663 | if ( (defined $default_width) || (defined $default_height)) { | ||
| 2664 | $class->add_to_UI($depth, "\$widgets->{'$name'}->set_default_size(". | ||
| 2665 | ($default_width||'0').", ".($default_height||'0').");"); | ||
| 2666 | } | ||
| 2667 | my $x = $class->use_par($proto, 'x'); | ||
| 2668 | my $y = $class->use_par($proto, 'y'); | ||
| 2669 | if ( (defined $x) || (defined $y)) { | ||
| 2670 | $Glade_Perl->diag_print(1, "warn Toplevel window uposition has been set ". | ||
| 2671 | "but breaks the window manager's placement policy, and is almost ". | ||
| 2672 | "certainly a bad idea. (Havoc Pennington)"); | ||
| 2673 | $class->add_to_UI($depth, "\$widgets->{'$name'}->move(". | ||
| 2674 | ($x||'0').", ".($y||'0').");"); | ||
| 2675 | } | ||
| 2676 | |||
| 2677 | my $wmclass_name = $class->use_par($proto, 'wmclass_name', $DEFAULT, ''); | ||
| 2678 | my $wmclass_class = $class->use_par($proto, 'wmclass_class', $DEFAULT, ''); | ||
| 2679 | if ($wmclass_name || $wmclass_class) { | ||
| 2680 | $class->add_to_UI($depth, "\$widgets->{'$name'}->set_wmclass(". | ||
| 2681 | "'$wmclass_name', '$wmclass_class');"); | ||
| 2682 | } | ||
| 2683 | $class->add_to_UI($depth, "\$widgets->{'$name'}->realize();"); | ||
| 2684 | #use Data::Dumper;print Dumper($Glade_Perl->source); | ||
| 2685 | unless ($Glade_Perl->source->quick_gen) { | ||
| 2686 | $widgets->{$name}->signal_connect("destroy" => sub{Gtk2->quit}); | ||
| 2687 | $widgets->{$name}->signal_connect("delete_event" => sub{Gtk2->quit}); | ||
| 2688 | } | ||
| 2689 | # my $visible = $class->use_par($proto,'visible', $BOOL|$MAYBE); | ||
| 2690 | # $visible && $class->add_to_UI($depth, "\$widgets->{'$name'}->show;", 'TO_FILE_ONLY'); | ||
| 2691 | |||
| 2692 | $class->pack_widget($parent, $name, $proto, $depth); | ||
| 2693 | } | ||
| 2694 | |||
| 2695 | sub pack_widget { | ||
| 2696 | my ($class, $parent, $name, $proto, $depth) = @_; | ||
| 2697 | my $me = (ref $class || $class)."->pack_widget"; | ||
| 2698 | $class->internal_pack_widget($parent, $name, $proto, $depth); | ||
| 2699 | $class->set_widget_properties($parent, $name, $proto, $depth); | ||
| 2700 | $class->set_container_properties($parent, $name, $proto, $depth); | ||
| 2701 | $class->set_tooltip($name, $proto, $depth); | ||
| 2702 | # Delete the $widget to show that it has been packed | ||
| 2703 | delete $widgets->{$name}; | ||
| 2704 | } | ||
| 2705 | |||
| 2706 | sub xnew_from_child_name { | ||
| 2707 | my ($class, $parent, $name, $proto, $depth) = @_; | ||
| 2708 | |||
| 2709 | my $type = $class->use_par($proto, 'child_name'); | ||
| 2710 | return undef unless $type; | ||
| 2711 | if ($type eq 'GnomeEntry:entry') { | ||
| 2712 | $type = 'gtk_entry'; | ||
| 2713 | # $type =~ s/.*:(.*)/gtk_$1/; | ||
| 2714 | |||
| 2715 | } elsif ($type eq 'GnomePixmapEntry:file-entry') { | ||
| 2716 | $type = 'gnome_file_entry'; | ||
| 2717 | |||
| 2718 | } elsif (' Toolbar:button GnomeDock:contents GnomeDruidPageStandard:vbox Dialog:action_area Dialog:vbox ' =~ m/ $type /) { | ||
| 2719 | # Keep the full child_name for later use | ||
| 2720 | |||
| 2721 | } else { | ||
| 2722 | # Just use the bit after the colon | ||
| 2723 | $type =~ s/.*:(.*)/$1/; | ||
| 2724 | |||
| 2725 | } | ||
| 2726 | #--------------------------------------- | ||
| 2727 | if ($type eq 'action_area') { | ||
| 2728 | # Gtk|Gnome::Dialog have widget tree that is not reflected by | ||
| 2729 | # the methods that access them. $dialog->action_area() points to | ||
| 2730 | # a child of $dialog->vbox() and not of $dialog. | ||
| 2731 | # In any case, they cannot be used/accessed until something is | ||
| 2732 | # added to them by the automagic ->new('title', 'Button_Ok',...). | ||
| 2733 | # | ||
| 2734 | # For Gnome::Dialog and derivatives we can use ->append_button() | ||
| 2735 | # (which calls gnome_dialog_init_action_area) | ||
| 2736 | unless ($class->my_gtk_perl_can_do('gnome_dialog_append_button')) { | ||
| 2737 | # Force HButtonbox to construct its widget and add it to the VBox | ||
| 2738 | # This will look wrong (above the separator) | ||
| 2739 | return undef; | ||
| 2740 | |||
| 2741 | } else { | ||
| 2742 | # Append the buttons | ||
| 2743 | my $number_of_buttons = | ||
| 2744 | $class->frig_Gnome_Dialog_buttons($parent, $proto, $depth); | ||
| 2745 | # Return the action_area now it exists | ||
| 2746 | $class->add_to_UI($depth, | ||
| 2747 | "\$widgets->{'$name'} = ${current_window}->$type;"); | ||
| 2748 | } | ||
| 2749 | |||
| 2750 | #--------------------------------------- | ||
| 2751 | } elsif (' Dialog:action_area Dialog:vbox ' =~ / $type /) { | ||
| 2752 | $type =~ s/.*:(.*)/$1/; | ||
| 2753 | # Return the action_area now it exists | ||
| 2754 | $class->add_to_UI($depth, | ||
| 2755 | "\$widgets->{'$name'} = ${current_window}->$type;"); | ||
| 2756 | |||
| 2757 | #--------------------------------------- | ||
| 2758 | } elsif (' GnomeDock:contents ' =~ / $type /) { | ||
| 2759 | return undef; | ||
| 2760 | # FIXME This doesn't make sense to me, get_client_area wants a DockItem | ||
| 2761 | # $class->add_to_UI($depth, | ||
| 2762 | # "\$widgets->{'$name'} = ". | ||
| 2763 | # "${current_form}\{'$parent'}->get_client_area;"); | ||
| 2764 | # $class->add_to_UI($depth, | ||
| 2765 | # "\$widgets->{'$name'} = ". | ||
| 2766 | # "${current_form}\{'$parent'}->get_client_area;"); | ||
| 2767 | |||
| 2768 | #--------------------------------------- | ||
| 2769 | } elsif (' GnomeDruidPageStandard:vbox ' =~ / $type /) { | ||
| 2770 | $class->add_to_UI($depth, | ||
| 2771 | "\$widgets->{'$name'} = ${current_form}\{'$parent'}->vbox;"); | ||
| 2772 | |||
| 2773 | #--------------------------------------- | ||
| 2774 | } elsif ($Glade_Perl->source->quick_gen || eval "${current_form}\{'$parent'}->can('$type')") { | ||
| 2775 | my $label = $class->use_par($proto, 'label', $DEFAULT, ''); | ||
| 2776 | $class->add_to_UI($depth, | ||
| 2777 | "\$widgets->{'$name'} = ". | ||
| 2778 | "${current_form}\{'$parent'}->$type;"); | ||
| 2779 | |||
| 2780 | if ($label) { | ||
| 2781 | if ($Glade_Perl->source->quick_gen) { | ||
| 2782 | $class->add_to_UI($depth, | ||
| 2783 | "\$widgets->{'$name'}->child->set_text(_('$label'));", | ||
| 2784 | 'TO_FILE_ONLY'); | ||
| 2785 | |||
| 2786 | } elsif ($widgets->{$name}->can('child')) { | ||
| 2787 | my $childref = ref $widgets->{$name}->child; | ||
| 2788 | |||
| 2789 | if ($childref eq 'Gtk2::Label') { | ||
| 2790 | $class->add_to_UI($depth, | ||
| 2791 | "\$widgets->{'$name'}->child->set_text(_('$label'));", | ||
| 2792 | 'TO_FILE_ONLY'); | ||
| 2793 | } else { | ||
| 2794 | $Glade_Perl->diag_print (1, "error We have a label ". | ||
| 2795 | "('%s') to set but the child of %s ". | ||
| 2796 | "isn't a label (actually it's a %s)", | ||
| 2797 | $label, "${current_form}\{'$name'}", $childref); | ||
| 2798 | } | ||
| 2799 | } else { | ||
| 2800 | $Glade_Perl->diag_print (1, "error We have a label ('%s') to ". | ||
| 2801 | "set but %s doesn't have a ->child() accessor", | ||
| 2802 | $label, "${current_form}\{'${name}'}"); | ||
| 2803 | } | ||
| 2804 | } | ||
| 2805 | |||
| 2806 | #--------------------------------------- | ||
| 2807 | } elsif ($type eq 'notebook') { | ||
| 2808 | return undef; | ||
| 2809 | |||
| 2810 | #--------------------------------------- | ||
| 2811 | } else { | ||
| 2812 | $Glade_Perl->diag_print (1, "error Don't know how to get a ref to %s ". | ||
| 2813 | "(type '%s')", | ||
| 2814 | "${current_form}\{'${name}'}{'child_name'}", $type); | ||
| 2815 | return undef; | ||
| 2816 | } | ||
| 2817 | |||
| 2818 | # FINDME This is to remove | ||
| 2819 | # $class->add_to_UI($depth, | ||
| 2820 | # "${current_form}\{'$name'} = \$widgets->{'$name'};"); | ||
| 2821 | # Delete the $widget to show that it has been packed | ||
| 2822 | # delete $widgets->{$name}; | ||
| 2823 | |||
| 2824 | # Deal with all the other widget properties that might be set | ||
| 2825 | # $class->set_widget_properties($parent, $name, $proto, $depth); | ||
| 2826 | # $class->set_container_properties($parent, $name, $proto, $depth); | ||
| 2827 | # $class->set_tooltip($name, $proto, $depth); | ||
| 2828 | |||
| 2829 | # we have constructed the widget so caller doesn't need to | ||
| 2830 | return 1; | ||
| 2831 | } | ||
| 2832 | |||
| 2833 | sub new_signal { | ||
| 2834 | my ($class, $parentname, $proto, $depth) = @_; | ||
| 2835 | my $classname = ref $class || $class; | ||
| 2836 | my $me = (ref $class || $class)."->new_signal"; | ||
| 2837 | my ($call, $expr, $when, $changes); | ||
| 2838 | # $class = ref $class || $class; | ||
| 2839 | # FIXME to handle object - look at Glade generated code (signal_connect_object) | ||
| 2840 | #print Dumper($proto); | ||
| 2841 | if ($proto->{'handler'}) { | ||
| 2842 | my $signal = $class->use_par($proto, 'name', $NOT_PROPERTY); | ||
| 2843 | my $handler = $class->use_par($proto, 'handler', $NOT_PROPERTY); | ||
| 2844 | my $object = $class->use_par($proto, 'object', $NOT_PROPERTY|$DEFAULT, ''); | ||
| 2845 | my $after = $class->use_par($proto, 'after', $NOT_PROPERTY|$BOOL, 'False'); | ||
| 2846 | |||
| 2847 | # # Triple escape any double-quotes so that they get passed through | ||
| 2848 | # $changes = $data =~ s/(?!\\)(.)"/$1\\\\\\"/g; | ||
| 2849 | # $changes += $data =~ s/^"/\\\\\\"/g; | ||
| 2850 | # if ($changes) { | ||
| 2851 | # $Glade_Perl->diag_print (1, "warn signal handler data ('%s') ". | ||
| 2852 | # "contains %s double-quote(s) which has(ve) been ". | ||
| 2853 | # "escaped so that they are preserved. ", | ||
| 2854 | # $handler, $changes); | ||
| 2855 | # } | ||
| 2856 | #FIXME Maybe this is not right - use signal_connect_object instead? | ||
| 2857 | $call = 'signal_connect'; | ||
| 2858 | # if ($object) { | ||
| 2859 | # $call .= '_object'; | ||
| 2860 | # } | ||
| 2861 | if ($after) { | ||
| 2862 | $when = 'after_'; | ||
| 2863 | # $call .= '_after' | ||
| 2864 | } else { | ||
| 2865 | $when = ''; | ||
| 2866 | # $call .= 'signal_connect' | ||
| 2867 | } | ||
| 2868 | $handler = $class->fix_name($handler, 'TRANSLATE'); | ||
| 2869 | |||
| 2870 | # We can check dynamically below | ||
| 2871 | # Flag that we are done | ||
| 2872 | delete $need_handlers->{$parentname}{$signal}; | ||
| 2873 | # We must log the sub name for dynamic stub handlers | ||
| 2874 | unless ( ($Glade::Two::Source::subs =~ m/ $handler /) or | ||
| 2875 | (defined $handlers->{$handler}) or | ||
| 2876 | ($Glade_Perl->Building_UI_only)) { | ||
| 2877 | $subs .= "$handler\n$indent".(' ' x 19); | ||
| 2878 | eval "$current_form\{$HANDLERS}{'$handler'} = 'signal'"; | ||
| 2879 | } | ||
| 2880 | if ($class->can($handler) || | ||
| 2881 | eval "$current_name->can('$handler')" | ||
| 2882 | ) { | ||
| 2883 | # Handler already available - no need to generate a stub | ||
| 2884 | eval "delete $current_form\{$HANDLERS}{'$handler'}"; | ||
| 2885 | # Just connect the signal handler as best we can | ||
| 2886 | unless ($Glade_Perl->Writing_Source_only) { | ||
| 2887 | $expr = "push \@{${current_form}\{'Signal_Strings'}}, ". | ||
| 2888 | "\"\\${current_form}\{'$parentname'}->$call( ". | ||
| 2889 | "'$signal', ". | ||
| 2890 | "'$current_name\::$handler', ". | ||
| 2891 | "['$object', 'name of form instance']);\""; | ||
| 2892 | #print "$expr\n"; | ||
| 2893 | eval $expr | ||
| 2894 | } | ||
| 2895 | } else { | ||
| 2896 | # First we'll connect a default handler to hijack the signal | ||
| 2897 | # for us to use during the Build run | ||
| 2898 | $Glade_Perl->diag_print (4, "warn Missing signal handler '%s' ". | ||
| 2899 | "connected to widget '%s' needs to be written", | ||
| 2900 | $handler, $object); | ||
| 2901 | unless ($Glade_Perl->Writing_Source_only) { | ||
| 2902 | $expr = | ||
| 2903 | "${current_form}\{'$parentname'}->$call(". | ||
| 2904 | "'$signal', \\\&". | ||
| 2905 | (ref $class||$class)."::missing_handler, ". | ||
| 2906 | "['$parentname', '$signal', '$handler', '".$Glade_Perl->app->logo."']);"; | ||
| 2907 | eval $expr; | ||
| 2908 | # print "$expr - $@\n"; | ||
| 2909 | } | ||
| 2910 | } | ||
| 2911 | # Now write a signal_connect for generated code | ||
| 2912 | # All these back-slashes are really necessary as these strings | ||
| 2913 | # are passed through so many others (evals and so on) | ||
| 2914 | my $id_string = ""; | ||
| 2915 | if ($Glade_Perl->source->save_connect_id) { | ||
| 2916 | $id_string = | ||
| 2917 | "\\\\\\${current_form}\{$CONNECT_ID}{'$object'}{'$when$signal'} = "; | ||
| 2918 | } | ||
| 2919 | $expr = "push \@{${current_form}\{'Signal_Strings'}}, ". | ||
| 2920 | "\"".(ref $class||$class)."->add_to_UI(1, \\\"".$id_string. | ||
| 2921 | "\\\\\\${current_form}\{'$parentname'}->$call(". | ||
| 2922 | "'$signal', \\\\\\\"\\\\\\\$class\\\\\\\\\::$handler\\\\\\\", ". | ||
| 2923 | "['$object', \\\\\\\"$current_form_name\\\\\\\"]);\\\", 'TO_FILE_ONLY');\""; | ||
| 2924 | eval $expr | ||
| 2925 | |||
| 2926 | } else { | ||
| 2927 | # This is a signal that we will cause | ||
| 2928 | } | ||
| 2929 | } | ||
| 2930 | |||
| 2931 | sub new_accelerator { | ||
| 2932 | my ($class, $parentname, $proto, $depth, $gnome_frig) = @_; | ||
| 2933 | my $me = (ref $class || $class)."->new_accelerator"; | ||
| 2934 | #print Dumper($proto); | ||
| 2935 | my $mods = '[]'; | ||
| 2936 | # my $accel_flags = "'GTK_ACCEL_VISIBLE|GTK_ACCEL_LOCKED'"; | ||
| 2937 | my $accel_flags = "['visible', 'locked']"; | ||
| 2938 | # my $key = $class->use_par($proto, 'key', $NOT_WIDGET|$LOOKUP); | ||
| 2939 | my $key = $class->use_par($proto, 'key', $NOT_PROPERTY|$KEYSYM); | ||
| 2940 | my $modifiers = $class->use_par($proto, 'modifiers', $NOT_PROPERTY|$DEFAULT, 0); | ||
| 2941 | my $signal = $class->use_par($proto, 'signal', $NOT_PROPERTY); | ||
| 2942 | unless (defined $need_handlers->{$parentname}{$signal}) { | ||
| 2943 | $need_handlers->{$parentname}{$signal} = undef; | ||
| 2944 | } | ||
| 2945 | |||
| 2946 | # FIXME move this to use_par | ||
| 2947 | #-------------------------------------- | ||
| 2948 | # Turn GDK values into array of $LOOKUPs | ||
| 2949 | unless ($modifiers eq 0) { | ||
| 2950 | $modifiers =~ s/ *//g; | ||
| 2951 | $modifiers =~ s/GDK_//g; | ||
| 2952 | $mods = "['".lc(join ("', '", split(/\|/, $modifiers)))."']"; | ||
| 2953 | } | ||
| 2954 | #-------------------------------------- | ||
| 2955 | |||
| 2956 | if ($gnome_frig) { | ||
| 2957 | $class->add_to_UI($depth, | ||
| 2958 | "${current_window}\->set_accelerator(". | ||
| 2959 | "$gnome_frig, $key, $mods);"); | ||
| 2960 | |||
| 2961 | } elsif ($Glade_Perl->source->quick_gen) { | ||
| 2962 | # Do no checks | ||
| 2963 | |||
| 2964 | } elsif (eval "${current_form}\{'$parentname'}->can('$signal')") { | ||
| 2965 | $class->add_to_UI($depth, | ||
| 2966 | "${current_form}\{'$parentname'}->add_accelerator(". | ||
| 2967 | "'$signal', ${current_form}\{'accelgroup'}, ". | ||
| 2968 | "Gtk2::Gdk->keyval_from_name('$key') || ". # The keyval when run | ||
| 2969 | Gtk2::Gdk->keyval_from_name($key). # Our keyval now | ||
| 2970 | " , $mods, $accel_flags". | ||
| 2971 | ");"); | ||
| 2972 | |||
| 2973 | } else { | ||
| 2974 | $Glade_Perl->diag_print (1, "error Widget '%s' can't emit signal ". | ||
| 2975 | "'%s' as requested - what's wrong?", | ||
| 2976 | $parentname, $signal); | ||
| 2977 | } | ||
| 2978 | } | ||
| 2979 | |||
| 2980 | sub xnew_style { | ||
| 2981 | my ($class, $parentname, $proto, $depth) = @_; | ||
| 2982 | my $me = (ref $class || $class)."->new_style"; | ||
| 2983 | my ($state, $color, $value, $element, $lc_state); | ||
| 2984 | my ($red, $green, $blue); | ||
| 2985 | $class->add_to_UI($depth, "$current_form\{'$parentname-style'} = ". | ||
| 2986 | "new Gtk2::Style;"); | ||
| 2987 | # $class->add_to_UI($depth, "$current_form\{'$parentname-style'} = ". | ||
| 2988 | # "$current_form\{'$parentname'}->style;"); | ||
| 2989 | my $style_font = $class->use_par($proto, 'style_font', $DEFAULT, ''); | ||
| 2990 | if ($style_font) { | ||
| 2991 | $class->add_to_UI($depth, "$current_form\{'$parentname-style'}". | ||
| 2992 | "->font(Gtk2::Gdk::Font->load('$style_font'));"); | ||
| 2993 | } | ||
| 2994 | foreach $state ("NORMAL", "ACTIVE", "PRELIGHT", "SELECTED", "INSENSITIVE") { | ||
| 2995 | $lc_state = lc($state); | ||
| 2996 | foreach $color ('fg', 'bg', 'text', 'base') { | ||
| 2997 | $element = "$color-$state"; | ||
| 2998 | if ($proto->{$element}) { | ||
| 2999 | $value = $class->use_par($proto, $element, $DEFAULT, ''); | ||
| 3000 | $Glade_Perl->diag_print(6, "%s- We have a style element ". | ||
| 3001 | "'%s' which is '%s'", $indent, $element, $value); | ||
| 3002 | ($red, $green, $blue) = split(',', $value); | ||
| 3003 | # Yes I really mean multiply by 257 (0x101) | ||
| 3004 | # We scale these so that 0x00 -> 0x0000 | ||
| 3005 | # 0x0c -> 0x0c0c | ||
| 3006 | # 0xff -> 0xffff | ||
| 3007 | # This spreads the values 0x00 - 0xff throughout the possible | ||
| 3008 | # Gdk values of 0x0000 - 0xffff rather than 0x00 - 0xff00 | ||
| 3009 | $red *= 257; | ||
| 3010 | $green *= 257; | ||
| 3011 | $blue *= 257; | ||
| 3012 | $class->add_to_UI($depth, "$current_form\{'$parentname-$color-$lc_state'} ". | ||
| 3013 | "= $current_form\{'$parentname-style'}->$color('$lc_state');"); | ||
| 3014 | $class->add_to_UI($depth, "$current_form\{'$parentname-$color-$lc_state'}". | ||
| 3015 | "->red($red);"); | ||
| 3016 | $class->add_to_UI($depth, "$current_form\{'$parentname-$color-$lc_state'}". | ||
| 3017 | "->green($green);"); | ||
| 3018 | $class->add_to_UI($depth, "$current_form\{'$parentname-$color-$lc_state'}". | ||
| 3019 | "->blue($blue);"); | ||
| 3020 | $class->add_to_UI($depth, "$current_form\{'$parentname-style'}". | ||
| 3021 | "->$color('$lc_state', $current_form\{'$parentname-$color-$lc_state'});"); | ||
| 3022 | } | ||
| 3023 | } | ||
| 3024 | $element = "bg_pixmap-${state}"; | ||
| 3025 | if ($proto->{$element}) { | ||
| 3026 | $class->add_to_UI($depth, "($current_form\{'$parentname-bg_pixmap-$lc_state'}, ". | ||
| 3027 | "$current_form\{'$parentname-bg_mask-$lc_state'}) = ". | ||
| 3028 | "Gtk2::Gdk::Pixmap->create_from_xpm($current_window->get_toplevel->window, ". | ||
| 3029 | "$current_form\{'$parentname-style'}, '$proto->{$element}');"); | ||
| 3030 | $class->add_to_UI($depth, "$current_form\{'$parentname-style'}". | ||
| 3031 | "->bg_pixmap('$lc_state', $current_form\{'$parentname-bg_pixmap-$lc_state'});"); | ||
| 3032 | } | ||
| 3033 | } | ||
| 3034 | if (eval "$current_form\{'$parentname'}->can('child')") { | ||
| 3035 | $class->add_to_UI($depth, "$current_form\{'$parentname'}->child->set_style(". | ||
| 3036 | "$current_form\{'$parentname-style'});"); | ||
| 3037 | } | ||
| 3038 | $class->add_to_UI($depth, "$current_form\{'$parentname'}->set_style(". | ||
| 3039 | "$current_form\{'$parentname-style'});"); | ||
| 3040 | } | ||
| 3041 | |||
| 3042 | #=============================================================================== | ||
| 3043 | #=========== Glade-2 subs to create a new project | ||
| 3044 | #=============================================================================== | ||
| 3045 | sub create_project { | ||
| 3046 | my ($class, %params) = @_; | ||
| 3047 | my $me = (ref $class||$class)."->create_project"; | ||
| 3048 | # Make up basic Project.glade2perl proto in $Glade_Perl | ||
| 3049 | # Make up basic Project.glade proto in $Glade_Perl->glade->proto | ||
| 3050 | # Write to $Glade_Perl->glade->file | ||
| 3051 | # Now generate | ||
| 3052 | } | ||
| 3053 | |||
| 3054 | sub create_glade_file { | ||
| 3055 | my ($class) = @_; | ||
| 3056 | my $me = (ref $class||$class)."->create_glade_file"; | ||
| 3057 | return "<?xml version=\"1.0\"?> | ||
| 3058 | <GTK-Interface> | ||
| 3059 | |||
| 3060 | <project> | ||
| 3061 | <name>".$class->app->name."</name> | ||
| 3062 | <program_name>".$class->app->name."</program_name> | ||
| 3063 | <directory></directory> | ||
| 3064 | <source_directory>".$class->app->source_directory."</source_directory> | ||
| 3065 | <pixmaps_directory>pixmaps</pixmaps_directory> | ||
| 3066 | <language>Perl</language> | ||
| 3067 | <gnome_support>". | ||
| 3068 | ($class->app->allow_gnome ? 'True' : 'False'). | ||
| 3069 | "</gnome_support> | ||
| 3070 | <gettext_support>True</gettext_support> | ||
| 3071 | <output_translatable_strings>True</output_translatable_strings> | ||
| 3072 | <translatable_strings_file>Translations</translatable_strings_file> | ||
| 3073 | </project> | ||
| 3074 | |||
| 3075 | <widget> | ||
| 3076 | <class>GtkWindow</class> | ||
| 3077 | <name>".$class->test->first_form."</name> | ||
| 3078 | <title>".$class->app->description."</title> | ||
| 3079 | <type>GTK_WINDOW_TOPLEVEL</type> | ||
| 3080 | <position>GTK_WIN_POS_NONE</position> | ||
| 3081 | <modal>False</modal> | ||
| 3082 | <allow_shrink>False</allow_shrink> | ||
| 3083 | <allow_grow>True</allow_grow> | ||
| 3084 | <auto_shrink>False</auto_shrink> | ||
| 3085 | </widget> | ||
| 3086 | |||
| 3087 | </GTK-Interface> | ||
| 3088 | "; | ||
| 3089 | } | ||
| 3090 | |||
| 3091 | sub test_string { | ||
| 3092 | return | ||
| 3093 | '<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> | ||
| 3094 | <!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd"> | ||
| 3095 | |||
| 3096 | <glade-interface> | ||
| 3097 | |||
| 3098 | <widget class="GtkWindow" id="window1"> | ||
| 3099 | <property name = "visible">True</property> | ||
| 3100 | <property name="title" translatable="yes">window1</property> | ||
| 3101 | <property name="type">GTK_WINDOW_TOPLEVEL</property> | ||
| 3102 | <property name="window_position">GTK_WIN_POS_NONE</property> | ||
| 3103 | <property name="modal">False</property> | ||
| 3104 | <property name="resizable">True</property> | ||
| 3105 | <property name="destroy_with_parent">False</property> | ||
| 3106 | |||
| 3107 | <child> | ||
| 3108 | <widget class="GtkVBox" id="vbox1"> | ||
| 3109 | <property name="visible">True</property> | ||
| 3110 | <property name="homogeneous">False</property> | ||
| 3111 | <property name="spacing">0</property> | ||
| 3112 | |||
| 3113 | <child> | ||
| 3114 | <widget class="GtkProgressBar" id="progressbar1"> | ||
| 3115 | <property name="visible">True</property> | ||
| 3116 | <property name="orientation">GTK_PROGRESS_LEFT_TO_RIGHT</property> | ||
| 3117 | <property name="fraction">0.42</property> | ||
| 3118 | <property name="pulse_step">0.1</property> | ||
| 3119 | <property name="activity_mode">False</property> | ||
| 3120 | <property name="show_text">False</property> | ||
| 3121 | <property name="text_xalign">0.5</property> | ||
| 3122 | <property name="text_yalign">0.5</property> | ||
| 3123 | </widget> | ||
| 3124 | <packing> | ||
| 3125 | <property name="padding">0</property> | ||
| 3126 | <property name="expand">False</property> | ||
| 3127 | <property name="fill">False</property> | ||
| 3128 | </packing> | ||
| 3129 | </child> | ||
| 3130 | |||
| 3131 | <child> | ||
| 3132 | <widget class="GtkButton" id="button1"> | ||
| 3133 | <property name="visible">True</property> | ||
| 3134 | <property name="can_focus">True</property> | ||
| 3135 | <property name="label" translatable="yes">Click here to close this window and carry out the other tests</property> | ||
| 3136 | <property name="use_underline">True</property> | ||
| 3137 | <property name="relief">GTK_RELIEF_NORMAL</property> | ||
| 3138 | <signal name="clicked" handler="destroy_Form" last_modification_time="Fri, 24 May 2002 14:07:26 GMT"/> | ||
| 3139 | <accelerator key="Q" modifiers="GDK_CONTROL_MASK" signal="clicked"/> | ||
| 3140 | </widget> | ||
| 3141 | <packing> | ||
| 3142 | <property name="padding">0</property> | ||
| 3143 | <property name="expand">True</property> | ||
| 3144 | <property name="fill">True</property> | ||
| 3145 | </packing> | ||
| 3146 | </child> | ||
| 3147 | |||
| 3148 | <child> | ||
| 3149 | <placeholder/> | ||
| 3150 | </child> | ||
| 3151 | </widget> | ||
| 3152 | </child> | ||
| 3153 | </widget> | ||
| 3154 | |||
| 3155 | <widget class="GtkFileSelection" id="Gtk_Fileselection1"> | ||
| 3156 | <property name="border_width">10</property> | ||
| 3157 | <property name="visible">True</property> | ||
| 3158 | <property name="title" translatable="yes">Select File</property> | ||
| 3159 | <property name="type">GTK_WINDOW_TOPLEVEL</property> | ||
| 3160 | <property name="window_position">GTK_WIN_POS_NONE</property> | ||
| 3161 | <property name="modal">False</property> | ||
| 3162 | <property name="resizable">True</property> | ||
| 3163 | <property name="destroy_with_parent">False</property> | ||
| 3164 | <property name="show_fileops">True</property> | ||
| 3165 | |||
| 3166 | <child internal-child="cancel_button"> | ||
| 3167 | <widget class="GtkButton" id="button85"> | ||
| 3168 | <property name="visible">True</property> | ||
| 3169 | <property name="can_default">True</property> | ||
| 3170 | <property name="can_focus">True</property> | ||
| 3171 | <property name="relief">GTK_RELIEF_NORMAL</property> | ||
| 3172 | </widget> | ||
| 3173 | </child> | ||
| 3174 | |||
| 3175 | <child internal-child="ok_button"> | ||
| 3176 | <widget class="GtkButton" id="button86"> | ||
| 3177 | <property name="visible">True</property> | ||
| 3178 | <property name="can_default">True</property> | ||
| 3179 | <property name="can_focus">True</property> | ||
| 3180 | <property name="relief">GTK_RELIEF_NORMAL</property> | ||
| 3181 | </widget> | ||
| 3182 | </child> | ||
| 3183 | </widget> | ||
| 3184 | |||
| 3185 | </glade-interface> | ||
| 3186 | '; | ||
| 3187 | } | ||
| 3188 | |||
| 3189 | sub our_logo { | ||
| 3190 | return '/* XPM */ | ||
| 3191 | static char *Logo[] = { | ||
| 3192 | /* width height num_colors chars_per_pixel */ | ||
| 3193 | " 66 97 256 2", | ||
| 3194 | /* colors */ | ||
| 3195 | ".. c #000008", | ||
| 3196 | ".# c #008808", | ||
| 3197 | ".a c #880400", | ||
| 3198 | ".b c #004400", | ||
| 3199 | ".c c #000088", | ||
| 3200 | ".d c #808480", | ||
| 3201 | ".e c #08c010", | ||
| 3202 | ".f c #480000", | ||
| 3203 | ".g c #082090", | ||
| 3204 | ".h c #08e410", | ||
| 3205 | ".i c #886898", | ||
| 3206 | ".j c #c00410", | ||
| 3207 | ".k c #002400", | ||
| 3208 | ".l c #80cc98", | ||
| 3209 | ".m c #000048", | ||
| 3210 | ".n c #30e430", | ||
| 3211 | ".o c #0044e0", | ||
| 3212 | ".p c #0008c8", | ||
| 3213 | ".q c #c81810", | ||
| 3214 | ".r c #00f408", | ||
| 3215 | ".s c #280000", | ||
| 3216 | ".t c #e80408", | ||
| 3217 | ".u c #c0c8c8", | ||
| 3218 | ".v c #0024d8", | ||
| 3219 | ".w c #d8e0e0", | ||
| 3220 | ".x c #001400", | ||
| 3221 | ".y c #0834d8", | ||
| 3222 | ".z c #489448", | ||
| 3223 | ".A c #982018", | ||
| 3224 | ".B c #00a400", | ||
| 3225 | ".C c #38c830", | ||
| 3226 | ".D c #484440", | ||
| 3227 | ".E c #e8e8e8", | ||
| 3228 | ".F c #a00408", | ||
| 3229 | ".G c #0014d0", | ||
| 3230 | ".H c #001490", | ||
| 3231 | ".I c #784c80", | ||
| 3232 | ".J c #18f410", | ||
| 3233 | ".K c #000028", | ||
| 3234 | ".L c #0860f8", | ||
| 3235 | ".M c #20e410", | ||
| 3236 | ".N c #e01010", | ||
| 3237 | ".O c #e8f8f0", | ||
| 3238 | ".P c #a0a4a0", | ||
| 3239 | ".Q c #08d408", | ||
| 3240 | ".R c #c81010", | ||
| 3241 | ".S c #102070", | ||
| 3242 | ".T c #606460", | ||
| 3243 | ".U c #1834d8", | ||
| 3244 | ".V c #2840d0", | ||
| 3245 | ".W c #20a410", | ||
| 3246 | ".X c #2028f0", | ||
| 3247 | ".Y c #2018f0", | ||
| 3248 | ".Z c #202428", | ||
| 3249 | ".0 c #0014e8", | ||
| 3250 | ".1 c #200450", | ||
| 3251 | ".2 c #288420", | ||
| 3252 | ".3 c #001450", | ||
| 3253 | ".4 c #0008b0", | ||
| 3254 | ".5 c #100000", | ||
| 3255 | ".6 c #a81410", | ||
| 3256 | ".7 c #0824f0", | ||
| 3257 | ".8 c #402c48", | ||
| 3258 | ".9 c #0854f8", | ||
| 3259 | "#. c #00fc00", | ||
| 3260 | "## c #0834f8", | ||
| 3261 | "#a c #881410", | ||
| 3262 | "#b c #20d410", | ||
| 3263 | "#c c #006400", | ||
| 3264 | "#d c #f8fcf8", | ||
| 3265 | "#e c #009408", | ||
| 3266 | "#f c #000068", | ||
| 3267 | "#g c #f80400", | ||
| 3268 | "#h c #505450", | ||
| 3269 | "#i c #28e428", | ||
| 3270 | "#j c #c01428", | ||
| 3271 | "#k c #680000", | ||
| 3272 | "#l c #001828", | ||
| 3273 | "#m c #38d430", | ||
| 3274 | "#n c #0014b0", | ||
| 3275 | "#o c #20f028", | ||
| 3276 | "#p c #08ec28", | ||
| 3277 | "#q c #a88cb0", | ||
| 3278 | "#r c #0008e8", | ||
| 3279 | "#s c #e81c20", | ||
| 3280 | "#t c #c0a4c0", | ||
| 3281 | "#u c #f00c08", | ||
| 3282 | "#v c #20b420", | ||
| 3283 | "#w c #1848d8", | ||
| 3284 | "#x c #f0d0f0", | ||
| 3285 | "#y c #003800", | ||
| 3286 | "#z c #20d828", | ||
| 3287 | "#A c #08ec08", | ||
| 3288 | "#B c #30f820", | ||
| 3289 | "#C c #f8ecf0", | ||
| 3290 | "#D c #100028", | ||
| 3291 | "#E c #d81010", | ||
| 3292 | "#F c #a084b8", | ||
| 3293 | "#G c #101410", | ||
| 3294 | "#H c #083cf8", | ||
| 3295 | "#I c #000800", | ||
| 3296 | "#J c #0018d0", | ||
| 3297 | "#K c #c02028", | ||
| 3298 | "#L c #c8d4c8", | ||
| 3299 | "#M c #b80808", | ||
| 3300 | "#N c #082cf8", | ||
| 3301 | "#O c #50dc58", | ||
| 3302 | "#P c #900400", | ||
| 3303 | "#Q c #000c88", | ||
| 3304 | "#R c #d80808", | ||
| 3305 | "#S c #001ce8", | ||
| 3306 | "#T c #681810", | ||
| 3307 | "#U c #20c410", | ||
| 3308 | "#V c #00b800", | ||
| 3309 | "#W c #203428", | ||
| 3310 | "#X c #100ca8", | ||
| 3311 | "#Y c #10fc10", | ||
| 3312 | "#Z c #38dc38", | ||
| 3313 | "#0 c #48e440", | ||
| 3314 | "#1 c #108810", | ||
| 3315 | "#2 c #909490", | ||
| 3316 | "#3 c #281810", | ||
| 3317 | "#4 c #c8fce0", | ||
| 3318 | "#5 c #20ec28", | ||
| 3319 | "#6 c #10f410", | ||
| 3320 | "#7 c #100c08", | ||
| 3321 | "#8 c #b81418", | ||
| 3322 | "#9 c #0818b0", | ||
| 3323 | "a. c #102418", | ||
| 3324 | "a# c #40ac40", | ||
| 3325 | "aa c #b0fcd8", | ||
| 3326 | "ab c #706c88", | ||
| 3327 | "ac c #4064f8", | ||
| 3328 | "ad c #7884a0", | ||
| 3329 | "ae c #204418", | ||
| 3330 | "af c #b8c4c8", | ||
| 3331 | "ag c #382450", | ||
| 3332 | "ah c #782c30", | ||
| 3333 | "ai c #2860f8", | ||
| 3334 | "aj c #007400", | ||
| 3335 | "ak c #90a0e8", | ||
| 3336 | "al c #5884a0", | ||
| 3337 | "am c #202cc0", | ||
| 3338 | "an c #b02018", | ||
| 3339 | "ao c #481818", | ||
| 3340 | "ap c #209820", | ||
| 3341 | "aq c #607468", | ||
| 3342 | "ar c #585858", | ||
| 3343 | "as c #b8bcb8", | ||
| 3344 | "at c #205c38", | ||
| 3345 | "au c #005400", | ||
| 3346 | "av c #889cd0", | ||
| 3347 | "aw c #286c38", | ||
| 3348 | "ax c #b0b4b0", | ||
| 3349 | "ay c #2854f8", | ||
| 3350 | "az c #483c40", | ||
| 3351 | "aA c #303840", | ||
| 3352 | "aB c #48c450", | ||
| 3353 | "aC c #807878", | ||
| 3354 | "aD c #1030a0", | ||
| 3355 | "aE c #381c40", | ||
| 3356 | "aF c #603c68", | ||
| 3357 | "aG c #584c60", | ||
| 3358 | "aH c #30b440", | ||
| 3359 | "aI c #b8dcd0", | ||
| 3360 | "aJ c #706480", | ||
| 3361 | "aK c #2870f8", | ||
| 3362 | "aL c #787890", | ||
| 3363 | "aM c #c0d4f0", | ||
| 3364 | "aN c #18b428", | ||
| 3365 | "aO c #203050", | ||
| 3366 | "aP c #a8aca8", | ||
| 3367 | "aQ c #989498", | ||
| 3368 | "aR c #787878", | ||
| 3369 | "aS c #300000", | ||
| 3370 | "aT c #304838", | ||
| 3371 | "aU c #389428", | ||
| 3372 | "aV c #a0b4d0", | ||
| 3373 | "aW c #b03020", | ||
| 3374 | "aX c #a898a8", | ||
| 3375 | "aY c #583868", | ||
| 3376 | "aZ c #001070", | ||
| 3377 | "a0 c #20c828", | ||
| 3378 | "a1 c #281830", | ||
| 3379 | "a2 c #104820", | ||
| 3380 | "a3 c #103420", | ||
| 3381 | "a4 c #107408", | ||
| 3382 | "a5 c #c8bcd0", | ||
| 3383 | "a6 c #c82428", | ||
| 3384 | "a7 c #58bc58", | ||
| 3385 | "a8 c #186cf8", | ||
| 3386 | "a9 c #10c828", | ||
| 3387 | "b. c #d0c8d8", | ||
| 3388 | "b# c #18a410", | ||
| 3389 | "ba c #686868", | ||
| 3390 | "bb c #28a828", | ||
| 3391 | "bc c #109810", | ||
| 3392 | "bd c #780000", | ||
| 3393 | "be c #30b428", | ||
| 3394 | "bf c #701408", | ||
| 3395 | "bg c #401838", | ||
| 3396 | "bh c #a098b0", | ||
| 3397 | "bi c #902c28", | ||
| 3398 | "bj c #908890", | ||
| 3399 | "bk c #1008c8", | ||
| 3400 | "bl c #d81c10", | ||
| 3401 | "bm c #181820", | ||
| 3402 | "bn c #d0d4d0", | ||
| 3403 | "bo c #10b810", | ||
| 3404 | "bp c #383838", | ||
| 3405 | "bq c #d8f8e0", | ||
| 3406 | "br c #d8d4e0", | ||
| 3407 | "bs c #38e440", | ||
| 3408 | "bt c #1834f8", | ||
| 3409 | "bu c #605870", | ||
| 3410 | "bv c #981408", | ||
| 3411 | "bw c #082030", | ||
| 3412 | "bx c #200428", | ||
| 3413 | "by c #30f838", | ||
| 3414 | "bz c #500000", | ||
| 3415 | "bA c #1854f8", | ||
| 3416 | "bB c #d81020", | ||
| 3417 | "bC c #c090c0", | ||
| 3418 | "bD c #f81c18", | ||
| 3419 | "bE c #484848", | ||
| 3420 | "bF c #08dc10", | ||
| 3421 | "bG c #282c28", | ||
| 3422 | "bH c #405c48", | ||
| 3423 | "bI c #2838a0", | ||
| 3424 | "bJ c #887890", | ||
| 3425 | "bK c #6878b0", | ||
| 3426 | "bL c #0044f8", | ||
| 3427 | "bM c #1044f8", | ||
| 3428 | "bN c #187828", | ||
| 3429 | "bO c #0824b8", | ||
| 3430 | "bP c #1060f8", | ||
| 3431 | "bQ c #2044f8", | ||
| 3432 | "bR c #d01c28", | ||
| 3433 | "bS c #102428", | ||
| 3434 | "bT c #385848", | ||
| 3435 | "bU c #300830", | ||
| 3436 | "bV c #08c808", | ||
| 3437 | "bW c #000c48", | ||
| 3438 | "bX c #002cd8", | ||
| 3439 | "bY c #d0e8d8", | ||
| 3440 | "bZ c #083cd8", | ||
| 3441 | "b0 c #001890", | ||
| 3442 | "b1 c #18fc10", | ||
| 3443 | "b2 c #18ec10", | ||
| 3444 | "b3 c #a0a8a0", | ||
| 3445 | "b4 c #081c48", | ||
| 3446 | "b5 c #18dc10", | ||
| 3447 | "b6 c #006c00", | ||
| 3448 | "b7 c #000c70", | ||
| 3449 | "b8 c #20fc28", | ||
| 3450 | "b9 c #f0dcf0", | ||
| 3451 | /* pixels */ | ||
| 3452 | "#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#C#d#C#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d", | ||
| 3453 | "#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#C#C#d#C#d#d#d#d#d#d#C#d#d#d#C#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d", | ||
| 3454 | "#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#C#d...P#d#d.ObWbW#l#I#I#d.O#d#d#d#d#C#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d", | ||
| 3455 | "#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#dbE..#7bhadaOb4.K#I#I..aL.O#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d", | ||
| 3456 | "#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#dbq#d.w.d..#I.......K...K.c.c#f.K...5aGax#C#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d", | ||
| 3457 | "#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d.O#d.w#I..........#I.K.Kb7.p#r.4.m....#D.5bj#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d", | ||
| 3458 | "#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d.P...............K.K#f.G#r#r.7ac.7.G#f.K.K..bE#d#C#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d", | ||
| 3459 | "#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d.O.O.O#G....a........K.m#f#J.pbtay.v#N#N.p.c#f.K.K...d#d#C#d#d#d.E#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d", | ||
| 3460 | "#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d.O#LbG..........#I.K.m.4.p#SbM#H#####H.vbL.G##.y#f#f.K..#I.d#C#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d", | ||
| 3461 | "#d#d#d#d#d#d#d#d#d#d#d#d#d.E#d.E.O...x#I..#7...3#f.c.p#S#r#r#r.0.p.p.G#N#Na8.p#H#r.v#n.m.K.....K#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d", | ||
| 3462 | "#d#d#d#d#d#d#d#d#d#d#d#d#d.O.O#2..#I.........K.m#X.4.X.X#r#r.G.4.4#f.4.4bt.Uai#r#Nbt#J#Q.m.K....aza5#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d", | ||
| 3463 | "#d#d#d#d#d#d#d#C#d#d#dbq#d.u...5.......K.m.c#X.c.m.m#f#f.m.K.K.........K.K.K#f.4.vbZ###S#r.4.m.K....#I#C#d#d#d#d#d#d#d#d#d#d#d#d#d#d", | ||
| 3464 | "#d#d#d#d#d#d#d#d#d.O#d#d#2bp..........#f.c.p.c.m.....K.K.....................K.m.3#Q.4.7.X.X#f.m......aR#C#d#C#d.O#C#d#d#d#d#d#d#d#d", | ||
| 3465 | "#d#d#d#d#d#d#d#d.O#db3.5......#I.m#f.4.p.p.c.K...............K.m.m...............K.K.K#Q#N####.G.c#f.K....bua5#C#d#d#d#d#d#d#d#d#d#d", | ||
| 3466 | "#d#d#d#d#d#d#d#d.O#L#I....#I...m#Q.G#S.p.4.m.............K.m#Q#Qb7.K.K.K..............#f.7#####r#S.4#f.K.K#D..#d#d#C#d.O#d#d#d#d#d#d", | ||
| 3467 | "#d#d#d#d#d#d#daq.......K.maZ.H#n.Xbt.Y#f.m...........m#f.p#r#r##.y#J.0.p#QbW...5.......K.H#n##a8.7##.G.4#f......#C#d#d.O#d#d#d#d#d#d", | ||
| 3468 | "#d#d#d#d.O#d#L.........m.4.4#nbZbt#r.G.K#I.......K#f.4.4###N#HbAbL##bQ#H.vb7.K...5.....K.m#9#H##bL#H#N###J.mbW...Tbj#C#d#d#d#d#d#d#d", | ||
| 3469 | "#C#d#d#daPaq...K.K.K.m.p#S#N#N##bt#f.m.........K.4#r.7##bL.9.LbLbL#HbL#HbM.p.4#f.K......#f#9.0bL.9###H#9ai.G.pb7......aC#C#C#d#d#d#d", | ||
| 3470 | "#d.E#daP.....K#f#f#Q.G#N#HbL#N#H#N#f.m.........m#r.7#H.9.9.9#HbL#H#r.7#Sai#SbX#n#f#I#I...m#9.o.9bL.9.LbL.9bA#H.0#f.m#l..aL#d#d#d#d#d", | ||
| 3471 | "#dbm#daP.....3#Q#Q.G#N#N#HbL#NbL.y#f.K.........m#S.7bL.9.obL#N#H#N.p.0.0.7aiay.p.4.K...K.cbObLbZbZ.9#H.9bLbLbL###J.4.K.K.K.P#C#d#d#d", | ||
| 3472 | "#d.......5.5.m.V.v#H##bL#H#N###H#w.m.K.......K.m#J#N#HbLbL##bt#r.c.m.m#Q.4acbM#r#r.p.p.G#r#N##bLbX.9.0bLbL.v#H#H.7.0.4bI.K..aG#d#C#d", | ||
| 3473 | ".O#I.s.5.saS..#f#nbt#H##bL#HbL.L.9#n#f.K.......m#S#N#HbL#H#H#N.p.m...K.K.c#J#S#H##.0ai.y###HbP###HbL#H#HbL.o.9aK.G.4b7b0.K..ba#d#d#d", | ||
| 3474 | "#d......bda6bz.K#f.c#9#N#H#HbLbL#H#S.4.K.......K#S.7#H.9.9#N#N#f.K.........m.c.v#N#SbL#H.ybLa8.7bL##bLbLbLbP.9#H#X.m#I#y#y..#h#d#d#d", | ||
| 3475 | "#C#I#I#Ibd.R#P.5.K#f#f.v###H.o#H###N.G.m.K.....K.p.0#N.9bL.9.0#f.K...........m#Q.p#N##bL.L.o#HbLbA#HbLbL##bL.vbZ.m.K#yaBa7..ar#d#C#d", | ||
| 3476 | "#d.x..#I.a#E.t.Fbz.....m.vbt#HbM#HbL#H.4.m.......m#f#w#JbAbL.G.p.m...........K.m#f#rbM#HbLbLbL#HbLbL#N.UbQ.c#f#laub#b8b2.b#I.T#d#d#d", | ||
| 3477 | "bq#l.....a#R#g#R.FaS...K#Q#n#r.0##bL##.4#Q.........Kb0#nai#H.7#r.4.K...........m.c#r.X.ybP##.9.7#N#H.G#n#Q.m.K#cby#6.r#6.k..#h#d#d.O", | ||
| 3478 | ".O.x.....a.t#g.t.N#M.a.5...Kb7.4.7#NbA#N#N#f.......K.K.K#f.p.p.7bk.m.....K.....c.p###N#HbL#H.0#N.4#9#f.K#I#yb6#A#.#.#.#p.k..ar#d#d#d", | ||
| 3479 | "#d.x....#P.t#g.t.t#g.t.a.5.....Kb7#N#S#H#H.4bW#I...........K.K.m.K..........b7#J#N#H#HbL#Nbt#n.c.K..#Iau.Bb1.r#.#6#.#.#p.k..bu#d#d#d", | ||
| 3480 | ".O.x....#P.t#g#g.t#g#g#RaS.......K#X.p#H#H#J.K.K..#I.............K.....K.K.m#n#N#H##bLbX.v.U#f.K#I.x.x#U#6#.#..r#6#Y#.#A.k..bJ#C#d#d", | ||
| 3481 | ".O.k.....a#R#g#g#g#g#g#u#8.a.s.5.....m#9#n.y.G.G#Q.m.....K.......K...Kb7.p.0#N.y.ybO#w#Q.K.K.x.xb6#m.J#.#.#..r#..r#.#..M.xaE#x#d#d#d", | ||
| 3482 | "bq.k....#P.t#g#g#g#g#g.t.N.jaS.5.5...K#f.c#N##.X.p.c#f#f#f.K.....K.m#Q#9.0#S.7.0.4.g#Q.m..#I#y#c#V.J#.#..r#.#..r#.#.#.#p.xaY#C#C#d#d", | ||
| 3483 | ".O.k#I..#P#R#g#u#g#g#g#g#g#g#jbd.saoaS.5...m.X.X#H##bA#H#rbk.c.c.4bXbL#H#N#S.4bW.K.K..#Iau.#.Mb2#Y#.#..r#.#.#.#..r#.#.#A.x.i#C#C#d#d", | ||
| 3484 | ".Oa3#I#I.a.t#g#u#g#g#g#u#g#g#R#j.fahbz.s.s.K#9.0#H#HbLbL.0#r.Y.p.G##bLbL.v.p.m........#y#5#Y#.#.#.#.#.#Y#.#.#..r#Y#.#.#o..#C#C#d#C#d", | ||
| 3485 | "bqa3....bd.N#g#g#g#g#g.t#g#g#g#gblbz#ka6#8aS.K.m#n.v#N#NbL#H#H#HbMbL.0.4#f.m#D..#I#ybc#i#6.r#.#.#6#.#.#A#Y.n#c#6#A.rb5#c..ab#C#C#d#d", | ||
| 3486 | "bqa...#Ibd.t#g#u#g#g#R.R#g#g#g#g.N#P#P#M#j.aaS...m.c#JbA#H#H##.7b0#Q#Q.c.K.KbW#I#y#U#5.Jb2b1.r#..r.r#.#5aNb6#y.h.r#.#b#y.Kb.#d#d#d#d", | ||
| 3487 | ".ObS#I#I.a.t#g#g#g.jbd.s#k.6#u#g#g#g.t.a#P.NbB.j.f.5.m.H#J#N.7.p#Q.K.K#D....#y.Bby#..r#..r#..r#.#.b8.B.k.x.x#y.J#.#.bo#y..#C#d#d#d#d", | ||
| 3488 | "#dbS#I..#P.t.t#g#g.6.f...5.5#kbdbl.t.t#E.Fbz.R.N#E#P.5.K#f.4#9aD.K.5....#c.Bb8.r#.#.#.#.#.#.#.#.#A#Z.x..#I.b#Z#.#.#.bc.x.5#d#d#d#d#d", | ||
| 3489 | "#d.x....#P.t#g#g.tbvaS.......5.sbvbB.t.t#E#kbd#8.N.jbz.s.K#faZal#l..#I.k.e#o.r#.#.#.#.#.#.#.#.#.#5au..#I#Iau#i#.#.#.bc.x.5#d#d#d#d#d", | ||
| 3490 | ".O......#P.t#g#g.tbz.5...........5.f.a.t#g.NaSaS#P#R.N.6.5#D...k.x#ca9#o#6#..J.nbF#6#.#..r#.#.b8au.x.K...x#5#.#.#.#..#.x..#d#d#d#d#d", | ||
| 3491 | "#d.......a.N#g#g#gaS.5...........s.5aS#M.t#u.abzbzbd#R.Nbf...xb#.B#5#6.r#6#5#e.2au.h#.#.#.#..hbs.k#I....aub1.r#.#.#.aj.x..#C#C#d#d#d", | ||
| 3492 | "#d.......a.N#g#g#g.s............#I...5.5.fbda6.qaS.s#k#8#8.5.x#U.J#.#.#.#Ub6.x.x.b.r#.#.#..r#1.k....#I#c.B#..r#Y.r#Y#y...K#C#C#d#d#d", | ||
| 3493 | "#d.......a.N#g#g#g#k.5.5.........x........aS.F.6#T.saS.abl...x#0.h#.#.#6.W.k#I.x.W#..r#..r#6.x.......x#zb8#.#..r#6b2.x...1#C#C#d#d#d", | ||
| 3494 | ".O.x.5..bd#j#g#g#g.t.t#EaS.5.................5.5bdanbd#P#8.....b#5#.#..J#y#I#I.xa4#A#.#.#i.b....#I#I.k.r#Y#.#.#.#Abe#I..bC#d#d#d#d#d", | ||
| 3495 | "#d.......abB#g#g#g#g#g#sbd.f.5..................bd.R.j#R.R.5#I.k.Q#.#.#6.x.x...xaubo.Q#A.W.x....#I.x#e#.#6#.#.#.#A.W#I..#x#d#d#d#d#d", | ||
| 3496 | "#d.......fbd.t#g#g#g#g#g.N#j.s.5...5........#I#I#k.R.t#g#8.5..#yaj.r#.b2.x#I...xae.x.##m#I.....K.x.##Y#..r#.#.#.#A.W#I#I#d#d#d#d#d#d", | ||
| 3497 | "bq#I.5...s.f#g#u#g#g#g#g.t#j.s........#I....#I..#k#R#g#gan..#I.x#e.r.rb2.x#I..#IbT#I.x#y#I.......##5#.#..r#.#.#..h.#.x..#d#d#d#d#d#d", | ||
| 3498 | "bY...5.5#T.a#g#g#g#g#g#g#u#j.5..............#I..bd#E#g#gan.5#I.x.##A#..J.x.....xbT.x#I.x#I.....xbs.h#..r#.#.#.#.#oap#I#I#C#d#d#d#d#d", | ||
| 3499 | "bq#I.....F#R#g#g#g#g#g#g.N#8.5........aSaS.s....#k#K.t#ubvaS.5.x#m#Y#.#6.x#I#I.xae......#I#I.xau#.#.#.#.#.#.#.#..naj#I..#d#d#d#d#d#d", | ||
| 3500 | "#4.k....#P#R#g#g#g#g#g#g#R.6.5.5......bd.a.a.s..aSbd#R#g#a.5...xbo#Y#.#6.x#I#I#Ia...........#ybs#.#.#.#.#.#.#.#.#Z.b#I..#d#d#d#d#d#d", | ||
| 3501 | "aaat.5.s#kbd#g#g#g#g#g#g.t.6.5.....5.s.R#u.N#M.F.F#M#g#gbf.....x#c#6#.#Y.x..#I.....5........#yaHby#..r#.#.#.#..Jaj.x....#d#d#d#d#d#d", | ||
| 3502 | "aaa2.5.s#kbd#g#g#g#g#g#g#R.6.5.....5.s#R#g#g#g.t.t.t#g#gbf....#Iau#p#.#A.x.......5.......5...k#y#z#p#A#.#.#.#.b2.b.x...K#d#d#d#d#d#d", | ||
| 3503 | "bq#y..#I#P#R#u.t#g#g#g#g#Rbv..#I....aS.t#g#g#g#g.t#g#g#g#a.5...xau#o#.b2#I...K......#I.........x.k.k#m.r.r#.#.b2.k#I#D#D#d#d#d#d#d#d", | ||
| 3504 | ".Oa3#I.x#M.t#g#g.t#g#g#g.j#a.........f.t#g#g#g#g#g#g#g#g.a.5...k#e#.#..J.x........#I...5....#I#I.x.x.b#o.h#.#.#Y#y#I.Kbx#d#d#d#d#d#d", | ||
| 3505 | "#4.k...5bB#g#g#g.t#g#g#g#R#a.......5#k#u#g#g#g#g#g#g#u#g.a.....b#i.r#.#A#I.......x#y.b#1.x.x#I......#I.bb6a9.h.h.k...5#q#d#d#d#d#d#d", | ||
| 3506 | "bq.x.5...j#g#g#g#g#g#g#g.t.F.......sbd#u#g#g#g#g#g#g#g#g.a.5#Iaj#z#.#..r.x.....x.b#5#o#Y#V#e.x......#I..#7.k.##m.k.x#G.E#C#d#d#d#d#d", | ||
| 3507 | "bY#I....#M#u#g#g#g#g#g#g.t#8.5.....s.a.t#g#g#g#g#g#g#g#g.a..#Ibb#o.r#.#A.x#I...xbb#..r#.#A#5#y.x..#I#I.5...k#y.n.k.xbS#d#d#d#d#d#d#d", | ||
| 3508 | "bq.k..#Ibdbl.t#g#g#g#u.t#u#8.5.....sbd.t#g#g#g#g#g#g#g#g.a..#I#ObF#.#.#A.x.....k#m#.#.#.#.#.#p#5b6.k.....x#V.J.M.x.x.D.O#G#C#d#d#d#d", | ||
| 3509 | "#4aw...x#kbl.t#g#g#g.t.t.t.F.5.....5.a.N#g#g#g#g#g#g.t#g.a.5#Ia0#o#.#.#6.x#I...b#z#.#.#.#.#.#..r#z.#.x.x.kb1.r.h.x#I..bT..#d.O#d#C#d", | ||
| 3510 | "#4.l.x.5#P.j#g#g#g#g#g#g.N#M.5.....5bd.t#g#g#g#g#g#g#g#g.a.5#I#ib2#.#..M#I..#I#y#z#Y.r#Y#.#.#.#.#.b8.e.B#6#.#..M.x...x..aQ#d#d#d#d#d", | ||
| 3511 | "#4bq#G..#k#K#g#g#g#g#g#g#u.j.s.....5bd#g#g#g#g#g#g#g#g#g.a..#I#Zb2#.#A.n.x#I...b#Z.r#Y#6#.#.#.#.#..r#Y.r#.#.#.#Z.x#I.x..#d#d#C#d#C#d", | ||
| 3512 | "#d.E#7...saS.F#R#g#g.t#g#g.N.6#k.f.sbd.t#g#g#g#g#g#g#g#g.a..#I.n.M#.b8be.......ba0#.#.#6#.#.#.#.#.#.#.#.#.#A#o.k......#I.K#C#d#d#d#d", | ||
| 3513 | "#C#da5aO....bz.F#R#g#g#g#g#g#E#MbdaSbd.t#g#g#g#g#g#g#g#gbd.5#Ibs.M#.b2aj....#Iaua9#.#.#..r#.#.#.#..r#Y#..r#iap#I..#7.x..#F#d#d#d#d#d", | ||
| 3514 | "#d#C.Obq.....5aSaS.6#j#g#g#g#g#g.N.R#R#g#g#g#g#g#g#g#g#g#T.5#I#m#A#..h#y....#I#c#i#.#.#.#.#.#.#.#.#.#..nbc.k.x......aR.u#C#d#d#d#d#d", | ||
| 3515 | "#d#d#d.Oadba.....5.s#k.N#g#g.t.t#g.t.t#g#g#g#g#g#g#g#g#g.f.5..#Zb2#.b5bc#I..#y#A#.#.#.#.#.#.#.#..h.r#v.k.x.x#I..aL.w#d#d#d#d#d#d#d#d", | ||
| 3516 | "#C#d.O.O#d#C.Z#I...5aS.j.t.t#g.t#g#g#g#g#g#g#g#g#g#g#g#gaS..#I#Z#p#.#ZaB.k.kbc#Y#.#.#.#.#.#.#.#..hbs#y.k.x.......E#d.O#d#d#d#d#d#d#d", | ||
| 3517 | "#d#C#d#d#d.O#da..x.....s#8bB.t#g#g#g#g#g#g#g#g#g#g#g.t.N.s..#I#i#p.r.##y#z#o#..r#.#.#.#.#.#.b2.n#1.k.x.....8#C#C#d#d#d#d#d#d#d#d#d#d", | ||
| 3518 | "#d#d.O#d#d#d.O.OaI#I#I.5bz.F#g#g#g#g#g#g#g#g#g#g#g#g.t#R.5...x#5#A#.bFbV#Y#.#.#.#.#.#.#.#6#A.B#c.x#I....#D#x#C#C#dbq#d#d#d#d#d#d#d#d", | ||
| 3519 | "#d#d#d#d#d#d#d#d.Obqbq......#kbR#g#g#g#g#g#g.t#g#g#g.t#8.5...x#zb8#.#.#.#.#..r#.#.#.#..J#map.x.x....azb.#C#d#d#d#d.O#d#d#d#d#d#d#d#d", | ||
| 3520 | "#d#d#d#d#d#d#d#d#d.ObqaR..#IaS.f.N#g#g#g#g#g#g#g#g#g.t.6.5..#I#z#A#.#.#.#.#.#.#.#.#..r#z#1.x#I#I#I..b9#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d", | ||
| 3521 | ".O#d#d#d#d#d#d#d#d#d#d#CaT...k#IaSbB.t#g#g#g#g#g#g#g#Ebv.5..#I#z#o.r.r.r#.#.#.#..r.M#v.x.x......#C#C#d#d#d#d.O.O#d#d#d#d#d#d#d#d#d#d", | ||
| 3522 | "#d#d#d#d#d#d#d#d#d#d#d#d.wbE..#I..#k#M#g#g#g#g#g#g#g.t.A.5..#I#z#o.r#.#.#.#.#6#.#Yb6#y.x.....P#L#d#d#C#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d", | ||
| 3523 | "#d#d#d#d#d.O#d#d#d#d.O#d#d#dbhbw...5.f#M.t#g#g#g#g#g.t.A.5..#I#5.r#..r#..r.r#B#c#y...x..araQ#d#d#d#d.O#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d", | ||
| 3524 | "#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d.d...5.5.f.N#g#g#g#g#R.6.5#I.x#Y#.#.#..r#6.e.k#I.......w#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d", | ||
| 3525 | "#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d..#I...5#K#u#g#g#g#R.F.5.x.b.r.r#.#.#6a0b6.x..#G.ZbE#d#C#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d", | ||
| 3526 | "#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#C#d#d.....sa6.jbD#RbB.a#I.xb6#.#..M#v.b.x.x..aG#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d", | ||
| 3527 | "#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#C.E.T.5.fbv#M#s#j.a...x.##.#Y#Z.k#I....bU.E#C.O#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d", | ||
| 3528 | "#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#db9..#7.s.fbd.f...xaU#1au.k#I...i#t#d#d#C#C.O#d#C#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d", | ||
| 3529 | "#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#dbG...5.5aS.s...xa2.x.x#I....#C#C#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d", | ||
| 3530 | "#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d.O.w.x..........#Iag#D.Ka5#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d", | ||
| 3531 | "#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d.ObG...x....#Ibw.K#DaG#C#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d", | ||
| 3532 | "#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d.O#d#C#C......#lbwabas#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d", | ||
| 3533 | "#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d.O#d#C#CbqaT....b.#d#C#d#C#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d", | ||
| 3534 | "#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d.O#db9#C#dbqbY..aG#d#C#C#C#d.O#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d", | ||
| 3535 | "#C#d.O#d#C#d#d#d#d#d#C#d#d#d#C#d#d#d#d#d#d#d#C#d#d#d#d#d#C#d#d#d#d#d#d#d#d#d#d#d#d#d#d#C#d#d#d#d#C#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d", | ||
| 3536 | "#d.O#d#d#d#d#d#d.E#d#d#d.P#C#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#C.O#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#dbj.u#d", | ||
| 3537 | "#d#d#d#daA.d......#d#dbm..aC#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d.u#G........#I#h#d#d#d#d#d#d#d#d#d#d#d#d#h....#2#d", | ||
| 3538 | "#d#d.u#G#d#C#dba#d#d#Cba#IaR#d.O#d#d#d#d#d#d#C#L#C#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#daR.T#G.ZaR......as.O#d#d#d#d#d#d#d#d#d#d.Eas..aR#d", | ||
| 3539 | "#d#d#IaR#d#d#d#d#d#d#daR..aC#d#d#d#d#d#d#d.u...D#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d..ba#d#d.Z#IaR#d#d#d#d#d#d#d#d#d#d#d#d#d#Iba#d", | ||
| 3540 | "#C#L...d#d#d#d#d#d#d#d.d..aR#d#d#C.d.u.O#dbp....#h.d#d#d#d#d#d#d.d.u#d#d#d#d#C#d#d#d#d..aC#d#daR..as#d#d#d.das#d#d#d#d#d.d#d#d..aR#d", | ||
| 3541 | "#d.d..aR#d#d#dbm....#daC...d#d#daR.....u#d#d#d#dbG#I..#I#C.O.DaRaA#7.E#d#d#d#d#d#d#d#d..aR#d.D#W#d#d#dbpaR..#I.u..#I#h....#d#d...D#d", | ||
| 3542 | "#d#2....#d#d#d#d.D..as.d..aR#d#d#dar..#I.u#d.D..#d#d....aC#I..#das.O#d#d....#I#7ax#d#d..aR#d#d#d#d#d..#d#dbG#d#d.d..aq#d#d#C#d....#d", | ||
| 3543 | "#dax....#d#d#d#CaR#I#daR..aR#d.wbE........#d..#I#d#dba#I#d..#7as.u#d#d#d......aR#d#d#d...d#d#d#C#d#C..#das#d#d#d.d...d.E#d#d#d..#I#d", | ||
| 3544 | "#d#d..#I...D#d#dbp#d#daR...d#2..#d#C#d....#d....#d#dbG#h#C....#h#d#d#d#d.E#d#d#d#d#d#d...d#d#d#d#C#d#I..az#d#d#d.d...d#d#d#C#d.x..#d", | ||
| 3545 | "#d#d.P#7#I...DbEba#d#daR..aR.......daRbp..aR.....D.daz#d#daR......#7#d#d#d#d#d#d#d#d#d...P#d#C#d#d#d.d..#I..#3#daC..ba#d#d#d#C....#d", | ||
| 3546 | "#d#d#d#das.Tax#d#C#d#das#d#C.O.u.d#C#d.Ebn.O#CaxaC.E#d.O#d#d.O.Taq.O#d#d#d#d#d#d#d#d#d#C#d#d#d#d#d#d#dasba#d#d#d#C#C.E#d#d#d#d#C#d#d", | ||
| 3547 | "#d#d#d#d#d#d#d#d#d.O#d#d#d#d#d#C#C#d#d#d#C#d#d.O#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d.O#d#d#d#d#d#d#C#d.E#d#d#d#d#d#d#d#d#d#d#d#d", | ||
| 3548 | "#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#C#d#d#d#d#d.E#d#d#d.O#d#d#d#d#d#d#d#d#d#d#d.O#d#d#d#d#d#d#d#d#d.E#d#C#d#d#d#d#d#C#d.E#d" | ||
| 3549 | '} | ||
| 3550 | |||
| 3551 | sub xconvert_glade2_proto_to_glade1 { | ||
| 3552 | my ($class, $parentname, $proto, $depth) = @_; | ||
| 3553 | my $me = (ref $class || $class)."->convert_glade1_proto_to_glade2"; | ||
| 3554 | my $xml = Glade::PerlRun->string_from_file($proto); | ||
| 3555 | my ($encoding, $tree) = Glade::PerlXML->tree_from_string($xml, 'ISO-8859-1'); | ||
| 3556 | # my $depth = 0; | ||
| 3557 | my $protop = old_glade1_proto_from_tree( | ||
| 3558 | $tree->[1], $depth, | ||
| 3559 | ' ', | ||
| 3560 | ' project ', | ||
| 3561 | 'ISO-8859-1'); | ||
| 3562 | return ($protop, $proto); | ||
| 3563 | } | ||
| 3564 | |||
| 3565 | sub convert_proto_to_glade1 { | ||
| 3566 | my ($class, $parentname, $proto, $depth) = @_; | ||
| 3567 | my $me = (ref $class||$class)."->convert_glade2_proto_to_glade1"; | ||
| 3568 | my ($key, $val, $limit, $protop, $propkey, $value, $work, $seqkey); | ||
| 3569 | my $prune = "*$Glade::PerlRun::permitted_fields*"; | ||
| 3570 | my $proto2 = {}; | ||
| 3571 | my $contents = ''; | ||
| 3572 | my $child; | ||
| 3573 | # make up the start tag | ||
| 3574 | foreach $key ('widget', sort keys %{$proto}) { | ||
| 3575 | next unless keys %{$proto->{$key}}; | ||
| 3576 | unless ($prune =~ /\*$key\*/) { | ||
| 3577 | if (ref $proto->{$key} eq 'ARRAY') { | ||
| 3578 | print "expanding array '$key'\n"; | ||
| 3579 | print Dumper($proto->{$key}); | ||
| 3580 | foreach $child (@{$proto->{$key}}) { | ||
| 3581 | $contents .= "\n" if $key eq 'child'; | ||
| 3582 | # Expand each sub tree in array | ||
| 3583 | ($protop, $proto2->{$key}) = | ||
| 3584 | $class->convert_proto_to_glade1( | ||
| 3585 | $key, | ||
| 3586 | $child, | ||
| 3587 | $depth); | ||
| 3588 | } | ||
| 3589 | |||
| 3590 | } elsif (ref $proto->{$key} eq 'HASH') { | ||
| 3591 | if (' widget ' =~ / $key /) { | ||
| 3592 | print "expanding widget hash '$proto->{$key}{'id'}'\n"; | ||
| 3593 | print Dumper($proto->{$key}); | ||
| 3594 | $Glade_Perl->widgets->{'converted'}++; | ||
| 3595 | # Make up widget starttag | ||
| 3596 | $seqkey = "~widget-".sprintf("%04d", ++$seq); | ||
| 3597 | foreach $propkey (%{$proto->{$key}{'property'}}) { | ||
| 3598 | $work->{$propkey} = $proto->{$key}{'property'}{$propkey}{'value'}; | ||
| 3599 | } | ||
| 3600 | print "New widget $seqkey ", Dumper($proto2); | ||
| 3601 | $work->{'class'} = $proto->{$key}{'class'}; | ||
| 3602 | $work->{'name'} = $proto->{$key}{'id'}; | ||
| 3603 | # delete $work->{'id'}; | ||
| 3604 | # Move packing information | ||
| 3605 | if (keys %{$proto->{$key}{'packing'}}) { | ||
| 3606 | foreach $propkey (keys %{$proto->{$key}{'packing'}}) { | ||
| 3607 | print "Packing $propkey is '$proto->{$key}{'packing'}{$propkey}{'value'}'\n"; | ||
| 3608 | $work->{'child'}{$propkey} = $proto->{$key}{'packing'}{$propkey}{'value'}; | ||
| 3609 | } | ||
| 3610 | # $work->{'child'} = $proto->{$key}{'packing'}; | ||
| 3611 | delete $proto->{$key}{'packing'}; | ||
| 3612 | } | ||
| 3613 | # ($protop, $work->{$seqkey}) = | ||
| 3614 | # $class->convert_glade2_proto_to_glade1( | ||
| 3615 | # $key, | ||
| 3616 | # $proto->{$key}{'child'}, | ||
| 3617 | # $depth+1); | ||
| 3618 | # push @{$proto2}, $work; | ||
| 3619 | $proto->{$seqkey} = $work; | ||
| 3620 | |||
| 3621 | } elsif (' property ' =~ / $key /) { | ||
| 3622 | print "expanding property hash \n"; | ||
| 3623 | print Dumper($proto->{$key}); | ||
| 3624 | foreach $propkey (keys %{$proto->{$key}}) { | ||
| 3625 | $proto2->{$propkey} = $proto->{$key}{$propkey}{'value'}; | ||
| 3626 | } | ||
| 3627 | delete $proto->{$key}; | ||
| 3628 | |||
| 3629 | } else { | ||
| 3630 | print "expanding simple hash '$key'\n"; | ||
| 3631 | print Dumper($proto->{$key}); | ||
| 3632 | # call ourself to expand nested xml | ||
| 3633 | ($protop, $proto2->{$key}) = | ||
| 3634 | $class->glade1_proto_from_glade2_proto( | ||
| 3635 | $key, | ||
| 3636 | $proto->{$key}, | ||
| 3637 | $depth); | ||
| 3638 | } | ||
| 3639 | |||
| 3640 | } else { | ||
| 3641 | # We are simple element so store as attributes | ||
| 3642 | print "foreach key in '".ref $proto->{$key}."' '$key'\n", Dumper($proto); | ||
| 3643 | foreach $propkey (keys %{$proto}) { | ||
| 3644 | print "Propkey2 '$propkey' => '$proto->{$propkey}'\n"; | ||
| 3645 | unless (' value ' =~ / $propkey /) { | ||
| 3646 | $proto2->{$propkey} = $proto->{$propkey}{'value'}; | ||
| 3647 | # $starttag .= " $propkey=\"$proto->{$propkey}\""; | ||
| 3648 | } | ||
| 3649 | } | ||
| 3650 | if (defined $value && $value ne '') { | ||
| 3651 | $value = &Glade::PerlRun::QuoteXMLChars($value); | ||
| 3652 | print "Value '$value'\n"; | ||
| 3653 | } | ||
| 3654 | } | ||
| 3655 | } | ||
| 3656 | delete $proto->{$key}; | ||
| 3657 | #print "Deleting key '$key'\n"; | ||
| 3658 | } | ||
| 3659 | |||
| 3660 | # make up the string to return | ||
| 3661 | if (defined $contents && $contents eq '') { | ||
| 3662 | if ($key && $key eq 'child') { | ||
| 3663 | # $xml .= "$prefix<$stag>\n". | ||
| 3664 | # "$newprefix<placeholder />\n". | ||
| 3665 | # "$prefix</$etag>"; | ||
| 3666 | |||
| 3667 | } elsif ($key && $key ne '') { | ||
| 3668 | # $xml .= "$prefix<$stag />"; | ||
| 3669 | } | ||
| 3670 | |||
| 3671 | } else { | ||
| 3672 | if (defined $key && $key ne '' && $key ne 'form') { | ||
| 3673 | # $xml .= "$prefix<$stag>$contents\n$prefix</$etag>"; | ||
| 3674 | } else { | ||
| 3675 | # $xml .= "$contents"; | ||
| 3676 | } | ||
| 3677 | } | ||
| 3678 | return $protop, $proto2; | ||
| 3679 | } | ||
| 3680 | |||
| 3681 | sub string_from_proto { | ||
| 3682 | my ($class, $prefix, $tab, $stag, $etag, $proto) = @_; | ||
| 3683 | my $me = (ref $class||$class)."->string_from_proto"; | ||
| 3684 | my ($key, $val, $limit, $starttag, $propkey, $value); | ||
| 3685 | my $prune = "*$Glade::PerlRun::permitted_fields*"; | ||
| 3686 | my $child; | ||
| 3687 | my $xml = ''; | ||
| 3688 | my $contents = ''; | ||
| 3689 | my $newprefix = ''; | ||
| 3690 | $newprefix = "$tab$prefix" if defined $stag; | ||
| 3691 | unless (defined $etag) { | ||
| 3692 | # We are the file level so add toplevel widgets in order | ||
| 3693 | foreach $child (@{$proto->{'widget'}{'child'}}) { | ||
| 3694 | $contents .= "\n".$class->string_from_proto( | ||
| 3695 | $newprefix, $tab, '', '', $child, $prune); | ||
| 3696 | } | ||
| 3697 | return "<$stag>$contents\n</$stag>\n"; | ||
| 3698 | } | ||
| 3699 | $etag ||= $stag; | ||
| 3700 | # make up the start tag | ||
| 3701 | foreach $key ('property', 'signal', 'accelerator', 'requires', | ||
| 3702 | 'child', 'widget', 'packing', sort keys %$proto) { | ||
| 3703 | unless ($prune =~ /\*$key\*/) { | ||
| 3704 | if ($etag && ' signal accelerator requires ' =~ / $etag /) { | ||
| 3705 | # We are simple element (no value) so store as attributes | ||
| 3706 | $starttag = $stag; | ||
| 3707 | # Store 'name' as first attribute | ||
| 3708 | foreach $propkey ('name', 'signal') { | ||
| 3709 | if ($proto->{'property'}{$propkey}) { | ||
| 3710 | $starttag .= " $propkey=\"$proto->{'property'}{$propkey}{'value'}\""; | ||
| 3711 | delete $proto->{$propkey}; | ||
| 3712 | } | ||
| 3713 | } | ||
| 3714 | # Add all other attributes | ||
| 3715 | foreach $propkey (keys %{$proto->{'property'}}) { | ||
| 3716 | unless (' name signal ' =~ / $propkey /) { | ||
| 3717 | $starttag .= " $propkey=\"$proto->{'property'}{$propkey}{'value'}\""; | ||
| 3718 | } | ||
| 3719 | } | ||
| 3720 | $value = $proto->{'value'}; | ||
| 3721 | if (defined $value && $value ne '') { | ||
| 3722 | $value = &Glade::PerlRun::QuoteXMLChars($value); | ||
| 3723 | $contents .= "$prefix<$starttag>$value</$etag>"; | ||
| 3724 | } else { | ||
| 3725 | $contents .= "$prefix<$starttag />"; | ||
| 3726 | } | ||
| 3727 | delete $proto->{$key}; | ||
| 3728 | undef $stag; | ||
| 3729 | undef $etag; | ||
| 3730 | |||
| 3731 | } elsif (ref $proto->{$key} eq 'ARRAY') { | ||
| 3732 | foreach $child (@{$proto->{$key}}) { | ||
| 3733 | $contents .= "\n" if $key eq 'child'; | ||
| 3734 | # Expand each sub element in array | ||
| 3735 | $contents .= "\n". | ||
| 3736 | $class->string_from_proto( | ||
| 3737 | $newprefix, | ||
| 3738 | $tab, | ||
| 3739 | $key, | ||
| 3740 | $key, | ||
| 3741 | $child, | ||
| 3742 | $prune); | ||
| 3743 | } | ||
| 3744 | |||
| 3745 | } elsif (ref $proto->{$key} eq 'HASH') { | ||
| 3746 | if (' property ' =~ / $key /) { | ||
| 3747 | foreach $child (sort keys %{$proto->{$key}}) { | ||
| 3748 | # Expand each sub element in hash | ||
| 3749 | $starttag = $key; | ||
| 3750 | foreach $propkey ('name') { | ||
| 3751 | $starttag .= " $propkey=\"$child\""; | ||
| 3752 | } | ||
| 3753 | # Add all attributes (except value) to starttag | ||
| 3754 | foreach $propkey (sort keys %{$proto->{$key}{$child}}) { | ||
| 3755 | unless (' value ' =~ / $propkey /) { | ||
| 3756 | $starttag .= " $propkey=\"$proto->{$key}{$child}{$propkey}\""; | ||
| 3757 | delete $proto->{$key}{$child}; | ||
| 3758 | } | ||
| 3759 | } | ||
| 3760 | # Store <starttag>value</endtag> or <starttag /> | ||
| 3761 | $value = $proto->{$key}{$child}{'value'}; | ||
| 3762 | if (defined $value && $value ne '') { | ||
| 3763 | $value = &Glade::PerlRun::QuoteXMLChars($value); | ||
| 3764 | $contents .= "\n$newprefix<$starttag>$value</$key>"; | ||
| 3765 | } else { | ||
| 3766 | $contents .= "\n$newprefix<$starttag />"; | ||
| 3767 | } | ||
| 3768 | } | ||
| 3769 | # undef $stag; | ||
| 3770 | delete $proto->{$key}; | ||
| 3771 | |||
| 3772 | } else { | ||
| 3773 | if (' widget ' =~ / $key /) { | ||
| 3774 | # Make up widget starttag | ||
| 3775 | $starttag = "$key class=\"$proto->{$key}{class}\" id=\"$proto->{$key}{'name'}\""; | ||
| 3776 | delete $proto->{$key}{class}; | ||
| 3777 | delete $proto->{$key}{name}; | ||
| 3778 | } else { | ||
| 3779 | $starttag = $key; | ||
| 3780 | } | ||
| 3781 | # call ourself to expand nested xml | ||
| 3782 | $contents .= "\n". | ||
| 3783 | $class->string_from_proto( | ||
| 3784 | $newprefix, | ||
| 3785 | $tab, | ||
| 3786 | $starttag, | ||
| 3787 | $key, | ||
| 3788 | $proto->{$key}, | ||
| 3789 | $prune); | ||
| 3790 | } | ||
| 3791 | } | ||
| 3792 | } | ||
| 3793 | delete $proto->{$key}; | ||
| 3794 | } | ||
| 3795 | |||
| 3796 | # make up the string to return | ||
| 3797 | if (defined $contents && $contents eq '') { | ||
| 3798 | if ($stag eq 'child') { | ||
| 3799 | $xml .= "$prefix<$stag>\n". | ||
| 3800 | "$newprefix<placeholder />\n". | ||
| 3801 | "$prefix</$etag>"; | ||
| 3802 | |||
| 3803 | } elsif ($stag ne '') { | ||
| 3804 | $xml .= "$prefix<$stag />"; | ||
| 3805 | } | ||
| 3806 | |||
| 3807 | } else { | ||
| 3808 | if (defined $stag && $stag ne '' && $stag ne 'form') { | ||
| 3809 | $xml .= "$prefix<$stag>$contents\n$prefix</$etag>"; | ||
| 3810 | } else { | ||
| 3811 | $xml .= "$contents"; | ||
| 3812 | } | ||
| 3813 | } | ||
| 3814 | return $xml; | ||
| 3815 | } | ||
| 3816 | |||
| 3817 | my $gtk2_changes = { | ||
| 3818 | 'glade' => { | ||
| 3819 | 'project' => $REMOVED, | ||
| 3820 | }, | ||
| 3821 | 'gtk-2.0' => { | ||
| 3822 | $ALL => { | ||
| 3823 | $CHILD => { | ||
| 3824 | 'pack' =>'pack_type', | ||
| 3825 | 'child_ipad_x' => 'child_internal_pad_x', | ||
| 3826 | 'child_ipad_y' => 'child_internal_pad_y', | ||
| 3827 | }, | ||
| 3828 | 'child_min_width' => $OBSOLETE, | ||
| 3829 | 'child_min_height' => $OBSOLETE, | ||
| 3830 | 'child_ipad_x' => $OBSOLETE, | ||
| 3831 | 'child_ipad_y' => $OBSOLETE, | ||
| 3832 | 'width' => 'width-request', | ||
| 3833 | 'height' => 'height-request', | ||
| 3834 | }, | ||
| 3835 | 'GtkButton' => { | ||
| 3836 | 'label' => '&add_use_underline($proto)', | ||
| 3837 | }, | ||
| 3838 | 'GtkCList' => { | ||
| 3839 | $WIDGET => $DEPRECATED, | ||
| 3840 | $CONVERT_TO => 'GtkTreeView', | ||
| 3841 | $CHILD => { | ||
| 3842 | 'child_name' => $OBSOLETE, | ||
| 3843 | }, | ||
| 3844 | 'columns' => 'n-columns', | ||
| 3845 | }, | ||
| 3846 | 'GtkCTree' => { | ||
| 3847 | $WIDGET => $DEPRECATED, | ||
| 3848 | $CONVERT_TO => 'GtkTreeView', | ||
| 3849 | $CHILD => { | ||
| 3850 | 'child_name' => $OBSOLETE, | ||
| 3851 | }, | ||
| 3852 | 'columns' => 'n-columns', | ||
| 3853 | }, | ||
| 3854 | 'GtkClock' => { | ||
| 3855 | $WIDGET => $REMOVED, | ||
| 3856 | }, | ||
| 3857 | 'GtkColorSelection' => { | ||
| 3858 | 'policy' => $OBSOLETE, | ||
| 3859 | }, | ||
| 3860 | 'GtkColorSelectionDialog' => { | ||
| 3861 | 'policy' => $OBSOLETE, | ||
| 3862 | }, | ||
| 3863 | 'GtkCombo' => { | ||
| 3864 | 'use_arrows' => 'enable_arrow_keys', | ||
| 3865 | 'use_arrows_always' => 'enable_arrows_always', | ||
| 3866 | 'ok_if_empty' => 'allow_empty', | ||
| 3867 | }, | ||
| 3868 | 'GtkDial' => { | ||
| 3869 | $WIDGET => $REMOVED, | ||
| 3870 | }, | ||
| 3871 | 'GtkEntry' => { | ||
| 3872 | 'text_max_length' => 'max-length', | ||
| 3873 | 'text_visible' => 'visibility', | ||
| 3874 | }, | ||
| 3875 | 'GtkFileSelection' => { | ||
| 3876 | 'show_file_op_buttons' => 'show-fileops', | ||
| 3877 | }, | ||
| 3878 | 'GtkFrame' => { | ||
| 3879 | 'shadow_type' => 'shadow', | ||
| 3880 | }, | ||
| 3881 | 'GtkGammaCurve' => { | ||
| 3882 | 'curve_type' => $OBSOLETE, | ||
| 3883 | 'max_x' => $OBSOLETE, | ||
| 3884 | 'max_y' => $OBSOLETE, | ||
| 3885 | 'min_' => $OBSOLETE, | ||
| 3886 | 'min_y' => $OBSOLETE, | ||
| 3887 | }, | ||
| 3888 | 'GtkHPaned' => { | ||
| 3889 | 'handle_size' => $OBSOLETE, | ||
| 3890 | 'gutter_size' => $OBSOLETE, | ||
| 3891 | }, | ||
| 3892 | 'GtkVPaned' => { | ||
| 3893 | 'handle_size' => $OBSOLETE, | ||
| 3894 | 'gutter_size' => $OBSOLETE, | ||
| 3895 | }, | ||
| 3896 | 'GtkHScale' => { | ||
| 3897 | 'policy' => $OBSOLETE, | ||
| 3898 | }, | ||
| 3899 | 'GtkVScale' => { | ||
| 3900 | 'policy' => $OBSOLETE, | ||
| 3901 | }, | ||
| 3902 | 'GtkHScrollbar' => { | ||
| 3903 | 'policy' => $OBSOLETE, | ||
| 3904 | }, | ||
| 3905 | 'GtkVScrollbar' => { | ||
| 3906 | 'policy' => $OBSOLETE, | ||
| 3907 | }, | ||
| 3908 | 'GtkHRuler' => { | ||
| 3909 | 'metric' => $OBSOLETE, | ||
| 3910 | }, | ||
| 3911 | 'GtkVRuler' => { | ||
| 3912 | 'metric' => $OBSOLETE, | ||
| 3913 | }, | ||
| 3914 | 'GtkHandleBox' => { | ||
| 3915 | 'shadow_type' => 'shadow', | ||
| 3916 | }, | ||
| 3917 | 'GtkImage' => { | ||
| 3918 | 'image_width' => $OBSOLETE, | ||
| 3919 | 'image_height' => $OBSOLETE, | ||
| 3920 | 'image_visual' => $OBSOLETE, | ||
| 3921 | 'image_type' => $OBSOLETE, | ||
| 3922 | }, | ||
| 3923 | 'GtkLabel' => { | ||
| 3924 | 'default_focus_target' => 'mnemonic_widget', | ||
| 3925 | 'focus_target' => 'mnemonic_widget', | ||
| 3926 | }, | ||
| 3927 | 'GtkLayout' => { | ||
| 3928 | 'area_width' => 'width', | ||
| 3929 | 'area_height' => 'height', | ||
| 3930 | }, | ||
| 3931 | 'GtkList' => { | ||
| 3932 | $WIDGET => $BROKEN, | ||
| 3933 | }, | ||
| 3934 | 'GtkMenuBar' => { | ||
| 3935 | 'shadow_type' => $OBSOLETE, | ||
| 3936 | }, | ||
| 3937 | 'GtkMenuItem' => { | ||
| 3938 | 'right_justify' => $OBSOLETE, | ||
| 3939 | }, | ||
| 3940 | 'GtkNotebook' => { | ||
| 3941 | 'popup_enable' => 'enable-popup', | ||
| 3942 | }, | ||
| 3943 | 'GtkOptionMenu' => { | ||
| 3944 | 'initial_choice' => 'history', | ||
| 3945 | }, | ||
| 3946 | 'GtkPacker' => { | ||
| 3947 | $WIDGET => $REMOVED, | ||
| 3948 | }, | ||
| 3949 | 'GtkPixmap' => { | ||
| 3950 | $WIDGET => $DEPRECATED, | ||
| 3951 | $CONVERT_TO => 'GtkImage', | ||
| 3952 | }, | ||
| 3953 | 'GtkPixmapMenuItem' => { | ||
| 3954 | $WIDGET => $REMOVED, | ||
| 3955 | }, | ||
| 3956 | 'GtkRange' => { | ||
| 3957 | 'policy' => 'update-policy', | ||
| 3958 | }, | ||
| 3959 | 'GtkSpinButton' => { | ||
| 3960 | 'snap' => 'snap_to_ticks', | ||
| 3961 | }, | ||
| 3962 | 'GtkTable' => { | ||
| 3963 | $CHILD => { | ||
| 3964 | 'xpad' => 'x_padding', | ||
| 3965 | 'ypad' => 'y_padding', | ||
| 3966 | }, | ||
| 3967 | 'rows' => 'n-rows', | ||
| 3968 | 'columns' => 'n-columns', | ||
| 3969 | }, | ||
| 3970 | 'GtkText' => { | ||
| 3971 | $WIDGET => $BROKEN, | ||
| 3972 | }, | ||
| 3973 | 'GtkToolbar' => { | ||
| 3974 | 'space_size' => $OBSOLETE, | ||
| 3975 | 'space_style' => $OBSOLETE, | ||
| 3976 | 'relief' => $OBSOLETE, | ||
| 3977 | 'tooltips' => $OBSOLETE, | ||
| 3978 | 'type' => 'toolbar-style', | ||
| 3979 | }, | ||
| 3980 | 'GtkTree' => { | ||
| 3981 | $WIDGET => $BROKEN, | ||
| 3982 | }, | ||
| 3983 | 'GtkTreeItem' => { | ||
| 3984 | $WIDGET => $BROKEN, | ||
| 3985 | }, | ||
| 3986 | 'GtkWindow' => { | ||
| 3987 | 'auto_shrink' => $OBSOLETE, | ||
| 3988 | 'position' => 'window-position', | ||
| 3989 | }, | ||
| 3990 | 'GnomeCalculator' => { | ||
| 3991 | $WIDGET => $REMOVED, | ||
| 3992 | }, | ||
| 3993 | 'GnomeDialog' => { | ||
| 3994 | $WIDGET => $DEPRECATED, | ||
| 3995 | }, | ||
| 3996 | 'GnomeDruidPageStandard' => { | ||
| 3997 | 'title_color' => 'title_foreground', | ||
| 3998 | 'background_color' => 'background', | ||
| 3999 | 'logo_background_color' => 'logo_background', | ||
| 4000 | 'logo_image' => 'logo', | ||
| 4001 | }, | ||
| 4002 | 'GnomeEntry' => { | ||
| 4003 | 'max_saved' => $OBSOLETE, | ||
| 4004 | }, | ||
| 4005 | 'GnomeFileEntry' => { | ||
| 4006 | 'max_saved' => $OBSOLETE, | ||
| 4007 | 'directory' => 'directory_entry', | ||
| 4008 | 'title' => 'browse_dialog_title', | ||
| 4009 | }, | ||
| 4010 | 'GnomeFontPicker' => { | ||
| 4011 | 'use_font_size' => 'label-font-size', | ||
| 4012 | 'use_font' => 'use-font-in-label', | ||
| 4013 | }, | ||
| 4014 | 'GnomeIconEntry' => { | ||
| 4015 | 'max_saved' => $OBSOLETE, | ||
| 4016 | 'title' => 'browse_dialog_title', | ||
| 4017 | }, | ||
| 4018 | 'GnomeLess' => { | ||
| 4019 | $WIDGET => $REMOVED, | ||
| 4020 | }, | ||
| 4021 | 'GnomeNumberEntry' => { | ||
| 4022 | $WIDGET => $REMOVED, | ||
| 4023 | }, | ||
| 4024 | 'GnomePixmap' => { | ||
| 4025 | $WIDGET => $DEPRECATED, | ||
| 4026 | }, | ||
| 4027 | 'GnomePixMapEntry' => { | ||
| 4028 | 'title' => 'browse_dialog_title', | ||
| 4029 | }, | ||
| 4030 | 'GnomePropertyBox' => { | ||
| 4031 | 'auto_shrink' => $OBSOLETE, | ||
| 4032 | }, | ||
| 4033 | 'GnomeSpell' => { | ||
| 4034 | $WIDGET => $REMOVED, | ||
| 4035 | }, | ||
| 4036 | }, | ||
| 4037 | }; | ||
| 4038 | } | ||
| 4039 | |||
| 4040 | 1; | ||
| 4041 | |||
| 4042 | __END__ |