| 1 | package Glade::PerlUIGtk; | ||
| 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 | @VARS @METHODS | ||
| 26 | @EXPORT @EXPORT_OK %EXPORT_TAGS | ||
| 27 | $CList_column | ||
| 28 | $CTree_column | ||
| 29 | $nb | ||
| 30 | @Notebook_panes | ||
| 31 | $Notebook_pane | ||
| 32 | $Notebook_tab | ||
| 33 | $enums | ||
| 34 | ); | ||
| 35 | $PACKAGE = __PACKAGE__; | ||
| 36 | $VERSION = q(0.61); | ||
| 37 | $AUTHOR = q(Dermot Musgrove <dermot.musgrove@virgin.net>); | ||
| 38 | $DATE = q(Sun Nov 17 03:21:11 GMT 2002); | ||
| 39 | @VARS = qw( | ||
| 40 | $CList_column | ||
| 41 | $CTree_column | ||
| 42 | $nb | ||
| 43 | @Notebook_panes | ||
| 44 | $Notebook_pane | ||
| 45 | $Notebook_tab | ||
| 46 | $enums | ||
| 47 | ); | ||
| 48 | # These symbols (globals and functions) are always exported | ||
| 49 | @EXPORT = qw( ); | ||
| 50 | # Optionally exported package symbols (globals and functions) | ||
| 51 | @EXPORT_OK = ( @METHODS, @VARS ); | ||
| 52 | # Tags (groups of symbols) to export | ||
| 53 | %EXPORT_TAGS = ( | ||
| 54 | 'METHODS' => [@METHODS] , | ||
| 55 | 'VARS' => [@VARS] | ||
| 56 | ); | ||
| 57 | } | ||
| 58 | |||
| 59 | $CList_column = 0; | ||
| 60 | $CTree_column = 0; | ||
| 61 | $Notebook_pane = 0; | ||
| 62 | $Notebook_tab = 0; | ||
| 63 | |||
| 64 | sub DESTROY { | ||
| 65 | # This sub will be called on object destruction | ||
| 66 | } # End of sub DESTROY | ||
| 67 | |||
| 68 | #=============================================================================== | ||
| 69 | #=========== Gtk utilities ============ | ||
| 70 | #=============================================================================== | ||
| 71 | sub lookup { | ||
| 72 | my ($class, $self) = @_; | ||
| 73 | # Check cached enums first | ||
| 74 | my $lookup = $enums->{$self}; | ||
| 75 | unless ($lookup) { | ||
| 76 | $lookup = $self; | ||
| 77 | $lookup =~ s/^G[DT]K_//; # strip off leading GDK_ or GTK_ | ||
| 78 | foreach my $type ( | ||
| 79 | 'WINDOW', 'WIN_POS', 'JUSTIFY', | ||
| 80 | 'POLICY', 'SELECTION', 'ORIENTATION', | ||
| 81 | 'TOOLBAR_SPACE','EXTENSION_EVENTS', | ||
| 82 | 'TOOLBAR', 'TOOLBAR_CHILD','TREE_VIEW', | ||
| 83 | 'BUTTONBOX', 'UPDATE', 'PACK', | ||
| 84 | 'POS', 'ARROW', 'BUTTONBOX', | ||
| 85 | 'CURVE_TYPE', 'PROGRESS', 'VISUAL', | ||
| 86 | 'IMAGE', 'CALENDAR', 'SHADOW', | ||
| 87 | 'CLOCK', 'RELIEF', 'SIDE', | ||
| 88 | 'ANCHOR', | ||
| 89 | ) { | ||
| 90 | # Remove leading GTK type | ||
| 91 | last if $lookup =~ s/^${type}_//; # finish early | ||
| 92 | } | ||
| 93 | $lookup = lc($lookup); | ||
| 94 | # Cache this enum for later use | ||
| 95 | $enums->{$self} = $lookup; | ||
| 96 | } | ||
| 97 | return $lookup; | ||
| 98 | } | ||
| 99 | |||
| 100 | #=============================================================================== | ||
| 101 | #=========== Gtk widget constructors ============ | ||
| 102 | #=============================================================================== | ||
| 103 | sub new_GtkAccelGroup { | ||
| 104 | my ($class, $parent, $proto, $depth) = @_; | ||
| 105 | my $me = "$class->new_GtkAccelGroup"; | ||
| 106 | my $name = $proto->{name}; | ||
| 107 | |||
| 108 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gtk::AccelGroup;" ); | ||
| 109 | |||
| 110 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 111 | return $widgets->{$name}; | ||
| 112 | } | ||
| 113 | |||
| 114 | sub new_GtkAccelLabel { | ||
| 115 | my ($class, $parent, $proto, $depth) = @_; | ||
| 116 | my $me = "$class->new_GtkAccelLabel"; | ||
| 117 | my $name = $proto->{'name'}; | ||
| 118 | my $label = $class->use_par($proto,'label', $DEFAULT, '' ); | ||
| 119 | my $justify = $class->use_par($proto, 'justify',$LOOKUP, 'left' ); | ||
| 120 | my $wrap = $class->use_par($proto, 'wrap', $BOOL, 'False' ); | ||
| 121 | my $pattern = $label; | ||
| 122 | |||
| 123 | if ($label =~ /_/) { | ||
| 124 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = ". | ||
| 125 | "new Gtk::AccelLabel('');" ); | ||
| 126 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->parse_uline(". | ||
| 127 | "_('$label') );" ); | ||
| 128 | } else { | ||
| 129 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = ". | ||
| 130 | "new Gtk::AccelLabel(_('$label'));" ); | ||
| 131 | } | ||
| 132 | # FIXME How do we know which widget/signal to emit? | ||
| 133 | # Should we use set_accel_widget? Probably I guess but how? | ||
| 134 | # How should we check that this is all correct? | ||
| 135 | # Look at gnome-libs gnome-libs/libgnomeui/gnome-app-helper.c | ||
| 136 | #use Data::Dumper; print Dumper($proto); | ||
| 137 | # $class->add_to_UI( -$depth, "\$widgets->{'$name'}->set_accel_widget(". | ||
| 138 | # "$current_form\{$proto->{'signal'}{'object'}});" ); | ||
| 139 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_justify(". | ||
| 140 | "'$justify' );" ); | ||
| 141 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_line_wrap($wrap );" ); | ||
| 142 | |||
| 143 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 144 | $class->set_misc_properties($parent, $name, $proto, $depth); | ||
| 145 | return $widgets->{$name}; | ||
| 146 | } | ||
| 147 | |||
| 148 | sub new_GtkAdjustment { | ||
| 149 | my ($class, $parent, $proto, $depth) = @_; | ||
| 150 | my $me = "$class->new_GtkAdjustment"; | ||
| 151 | my $name = $proto->{'name'}; | ||
| 152 | my $hvalue = $class->use_par($proto, 'hvalue', $DEFAULT, 0 ); | ||
| 153 | my $hlower = $class->use_par($proto, 'hlower', $DEFAULT, 0 ); | ||
| 154 | my $hupper = $class->use_par($proto, 'hupper', $DEFAULT, 0 ); | ||
| 155 | my $hstep = $class->use_par($proto, 'hstep', $DEFAULT, 0 ); | ||
| 156 | my $hpage = $class->use_par($proto, 'hpage', $DEFAULT, 0 ); | ||
| 157 | my $hpage_size = $class->use_par($proto, 'hpage_size', $DEFAULT, 0 ); | ||
| 158 | |||
| 159 | $class->add_to_UI( $depth, "\$widgets->{$name-adj} = new Gtk::Adjustment(". | ||
| 160 | "$hvalue, $hlower, $hupper, ". | ||
| 161 | "$hstep, $hpage, $hpage_size );" ); | ||
| 162 | |||
| 163 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 164 | return $widgets->{$name}; | ||
| 165 | } | ||
| 166 | |||
| 167 | sub new_GtkAlignment { | ||
| 168 | my ($class, $parent, $proto, $depth) = @_; | ||
| 169 | my $me = "$class->new_GtkAlignment"; | ||
| 170 | my $name = $proto->{'name'}; | ||
| 171 | my $xalign = $class->use_par($proto, 'xalign', $DEFAULT, 0.5 ); | ||
| 172 | my $yalign = $class->use_par($proto, 'yalign', $DEFAULT, 0.5 ); | ||
| 173 | my $xscale = $class->use_par($proto, 'xscale', $DEFAULT, 0.5 ); | ||
| 174 | my $yscale = $class->use_par($proto, 'yscale', $DEFAULT, 0.5 ); | ||
| 175 | |||
| 176 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gtk::Alignment(". | ||
| 177 | "$xalign, $yalign, $xscale, $yscale );" ); | ||
| 178 | |||
| 179 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 180 | return $widgets->{$name}; | ||
| 181 | } | ||
| 182 | |||
| 183 | sub new_GtkArrow { | ||
| 184 | my ($class, $parent, $proto, $depth) = @_; | ||
| 185 | my $me = "$class->new_GtkArrow"; | ||
| 186 | my $name = $proto->{'name'}; | ||
| 187 | my $arrow_type = $class->use_par($proto, 'arrow_type', $LOOKUP, 'right' ); | ||
| 188 | my $shadow_type = $class->use_par($proto, 'shadow_type', $LOOKUP, '' ); | ||
| 189 | |||
| 190 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gtk::Arrow(". | ||
| 191 | "'$arrow_type', '$shadow_type' );" ); | ||
| 192 | |||
| 193 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 194 | $class->set_misc_properties($parent, $name, $proto, $depth); | ||
| 195 | return $widgets->{$name}; | ||
| 196 | } | ||
| 197 | |||
| 198 | sub new_GtkAspectFrame { | ||
| 199 | my ($class, $parent, $proto, $depth) = @_; | ||
| 200 | my $me = "$class->new_GtkAspectFrame"; | ||
| 201 | my $name = $proto->{'name'}; | ||
| 202 | my $label = $class->use_par($proto, 'label', $DEFAULT, '' ); | ||
| 203 | my $xalign = $class->use_par($proto, 'xalign', $DEFAULT, 0.5 ); | ||
| 204 | my $yalign = $class->use_par($proto, 'yalign', $DEFAULT, 0.5 ); | ||
| 205 | my $ratio = $class->use_par($proto, 'ratio', $DEFAULT, 1 ); | ||
| 206 | my $obey_child = $class->use_par($proto, 'obey_child', $BOOL, 'True' ); | ||
| 207 | my $label_xalign = $class->use_par($proto, 'label_xalign', $DEFAULT, 0.5 ); | ||
| 208 | my $label_yalign = $class->use_par($proto, 'label_xalign', $DEFAULT, 0.5 ); | ||
| 209 | my $shadow_type = $class->use_par($proto, 'shadow_type', $LOOKUP, 'right' ); | ||
| 210 | |||
| 211 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gtk::AspectFrame(". | ||
| 212 | "_('$label'), $xalign, $yalign, $ratio, $obey_child );" ); | ||
| 213 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_label_align(". | ||
| 214 | "$label_xalign, $label_yalign );" ); | ||
| 215 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_shadow_type(". | ||
| 216 | "'$shadow_type' );" ); | ||
| 217 | |||
| 218 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 219 | return $widgets->{$name}; | ||
| 220 | } | ||
| 221 | |||
| 222 | sub new_GtkButton { | ||
| 223 | my ($class, $parent, $proto, $depth) = @_; | ||
| 224 | my $me = "$class->new_GtkButton"; | ||
| 225 | my $name = $proto->{'name'}; | ||
| 226 | my $relief = $class->use_par($proto, 'relief', $LOOKUP, 'normal' ); | ||
| 227 | # FIXME - toolbar buttons with a removed label don't have a child_name | ||
| 228 | # but can have a sub-widget. allow this | ||
| 229 | unless ($class->new_from_child_name($parent, $name, $proto, $depth )) { | ||
| 230 | my $label = $class->use_par($proto, 'label', $DEFAULT, '' ); | ||
| 231 | my $stock_button = $class->use_par($proto, 'stock_button', $LOOKUP, ''); | ||
| 232 | if ($label) { | ||
| 233 | # FIXME This should probably be split into GnomeStock(Button) and GtkButton | ||
| 234 | if ($stock_button) { | ||
| 235 | $Glade_Perl->diag_print(2, $proto); | ||
| 236 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = ". | ||
| 237 | "new Gnome::Stock->button('$stock_button' );" ); | ||
| 238 | |||
| 239 | } else { | ||
| 240 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = ". | ||
| 241 | "new Gtk::Button(_('$label'));"); | ||
| 242 | } | ||
| 243 | |||
| 244 | } else { | ||
| 245 | if ($stock_button) { | ||
| 246 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = ". | ||
| 247 | "Gnome::Stock->button('$stock_button' );" ); | ||
| 248 | } elsif (! $proto->{'stock_pixmap'}) { | ||
| 249 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = ". | ||
| 250 | "new Gtk::Button;" ); | ||
| 251 | } | ||
| 252 | } | ||
| 253 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 254 | if (_($label) =~ /_/) { | ||
| 255 | $class->add_to_UI( $depth, | ||
| 256 | "$current_form\{'$name-key'} = ". | ||
| 257 | "$current_form\{'$name'}->child->parse_uline(_('$label') );"); | ||
| 258 | $class->add_to_UI( $depth, | ||
| 259 | "$current_form\{'$name'}->add_accelerator(". | ||
| 260 | "'clicked', $current_form\{'accelgroup'}, ". | ||
| 261 | "$current_form\{'$name-key'}, 'mod1_mask', ['visible', 'locked'] );"); | ||
| 262 | undef $widgets->{"$name-key"}; | ||
| 263 | } | ||
| 264 | } | ||
| 265 | if ($relief ne 'normal') { | ||
| 266 | $class->add_to_UI( $depth, | ||
| 267 | "$current_form\{'$name'}->set_relief('$relief');"); | ||
| 268 | } | ||
| 269 | return $widgets->{$name}; | ||
| 270 | } | ||
| 271 | |||
| 272 | sub new_GtkCalendar { | ||
| 273 | my ($class, $parent, $proto, $depth) = @_; | ||
| 274 | my $me = "$class->new_GtkCalendar"; | ||
| 275 | my $name = $proto->{'name'}; | ||
| 276 | my @options; | ||
| 277 | push @options, 'show_heading' if | ||
| 278 | $class->use_par($proto, 'show_heading', $BOOL, 'False' ); | ||
| 279 | push @options, 'show_day_names' if | ||
| 280 | $class->use_par($proto, 'show_day_names', $BOOL, 'False' ); | ||
| 281 | push @options, 'no_month_change' if | ||
| 282 | $class->use_par($proto, 'no_month_change', $BOOL, 'False' ); | ||
| 283 | push @options, 'show_week_numbers' if | ||
| 284 | $class->use_par($proto, 'show_week_numbers', $BOOL, 'False' ); | ||
| 285 | push @options, 'week_start_monday' if | ||
| 286 | $class->use_par($proto, 'week_start_monday', $BOOL, 'False' ); | ||
| 287 | my $display_options; | ||
| 288 | if (scalar @options) { | ||
| 289 | $display_options = "['".join("', '", @options)."']" | ||
| 290 | } else { | ||
| 291 | $display_options = '[]' | ||
| 292 | } | ||
| 293 | |||
| 294 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gtk::Calendar;" ); | ||
| 295 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->display_options(". | ||
| 296 | "$display_options );" ); | ||
| 297 | $class->add_to_UI( $depth, "\$work->{'$name-date'} = [localtime];"); | ||
| 298 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->select_day(". | ||
| 299 | "\$work->{'$name-date'}[3] );" ); | ||
| 300 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->select_month(". | ||
| 301 | "\$work->{'$name-date'}[4], \$work->{'$name-date'}[5] + 1900);" ); | ||
| 302 | |||
| 303 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 304 | return $widgets->{$name}; | ||
| 305 | } | ||
| 306 | |||
| 307 | sub new_GtkCheckButton { | ||
| 308 | my ($class, $parent, $proto, $depth) = @_; | ||
| 309 | my $me = "$class->new_GtkCheckButton"; | ||
| 310 | my $name = $proto->{'name'}; | ||
| 311 | my $label = $class->use_par($proto, 'label', $DEFAULT, '' ); | ||
| 312 | my $draw_indicator = $class->use_par($proto, 'draw_indicator', $BOOL, 'False' ); | ||
| 313 | my $active = $class->use_par($proto, 'active', $BOOL, 'False' ); | ||
| 314 | |||
| 315 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gtk::CheckButton(". | ||
| 316 | "_('$label'));" ); | ||
| 317 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_mode($draw_indicator );" ); | ||
| 318 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_state($active );" ); | ||
| 319 | |||
| 320 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 321 | if (_($label) =~ /_/) { | ||
| 322 | $class->add_to_UI( $depth, | ||
| 323 | "$current_form\{'$name-key'} = ". | ||
| 324 | "$current_form\{'$name'}->child->parse_uline(_('$label') );"); | ||
| 325 | $class->add_to_UI( $depth, | ||
| 326 | "$current_form\{'$name'}->add_accelerator(". | ||
| 327 | "'clicked', $current_form\{'accelgroup'}, ". | ||
| 328 | "$current_form\{'$name-key'}, 'mod1_mask', ['visible', 'locked'] );"); | ||
| 329 | undef $widgets->{"$name-key"}; | ||
| 330 | } | ||
| 331 | return $widgets->{$name}; | ||
| 332 | } | ||
| 333 | |||
| 334 | sub new_GtkCheckMenuItem { | ||
| 335 | my ($class, $parent, $proto, $depth) = @_; | ||
| 336 | my $me = "$class->new_GtkCheckMenuItem"; | ||
| 337 | my $name = $proto->{'name'}; | ||
| 338 | my $label = $class->use_par($proto, 'label', $DEFAULT, '' ); | ||
| 339 | my $active = $class->use_par($proto, 'active', $BOOL, 'False' ); | ||
| 340 | my $always_show_toggle= $class->use_par($proto, 'always_show_toggle', $BOOL, 'False' ); | ||
| 341 | |||
| 342 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = ". | ||
| 343 | "new_with_label Gtk::CheckMenuItem(_('$label'));" ); | ||
| 344 | |||
| 345 | if ($class->use_par($proto, 'right_justify', $BOOL, 'False' )) { | ||
| 346 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->right_justify;" ); | ||
| 347 | } | ||
| 348 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_state($active );" ); | ||
| 349 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_show_toggle($always_show_toggle );" ); | ||
| 350 | |||
| 351 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 352 | if (_($label) =~ /_/) { | ||
| 353 | $class->add_to_UI( $depth, | ||
| 354 | "$current_form\{'$name-key'} = ". | ||
| 355 | "$current_form\{'$name'}->child->parse_uline(_('$label') );"); | ||
| 356 | $class->add_to_UI( $depth, | ||
| 357 | "$current_form\{'$name'}->add_accelerator(". | ||
| 358 | "'activate', $current_form\{'accelgroup'}, ". | ||
| 359 | "$current_form\{'$name-key'}, 'mod1_mask', ['visible', 'locked'] );"); | ||
| 360 | undef $widgets->{"$name-key"}; | ||
| 361 | } | ||
| 362 | return $widgets->{$name}; | ||
| 363 | } | ||
| 364 | |||
| 365 | |||
| 366 | sub new_GtkCList { | ||
| 367 | my ($class, $parent, $proto, $depth) = @_; | ||
| 368 | my $me = "$class->new_GtkCList"; | ||
| 369 | my $name = $proto->{'name'}; | ||
| 370 | my $columns = $class->use_par($proto, 'columns' ); | ||
| 371 | my $selection_mode = $class->use_par($proto, 'selection_mode', $LOOKUP ); | ||
| 372 | my $shadow_type = $class->use_par($proto, 'shadow_type', $LOOKUP ); | ||
| 373 | |||
| 374 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gtk::CList(". | ||
| 375 | "$columns );" ); | ||
| 376 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_selection_mode(". | ||
| 377 | "'$selection_mode' );" ); | ||
| 378 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_border(". | ||
| 379 | "'$shadow_type' );" ); | ||
| 380 | if ($class->use_par($proto, 'show_titles', $BOOL, 'True' )) { | ||
| 381 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->column_titles_show;" ); | ||
| 382 | } | ||
| 383 | my @column_widths = split(',', $class->use_par($proto, 'column_widths' )); | ||
| 384 | $CList_column = 0; | ||
| 385 | my $i = 0; | ||
| 386 | while ($i < scalar(@column_widths)) { | ||
| 387 | $Glade_Perl->diag_print(8, | ||
| 388 | "%s- Setting column %s to width %s in %s", | ||
| 389 | $indent, $i, $column_widths[$i], $me); | ||
| 390 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_column_width(". | ||
| 391 | "$i, $column_widths[$i] );" ); | ||
| 392 | $i++; | ||
| 393 | } | ||
| 394 | |||
| 395 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 396 | return $widgets->{$name}; | ||
| 397 | } | ||
| 398 | |||
| 399 | sub new_GtkCTree { | ||
| 400 | my ($class, $parent, $proto, $depth) = @_; | ||
| 401 | my $me = "$class->new_GtkCTree"; | ||
| 402 | my $name = $proto->{'name'}; | ||
| 403 | my $columns = $class->use_par($proto, 'columns' ); | ||
| 404 | my $selection_mode = $class->use_par($proto, 'selection_mode', $LOOKUP ); | ||
| 405 | my $shadow_type = $class->use_par($proto, 'shadow_type', $LOOKUP ); | ||
| 406 | my $tree_column = $class->use_par($proto, 'tree_column', $DEFAULT, 0 ); | ||
| 407 | |||
| 408 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gtk::CTree(". | ||
| 409 | "$columns, $tree_column );" ); | ||
| 410 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_selection_mode(". | ||
| 411 | "'$selection_mode' );" ); | ||
| 412 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_border(". | ||
| 413 | "'$shadow_type' );" ); | ||
| 414 | if ($class->use_par($proto, 'show_titles', $BOOL, 'True' )) { | ||
| 415 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->column_titles_show;" ); | ||
| 416 | } | ||
| 417 | my @column_widths = split(',', $class->use_par($proto, 'column_widths' )); | ||
| 418 | $CTree_column = 0; | ||
| 419 | my $i = 0; | ||
| 420 | while ($i < scalar(@column_widths)) { | ||
| 421 | $Glade_Perl->diag_print(8, | ||
| 422 | "%s- Setting column %s to width %s in %s", | ||
| 423 | $indent, $i, $column_widths[$i], $me); | ||
| 424 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_column_width(". | ||
| 425 | "$i, $column_widths[$i] );" ); | ||
| 426 | $i++; | ||
| 427 | } | ||
| 428 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 429 | return $widgets->{$name}; | ||
| 430 | } | ||
| 431 | |||
| 432 | sub new_GtkColorSelection { | ||
| 433 | my ($class, $parent, $proto, $depth) = @_; | ||
| 434 | my $me = "$class->new_GtkColorSelection"; | ||
| 435 | my $name = $proto->{'name'}; | ||
| 436 | my $policy = $class->use_par($proto, 'policy', $LOOKUP, 'continuous'); | ||
| 437 | |||
| 438 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gtk::ColorSelection;"); | ||
| 439 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_update_policy(". | ||
| 440 | "'$policy' );" ); | ||
| 441 | |||
| 442 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 443 | return $widgets->{$name}; | ||
| 444 | } | ||
| 445 | |||
| 446 | sub new_GtkColorSelectionDialog { | ||
| 447 | my ($class, $parent, $proto, $depth) = @_; | ||
| 448 | my $me = "$class->new_GtkColorSelectionDialog"; | ||
| 449 | my $name = $proto->{'name'}; | ||
| 450 | my $title = $class->use_par($proto,'title', $DEFAULT, 'File Selection' ); | ||
| 451 | my $policy = $class->use_par($proto,'policy', $LOOKUP, 'continuous' ); | ||
| 452 | |||
| 453 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = ". | ||
| 454 | "new Gtk::ColorSelectionDialog(_('$title') );" ); | ||
| 455 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->colorsel->". | ||
| 456 | "set_update_policy( '$policy' );" ); | ||
| 457 | |||
| 458 | $class->set_window_properties($parent, $name, $proto, $depth ); | ||
| 459 | return $widgets->{$name}; | ||
| 460 | } | ||
| 461 | |||
| 462 | sub new_GtkCombo { | ||
| 463 | my ($class, $parent, $proto, $depth) = @_; | ||
| 464 | my $me = "$class->new_GtkCombo"; | ||
| 465 | my $name = $proto->{'name'}; | ||
| 466 | my $case_sensitive = $class->use_par($proto, 'case_sensitive', $BOOL, 'False' ); | ||
| 467 | my $use_arrows = $class->use_par($proto, 'use_arrows', $BOOL, 'True' ); | ||
| 468 | my $use_arrows_always= $class->use_par($proto, 'use_arrows_always', $BOOL, 'False' ); | ||
| 469 | my $items = $class->use_par($proto, 'items', $DEFAULT, '' ); | ||
| 470 | my $ok_if_empty = $class->use_par($proto, 'ok_if_empty', $BOOL, 'True' ); | ||
| 471 | my $value_in_list = $class->use_par($proto, 'value_in_list', $BOOL, 'False' ); | ||
| 472 | unless ($ok_if_empty) { | ||
| 473 | if ($items eq '') { | ||
| 474 | $Glade_Perl->diag_print (1, "warn Widget '%s' does not have any ". | ||
| 475 | "items specified in %s", $name, $me); | ||
| 476 | } | ||
| 477 | } | ||
| 478 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gtk::Combo;" ); | ||
| 479 | if ($value_in_list) { | ||
| 480 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_value_in_list(". | ||
| 481 | "$value_in_list, $ok_if_empty );" ); | ||
| 482 | } | ||
| 483 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_case_sensitive(". | ||
| 484 | "$case_sensitive );" ); | ||
| 485 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_use_arrows(". | ||
| 486 | "$use_arrows );" ); | ||
| 487 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_use_arrows_always(". | ||
| 488 | "$use_arrows_always );" ); | ||
| 489 | my @popdown_strings; | ||
| 490 | my $popdown_strings; | ||
| 491 | if (defined $items) { | ||
| 492 | @popdown_strings = split(/\n/, $items ); | ||
| 493 | $popdown_strings = "'".join("', '", @popdown_strings)."'"; | ||
| 494 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_popdown_strings(". | ||
| 495 | " $popdown_strings );" ); | ||
| 496 | } | ||
| 497 | |||
| 498 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 499 | return $widgets->{$name}; | ||
| 500 | } | ||
| 501 | |||
| 502 | sub new_GtkCurve { | ||
| 503 | my ($class, $parent, $proto, $depth) = @_; | ||
| 504 | my $me = "$class->new_GtkCurve"; | ||
| 505 | my $name = $proto->{'name'}; | ||
| 506 | my $min_x = $class->use_par($proto, 'min_x', $DEFAULT, 0 ); | ||
| 507 | my $min_y = $class->use_par($proto, 'min_y', $DEFAULT, 0 ); | ||
| 508 | my $max_x = $class->use_par($proto, 'max_x', $DEFAULT, 1 ); | ||
| 509 | my $max_y = $class->use_par($proto, 'max_y', $DEFAULT, 1 ); | ||
| 510 | my $curve_type = $class->use_par($proto, 'curve_type', $LOOKUP, 'spline' ); | ||
| 511 | |||
| 512 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gtk::Curve;" ); | ||
| 513 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_curve_type('$curve_type' );" ); | ||
| 514 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_range(". | ||
| 515 | "$min_x, $min_y, $max_x, $max_y );" ); | ||
| 516 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 517 | return $widgets->{$name}; | ||
| 518 | } | ||
| 519 | |||
| 520 | sub new_GtkDialog { | ||
| 521 | my ($class, $parent, $proto, $depth, $mainmenu) = @_; | ||
| 522 | my $me = "$class->new_GtkDialog"; | ||
| 523 | my $name = $proto->{'name'}; | ||
| 524 | my $title = $class->use_par($proto, 'title', $DEFAULT, '' ); | ||
| 525 | |||
| 526 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gtk::Dialog;" ); | ||
| 527 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_title(_('$title') );" ); | ||
| 528 | |||
| 529 | $class->set_window_properties($parent, $name, $proto, $depth ); | ||
| 530 | return $widgets->{$name}; | ||
| 531 | } | ||
| 532 | |||
| 533 | sub new_GtkDrawingArea { | ||
| 534 | my ($class, $parent, $proto, $depth) = @_; | ||
| 535 | my $me = "$class->new_GtkDrawingArea"; | ||
| 536 | my $name = $proto->{'name'}; | ||
| 537 | |||
| 538 | $class->add_to_UI($depth, "\$widgets->{'$name'} = new Gtk::DrawingArea;" ); | ||
| 539 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 540 | return $widgets->{$name}; | ||
| 541 | } | ||
| 542 | |||
| 543 | sub new_GtkEntry { | ||
| 544 | my ($class, $parent, $proto, $depth) = @_; | ||
| 545 | my $me = "$class->new_GtkEntry"; | ||
| 546 | my $name = $proto->{'name'}; | ||
| 547 | my $text = $class->use_par($proto, 'text', $DEFAULT, '' ); | ||
| 548 | my $text_max_length = $class->use_par($proto, 'text_max_length', $DEFAULT, 0 ); | ||
| 549 | my $text_visible = $class->use_par($proto, 'text_visible', $BOOL, 'True' ); | ||
| 550 | my $editable = $class->use_par($proto, 'editable', $BOOL, 'True' ); | ||
| 551 | my $max_length = $class->use_par($proto, 'text_max_length', $DEFAULT, 0 ); | ||
| 552 | |||
| 553 | unless ($class->new_from_child_name($parent, $name, $proto, $depth )) { | ||
| 554 | if ($max_length) { | ||
| 555 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = ". | ||
| 556 | "new_with_max_length Gtk::Entry($max_length );" ); | ||
| 557 | } else { | ||
| 558 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gtk::Entry;" ); | ||
| 559 | } | ||
| 560 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 561 | } | ||
| 562 | $class->add_to_UI( $depth, "$current_form\{'$name'}->set_text(_('$text') );" ); | ||
| 563 | $class->add_to_UI( $depth, "$current_form\{'$name'}->set_max_length(". | ||
| 564 | "$text_max_length );" ); | ||
| 565 | $class->add_to_UI( $depth, "$current_form\{'$name'}->set_visibility(". | ||
| 566 | "$text_visible );" ); | ||
| 567 | $class->add_to_UI( $depth, "$current_form\{'$name'}->set_editable($editable );" ); | ||
| 568 | |||
| 569 | return $widgets->{$name}; | ||
| 570 | } | ||
| 571 | |||
| 572 | sub new_GtkEventBox { | ||
| 573 | my ($class, $parent, $proto, $depth) = @_; | ||
| 574 | my $me = "$class->new_GtkEventBox"; | ||
| 575 | my $name = $proto->{'name'}; | ||
| 576 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gtk::EventBox;" ); | ||
| 577 | |||
| 578 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 579 | return $widgets->{$name}; | ||
| 580 | } | ||
| 581 | |||
| 582 | sub new_GtkFileSelection { | ||
| 583 | my ($class, $parent, $proto, $depth) = @_; | ||
| 584 | my $me = "$class->new_GtkFileSelection"; | ||
| 585 | my $name = $proto->{'name'}; | ||
| 586 | my $title = $class->use_par($proto,'title', $DEFAULT, 'File Selection' ); | ||
| 587 | my $show_file_op_buttons = $class->use_par($proto,'show_file_op_buttons', $BOOL, 'True' ); | ||
| 588 | |||
| 589 | $class->add_to_UI($depth, "\$widgets->{'$name'} = new Gtk::FileSelection(_('$title') );" ); | ||
| 590 | if ($show_file_op_buttons) { | ||
| 591 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->show_fileop_buttons;" ); | ||
| 592 | } else { | ||
| 593 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->hide_fileop_buttons;" ); | ||
| 594 | } | ||
| 595 | $class->set_window_properties($parent, $name, $proto, $depth ); | ||
| 596 | return $widgets->{$name}; | ||
| 597 | } | ||
| 598 | |||
| 599 | sub new_GtkFixed { | ||
| 600 | my ($class, $parent, $proto, $depth) = @_; | ||
| 601 | my $me = "$class->new_GtkFixed"; | ||
| 602 | my $name = $proto->{'name'}; | ||
| 603 | |||
| 604 | $class->add_to_UI($depth, "\$widgets->{'$name'} = new Gtk::Fixed;" ); | ||
| 605 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 606 | return $widgets->{$name}; | ||
| 607 | } | ||
| 608 | |||
| 609 | sub new_GtkFontSelection { | ||
| 610 | my ($class, $parent, $proto, $depth) = @_; | ||
| 611 | my $me = "$class->new_GtkFontSelection"; | ||
| 612 | my $name = $proto->{'name'}; | ||
| 613 | |||
| 614 | $class->add_to_UI($depth, "\$widgets->{'$name'} = new Gtk::FontSelection;" ); | ||
| 615 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 616 | return $widgets->{$name}; | ||
| 617 | } | ||
| 618 | |||
| 619 | sub new_GtkFontSelectionDialog { | ||
| 620 | my ($class, $parent, $proto, $depth) = @_; | ||
| 621 | my $me = "$class->new_GtkFontSelectionDialog"; | ||
| 622 | my $name = $proto->{'name'}; | ||
| 623 | my $title = $class->use_par($proto,'title', $DEFAULT, 'Font Selection' ); | ||
| 624 | |||
| 625 | $class->add_to_UI($depth, "\$widgets->{'$name'} = ". | ||
| 626 | "new Gtk::FontSelectionDialog(_('$title') );" ); | ||
| 627 | |||
| 628 | $class->set_window_properties($parent, $name, $proto, $depth ); | ||
| 629 | return $widgets->{$name}; | ||
| 630 | } | ||
| 631 | |||
| 632 | sub new_GtkFrame { | ||
| 633 | my ($class, $parent, $proto, $depth) = @_; | ||
| 634 | my $me = "$class->new_GtkFrame"; | ||
| 635 | my $name = $proto->{'name'}; | ||
| 636 | my $label = $class->use_par($proto, 'label' , $DEFAULT, ''); | ||
| 637 | my $shadow_type = $class->use_par($proto, 'shadow_type', $LOOKUP ); | ||
| 638 | my $label_xalign = $class->use_par($proto, 'label_xalign', $DEFAULT, 0 ); | ||
| 639 | my $label_yalign = $class->use_par($proto, 'label_yalign', $DEFAULT, 0 ); | ||
| 640 | |||
| 641 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = ". | ||
| 642 | "new Gtk::Frame(_('$label'));" ); | ||
| 643 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_label_align(". | ||
| 644 | "$label_xalign, $label_yalign );" ); | ||
| 645 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_shadow_type(". | ||
| 646 | "'$shadow_type' );" ); | ||
| 647 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 648 | return $widgets->{$name}; | ||
| 649 | } | ||
| 650 | |||
| 651 | sub new_GtkGammaCurve { | ||
| 652 | my ($class, $parent, $proto, $depth) = @_; | ||
| 653 | my $me = "$class->new_GtkGammaCurve"; | ||
| 654 | my $name = $proto->{'name'}; | ||
| 655 | my $min_x = $class->use_par($proto, 'min_x', $DEFAULT, 0 ); | ||
| 656 | my $min_y = $class->use_par($proto, 'min_y', $DEFAULT, 0 ); | ||
| 657 | my $max_x = $class->use_par($proto, 'max_x', $DEFAULT, 1 ); | ||
| 658 | my $max_y = $class->use_par($proto, 'max_y', $DEFAULT, 1 ); | ||
| 659 | my $curve_type = $class->use_par($proto, 'curve_type', $LOOKUP, 'spline' ); | ||
| 660 | |||
| 661 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gtk::GammaCurve;" ); | ||
| 662 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->curve->set_curve_type(". | ||
| 663 | "'$curve_type' );" ); | ||
| 664 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->curve->set_range(". | ||
| 665 | "$min_x, $min_y, $max_x, $max_y );" ); | ||
| 666 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 667 | return $widgets->{$name}; | ||
| 668 | } | ||
| 669 | |||
| 670 | |||
| 671 | sub new_GtkHandleBox { | ||
| 672 | my ($class, $parent, $proto, $depth) = @_; | ||
| 673 | my $me = "$class->new_GtkHandleBox"; | ||
| 674 | my $name = $proto->{'name'}; | ||
| 675 | my $handle_position = $class->use_par($proto, 'handle_position', $LOOKUP, 'left' ); | ||
| 676 | my $shadow_type = $class->use_par($proto, 'shadow_type', $LOOKUP , 'out'); | ||
| 677 | my $snap_edge = $class->use_par($proto, 'snap_edge', $LOOKUP, 'top' ); | ||
| 678 | |||
| 679 | $class->add_to_UI($depth, "\$widgets->{'$name'} = new Gtk::HandleBox;" ); | ||
| 680 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_handle_position(". | ||
| 681 | "'$handle_position' );" ); | ||
| 682 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_shadow_type(". | ||
| 683 | "'$shadow_type' );" ); | ||
| 684 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_snap_edge(". | ||
| 685 | "'$snap_edge' );" ); | ||
| 686 | |||
| 687 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 688 | return $widgets->{$name}; | ||
| 689 | } | ||
| 690 | |||
| 691 | sub new_GtkHBox { | ||
| 692 | my ($class, $parent, $proto, $depth) = @_; | ||
| 693 | my $me = "$class->new_GtkHBox"; | ||
| 694 | my $name = $proto->{'name'}; | ||
| 695 | my $homogeneous = $class->use_par($proto, 'homogeneous', $BOOL, 'False' ); | ||
| 696 | my $spacing = $class->use_par($proto, 'spacing' , $DEFAULT, 0 ); | ||
| 697 | |||
| 698 | unless ($class->new_from_child_name($parent, $name, $proto, $depth )) { | ||
| 699 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gtk::HBox(". | ||
| 700 | "$homogeneous, $spacing );" ); | ||
| 701 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 702 | } | ||
| 703 | |||
| 704 | return $widgets->{$name}; | ||
| 705 | } | ||
| 706 | |||
| 707 | sub new_GtkHButtonBox { | ||
| 708 | my ($class, $parent, $proto, $depth) = @_; | ||
| 709 | my $me = "$class->new_GtkHButtonBox"; | ||
| 710 | my $name = $proto->{'name'}; | ||
| 711 | my $layout_style = $class->use_par($proto, 'layout_style', $LOOKUP, 'default' ); | ||
| 712 | my $spacing = $class->use_par($proto, 'spacing', $DEFAULT, 0 ); | ||
| 713 | my $child_min_width = $class->use_par($proto, 'child_min_width', $DEFAULT, 0 ); | ||
| 714 | my $child_min_height = $class->use_par($proto, 'child_min_height', $DEFAULT, 0 ); | ||
| 715 | my $child_ipad_x = $class->use_par($proto, 'child_ipad_x', $DEFAULT, 0 ); | ||
| 716 | my $child_ipad_y = $class->use_par($proto, 'child_ipad_y', $DEFAULT, 0 ); | ||
| 717 | |||
| 718 | unless ($class->new_from_child_name($parent, $name, $proto, $depth )) { | ||
| 719 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gtk::HButtonBox;" ); | ||
| 720 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 721 | } | ||
| 722 | $class->add_to_UI( $depth, "$current_form\{'$name'}->set_layout(". | ||
| 723 | "'$layout_style' );" ); | ||
| 724 | $class->add_to_UI( $depth, "$current_form\{'$name'}->set_spacing(". | ||
| 725 | "$spacing );" ); | ||
| 726 | $class->add_to_UI( $depth, "$current_form\{'$name'}->set_child_size(". | ||
| 727 | "$child_min_width, $child_min_height );" ); | ||
| 728 | $class->add_to_UI( $depth, "$current_form\{'$name'}->set_child_ipadding(". | ||
| 729 | "$child_ipad_x, $child_ipad_y );" ); | ||
| 730 | |||
| 731 | return $widgets->{$name}; | ||
| 732 | } | ||
| 733 | |||
| 734 | sub new_GtkHPaned { | ||
| 735 | my ($class, $parent, $proto, $depth) = @_; | ||
| 736 | my $me = "$class->new_GtkHPaned"; | ||
| 737 | my $name = $proto->{'name'}; | ||
| 738 | my $handle_size = $class->use_par($proto, 'handle_size', $DEFAULT, 0 ); | ||
| 739 | my $gutter_size = $class->use_par($proto, 'gutter_size', $DEFAULT, 0 ); | ||
| 740 | my $position = $class->use_par($proto, 'position', $DEFAULT, 0); | ||
| 741 | |||
| 742 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gtk::HPaned;" ); | ||
| 743 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->handle_size(". | ||
| 744 | "$handle_size );" ); | ||
| 745 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->gutter_size(". | ||
| 746 | "$gutter_size );" ); | ||
| 747 | $position && | ||
| 748 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_position(". | ||
| 749 | "$position );" ); | ||
| 750 | |||
| 751 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 752 | return $widgets->{$name}; | ||
| 753 | } | ||
| 754 | |||
| 755 | sub new_GtkHRuler { | ||
| 756 | my ($class, $parent, $proto, $depth) = @_; | ||
| 757 | my $me = "$class->new_GtkHRuler"; | ||
| 758 | my $name = $proto->{'name'}; | ||
| 759 | my $lower = $class->use_par($proto, 'lower', $DEFAULT, 0 ); | ||
| 760 | my $upper = $class->use_par($proto, 'upper', $DEFAULT, 10 ); | ||
| 761 | my $position = $class->use_par($proto, 'position', $DEFAULT, 0 ); | ||
| 762 | my $max_size = $class->use_par($proto, 'max_size', $DEFAULT, 10 ); | ||
| 763 | my $metric = $class->use_par($proto, 'metric', $BOOL, 'False' ); | ||
| 764 | |||
| 765 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gtk::HRuler;" ); | ||
| 766 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_range(". | ||
| 767 | "$lower, $upper, $position, $max_size );" ); | ||
| 768 | if ($metric) { | ||
| 769 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_metric;" ); | ||
| 770 | } | ||
| 771 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 772 | return $widgets->{$name}; | ||
| 773 | } | ||
| 774 | |||
| 775 | sub new_GtkHScale { | ||
| 776 | my ($class, $parent, $proto, $depth) = @_; | ||
| 777 | my $me = "$class->new_GtkHScale"; | ||
| 778 | my $name = $proto->{'name'}; | ||
| 779 | my $pre = ''; | ||
| 780 | $pre = 'h' if $proto->{'hlower'}; # cater for Glade <= 0.5.1 | ||
| 781 | my $lower = $class->use_par($proto, $pre.'lower', $DEFAULT, 0 ); | ||
| 782 | my $upper = $class->use_par($proto, $pre.'upper', $DEFAULT, 100 ); | ||
| 783 | my $step = $class->use_par($proto, $pre.'step', $DEFAULT, 1 ); | ||
| 784 | my $page = $class->use_par($proto, $pre.'page', $DEFAULT, 10 ); | ||
| 785 | my $page_size = $class->use_par($proto, $pre.'page_size', $DEFAULT, 10 ); | ||
| 786 | my $value = $class->use_par($proto, $pre.'value', $DEFAULT, 0 ); | ||
| 787 | my $policy = $class->use_par($proto, 'policy', $LOOKUP, 'continuous' ); | ||
| 788 | my $draw_value = $class->use_par($proto, 'draw_value', $BOOL, 'True' ); | ||
| 789 | my $digits = $class->use_par($proto, 'digits', $DEFAULT, 1 ); | ||
| 790 | my $value_pos = $class->use_par($proto, 'value_pos', $LOOKUP, 'top' ); | ||
| 791 | |||
| 792 | $class->add_to_UI( $depth, "\$work->{'$name-adj'} = new Gtk::Adjustment(". | ||
| 793 | "$value, $lower, $upper, $step, $page, $page_size );" ); | ||
| 794 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gtk::HScale(". | ||
| 795 | "\$work->{'$name-adj'} );" ); | ||
| 796 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_draw_value(". | ||
| 797 | "$draw_value );" ); | ||
| 798 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_digits(". | ||
| 799 | "$digits );" ); | ||
| 800 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_value_pos(". | ||
| 801 | "'$value_pos' );" ); | ||
| 802 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_update_policy(". | ||
| 803 | "'$policy' );" ); | ||
| 804 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 805 | return $widgets->{$name}; | ||
| 806 | } | ||
| 807 | |||
| 808 | sub new_GtkHScrollbar { | ||
| 809 | my ($class, $parent, $proto, $depth) = @_; | ||
| 810 | my $me = "$class->new_GtkHScrollbar"; | ||
| 811 | my $name = $proto->{'name'}; | ||
| 812 | my $pre = ''; | ||
| 813 | $pre = 'h' if $proto->{'hlower'}; # Glade <= 0.5.1 | ||
| 814 | my $lower = $class->use_par($proto, $pre.'lower', $DEFAULT, 0 ); | ||
| 815 | my $upper = $class->use_par($proto, $pre.'upper', $DEFAULT, 100 ); | ||
| 816 | my $step = $class->use_par($proto, $pre.'step', $DEFAULT, 1 ); | ||
| 817 | my $page = $class->use_par($proto, $pre.'page', $DEFAULT, 10 ); | ||
| 818 | my $page_size = $class->use_par($proto, $pre.'page_size', $DEFAULT, 10 ); | ||
| 819 | my $value = $class->use_par($proto, $pre.'value', $DEFAULT, 0 ); | ||
| 820 | my $policy = $class->use_par($proto, 'policy', $LOOKUP, 'continuous' ); | ||
| 821 | |||
| 822 | $class->add_to_UI( $depth, "\$work->{'$name-adj'} = new Gtk::Adjustment(". | ||
| 823 | "$value, $lower, $upper, $step, $page, $page_size );" ); | ||
| 824 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gtk::HScrollbar(". | ||
| 825 | "\$work->{'$name-adj'} );" ); | ||
| 826 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_update_policy(". | ||
| 827 | "'$policy' );" ); | ||
| 828 | |||
| 829 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 830 | return $widgets->{$name}; | ||
| 831 | } | ||
| 832 | |||
| 833 | sub new_GtkHSeparator { | ||
| 834 | my ($class, $parent, $proto, $depth) = @_; | ||
| 835 | my $me = "$class->new_GtkHSeparatorDrawingArea"; | ||
| 836 | my $name = $proto->{'name'}; | ||
| 837 | |||
| 838 | $class->add_to_UI($depth, "\$widgets->{'$name'} = new Gtk::HSeparator;" ); | ||
| 839 | |||
| 840 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 841 | return $widgets->{$name}; | ||
| 842 | } | ||
| 843 | |||
| 844 | sub new_GtkImage { | ||
| 845 | my ($class, $parent, $proto, $depth) = @_; | ||
| 846 | my $me = "$class->new_GtkImage"; | ||
| 847 | my $name = $proto->{'name'}; | ||
| 848 | my $image_width = $class->use_par($proto, 'image_width', $DEFAULT, 100 ); | ||
| 849 | my $image_height = $class->use_par($proto, 'image_height', $DEFAULT, 100 ); | ||
| 850 | my $image_type = $class->use_par($proto, 'image_type', $LOOKUP, 'normal' ); | ||
| 851 | my $image_visual = $class->use_par($proto, 'image_visual', $LOOKUP, 'system' ); | ||
| 852 | |||
| 853 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gtk::Image(". | ||
| 854 | "Gtk::Gdk::Image->new('$image_type', ". | ||
| 855 | "Gtk::Gdk::Visual->$image_visual, $image_width, $image_height ), ". | ||
| 856 | "undef );" ); | ||
| 857 | |||
| 858 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 859 | $class->set_misc_properties($parent, $name, $proto, $depth); | ||
| 860 | return $widgets->{$name}; | ||
| 861 | } | ||
| 862 | |||
| 863 | sub new_GtkInputDialog { | ||
| 864 | my ($class, $parent, $proto, $depth) = @_; | ||
| 865 | my $me = "$class->new_GtkHInputDialog"; | ||
| 866 | my $name = $proto->{'name'}; | ||
| 867 | my $title = $class->use_par($proto, 'title', $DEFAULT, '' ); | ||
| 868 | |||
| 869 | $class->add_to_UI($depth, "\$widgets->{'$name'} = new Gtk::InputDialog;" ); | ||
| 870 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_title(_('$title') );" ); | ||
| 871 | |||
| 872 | $class->set_window_properties($parent, $name, $proto, $depth ); | ||
| 873 | return $widgets->{$name}; | ||
| 874 | } | ||
| 875 | |||
| 876 | sub new_GtkLabel { | ||
| 877 | my ($class, $parent, $proto, $depth) = @_; | ||
| 878 | my $me = "$class->new_GtkLabel"; | ||
| 879 | my $name = $proto->{'name'}; | ||
| 880 | my $label = $class->use_par($proto, 'label', $DEFAULT, '' ); | ||
| 881 | my $justify = $class->use_par($proto, 'justify', $LOOKUP, 'center' ); | ||
| 882 | my $wrap = $class->use_par($proto, 'wrap', $BOOL, 'False' ); | ||
| 883 | |||
| 884 | if ($label =~ /_/) { | ||
| 885 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gtk::Label('');" ); | ||
| 886 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->parse_uline(". | ||
| 887 | "_('$label') );" ); | ||
| 888 | } else { | ||
| 889 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gtk::Label(". | ||
| 890 | "_('$label'));" ); | ||
| 891 | } | ||
| 892 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_justify('$justify' );" ); | ||
| 893 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_line_wrap($wrap );" ); | ||
| 894 | |||
| 895 | $class->pack_widget($parent, $name, $proto, $depth); | ||
| 896 | $class->set_misc_properties($parent, $name, $proto, $depth); | ||
| 897 | return $widgets->{$name}; | ||
| 898 | } | ||
| 899 | |||
| 900 | sub new_GtkLayout { | ||
| 901 | my ($class, $parent, $proto, $depth) = @_; | ||
| 902 | my $me = "$class->new_GtkLayout"; | ||
| 903 | my $name = $proto->{'name'}; | ||
| 904 | my $hstep = $class->use_par($proto, 'hstep', $DEFAULT, 10 ); | ||
| 905 | my $vstep = $class->use_par($proto, 'vstep', $DEFAULT, 10 ); | ||
| 906 | my $area_width = $class->use_par($proto, 'area_width', $DEFAULT, 0 ); | ||
| 907 | my $area_height = $class->use_par($proto, 'area_height', $DEFAULT, 0 ); | ||
| 908 | |||
| 909 | $class->add_to_UI($depth, "\$widgets->{'$name'} = new Gtk::Layout(". | ||
| 910 | "undef, undef );" ); | ||
| 911 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_size(". | ||
| 912 | "$area_width, $area_height );" ); | ||
| 913 | $class->add_to_UI( $depth, | ||
| 914 | "\$widgets->{'$name'}->get_hadjustment->step_increment($hstep );" ); | ||
| 915 | $class->add_to_UI( $depth, | ||
| 916 | "\$widgets->{'$name'}->get_vadjustment->step_increment($vstep );" ); | ||
| 917 | |||
| 918 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 919 | return $widgets->{$name}; | ||
| 920 | } | ||
| 921 | |||
| 922 | sub new_GtkList { | ||
| 923 | my ($class, $parent, $proto, $depth) = @_; | ||
| 924 | my $me = "$class->new_GtkList"; | ||
| 925 | my $name = $proto->{'name'}; | ||
| 926 | my $selection_mode = $class->use_par($proto, 'selection_mode', $LOOKUP, 'single' ); | ||
| 927 | |||
| 928 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gtk::List;" ); | ||
| 929 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_selection_mode(". | ||
| 930 | "'$selection_mode' );" ); | ||
| 931 | |||
| 932 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 933 | return $widgets->{$name}; | ||
| 934 | } | ||
| 935 | |||
| 936 | sub new_GtkMenu { | ||
| 937 | my ($class, $parent, $proto, $depth) = @_; | ||
| 938 | my $me = "$class->new_GtkMenu"; | ||
| 939 | my $name = $proto->{'name'}; | ||
| 940 | |||
| 941 | $class->add_to_UI($depth, "\$widgets->{'$name'} = new Gtk::Menu;" ); | ||
| 942 | |||
| 943 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 944 | return $widgets->{$name}; | ||
| 945 | } | ||
| 946 | |||
| 947 | sub new_GtkMenuBar { | ||
| 948 | my ($class, $parent, $proto, $depth) = @_; | ||
| 949 | my $me = "$class->new_GtkMenuBar"; | ||
| 950 | my $name = $proto->{'name'}; | ||
| 951 | my $shadow_type = $class->use_par($proto, 'shadow_type', $LOOKUP, 'out' ); | ||
| 952 | |||
| 953 | $class->add_to_UI($depth, "\$widgets->{'$name'} = new Gtk::MenuBar;" ); | ||
| 954 | $shadow_type && | ||
| 955 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_shadow_type(". | ||
| 956 | "'$shadow_type' );" ); | ||
| 957 | |||
| 958 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 959 | return $widgets->{$name}; | ||
| 960 | } | ||
| 961 | |||
| 962 | sub new_GtkMenuFactory { | ||
| 963 | my ($class, $parent, $proto, $depth) = @_; | ||
| 964 | my $me = "$class->new_GtkMenuFactory"; | ||
| 965 | my $name = $proto->{'name'}; | ||
| 966 | |||
| 967 | $class->add_to_UI($depth, "\$widgets->{'$name'} = new Gtk::MenuFactory("." );" ); | ||
| 968 | |||
| 969 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 970 | return $widgets->{$name}; | ||
| 971 | } | ||
| 972 | |||
| 973 | sub new_GtkMenuItem { | ||
| 974 | my ($class, $parent, $proto, $depth) = @_; | ||
| 975 | my $me = "$class->new_GtkMenuItem"; | ||
| 976 | my $name = $proto->{'name'}; | ||
| 977 | my $label = $class->use_par($proto, 'label', $DEFAULT, '' ); | ||
| 978 | my $right_justify = $class->use_par($proto, 'right_justify', $BOOL, 'False' ); | ||
| 979 | |||
| 980 | if ($proto->{'stock_item'}) { | ||
| 981 | # FIXME - this is a Gnome stock menu item and should be in UIExtra | ||
| 982 | # FIXME convert this to do a proper lookup (maybe with new sub) | ||
| 983 | my $stock_item = $class->use_par($proto, 'stock_item', $DEFAULT, '' ); | ||
| 984 | $stock_item =~ s/GNOMEUIINFO_MENU_(.*)_TREE/$1/; | ||
| 985 | # FIXME this creates the string - we should look it up instead | ||
| 986 | $stock_item = ucfirst(lc($stock_item)); | ||
| 987 | # FIXME this only does uline for first character wrong, wrong, wrong | ||
| 988 | $label = "_".$stock_item; | ||
| 989 | # $stock_item = $Glade::PerlUIExtra::gnome_enums->{"GNOME_STOCK_PIXMAP_$stock_item"}; | ||
| 990 | # $class->add_to_UI( $depth, "\$widgets->{'$name'} = ". | ||
| 991 | # "Gnome::Stock->menu_item('$stock_item', '$stock_item');" ); | ||
| 992 | } | ||
| 993 | if ($label) { | ||
| 994 | $class->add_to_UI($depth, "\$widgets->{'$name'} = new Gtk::MenuItem(". | ||
| 995 | "_('$label'));" ); | ||
| 996 | } else { | ||
| 997 | $class->add_to_UI($depth, "\$widgets->{'$name'} = new Gtk::MenuItem;" ); | ||
| 998 | } | ||
| 999 | if ($right_justify) { | ||
| 1000 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->right_justify;" ); | ||
| 1001 | } | ||
| 1002 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 1003 | if (_($label) =~ /_/) { | ||
| 1004 | $class->add_to_UI( $depth, | ||
| 1005 | "$current_form\{'$name-key'} = ". | ||
| 1006 | "$current_form\{'$name'}->child->parse_uline(_('$label') );"); | ||
| 1007 | $class->add_to_UI( $depth, | ||
| 1008 | "$current_form\{'$name'}->add_accelerator(". | ||
| 1009 | "'activate_item', $current_form\{'accelgroup'}, ". | ||
| 1010 | "$current_form\{'$name-key'}, 'mod1_mask', ['visible', 'locked'] );"); | ||
| 1011 | undef $widgets->{"$name-key"}; | ||
| 1012 | } | ||
| 1013 | return $widgets->{$name}; | ||
| 1014 | } | ||
| 1015 | |||
| 1016 | sub new_GtkNotebook { | ||
| 1017 | my ($class, $parent, $proto, $depth) = @_; | ||
| 1018 | my $me = "$class->new_GtkNotebook"; | ||
| 1019 | my $name = $proto->{'name'}; | ||
| 1020 | my $tab_pos = $class->use_par($proto, 'tab_pos' , $LOOKUP, 'top' ); | ||
| 1021 | my $show_tabs = $class->use_par($proto, 'show_tabs', $BOOL, 'True' ); | ||
| 1022 | my $show_border = $class->use_par($proto, 'show_border', $BOOL, 'True' ); | ||
| 1023 | my $scrollable = $class->use_par($proto, 'scrollable', $BOOL, 'True' ); | ||
| 1024 | my $tab_hborder = $class->use_par($proto, 'tab_hborder', $DEFAULT, 0 ); | ||
| 1025 | my $tab_vborder = $class->use_par($proto, 'tab_vborder', $DEFAULT, 0 ); | ||
| 1026 | my $ignore = $class->use_par($proto, 'num_pages', $DEFAULT, 0 ); | ||
| 1027 | |||
| 1028 | unless ($class->new_from_child_name($parent, $name, $proto, $depth )) { | ||
| 1029 | $class->add_to_UI($depth, "\$widgets->{'$name'} = new Gtk::Notebook;" ); | ||
| 1030 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 1031 | } | ||
| 1032 | $class->add_to_UI( $depth, "$current_form\{'$name'}->set_tab_pos('$tab_pos' );" ); | ||
| 1033 | $class->add_to_UI( $depth, "$current_form\{'$name'}->set_show_tabs($show_tabs );" ); | ||
| 1034 | $class->add_to_UI( $depth, "$current_form\{'$name'}->set_show_border($show_border );" ); | ||
| 1035 | $class->add_to_UI( $depth, "$current_form\{'$name'}->set_scrollable($scrollable );" ); | ||
| 1036 | $class->add_to_UI( $depth, "$current_form\{'$name'}->set_tab_hborder($tab_hborder );" ); | ||
| 1037 | $class->add_to_UI( $depth, "$current_form\{'$name'}->set_tab_vborder($tab_vborder );" ); | ||
| 1038 | if ($class->use_par($proto, 'popup_enable', $BOOL, 'True' )) { | ||
| 1039 | $class->add_to_UI( $depth, "$current_form\{'$name'}->popup_enable;" ); | ||
| 1040 | } | ||
| 1041 | # 'num_pages' | ||
| 1042 | $nb->{$name} = {'panes' => [], 'pane' => 0, 'tab' => 0}; | ||
| 1043 | @Notebook_panes = (); | ||
| 1044 | $Notebook_pane = 0; | ||
| 1045 | $Notebook_tab = 0; | ||
| 1046 | |||
| 1047 | return $widgets->{$name}; | ||
| 1048 | } | ||
| 1049 | |||
| 1050 | sub new_GtkObject { | ||
| 1051 | my ($class, $parent, $proto, $depth) = @_; | ||
| 1052 | my $me = "$class->new_GtkObject"; | ||
| 1053 | my $name = $proto->{'name'}; | ||
| 1054 | |||
| 1055 | $class->add_to_UI($depth, "\$widgets->{'$name'} = new Gtk::Object;" ); | ||
| 1056 | |||
| 1057 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 1058 | return $widgets->{$name}; | ||
| 1059 | } | ||
| 1060 | |||
| 1061 | sub new_GtkOptionMenu { | ||
| 1062 | my ($class, $parent, $proto, $depth) = @_; | ||
| 1063 | my $me = "$class->new_GtkOptionMenu"; | ||
| 1064 | my $name = $proto->{'name'}; | ||
| 1065 | my $item; | ||
| 1066 | my @items; | ||
| 1067 | my $count = 0; | ||
| 1068 | my $items = $class->use_par($proto, 'items' ); | ||
| 1069 | my $initial_choice = $class->use_par($proto, 'initial_choice', $DEFAULT, 0 ); | ||
| 1070 | |||
| 1071 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gtk::OptionMenu;" ); | ||
| 1072 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 1073 | |||
| 1074 | $class->add_to_UI( $depth, "\$widgets->{'${name}_menu'} = new Gtk::Menu;" ); | ||
| 1075 | $class->pack_widget("$name", "${name}_menu", $proto, $depth ); | ||
| 1076 | if (defined $items) { | ||
| 1077 | @items = split(/\n/, $items ); | ||
| 1078 | foreach $item (@items) { | ||
| 1079 | if ($item) { | ||
| 1080 | $class->add_to_UI( $depth, "\$widgets->{'${name}_item$count'} = ". | ||
| 1081 | "new Gtk::MenuItem('$item' );" ); | ||
| 1082 | $class->pack_widget("${name}_menu", "${name}_item$count", $proto, $depth+1 ); | ||
| 1083 | if ($count == $initial_choice) { | ||
| 1084 | $class->add_to_UI( $depth, | ||
| 1085 | "${current_form}\{'${name}_item$count'}\->activate;" ); | ||
| 1086 | } | ||
| 1087 | $count++; | ||
| 1088 | } | ||
| 1089 | } | ||
| 1090 | $class->add_to_UI( $depth, | ||
| 1091 | "${current_form}\{'$name'}->set_history( $initial_choice );" ); | ||
| 1092 | } | ||
| 1093 | return $widgets->{$name}; | ||
| 1094 | } | ||
| 1095 | |||
| 1096 | sub new_GtkPacker { | ||
| 1097 | my ($class, $parent, $proto, $depth) = @_; | ||
| 1098 | my $me = "$class->new_GtkPacker"; | ||
| 1099 | my $name = $proto->{'name'}; | ||
| 1100 | my $default_border_width = $class->use_par($proto, 'default_border_width', $DEFAULT, 0 ); | ||
| 1101 | my $default_ipad_x = $class->use_par($proto, 'default_ipad_x', $DEFAULT, 0 ); | ||
| 1102 | my $default_ipad_y = $class->use_par($proto, 'default_ipad_y', $DEFAULT, 0 ); | ||
| 1103 | my $default_pad_x = $class->use_par($proto, 'default_pad_x', $DEFAULT, 0 ); | ||
| 1104 | my $default_pad_y = $class->use_par($proto, 'default_pad_y', $DEFAULT, 0 ); | ||
| 1105 | my $use_default = $class->use_par($proto, 'use_default', $BOOL, 'True' ); | ||
| 1106 | |||
| 1107 | $class->add_to_UI($depth, "\$widgets->{'$name'} = new Gtk::Packer;" ); | ||
| 1108 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_default_border_width(". | ||
| 1109 | "$default_border_width );" ); | ||
| 1110 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_default_pad(". | ||
| 1111 | "$default_pad_x, $default_pad_y );" ); | ||
| 1112 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_default_ipad(". | ||
| 1113 | "$default_ipad_x, $default_ipad_y );" ); | ||
| 1114 | |||
| 1115 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 1116 | return $widgets->{$name}; | ||
| 1117 | } | ||
| 1118 | |||
| 1119 | sub new_GtkPixmap { | ||
| 1120 | my ($class, $parent, $proto, $depth) = @_; | ||
| 1121 | my $me = "$class->new_GtkPixmap"; | ||
| 1122 | my $name = $proto->{'name'}; | ||
| 1123 | my $filename = $class->use_par($proto, 'filename', $DEFAULT, '' ); | ||
| 1124 | my $build_insensitive = $class->use_par($proto, 'build_insensitive', $BOOL, 'False' ); | ||
| 1125 | unless ($filename) { | ||
| 1126 | $Glade_Perl->diag_print(2, "warn No pixmap file specified for GtkPixmap ". | ||
| 1127 | "'%s' so we are using the project logo instead", $name); | ||
| 1128 | $filename = $Glade_Perl->app->logo; | ||
| 1129 | } | ||
| 1130 | $filename = "\"\$Glade::PerlRun::pixmaps_directory/$filename\""; | ||
| 1131 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = ". | ||
| 1132 | "\$class->create_pixmap($current_window, $filename );" ); | ||
| 1133 | unless ($Glade_Perl->source->quick_gen or defined $widgets->{$name}) { | ||
| 1134 | die sprintf(("\nerror %s failed to create pixmap from file '%s'"), | ||
| 1135 | $me, $filename), "\n"; | ||
| 1136 | } | ||
| 1137 | unless ($build_insensitive) { | ||
| 1138 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_build_insensitive(". | ||
| 1139 | "$build_insensitive );" ); | ||
| 1140 | } | ||
| 1141 | |||
| 1142 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 1143 | $class->set_misc_properties($parent, $name, $proto, $depth); | ||
| 1144 | return $widgets->{$name}; | ||
| 1145 | } | ||
| 1146 | |||
| 1147 | sub new_GtkPreview { | ||
| 1148 | my ($class, $parent, $proto, $depth) = @_; | ||
| 1149 | my $me = "$class->new_GtkPreview"; | ||
| 1150 | my $name = $proto->{'name'}; | ||
| 1151 | my $type; | ||
| 1152 | my $color = $class->use_par($proto, 'type', $DEFAULT, 'True' ); | ||
| 1153 | my $expand = $class->use_par($proto, 'expand', $BOOL, 'False' ); | ||
| 1154 | if ($color) {$type='color'} else {$type = 'grayscale'} | ||
| 1155 | |||
| 1156 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gtk::Preview(". | ||
| 1157 | "'$type' );" ); | ||
| 1158 | |||
| 1159 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_expand(". | ||
| 1160 | "$expand );" ); | ||
| 1161 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 1162 | return $widgets->{$name}; | ||
| 1163 | } | ||
| 1164 | |||
| 1165 | sub new_GtkProgressBar { | ||
| 1166 | my ($class, $parent, $proto, $depth) = @_; | ||
| 1167 | my $me = "$class->new_GtkProgressBar"; | ||
| 1168 | my $name = $proto->{'name'}; | ||
| 1169 | my $bar_style = $class->use_par($proto, 'bar_style', $LOOKUP, 'continuous' ); | ||
| 1170 | my $activity_mode = $class->use_par($proto, 'activity_mode', $BOOL, 'False' ); | ||
| 1171 | my $show_text = $class->use_par($proto, 'show_text', $BOOL, 'False' ); | ||
| 1172 | my $text_xalign = $class->use_par($proto, 'text_xalign', $DEFAULT, 0.5 ); | ||
| 1173 | my $text_yalign = $class->use_par($proto, 'text_yalign', $DEFAULT, 0.5 ); | ||
| 1174 | my $format = $class->use_par($proto, 'format', $DEFAULT, '%P %%'); | ||
| 1175 | my $value = $class->use_par($proto, 'value', $DEFAULT, 0 ); | ||
| 1176 | my $lower = $class->use_par($proto, 'lower', $DEFAULT, 0 ); | ||
| 1177 | my $upper = $class->use_par($proto, 'upper', $DEFAULT, 0 ); | ||
| 1178 | my $orientation = $class->use_par($proto, 'orientation', $LOOKUP, 'left_to_right' ); | ||
| 1179 | |||
| 1180 | $class->add_to_UI($depth, "\$widgets->{'$name'} = new Gtk::ProgressBar;" ); | ||
| 1181 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_orientation(". | ||
| 1182 | "'$orientation' );" ); | ||
| 1183 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_bar_style(". | ||
| 1184 | "'$bar_style' );" ); | ||
| 1185 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_show_text(". | ||
| 1186 | "$show_text );" ); | ||
| 1187 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_activity_mode(". | ||
| 1188 | "$activity_mode );" ); | ||
| 1189 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_text_alignment(". | ||
| 1190 | "$text_xalign, $text_yalign );" ); | ||
| 1191 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_format_string(". | ||
| 1192 | "_('$format' ));" ); | ||
| 1193 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->configure(". | ||
| 1194 | "$value, $lower, $upper );" ); | ||
| 1195 | |||
| 1196 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 1197 | return $widgets->{$name}; | ||
| 1198 | } | ||
| 1199 | |||
| 1200 | sub new_GtkRadioButton { | ||
| 1201 | my ($class, $parent, $proto, $depth) = @_; | ||
| 1202 | my $me = "$class->new_GtkRadioButton"; | ||
| 1203 | my $name = $proto->{'name'}; | ||
| 1204 | my $label = $class->use_par($proto, 'label' , $DEFAULT, '' ); | ||
| 1205 | my $draw_indicator = $class->use_par($proto, 'draw_indicator', $BOOL, 'False' ); | ||
| 1206 | my $active = $class->use_par($proto, 'active', $BOOL, 'False' ); | ||
| 1207 | |||
| 1208 | unless ($class->new_from_child_name($parent, $name, $proto, $depth )) { | ||
| 1209 | my $group = $class->use_par($proto, 'group' , $DEFAULT, '' ); | ||
| 1210 | my $rb_group = "$current_form\{'rb-group-$group'}"; | ||
| 1211 | |||
| 1212 | if ($group) { | ||
| 1213 | if (eval "defined $rb_group") { | ||
| 1214 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = ". | ||
| 1215 | "new Gtk::RadioButton(_('$label'), $rb_group );" ); | ||
| 1216 | } else { | ||
| 1217 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = ". | ||
| 1218 | "new Gtk::RadioButton(_('$label') );" ); | ||
| 1219 | $class->add_to_UI( $depth, "$rb_group = \$widgets->{'$name'};" ); | ||
| 1220 | |||
| 1221 | } | ||
| 1222 | } else { | ||
| 1223 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = ". | ||
| 1224 | "new Gtk::RadioButton(_('$label') );" ); | ||
| 1225 | } | ||
| 1226 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 1227 | if (_($label) =~ /_/) { | ||
| 1228 | $class->add_to_UI( $depth, | ||
| 1229 | "$current_form\{'$name-key'} = ". | ||
| 1230 | "$current_form\{'$name'}->child->parse_uline(_('$label') );"); | ||
| 1231 | $class->add_to_UI( $depth, | ||
| 1232 | "$current_form\{'$name'}->add_accelerator(". | ||
| 1233 | "'clicked', $current_form\{'accelgroup'}, ". | ||
| 1234 | "$current_form\{'$name-key'}, 'mod1_mask', ['visible', 'locked'] );"); | ||
| 1235 | undef $widgets->{"$name-key"}; | ||
| 1236 | } | ||
| 1237 | } | ||
| 1238 | |||
| 1239 | $class->add_to_UI( $depth, "$current_form\{'$name'}->set_mode(". | ||
| 1240 | "$draw_indicator );" ); | ||
| 1241 | $class->add_to_UI( $depth, "$current_form\{'$name'}->set_state(". | ||
| 1242 | "$active );" ); | ||
| 1243 | |||
| 1244 | return $widgets->{$name}; | ||
| 1245 | } | ||
| 1246 | |||
| 1247 | sub new_GtkRadioMenuItem { | ||
| 1248 | my ($class, $parent, $proto, $depth) = @_; | ||
| 1249 | my $me = "$class->new_GtkRadioMenuItem"; | ||
| 1250 | my $name = $proto->{'name'}; | ||
| 1251 | my $label = $class->use_par($proto, 'label', $DEFAULT, '' ); | ||
| 1252 | my $right_justify = $class->use_par($proto, 'right_justify', $BOOL, 'False' ); | ||
| 1253 | my $active = $class->use_par($proto, 'active', $BOOL, 'False' ); | ||
| 1254 | my $always_show_toggle = $class->use_par($proto, 'always_show_toggle', $BOOL, 'True' ); | ||
| 1255 | my $group = $class->use_par($proto, 'group', $DEFAULT, '' ); | ||
| 1256 | my $rmi_group = "$current_form\{'rmi-group-$group'}"; | ||
| 1257 | |||
| 1258 | if ($group) { | ||
| 1259 | if (eval "defined $rmi_group") { | ||
| 1260 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = ". | ||
| 1261 | "new Gtk::RadioMenuItem(_('$label'), $rmi_group );" ); | ||
| 1262 | } else { | ||
| 1263 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = ". | ||
| 1264 | "new Gtk::RadioMenuItem(_('$label') );" ); | ||
| 1265 | } | ||
| 1266 | $class->add_to_UI( $depth, "$rmi_group = \$widgets->{'$name'};" ); | ||
| 1267 | } else { | ||
| 1268 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = ". | ||
| 1269 | "new Gtk::RadioMenuItem(_('$label') );" ); | ||
| 1270 | } | ||
| 1271 | |||
| 1272 | if ($right_justify) { | ||
| 1273 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->right_justify;" ); | ||
| 1274 | } | ||
| 1275 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_state(". | ||
| 1276 | "$active );" ); | ||
| 1277 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_show_toggle(". | ||
| 1278 | "$always_show_toggle );" ); | ||
| 1279 | |||
| 1280 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 1281 | if (_($label) =~ /_/) { | ||
| 1282 | $class->add_to_UI( $depth, | ||
| 1283 | "$current_form\{'$name-key'} = ". | ||
| 1284 | "$current_form\{'$name'}->child->parse_uline(_('$label') );"); | ||
| 1285 | $class->add_to_UI( $depth, | ||
| 1286 | "$current_form\{'$name'}->add_accelerator(". | ||
| 1287 | "'activate', $current_form\{'accelgroup'}, ". | ||
| 1288 | "$current_form\{'$name-key'}, 'mod1_mask', ['visible', 'locked'] );"); | ||
| 1289 | undef $widgets->{"$name-key"}; | ||
| 1290 | } | ||
| 1291 | return $widgets->{$name}; | ||
| 1292 | } | ||
| 1293 | |||
| 1294 | sub new_GtkScrolledWindow { | ||
| 1295 | my ($class, $parent, $proto, $depth) = @_; | ||
| 1296 | my $me = "$class->new_GtkScrolledWindow"; | ||
| 1297 | my $name = $proto->{'name'}; | ||
| 1298 | my $hscrollbar_policy = $class->use_par($proto, 'hscrollbar_policy', $LOOKUP, 'always' ); | ||
| 1299 | my $vscrollbar_policy = $class->use_par($proto, 'vscrollbar_policy', $LOOKUP, 'always' ); | ||
| 1300 | my $border_width = $class->use_par($proto, 'border_width', $DEFAULT, 0 ); | ||
| 1301 | my $hupdate_policy = $class->use_par($proto, 'hupdate_policy', $LOOKUP, 'continuous' ); | ||
| 1302 | my $vupdate_policy = $class->use_par($proto, 'vupdate_policy', $LOOKUP, 'continuous' ); | ||
| 1303 | |||
| 1304 | $class->add_to_UI( $depth, | ||
| 1305 | "\$widgets->{'$name'} = new Gtk::ScrolledWindow( undef, undef);" ); | ||
| 1306 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_policy(". | ||
| 1307 | "'$hscrollbar_policy', '$vscrollbar_policy' );" ); | ||
| 1308 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->border_width(". | ||
| 1309 | "$border_width );" ); | ||
| 1310 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->hscrollbar->". | ||
| 1311 | "set_update_policy('$hupdate_policy' );" ); | ||
| 1312 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->vscrollbar->". | ||
| 1313 | "set_update_policy('$vupdate_policy' );" ); | ||
| 1314 | |||
| 1315 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 1316 | return $widgets->{$name}; | ||
| 1317 | } | ||
| 1318 | |||
| 1319 | sub new_GtkSpinButton { | ||
| 1320 | my ($class, $parent, $proto, $depth) = @_; | ||
| 1321 | my $me = "$class->new_GtkSpinButton"; | ||
| 1322 | my $name = $proto->{'name'}; | ||
| 1323 | my $pre = ''; | ||
| 1324 | $pre = 'h' if $proto->{'hlower'}; # cater for Glade <= 0.5.1 | ||
| 1325 | my $lower = $class->use_par($proto, $pre.'lower', $DEFAULT, 0 ); | ||
| 1326 | my $upper = $class->use_par($proto, $pre.'upper', $DEFAULT, 100 ); | ||
| 1327 | my $step = $class->use_par($proto, $pre.'step', $DEFAULT, 1 ); | ||
| 1328 | my $page = $class->use_par($proto, $pre.'page', $DEFAULT, 10 ); | ||
| 1329 | my $page_size = $class->use_par($proto, $pre.'page_size', $DEFAULT, 10 ); | ||
| 1330 | my $value = $class->use_par($proto, $pre.'value', $DEFAULT, 0 ); | ||
| 1331 | my $climb_rate = $class->use_par($proto, 'climb_rate', $DEFAULT, 1 ); | ||
| 1332 | my $digits = $class->use_par($proto, 'digits', $DEFAULT, 1 ); | ||
| 1333 | my $numeric = $class->use_par($proto, 'numeric', $BOOL, 'False' ); | ||
| 1334 | my $wrap = $class->use_par($proto, 'wrap', $BOOL, 'False' ); | ||
| 1335 | my $update_policy = $class->use_par($proto, 'update_policy', $LOOKUP, 'continuous' ); | ||
| 1336 | my $snap = $class->use_par($proto, 'snap', $BOOL, 'False' ); | ||
| 1337 | |||
| 1338 | $class->add_to_UI( $depth, "\$work->{'$name-adj'} = new Gtk::Adjustment(". | ||
| 1339 | "$value, $lower, $upper, $step, $page, $page_size );" ); | ||
| 1340 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gtk::SpinButton(". | ||
| 1341 | "\$work->{'$name-adj'}, $climb_rate, $digits );" ); | ||
| 1342 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_update_policy(". | ||
| 1343 | "'$update_policy' );" ); | ||
| 1344 | if ($numeric) { | ||
| 1345 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_numeric(1);" ); | ||
| 1346 | } | ||
| 1347 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_wrap($wrap);" ); | ||
| 1348 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_snap_to_ticks(". | ||
| 1349 | "$snap );" ); | ||
| 1350 | |||
| 1351 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 1352 | return $widgets->{$name}; | ||
| 1353 | } | ||
| 1354 | |||
| 1355 | sub new_GtkStatusbar { | ||
| 1356 | my ($class, $parent, $proto, $depth) = @_; | ||
| 1357 | my $me = "$class->new_GtkStatusbar"; | ||
| 1358 | my $name = $proto->{'name'}; | ||
| 1359 | |||
| 1360 | $class->add_to_UI($depth, "\$widgets->{'$name'} = new Gtk::Statusbar;" ); | ||
| 1361 | |||
| 1362 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 1363 | return $widgets->{$name}; | ||
| 1364 | } | ||
| 1365 | |||
| 1366 | sub new_GtkStyle { | ||
| 1367 | my ($class, $parent, $proto, $depth) = @_; | ||
| 1368 | my $me = "$class->new_GtkStyle"; | ||
| 1369 | my $name = $proto->{'name'}; | ||
| 1370 | |||
| 1371 | $class->add_to_UI($depth, "\$widgets->{'$name'} = new Gtk::Style;" ); | ||
| 1372 | |||
| 1373 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 1374 | return $widgets->{$name}; | ||
| 1375 | } | ||
| 1376 | |||
| 1377 | sub new_GtkTable { | ||
| 1378 | my ($class, $parent, $proto, $depth) = @_; | ||
| 1379 | my $me = "$class->new_GtkTable"; | ||
| 1380 | my $name = $proto->{'name'}; | ||
| 1381 | my $rows = $class->use_par($proto, 'rows' ); | ||
| 1382 | my $columns = $class->use_par($proto, 'columns' ); | ||
| 1383 | my $homogeneous = $class->use_par($proto, 'homogeneous', $BOOL, 'False' ); | ||
| 1384 | my $row_spacing = $class->use_par($proto, 'row_spacing', $DEFAULT, 0 ); | ||
| 1385 | my $column_spacing = $class->use_par($proto, 'column_spacing', $DEFAULT, 0 ); | ||
| 1386 | |||
| 1387 | unless ($class->new_from_child_name($parent, $name, $proto, $depth )) { | ||
| 1388 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gtk::Table(". | ||
| 1389 | "$rows, $columns, $homogeneous );" ); | ||
| 1390 | } | ||
| 1391 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_row_spacings(". | ||
| 1392 | "$row_spacing );" ); | ||
| 1393 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_col_spacings(". | ||
| 1394 | "$column_spacing );" ); | ||
| 1395 | |||
| 1396 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 1397 | return $widgets->{$name}; | ||
| 1398 | } | ||
| 1399 | |||
| 1400 | sub new_GtkText { | ||
| 1401 | my ($class, $parent, $proto, $depth) = @_; | ||
| 1402 | my $me = "$class->new_GtkText"; | ||
| 1403 | my $name = $proto->{'name'}; | ||
| 1404 | my $text = $class->use_par($proto, 'text' , $DEFAULT, '' ); | ||
| 1405 | my $editable = $class->use_par($proto, 'editable', $BOOL, 'False' ); | ||
| 1406 | |||
| 1407 | $text =~ s/\n/\\n/g; | ||
| 1408 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gtk::Text(". | ||
| 1409 | " undef, undef );" ); | ||
| 1410 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_editable(". | ||
| 1411 | "$editable );" ); | ||
| 1412 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->insert(". | ||
| 1413 | "undef, \$widgets->{'$name'}->style->text('normal'), undef, _(\"$text\"));" ); | ||
| 1414 | |||
| 1415 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 1416 | return $widgets->{$name}; | ||
| 1417 | } | ||
| 1418 | |||
| 1419 | sub new_GtkTipsQuery { | ||
| 1420 | my ($class, $parent, $proto, $depth) = @_; | ||
| 1421 | my $me = "$class->new_GtkTipsQuery"; | ||
| 1422 | my $name = $proto->{'name'}; | ||
| 1423 | |||
| 1424 | $class->add_to_UI($depth, "\$widgets->{'$name'} = new Gtk::TipsQuery;" ); | ||
| 1425 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 1426 | $class->set_misc_properties($parent, $name, $proto, $depth); | ||
| 1427 | return $widgets->{$name}; | ||
| 1428 | } | ||
| 1429 | |||
| 1430 | |||
| 1431 | sub new_GtkToggleButton { | ||
| 1432 | my ($class, $parent, $proto, $depth) = @_; | ||
| 1433 | my $me = "$class->new_GtkToggleButton"; | ||
| 1434 | my $name = $proto->{'name'}; | ||
| 1435 | my $active = $class->use_par($proto, 'active', $BOOL, 'False' ); | ||
| 1436 | my $relief = $class->use_par($proto, 'relief', $LOOKUP, 'normal' ); | ||
| 1437 | |||
| 1438 | unless ($class->new_from_child_name($parent, $name, $proto, $depth )) { | ||
| 1439 | my $label = $class->use_par($proto, 'label' , $DEFAULT, '' ); | ||
| 1440 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gtk::ToggleButton(". | ||
| 1441 | "_('$label') );" ); | ||
| 1442 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 1443 | if (_($label) =~ /_/) { | ||
| 1444 | $class->add_to_UI( $depth, | ||
| 1445 | "$current_form\{'$name-key'} = ". | ||
| 1446 | "$current_form\{'$name'}->child->parse_uline(_('$label') );"); | ||
| 1447 | $class->add_to_UI( $depth, | ||
| 1448 | "$current_form\{'$name'}->add_accelerator(". | ||
| 1449 | "'clicked', $current_form\{'accelgroup'}, ". | ||
| 1450 | "$current_form\{'$name-key'}, 'mod1_mask', ['visible', 'locked'] );"); | ||
| 1451 | undef $widgets->{"$name-key"}; | ||
| 1452 | } | ||
| 1453 | } | ||
| 1454 | $class->add_to_UI( $depth, "$current_form\{'$name'}->active(". | ||
| 1455 | "$active );" ); | ||
| 1456 | if ($relief ne 'normal') { | ||
| 1457 | $class->add_to_UI( $depth, | ||
| 1458 | "$current_form\{'$name'}->set_relief('$relief');"); | ||
| 1459 | } | ||
| 1460 | |||
| 1461 | return $widgets->{$name}; | ||
| 1462 | } | ||
| 1463 | |||
| 1464 | sub new_GtkToolbar { | ||
| 1465 | my ($class, $parent, $proto, $depth) = @_; | ||
| 1466 | my $me = "$class->new_GtkTabbar"; | ||
| 1467 | my $name = $proto->{'name'}; | ||
| 1468 | my $orientation = $class->use_par($proto, 'orientation', $LOOKUP, 'horizontal' ); | ||
| 1469 | my $type = $class->use_par($proto, 'type' , $LOOKUP, 'icons' ); | ||
| 1470 | my $space_style = $class->use_par($proto, 'space_style', $LOOKUP, 'empty' ); | ||
| 1471 | my $space_size = $class->use_par($proto, 'space_size', $DEFAULT, 5 ); | ||
| 1472 | my $tooltips = $class->use_par($proto, 'tooltips', $BOOL, 'True' ); | ||
| 1473 | my $relief = $class->use_par($proto, 'relief', $LOOKUP, 'normal' ); | ||
| 1474 | |||
| 1475 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gtk::Toolbar(". | ||
| 1476 | "'$orientation', '$type' );" ); | ||
| 1477 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_space_size(". | ||
| 1478 | "$space_size );" ); | ||
| 1479 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_space_style(". | ||
| 1480 | "'$space_style' );" ); | ||
| 1481 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_button_relief(". | ||
| 1482 | "'$relief' );" ); | ||
| 1483 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_tooltips(". | ||
| 1484 | "$tooltips );" ); | ||
| 1485 | |||
| 1486 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 1487 | # Store the tooltips parameter for append_element to check later | ||
| 1488 | eval "$current_form\{'$name'}{'tooltips'} = $tooltips"; | ||
| 1489 | return $widgets->{$name}; | ||
| 1490 | } | ||
| 1491 | |||
| 1492 | sub new_GtkTree { | ||
| 1493 | my ($class, $parent, $proto, $depth) = @_; | ||
| 1494 | my $me = "$class->new_GtkTree"; | ||
| 1495 | my $name = $proto->{'name'}; | ||
| 1496 | my $selection_mode = $class->use_par($proto, 'selection_mode', $LOOKUP, 'single' ); | ||
| 1497 | my $view_mode = $class->use_par($proto, 'view_mode', $LOOKUP, 'line' ); | ||
| 1498 | my $view_line = $class->use_par($proto, 'view_line', $BOOL, 'False' ); | ||
| 1499 | |||
| 1500 | $class->add_to_UI($depth, "\$widgets->{'$name'} = new Gtk::Tree;" ); | ||
| 1501 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_selection_mode(". | ||
| 1502 | "'$selection_mode' );" ); | ||
| 1503 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_view_mode(". | ||
| 1504 | "'$view_mode' );" ); | ||
| 1505 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_view_lines(". | ||
| 1506 | "$view_line );" ); | ||
| 1507 | |||
| 1508 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 1509 | return $widgets->{$name}; | ||
| 1510 | } | ||
| 1511 | |||
| 1512 | sub new_GtkVBox { | ||
| 1513 | my ($class, $parent, $proto, $depth) = @_; | ||
| 1514 | my $me = "$class->new_GtkVBox"; | ||
| 1515 | my $name = $proto->{'name'}; | ||
| 1516 | my $homogeneous = $class->use_par($proto, 'homogeneous', $BOOL, 'False' ); | ||
| 1517 | my $spacing = $class->use_par($proto, 'spacing' , $DEFAULT, 0 ); | ||
| 1518 | |||
| 1519 | unless ($class->new_from_child_name($parent, $name, $proto, $depth )) { | ||
| 1520 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gtk::VBox(". | ||
| 1521 | "$homogeneous, $spacing );" ); | ||
| 1522 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 1523 | } | ||
| 1524 | |||
| 1525 | return $widgets->{$name}; | ||
| 1526 | } | ||
| 1527 | |||
| 1528 | sub new_GtkVButtonBox { | ||
| 1529 | my ($class, $parent, $proto, $depth) = @_; | ||
| 1530 | my $me = "$class->new_GtkVButtonBox"; | ||
| 1531 | my $name = $proto->{'name'}; | ||
| 1532 | my $layout_style = $class->use_par($proto, 'layout_style', $LOOKUP, 'default' ); | ||
| 1533 | my $spacing = $class->use_par($proto, 'spacing', $DEFAULT, 0 ); | ||
| 1534 | my $child_min_width = $class->use_par($proto, 'child_min_width', $DEFAULT, 0 ); | ||
| 1535 | my $child_min_height = $class->use_par($proto, 'child_min_height', $DEFAULT, 0 ); | ||
| 1536 | my $child_ipad_x = $class->use_par($proto, 'child_ipad_x', $DEFAULT, 0 ); | ||
| 1537 | my $child_ipad_y = $class->use_par($proto, 'child_ipad_y', $DEFAULT, 0 ); | ||
| 1538 | |||
| 1539 | unless ($class->new_from_child_name($parent, $name, $proto, $depth )) { | ||
| 1540 | $class->add_to_UI($depth, "\$widgets->{'$name'} = new Gtk::VButtonBox;" ); | ||
| 1541 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 1542 | } | ||
| 1543 | $class->add_to_UI( $depth, "$current_form\{'$name'}->set_layout(". | ||
| 1544 | "'$layout_style' );" ); | ||
| 1545 | $class->add_to_UI( $depth, "$current_form\{'$name'}->set_spacing(". | ||
| 1546 | "$spacing );" ); | ||
| 1547 | $class->add_to_UI( $depth, "$current_form\{'$name'}->set_child_size(". | ||
| 1548 | "$child_min_width, $child_min_height );" ); | ||
| 1549 | $class->add_to_UI( $depth, "$current_form\{'$name'}->set_child_ipadding(". | ||
| 1550 | "$child_ipad_x, $child_ipad_y );" ); | ||
| 1551 | |||
| 1552 | return $widgets->{$name}; | ||
| 1553 | } | ||
| 1554 | |||
| 1555 | sub new_GtkViewport { | ||
| 1556 | my ($class, $parent, $proto, $depth) = @_; | ||
| 1557 | my $me = "$class->new_GtkViewport"; | ||
| 1558 | my $name = $proto->{'name'}; | ||
| 1559 | my $shadow_type = $class->use_par($proto, 'shadow_type', $LOOKUP, '' ); | ||
| 1560 | |||
| 1561 | $class->add_to_UI( $depth, | ||
| 1562 | "\$widgets->{'$name'} = new Gtk::Viewport(". | ||
| 1563 | "new Gtk::Adjustment( 0.0, 0.0, 101.0, 0.1, 1.0, 1.0), ". | ||
| 1564 | "new Gtk::Adjustment( 0.0, 0.0, 101.0, 0.1, 1.0, 1.0) );" ); | ||
| 1565 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_shadow_type(". | ||
| 1566 | "'$shadow_type' );" ); | ||
| 1567 | |||
| 1568 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 1569 | return $widgets->{$name}; | ||
| 1570 | } | ||
| 1571 | |||
| 1572 | |||
| 1573 | sub new_GtkVPaned { | ||
| 1574 | my ($class, $parent, $proto, $depth) = @_; | ||
| 1575 | my $me = "$class->new_GtkVPaned"; | ||
| 1576 | my $name = $proto->{'name'}; | ||
| 1577 | my $handle_size = $class->use_par($proto, 'handle_size', $DEFAULT, 0 ); | ||
| 1578 | my $gutter_size = $class->use_par($proto, 'gutter_size', $DEFAULT, 0 ); | ||
| 1579 | my $position = $class->use_par($proto, 'position', $DEFAULT, 0); | ||
| 1580 | |||
| 1581 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gtk::VPaned;" ); | ||
| 1582 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->handle_size(". | ||
| 1583 | "$handle_size );" ); | ||
| 1584 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->gutter_size(". | ||
| 1585 | "$gutter_size );" ); | ||
| 1586 | $position && | ||
| 1587 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_position(". | ||
| 1588 | "$position );" ); | ||
| 1589 | |||
| 1590 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 1591 | return $widgets->{$name}; | ||
| 1592 | } | ||
| 1593 | |||
| 1594 | sub new_GtkVRuler { | ||
| 1595 | my ($class, $parent, $proto, $depth) = @_; | ||
| 1596 | my $me = "$class->new_GtkVRuler"; | ||
| 1597 | my $name = $proto->{'name'}; | ||
| 1598 | my $lower = $class->use_par($proto, 'lower', $DEFAULT, 0 ); | ||
| 1599 | my $upper = $class->use_par($proto, 'upper', $DEFAULT, 0 ); | ||
| 1600 | my $position = $class->use_par($proto, 'position', $DEFAULT, 0 ); | ||
| 1601 | my $max_size = $class->use_par($proto, 'max_size', $DEFAULT, 0 ); | ||
| 1602 | my $metric = $class->use_par($proto, 'metric', $BOOL, 'False' ); | ||
| 1603 | |||
| 1604 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gtk::VRuler;" ); | ||
| 1605 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_range(". | ||
| 1606 | "$lower, $upper, $position, $max_size );" ); | ||
| 1607 | if ($metric) { | ||
| 1608 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_metric;" ); | ||
| 1609 | } | ||
| 1610 | |||
| 1611 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 1612 | return $widgets->{$name}; | ||
| 1613 | } | ||
| 1614 | |||
| 1615 | sub new_GtkVScale { | ||
| 1616 | my ($class, $parent, $proto, $depth) = @_; | ||
| 1617 | my $me = "$class->new_GtkVScale"; | ||
| 1618 | my $name = $proto->{'name'}; | ||
| 1619 | my $pre = ''; | ||
| 1620 | $pre = 'v' if $proto->{'vlower'}; # cater for Glade <= 0.5.1 | ||
| 1621 | my $lower = $class->use_par($proto, $pre.'lower', $DEFAULT, 0 ); | ||
| 1622 | my $upper = $class->use_par($proto, $pre.'upper', $DEFAULT, 100 ); | ||
| 1623 | my $step = $class->use_par($proto, $pre.'step', $DEFAULT, 1 ); | ||
| 1624 | my $page = $class->use_par($proto, $pre.'page', $DEFAULT, 10 ); | ||
| 1625 | my $page_size = $class->use_par($proto, $pre.'page_size', $DEFAULT, 10 ); | ||
| 1626 | my $value = $class->use_par($proto, $pre.'value', $DEFAULT, 0 ); | ||
| 1627 | my $draw_value = $class->use_par($proto, 'draw_value', $BOOL, 'True' ); | ||
| 1628 | my $digits = $class->use_par($proto, 'digits', $DEFAULT, 1 ); | ||
| 1629 | my $numeric = $class->use_par($proto, 'numeric', $BOOL, 'False' ); | ||
| 1630 | my $value_pos = $class->use_par($proto, 'value_pos', $LOOKUP, 'top' ); | ||
| 1631 | my $policy = $class->use_par($proto, 'policy', $LOOKUP, 'continuous' ); | ||
| 1632 | |||
| 1633 | $class->add_to_UI( $depth, "\$work->{'$name-adj'} = new Gtk::Adjustment(". | ||
| 1634 | "$value, $lower, $upper, $step, $page, $page_size );" ); | ||
| 1635 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gtk::VScale(". | ||
| 1636 | "\$work->{'$name-adj'} );" ); | ||
| 1637 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_draw_value(". | ||
| 1638 | "$draw_value );" ); | ||
| 1639 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_digits(". | ||
| 1640 | "$digits );" ); | ||
| 1641 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_value_pos(". | ||
| 1642 | "'$value_pos' );" ); | ||
| 1643 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_update_policy(". | ||
| 1644 | "'$policy' );" ); | ||
| 1645 | |||
| 1646 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 1647 | return $widgets->{$name}; | ||
| 1648 | } | ||
| 1649 | |||
| 1650 | sub new_GtkVScrollbar { | ||
| 1651 | my ($class, $parent, $proto, $depth) = @_; | ||
| 1652 | my $me = "$class->new_GtkVScrollbar"; | ||
| 1653 | my $name = $proto->{'name'}; | ||
| 1654 | my $pre = ''; | ||
| 1655 | $pre = 'v' if $proto->{'vlower'}; # cater for Glade <= 0.5.1 | ||
| 1656 | my $lower = $class->use_par($proto, $pre.'lower', $DEFAULT, 0 ); | ||
| 1657 | my $upper = $class->use_par($proto, $pre.'upper', $DEFAULT, 100 ); | ||
| 1658 | my $step = $class->use_par($proto, $pre.'step', $DEFAULT, 1 ); | ||
| 1659 | my $page = $class->use_par($proto, $pre.'page', $DEFAULT, 10 ); | ||
| 1660 | my $page_size = $class->use_par($proto, $pre.'page_size', $DEFAULT, 10 ); | ||
| 1661 | my $value = $class->use_par($proto, $pre.'value', $DEFAULT, 0 ); | ||
| 1662 | my $policy = $class->use_par($proto, 'policy', $LOOKUP, 'continuous' ); | ||
| 1663 | |||
| 1664 | $class->add_to_UI( $depth, "\$work->{'$name-adj'} = new Gtk::Adjustment(". | ||
| 1665 | "$value, $lower, $upper, $step, $page, $page_size );" ); | ||
| 1666 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gtk::VScrollbar(". | ||
| 1667 | "\$work->{'$name-adj'} );" ); | ||
| 1668 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_update_policy(". | ||
| 1669 | "'$policy' );" ); | ||
| 1670 | |||
| 1671 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 1672 | return $widgets->{$name}; | ||
| 1673 | } | ||
| 1674 | |||
| 1675 | sub new_GtkVSeparator { | ||
| 1676 | my ($class, $parent, $proto, $depth) = @_; | ||
| 1677 | my $me = "$class->new_VSeparator"; | ||
| 1678 | my $name = $proto->{'name'}; | ||
| 1679 | |||
| 1680 | $class->add_to_UI($depth, "\$widgets->{'$name'} = new Gtk::VSeparator;" ); | ||
| 1681 | |||
| 1682 | $class->pack_widget($parent, $name, $proto, $depth ); | ||
| 1683 | return $widgets->{$name}; | ||
| 1684 | } | ||
| 1685 | |||
| 1686 | sub new_GtkWindow { | ||
| 1687 | my ($class, $parent, $proto, $depth, $mainmenu) = @_; | ||
| 1688 | my $me = "$class->new_GtkWindow"; | ||
| 1689 | my $name = $proto->{'name'}; | ||
| 1690 | my $title = $class->use_par($proto, 'title', $DEFAULT, '' ); | ||
| 1691 | |||
| 1692 | $class->add_to_UI( $depth, "\$widgets->{'$name'} = new Gtk::Window;" ); | ||
| 1693 | $class->add_to_UI( $depth, "\$widgets->{'$name'}->set_title(_('$title') );" ); | ||
| 1694 | |||
| 1695 | $class->set_window_properties($parent, $name, $proto, $depth ); | ||
| 1696 | return $widgets->{$name}; | ||
| 1697 | } | ||
| 1698 | |||
| 1699 | 1; | ||
| 1700 | |||
| 1701 | __END__ |