Skip to content

Commit

Permalink
Make use of latest libadwaita components
Browse files Browse the repository at this point in the history
  • Loading branch information
rdbende authored Jul 21, 2024
2 parents 458807f + c107b31 commit e42391a
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 19 deletions.
4 changes: 1 addition & 3 deletions cozy/ui/headerbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions cozy/ui/widgets/first_import_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__()
Expand All @@ -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)
12 changes: 3 additions & 9 deletions cozy/ui/widgets/storages.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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()

Expand All @@ -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()

Expand 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)
Expand All @@ -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)

Expand Down
8 changes: 5 additions & 3 deletions data/ui/book_detail.blp
Original file line number Diff line number Diff line change
Expand Up @@ -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…");
};
}
}
Expand Down
2 changes: 1 addition & 1 deletion data/ui/first_import_button.blp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ template $FirstImportButton: Button {
icon-name: 'folder-open-symbolic';
}

Spinner spinner {}
Adw.Spinner spinner {}
}

styles [
Expand Down
2 changes: 1 addition & 1 deletion data/ui/headerbar.blp
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 6 additions & 0 deletions data/ui/storage_locations.blp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit e42391a

Please sign in to comment.