From e77f90883cd4d528a6ae31c87af59e2f3005b4ac Mon Sep 17 00:00:00 2001 From: rdbende Date: Sun, 14 Jul 2024 23:53:54 +0200 Subject: [PATCH 1/2] Use libadwaita's spinner --- cozy/ui/headerbar.py | 4 +--- cozy/ui/widgets/first_import_button.py | 3 +-- data/ui/book_detail.blp | 8 +++++--- data/ui/first_import_button.blp | 2 +- data/ui/headerbar.blp | 2 +- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/cozy/ui/headerbar.py b/cozy/ui/headerbar.py index b7063aa0..d7263ecf 100644 --- a/cozy/ui/headerbar.py +++ b/cozy/ui/headerbar.py @@ -23,7 +23,7 @@ class Headerbar(Gtk.Box): menu_button: Gtk.MenuButton = Gtk.Template.Child() progress_menu_button: Gtk.MenuButton = Gtk.Template.Child() - progress_spinner: Gtk.Spinner = Gtk.Template.Child() + progress_spinner: Adw.Spinner = Gtk.Template.Child() view_switcher: Adw.ViewSwitcher = Gtk.Template.Child() @@ -109,10 +109,8 @@ def _on_state_changed(self): if self._headerbar_view_model.state == HeaderBarState.PLAYING: self.progress_menu_button.set_visible(False) self.progress_popover.set_progress(0) - self.progress_spinner.stop() else: self.progress_menu_button.set_visible(True) - self.progress_spinner.start() def _on_work_progress_changed(self): self.progress_popover.set_progress(self._headerbar_view_model.work_progress) diff --git a/cozy/ui/widgets/first_import_button.py b/cozy/ui/widgets/first_import_button.py index 3160fcf2..8cc2269e 100644 --- a/cozy/ui/widgets/first_import_button.py +++ b/cozy/ui/widgets/first_import_button.py @@ -11,7 +11,7 @@ class FirstImportButton(Gtk.Button): stack: Gtk.Stack = Gtk.Template.Child() label: Adw.ButtonContent = Gtk.Template.Child() - spinner: Gtk.Spinner = Gtk.Template.Child() + spinner: Adw.Spinner = Gtk.Template.Child() def __init__(self, callback: Callable[[str], None], initial_folder: str) -> None: super().__init__() @@ -20,5 +20,4 @@ def __init__(self, callback: Callable[[str], None], initial_folder: str) -> None def disable(self) -> None: self.set_sensitive(False) - self.spinner.set_spinning(True) self.stack.set_visible_child(self.spinner) diff --git a/data/ui/book_detail.blp b/data/ui/book_detail.blp index edca2288..5ad01dc9 100644 --- a/data/ui/book_detail.blp +++ b/data/ui/book_detail.blp @@ -226,9 +226,11 @@ template $BookDetail: Adw.NavigationPage { StackPage { name: 'chapters_loader'; - child: Spinner spinner { - halign: center; - spinning: true; + child: Adw.StatusPage _loading_status_page { + paintable: Adw.SpinnerPaintable { + widget: _loading_status_page; + }; + title: _("Loading…"); }; } } diff --git a/data/ui/first_import_button.blp b/data/ui/first_import_button.blp index 57219637..2a941968 100644 --- a/data/ui/first_import_button.blp +++ b/data/ui/first_import_button.blp @@ -13,7 +13,7 @@ template $FirstImportButton: Button { icon-name: 'folder-open-symbolic'; } - Spinner spinner {} + Adw.Spinner spinner {} } styles [ diff --git a/data/ui/headerbar.blp b/data/ui/headerbar.blp index 88f00f14..afc21dd5 100644 --- a/data/ui/headerbar.blp +++ b/data/ui/headerbar.blp @@ -45,7 +45,7 @@ template $Headerbar: Box { can-focus: true; tooltip-text: _("Display background task progress"); - Spinner progress_spinner {} + Adw.Spinner progress_spinner {} styles [ "flat", From c107b319166c912440d2c7bf9079a1ca4d9e5b47 Mon Sep 17 00:00:00 2001 From: rdbende Date: Sun, 14 Jul 2024 23:54:11 +0200 Subject: [PATCH 2/2] Use new ButtonRow widget --- cozy/ui/widgets/storages.py | 12 +++--------- data/ui/storage_locations.blp | 6 ++++++ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cozy/ui/widgets/storages.py b/cozy/ui/widgets/storages.py index 7d24df21..c75aaa15 100644 --- a/cozy/ui/widgets/storages.py +++ b/cozy/ui/widgets/storages.py @@ -84,6 +84,7 @@ class StorageLocations(Adw.PreferencesGroup): _view_model: StoragesViewModel = inject.attr(StoragesViewModel) storage_locations_list: Gtk.ListBox = Gtk.Template.Child() + new_storage_row: Adw.ButtonRow = Gtk.Template.Child() storage_menu: Gio.Menu = Gtk.Template.Child() def __init__(self) -> None: @@ -93,7 +94,6 @@ def __init__(self) -> None: self._view_model.bind_to("storage_attributes", self._reload_storage_list) self._create_actions() - self.new_storage_button = self._create_new_storage_button() self._reload_storage_list() @@ -117,13 +117,6 @@ def _create_actions(self) -> None: self.make_default_action.connect("activate", self._set_default_storage_location) self.action_group.add_action(self.make_default_action) - def _create_new_storage_button(self) -> Adw.ActionRow: - icon = Gtk.Image(icon_name="list-add-symbolic", margin_top=18, margin_bottom=18) - row = Adw.ActionRow(selectable=False, activatable=True) - row.connect("activated", self._on_new_storage_clicked) - row.set_child(icon) - return row - def _reload_storage_list(self) -> None: self.storage_locations_list.remove_all() @@ -133,7 +126,7 @@ def _reload_storage_list(self) -> None: row.connect("menu-opened", self._on_storage_menu_opened) self.storage_locations_list.append(row) - self.storage_locations_list.append(self.new_storage_button) + self.storage_locations_list.append(self.new_storage_row) def _remove_storage_location(self, *_) -> None: self._view_model.remove(self._view_model.selected_storage) @@ -147,6 +140,7 @@ def _mark_storage_location_external( value = action.get_property(value.name) self._view_model.set_external(self._view_model.selected_storage, value) + @Gtk.Template.Callback() def _on_new_storage_clicked(self, *_) -> None: ask_storage_location(self._view_model.add_storage_location) diff --git a/data/ui/storage_locations.blp b/data/ui/storage_locations.blp index ac283426..6491f647 100644 --- a/data/ui/storage_locations.blp +++ b/data/ui/storage_locations.blp @@ -13,6 +13,12 @@ template $StorageLocations: Adw.PreferencesGroup { } } +Adw.ButtonRow new_storage_row { + title: _("Add Storage"); + start-icon-name: "list-add-symbolic"; + activated => $_on_new_storage_clicked(); +} + menu storage_menu { section { item {