Make MyImageMenuItem constructable from an RTImage

This commit is contained in:
Lawrence Lee
2021-04-12 21:48:54 -07:00
parent be7aecac40
commit 3efbb99ba9
2 changed files with 20 additions and 2 deletions

View File

@@ -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;