KeyboardSettings: Port to LibMain :^)

This commit is contained in:
Andreas Kling 2021-11-23 23:16:12 +01:00
parent 10b5393506
commit 31867bed5c
Notes: sideshowbarker 2024-07-18 00:45:59 +09:00
2 changed files with 12 additions and 33 deletions

View file

@ -13,4 +13,4 @@ set(SOURCES
)
serenity_app(KeyboardSettings ICON app-keyboard-settings)
target_link_libraries(KeyboardSettings LibGUI LibKeyboard LibConfig)
target_link_libraries(KeyboardSettings LibGUI LibKeyboard LibConfig LibMain)

View file

@ -6,51 +6,30 @@
*/
#include "KeyboardSettingsWidget.h"
#include <LibCore/System.h>
#include <LibGUI/Application.h>
#include <LibGUI/SettingsWindow.h>
#include <LibGUI/WindowServerConnection.h>
#include <LibMain/Main.h>
// Including this after to avoid LibIPC errors
#include <LibConfig/Client.h>
int main(int argc, char** argv)
ErrorOr<int> serenity_main(Main::Arguments arguments)
{
if (pledge("stdio rpath cpath wpath recvfd sendfd unix proc exec", nullptr) < 0) {
perror("pledge");
return 1;
}
auto app = GUI::Application::construct(argc, argv);
TRY(Core::System::pledge("stdio rpath cpath wpath recvfd sendfd unix proc exec", nullptr));
auto app = TRY(GUI::Application::try_create(arguments));
Config::pledge_domains("KeyboardSettings");
if (pledge("stdio rpath cpath wpath recvfd sendfd proc exec", nullptr) < 0) {
perror("pledge");
return 1;
}
if (unveil("/res", "r") < 0) {
perror("unveil");
return 1;
}
if (unveil("/bin/keymap", "x") < 0) {
perror("unveil");
return 1;
}
if (unveil("/proc/keymap", "r") < 0) {
perror("unveil");
return 1;
}
if (unveil(nullptr, nullptr)) {
perror("unveil");
return 1;
}
TRY(Core::System::pledge("stdio rpath cpath wpath recvfd sendfd proc exec", nullptr));
TRY(Core::System::unveil("/res", "r"));
TRY(Core::System::unveil("/bin/keymap", "x"));
TRY(Core::System::unveil("/proc/keymap", "r"));
TRY(Core::System::unveil(nullptr, nullptr));
auto app_icon = GUI::Icon::default_icon("app-keyboard-settings");
auto window = GUI::SettingsWindow::construct("Keyboard Settings");
auto window = TRY(GUI::SettingsWindow::try_create("Keyboard Settings"));
window->set_icon(app_icon.bitmap_for_size(16));
window->add_tab<KeyboardSettingsWidget>("Keyboard");