| 1 | package Glade::PerlUIExtra; | ||
| 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 Glade::PerlSource qw( :VARS :METHODS ); | ||
| 23 | use vars qw( | ||
| 24 | $PACKAGE $VERSION $AUTHOR $DATE | ||
| 25 | $enums | ||
| 26 | ); | ||
| 27 | # These cannot be looked up in the include files | ||
| 28 | $enums = { | ||
| 29 | 'GNOME_MENU_SAVE_AS_STRING' => 'Save _As...', | ||
| 30 | }; | ||
| 31 | $PACKAGE = __PACKAGE__; | ||
| 32 | $VERSION = q(0.61); | ||
| 33 | $AUTHOR = q(Dermot Musgrove <dermot.musgrove@virgin.net>); | ||
| 34 | $DATE = q(Sun Nov 17 03:21:11 GMT 2002); | ||
| 35 | } | ||
| 36 | |||
| 37 | sub DESTROY { | ||
| 38 | # This sub will be called on object destruction | ||
| 39 | } # End of sub DESTROY | ||
| 40 | |||
| 41 | #=============================================================================== | ||
| 42 | #=========== Gnome utilities ============ | ||
| 43 | #=============================================================================== | ||
| 44 | sub lookup { | ||
| 45 | my ($class, $self) = @_; | ||
| 46 | my $me = __PACKAGE__."->lookup"; | ||
| 47 | # Check cached enums first | ||
| 48 | my $lookup = $enums->{$self}; | ||
| 49 | |||
| 50 | unless ($lookup) { | ||
| 51 | my $work = $self; | ||
| 52 | foreach my $type ( | ||
| 53 | 'GNOME_MESSAGE_BOX', | ||
| 54 | 'GNOME_FONT_PICKER_MODE', | ||
| 55 | 'GNOME_PREFERENCES', | ||
| 56 | 'GNOME_DOCK', | ||
| 57 | 'GNOME_ANIMATOR_LOOP', | ||
| 58 | ) { | ||
| 59 | # Remove leading GTK type | ||
| 60 | if ($work =~ s/^${type}_//) { | ||
| 61 | $lookup = lc($work); | ||
| 62 | last; # finish early | ||
| 63 | } | ||
| 64 | } | ||
| 65 | } | ||
| 66 | |||
| 67 | unless ($lookup) { | ||
| 68 | # We still don't have a value so grep the gnome .h files | ||
| 69 | my ($grep, $inc_dir, $gnome_incs, $command, $hfiles); | ||
| 70 | $inc_dir = `gnome-config --includedir`; | ||
| 71 | chomp $inc_dir; | ||
| 72 | $gnome_incs = "$inc_dir/libgnomeui"; | ||
| 73 | $lookup = $self; | ||
| 74 | |||
| 75 | # Grep recursively in case one const points to another | ||
| 76 | while ($lookup =~ /^GNOME/) { | ||
| 77 | $grep = ''; | ||
| 78 | if ($lookup =~ /^GNOME_KEY_/) { | ||
| 79 | $hfiles = "gnome-uidefs.h"; | ||
| 80 | |||
| 81 | } elsif ($lookup =~ /^GNOME_MENU_/) { | ||
| 82 | $hfiles = 'gnome-app-helper.h'; | ||
| 83 | |||
| 84 | } elsif ($lookup =~ /^GNOME_STOCK_/) { | ||
| 85 | $hfiles = 'gnome-stock.h'; | ||
| 86 | |||
| 87 | } else { | ||
| 88 | $hfiles = "*.h"; | ||
| 89 | } | ||
| 90 | |||
| 91 | $command = "\$grep = `grep -h \"define.*\\\\b$lookup\\\\b\" $gnome_incs/$hfiles`"; | ||
| 92 | eval $command; | ||
| 93 | if ($grep) { | ||
| 94 | $grep =~ s/.*$lookup\s+//g; # Remove upto and including our enum name | ||
| 95 | $grep =~ s/^D_*//g; # Strip leading D_ gettext call | ||
| 96 | $grep =~ s/^[\'\"\s\(]*//g; # Strip leading spaces brackets or quotes | ||
| 97 | $grep =~ s/[\'\"\s\)]*$//g; # Strip trailing spaces brackets or quotes | ||
| 98 | } | ||
| 99 | $lookup = $grep; | ||
| 100 | } | ||
| 101 | } | ||
| 102 | # Cache this enum for later use | ||
| 103 | $enums->{$self} = $lookup; | ||
| 104 | return $lookup; | ||
| 105 | } | ||
| 106 | |||
| 107 | #=============================================================================== | ||
| 108 | #=========== Gnome widget constructors ============ | ||
| 109 | #=============================================================================== | ||
| 110 | sub frig_Gnome_Dialog_buttons { | ||
| 111 | my ($class, $parent, $proto, $depth) = @_; | ||
| 112 | my $typekey = $class->typeKey; | ||
| 113 | my ($stock_button, $sensitive, $visible); | ||
| 114 | my ($can_default, $has_default, $can_focus, $has_focus); | ||
| 115 | my ($key, $work, $subkey, $subwork); | ||
| 116 | my $current_button = 0; | ||
| 117 | foreach $key (keys %{$proto}) { | ||
| 118 | $work = $proto->{$key}; | ||
| 119 | next unless ref $work; | ||
| 120 | if ($work->{$typekey} eq 'widget') { | ||
| 121 | $stock_button = $class->use_par($work, 'stock_button', $LOOKUP); | ||
| 122 | # FIXME Glade saves all these but surely it's pointless | ||
| 123 | # We can't get at the button to set them in any case | ||
| 124 | # $visible = $class->use_par($work, 'visible', $BOOL, 1); | ||
| 125 | # $can_focus = $class->use_par($work, 'can_focus', $BOOL, 1); | ||
| 126 | # $has_focus = $class->use_par($work, 'has_focus', $BOOL, 0); | ||
| 127 | $can_default = $class->use_par($work, 'can_default', $BOOL, 1); | ||
| 128 | $has_default = $class->use_par($work, 'has_default', $BOOL, 0); | ||
| 129 | $sensitive = $class->use_par($work, 'sensitive', $BOOL, 1); | ||
| 130 | $class->add_to_UI( $depth, | ||
| 131 | "$current_window\->append_button('$stock_button');"); | ||
| 132 | (defined $sensitive) && !$sensitive && | ||
| 133 | $class->add_to_UI( $depth, | ||
| 134 | "$current_window\->set_sensitive(". | ||
| 135 | "'$current_button', $sensitive);"); | ||
| 136 | $has_default && $can_default && | ||
| 137 | $class->add_to_UI( $depth, | ||
| 138 | "$current_window\->set_default('$current_button');"); | ||
| 139 | |||
| 140 | foreach $subkey (keys %$work) { | ||
| 141 | # print Dumper($work->{$subkey}); | ||
| 142 | next unless ref $work->{$subkey}; | ||
| 143 | $subwork = $work->{$subkey}; | ||
| 144 | if ($subwork->{$typekey} eq 'accelerator') { | ||
| 145 | $class->new_accelerator($parent, $subwork, | ||
| 146 | $depth, $current_button); | ||
| 147 | |||
| 148 | } elsif ($subwork->{$typekey} eq 'signal') { | ||
| 149 | $Glade_Perl->diag_print(1, "warn You have specified a signal". | ||
| 150 | "'%s' (handler '%s') for Gnome::Dialog button '%s' ". | ||
| 151 | "but Gtk-Perl cannot add it and it has been ignored", | ||
| 152 | $subwork->{'name'}, $subwork->{'handler'}, | ||
| 153 | $work->{'name'}); | ||
| 154 | } | ||
| 155 | } | ||
| 156 | |||
| 157 | delete $proto->{$key}; | ||
| 158 | $current_button++; | ||
| 159 | } | ||
| 160 | } | ||
| 161 | } | ||
| 162 | |||
| 163 | sub new_GnomeAbout { | ||
| 164 | my ($class, $parent, $proto, $depth) = @_; | ||
| 165 | my $me = "$class->new_GnomeAbout"; | ||
| 166 | my $name = $proto->{name}; | ||
| 167 | my $title = $class->use_par($proto, 'title', $DEFAULT, $Glade_Perl->app->name ); | ||
| 168 | my $version = $class->use_par($proto, 'version', $DEFAULT, $Glade_Perl->app->version ); | ||
| 169 | my $logo = $class->use_par($proto, 'logo', $DEFAULT, $Glade_Perl->app->logo ); | ||
| 170 | my $copyright = $class->use_par($proto, 'copyright', $DEFAULT, S_("Copyright")." ".$Glade_Perl->app->date ); | ||
| 171 | my $authors = $class->use_par($proto, 'authors', $DEFAULT, $Glade_Perl->app->author ); | ||
| 172 | my $comments = $class->use_par($proto, 'comments', $DEFAULT, $Glade_Perl->app->copying ); | ||
| 173 | $logo = "\"\$Glade::PerlRun::pixmaps_directory/$logo\""; | ||
| 174 | |||
| 175 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gnome::About(". | ||
| 176 | "_('$title'), '$version', _('$copyright'), '$authors', _('$comments'), $logo);" ); | ||
| 177 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_title(". | ||
| 178 | "_('About').' $title' );" ); | ||
| 179 | |||
| 180 | $class->set_window_properties($parent, $name, $proto, $depth ); | ||
| 181 | return $widgets->{$name}; | ||
| 182 | } | ||
| 183 | |||
| 184 | sub new_GnomeAnimator { | ||
| 185 | my ($class, $parent, $proto, $depth) = @_; | ||
| 186 | my $me = "$class->new_GnomeAnimator"; | ||
| 187 | my $name = $proto->{name}; | ||
| 188 | my $playback_direction = | ||
| 189 | $class->use_par($proto, 'playback_direction', $BOOL, 0 ) ? '-1' : '1'; | ||
| 190 | my $playback_speed = $class->use_par($proto, 'playback_speed', $DEFAULT, 1 ); | ||
| 191 | my $loop_type = $class->use_par($proto, 'loop_type', $LOOKUP, 'none' ); | ||
| 192 | |||
| 193 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = ". | ||
| 194 | "new_with_size Gnome::Animator(190, 141);" ); | ||
| 195 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_playback_speed(". | ||
| 196 | "$playback_speed );" ); | ||
| 197 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_playback_direction(". | ||
| 198 | "$playback_direction );" ); | ||
| 199 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_loop_type(". | ||
| 200 | "'$loop_type' );" ); | ||
| 201 | |||
| 202 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 203 | return $widgets->{$name}; | ||
| 204 | } | ||
| 205 | |||
| 206 | sub new_GnomeApp { | ||
| 207 | my ($class, $parent, $proto, $depth) = @_; | ||
| 208 | my $me = "$class->new_GnomeApp"; | ||
| 209 | my $name = $proto->{name}; | ||
| 210 | my $appname = $class->use_par($proto, 'title', $DEFAULT, $Glade_Perl->app->name ); | ||
| 211 | my $title = $class->use_par($proto, 'title', $DEFAULT, $Glade_Perl->app->name ); | ||
| 212 | my $enable_layout_config = $class->use_par($proto, 'enable_layout_config', $BOOL, 'True' ); | ||
| 213 | |||
| 214 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gnome::App(". | ||
| 215 | "'$appname', _('$title'));" ); | ||
| 216 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->enable_layout_config(". | ||
| 217 | "$enable_layout_config );" ); | ||
| 218 | |||
| 219 | $class->set_window_properties($parent, $name, $proto, $depth ); | ||
| 220 | return $widgets->{$name}; | ||
| 221 | } | ||
| 222 | |||
| 223 | sub new_GnomeAppBar { | ||
| 224 | my ($class, $parent, $proto, $depth) = @_; | ||
| 225 | my $me = "$class->new_GnomeAppBar"; | ||
| 226 | my $name = $proto->{name}; | ||
| 227 | my $has_progress = $class->use_par($proto, 'has_progress', $BOOL, 'True' ); | ||
| 228 | my $has_status = $class->use_par($proto, 'has_status', $BOOL, 'True' ); | ||
| 229 | my $interactivity = $class->use_par($proto, 'interactivity', $LOOKUP, 'user' ); | ||
| 230 | |||
| 231 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gnome::AppBar(". | ||
| 232 | "$has_progress, $has_status, '$interactivity');" ); | ||
| 233 | |||
| 234 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 235 | return $widgets->{$name}; | ||
| 236 | } | ||
| 237 | |||
| 238 | sub new_GnomeCalculator { | ||
| 239 | my ($class, $parent, $proto, $depth) = @_; | ||
| 240 | my $me = "$class->new_GnomeCalculator"; | ||
| 241 | my $name = $proto->{name}; | ||
| 242 | |||
| 243 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = ". | ||
| 244 | "${current_form}\{$parent}->new_child('Gnome::Calculator');" ); | ||
| 245 | |||
| 246 | # FIXME move this to internal_pack_widget or somewhere more central | ||
| 247 | # perhaps gnome_pack_widget | ||
| 248 | $class->add_to_UI($depth, "\$widgets->{'$name'}->show;" ); | ||
| 249 | $class->add_to_UI( $depth, | ||
| 250 | "${current_form}\{$name} = \$widgets->{'$name'};" ); | ||
| 251 | # Delete the $widget to show that it has been packed | ||
| 252 | delete $widgets->{$name}; | ||
| 253 | # $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 254 | return $widgets->{$name}; | ||
| 255 | } | ||
| 256 | |||
| 257 | sub new_GnomeCanvas { | ||
| 258 | my ($class, $parent, $proto, $depth) = @_; | ||
| 259 | my $me = "$class->new_GnomeCanvas"; | ||
| 260 | my $name = $proto->{name}; | ||
| 261 | my $pixels_per_unit = $class->use_par($proto, 'pixels_per_unit', $DEFAULT, 1 ); | ||
| 262 | my $scroll_x1 = $class->use_par($proto, 'scroll_x1',$DEFAULT, 0 ); | ||
| 263 | my $scroll_y1 = $class->use_par($proto, 'scroll_y1',$DEFAULT, 0 ); | ||
| 264 | my $scroll_x2 = $class->use_par($proto, 'scroll_x2',$DEFAULT, 100 ); | ||
| 265 | my $scroll_y2 = $class->use_par($proto, 'scroll_y2',$DEFAULT, 100 ); | ||
| 266 | my $anti_aliased = $class->use_par($proto, 'anti_aliased', $BOOL, 'False' ); | ||
| 267 | |||
| 268 | if ($anti_aliased) { | ||
| 269 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = ". | ||
| 270 | "new_aa Gnome::Canvas;" ); | ||
| 271 | } else { | ||
| 272 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = ". | ||
| 273 | "new Gnome::Canvas;" ); | ||
| 274 | } | ||
| 275 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_scroll_region(". | ||
| 276 | "$scroll_x1, $scroll_y1, $scroll_x2, $scroll_y2 );" ); | ||
| 277 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_pixels_per_unit(". | ||
| 278 | "$pixels_per_unit );" ); | ||
| 279 | |||
| 280 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 281 | return $widgets->{$name}; | ||
| 282 | } | ||
| 283 | |||
| 284 | sub new_GnomeColorPicker { | ||
| 285 | my ($class, $parent, $proto, $depth) = @_; | ||
| 286 | my $me = "$class->new_GnomeColorPicker"; | ||
| 287 | my $name = $proto->{name}; | ||
| 288 | my $dither = $class->use_par($proto, 'dither', $BOOL, 'True' ); | ||
| 289 | my $use_alpha = $class->use_par($proto, 'use_alpha',$BOOL, 'False' ); | ||
| 290 | my $title = $class->use_par($proto, 'title', $DEFAULT, '' ); | ||
| 291 | |||
| 292 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = ". | ||
| 293 | "new Gnome::ColorPicker;" ); | ||
| 294 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_dither(". | ||
| 295 | "$dither );" ); | ||
| 296 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_use_alpha(". | ||
| 297 | "$use_alpha );" ); | ||
| 298 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_title(". | ||
| 299 | "_('$title') );" ); | ||
| 300 | |||
| 301 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 302 | return $widgets->{$name}; | ||
| 303 | } | ||
| 304 | |||
| 305 | sub new_GnomeDateEdit { | ||
| 306 | my ($class, $parent, $proto, $depth) = @_; | ||
| 307 | my $me = "$class->new_GnomeDateEdit"; | ||
| 308 | my $name = $proto->{name}; | ||
| 309 | my $show_time = $class->use_par($proto, 'show_time', $BOOL, 'True' ); | ||
| 310 | my $use_24_format = $class->use_par($proto, 'use_24_format', $BOOL, 'True' ); | ||
| 311 | my $week_start_monday = $class->use_par($proto, 'week_start_monday', $BOOL, 'False' ); | ||
| 312 | my $lower_hour = $class->use_par($proto, 'lower_hour', $DEFAULT, 7 ); | ||
| 313 | my $upper_hour = $class->use_par($proto, 'upper_hour', $DEFAULT, 19 ); | ||
| 314 | |||
| 315 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gnome::DateEdit(". | ||
| 316 | "0, $show_time, $use_24_format);" ); | ||
| 317 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_popup_range(". | ||
| 318 | "$lower_hour, $upper_hour );" ); | ||
| 319 | |||
| 320 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 321 | return $widgets->{$name}; | ||
| 322 | } | ||
| 323 | |||
| 324 | sub new_GnomeDialog { | ||
| 325 | my ($class, $parent, $proto, $depth) = @_; | ||
| 326 | my $me = "$class->new_GnomeDialog"; | ||
| 327 | my $name = $proto->{name}; | ||
| 328 | my $title = $class->use_par($proto, 'title', $DEFAULT, '' ); | ||
| 329 | my $auto_close = $class->use_par($proto, 'auto_close', $BOOL, 'True' ); | ||
| 330 | my $hide_on_close = $class->use_par($proto, 'hide_on_close', $BOOL, 'True' ); | ||
| 331 | |||
| 332 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gnome::Dialog(". | ||
| 333 | "_('$title'));" ); | ||
| 334 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->close_hides(". | ||
| 335 | "$hide_on_close );" ); | ||
| 336 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_close(". | ||
| 337 | "$auto_close );" ); | ||
| 338 | |||
| 339 | $class->set_window_properties($parent, $name, $proto, $depth ); | ||
| 340 | |||
| 341 | return $widgets->{$name}; | ||
| 342 | } | ||
| 343 | |||
| 344 | sub new_GnomeDock { | ||
| 345 | my ($class, $parent, $proto, $depth) = @_; | ||
| 346 | my $me = "$class->new_GnomeDock"; | ||
| 347 | my $name = $proto->{name}; | ||
| 348 | my $allow_floating = $class->use_par($proto, 'allow_floating', $BOOL, 'True' ); | ||
| 349 | my $child_name = $class->use_par($proto, 'child_name', $DEFAULT, 'True' ); | ||
| 350 | |||
| 351 | if ($child_name) { | ||
| 352 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = ". | ||
| 353 | "$current_form\{'$parent'}->get_dock;" ); | ||
| 354 | } else { | ||
| 355 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gnome::Dock;" ); | ||
| 356 | } | ||
| 357 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->allow_floating_items(". | ||
| 358 | "$allow_floating );" ); | ||
| 359 | |||
| 360 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 361 | return $widgets->{$name}; | ||
| 362 | } | ||
| 363 | |||
| 364 | sub new_GnomeDockItem { | ||
| 365 | my ($class, $parent, $proto, $depth) = @_; | ||
| 366 | my $me = "$class->new_GnomeDockItem"; | ||
| 367 | my $name = $proto->{name}; | ||
| 368 | my $shadow_type = $class->use_par($proto, 'shadow_type', $LOOKUP, 'out' ); | ||
| 369 | |||
| 370 | my @options; | ||
| 371 | push @options, 'exclusive' if | ||
| 372 | $class->use_par($proto, 'exclusive', $BOOL, 'True' ); | ||
| 373 | push @options, 'never_horizontal' if | ||
| 374 | $class->use_par($proto, 'never_horizontal', $BOOL, 'False' ); | ||
| 375 | push @options, 'never_vertical' if | ||
| 376 | $class->use_par($proto, 'never_vertical', $BOOL, 'True' ); | ||
| 377 | push @options, 'locked' if | ||
| 378 | $class->use_par($proto, 'locked', $BOOL, 'True' ); | ||
| 379 | push @options, 'never_float' if | ||
| 380 | $class->use_par($proto, 'never_floating', $BOOL, 'False' ); | ||
| 381 | # 'exclusive', 'never_horizontal', 'never_vertical', 'normal', 'locked', or 'never_float' | ||
| 382 | # FIXME where do I get 'normal' ? | ||
| 383 | # push @options, 'normal' if | ||
| 384 | # $class->use_par($proto, 'normal', $BOOL, 'False' ); | ||
| 385 | my $behavior; | ||
| 386 | if (scalar @options) { | ||
| 387 | $behavior = "['".join("', '", @options)."']", | ||
| 388 | } else { | ||
| 389 | $behavior = '[]' | ||
| 390 | } | ||
| 391 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gnome::DockItem(". | ||
| 392 | "'$name', $behavior );" ); | ||
| 393 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_shadow_type(". | ||
| 394 | "'$shadow_type' );" ); | ||
| 395 | |||
| 396 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 397 | return $widgets->{$name}; | ||
| 398 | } | ||
| 399 | |||
| 400 | sub new_GnomeDruid { | ||
| 401 | my ($class, $parent, $proto, $depth) = @_; | ||
| 402 | my $me = "$class->new_GnomeDruid"; | ||
| 403 | my $name = $proto->{name}; | ||
| 404 | |||
| 405 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gnome::Druid;" ); | ||
| 406 | |||
| 407 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 408 | return $widgets->{$name}; | ||
| 409 | } | ||
| 410 | |||
| 411 | sub new_GnomeDruidPageStart { | ||
| 412 | my ($class, $parent, $proto, $depth) = @_; | ||
| 413 | my $me = "$class->new_GnomeDruidPageStart"; | ||
| 414 | my ($type, $value, $command, $color_string, $red, $blue, $green); | ||
| 415 | my $name = $proto->{name}; | ||
| 416 | my $title = $class->use_par($proto, 'title', $DEFAULT, '' ); | ||
| 417 | my $text = $class->use_par($proto, 'text', $DEFAULT, '' ); | ||
| 418 | my $logo_image = $class->use_par($proto, 'logo_image', $DEFAULT, '' ); | ||
| 419 | my $watermark_image = $class->use_par($proto, 'watermark_image', $DEFAULT, '' ); | ||
| 420 | |||
| 421 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gnome::DruidPageStart;" ); | ||
| 422 | foreach $type ('background', 'textbox', 'logo_background', 'title', 'text') { | ||
| 423 | $value = $class->use_par($proto, "$type\_color", $DEFAULT, '' ); | ||
| 424 | if ($value) { | ||
| 425 | ($red, $green, $blue) = split(',', $value); | ||
| 426 | $red *= 257; $green *= 257; $blue *= 257; | ||
| 427 | $color_string = "${current_form}\{$parent}->get_toplevel->". | ||
| 428 | "get_colormap->color_alloc({red => $red, green => $green, blue => $blue})"; | ||
| 429 | $command = $type; | ||
| 430 | $command =~ s/background/bg/; | ||
| 431 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_$command\_color(". | ||
| 432 | "$color_string);"); | ||
| 433 | } | ||
| 434 | } | ||
| 435 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_title(_('$title') );" ); | ||
| 436 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_text(_('$text') );" ); | ||
| 437 | $logo_image && | ||
| 438 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_logo(". | ||
| 439 | "\$class->create_image('$logo_image'));" ); | ||
| 440 | $watermark_image && | ||
| 441 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_watermark(". | ||
| 442 | "\$class->create_image('$watermark_image'));" ); | ||
| 443 | |||
| 444 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 445 | return $widgets->{$name}; | ||
| 446 | } | ||
| 447 | |||
| 448 | sub new_GnomeDruidPageStandard { | ||
| 449 | my ($class, $parent, $proto, $depth) = @_; | ||
| 450 | my $me = "$class->new_GnomeDruidPageStandard"; | ||
| 451 | my ($type, $value, $command, $color_string, $red, $blue, $green); | ||
| 452 | my $name = $proto->{name}; | ||
| 453 | my $title = $class->use_par($proto, 'title', $DEFAULT, '' ); | ||
| 454 | my $logo_image = $class->use_par($proto, 'logo_image', $DEFAULT, '' ); | ||
| 455 | my $watermark_image = $class->use_par($proto, 'watermark_image', $DEFAULT, '' ); | ||
| 456 | |||
| 457 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gnome::DruidPageStandard;" ); | ||
| 458 | foreach $type ('background', 'textbox', 'logo_background', 'title', 'text') { | ||
| 459 | $value = $class->use_par($proto, "$type\_color", $DEFAULT, '' ); | ||
| 460 | if ($value) { | ||
| 461 | ($red, $green, $blue) = split(',', $value); | ||
| 462 | $red *= 257; $green *= 257; $blue *= 257; | ||
| 463 | $command = $type; | ||
| 464 | $command =~ s/background/bg/; | ||
| 465 | $color_string = "${current_form}\{$parent}->get_toplevel->". | ||
| 466 | "get_colormap->color_alloc({red => $red, green => $green, blue => $blue})"; | ||
| 467 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_$command\_color(". | ||
| 468 | "$color_string);"); | ||
| 469 | } | ||
| 470 | } | ||
| 471 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_title(_('$title') );" ); | ||
| 472 | $logo_image && | ||
| 473 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_logo(". | ||
| 474 | "\$class->create_image('$logo_image' ));" ); | ||
| 475 | $watermark_image && | ||
| 476 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_watermark(". | ||
| 477 | "\$class->create_image('$watermark_image' ));" ); | ||
| 478 | |||
| 479 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 480 | return $widgets->{$name}; | ||
| 481 | } | ||
| 482 | |||
| 483 | sub new_GnomeDruidPageFinish { | ||
| 484 | my ($class, $parent, $proto, $depth) = @_; | ||
| 485 | my $me = "$class->new_GnomeDruidPageFinish"; | ||
| 486 | my ($type, $value, $command, $color_string, $red, $blue, $green); | ||
| 487 | my $name = $proto->{name}; | ||
| 488 | my $title = $class->use_par($proto, 'title', $DEFAULT, '' ); | ||
| 489 | my $text = $class->use_par($proto, 'text', $DEFAULT, '' ); | ||
| 490 | my $logo_image = $class->use_par($proto, 'logo_image', $DEFAULT, '' ); | ||
| 491 | my $watermark_image = $class->use_par($proto, 'watermark_image', $DEFAULT, '' ); | ||
| 492 | |||
| 493 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gnome::DruidPageFinish;" ); | ||
| 494 | foreach $type ('background', 'textbox', 'logo_background', 'title', 'text') { | ||
| 495 | $value = $class->use_par($proto, "$type\_color", $DEFAULT, '' ); | ||
| 496 | if ($value) { | ||
| 497 | ($red, $green, $blue) = split(',', $value); | ||
| 498 | $red *= 257; $green *= 257; $blue *= 257; | ||
| 499 | $color_string = "${current_form}\{$parent}->get_toplevel->". | ||
| 500 | "get_colormap->color_alloc({red => $red, green => $green, blue => $blue})"; | ||
| 501 | $command = $type; | ||
| 502 | $command =~ s/background/bg/; | ||
| 503 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_$command\_color(". | ||
| 504 | "$color_string);"); | ||
| 505 | } | ||
| 506 | } | ||
| 507 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_title(_('$title') );" ); | ||
| 508 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_text(_('$text') );" ); | ||
| 509 | $logo_image && | ||
| 510 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_logo(". | ||
| 511 | "\$class->create_image('$logo_image' ));" ); | ||
| 512 | $watermark_image && | ||
| 513 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_watermark(". | ||
| 514 | "\$class->create_image('$watermark_image' ));" ); | ||
| 515 | |||
| 516 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 517 | return $widgets->{$name}; | ||
| 518 | } | ||
| 519 | |||
| 520 | sub new_GnomeEntry { | ||
| 521 | my ($class, $parent, $proto, $depth) = @_; | ||
| 522 | my $me = "$class->new_GnomeEntry"; | ||
| 523 | my $name = $proto->{name}; | ||
| 524 | my $history_id = $class->use_par($proto, 'history_id', $DEFAULT, '' ); | ||
| 525 | my $max_saved = $class->use_par($proto, 'max_saved', $DEFAULT, 10 ); | ||
| 526 | |||
| 527 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gnome::Entry(". | ||
| 528 | "'$history_id');" ); | ||
| 529 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_max_saved(". | ||
| 530 | "$max_saved );" ); | ||
| 531 | |||
| 532 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 533 | return $widgets->{$name}; | ||
| 534 | } | ||
| 535 | |||
| 536 | sub new_GnomeFileEntry { | ||
| 537 | my ($class, $parent, $proto, $depth) = @_; | ||
| 538 | my $me = "$class->new_GnomeFileEntry"; | ||
| 539 | my $name = $proto->{name}; | ||
| 540 | my $history_id = $class->use_par($proto, 'history_id', $DEFAULT, '' ); | ||
| 541 | my $title = $class->use_par($proto, 'title', $DEFAULT, '' ); | ||
| 542 | my $max_saved = $class->use_par($proto, 'max_saved', $DEFAULT, 10 ); | ||
| 543 | my $directory = $class->use_par($proto, 'directory', $BOOL, 'False' ); | ||
| 544 | my $modal = $class->use_par($proto, 'modal', $BOOL, 'False' ); | ||
| 545 | |||
| 546 | if ($proto->{'child_name'}) { | ||
| 547 | my $type = $class->use_par($proto, 'child_name' ,$DEFAULT, ''); | ||
| 548 | if ($type eq 'GnomePixmapEntry:file-entry') { | ||
| 549 | $type = 'gnome_file_entry'; | ||
| 550 | } else { | ||
| 551 | $type =~ s/.*:(.*)/$1/; | ||
| 552 | } | ||
| 553 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = ". | ||
| 554 | "$current_form\{'$parent'}->$type;" ); | ||
| 555 | } else { | ||
| 556 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gnome::FileEntry(". | ||
| 557 | "'$history_id', _('$title'));" ); | ||
| 558 | } | ||
| 559 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->gnome_entry->set_max_saved(". | ||
| 560 | "$max_saved );" ); | ||
| 561 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_directory(". | ||
| 562 | "$directory );" ); | ||
| 563 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_modal(". | ||
| 564 | "$modal);" ); | ||
| 565 | |||
| 566 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 567 | return $widgets->{$name}; | ||
| 568 | } | ||
| 569 | |||
| 570 | sub new_GnomeFontPicker { | ||
| 571 | my ($class, $parent, $proto, $depth) = @_; | ||
| 572 | my $me = "$class->new_GnomeFontPicker"; | ||
| 573 | my $name = $proto->{name}; | ||
| 574 | my $the_time = localtime; | ||
| 575 | my $title = $class->use_par($proto, 'title', $DEFAULT, '' ); | ||
| 576 | my $preview_text = $class->use_par($proto, 'preview_text', $DEFAULT, 'The quick brown fox jumped over the lazy dog' ); | ||
| 577 | my $mode = $class->use_par($proto, 'mode', $LOOKUP, 'pixmap' ); | ||
| 578 | my $show_size = $class->use_par($proto, 'show_size', $BOOL, 'True' ); | ||
| 579 | my $use_font = $class->use_par($proto, 'use_font', $BOOL, 'False' ); | ||
| 580 | my $use_font_size = $class->use_par($proto, 'use_font_size', $DEFAULT, 14); | ||
| 581 | |||
| 582 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = ". | ||
| 583 | "new Gnome::FontPicker;" ); | ||
| 584 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_title(". | ||
| 585 | "_('$title') );" ); | ||
| 586 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_mode(". | ||
| 587 | "'$mode' );" ); | ||
| 588 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->fi_set_show_size(". | ||
| 589 | "$show_size );" ); | ||
| 590 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_preview_text(". | ||
| 591 | "_('$preview_text' ));" ); | ||
| 592 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->fi_set_use_font_in_label(". | ||
| 593 | "$use_font, $use_font_size );" ); | ||
| 594 | |||
| 595 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 596 | return $widgets->{$name}; | ||
| 597 | } | ||
| 598 | |||
| 599 | sub new_GnomeHRef { | ||
| 600 | my ($class, $parent, $proto, $depth) = @_; | ||
| 601 | my $me = "$class->new_GnomeHRef"; | ||
| 602 | my $name = $proto->{name}; | ||
| 603 | my $url = $class->use_par($proto, 'url', $DEFAULT, '' ); | ||
| 604 | my $label = $class->use_par($proto, 'label', $DEFAULT, '' ); | ||
| 605 | |||
| 606 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gnome::HRef(". | ||
| 607 | "'$url', _('$label'));" ); | ||
| 608 | |||
| 609 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 610 | return $widgets->{$name}; | ||
| 611 | } | ||
| 612 | |||
| 613 | sub new_GnomeIconEntry { | ||
| 614 | my ($class, $parent, $proto, $depth) = @_; | ||
| 615 | my $me = "$class->new_GnomeIconEntry"; | ||
| 616 | my $name = $proto->{name}; | ||
| 617 | my $history_id = $class->use_par($proto, 'history_id', $DEFAULT, '' ); | ||
| 618 | my $title = $class->use_par($proto, 'title', $DEFAULT, '' ); | ||
| 619 | my $max_saved = $class->use_par($proto, 'max_saved', $DEFAULT, 10 ); | ||
| 620 | |||
| 621 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gnome::IconEntry(". | ||
| 622 | "'$history_id', _('$title'));" ); | ||
| 623 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->gnome_entry->set_max_saved(". | ||
| 624 | "$max_saved );" ); | ||
| 625 | |||
| 626 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 627 | return $widgets->{$name}; | ||
| 628 | } | ||
| 629 | |||
| 630 | sub new_GnomeIconList { | ||
| 631 | my ($class, $parent, $proto, $depth) = @_; | ||
| 632 | my $me = "$class->new_GnomeIconList"; | ||
| 633 | my $name = $proto->{name}; | ||
| 634 | my $text_editable = $class->use_par($proto, 'text_editable', $BOOL, 'False' ); | ||
| 635 | my $icon_width = $class->use_par($proto, 'icon_width', $DEFAULT, 78); | ||
| 636 | my $selection_mode = $class->use_par($proto, 'selection_mode', $LOOKUP, 'single' ); | ||
| 637 | my $row_spacing = $class->use_par($proto, 'row_spacing', $DEFAULT, 4 ); | ||
| 638 | my $column_spacing = $class->use_par($proto, 'column_spacing', $DEFAULT, 2 ); | ||
| 639 | my $text_spacing = $class->use_par($proto, 'text_spacing', $DEFAULT, 2 ); | ||
| 640 | my $text_static = $class->use_par($proto, 'text_static', $BOOL, 'False' ); | ||
| 641 | my $flags = $text_editable + 2 * $text_static; | ||
| 642 | # FIXME possibly use new_flags() ? | ||
| 643 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gnome::IconList(". | ||
| 644 | "$icon_width, undef, $flags);" ); | ||
| 645 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_row_spacing(". | ||
| 646 | "$row_spacing );" ); | ||
| 647 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_col_spacing(". | ||
| 648 | "$column_spacing );" ); | ||
| 649 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_text_spacing(". | ||
| 650 | "$text_spacing );" ); | ||
| 651 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_selection_mode(". | ||
| 652 | "'$selection_mode' );" ); | ||
| 653 | |||
| 654 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 655 | return $widgets->{$name}; | ||
| 656 | } | ||
| 657 | |||
| 658 | sub new_GnomeIconSelection { | ||
| 659 | my ($class, $parent, $proto, $depth) = @_; | ||
| 660 | my $me = "$class->new_GnomeIconSelection"; | ||
| 661 | my $name = $proto->{name}; | ||
| 662 | |||
| 663 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gnome::IconSelection();" ); | ||
| 664 | |||
| 665 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 666 | return $widgets->{$name}; | ||
| 667 | } | ||
| 668 | |||
| 669 | |||
| 670 | sub new_GnomeLess { | ||
| 671 | my ($class, $parent, $proto, $depth) = @_; | ||
| 672 | my $me = "$class->new_GnomeLess"; | ||
| 673 | my $name = $proto->{name}; | ||
| 674 | |||
| 675 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gnome::Less;" ); | ||
| 676 | |||
| 677 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 678 | return $widgets->{$name}; | ||
| 679 | } | ||
| 680 | |||
| 681 | sub new_GnomeMessageBox { | ||
| 682 | my ($class, $parent, $proto, $depth) = @_; | ||
| 683 | my $me = "$class->new_GnomeMessageBox"; | ||
| 684 | my $name = $proto->{name}; | ||
| 685 | # my $type = $class->use_par($proto, 'type', $LOOKUP ); | ||
| 686 | # Clear any pre-Glade-0.5.10 (unused) properties | ||
| 687 | undef $proto->{'type'}; | ||
| 688 | my $message = $class->use_par($proto, 'message', $DEFAULT, '' ); | ||
| 689 | my $message_box_type = $class->use_par($proto, 'message_box_type', $LOOKUP ); | ||
| 690 | my $auto_close = $class->use_par($proto, 'auto_close', $BOOL, 'True' ); | ||
| 691 | my $hide_on_close = $class->use_par($proto, 'hide_on_close', $BOOL, 'True' ); | ||
| 692 | |||
| 693 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gnome::MessageBox(". | ||
| 694 | "'$message', '$message_box_type');" ); | ||
| 695 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->close_hides(". | ||
| 696 | "$hide_on_close );" ); | ||
| 697 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_close(". | ||
| 698 | "$auto_close );" ); | ||
| 699 | |||
| 700 | $class->set_window_properties($parent, $name, $proto, $depth ); | ||
| 701 | return $widgets->{$name}; | ||
| 702 | } | ||
| 703 | |||
| 704 | sub new_GnomeNumberEntry { | ||
| 705 | my ($class, $parent, $proto, $depth) = @_; | ||
| 706 | my $me = "$class->new_GnomeNumberEntry"; | ||
| 707 | my $name = $proto->{name}; | ||
| 708 | my $history_id = $class->use_par($proto, 'history_id', $DEFAULT, '' ); | ||
| 709 | my $title = $class->use_par($proto, 'title', $DEFAULT, '' ); | ||
| 710 | my $max_saved = $class->use_par($proto, 'max_saved', $DEFAULT, 10 ); | ||
| 711 | |||
| 712 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gnome::NumberEntry(". | ||
| 713 | "'$history_id', _('$title'));" ); | ||
| 714 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->gnome_entry->set_max_saved(". | ||
| 715 | "$max_saved );" ); | ||
| 716 | |||
| 717 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 718 | return $widgets->{$name}; | ||
| 719 | } | ||
| 720 | |||
| 721 | sub new_GnomePixmap { | ||
| 722 | my ($class, $parent, $proto, $depth) = @_; | ||
| 723 | my $me = "$class->new_GnomePixmap"; | ||
| 724 | my $name = $proto->{name}; | ||
| 725 | my $filename = $class->use_par($proto, 'filename', $DEFAULT, '' ); | ||
| 726 | unless ($filename) { | ||
| 727 | $Glade_Perl->diag_print(2, "warn No pixmap file specified for GtkPixmap ". | ||
| 728 | "'%s' so we are using the project logo instead", $name); | ||
| 729 | $filename = $Glade_Perl->app->logo; | ||
| 730 | } | ||
| 731 | $filename = "\"\$Glade::PerlRun::pixmaps_directory/$filename\""; | ||
| 732 | my $scaled_width = $class->use_par($proto, 'scaled_width', $DEFAULT, 0); | ||
| 733 | my $scaled_height = $class->use_par($proto, 'scaled_height', $DEFAULT, 0); | ||
| 734 | if ($scaled_width) { | ||
| 735 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = ". | ||
| 736 | "new_from_file_at_size Gnome::Pixmap(". | ||
| 737 | "$filename, $scaled_width, $scaled_height". | ||
| 738 | " );" ); | ||
| 739 | } else { | ||
| 740 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = ". | ||
| 741 | "new_from_file Gnome::Pixmap(". | ||
| 742 | "$filename );" ); | ||
| 743 | } | ||
| 744 | |||
| 745 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 746 | return $widgets->{$name}; | ||
| 747 | } | ||
| 748 | |||
| 749 | sub new_GnomePixmapEntry { | ||
| 750 | my ($class, $parent, $proto, $depth) = @_; | ||
| 751 | my $me = "$class->new_GnomePixmapEntry"; | ||
| 752 | my $name = $proto->{name}; | ||
| 753 | my $history_id = $class->use_par($proto, 'history_id', $DEFAULT, '' ); | ||
| 754 | my $title = $class->use_par($proto, 'title', $DEFAULT, '' ); | ||
| 755 | my $preview = $class->use_par($proto, 'preview', $BOOL, 'True' ); | ||
| 756 | my $max_saved = $class->use_par($proto, 'max_saved', $DEFAULT, 10 ); | ||
| 757 | |||
| 758 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gnome::PixmapEntry(". | ||
| 759 | "'$history_id', _('$title'), $preview);" ); | ||
| 760 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->gnome_entry->set_max_saved(". | ||
| 761 | "$max_saved );" ); | ||
| 762 | |||
| 763 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 764 | return $widgets->{$name}; | ||
| 765 | } | ||
| 766 | |||
| 767 | sub new_GnomePaperSelector { | ||
| 768 | my ($class, $parent, $proto, $depth) = @_; | ||
| 769 | my $me = "$class->new_GnomePaperSelector"; | ||
| 770 | my $name = $proto->{name}; | ||
| 771 | |||
| 772 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gnome::PaperSelector;"); | ||
| 773 | |||
| 774 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 775 | return $widgets->{$name}; | ||
| 776 | } | ||
| 777 | |||
| 778 | sub new_GnomePropertyBox { | ||
| 779 | my ($class, $parent, $proto, $depth) = @_; | ||
| 780 | my $me = "$class->new_GnomePropertyBox"; | ||
| 781 | my $name = $proto->{name}; | ||
| 782 | |||
| 783 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gnome::PropertyBox(". | ||
| 784 | ");"); | ||
| 785 | # FIXME - Glade 0.5.3 doesn't generate these params, perhaps it should? | ||
| 786 | # $class->add_to_UI( $depth, "\$widgets->{'$name'}->close_hides(". | ||
| 787 | # "'$hide_on_close' );" ); | ||
| 788 | # $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_close(". | ||
| 789 | # "'$auto_close' );" ); | ||
| 790 | |||
| 791 | $class->set_window_properties($parent, $name, $proto, $depth ); | ||
| 792 | return $widgets->{$name}; | ||
| 793 | } | ||
| 794 | |||
| 795 | |||
| 796 | sub new_GnomeSpell { | ||
| 797 | my ($class, $parent, $proto, $depth) = @_; | ||
| 798 | my $me = "$class->new_GnomeSpell"; | ||
| 799 | my $name = $proto->{name}; | ||
| 800 | |||
| 801 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gnome::Spell;"); | ||
| 802 | |||
| 803 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 804 | return $widgets->{$name}; | ||
| 805 | } | ||
| 806 | |||
| 807 | sub new_GtkClock { | ||
| 808 | my ($class, $parent, $proto, $depth) = @_; | ||
| 809 | my $me = "$class->new_GtkClock"; | ||
| 810 | my $name = $proto->{name}; | ||
| 811 | my $type = $class->use_par($proto, 'type', $LOOKUP, 'realtime' ); | ||
| 812 | my $format = $class->use_par($proto, 'format', $DEFAULT, '%H:%M' ); | ||
| 813 | my $seconds = $class->use_par($proto, 'seconds', $DEFAULT, 0 ); | ||
| 814 | my $interval = $class->use_par($proto, 'interval', $DEFAULT, 60 ); | ||
| 815 | |||
| 816 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gtk::Clock('$type');" ); | ||
| 817 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_format(_('$format' ));" ); | ||
| 818 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_seconds($seconds );" ); | ||
| 819 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_update_interval($interval );" ); | ||
| 820 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->start();" ); | ||
| 821 | |||
| 822 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 823 | return $widgets->{$name}; | ||
| 824 | } | ||
| 825 | |||
| 826 | sub new_GtkDial { | ||
| 827 | my ($class, $parent, $proto, $depth) = @_; | ||
| 828 | my $me = "$class->new_GtkDial"; | ||
| 829 | my $name = $proto->{name}; | ||
| 830 | my $view_only = $class->use_par($proto, 'view_only', $BOOL, 'False' ); | ||
| 831 | my $update_policy= $class->use_par($proto, 'update_policy',$LOOKUP, 'continuous' ); | ||
| 832 | my $value = $class->use_par($proto, 'value', $DEFAULT, 0 ); | ||
| 833 | my $lower = $class->use_par($proto, 'lower', $DEFAULT, 0 ); | ||
| 834 | my $upper = $class->use_par($proto, 'upper', $DEFAULT, 100 ); | ||
| 835 | my $step = $class->use_par($proto, 'step', $DEFAULT, 0 ); | ||
| 836 | my $page = $class->use_par($proto, 'page', $DEFAULT, 0 ); | ||
| 837 | my $page_size = $class->use_par($proto, 'page_size', $DEFAULT, 0 ); | ||
| 838 | |||
| 839 | $class->add_to_UI( $depth, "\$work->{'$name-adj'} = new Gtk::Adjustment(". | ||
| 840 | "$value, $lower, $upper, $step, $page, $page_size );" ); | ||
| 841 | |||
| 842 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gtk::Dial(". | ||
| 843 | "\$work->{'$name-adj'});" ); | ||
| 844 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_view_only($view_only );" ); | ||
| 845 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_update_policy('$update_policy' );" ); | ||
| 846 | |||
| 847 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 848 | |||
| 849 | return $widgets->{$name}; | ||
| 850 | } | ||
| 851 | |||
| 852 | sub new_GtkPixmapMenuItem { | ||
| 853 | my ($class, $parent, $proto, $depth) = @_; | ||
| 854 | my $me = "$class->new_GtkPixmapMenuItem"; | ||
| 855 | my $name = $proto->{name}; | ||
| 856 | my ($work, $mod); | ||
| 857 | my $icon = $class->use_par($proto, 'icon', $DEFAULT, '' ); | ||
| 858 | my $stock_item = uc($class->use_par($proto, 'stock_item', $DEFAULT, '' )); | ||
| 859 | my $stock_icon = $class->use_par($proto, 'stock_icon', $LOOKUP, '' ); | ||
| 860 | my $label = $class->use_par($proto, 'label', $DEFAULT, '' ); | ||
| 861 | my $right_justify = $class->use_par($proto, 'right_justify', $BOOL, 'False' ); | ||
| 862 | # FIXME possibly make this add to a Gnome::UIInfo structure for later use by | ||
| 863 | # Gnome->create_menus() - see also toolbars | ||
| 864 | if ($stock_item) { | ||
| 865 | $stock_item =~ s/GNOMEUIINFO_MENU_(.*)_ITEM/$1/; | ||
| 866 | $label = __PACKAGE__->lookup("GNOME_MENU_$stock_item\_STRING") | ||
| 867 | unless $label; | ||
| 868 | # If we still don't have a label synthesise one from stock_item | ||
| 869 | $label = ucfirst(lc($stock_item)) unless $label; | ||
| 870 | $stock_icon = __PACKAGE__->lookup("GNOME_STOCK_PIXMAP_$stock_item"); | ||
| 871 | $stock_item =~ s/^PROPERTIES$/PROP/; # What is this shit? | ||
| 872 | $stock_item =~ s/^PREFERENCES$/PREF/; # What is this shit? | ||
| 873 | $work->{'sim'} = __PACKAGE__->lookup("GNOME_STOCK_MENU_$stock_item"); | ||
| 874 | } | ||
| 875 | |||
| 876 | if ($work->{'sim'}) { | ||
| 877 | if ($work->{'sim'}) { | ||
| 878 | my ( @ac_mods); | ||
| 879 | my $accel_flags = "['visible', 'locked']"; | ||
| 880 | $work->{'ak'} = __PACKAGE__->lookup("GNOME_KEY_NAME_$stock_item"); | ||
| 881 | $work->{'am'} = __PACKAGE__->lookup("GNOME_KEY_MOD_$stock_item"); | ||
| 882 | |||
| 883 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = ". | ||
| 884 | "Gnome::Stock->menu_item('$work->{'sim'}', _('$label'));" ); | ||
| 885 | $work->{'ak'} =~ s/GDK_//; | ||
| 886 | # $work->{'ak'} = $Gtk::Keysyms{$work->{'ak'}} if $work->{'ak'}; | ||
| 887 | |||
| 888 | my $ac_mods = $class->use_par($proto, 'ac_mods', $DEFAULT, '0' ) || | ||
| 889 | $work->{'am'}; | ||
| 890 | foreach $mod (split(/\|/, $ac_mods)) { | ||
| 891 | push @ac_mods, Glade::PerlUIGtk->lookup($mod); | ||
| 892 | } | ||
| 893 | $ac_mods = $#ac_mods >= 0 ? join("', '", @ac_mods) : ''; | ||
| 894 | |||
| 895 | if ($work->{'ak'} || $ac_mods) { | ||
| 896 | # if ($work->{'ak'} && $ac_mods) { | ||
| 897 | $class->add_to_UI( $depth, "${current_form}\{accelgroup}->add(". | ||
| 898 | "\$Gtk::Keysyms{'$work->{'ak'}'} || ". | ||
| 899 | "Gtk::Gdk->keyval_from_name('$work->{'ak'}') || ". | ||
| 900 | $Gtk::Keysyms{$work->{'ak'}}. | ||
| 901 | # ($work->{'ak'} || "''"). | ||
| 902 | ", \['$ac_mods'\], $accel_flags, ". | ||
| 903 | "\$widgets->{'$name'}, 'activate');"); | ||
| 904 | } | ||
| 905 | if (_($label) =~ /_/) { | ||
| 906 | $class->add_to_UI( $depth, | ||
| 907 | "\$widgets->{'$name-key'} = ". | ||
| 908 | "(\$widgets->{'$name'}->child->children)[1]->widget->parse_uline(_('$label') );"); | ||
| 909 | $class->add_to_UI( $depth, | ||
| 910 | "\$widgets->{'$name'}->add_accelerator(". | ||
| 911 | "'activate_item', $current_form\{'accelgroup'}, ". | ||
| 912 | "\$widgets->{'$name-key'}, 'mod1_mask', ". | ||
| 913 | "['visible', 'locked'] );"); | ||
| 914 | undef $widgets->{"$name-key"}; | ||
| 915 | } | ||
| 916 | |||
| 917 | } | ||
| 918 | |||
| 919 | } elsif ($stock_icon) { | ||
| 920 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = ". | ||
| 921 | "Gnome::Stock->menu_item('$stock_icon', _('$label'));" ); | ||
| 922 | if (_($label) =~ /_/) { | ||
| 923 | $class->add_to_UI( $depth, | ||
| 924 | "\$widgets->{'$name-key'} = ". | ||
| 925 | "(\$widgets->{'$name'}->child->children)[1]->widget->parse_uline(_('$label') );"); | ||
| 926 | $class->add_to_UI( $depth, | ||
| 927 | "\$widgets->{'$name'}->add_accelerator(". | ||
| 928 | "'activate_item', $current_form\{'accelgroup'}, ". | ||
| 929 | "\$widgets->{'$name-key'}, 'mod1_mask', ". | ||
| 930 | "['visible', 'locked'] );"); | ||
| 931 | undef $widgets->{"$name-key"}; | ||
| 932 | } | ||
| 933 | |||
| 934 | } elsif ($label) { | ||
| 935 | if ($class->my_gtk_perl_can_do('gtk_pixmap_menu_item')) { | ||
| 936 | # We can use all the PixmapMenuItem methods | ||
| 937 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = ". | ||
| 938 | "new Gtk::PixmapMenuItem;" ); | ||
| 939 | $class->add_to_UI( $depth, "\$widgets->{'$name-label'} = ". | ||
| 940 | "new Gtk::AccelLabel(_('$label'));" ); | ||
| 941 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->add(". | ||
| 942 | "\$widgets->{'$name-label'});" ); | ||
| 943 | $class->add_to_UI( $depth, "\$widgets->{'$name-label'}->". | ||
| 944 | "set_alignment(0.0, 0.5);" ); | ||
| 945 | $class->add_to_UI( $depth, "\$widgets->{'$name-label'}->show;" ); | ||
| 946 | |||
| 947 | if (_($label) =~ /_/) { | ||
| 948 | $class->add_to_UI( $depth, | ||
| 949 | "\$widgets->{'$name-key'} = ". | ||
| 950 | "\$widgets->{'$name-label'}->parse_uline(_('$label') );"); | ||
| 951 | $class->add_to_UI( $depth, | ||
| 952 | "\$widgets->{'$name'}->add_accelerator(". | ||
| 953 | "'activate', $current_form\{'accelgroup'}, ". | ||
| 954 | "\$widgets->{'$name-key'}, 'mod1_mask', ". | ||
| 955 | "['visible', 'locked'] );"); | ||
| 956 | undef $widgets->{"$name-key"}; | ||
| 957 | } | ||
| 958 | undef $widgets->{"$name-label"}; | ||
| 959 | |||
| 960 | } else { | ||
| 961 | # Use old methods (from Gtk::MenuItem) | ||
| 962 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = ". | ||
| 963 | "new Gtk::MenuItem(_('$label') );" ); | ||
| 964 | if (_($label) =~ /_/) { | ||
| 965 | $class->add_to_UI( $depth, | ||
| 966 | "\$widgets->{'$name-key'} = ". | ||
| 967 | "\$widgets->{'$name'}->child->parse_uline(_('$label') );"); | ||
| 968 | $class->add_to_UI( $depth, | ||
| 969 | "\$widgets->{'$name'}->add_accelerator(". | ||
| 970 | "'activate', $current_form\{'accelgroup'}, ". | ||
| 971 | "\$widgets->{'$name-key'}, 'mod1_mask', ". | ||
| 972 | "['visible', 'locked'] );"); | ||
| 973 | undef $widgets->{"$name-key"}; | ||
| 974 | } | ||
| 975 | } | ||
| 976 | } else { | ||
| 977 | # There is no label | ||
| 978 | $class->add_to_UI($depth, "\$widgets->{'$name'} = ". | ||
| 979 | "new Gtk::PixmapMenuItem;" ); | ||
| 980 | } | ||
| 981 | if ($right_justify) { | ||
| 982 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->right_justify;" ); | ||
| 983 | } | ||
| 984 | |||
| 985 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 986 | if ($icon) { | ||
| 987 | if ($class->my_gtk_perl_can_do('gtk_pixmap_menu_item')) { | ||
| 988 | $class->add_to_UI( $depth, | ||
| 989 | "$current_form\{'$name-pixmap'} = \$class->create_pixmap(". | ||
| 990 | "$current_window, '$icon');"); | ||
| 991 | $class->add_to_UI( $depth, "$current_form\{'$name-pixmap'}->show;"); | ||
| 992 | # FIXME find out how to show the accelerators - they are set but not shown :( | ||
| 993 | $class->add_to_UI( $depth, | ||
| 994 | "$current_form\{'$name'}->set_pixmap(". | ||
| 995 | "$current_form\{'$name-pixmap'});"); | ||
| 996 | undef $widgets->{"$name-pixmap"}; | ||
| 997 | } | ||
| 998 | } | ||
| 999 | return $widgets->{$name}; | ||
| 1000 | } | ||
| 1001 | |||
| 1002 | 1; | ||
| 1003 | |||
| 1004 | __END__ |