Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for network access #125

Merged
merged 9 commits into from
Feb 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions po/POTFILES
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ src/Views/AbstractInstallerView.vala
src/Views/AccountView.vala
src/Views/KeyboardLayoutView.vala
src/Views/LanguageView.vala
src/Views/NetworkView.vala
src/Widgets/LayoutWidget.vala
src/Widgets/VariantWidget.vala
20 changes: 19 additions & 1 deletion src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class Installer.MainWindow : Hdy.Window {
private AccountView account_view;
private LanguageView language_view;
private KeyboardLayoutView keyboard_layout_view;
private NetworkView network_view;

public MainWindow () {
Object (
Expand Down Expand Up @@ -67,7 +68,24 @@ public class Installer.MainWindow : Hdy.Window {
deck.add (keyboard_layout_view);
deck.visible_child = keyboard_layout_view;

keyboard_layout_view.next_step.connect (() => load_account_view ());
keyboard_layout_view.next_step.connect (() => load_network_view ());
}

private void load_network_view () {
if (network_view != null) {
network_view.destroy ();
}

if (!NetworkMonitor.get_default ().get_network_available ()) {
network_view = new NetworkView ();

deck.add (network_view);
deck.visible_child = network_view;

network_view.next_step.connect (load_account_view);
} else {
load_account_view ();
}
}

private void load_account_view () {
Expand Down
110 changes: 110 additions & 0 deletions src/Views/NetworkView.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
/*
* Copyright (c) 2021 elementary, Inc. (https://elementary.io)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Authored by: Marius Meisenzahl <mariusmeisenzahl@gmail.com>
*/

public class Installer.NetworkView : AbstractInstallerView {
private NetworkMonitor network_monitor;
private Gtk.Button skip_button;

construct {
var image = new Gtk.Image.from_icon_name ("network-wireless", Gtk.IconSize.DIALOG) {
valign = Gtk.Align.END
};

var title_label = new Gtk.Label (_("Connect Network")) {
valign = Gtk.Align.START
};
title_label.get_style_context ().add_class (Granite.STYLE_CLASS_H2_LABEL);

var details_label = new Gtk.Label (_("An Internet connection is required to receive updates, install new apps, and connect to online services")) {
hexpand = true,
max_width_chars = 1, // Make Gtk wrap, but not expand the window
wrap = true,
xalign = 0
};
details_label.get_style_context ().add_class (Granite.STYLE_CLASS_H3_LABEL);

var wireless_image = new Gtk.Image.from_icon_name ("network-wireless-signal-excellent-symbolic", Gtk.IconSize.LARGE_TOOLBAR);

unowned var wireless_image_context = wireless_image.get_style_context ();
wireless_image_context.add_class (Granite.STYLE_CLASS_ACCENT);
wireless_image_context.add_class ("blue");

///Translators: for RTL languages, the UI is flipped
var wireless_label = new Gtk.Label (_("Choose a nearby wireless network from the network indicator in the top right.")) {
hexpand = true,
max_width_chars = 1, // Make Gtk wrap, but not expand the window
wrap = true,
xalign = 0
};

var wired_image = new Gtk.Image.from_icon_name ("network-wired-symbolic", Gtk.IconSize.LARGE_TOOLBAR);

unowned var wired_image_context = wired_image.get_style_context ();
wired_image_context.add_class (Granite.STYLE_CLASS_ACCENT);
wired_image_context.add_class ("orange");


var wired_label = new Gtk.Label (_("Connect a network cable")) {
hexpand = true,
max_width_chars = 1, // Make Gtk wrap, but not expand the window
wrap = true,
xalign = 0
};

var choice_grid = new Gtk.Grid () {
column_spacing = 12,
row_spacing = 32,
valign = Gtk.Align.CENTER,
vexpand = true
};
choice_grid.attach (details_label, 0, 0, 2);
choice_grid.attach (wireless_image, 0, 1);
choice_grid.attach (wireless_label, 1, 1);
choice_grid.attach (wired_image, 0, 2);
choice_grid.attach (wired_label, 1, 2);

content_area.attach (image, 0, 0);
content_area.attach (title_label, 0, 1);
content_area.attach (choice_grid, 1, 0, 1, 2);

var back_button = new Gtk.Button.with_label (_("Back"));

skip_button = new Gtk.Button.with_label (_("Skip"));
skip_button.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION);

action_area.add (back_button);
action_area.add (skip_button);

back_button.clicked.connect (() => ((Hdy.Deck) get_parent ()).navigate (Hdy.NavigationDirection.BACK));
skip_button.clicked.connect (() => (next_step ()));

network_monitor = NetworkMonitor.get_default ();
network_monitor.network_changed.connect (update);

show_all ();
}

private void update () {
if (network_monitor.get_network_available ()) {
network_monitor.network_changed.disconnect (update);
skip_button.label = _("Next");
next_step ();
}
}
}
1 change: 1 addition & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ vala_files = [
'Views/AccountView.vala',
'Views/KeyboardLayoutView.vala',
'Views/LanguageView.vala',
'Views/NetworkView.vala',
'Widgets/LayoutWidget.vala',
'Widgets/VariantWidget.vala'
]
Expand Down