From 3d6b0e60ca668a627c5519465eaf777de8a944a4 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Mon, 2 Jan 2023 11:59:48 -0500 Subject: [PATCH] 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. --- Base/res/apps/BrowserSettings.af | 1 + Base/res/apps/CalendarSettings.af | 1 + Base/res/apps/ClockSettings.af | 1 + Base/res/apps/DisplaySettings.af | 1 + Base/res/apps/GamesSettings.af | 1 + Base/res/apps/Keyboard.af | 1 + Base/res/apps/MailSettings.af | 1 + Base/res/apps/MouseSettings.af | 1 + Base/res/apps/NetworkSettings.af | 1 + Base/res/apps/TerminalSettings.af | 1 + Userland/Libraries/LibDesktop/AppFile.cpp | 5 +++++ Userland/Libraries/LibDesktop/AppFile.h | 1 + Userland/Services/Taskbar/main.cpp | 13 ++++--------- 13 files changed, 20 insertions(+), 9 deletions(-) diff --git a/Base/res/apps/BrowserSettings.af b/Base/res/apps/BrowserSettings.af index 4e8b837e050..fcdbd2fc68b 100644 --- a/Base/res/apps/BrowserSettings.af +++ b/Base/res/apps/BrowserSettings.af @@ -3,3 +3,4 @@ Name=Browser Settings Executable=/bin/BrowserSettings Category=Settings Description=Configure Browser +ExcludeFromSystemMenu=true diff --git a/Base/res/apps/CalendarSettings.af b/Base/res/apps/CalendarSettings.af index 8aeb9e3afa2..e164d001d4e 100644 --- a/Base/res/apps/CalendarSettings.af +++ b/Base/res/apps/CalendarSettings.af @@ -3,3 +3,4 @@ Name=Calendar Settings Executable=/bin/CalendarSettings Category=Settings Description=Configure the Calendar application and applet +ExcludeFromSystemMenu=true diff --git a/Base/res/apps/ClockSettings.af b/Base/res/apps/ClockSettings.af index 31087de388c..baa3d417113 100644 --- a/Base/res/apps/ClockSettings.af +++ b/Base/res/apps/ClockSettings.af @@ -3,3 +3,4 @@ Name=Clock Settings Executable=/bin/ClockSettings Category=Settings Description=Configure the system clock +ExcludeFromSystemMenu=true diff --git a/Base/res/apps/DisplaySettings.af b/Base/res/apps/DisplaySettings.af index c8f30e39d4e..262797ab353 100644 --- a/Base/res/apps/DisplaySettings.af +++ b/Base/res/apps/DisplaySettings.af @@ -3,3 +3,4 @@ Name=Display Settings Executable=/bin/DisplaySettings Category=Settings Description=Configure your display hardware, desktop wallpaper, fonts, etc. +ExcludeFromSystemMenu=true diff --git a/Base/res/apps/GamesSettings.af b/Base/res/apps/GamesSettings.af index bac017ee0ac..c4260df343b 100644 --- a/Base/res/apps/GamesSettings.af +++ b/Base/res/apps/GamesSettings.af @@ -3,3 +3,4 @@ Name=Games Settings Executable=/bin/GamesSettings Category=Settings Description=Configure games +ExcludeFromSystemMenu=true diff --git a/Base/res/apps/Keyboard.af b/Base/res/apps/Keyboard.af index fae79b4951c..a72256ce90e 100644 --- a/Base/res/apps/Keyboard.af +++ b/Base/res/apps/Keyboard.af @@ -3,3 +3,4 @@ Name=Keyboard Settings Executable=/bin/KeyboardSettings Category=Settings Description=Customize your keyboard layout and other settings +ExcludeFromSystemMenu=true diff --git a/Base/res/apps/MailSettings.af b/Base/res/apps/MailSettings.af index 4d92c6135e2..eab1cb6316b 100644 --- a/Base/res/apps/MailSettings.af +++ b/Base/res/apps/MailSettings.af @@ -3,3 +3,4 @@ Name=Mail Settings Executable=/bin/MailSettings Category=Settings Description=Configure the Mail application +ExcludeFromSystemMenu=true diff --git a/Base/res/apps/MouseSettings.af b/Base/res/apps/MouseSettings.af index d50c5e239d8..6dd13a9bb39 100644 --- a/Base/res/apps/MouseSettings.af +++ b/Base/res/apps/MouseSettings.af @@ -3,3 +3,4 @@ Name=Mouse Settings Executable=/bin/MouseSettings Category=Settings Description=Customize your mouse and cursor settings +ExcludeFromSystemMenu=true diff --git a/Base/res/apps/NetworkSettings.af b/Base/res/apps/NetworkSettings.af index d9a3e318c16..848f5a725b1 100644 --- a/Base/res/apps/NetworkSettings.af +++ b/Base/res/apps/NetworkSettings.af @@ -4,3 +4,4 @@ Executable=/bin/NetworkSettings RequiresRoot=true Category=Settings Description=Configure network connections +ExcludeFromSystemMenu=true diff --git a/Base/res/apps/TerminalSettings.af b/Base/res/apps/TerminalSettings.af index 36d29d8a3e8..b6080289993 100644 --- a/Base/res/apps/TerminalSettings.af +++ b/Base/res/apps/TerminalSettings.af @@ -3,3 +3,4 @@ Name=Terminal Settings Executable=/bin/TerminalSettings Category=Settings Description=Configure the Terminal appearance and behavior +ExcludeFromSystemMenu=true diff --git a/Userland/Libraries/LibDesktop/AppFile.cpp b/Userland/Libraries/LibDesktop/AppFile.cpp index c28eb7ae89d..e118160d6fc 100644 --- a/Userland/Libraries/LibDesktop/AppFile.cpp +++ b/Userland/Libraries/LibDesktop/AppFile.cpp @@ -112,6 +112,11 @@ bool AppFile::requires_root() const 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 AppFile::launcher_mime_types() const { Vector mime_types; diff --git a/Userland/Libraries/LibDesktop/AppFile.h b/Userland/Libraries/LibDesktop/AppFile.h index 69f5dbbdf6b..d272d466882 100644 --- a/Userland/Libraries/LibDesktop/AppFile.h +++ b/Userland/Libraries/LibDesktop/AppFile.h @@ -34,6 +34,7 @@ public: GUI::Icon icon() const; bool run_in_terminal() const; bool requires_root() const; + bool exclude_from_system_menu() const; Vector launcher_mime_types() const; Vector launcher_file_types() const; Vector launcher_protocols() const; diff --git a/Userland/Services/Taskbar/main.cpp b/Userland/Services/Taskbar/main.cpp index af5626fadfa..6a46a24e203 100644 --- a/Userland/Services/Taskbar/main.cpp +++ b/Userland/Services/Taskbar/main.cpp @@ -96,6 +96,8 @@ ErrorOr> discover_apps_and_categories() { HashTable seen_app_categories; Desktop::AppFile::for_each([&](auto af) { + if (af->exclude_from_system_menu()) + return; 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() }); seen_app_categories.set(af->category()); @@ -159,19 +161,12 @@ ErrorOr> build_system_menu(GUI::Window& window) app_category_menus.set(category, category_menu); }; - for (auto const& category : sorted_app_categories) { - if (category != "Settings"sv) - create_category_menu(category); - } + for (auto const& category : sorted_app_categories) + create_category_menu(category); // Then we create and insert all the app menu items into the right place. int app_identifier = 0; for (auto const& app : g_apps) { - if (app.category == "Settings"sv) { - ++app_identifier; - continue; - } - auto icon = app.icon.bitmap_for_size(16); if constexpr (SYSTEM_MENU_DEBUG) {