2020-12-27 18:50:50 +01:00
|
|
|
/*
|
2021-04-22 22:51:19 +02:00
|
|
|
* Copyright (c) 2020, Linus Groh <linusg@serenityos.org>
|
2020-12-27 18:50:50 +01:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-12-27 18:50:50 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <LibCore/ConfigFile.h>
|
|
|
|
|
#include <LibGUI/FileIconProvider.h>
|
|
|
|
|
#include <LibGUI/Icon.h>
|
|
|
|
|
|
2020-12-28 01:06:38 +01:00
|
|
|
namespace Desktop {
|
2020-12-27 18:50:50 +01:00
|
|
|
|
|
|
|
|
class AppFile : public RefCounted<AppFile> {
|
|
|
|
|
public:
|
|
|
|
|
static constexpr const char* APP_FILES_DIRECTORY = "/res/apps";
|
2021-11-11 00:55:02 +01:00
|
|
|
static NonnullRefPtr<AppFile> get_for_app(StringView app_name);
|
|
|
|
|
static NonnullRefPtr<AppFile> open(StringView path);
|
|
|
|
|
static void for_each(Function<void(NonnullRefPtr<AppFile>)>, StringView directory = APP_FILES_DIRECTORY);
|
2020-12-27 18:50:50 +01:00
|
|
|
~AppFile();
|
|
|
|
|
|
|
|
|
|
bool is_valid() const { return m_valid; }
|
2021-04-29 21:46:15 +02:00
|
|
|
String filename() const { return m_config->filename(); }
|
2020-12-27 18:50:50 +01:00
|
|
|
|
|
|
|
|
String name() const;
|
|
|
|
|
String executable() const;
|
|
|
|
|
String category() const;
|
2021-07-25 21:51:35 +02:00
|
|
|
String description() const;
|
2021-08-04 13:16:26 +02:00
|
|
|
String icon_path() const;
|
|
|
|
|
GUI::Icon icon() const;
|
2021-07-19 22:00:34 +01:00
|
|
|
bool run_in_terminal() const;
|
2020-12-27 18:50:50 +01:00
|
|
|
Vector<String> launcher_file_types() const;
|
|
|
|
|
Vector<String> launcher_protocols() const;
|
2021-06-21 20:20:05 -04:00
|
|
|
bool spawn() const;
|
2020-12-27 18:50:50 +01:00
|
|
|
|
|
|
|
|
private:
|
2021-11-11 00:55:02 +01:00
|
|
|
explicit AppFile(StringView path);
|
2020-12-27 18:50:50 +01:00
|
|
|
|
|
|
|
|
bool validate() const;
|
|
|
|
|
|
|
|
|
|
RefPtr<Core::ConfigFile> m_config;
|
|
|
|
|
bool m_valid { false };
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|