@@ -5,6 +5,8 @@
|
||||
#include <ranges>
|
||||
#include <stdexcept>
|
||||
|
||||
#include <mini/ini.h>
|
||||
|
||||
IconTheme::IconTheme(std::filesystem::path const &themes_directory_path)
|
||||
{
|
||||
for (auto const &dir :
|
||||
@@ -15,6 +17,56 @@ IconTheme::IconTheme(std::filesystem::path const &themes_directory_path)
|
||||
auto const index_path = dir.path() / "index.theme";
|
||||
if (std::filesystem::is_regular_file(index_path))
|
||||
continue;
|
||||
|
||||
mINI::INIFile ini_file(index_path);
|
||||
mINI::INIStructure ini;
|
||||
ini_file.read(ini);
|
||||
|
||||
auto const &directories { ini["Icon Theme"]["Directories"] };
|
||||
for (auto const &&dir_entry : directories | std::views::split(':')) {
|
||||
auto const dir_entry_str { std::string(
|
||||
dir_entry.begin(), dir_entry.end()) };
|
||||
auto const path { std::filesystem::path(dir_entry_str) };
|
||||
auto const path_actual { dir.path() / path };
|
||||
|
||||
if (!std::filesystem::is_directory(path_actual))
|
||||
continue;
|
||||
|
||||
auto const &type_raw { ini[dir_entry_str]["Type"] };
|
||||
DirectoryEntry::Type type;
|
||||
if (type_raw == "Fixed") {
|
||||
type = DirectoryEntry::Type::Fixed;
|
||||
} else if (type_raw == "Scalable") {
|
||||
type = DirectoryEntry::Type::Scalable;
|
||||
} else if (type_raw == "Threshold") {
|
||||
type = DirectoryEntry::Type::Threshold;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto const &context_raw { ini[dir_entry_str]["context"] };
|
||||
DirectoryEntry::Context context;
|
||||
if (context_raw == "Actions") {
|
||||
context = DirectoryEntry::Context::Actions;
|
||||
} else if (type_raw == "Devices") {
|
||||
context = DirectoryEntry::Context::Devices;
|
||||
} else if (type_raw == "FileSystems") {
|
||||
context = DirectoryEntry::Context::FileSystems;
|
||||
} else if (type_raw == "MomeTypes") {
|
||||
context = DirectoryEntry::Context::MimeTypes;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
int size { std::atoi(ini[dir_entry_str]["Size"].c_str()) };
|
||||
|
||||
m_directories.push_back({
|
||||
.path = path,
|
||||
.size = size,
|
||||
.type = type,
|
||||
.context = context,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +96,7 @@ IconRegistry::IconRegistry()
|
||||
theme_directory_paths.push_back(path);
|
||||
}
|
||||
|
||||
for (auto const &path : std::move(theme_directory_paths)
|
||||
for (auto &&path : std::move(theme_directory_paths)
|
||||
| std::views::filter([](std::filesystem::path &path) {
|
||||
return std::filesystem::is_directory(path);
|
||||
})) {
|
||||
|
||||
Reference in New Issue
Block a user