Explorar el Código

Launcher loads applications from Launcher.ini, is started by default, and is resized automatically

Co-Authored-By: Andreas Kling <awesomekling@gmail.com>
Christopher Dumas hace 6 años
padre
commit
dd84dcf31f

+ 12 - 8
Applications/Launcher/main.cpp

@@ -4,6 +4,7 @@
 #include <LibGUI/GButton.h>
 #include <LibGUI/GApplication.h>
 #include <LibGUI/GBoxLayout.h>
+#include <LibCore/CConfigFile.h>
 #include <sys/wait.h>
 #include <signal.h>
 #include <unistd.h>
@@ -60,22 +61,25 @@ private:
 
 GWindow* make_launcher_window()
 {
+    auto config = CConfigFile::get_for_app("Launcher");
+
     auto* window = new GWindow;
     window->set_title("Launcher");
-    window->set_rect(50, 50, 300, 60);
+    window->set_rect(50, 50,
+                     50, config->groups().size() * 55);
 
     auto* widget = new GWidget;
     widget->set_fill_with_background_color(true);
-    widget->set_layout(make<GBoxLayout>(Orientation::Horizontal));
+    widget->set_layout(make<GBoxLayout>(Orientation::Vertical));
     widget->layout()->set_margins({ 5, 5, 5, 5 });
     window->set_main_widget(widget);
 
-    new LauncherButton("Terminal", "/res/icons/Terminal.png", "/bin/Terminal", widget);
-    new LauncherButton("FontEditor", "/res/icons/FontEditor.png", "/bin/FontEditor", widget);
-    new LauncherButton("FileManager", "/res/icons/32x32/filetype-folder.png", "/bin/FileManager", widget);
-    new LauncherButton("TextEditor", "/res/icons/TextEditor.png", "/bin/TextEditor", widget);
-    new LauncherButton("VisualBuilder", "/res/icons/32x32/app-visual-builder.png", "/bin/VisualBuilder", widget);
-    new LauncherButton("IRCClient", "/res/icons/32x32/app-irc-client.png", "/bin/IRCClient", widget);
+    for (auto& group : config->groups()) {
+        new LauncherButton(config->read_entry(group, "Name", group),
+                           config->read_entry(group, "Icon", ""),
+                           config->read_entry(group, "Path", ""),
+                           widget);
+    }
 
     return window;
 }

+ 35 - 0
Base/home/anon/Launcher.ini

@@ -0,0 +1,35 @@
+[Terminal]
+Path=/bin/Terminal
+Icon=/res/icons/Terminal.png
+
+[FontEditor]
+Path=/bin/FontEditor
+Icon=/res/icons/FontEditor.png
+
+[TextEditor]
+Path=/bin/TextEditor
+Icon=/res/icons/TextEditor.png
+
+[VisualBuilder]
+Path=/bin/VisualBuilder
+Icon=/res/icons/32x32/app-visual-builder.png
+
+[IRCClient]
+Path=/bin/IRCClient
+Icon=/res/icons/32x32/app-irc-client.png
+
+[FileManager]
+Path=/bin/FileManager
+Icon=/res/icons/32x32/filetype-folder.png
+
+[Minesweeper]
+Path=/bin/Minesweeper
+Icon=/res/icons/minesweeper/mine.png
+
+[Snake]
+Path=/bin/Snake
+Icon=/res/icons/snake/eggplant.png
+
+[ProcessManager]
+Path=/bin/ProcessManager
+Icon=/res/icons/32x32/msgbox-warning.png

+ 1 - 1
Kernel/init.cpp

@@ -27,7 +27,7 @@
 #include <Kernel/Devices/DebugLogDevice.h>
 
 #define SPAWN_TERMINAL
-//#define SPAWN_LAUNCHER
+#define SPAWN_LAUNCHER
 //#define SPAWN_GUITEST2
 //#define SPAWN_FILE_MANAGER
 //#define SPAWN_PROCESS_MANAGER

+ 0 - 7
Servers/WindowServer/WSWindowManager.cpp

@@ -72,15 +72,8 @@ WSWindowManager::WSWindowManager()
 
     Vector<AppMenuItem> apps;
     apps.append({ "/bin/Terminal", "Open Terminal..." });
-    apps.append({ "/bin/FontEditor", "Open FontEditor..." });
-    apps.append({ "/bin/TextEditor", "Open TextEditor..." });
-    apps.append({ "/bin/VisualBuilder", "Open VisualBuilder..." });
-    apps.append({ "/bin/IRCClient", "Open IRCClient..." });
     apps.append({ "/bin/FileManager", "Open FileManager..." });
     apps.append({ "/bin/ProcessManager", "Open ProcessManager..." });
-    apps.append({ "/bin/HelloWorld", "Open HelloWorld..." });
-    apps.append({ "/bin/Minesweeper", "Play Minesweeper..." });
-    apps.append({ "/bin/Snake", "Play Snake..." });
 
     {
         byte system_menu_name[] = { 0xf8, 0 };