mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 19:37:36 +00:00
Everywhere: Move AppFile from LibGUI to LibDesktop
This was mentioned in #4574, and the more I think about it the more it feels just right - let's move it there! :^) Having to link LaunchServer against LibGUI explicitly should've been telling enough...
This commit is contained in:
parent
97c42694db
commit
58890e03b6
12 changed files with 20 additions and 20 deletions
|
@ -28,9 +28,9 @@
|
||||||
#include <AK/Vector.h>
|
#include <AK/Vector.h>
|
||||||
#include <LibCore/ConfigFile.h>
|
#include <LibCore/ConfigFile.h>
|
||||||
#include <LibCore/DirIterator.h>
|
#include <LibCore/DirIterator.h>
|
||||||
#include <LibGUI/AppFile.h>
|
#include <LibDesktop/AppFile.h>
|
||||||
|
|
||||||
namespace GUI {
|
namespace Desktop {
|
||||||
|
|
||||||
NonnullRefPtr<AppFile> AppFile::get_for_app(const StringView& app_name)
|
NonnullRefPtr<AppFile> AppFile::get_for_app(const StringView& app_name)
|
||||||
{
|
{
|
|
@ -30,7 +30,7 @@
|
||||||
#include <LibGUI/FileIconProvider.h>
|
#include <LibGUI/FileIconProvider.h>
|
||||||
#include <LibGUI/Icon.h>
|
#include <LibGUI/Icon.h>
|
||||||
|
|
||||||
namespace GUI {
|
namespace Desktop {
|
||||||
|
|
||||||
class AppFile : public RefCounted<AppFile> {
|
class AppFile : public RefCounted<AppFile> {
|
||||||
public:
|
public:
|
||||||
|
@ -49,7 +49,7 @@ public:
|
||||||
Vector<String> launcher_file_types() const;
|
Vector<String> launcher_file_types() const;
|
||||||
Vector<String> launcher_protocols() const;
|
Vector<String> launcher_protocols() const;
|
||||||
|
|
||||||
Icon icon() const { return FileIconProvider::icon_for_path(executable()); };
|
GUI::Icon icon() const { return GUI::FileIconProvider::icon_for_path(executable()); };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit AppFile(const StringView& path);
|
explicit AppFile(const StringView& path);
|
|
@ -1,4 +1,5 @@
|
||||||
set(SOURCES
|
set(SOURCES
|
||||||
|
AppFile.cpp
|
||||||
Launcher.cpp
|
Launcher.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -8,4 +9,4 @@ set(GENERATED_SOURCES
|
||||||
)
|
)
|
||||||
|
|
||||||
serenity_lib(LibDesktop desktop)
|
serenity_lib(LibDesktop desktop)
|
||||||
target_link_libraries(LibDesktop LibIPC)
|
target_link_libraries(LibDesktop LibCore LibIPC LibGUI)
|
||||||
|
|
|
@ -5,7 +5,6 @@ set(SOURCES
|
||||||
AbstractView.cpp
|
AbstractView.cpp
|
||||||
Action.cpp
|
Action.cpp
|
||||||
ActionGroup.cpp
|
ActionGroup.cpp
|
||||||
AppFile.cpp
|
|
||||||
Application.cpp
|
Application.cpp
|
||||||
BoxLayout.cpp
|
BoxLayout.cpp
|
||||||
Button.cpp
|
Button.cpp
|
||||||
|
|
|
@ -34,9 +34,9 @@
|
||||||
#include <AK/Utf8View.h>
|
#include <AK/Utf8View.h>
|
||||||
#include <LibCore/ConfigFile.h>
|
#include <LibCore/ConfigFile.h>
|
||||||
#include <LibCore/MimeData.h>
|
#include <LibCore/MimeData.h>
|
||||||
|
#include <LibDesktop/AppFile.h>
|
||||||
#include <LibDesktop/Launcher.h>
|
#include <LibDesktop/Launcher.h>
|
||||||
#include <LibGUI/Action.h>
|
#include <LibGUI/Action.h>
|
||||||
#include <LibGUI/AppFile.h>
|
|
||||||
#include <LibGUI/Application.h>
|
#include <LibGUI/Application.h>
|
||||||
#include <LibGUI/Clipboard.h>
|
#include <LibGUI/Clipboard.h>
|
||||||
#include <LibGUI/DragOperation.h>
|
#include <LibGUI/DragOperation.h>
|
||||||
|
@ -858,7 +858,7 @@ void TerminalWidget::context_menu_event(GUI::ContextMenuEvent& event)
|
||||||
// Then add them to the context menu.
|
// Then add them to the context menu.
|
||||||
// FIXME: Adapt this code when we actually support calling LaunchServer with a specific handler in mind.
|
// FIXME: Adapt this code when we actually support calling LaunchServer with a specific handler in mind.
|
||||||
for (auto& handler : handlers) {
|
for (auto& handler : handlers) {
|
||||||
auto af = GUI::AppFile::get_for_app(LexicalPath(handler).basename());
|
auto af = Desktop::AppFile::get_for_app(LexicalPath(handler).basename());
|
||||||
if (!af->is_valid())
|
if (!af->is_valid())
|
||||||
continue;
|
continue;
|
||||||
auto action = GUI::Action::create(String::formatted("Open in {}", af->name()), af->icon().bitmap_for_size(16), [this, handler](auto&) {
|
auto action = GUI::Action::create(String::formatted("Open in {}", af->name()), af->icon().bitmap_for_size(16), [this, handler](auto&) {
|
||||||
|
|
|
@ -10,4 +10,4 @@ set(SOURCES
|
||||||
)
|
)
|
||||||
|
|
||||||
serenity_bin(LaunchServer)
|
serenity_bin(LaunchServer)
|
||||||
target_link_libraries(LaunchServer LibCore LibIPC LibGUI)
|
target_link_libraries(LaunchServer LibCore LibIPC LibDesktop)
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
#include <AK/LexicalPath.h>
|
#include <AK/LexicalPath.h>
|
||||||
#include <AK/StringBuilder.h>
|
#include <AK/StringBuilder.h>
|
||||||
#include <LibCore/ConfigFile.h>
|
#include <LibCore/ConfigFile.h>
|
||||||
#include <LibGUI/AppFile.h>
|
#include <LibDesktop/AppFile.h>
|
||||||
#include <serenity.h>
|
#include <serenity.h>
|
||||||
#include <spawn.h>
|
#include <spawn.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -97,7 +97,7 @@ Launcher& Launcher::the()
|
||||||
|
|
||||||
void Launcher::load_handlers(const String& af_dir)
|
void Launcher::load_handlers(const String& af_dir)
|
||||||
{
|
{
|
||||||
GUI::AppFile::for_each([&](auto af) {
|
Desktop::AppFile::for_each([&](auto af) {
|
||||||
auto app_name = af->name();
|
auto app_name = af->name();
|
||||||
auto app_executable = af->executable();
|
auto app_executable = af->executable();
|
||||||
HashTable<String> file_types;
|
HashTable<String> file_types;
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
#include <AK/HashTable.h>
|
#include <AK/HashTable.h>
|
||||||
#include <AK/URL.h>
|
#include <AK/URL.h>
|
||||||
#include <LibCore/ConfigFile.h>
|
#include <LibCore/ConfigFile.h>
|
||||||
#include <LibGUI/AppFile.h>
|
#include <LibDesktop/AppFile.h>
|
||||||
|
|
||||||
namespace LaunchServer {
|
namespace LaunchServer {
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ public:
|
||||||
Launcher();
|
Launcher();
|
||||||
static Launcher& the();
|
static Launcher& the();
|
||||||
|
|
||||||
void load_handlers(const String& af_dir = GUI::AppFile::APP_FILES_DIRECTORY);
|
void load_handlers(const String& af_dir = Desktop::AppFile::APP_FILES_DIRECTORY);
|
||||||
void load_config(const Core::ConfigFile&);
|
void load_config(const Core::ConfigFile&);
|
||||||
bool open_url(const URL&, const String& handler_name);
|
bool open_url(const URL&, const String& handler_name);
|
||||||
Vector<String> handlers_for_url(const URL&);
|
Vector<String> handlers_for_url(const URL&);
|
||||||
|
|
|
@ -4,4 +4,4 @@ set(SOURCES
|
||||||
)
|
)
|
||||||
|
|
||||||
serenity_bin(SystemMenu)
|
serenity_bin(SystemMenu)
|
||||||
target_link_libraries(SystemMenu LibGUI)
|
target_link_libraries(SystemMenu LibGUI LibDesktop)
|
||||||
|
|
|
@ -30,9 +30,9 @@
|
||||||
#include <LibCore/ConfigFile.h>
|
#include <LibCore/ConfigFile.h>
|
||||||
#include <LibCore/DirIterator.h>
|
#include <LibCore/DirIterator.h>
|
||||||
#include <LibCore/StandardPaths.h>
|
#include <LibCore/StandardPaths.h>
|
||||||
|
#include <LibDesktop/AppFile.h>
|
||||||
#include <LibGUI/Action.h>
|
#include <LibGUI/Action.h>
|
||||||
#include <LibGUI/ActionGroup.h>
|
#include <LibGUI/ActionGroup.h>
|
||||||
#include <LibGUI/AppFile.h>
|
|
||||||
#include <LibGUI/Application.h>
|
#include <LibGUI/Application.h>
|
||||||
#include <LibGUI/FileIconProvider.h>
|
#include <LibGUI/FileIconProvider.h>
|
||||||
#include <LibGUI/Icon.h>
|
#include <LibGUI/Icon.h>
|
||||||
|
@ -103,7 +103,7 @@ int main(int argc, char** argv)
|
||||||
Vector<String> discover_apps_and_categories()
|
Vector<String> discover_apps_and_categories()
|
||||||
{
|
{
|
||||||
HashTable<String> seen_app_categories;
|
HashTable<String> seen_app_categories;
|
||||||
GUI::AppFile::for_each([&](auto af) {
|
Desktop::AppFile::for_each([&](auto af) {
|
||||||
g_apps.append({ af->executable(), af->name(), af->category() });
|
g_apps.append({ af->executable(), af->name(), af->category() });
|
||||||
seen_app_categories.set(af->category());
|
seen_app_categories.set(af->category());
|
||||||
});
|
});
|
||||||
|
|
|
@ -6,4 +6,4 @@ set(SOURCES
|
||||||
)
|
)
|
||||||
|
|
||||||
serenity_bin(Taskbar)
|
serenity_bin(Taskbar)
|
||||||
target_link_libraries(Taskbar LibGUI)
|
target_link_libraries(Taskbar LibGUI LibDesktop)
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
#include <AK/SharedBuffer.h>
|
#include <AK/SharedBuffer.h>
|
||||||
#include <LibCore/ConfigFile.h>
|
#include <LibCore/ConfigFile.h>
|
||||||
#include <LibCore/StandardPaths.h>
|
#include <LibCore/StandardPaths.h>
|
||||||
#include <LibGUI/AppFile.h>
|
#include <LibDesktop/AppFile.h>
|
||||||
#include <LibGUI/BoxLayout.h>
|
#include <LibGUI/BoxLayout.h>
|
||||||
#include <LibGUI/Button.h>
|
#include <LibGUI/Button.h>
|
||||||
#include <LibGUI/Desktop.h>
|
#include <LibGUI/Desktop.h>
|
||||||
|
@ -111,8 +111,8 @@ void TaskbarWindow::create_quick_launch_bar()
|
||||||
// FIXME: Core::ConfigFile does not keep the order of the entries.
|
// FIXME: Core::ConfigFile does not keep the order of the entries.
|
||||||
for (auto& name : config->keys(quick_launch)) {
|
for (auto& name : config->keys(quick_launch)) {
|
||||||
auto af_name = config->read_entry(quick_launch, name);
|
auto af_name = config->read_entry(quick_launch, name);
|
||||||
auto af_path = String::formatted("{}/{}", GUI::AppFile::APP_FILES_DIRECTORY, af_name);
|
auto af_path = String::formatted("{}/{}", Desktop::AppFile::APP_FILES_DIRECTORY, af_name);
|
||||||
auto af = GUI::AppFile::open(af_path);
|
auto af = Desktop::AppFile::open(af_path);
|
||||||
if (!af->is_valid())
|
if (!af->is_valid())
|
||||||
continue;
|
continue;
|
||||||
auto app_executable = af->executable();
|
auto app_executable = af->executable();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue