Links
Archives
Random notes from yet another Finnish nerd. This blog reflects mostly my life with computers and stuff, rather than my real life.
May 25, 2004
gtk2-perl for win32
Decided to try gtk2-perl on win32 today. There were some rough edges but it went something like this:
- Upgraded to ActiveState Perl 5.8 (gtk2-perl doesn't support 5.6 releases)
- Downloaded binary installers for Glib and Gtk+ 2 Perl modules
- I had already installed GTK+ 2 for Windows. I also happened to have an older version of iconv.dll somewhere else in the PATH. Had to remove it to make gtk2-perl work.
- Verified the thing works by hacking together the following simple image viewer utility:
#!/usr/bin/perl
#
# Simple image browser.
# Directory containing images given as command line argument.
use strict;
use warnings;
use Glib qw(FALSE TRUE);
use Gtk2 -init;
use Gtk2::SimpleList;
use File::Spec;
use constant TRUE => 1;
use constant FALSE => 0;
die "Usage: $0 directory\n" unless @ARGV;
my $dir_base = $ARGV[0];
opendir(DIR, $dir_base) or die("Directory open error: $!");
my $window = Gtk2::Window->new;
my $image = Gtk2::Image->new;
my $list = Gtk2::SimpleList->new('Image name' => 'text');
foreach(readdir(DIR)) {
my $file = $_;
if($file =~ /\.jpe?g$/i) {
push @{$list->{data}}, [ $file ];
}
}
$list->set_rules_hint (TRUE);
#$list->signal_connect (row_activated => \&row_clicked); # double click event
$list->signal_connect (cursor_changed => \&row_clicked); # focus change event
my $scroll = Gtk2::ScrolledWindow->new(undef, undef);
$scroll->add($list);
$scroll->set_policy('never','automatic');
my $hbox = Gtk2::HBox->new;
$hbox->pack_start($scroll,FALSE,FALSE,0);
$hbox->pack_start($image,TRUE,TRUE,0);
$window->add ($hbox);
$window->set_default_size(800,600);
$window->show_all;
$window->signal_connect (delete_event => \&delete_event);
$window->signal_connect (destroy => sub {Gtk2->main_quit;});
Gtk2->main;
sub row_clicked {
my ($model,$iter) = $list->get_selection->get_selected;
my $filename = $model->get ($iter, 0);
my $pixbuf = Gtk2::Gdk::Pixbuf->new_from_file (File::Spec->catdir($dir_base, $filename));
$image->set_from_pixbuf($pixbuf);
$window->set_title ($filename);
}
sub delete_event
{
return FALSE;
} - Some of the examples and gtk2-demo in gtk2-perl source archive failed to work out of the box. There was also a lot of warnings about TRUE & FALSE being undefined. I simply ignored them or defined constants called TRUE & FALSE.
Blogger software on Slashdot
There was another story on on MovableType 3 licensing changes. Seems like a lot of the open source folk are gonna move on to open source blogger software, such as WordPress, Blosxom, Drupal and LiveJournal.
Comments:
Post a Comment