Skip to content

Commit

Permalink
Merge branch 'ui-redesign'
Browse files Browse the repository at this point in the history
  • Loading branch information
Ketok4321 committed Jan 15, 2024
2 parents f5696a9 + 93ddf1e commit a11585b
Show file tree
Hide file tree
Showing 9 changed files with 238 additions and 151 deletions.
6 changes: 6 additions & 0 deletions data/xyz.ketok.Speedtest.gschema.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<schemalist gettext-domain="speedtest">
<schema id="xyz.ketok.Speedtest" path="/xyz/ketok/Speedtest/">
<key name="width" type="i">
<default>650</default>
</key>
<key name="height" type="i">
<default>400</default>
</key>
<key name="theme" type="i">
<default>0</default>
</key>
Expand Down
3 changes: 2 additions & 1 deletion src/fetch_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ async def do_run(self):
self.app.servers = await self.app.backend.get_servers()

GLib.idle_add(self.app.win.start_view.server_selector.set_model, Gtk.StringList.new(list(map(lambda s: s.name, self.app.servers))))
GLib.idle_add(self.app.win.set_view, self.app.win.start_view)
GLib.idle_add(self.app.win.main_view.pop)
GLib.idle_add(self.app.win.set_view, self.app.win.main_view)
except Exception as e:
print(e)
GLib.idle_add(self.app.win.set_view, self.app.win.offline_view)
15 changes: 7 additions & 8 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ def __init__(self, version):
self.create_action("about", self.on_about_action)
self.create_action("preferences", self.on_preferences_action, ["<primary>comma"])
self.create_action("start", self.on_start_action)
self.create_action("back", self.on_back_action)
self.create_action("retry_connect", self.on_retry_connect_action)

def do_activate(self):
Expand All @@ -38,6 +37,11 @@ def do_activate(self):
self.win = self.props.active_window
if not self.win:
self.win = SpeedtestWindow(application=self)
self.win.on_test_end = lambda: self.test_worker.stop_event.set()

self.settings.bind("width", self.win, "default-width", Gio.SettingsBindFlags.DEFAULT)
self.settings.bind("height", self.win, "default-height", Gio.SettingsBindFlags.DEFAULT)

self.win.present()

self.load_backend()
Expand Down Expand Up @@ -72,12 +76,12 @@ def on_about_action(self, widget, __):
about.present()

def on_preferences_action(self, widget, _):
if self.win.view_switcher.get_visible_child() == self.win.test_view:
if self.win.main_view.get_visible_page() == self.win.test_view: # TODO: deactivate this action insead of disabling it
return
SpeedtestPreferencesWindow(self, transient_for=self.props.active_window).present()

def on_start_action(self, widget, _):
self.win.set_view(self.win.test_view)
self.win.start_test()

server = self.servers[self.win.start_view.server_selector.get_selected()]

Expand All @@ -87,11 +91,6 @@ def on_start_action(self, widget, _):
self.test_worker = TestWorker(self.backend, self.win, server, self.settings)
self.test_worker.start()

def on_back_action(self, widget, _):
self.test_worker.stop_event.set()

self.win.set_view(self.win.start_view)

def on_retry_connect_action(self, widget, _):
self.load_backend()

Expand Down
3 changes: 1 addition & 2 deletions src/ui/gauge.blp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ template $Gauge : Box {
orientation: vertical;
valign: end;
halign: center;
margin-bottom: 24;

Label {
valign: center;
Expand All @@ -40,4 +39,4 @@ template $Gauge : Box {
}
}
}
}
}
33 changes: 19 additions & 14 deletions src/ui/views/offline.blp
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
using Gtk 4.0;
using Adw 1;

template $OfflineView : Box {
orientation: vertical;
valign: center;

Adw.StatusPage {
title: _("Couldn't connect to the speedtest servers");
description: _("Make sure you are connected to the internet");
icon-name: "network-offline-symbolic";
styles [ "compact" ]
template $OfflineView : Adw.Bin {
Adw.ToolbarView {
[top]
Adw.HeaderBar {
decoration-layout: ":close"; // We don't want the maximize button, even if someone has it enabled.
}

Adw.StatusPage {
title: _("Couldn't connect to the speedtest servers");
description: _("Make sure you are connected to the internet");
icon-name: "network-offline-symbolic";
vexpand: true;
styles [ "compact" ]

Button {
halign: center;
Button {
halign: center;

label: _("Retry");
action-name: "app.retry_connect";
styles [ "pill", "suggested-action" ]
label: _("Retry");
action-name: "app.retry_connect";
styles [ "pill", "suggested-action" ]
}
}
}
}
31 changes: 27 additions & 4 deletions src/ui/views/start.blp
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
using Gtk 4.0;
using Adw 1;

template $StartView : Box {
orientation: vertical;
template $StartView : Adw.NavigationPage {
Adw.ToolbarView {
[top]
Adw.HeaderBar {
decoration-layout: ":close"; // We don't want the maximize button, even if someone has it enabled.

[start]
MenuButton menu_button {
icon-name: "open-menu-symbolic";
menu-model: primary_menu;
}
}

Adw.ToastOverlay {
Adw.StatusPage {
title: _("Speedtest");
description: _("Measure your internet connection speed");

vexpand: true;

Box {
orientation: vertical;
halign: center;
Expand All @@ -33,3 +43,16 @@ template $StartView : Box {
}
}
}

menu primary_menu {
section {
item {
label: _("Preferences");
action: "app.preferences";
}
item {
label: _("About Speedtest");
action: "app.about";
}
}
}
194 changes: 134 additions & 60 deletions src/ui/views/test.blp
Original file line number Diff line number Diff line change
@@ -1,81 +1,155 @@
using Gtk 4.0;
using Adw 1;

template $TestView : Box {
orientation: vertical;
template $TestView : Adw.NavigationPage {
Adw.BreakpointBin {
width-request: 360;
height-request: 294;

Overlay {
[overlay]
ProgressBar progress {
styles [ "osd" ]
}

[overlay]
Box {
orientation: vertical;
spacing: 16;
halign: center;
valign: end;
margin-bottom: 24;
Adw.ToolbarView {
[top]
Adw.HeaderBar {
decoration-layout: ":close"; // We don't want the maximize button, even if someone has it enabled.
}

Box {
orientation: vertical;

Label {
label: _("Ping:");
styles [ "title-2" ]
}
Overlay {
[overlay]
ProgressBar progress {
styles [ "osd" ]
}

Adw.Clamp horizontal_clamp {
orientation: horizontal;
maximum-size: 1300;

Label {
label: bind template.ping;
styles [ "title-3" ]
}
}
Adw.Clamp vertical_clamp {
orientation: vertical;
maximum-size: 800;

Box {
orientation: vertical;
Box {
orientation: vertical;
margin-bottom: 8;

Label {
label: _("Jitter:");
styles [ "title-2" ]
}
Label title {
label: bind template.server;
margin-top: 8;
margin-bottom: 8;
styles [ "title-2" ]
ellipsize: end;
}

Label {
label: bind template.jitter;
styles [ "title-3" ]
}
}
}
Box gauge_box {
orientation: horizontal;
margin-start: 8;
margin-end: 8;
margin-bottom: 8;

[start]
$Gauge download {
label: _("Download:");
vexpand: true;
hexpand: true;
styles [ "dl" ]
}

Box {
orientation: vertical;
Box ping_box_1 {
orientation: vertical;
spacing: 16;
halign: center;
valign: end;
width-request: 96;

Label title {
label: bind template.server;
margin-top: 8;
styles [ "title-2" ]
}
Box {
orientation: vertical;

Box {
orientation: horizontal;
spacing: 80;
margin-start: 8;
margin-end: 8;

$Gauge download {
label: _("Download:");
vexpand: true;
hexpand: true;
styles [ "dl" ]
}
Label {
label: _("Ping:");
styles [ "title-2" ]
}

Label {
label: bind template.ping;
styles [ "title-3" ]
}
}

Box {
orientation: vertical;

Label {
label: _("Jitter:");
styles [ "title-2" ]
}

Label {
label: bind template.jitter;
styles [ "title-3" ]
}
}
}

[end]
$Gauge upload {
label: _("Upload:");
vexpand: true;
hexpand: true;
styles [ "up" ]
}
}

Box ping_box_2 {
orientation: horizontal;
spacing: 24;
halign: center;
valign: end;
visible: false;

Box {
orientation: vertical;

$Gauge upload {
label: _("Upload:");
vexpand: true;
hexpand: true;
styles [ "up" ]
Label {
label: _("Ping:");
styles [ "title-2" ]
}

Label {
label: bind template.ping;
styles [ "title-3" ]
}
}

Box {
orientation: vertical;

Label {
label: _("Jitter:");
styles [ "title-2" ]
}

Label {
label: bind template.jitter;
styles [ "title-3" ]
}
}
}
}
}
}
}
}
}

Adw.Breakpoint {
condition ("max-width: 500")
setters {
gauge_box.orientation: vertical;
ping_box_1.visible: false;
ping_box_2.visible: true;
vertical_clamp.maximum-size: 1600;
}
}
}
}
Loading

0 comments on commit a11585b

Please sign in to comment.