Gtk.pm untested

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