mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 11:17:44 +00:00
Launcher: Remove the Launcher app, and all hacks in support of it
The Launcher's functionality has been replaced by the app shortcuts in the system menu. There were various window management hacks to ensure that the launcher stayed below all other windows while also being movable, etc.
This commit is contained in:
parent
26f41c7ecb
commit
dd2900eda0
12 changed files with 2 additions and 164 deletions
|
@ -1,8 +0,0 @@
|
|||
include ../../Makefile.common
|
||||
|
||||
OBJS = \
|
||||
main.o
|
||||
|
||||
APP = Launcher
|
||||
|
||||
include ../Makefile.common
|
|
@ -1,94 +0,0 @@
|
|||
#include <LibCore/CConfigFile.h>
|
||||
#include <LibCore/CUserInfo.h>
|
||||
#include <LibGUI/GApplication.h>
|
||||
#include <LibGUI/GBoxLayout.h>
|
||||
#include <LibGUI/GButton.h>
|
||||
#include <LibGUI/GWidget.h>
|
||||
#include <LibGUI/GWindow.h>
|
||||
#include <LibDraw/GraphicsBitmap.h>
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static RefPtr<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 argc, char** argv)
|
||||
{
|
||||
if (chdir(get_current_user_home_path().characters()) < 0)
|
||||
perror("chdir");
|
||||
|
||||
GApplication app(argc, argv);
|
||||
|
||||
signal(SIGCHLD, handle_sigchld);
|
||||
|
||||
auto launcher_window = make_launcher_window();
|
||||
launcher_window->show();
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
||||
class LauncherButton final : public GButton {
|
||||
public:
|
||||
LauncherButton(const String& name, const String& icon_path, const String& exec_path, GWidget* parent)
|
||||
: GButton(parent)
|
||||
, m_executable_path(exec_path)
|
||||
{
|
||||
set_tooltip(name);
|
||||
set_button_style(ButtonStyle::CoolBar);
|
||||
set_icon(GraphicsBitmap::load_from_file(icon_path));
|
||||
set_preferred_size(50, 50);
|
||||
set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);
|
||||
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;
|
||||
};
|
||||
|
||||
RefPtr<GWindow> make_launcher_window()
|
||||
{
|
||||
auto config = CConfigFile::get_for_app("Launcher");
|
||||
auto vertical = config->read_bool_entry("Launcher", "Vertical", true);
|
||||
|
||||
auto window = GWindow::construct();
|
||||
window->set_title("Launcher");
|
||||
int launcher_size = (config->groups().size() - 1) * 50;
|
||||
window->set_rect(50, 50, vertical ? 50 : launcher_size, vertical ? launcher_size : 50);
|
||||
window->set_show_titlebar(false);
|
||||
window->set_window_type(GWindowType::Launcher);
|
||||
|
||||
auto widget = GWidget::construct();
|
||||
widget->set_fill_with_background_color(true);
|
||||
widget->set_layout(make<GBoxLayout>(vertical ? Orientation::Vertical : Orientation::Horizontal));
|
||||
widget->layout()->set_spacing(0);
|
||||
widget->layout()->set_margins({ 5, 0, 5, 0 });
|
||||
window->set_main_widget(widget);
|
||||
|
||||
for (auto& group : config->groups()) {
|
||||
if (group != "Launcher")
|
||||
new LauncherButton(config->read_entry(group, "Name", group),
|
||||
config->read_entry(group, "Icon", ""),
|
||||
config->read_entry(group, "Path", ""),
|
||||
widget);
|
||||
}
|
||||
|
||||
return window;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue