summaryrefslogtreecommitdiffstats
path: root/perl-install
diff options
context:
space:
mode:
authordamien <damien@mandriva.com>2002-03-22 14:37:19 +0000
committerdamien <damien@mandriva.com>2002-03-22 14:37:19 +0000
commitd42128dda9ce3f6148ab7b08458161584db65af8 (patch)
tree85f3fcb70f9d113e6665038bc07ba1825dd566dd /perl-install
parente20a4f9ab395d3d354364f859f27a634bacc21f5 (diff)
downloaddrakx-d42128dda9ce3f6148ab7b08458161584db65af8.tar
drakx-d42128dda9ce3f6148ab7b08458161584db65af8.tar.gz
drakx-d42128dda9ce3f6148ab7b08458161584db65af8.tar.bz2
drakx-d42128dda9ce3f6148ab7b08458161584db65af8.tar.xz
drakx-d42128dda9ce3f6148ab7b08458161584db65af8.zip
cleaned gtkpowerpack
Diffstat (limited to 'perl-install')
-rw-r--r--perl-install/my_gtk.pm56
1 files changed, 25 insertions, 31 deletions
diff --git a/perl-install/my_gtk.pm b/perl-install/my_gtk.pm
index 0f43de49e..888d7b8dd 100644
--- a/perl-install/my_gtk.pm
+++ b/perl-install/my_gtk.pm
@@ -181,14 +181,12 @@ sub gtkpowerpack {
#- gtkpowerpack( {expand => 1, fill => 0}, $box...) : the attributes are picked from a specified hash ref
#- gtkpowerpack(1,0,1, $box, ...) : the attributes are picked from the non-ref list, in the order (expand, fill, padding, pack_end).
my $RefDefaultAttrs;
- if (ref($_[0]) eq 'HASH') {
- $RefDefaultAttrs = shift;
- } elsif (!ref($_[0])) {
- my %tmp;
- foreach my $i ("expand", "fill", "padding", "pack_end") {
- !ref($_[0]) ? $tmp{$i} = shift : last
+ if (ref($_[0]) eq 'HASH') { $RefDefaultAttrs = shift }
+ elsif (!ref($_[0])) {
+ $RefDefaultAttrs = {};
+ foreach ("expand", "fill", "padding", "pack_end") {
+ !ref($_[0]) ? $RefDefaultAttrs->{$_} = shift : last
}
- $RefDefaultAttrs = \%tmp;
}
my $box = shift;
@@ -196,36 +194,32 @@ sub gtkpowerpack {
#- Get attributes (if specified). 4 syntaxes allowed (default values are undef ie. false...) :
#- gtkpowerpack({defaultattrs}, $box, $widget1, $widget2, ...) : the attrs are picked from the default ones (if they exist)
#- gtkpowerpack($box, {fill=>1, expand=>0, ...}, $widget1, ...) : the attributes are picked from a specified hash ref
- #- gtkpowerpack($box, [1,0,1], $widget1, ...) : the attributes are picked from the array ref, in the order (expand, fill, padding, pack_end).
- #- gtkpowerpack({attr=>'arg'}, $box, 1, $widget1, 0, $widget2, etc...) : the 'arg' value will tell gtkpowerpack to always read the attr value directly in the arg list (avoiding confusion between value 0 and Gtk::Label("0"). That can simplify some writings but this arg(s) MUST then be present...
+ #- gtkpowerpack($box, [1,0,1], $widget1, ...) : the attributes are picked from the array ref : (expand, fill, padding, pack_end).
+ #- gtkpowerpack({attr=>'arg'}, $box, 1, $widget1, 0, $widget2, etc...) : the 'arg' value will tell gtkpowerpack to always read the
+ #- attr value directly in the arg list (avoiding confusion between value 0 and Gtk::Label("0"). That can simplify some writings but
+ #- this arg(s) MUST then be present...
my %attr;
- my $RefAttrs = shift if (ref($_[0]) eq 'HASH' or ref($_[0]) eq 'ARRAY');
- foreach my $i ("expand", "fill", "padding", "pack_end") {
- if (defined($RefDefaultAttrs->{$i}) and $RefDefaultAttrs->{$i} eq 'arg') {
- if (!ref ($_[0])) {
- $attr{$i} = shift;
- shift @$RefAttrs if (ref($RefAttrs) eq 'ARRAY')
- } else {
- die "error in packing definition\n"
- }
- } elsif (ref($RefAttrs) eq 'HASH' and defined($RefAttrs->{$i})) {
- $attr{$i} = $RefAttrs->{$i}
+ my $RefAttrs;
+ ref($_[0]) eq 'HASH' || ref($_[0]) eq 'ARRAY' and $RefAttrs = shift;
+ foreach ("expand", "fill", "padding", "pack_end") {
+ if ($RefDefaultAttrs->{$_} eq 'arg') {
+ ref ($_[0]) and die "error in packing definition\n";
+ $attr{$_} = shift;
+ ref($RefAttrs) eq 'ARRAY' and shift @$RefAttrs;
+ } elsif (ref($RefAttrs) eq 'HASH' && defined($RefAttrs->{$_})) {
+ $attr{$_} = $RefAttrs->{$_};
} elsif (ref($RefAttrs) eq 'ARRAY') {
- $attr{$i} = shift @$RefAttrs
- } elsif (defined($RefDefaultAttrs->{$i})) {
- $attr{$i} = int $RefDefaultAttrs->{$i}
+ $attr{$_} = shift @$RefAttrs;
+ } elsif (defined($RefDefaultAttrs->{$_})) {
+ $attr{$_} = int $RefDefaultAttrs->{$_};
} else {
- $attr{$i} = 0
+ $attr{$_} = 0;
}
}
-
#- Get and pack the widget (create it if necessary when it is a label...)
my $widget = ref($_[0]) ? shift : new Gtk::Label(shift);
- if (! $attr{pack_end}) {
- $box->pack_start($widget, $attr{expand}, $attr{fill}, $attr{padding});
- } else {
- $box->pack_end($widget, $attr{expand}, $attr{fill}, $attr{padding});
- }
+ if ($attr{pack_end}) { $box->pack_end($widget, $attr{expand}, $attr{fill}, $attr{padding})}
+ else { $box->pack_start($widget, $attr{expand}, $attr{fill}, $attr{padding}) }
$widget->show;
}
$box
@@ -442,7 +436,7 @@ sub get_text_coord {
my ($text, $widget4style, $max_width, $max_height, $can_be_greater, $can_be_smaller, $centeredx, $centeredy, $wrap_char) = @_;
- my $wrap_char ||= ' ';
+ $wrap_char ||= ' ';
my $idx = 0;
my $real_width = 0;
my $real_height = 0;