1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:47:44 +00:00

Terminal+LibVT: Use GUI::AppFile

This commit is contained in:
Linus Groh 2020-12-27 19:13:57 +01:00 committed by Andreas Kling
parent 6f95a6ca27
commit ddeb261bc2
2 changed files with 10 additions and 6 deletions

View file

@ -434,6 +434,11 @@ int main(int argc, char** argv)
return 1;
}
if (unveil("/etc/FileIconProvider.ini", "r") < 0) {
perror("unveil");
return 1;
}
if (unveil("/tmp/portal/launch", "rw") < 0) {
perror("unveil");
return 1;

View file

@ -36,6 +36,7 @@
#include <LibCore/MimeData.h>
#include <LibDesktop/Launcher.h>
#include <LibGUI/Action.h>
#include <LibGUI/AppFile.h>
#include <LibGUI/Application.h>
#include <LibGUI/Clipboard.h>
#include <LibGUI/DragOperation.h>
@ -857,12 +858,10 @@ void TerminalWidget::context_menu_event(GUI::ContextMenuEvent& event)
// Then add them to the context menu.
// FIXME: Adapt this code when we actually support calling LaunchServer with a specific handler in mind.
for (auto& handler : handlers) {
auto af_path = String::format("/res/apps/%s.af", LexicalPath(handler).basename().characters());
auto af = Core::ConfigFile::open(af_path);
auto handler_name = af->read_entry("App", "Name", handler);
auto handler_executable = af->read_entry("App", "Executable");
auto handler_icon = GUI::FileIconProvider::icon_for_path(handler_executable).bitmap_for_size(16);
auto action = GUI::Action::create(String::format("Open in %s", handler_name.characters()), handler_icon, [this, handler](auto&) {
auto af = GUI::AppFile::get_for_app(LexicalPath(handler).basename());
if (!af->is_valid())
continue;
auto action = GUI::Action::create(String::formatted("Open in {}", af->name()), af->icon().bitmap_for_size(16), [this, handler](auto&) {
Desktop::Launcher::open(m_context_menu_href, handler);
});