summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perl-install/mygtk2.pm19
-rw-r--r--perl-install/ugtk2.pm6
2 files changed, 18 insertions, 7 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;
diff --git a/perl-install/ugtk2.pm b/perl-install/ugtk2.pm
index d156bc03d..fe20ca05a 100644
--- a/perl-install/ugtk2.pm
+++ b/perl-install/ugtk2.pm
@@ -605,12 +605,14 @@ sub _find_imgfile {
# use it if you want to display an icon/image in your app
sub gtkcreate_img {
- gtknew('Image', file => $_[0]);
+ my ($file, $o_size) = @_;
+ gtknew('Image', file => $file, if_($o_size, size => $o_size));
}
# use it if you want to draw an image onto a drawingarea
sub gtkcreate_pixbuf {
- gtknew('Pixbuf', file => $_[0]);
+ my ($file, $o_size) = @_;
+ gtknew('Pixbuf', file => $_[0], if_($o_size, size => $o_size));
}
sub gtktext_append { gtktext_insert(@_, append => 1) }