Compare commits
2 Commits
9c4f20790f
...
0a9578c1ec
Author | SHA1 | Date | |
---|---|---|---|
0a9578c1ec | |||
1fc2da4fb0 |
@ -1,5 +1,6 @@
|
|||||||
#include <luna/Sort.h>
|
#include <luna/Sort.h>
|
||||||
#include <luna/StringBuilder.h>
|
#include <luna/StringBuilder.h>
|
||||||
|
#include <os/Config.h>
|
||||||
#include <os/Directory.h>
|
#include <os/Directory.h>
|
||||||
#include <os/File.h>
|
#include <os/File.h>
|
||||||
#include <os/FileSystem.h>
|
#include <os/FileSystem.h>
|
||||||
@ -66,64 +67,31 @@ static Result<void> load_application_file(const os::Path& path)
|
|||||||
{
|
{
|
||||||
os::println("[taskbar] reading app file: %s", path.name().chars());
|
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;
|
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());
|
os::println("[taskbar] app file is missing 'Name' entry, aborting!");
|
||||||
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!");
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
app_file.command = TRY(String::from_string_view(file->read_string_or("Command", "")));
|
||||||
if (app_file.command.is_empty())
|
if (app_file.command.is_empty())
|
||||||
{
|
{
|
||||||
os::println("[taskbar] app file is missing 'Command' entry, aborting!");
|
os::println("[taskbar] app file is missing 'Command' entry, aborting!");
|
||||||
return {};
|
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());
|
os::println("[taskbar] loaded app %s into memory", app_file.name.chars());
|
||||||
|
|
||||||
TRY(s_app_files.try_append(move(app_file)));
|
TRY(s_app_files.try_append(move(app_file)));
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <luna/String.h>
|
#include <luna/RefString.h>
|
||||||
#include <os/File.h>
|
#include <os/File.h>
|
||||||
#include <ui/Font.h>
|
#include <ui/Font.h>
|
||||||
|
|
||||||
@ -49,8 +49,8 @@ namespace ui
|
|||||||
|
|
||||||
Result<SharedPtr<Font>> Font::load_builtin(StringView name, FontWeight weight)
|
Result<SharedPtr<Font>> Font::load_builtin(StringView name, FontWeight weight)
|
||||||
{
|
{
|
||||||
auto path = TRY(String::format("/usr/share/fonts/%s-%s.psf"_sv, name.chars(),
|
auto path = TRY(RefString::format("/usr/share/fonts/%s-%s.psf"_sv, name.chars(),
|
||||||
weight == FontWeight::Bold ? "Bold" : "Regular"));
|
weight == FontWeight::Bold ? "Bold" : "Regular"));
|
||||||
|
|
||||||
return load(path.view());
|
return load(path.view());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user