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:
Timothy Flynn 2023-01-02 11:59:48 -05:00 committed by Andreas Kling
parent 10bf86de2c
commit 3d6b0e60ca
13 changed files with 20 additions and 9 deletions

View file

@ -3,3 +3,4 @@ Name=Browser Settings
Executable=/bin/BrowserSettings
Category=Settings
Description=Configure Browser
ExcludeFromSystemMenu=true

View file

@ -3,3 +3,4 @@ Name=Calendar Settings
Executable=/bin/CalendarSettings
Category=Settings
Description=Configure the Calendar application and applet
ExcludeFromSystemMenu=true

View file

@ -3,3 +3,4 @@ Name=Clock Settings
Executable=/bin/ClockSettings
Category=Settings
Description=Configure the system clock
ExcludeFromSystemMenu=true

View file

@ -3,3 +3,4 @@ Name=Display Settings
Executable=/bin/DisplaySettings
Category=Settings
Description=Configure your display hardware, desktop wallpaper, fonts, etc.
ExcludeFromSystemMenu=true

View file

@ -3,3 +3,4 @@ Name=Games Settings
Executable=/bin/GamesSettings
Category=Settings
Description=Configure games
ExcludeFromSystemMenu=true

View file

@ -3,3 +3,4 @@ Name=Keyboard Settings
Executable=/bin/KeyboardSettings
Category=Settings
Description=Customize your keyboard layout and other settings
ExcludeFromSystemMenu=true

View file

@ -3,3 +3,4 @@ Name=Mail Settings
Executable=/bin/MailSettings
Category=Settings
Description=Configure the Mail application
ExcludeFromSystemMenu=true

View file

@ -3,3 +3,4 @@ Name=Mouse Settings
Executable=/bin/MouseSettings
Category=Settings
Description=Customize your mouse and cursor settings
ExcludeFromSystemMenu=true

View file

@ -4,3 +4,4 @@ Executable=/bin/NetworkSettings
RequiresRoot=true
Category=Settings
Description=Configure network connections
ExcludeFromSystemMenu=true

View file

@ -3,3 +3,4 @@ Name=Terminal Settings
Executable=/bin/TerminalSettings
Category=Settings
Description=Configure the Terminal appearance and behavior
ExcludeFromSystemMenu=true

View file

@ -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<DeprecatedString> AppFile::launcher_mime_types() const
{
Vector<DeprecatedString> mime_types;

View file

@ -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<DeprecatedString> launcher_mime_types() const;
Vector<DeprecatedString> launcher_file_types() const;
Vector<DeprecatedString> launcher_protocols() const;

View file

@ -96,6 +96,8 @@ ErrorOr<Vector<DeprecatedString>> discover_apps_and_categories()
{
HashTable<DeprecatedString> 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<NonnullRefPtr<GUI::Menu>> 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) {