You don't need the Gnome desktop to run this, but you may need a few Gnome libs, like libcroco, librsvg and the latest Cairo version. It displays SVG files, can zoom them, etc. This is a very basic example showing it's use.
#!/usr/bin/perl use strict; use warnings; use Gtk2 '-init'; use Gnome2::Rsvg; my $file = shift || die "Need and svg file as argument $!\n"; my $sw = Gtk2::ScrolledWindow->new(undef, undef); $sw->set_policy('automatic','automatic'); my $mw = Gtk2::Window->new; $mw->add($sw); my $vp; &load_image; $mw->signal_connect('destroy', sub { Gtk2->main_quit }); Gtk2->main; ########################################################## sub load_image { $sw->remove($vp) if defined $vp; # The easy way. my $pb = Gnome2::Rsvg->pixbuf_from_file_at_zoom_with_max($file,10,10,1 +000,1000); # ($file, x_zoom, y_zoom, max_x, max_y ) my $img = Gtk2::Image->new_from_pixbuf($pb); my ($x, $y) = ($pb->get_width, $pb->get_height); $vp = Gtk2::Viewport->new(undef, undef); $vp->add($img); $sw->add($vp); $mw->resize(500,500); my $ha = Gtk2::Adjustment->new(50, 0, 1, 0.1, 0.9, 1); my $va = Gtk2::Adjustment->new(50, 0, 1, 0.1, 0.9, 1); $sw->set_hadjustment($ha); $sw->set_vadjustment($va); $mw->set_title("$file ${x}x${y}"); $mw->show_all(); return 1; }
|
|---|