Re: Gtk2::ImageMenuItem with a custom icon
- From: Emmanuele Bassi <ebassi gmail com>
- To: gtk-perl-list gnome org
- Subject: Re: Gtk2::ImageMenuItem with a custom icon
- Date: Thu, 14 Jul 2005 10:03:07 +0200
Hi,
On Thu, 2005-07-14 at 14:45 +1000, Daniel Kasak wrote:
I've tried:
my $menu_item = Gtk2::ImageMenuItem->new;
my $pixbuf = $form->render_icon( "gtk-index", "menu");
$menu_item->set_image($pixbuf);
But the last line complains that $pixbuf is not of type Gtk2::Widget.
Yep, Gtk2::ImageMenuItem::set_image requires a Gtk2::Image widget, not a
Gtk2::Gdk::Pixbuf object.
You should create a new Gtk2::Image widget to pass to the ::set_image
method, like this:
my $menu_item = Gtk2::ImageMenuItem->new;
my $pixbuf = $form->render_icon('gtk-index', 'menu');
- $menu_item->set_image($pixbuf);
+ my $image = Gtk2::Image->new_from_pixbuf($pixbuf);
+ $menu_item->set_image($image);
Hint: if the apidoc is ambiguous, go to the C API reference, at:
http://developer.gnome.org/doc/API/2.0/gtk/
It should make things easier.
Regards,
Emmanuele.
--
Emmanuele Bassi <ebassi gmail com>
Web site: http://log.emmanuelebassi.net
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]