Jelajahi Sumber

Taskbar: Show Settings app instead of Settings app category

The Settings app is basically a viewer for the Settings app category
anyway, so let's just direct users there instead of having the various
settings apps in the start menu.
Andreas Kling 4 tahun lalu
induk
melakukan
4e2c5cd19e
1 mengubah file dengan 18 tambahan dan 2 penghapusan
  1. 18 2
      Userland/Services/Taskbar/main.cpp

+ 18 - 2
Userland/Services/Taskbar/main.cpp

@@ -158,12 +158,17 @@ NonnullRefPtr<GUI::Menu> build_system_menu()
         app_category_menus.set(category, category_menu);
     };
 
-    for (const auto& category : sorted_app_categories)
-        create_category_menu(category);
+    for (const auto& category : sorted_app_categories) {
+        if (category != "Settings"sv)
+            create_category_menu(category);
+    }
 
     // Then we create and insert all the app menu items into the right place.
     int app_identifier = 0;
     for (const auto& app : g_apps) {
+        if (app.category == "Settings"sv)
+            continue;
+
         auto icon = GUI::FileIconProvider::icon_for_executable(app.executable).bitmap_for_size(16);
 
         if constexpr (SYSTEM_MENU_DEBUG) {
@@ -231,6 +236,17 @@ NonnullRefPtr<GUI::Menu> build_system_menu()
         }
     }
 
+    system_menu->add_action(GUI::Action::create("Settings", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-settings.png"), [](auto&) {
+        pid_t child_pid;
+        const char* argv[] = { "/bin/Settings", nullptr };
+        if ((errno = posix_spawn(&child_pid, "/bin/Settings", nullptr, nullptr, const_cast<char**>(argv), environ))) {
+            perror("posix_spawn");
+        } else {
+            if (disown(child_pid) < 0)
+                perror("disown");
+        }
+    }));
+
     system_menu->add_separator();
     system_menu->add_action(GUI::Action::create("Help", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-help.png"), [](auto&) {
         pid_t child_pid;