mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 08:17:34 +00:00
Move apps into a top-level Applications/ directory.
This commit is contained in:
parent
29f2a22d34
commit
2cf1dd5b6f
27 changed files with 30 additions and 26 deletions
3
Applications/Launcher/.gitignore
vendored
Normal file
3
Applications/Launcher/.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
*.o
|
||||
*.d
|
||||
Launcher
|
34
Applications/Launcher/Makefile
Normal file
34
Applications/Launcher/Makefile
Normal file
|
@ -0,0 +1,34 @@
|
|||
OBJS = \
|
||||
main.o
|
||||
|
||||
APP = Launcher
|
||||
|
||||
ARCH_FLAGS =
|
||||
STANDARD_FLAGS = -std=c++17 -nostdinc++ -nostdlib -nostdinc
|
||||
USERLAND_FLAGS = -ffreestanding -fno-stack-protector -fno-ident
|
||||
WARNING_FLAGS = -Wextra -Wall -Wundef -Wcast-qual -Wwrite-strings
|
||||
FLAVOR_FLAGS = -march=i386 -m32 -fno-exceptions -fno-rtti -fmerge-all-constants -fno-unroll-loops -fno-pie -fno-pic
|
||||
OPTIMIZATION_FLAGS = -Oz -fno-asynchronous-unwind-tables
|
||||
INCLUDE_FLAGS = -I../.. -I. -I../../LibC
|
||||
|
||||
DEFINES = -DSERENITY -DSANITIZE_PTRS -DUSERLAND
|
||||
|
||||
CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(USERLAND_FLAGS) $(FLAVOR_FLAGS) $(ARCH_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS) $(DEFINES)
|
||||
CXX = clang
|
||||
LD = ld
|
||||
AR = ar
|
||||
LDFLAGS = -static --strip-debug -melf_i386 -e _start --gc-sections
|
||||
|
||||
all: $(APP)
|
||||
|
||||
$(APP): $(OBJS)
|
||||
$(LD) -o $(APP) $(LDFLAGS) $(OBJS) ../LibGUI/LibGUI.a ../LibC/LibC.a
|
||||
|
||||
.cpp.o:
|
||||
@echo "CXX $<"; $(CXX) $(CXXFLAGS) -o $@ -c $<
|
||||
|
||||
-include $(OBJS:%.o=%.d)
|
||||
|
||||
clean:
|
||||
@echo "CLEAN"; rm -f $(APPS) $(OBJS) *.d
|
||||
|
80
Applications/Launcher/main.cpp
Normal file
80
Applications/Launcher/main.cpp
Normal file
|
@ -0,0 +1,80 @@
|
|||
#include <SharedGraphics/GraphicsBitmap.h>
|
||||
#include <LibGUI/GWindow.h>
|
||||
#include <LibGUI/GWidget.h>
|
||||
#include <LibGUI/GButton.h>
|
||||
#include <LibGUI/GEventLoop.h>
|
||||
#include <sys/wait.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
static GWindow* make_launcher_window();
|
||||
|
||||
void handle_sigchld(int)
|
||||
{
|
||||
dbgprintf("Launcher(%d) Got SIGCHLD\n", getpid());
|
||||
int pid = waitpid(-1, nullptr, 0);
|
||||
dbgprintf("Launcher(%d) waitpid() returned %d\n", getpid(), pid);
|
||||
ASSERT(pid > 0);
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
signal(SIGCHLD, handle_sigchld);
|
||||
|
||||
GEventLoop loop;
|
||||
|
||||
auto* launcher_window = make_launcher_window();
|
||||
launcher_window->set_should_exit_app_on_close(true);
|
||||
launcher_window->show();
|
||||
|
||||
return loop.exec();
|
||||
}
|
||||
|
||||
class LauncherButton final : public GButton {
|
||||
public:
|
||||
LauncherButton(const String& icon_path, const String& exec_path, GWidget* parent)
|
||||
: GButton(parent)
|
||||
, m_executable_path(exec_path)
|
||||
{
|
||||
set_icon(GraphicsBitmap::load_from_file(icon_path, { 32, 32 }));
|
||||
resize(50, 50);
|
||||
on_click = [this] (GButton&) {
|
||||
pid_t child_pid = fork();
|
||||
if (!child_pid) {
|
||||
int rc = execl(m_executable_path.characters(), m_executable_path.characters(), nullptr);
|
||||
if (rc < 0)
|
||||
perror("execl");
|
||||
}
|
||||
};
|
||||
}
|
||||
virtual ~LauncherButton() { }
|
||||
|
||||
private:
|
||||
String m_executable_path;
|
||||
};
|
||||
|
||||
GWindow* make_launcher_window()
|
||||
{
|
||||
auto* window = new GWindow;
|
||||
window->set_title("Launcher");
|
||||
window->set_rect(50, 50, 300, 60);
|
||||
|
||||
auto* widget = new GWidget;
|
||||
window->set_main_widget(widget);
|
||||
|
||||
auto* terminal_button = new LauncherButton("/res/icons/Terminal.rgb", "/bin/Terminal", widget);
|
||||
terminal_button->move_to(5, 5);
|
||||
|
||||
auto* font_editor_button = new LauncherButton("/res/icons/FontEditor.rgb", "/bin/FontEditor", widget);
|
||||
font_editor_button->move_to(60, 5);
|
||||
|
||||
auto* file_manager_button = new LauncherButton("/res/icons/FileManager.rgb", "/bin/FileManager", widget);
|
||||
file_manager_button->move_to(115, 5);
|
||||
|
||||
auto* guitest_button = new LauncherButton("/res/icons/generic.rgb", "/bin/guitest", widget);
|
||||
guitest_button->move_to(170, 5);
|
||||
|
||||
return window;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue