Show icon in external editor button when disabled

This commit is contained in:
Lawrence Lee
2023-08-05 10:11:54 -07:00
parent 7ad414aa63
commit c82369843e
3 changed files with 26 additions and 2 deletions

View File

@@ -136,6 +136,21 @@ bool PopUpCommon::insertEntryImpl(int position, const Glib::ustring& fileName, c
return true;
}
void PopUpCommon::setEmptyImage(const Glib::ustring &fileName)
{
emptyImageFilename = fileName;
if (getEntryCount()) {
return;
}
if (fileName.empty()) {
buttonImage->hide();
} else {
changeImage(emptyImageFilename, Glib::RefPtr<const Gio::Icon>());
buttonImage->show();
}
}
void PopUpCommon::removeEntry(int position)
{
if (position < 0 || position >= getEntryCount()) {
@@ -147,8 +162,13 @@ void PopUpCommon::removeEntry(int position)
button->get_style_context()->remove_class("Left");
arrowButton->hide();
hasMenu = false;
// Remove the button image.
buttonImage->hide();
if (emptyImageFilename.empty()) {
// Remove the button image.
buttonImage->hide();
} else {
// Show the empty icon.
changeImage(emptyImageFilename, Glib::RefPtr<const Gio::Icon>());
}
selected = -1;
}
else if (position < selected) {