Compare commits

..

No commits in common. "0a9578c1ec7593808dc17cd14b13b154fb839c57" and "9c4f20790f99325077eda7b8104de761ab4e4c2e" have entirely different histories.

2 changed files with 49 additions and 17 deletions

View File

@ -1,6 +1,5 @@
#include <luna/Sort.h>
#include <luna/StringBuilder.h>
#include <os/Config.h>
#include <os/Directory.h>
#include <os/File.h>
#include <os/FileSystem.h>
@ -67,31 +66,64 @@ static Result<void> load_application_file(const os::Path& path)
{
os::println("[taskbar] reading app file: %s", path.name().chars());
auto file = TRY(os::ConfigFile::open(path));
auto file = TRY(os::File::open(path, os::File::ReadOnly));
ApplicationFile app_file;
app_file.name = TRY(String::from_string_view(file->read_string_or("Name", "")));
if (app_file.name.is_empty())
while (true)
{
os::println("[taskbar] app file is missing 'Name' entry, aborting!");
return {};
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());
}
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 {};
}
if (app_file.command.is_empty())
{
os::println("[taskbar] app file is missing 'Command' entry, aborting!");
return {};
}
os::println("[taskbar] loaded app %s into memory", app_file.name.chars());
TRY(s_app_files.try_append(move(app_file)));

View File

@ -7,7 +7,7 @@
*
*/
#include <luna/RefString.h>
#include <luna/String.h>
#include <os/File.h>
#include <ui/Font.h>
@ -49,8 +49,8 @@ namespace ui
Result<SharedPtr<Font>> Font::load_builtin(StringView name, FontWeight weight)
{
auto path = TRY(RefString::format("/usr/share/fonts/%s-%s.psf"_sv, name.chars(),
weight == FontWeight::Bold ? "Bold" : "Regular"));
auto path = TRY(String::format("/usr/share/fonts/%s-%s.psf"_sv, name.chars(),
weight == FontWeight::Bold ? "Bold" : "Regular"));
return load(path.view());
}