Skip to content

Commit

Permalink
Use new libadwaita 1.5 dialogs
Browse files Browse the repository at this point in the history
  • Loading branch information
Ketok4321 committed Apr 1, 2024
1 parent 535403b commit ef6323d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
9 changes: 4 additions & 5 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from gi.repository import GLib, Gio, Gtk, Adw

from .conf import *
from .window import SpeedtestWindow, SpeedtestPreferencesWindow
from .window import SpeedtestWindow, SpeedtestPreferencesDialog
from .gauge import Gauge # This class isn't used there but it the widget needs to be registered
from .fetch_worker import FetchWorker
from .test_worker import TestWorker
Expand Down Expand Up @@ -63,8 +63,7 @@ def load_backend(self):
self.fetch_worker.start()

def on_about_action(self, widget, __):
about = Adw.AboutWindow(transient_for=self.props.active_window,
application_name=_("Speedtest"),
about = Adw.AboutDialog(application_name=_("Speedtest"),
application_icon=APP_ID,
developer_name="Ketok",
version=VERSION,
Expand All @@ -75,12 +74,12 @@ def on_about_action(self, widget, __):

about.add_credit_section(_("Backend by"), ["Librespeed"])

about.present()
about.present(self.win)

def on_preferences_action(self, widget, _):
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()
SpeedtestPreferencesDialog(self).present(self.win)

def on_start_action(self, widget, _):
self.win.start_test()
Expand Down
4 changes: 1 addition & 3 deletions src/ui/preferences.blp
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using Gtk 4.0;
using Adw 1;

template $SpeedtestPreferencesWindow : Adw.PreferencesWindow {
template $SpeedtestPreferencesDialog : Adw.PreferencesDialog {
search-enabled: false;
default-width: 360;
default-height: 480;

Adw.PreferencesPage {
Adw.PreferencesGroup {
Expand Down
4 changes: 2 additions & 2 deletions src/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def end_test(self, *_):
self.on_test_end()

@Gtk.Template(resource_path="/xyz/ketok/Speedtest/ui/preferences.ui")
class SpeedtestPreferencesWindow(Adw.PreferencesWindow):
__gtype_name__ = "SpeedtestPreferencesWindow"
class SpeedtestPreferencesDialog(Adw.PreferencesDialog):
__gtype_name__ = "SpeedtestPreferencesDialog"

theme = Gtk.Template.Child()
gauge_scale = Gtk.Template.Child()
Expand Down

0 comments on commit ef6323d

Please sign in to comment.