Re: pixbufs in a SimpleList
- From: muppet <scott asofyet org>
- To: The Saltydog <thesaltydog gmail com>
- Cc: gtk-perl-list gnome org
- Subject: Re: pixbufs in a SimpleList
- Date: Sun, 29 May 2005 15:13:57 -0400
On May 29, 2005, at 2:50 PM, The Saltydog wrote:
I need short instructions (maybe a small sample code) to implement a
column of little icons into my Gtk2::SimpleList....
See also the stock browser portion of gtk-demo, which comes in the
Gtk2 source tarball; it's a non-trivial example of using the TreeView
in a real-world setting.
Here's something trivial with SimpleList.
#!/usr/bin/perl -w
use strict;
use Gtk2 -init;
use Gtk2::SimpleList; # Gtk2::Ex::Simple::List
my $window = Gtk2::Window->new;
$window->signal_connect (destroy => sub { Gtk2->main_quit });
my $slist = Gtk2::SimpleList->new ('Icon' => 'pixbuf',
'Stock-Id' => 'text');
# I'm too lazy to create a bunch of pixbufs here, so i want to use
# stock items. Gtk2::CellRendererPixbuf can, indeed, use a stock id,
# but the 'pixbuf' column type for SimpleList wants an actual pixbuf
# object. So, here's a little perl magic to render these stock icons
# as we will the store. Remember, the SimpleList represents the
# TreeStore as a list of lists, so the map block must return a
# reference an array of column values...
@{ $slist->{data} } = map {
# column 0, the pixbuf column 1, the text
[ $window->render_icon ($_, 'menu'), $_ ]
} qw(gtk-ok gtk-cancel gtk-yes gtk-no gtk-save gtk-open gtk-quit
gtk-close);
$window->add ($slist);
$window->show_all;
Gtk2->main;
--
I don't like... this game... when there's cannons... being shot... at
me.
-- Elysse
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]