Skip to content

Commit

Permalink
details-versioning-page: Use Modern widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
TheEvilSkeleton committed Jan 14, 2025
1 parent e44d7cd commit d1e7703
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 22 deletions.
38 changes: 23 additions & 15 deletions bottles/frontend/details-versioning-page.blp
Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@
using Gtk 4.0;
using Adw 1;

template $DetailsVersioningPage: Adw.PreferencesPage {
Adw.PreferencesPage pref_page {
Adw.PreferencesGroup {
ListBox list_states {
selection-mode: none;
template $DetailsVersioningPage: Adw.Bin {
child: Stack {
StackPage {
name: "states-list-page";
child: Adw.PreferencesPage {
Adw.PreferencesGroup {
ListBox list_states {
selection-mode: none;

styles [
"boxed-list",
]
}
styles [
"boxed-list",
]
}
}
};
}
}

Adw.StatusPage status_page {
icon-name: "preferences-system-time-symbolic";
title: _("No Snapshots Found");
description: _("Create your first snapshot to start saving states of your preferences.");
}
StackPage {
name: "empty-page";
child: Adw.StatusPage {
icon-name: "preferences-system-time-symbolic";
title: _("No Snapshots Found");
description: _("Create your first snapshot to start saving states of your preferences.");
};
}
};
}

Popover pop_context {
Expand Down
14 changes: 7 additions & 7 deletions bottles/frontend/details_versioning_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@


@Gtk.Template(resource_path="/com/usebottles/bottles/details-versioning-page.ui")
class DetailsVersioningPage(Adw.PreferencesPage):
class DetailsVersioningPage(Adw.Bin):
__gtype_name__ = "DetailsVersioningPage"
__registry = []

Expand All @@ -39,8 +39,6 @@ class DetailsVersioningPage(Adw.PreferencesPage):
btn_save = Gtk.Template.Child()
btn_help = Gtk.Template.Child()
entry_state_message = Gtk.Template.Child()
status_page = Gtk.Template.Child()
pref_page = Gtk.Template.Child()
btn_add = Gtk.Template.Child()
ev_controller = Gtk.EventControllerKey.new()

Expand All @@ -62,6 +60,8 @@ def __init__(self, details, config, **kwargs):
self.btn_help.connect("clicked", open_doc_url, "bottles/versioning")
self.entry_state_message.connect("activate", self.add_state)

self.stack = self.get_child()

def empty_list(self):
for r in self.__registry:
if r.get_parent() is not None:
Expand Down Expand Up @@ -99,10 +99,10 @@ def new_state(_state, active):
self.list_states.append(entry)

def callback(result, error=False):
self.status_page.set_visible(not result.status)
self.pref_page.set_visible(result.status)
self.list_states.set_visible(result.status)
self.list_states.set_sensitive(result.status)
if result.status:
self.stack.set_visible_child_name("states-list-page")
else:
self.stack.set_visible_child_name("empty-page")

def process_states():
GLib.idle_add(self.empty_list)
Expand Down

0 comments on commit d1e7703

Please sign in to comment.