diff --git a/gui/apps/taskbar.cpp b/gui/apps/taskbar.cpp index a40ee0f3..4780bef7 100644 --- a/gui/apps/taskbar.cpp +++ b/gui/apps/taskbar.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -66,64 +67,31 @@ static Result load_application_file(const os::Path& path) { os::println("[taskbar] reading app file: %s", path.name().chars()); - auto file = TRY(os::File::open(path, os::File::ReadOnly)); + auto file = TRY(os::ConfigFile::open(path)); ApplicationFile app_file; - while (true) + app_file.name = TRY(String::from_string_view(file->read_string_or("Name", ""))); + if (app_file.name.is_empty()) { - auto line = TRY(file->read_line()); - if (line.is_empty()) break; - - line.trim("\n"); - if (line.is_empty()) continue; - - auto parts = TRY(line.split_once('=')); - if (parts.size() < 2 || parts[0].is_empty() || parts[1].is_empty()) - { - os::println("[taskbar] file contains invalid line, aborting: '%s'", line.chars()); - return {}; - } - - if (parts[0].view() == "Name") - { - app_file.name = move(parts[1]); - continue; - } - - if (parts[0].view() == "Description") - { - // We let users specify this in the config file, but taskbar doesn't actually use it. - continue; - } - - if (parts[0].view() == "Command") - { - app_file.command = move(parts[1]); - continue; - } - - if (parts[0].view() == "Icon") - { - app_file.icon = move(parts[1]); - continue; - } - - os::println("[taskbar] skipping unknown entry name %s", parts[0].chars()); - } - - if (app_file.icon.is_empty()) - { - os::println("[taskbar] app file is missing 'Icon' entry, aborting!"); + os::println("[taskbar] app file is missing 'Name' entry, aborting!"); return {}; } + app_file.command = TRY(String::from_string_view(file->read_string_or("Command", ""))); if (app_file.command.is_empty()) { os::println("[taskbar] app file is missing 'Command' entry, aborting!"); return {}; } + app_file.icon = TRY(String::from_string_view(file->read_string_or("Icon", ""))); + if (app_file.icon.is_empty()) + { + os::println("[taskbar] app file is missing 'Icon' entry, aborting!"); + return {}; + } + os::println("[taskbar] loaded app %s into memory", app_file.name.chars()); TRY(s_app_files.try_append(move(app_file)));