Fix storage of external editor icons

De-serialize and serialize icons instead of using their names.
This commit is contained in:
Lawrence Lee
2021-08-14 17:11:07 -07:00
parent d3e524a491
commit 672d6302f3
7 changed files with 75 additions and 31 deletions

View File

@@ -2522,8 +2522,22 @@ void EditorPanel::updateExternalEditorWidget(int selectedIndex, const std::vecto
// Add the editors.
for (unsigned i = 0; i < editors.size(); i++) {
const auto & name = editors[i].name.empty() ? Glib::ustring(" ") : editors[i].name;
if (!editors[i].icon_name.empty()) {
Glib::RefPtr<Gio::Icon> gioIcon = Gio::Icon::create(editors[i].icon_name);
if (!editors[i].icon_serialized.empty()) {
Glib::RefPtr<Gio::Icon> gioIcon;
GError *e = nullptr;
GVariant *icon_variant = g_variant_parse(
nullptr, editors[i].icon_serialized.c_str(), nullptr, nullptr, &e);
if (e) {
std::cerr
<< "Error loading external editor icon from \""
<< editors[i].icon_serialized << "\": " << e->message
<< std::endl;
gioIcon = Glib::RefPtr<Gio::Icon>();
} else {
gioIcon = Gio::Icon::deserialize(Glib::VariantBase(icon_variant));
}
send_to_external->insertEntry(i, gioIcon, name);
} else {
send_to_external->insertEntry(i, "palette-brush.png", name);