1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 00:57:45 +00:00

Escalator: Port Escalator to GML Compiler

This commit is contained in:
Mr.UNIX 2024-01-09 23:07:42 +01:00 committed by Tim Schumacher
parent 7d63b8b95f
commit 9507157f04
6 changed files with 35 additions and 10 deletions

View file

@ -4,16 +4,13 @@ serenity_component(
TARGETS Escalator TARGETS Escalator
) )
stringify_gml(Escalator.gml EscalatorGML.h escalator_gml) compile_gml(Escalator.gml EscalatorGML.cpp)
set(SOURCES set(SOURCES
EscalatorGML.cpp
main.cpp main.cpp
EscalatorWindow.cpp EscalatorWindow.cpp
) )
set(GENERATED_SOURCES
EscalatorGML.h
)
serenity_app(Escalator ICON app-escalator) serenity_app(Escalator ICON app-escalator)
target_link_libraries(Escalator PRIVATE LibCore LibDesktop LibGfx LibGUI LibMain) target_link_libraries(Escalator PRIVATE LibCore LibDesktop LibGfx LibGUI LibMain)

View file

@ -1,4 +1,4 @@
@GUI::Widget { @Escalator::MainWidget {
fill_with_background_color: true fill_with_background_color: true
layout: @GUI::VerticalBoxLayout { layout: @GUI::VerticalBoxLayout {
margins: [4] margins: [4]

View file

@ -7,8 +7,8 @@
*/ */
#include "EscalatorWindow.h" #include "EscalatorWindow.h"
#include "MainWidget.h"
#include <AK/Assertions.h> #include <AK/Assertions.h>
#include <Applications/Escalator/EscalatorGML.h>
#include <LibCore/File.h> #include <LibCore/File.h>
#include <LibCore/SecretString.h> #include <LibCore/SecretString.h>
#include <LibCore/System.h> #include <LibCore/System.h>
@ -20,6 +20,7 @@
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
namespace Escalator {
EscalatorWindow::EscalatorWindow(StringView executable, Vector<StringView> arguments, EscalatorWindow::Options const& options) EscalatorWindow::EscalatorWindow(StringView executable, Vector<StringView> arguments, EscalatorWindow::Options const& options)
: m_arguments(move(arguments)) : m_arguments(move(arguments))
, m_executable(executable) , m_executable(executable)
@ -36,8 +37,8 @@ EscalatorWindow::EscalatorWindow(StringView executable, Vector<StringView> argum
set_resizable(false); set_resizable(false);
set_minimizable(false); set_minimizable(false);
auto main_widget = set_main_widget<GUI::Widget>(); auto main_widget = Escalator::MainWidget::try_create().release_value_but_fixme_should_propagate_errors();
main_widget->load_from_gml(escalator_gml).release_value_but_fixme_should_propagate_errors(); set_main_widget(main_widget);
RefPtr<GUI::Label> app_label = *main_widget->find_descendant_of_type_named<GUI::Label>("description"); RefPtr<GUI::Label> app_label = *main_widget->find_descendant_of_type_named<GUI::Label>("description");
@ -144,3 +145,4 @@ ErrorOr<void> EscalatorWindow::execute_command()
return {}; return {};
} }
}

View file

@ -17,6 +17,7 @@
#include <LibGUI/TextBox.h> #include <LibGUI/TextBox.h>
#include <LibGUI/Window.h> #include <LibGUI/Window.h>
namespace Escalator {
class EscalatorWindow final : public GUI::Window { class EscalatorWindow final : public GUI::Window {
C_OBJECT(EscalatorWindow) C_OBJECT(EscalatorWindow)
public: public:
@ -49,3 +50,4 @@ private:
RefPtr<GUI::Button> m_cancel_button; RefPtr<GUI::Button> m_cancel_button;
RefPtr<GUI::PasswordBox> m_password_input; RefPtr<GUI::PasswordBox> m_password_input;
}; };
}

View file

@ -0,0 +1,24 @@
/*
* Copyright (c) 2023, the SerenityOS developers
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibGUI/Widget.h>
namespace Escalator {
class MainWidget : public GUI::Widget {
C_OBJECT_ABSTRACT(MainWidget)
public:
static ErrorOr<NonnullRefPtr<MainWidget>> try_create();
virtual ~MainWidget() override = default;
private:
MainWidget() = default;
};
}

View file

@ -44,7 +44,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
} }
auto current_user = TRY(Core::Account::self()); auto current_user = TRY(Core::Account::self());
auto window = TRY(EscalatorWindow::try_create(executable_path.value(), command, EscalatorWindow::Options { description, current_user, preserve_env, forward_stdin, forward_stdout })); auto window = TRY(Escalator::EscalatorWindow::try_create(executable_path.value(), command, Escalator::EscalatorWindow::Options { description, current_user, preserve_env, forward_stdin, forward_stdout }));
if (current_user.uid() != 0) { if (current_user.uid() != 0) {
window->show(); window->show();