summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaciej <sppmacd@pm.me>2022-10-29 21:50:15 +0200
committerSam Atkins <atkinssj@gmail.com>2022-11-02 12:00:26 +0000
commit38fb3257c8ffdf11ca2ce7a8f949af7a3f79df9c (patch)
treef4b8cfe5eaf169138ee0dbb66d698388bcad6b7c
parentf4a5cd63bb158b580bad510a5ad4a7ac337e3f4b (diff)
downloadserenity-38fb3257c8ffdf11ca2ce7a8f949af7a3f79df9c.zip
NetworkSettings: Add command line option for opening a specific adapter
-rw-r--r--Userland/Applications/NetworkSettings/NetworkSettingsWidget.cpp6
-rw-r--r--Userland/Applications/NetworkSettings/NetworkSettingsWidget.h1
-rw-r--r--Userland/Applications/NetworkSettings/main.cpp12
3 files changed, 18 insertions, 1 deletions
diff --git a/Userland/Applications/NetworkSettings/NetworkSettingsWidget.cpp b/Userland/Applications/NetworkSettings/NetworkSettingsWidget.cpp
index 264edec5ac..33b96b9ccf 100644
--- a/Userland/Applications/NetworkSettings/NetworkSettingsWidget.cpp
+++ b/Userland/Applications/NetworkSettings/NetworkSettingsWidget.cpp
@@ -158,4 +158,10 @@ void NetworkSettingsWidget::apply_settings()
GUI::Process::spawn_or_show_error(window(), "/bin/NetworkServer"sv);
}
+void NetworkSettingsWidget::switch_adapter(String const& adapter)
+{
+ m_adapters_combobox->set_text(adapter, GUI::AllowCallback::No);
+ on_switch_adapter(adapter);
+}
+
}
diff --git a/Userland/Applications/NetworkSettings/NetworkSettingsWidget.h b/Userland/Applications/NetworkSettings/NetworkSettingsWidget.h
index decf4c13b3..6f7f949313 100644
--- a/Userland/Applications/NetworkSettings/NetworkSettingsWidget.h
+++ b/Userland/Applications/NetworkSettings/NetworkSettingsWidget.h
@@ -17,6 +17,7 @@ class NetworkSettingsWidget : public GUI::SettingsWindow::Tab {
public:
virtual void apply_settings() override;
+ void switch_adapter(String const& adapter);
private:
NetworkSettingsWidget();
diff --git a/Userland/Applications/NetworkSettings/main.cpp b/Userland/Applications/NetworkSettings/main.cpp
index 01c4d48507..d23906cd2d 100644
--- a/Userland/Applications/NetworkSettings/main.cpp
+++ b/Userland/Applications/NetworkSettings/main.cpp
@@ -5,6 +5,7 @@
*/
#include "NetworkSettingsWidget.h"
+#include <LibCore/ArgsParser.h>
#include <LibGUI/MessageBox.h>
#include <unistd.h>
@@ -28,6 +29,12 @@ ErrorOr<int> serenity_main(Main::Arguments args)
TRY(Core::System::unveil("/tmp/portal/window", "rw"));
TRY(Core::System::unveil(nullptr, nullptr));
+ String adapter;
+
+ Core::ArgsParser parser;
+ parser.add_positional_argument(adapter, "Adapter to display settings for", "adapter", Core::ArgsParser::Required::No);
+ parser.parse(args);
+
auto app = TRY(GUI::Application::try_create(args));
if (getuid() != 0) {
@@ -39,7 +46,10 @@ ErrorOr<int> serenity_main(Main::Arguments args)
auto app_icon = GUI::Icon::default_icon("network"sv);
auto window = TRY(GUI::SettingsWindow::create("Network Settings", GUI::SettingsWindow::ShowDefaultsButton::No));
- (void)TRY(window->add_tab<NetworkSettings::NetworkSettingsWidget>("Network"sv, "network"sv));
+ auto network_settings_widget = TRY(window->add_tab<NetworkSettings::NetworkSettingsWidget>("Network"sv, "network"sv));
+ if (!adapter.is_null()) {
+ network_settings_widget->switch_adapter(adapter);
+ }
window->set_icon(app_icon.bitmap_for_size(16));
window->show();