Re: Gtk2::ImageMenuItem with a custom icon




On Jul 14, 2005, at 4:03 AM, Emmanuele Bassi wrote:

On Thu, 2005-07-14 at 14:45 +1000, Daniel Kasak wrote:

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:

Another option, which takes more work but may pay off with less work and easier reuse in the long run (e.g. if you want to create a toolbar button for the same action, have a bunch of custom icon+text combinations, or use UIManager to create the menus), is to create your own stock item.

See examples/adding_stock_icons.pl in the Gtk2 source tree.


--
"Ghostbusters" is the best movie of this decade.
  -- Neal, circa 1996, referring to a movie released in 1984.




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]