It sounds like some tricky layout features for the textview. Maybe wrapping 
text around images? 

Not sure how to go about doing this. One thing to try is putting another 
textview in there with the image. Then you can size it to the image height and 
could resize it based on the overall window width.


Eric

#!/usr/bin/perl
package scaleme;
 
use strict;
use diagnostics;
use warnings;
 
use Gtk2 '-init';
use Glib qw(TRUE FALSE);
 
# Display this image
my $path = 'cat.png';
 
# Open a Gtk2 window with a Gtk2::TextView
my $window = Gtk2::Window->new('toplevel');
$window->set_title('scaleme');
$window->set_position('center');
$window->set_default_size(400, 400);
$window->signal_connect('delete-event' => sub {
    Gtk2->main_quit();
    exit;
});
            
my $frame = Gtk2::Frame->new();
$window->add($frame);
 
my $scrollWin = Gtk2::ScrolledWindow->new(undef, undef);
$frame->add($scrollWin);
$scrollWin->set_policy('automatic', 'automatic');     
$scrollWin->set_border_width(0);
 
my $textView = Gtk2::TextView->new;
$scrollWin->add_with_viewport($textView);
 
if (-e $path) {
 
    # Display a photo of a cat face
    my $pixbuf = Gtk2::Gdk::Pixbuf->new_from_file($path);
  
    my $w = $pixbuf->get_width();
    my $h = $pixbuf->get_height();
    my $scale_w1 = $w * 0.3;
    my $scale_h1 = $h * 0.3;
 
    my $pixbuf2 = $pixbuf->scale_simple($scale_w1, $scale_h1, 
'GDK_INTERP_BILINEAR');

    my $textView2 = Gtk2::TextView->new;
    $textView2->set_size_request(400, $scale_h1);
    my $table = Gtk2::Table->new(1, 2, FALSE);
    my $image = Gtk2::Image->new_from_pixbuf($pixbuf2);
    my $ebox = Gtk2::EventBox->new();
    $ebox->signal_connect('button-press-event' => \&click_pixbuf);
    $ebox->add($image);
    $table->attach_defaults($ebox, 0, 1, 0, 1);
    $table->attach_defaults($textView2, 1, 2, 0, 1);

    my $buffer = $textView->get_buffer();
    my $buffer2 = $textView2->get_buffer();
    $buffer->set_text("Top of the cat\n");
    my $anchor = $buffer->create_child_anchor($buffer->get_end_iter());
    $textView->add_child_at_anchor($table, $anchor);
    $buffer2->insert_at_cursor("\nA few\nlines to the right\n of the cat\n");
    $buffer->insert_at_cursor("\nBottom of the cat\n");

}
 
$window->show_all();   
Gtk2->main();

sub click_pixbuf 
{
  print "Click Pixbuf\n";
}


_______________________________________________
gtk-perl-list mailing list
gtk-perl-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-perl-list

Reply via email to