diff --git a/rtgui/guiutils.cc b/rtgui/guiutils.cc index f415d770f..52ad2d6d4 100644 --- a/rtgui/guiutils.cc +++ b/rtgui/guiutils.cc @@ -1466,13 +1466,28 @@ TextOrIcon::TextOrIcon (const Glib::ustring &fname, const Glib::ustring &labelTx } MyImageMenuItem::MyImageMenuItem(Glib::ustring label, Glib::ustring imageFileName) +{ + RTImage* itemImage = nullptr; + + if (!imageFileName.empty()) { + itemImage = Gtk::manage(new RTImage(imageFileName)); + } + + construct(label, itemImage); +} + +MyImageMenuItem::MyImageMenuItem(Glib::ustring label, RTImage* itemImage) { + construct(label, itemImage); +} + +void MyImageMenuItem::construct(Glib::ustring label, RTImage* itemImage) { box = Gtk::manage (new Gtk::Grid()); this->label = Gtk::manage( new Gtk::Label(label)); box->set_orientation(Gtk::ORIENTATION_HORIZONTAL); - if (!imageFileName.empty()) { - image = Gtk::manage( new RTImage(imageFileName) ); + if (itemImage) { + image = itemImage; box->attach_next_to(*image, Gtk::POS_LEFT, 1, 1); } else { image = nullptr; diff --git a/rtgui/guiutils.h b/rtgui/guiutils.h index d90d45370..2077d505d 100644 --- a/rtgui/guiutils.h +++ b/rtgui/guiutils.h @@ -489,8 +489,11 @@ private: RTImage *image; Gtk::Label *label; + void construct(Glib::ustring label, RTImage* image); + public: MyImageMenuItem (Glib::ustring label, Glib::ustring imageFileName); + MyImageMenuItem (Glib::ustring label, RTImage* image); const RTImage *getImage () const; const Gtk::Label* getLabel () const; };