Re: Adding an image to the menuitem



You should really take a look at the API reference. It clearly says: set_image is your friend.

http://www.gtkmm.org/docs/gtkmm-2.4/docs/reference/html/classGtk_1_1ImageMenuItem.html

youritem->set_image(*Gtk::manage(new Gtk::Image(Gdk::Pixbuf::create_from_file("filename.png"))));


> Datum: Wed, 24 Sep 2008 10:03:53 +0200
> Von: Dimitri Holz <d holz innoventis de>
> An: Simon Fuhrmann <NightSlayer gmx de>
> Betreff: Adding an image to the menuitem

> How can be Gtk::ImageMenuItem used to add a icon from file instead of 
> Gtk::Stock::QUIT in this code?
> I had tried it, but without success, because  I don't know the way to 
> doing it.
> 
> ################################################################################
>    
>    
> #      Glib::RefPtr<Gtk::UIManager>   m_refUIManager;
> #     Glib::RefPtr<Gtk::ActionGroup> m_refActionGroup;
> #      m_refActionGroup = Gtk::ActionGroup::create();
> #
> #      //File menu:
> #      m_refActionGroup->add(Gtk::Action::create("FileMenu", "File"));
> #      m_refActionGroup->add(Gtk::Action::create("FileQuit", 
> Gtk::Stock::QUIT), sigc::mem_fun(*this, 
> &MainWnd::on_ToolButClose_clicked) );
> #
> #
> #      m_refUIManager = Gtk::UIManager::create();
> #      m_refUIManager->insert_action_group(m_refActionGroup);
> #
> #      add_accel_group(m_refUIManager->get_accel_group());
> #
> #      Glib::ustring ui_info =
> #      "<ui>"
> #      "  <menubar name='MenuBar'>"
> #      "    <menu action='FileMenu'>"
> #      "      <menuitem action='FileQuit'/>"
> #      "    </menu>"
> #      "  </menubar>"
> #      "</ui>";
> ################################################################################

-- 
Simon Fuhrmann | NightSlayer at gmx.de



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