[gtkmm] Packing a Gdk::Pixbuf into a Gtk::Box



I am attempting to put an image in the form of a Pixbuf into an HBox that lives on a Button. The only problem is that all Pixbuf creation functions return RefPtr's, and the pack_start function on the box requires a pass by reference, not pointer of the item to be packed. Currently, I'm using the following code:

hbox = new Gtk::HBox();

Glib::RefPtr<Gdk::Pixbuf> pixbuf = Gdk::Pixbuf::create_subpixbuf (tmp_pixbuf, 0, 0, 17, 17);
tmp_pixbuf->scale (pixbuf, 0, 0, 17, 17, 0, 0, 0.6, 0.6, Gdk::INTERP_HYPER);
hbox->pack_start (pixbuf, false, false, 0);


When I attempt to compile the code, I get the following output from the compiler:

MyButton.cc: In constructor `MyButton::MyButton(int, const char*)':
MyButton.cc:52: error: no matching function for call to `Gtk::HBox::
   pack_start(Glib::RefPtr<Gdk::Pixbuf>&, bool, bool, int)'
/usr/include/gtkmm-2.0/gtkmm/box.h:302: error: candidates are: void
   Gtk::Box::pack_start(Gtk::Widget&, bool, bool, unsigned int)
/usr/include/gtkmm-2.0/gtkmm/box.h:303: error:                 void
   Gtk::Box::pack_start(Gtk::Widget&, Gtk::PackOptions, unsigned int)

Apparently, I can't back the RefPtr, and there is no way (that I can tell) to dereference it so that the pack_start function will accept it as input.

How do I work around this problem?

Many thanks,
Hyrum

--
High-Altitude Amateur Ballooning - http://icarus.byu.edu

This message is digitally signed to show that it originated from Hyrum
Wright.  If you know what digitally signed email is, and your email
software supports it, download the key for hyrum_wright byu edu from
hkp://pgp.mit.edu.

GnuPG Fingerprint: 62B3 E69E 8982 C407 95C0  2182 E80D 6D27 1CD9 143B

Attachment: signature.asc
Description: OpenPGP digital signature



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