summaryrefslogtreecommitdiffstats
path: root/perl-install/mygtk2.pm
diff options
context:
space:
mode:
authorOlivier Blin <oblin@mandriva.com>2007-08-20 20:13:36 +0000
committerOlivier Blin <oblin@mandriva.com>2007-08-20 20:13:36 +0000
commit75e462557cd824504f8a5b7c713924bf8e52cfa2 (patch)
tree5607b7d64f7aa5821ee8925cf6d058b81a26bfa4 /perl-install/mygtk2.pm
parent7fbad81c1334b8345e2e217cd8a48c31b40a9a81 (diff)
downloaddrakx-backup-do-not-use-75e462557cd824504f8a5b7c713924bf8e52cfa2.tar
drakx-backup-do-not-use-75e462557cd824504f8a5b7c713924bf8e52cfa2.tar.gz
drakx-backup-do-not-use-75e462557cd824504f8a5b7c713924bf8e52cfa2.tar.bz2
drakx-backup-do-not-use-75e462557cd824504f8a5b7c713924bf8e52cfa2.tar.xz
drakx-backup-do-not-use-75e462557cd824504f8a5b7c713924bf8e52cfa2.zip
allow to specify size when creating pixbufs and images
Diffstat (limited to 'perl-install/mygtk2.pm')
-rw-r--r--perl-install/mygtk2.pm19
1 files changed, 14 insertions, 5 deletions
diff --git a/perl-install/mygtk2.pm b/perl-install/mygtk2.pm
index 6569c3180..f9985db77 100644
--- a/perl-install/mygtk2.pm
+++ b/perl-install/mygtk2.pm
@@ -275,7 +275,11 @@ sub _gtk__Pixbuf {
if (!$w) {
my $name = delete $opts->{file} or internal_error("missing file");
my $file = _find_imgfile($name) or internal_error("can not find image $name");
- $w = Gtk2::Gdk::Pixbuf->new_from_file($file);
+ if (my $size = delete $opts->{size}) {
+ $w = Gtk2::Gdk::Pixbuf->new_from_file_at_scale($file, $size, $size, 1);
+ } else {
+ $w = Gtk2::Gdk::Pixbuf->new_from_file($file);
+ }
}
$w;
}
@@ -294,18 +298,23 @@ sub _gtk__Image {
my $pixmap = mygtk2::pixmap_from_pixbuf($w, gtknew('Pixbuf', file => $file));
$w->set_from_pixmap($pixmap, undef);
} : sub {
- my ($w, $file) = @_;
- $w->set_from_file($file);
+ my ($w, $file, $o_size) = @_;
+ if ($o_size) {
+ my $pixbuf = gtknew('Pixbuf', file => $file, size => $o_size);
+ $w->set_from_pixbuf($pixbuf);
+ } else {
+ $w->set_from_file($file);
+ }
};
}
if (my $name = delete $opts->{file}) {
my $file = _find_imgfile(may_apply($w->{format}, $name)) or internal_error("can not find image $name");
- $w->{set_from_file}->($w, $file);
+ $w->{set_from_file}->($w, $file, delete $opts->{size});
} elsif (my $file_ref = delete $opts->{file_ref}) {
my $set = sub {
my $file = _find_imgfile(may_apply($w->{format}, $$file_ref)) or internal_error("can not find image $$file_ref");
- $w->{set_from_file}->($w, $file);
+ $w->{set_from_file}->($w, $file, delete $opts->{size});
};
gtkval_register($w, $file_ref, $set);
$set->() if $$file_ref;