mirror of
https://github.com/audacity/linuxdeploy.git
synced 2026-07-01 17:11:26 -05:00
Move linuxdeploy-specific helper out of desktop file class
This commit is contained in:
32
src/core.cpp
32
src/core.cpp
@@ -39,7 +39,7 @@ namespace linuxdeploy {
|
||||
deployedDesktopFiles.begin(),
|
||||
deployedDesktopFiles.end(),
|
||||
[&firstDeployedDesktopFileName](const desktopfile::DesktopFile& desktopFile) {
|
||||
auto fileName = desktopFile.path().filename().string();
|
||||
auto fileName = desktopFile.path();
|
||||
return fileName == firstDeployedDesktopFileName;
|
||||
}
|
||||
);
|
||||
@@ -85,4 +85,34 @@ namespace linuxdeploy {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool addDefaultKeys(DesktopFile& desktopFile, const std::string& executableFileName) {
|
||||
ldLog() << "Adding default values to desktop file:" << desktopFile.path() << std::endl;
|
||||
|
||||
auto rv = true;
|
||||
|
||||
auto setDefault = [&rv, &desktopFile](const std::string& section, const std::string& key, const std::string& value) {
|
||||
if (desktopFile.entryExists(section, key)) {
|
||||
DesktopFileEntry entry;
|
||||
|
||||
// this should never return false
|
||||
auto entryExists = desktopFile.getEntry(section, key, entry);
|
||||
assert(entryExists);
|
||||
|
||||
ldLog() << LD_WARNING << "Key exists, not modified:" << key << "(current value:" << entry.value() << LD_NO_SPACE << ")" << std::endl;
|
||||
rv = false;
|
||||
} else {
|
||||
auto entryOverwritten = desktopFile.setEntry(section, DesktopFileEntry(key, value));
|
||||
assert(!entryOverwritten);
|
||||
}
|
||||
};
|
||||
|
||||
setDefault("Desktop Entry", "Name", executableFileName);
|
||||
setDefault("Desktop Entry", "Exec", executableFileName);
|
||||
setDefault("Desktop Entry", "Icon", executableFileName);
|
||||
setDefault("Desktop Entry", "Type", "Application");
|
||||
setDefault("Desktop Entry", "Categories", "Utility;");
|
||||
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user