WindowServer: Populate system menu with app launchers from /res/apps
The new system directory /res/apps now contains ".af" files describing applications (name, category, executable path, and icon.) These are used to populate the system menu with application shortcuts. This will replace the Launcher app. :^)
This commit is contained in:
parent
37329f829b
commit
b6a6f34caa
Notes:
sideshowbarker
2024-07-19 11:16:18 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/b6a6f34caae
13 changed files with 114 additions and 9 deletions
8
Base/res/apps/Browser.af
Normal file
8
Base/res/apps/Browser.af
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
[App]
|
||||||
|
Name=Browser
|
||||||
|
Executable=/bin/Browser
|
||||||
|
Category=Internet
|
||||||
|
|
||||||
|
[Icons]
|
||||||
|
16x16=/res/icons/16x16/filetype-html.png
|
||||||
|
32x32=/res/icons/32x32/filetype-html.png
|
8
Base/res/apps/Calculator.af
Normal file
8
Base/res/apps/Calculator.af
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
[App]
|
||||||
|
Name=Calculator
|
||||||
|
Executable=/bin/Calculator
|
||||||
|
Category=Utilities
|
||||||
|
|
||||||
|
[Icons]
|
||||||
|
16x16=
|
||||||
|
32x32=
|
8
Base/res/apps/ChanViewer.af
Normal file
8
Base/res/apps/ChanViewer.af
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
[App]
|
||||||
|
Name=ChanViewer
|
||||||
|
Executable=/bin/ChanViewer
|
||||||
|
Category=Internet
|
||||||
|
|
||||||
|
[Icons]
|
||||||
|
16x16=/res/icons/16x16/app-chanviewer.png
|
||||||
|
32x32=/res/icons/32x32/app-chanviewer.png
|
8
Base/res/apps/DisplayProperties.af
Normal file
8
Base/res/apps/DisplayProperties.af
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
[App]
|
||||||
|
Name=DisplayProperties
|
||||||
|
Executable=/bin/DisplayProperties
|
||||||
|
Category=Utilities
|
||||||
|
|
||||||
|
[Icons]
|
||||||
|
16x16=/res/icons/16x16/app-display-properties.png
|
||||||
|
32x32=/res/icons/32x32/app-display-properties.png
|
8
Base/res/apps/FileManager.af
Normal file
8
Base/res/apps/FileManager.af
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
[App]
|
||||||
|
Name=FileManager
|
||||||
|
Executable=/bin/FileManager
|
||||||
|
Category=Utilities
|
||||||
|
|
||||||
|
[Icons]
|
||||||
|
16x16=/res/icons/16x16/filetype-folder.png
|
||||||
|
32x32=/res/icons/32x32/filetype-folder.png
|
8
Base/res/apps/FontEditor.af
Normal file
8
Base/res/apps/FontEditor.af
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
[App]
|
||||||
|
Name=FontEditor
|
||||||
|
Executable=/bin/FontEditor
|
||||||
|
Category=FontEditor
|
||||||
|
|
||||||
|
[Icons]
|
||||||
|
16x16=/res/icons/16x16/app-font-editor.png
|
||||||
|
32x32=/res/icons/FontEditor.png
|
8
Base/res/apps/HackStudio.af
Normal file
8
Base/res/apps/HackStudio.af
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
[App]
|
||||||
|
Name=HackStudio
|
||||||
|
Executable=/bin/HackStudio
|
||||||
|
Category=Development
|
||||||
|
|
||||||
|
[Icons]
|
||||||
|
16x16=/res/icons/16x16/app-hack-studio.png
|
||||||
|
32x32=/res/icons/32x32/app-hack-studio.png
|
8
Base/res/apps/HexEditor.af
Normal file
8
Base/res/apps/HexEditor.af
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
[App]
|
||||||
|
Name=HexEditor
|
||||||
|
Executable=/bin/HexEditor
|
||||||
|
Category=Development
|
||||||
|
|
||||||
|
[Icons]
|
||||||
|
16x16=/res/icons/16x16/app-hexeditor.png
|
||||||
|
32x32=/res/icons/32x32/app-hexeditor.png
|
8
Base/res/apps/IRCClient.af
Normal file
8
Base/res/apps/IRCClient.af
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
[App]
|
||||||
|
Name=IRCClient
|
||||||
|
Executable=/bin/IRCClient
|
||||||
|
Category=Internet
|
||||||
|
|
||||||
|
[Icons]
|
||||||
|
16x16=/res/icons/16x16/app-irc-client.png
|
||||||
|
32x32=/res/icons/32x32/app-irc-client.png
|
7
Base/res/apps/PaintBrush.af
Normal file
7
Base/res/apps/PaintBrush.af
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
[App]
|
||||||
|
Name=PaintBrush
|
||||||
|
Executable=/bin/PaintBrush
|
||||||
|
|
||||||
|
[Icons]
|
||||||
|
16x16=/res/icons/16x16/app-paintbrush.png
|
||||||
|
32x32=/res/icons/32x32/app-paintbrush.png
|
8
Base/res/apps/SystemMonitor.af
Normal file
8
Base/res/apps/SystemMonitor.af
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
[App]
|
||||||
|
Name=SystemMonitor
|
||||||
|
Executable=/bin/SystemMonitor
|
||||||
|
Category=Utilities
|
||||||
|
|
||||||
|
[Icons]
|
||||||
|
16x16=/res/icons/16x16/app-system-monitor.png
|
||||||
|
32x32=/res/icons/32x32/app-system-monitor.png
|
8
Base/res/apps/Terminal.af
Normal file
8
Base/res/apps/Terminal.af
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
[App]
|
||||||
|
Name=Terminal
|
||||||
|
Executable=/bin/Terminal
|
||||||
|
Category=Utilities
|
||||||
|
|
||||||
|
[Icons]
|
||||||
|
16x16=/res/icons/16x16/app-terminal.png
|
||||||
|
32x32=/res/icons/32x32/app-terminal.png
|
|
@ -10,6 +10,7 @@
|
||||||
#include <AK/StdLibExtras.h>
|
#include <AK/StdLibExtras.h>
|
||||||
#include <AK/Vector.h>
|
#include <AK/Vector.h>
|
||||||
#include <LibCore/CTimer.h>
|
#include <LibCore/CTimer.h>
|
||||||
|
#include <LibCore/CDirIterator.h>
|
||||||
#include <LibDraw/CharacterBitmap.h>
|
#include <LibDraw/CharacterBitmap.h>
|
||||||
#include <LibDraw/Font.h>
|
#include <LibDraw/Font.h>
|
||||||
#include <LibDraw/PNGLoader.h>
|
#include <LibDraw/PNGLoader.h>
|
||||||
|
@ -45,16 +46,25 @@ WSWindowManager::WSWindowManager()
|
||||||
reload_config(false);
|
reload_config(false);
|
||||||
|
|
||||||
struct AppMenuItem {
|
struct AppMenuItem {
|
||||||
const char* binary_name;
|
String binary_name;
|
||||||
const char* description;
|
String description;
|
||||||
const char* icon_path;
|
String icon_path;
|
||||||
};
|
};
|
||||||
|
|
||||||
Vector<AppMenuItem> apps = {
|
Vector<AppMenuItem> apps;
|
||||||
{ "/bin/Terminal", "Open Terminal...", "/res/icons/16x16/app-terminal.png" },
|
|
||||||
{ "/bin/FileManager", "Open FileManager...", "/res/icons/16x16/filetype-folder.png" },
|
CDirIterator dt("/res/apps", CDirIterator::SkipDots);
|
||||||
{ "/bin/SystemMonitor", "Open SystemMonitor...", "/res/icons/16x16/app-system-monitor.png" }
|
while (dt.has_next()) {
|
||||||
};
|
auto af_name = dt.next_path();
|
||||||
|
auto af_path = String::format("/res/apps/%s", af_name.characters());
|
||||||
|
auto af = CConfigFile::open(af_path);
|
||||||
|
if (!af->has_key("App", "Name") || !af->has_key("App", "Executable"))
|
||||||
|
continue;
|
||||||
|
auto app_name = af->read_entry("App", "Name");
|
||||||
|
auto app_executable = af->read_entry("App", "Executable");
|
||||||
|
auto app_icon_path = af->read_entry("Icons", "16x16");
|
||||||
|
apps.append({ app_executable, app_name, app_icon_path });
|
||||||
|
}
|
||||||
|
|
||||||
u8 system_menu_name[] = { 0xc3, 0xb8, 0 };
|
u8 system_menu_name[] = { 0xc3, 0xb8, 0 };
|
||||||
m_system_menu = WSMenu::construct(nullptr, -1, String((const char*)system_menu_name));
|
m_system_menu = WSMenu::construct(nullptr, -1, String((const char*)system_menu_name));
|
||||||
|
@ -74,7 +84,7 @@ WSWindowManager::WSWindowManager()
|
||||||
if (item.identifier() >= 1 && item.identifier() <= 1u + apps.size() - 1) {
|
if (item.identifier() >= 1 && item.identifier() <= 1u + apps.size() - 1) {
|
||||||
if (fork() == 0) {
|
if (fork() == 0) {
|
||||||
const auto& bin = apps[item.identifier() - 1].binary_name;
|
const auto& bin = apps[item.identifier() - 1].binary_name;
|
||||||
execl(bin, bin, nullptr);
|
execl(bin.characters(), bin.characters(), nullptr);
|
||||||
ASSERT_NOT_REACHED();
|
ASSERT_NOT_REACHED();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue