mirror of
https://github.com/SerenityOS/serenity
synced 2024-09-06 08:56:40 +00:00
LibDesktop+Taskbar: Add an option to exclude apps from the system menu
We currently hard-code excluding Settings apps from the system menu. This adds an "ExcludeFromSystemMenu" option to the AppFile configuration to selectively exclude these apps, which all Settings app now set. This is to allow selectively excluding a few Demo apps in a future commit.
This commit is contained in:
parent
10bf86de2c
commit
3d6b0e60ca
|
@ -3,3 +3,4 @@ Name=Browser Settings
|
||||||
Executable=/bin/BrowserSettings
|
Executable=/bin/BrowserSettings
|
||||||
Category=Settings
|
Category=Settings
|
||||||
Description=Configure Browser
|
Description=Configure Browser
|
||||||
|
ExcludeFromSystemMenu=true
|
||||||
|
|
|
@ -3,3 +3,4 @@ Name=Calendar Settings
|
||||||
Executable=/bin/CalendarSettings
|
Executable=/bin/CalendarSettings
|
||||||
Category=Settings
|
Category=Settings
|
||||||
Description=Configure the Calendar application and applet
|
Description=Configure the Calendar application and applet
|
||||||
|
ExcludeFromSystemMenu=true
|
||||||
|
|
|
@ -3,3 +3,4 @@ Name=Clock Settings
|
||||||
Executable=/bin/ClockSettings
|
Executable=/bin/ClockSettings
|
||||||
Category=Settings
|
Category=Settings
|
||||||
Description=Configure the system clock
|
Description=Configure the system clock
|
||||||
|
ExcludeFromSystemMenu=true
|
||||||
|
|
|
@ -3,3 +3,4 @@ Name=Display Settings
|
||||||
Executable=/bin/DisplaySettings
|
Executable=/bin/DisplaySettings
|
||||||
Category=Settings
|
Category=Settings
|
||||||
Description=Configure your display hardware, desktop wallpaper, fonts, etc.
|
Description=Configure your display hardware, desktop wallpaper, fonts, etc.
|
||||||
|
ExcludeFromSystemMenu=true
|
||||||
|
|
|
@ -3,3 +3,4 @@ Name=Games Settings
|
||||||
Executable=/bin/GamesSettings
|
Executable=/bin/GamesSettings
|
||||||
Category=Settings
|
Category=Settings
|
||||||
Description=Configure games
|
Description=Configure games
|
||||||
|
ExcludeFromSystemMenu=true
|
||||||
|
|
|
@ -3,3 +3,4 @@ Name=Keyboard Settings
|
||||||
Executable=/bin/KeyboardSettings
|
Executable=/bin/KeyboardSettings
|
||||||
Category=Settings
|
Category=Settings
|
||||||
Description=Customize your keyboard layout and other settings
|
Description=Customize your keyboard layout and other settings
|
||||||
|
ExcludeFromSystemMenu=true
|
||||||
|
|
|
@ -3,3 +3,4 @@ Name=Mail Settings
|
||||||
Executable=/bin/MailSettings
|
Executable=/bin/MailSettings
|
||||||
Category=Settings
|
Category=Settings
|
||||||
Description=Configure the Mail application
|
Description=Configure the Mail application
|
||||||
|
ExcludeFromSystemMenu=true
|
||||||
|
|
|
@ -3,3 +3,4 @@ Name=Mouse Settings
|
||||||
Executable=/bin/MouseSettings
|
Executable=/bin/MouseSettings
|
||||||
Category=Settings
|
Category=Settings
|
||||||
Description=Customize your mouse and cursor settings
|
Description=Customize your mouse and cursor settings
|
||||||
|
ExcludeFromSystemMenu=true
|
||||||
|
|
|
@ -4,3 +4,4 @@ Executable=/bin/NetworkSettings
|
||||||
RequiresRoot=true
|
RequiresRoot=true
|
||||||
Category=Settings
|
Category=Settings
|
||||||
Description=Configure network connections
|
Description=Configure network connections
|
||||||
|
ExcludeFromSystemMenu=true
|
||||||
|
|
|
@ -3,3 +3,4 @@ Name=Terminal Settings
|
||||||
Executable=/bin/TerminalSettings
|
Executable=/bin/TerminalSettings
|
||||||
Category=Settings
|
Category=Settings
|
||||||
Description=Configure the Terminal appearance and behavior
|
Description=Configure the Terminal appearance and behavior
|
||||||
|
ExcludeFromSystemMenu=true
|
||||||
|
|
|
@ -112,6 +112,11 @@ bool AppFile::requires_root() const
|
||||||
return m_config->read_bool_entry("App", "RequiresRoot", false);
|
return m_config->read_bool_entry("App", "RequiresRoot", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AppFile::exclude_from_system_menu() const
|
||||||
|
{
|
||||||
|
return m_config->read_bool_entry("App", "ExcludeFromSystemMenu", false);
|
||||||
|
}
|
||||||
|
|
||||||
Vector<DeprecatedString> AppFile::launcher_mime_types() const
|
Vector<DeprecatedString> AppFile::launcher_mime_types() const
|
||||||
{
|
{
|
||||||
Vector<DeprecatedString> mime_types;
|
Vector<DeprecatedString> mime_types;
|
||||||
|
|
|
@ -34,6 +34,7 @@ public:
|
||||||
GUI::Icon icon() const;
|
GUI::Icon icon() const;
|
||||||
bool run_in_terminal() const;
|
bool run_in_terminal() const;
|
||||||
bool requires_root() const;
|
bool requires_root() const;
|
||||||
|
bool exclude_from_system_menu() const;
|
||||||
Vector<DeprecatedString> launcher_mime_types() const;
|
Vector<DeprecatedString> launcher_mime_types() const;
|
||||||
Vector<DeprecatedString> launcher_file_types() const;
|
Vector<DeprecatedString> launcher_file_types() const;
|
||||||
Vector<DeprecatedString> launcher_protocols() const;
|
Vector<DeprecatedString> launcher_protocols() const;
|
||||||
|
|
|
@ -96,6 +96,8 @@ ErrorOr<Vector<DeprecatedString>> discover_apps_and_categories()
|
||||||
{
|
{
|
||||||
HashTable<DeprecatedString> seen_app_categories;
|
HashTable<DeprecatedString> seen_app_categories;
|
||||||
Desktop::AppFile::for_each([&](auto af) {
|
Desktop::AppFile::for_each([&](auto af) {
|
||||||
|
if (af->exclude_from_system_menu())
|
||||||
|
return;
|
||||||
if (access(af->executable().characters(), X_OK) == 0) {
|
if (access(af->executable().characters(), X_OK) == 0) {
|
||||||
g_apps.append({ af->executable(), af->name(), af->category(), af->working_directory(), af->icon(), af->run_in_terminal(), af->requires_root() });
|
g_apps.append({ af->executable(), af->name(), af->category(), af->working_directory(), af->icon(), af->run_in_terminal(), af->requires_root() });
|
||||||
seen_app_categories.set(af->category());
|
seen_app_categories.set(af->category());
|
||||||
|
@ -159,19 +161,12 @@ ErrorOr<NonnullRefPtr<GUI::Menu>> build_system_menu(GUI::Window& window)
|
||||||
app_category_menus.set(category, category_menu);
|
app_category_menus.set(category, category_menu);
|
||||||
};
|
};
|
||||||
|
|
||||||
for (auto const& category : sorted_app_categories) {
|
for (auto const& category : sorted_app_categories)
|
||||||
if (category != "Settings"sv)
|
create_category_menu(category);
|
||||||
create_category_menu(category);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Then we create and insert all the app menu items into the right place.
|
// Then we create and insert all the app menu items into the right place.
|
||||||
int app_identifier = 0;
|
int app_identifier = 0;
|
||||||
for (auto const& app : g_apps) {
|
for (auto const& app : g_apps) {
|
||||||
if (app.category == "Settings"sv) {
|
|
||||||
++app_identifier;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto icon = app.icon.bitmap_for_size(16);
|
auto icon = app.icon.bitmap_for_size(16);
|
||||||
|
|
||||||
if constexpr (SYSTEM_MENU_DEBUG) {
|
if constexpr (SYSTEM_MENU_DEBUG) {
|
||||||
|
|
Loading…
Reference in a new issue