Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions src/Core/FlatpakBackend.vala
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,12 @@ public class AppCenterCore.FlatpakBackend : Object, Backend {
// Right now only for runtime updates
private GLib.ListStore additional_updates;

private Gtk.SortListModel _updatable_packages;
private Gtk.FilterListModel _updatable_packages;
public ListModel updatable_packages { get { return _updatable_packages; } }

public ListModel working_packages { get; private set; }

public bool has_working_packages { get { return working_packages.get_n_items () > 0; } }
public bool has_updatable_packages { get { return _updatable_packages.n_items > 0; } }
public uint n_updatable_packages { get { return _updatable_packages.n_items; } }
public uint n_unpaid_updatable_packages {
Expand Down Expand Up @@ -273,19 +276,8 @@ public class AppCenterCore.FlatpakBackend : Object, Backend {
var flatten_model = new Gtk.FlattenListModel (updates_models);

var updatable_filter = new Gtk.BoolFilter (update_available_expression);
var updating_filter = new Gtk.BoolFilter (updating_expression);

var updatable_any_filter = new Gtk.AnyFilter ();
updatable_any_filter.append (updatable_filter);
updatable_any_filter.append (updating_filter);

var updatable_packages = new Gtk.FilterListModel (flatten_model, updatable_any_filter);

var updating_sorter = new Gtk.NumericSorter (updating_expression) {
sort_order = DESCENDING
};

_updatable_packages = new Gtk.SortListModel (updatable_packages, updating_sorter);
_updatable_packages = new Gtk.FilterListModel (flatten_model, updatable_filter);
_updatable_packages.items_changed.connect (() => {
notify_property ("has-updatable-packages");
notify_property ("n-updatable-packages");
Expand All @@ -294,6 +286,12 @@ public class AppCenterCore.FlatpakBackend : Object, Backend {
notify_property ("up-to-date");
});

var working_expression = new Gtk.PropertyExpression (typeof (Package), null, "working");
var working_filter = new Gtk.BoolFilter (working_expression);

working_packages = new Gtk.FilterListModel (_sorted_packages, working_filter);
working_packages.items_changed.connect (() => notify_property ("has-working-packages"));

worker_thread = new Thread<bool> ("flatpak-worker", worker_func);
user_appstream_pool = new AppStream.Pool ();
user_appstream_pool.set_flags (AppStream.PoolFlags.LOAD_OS_CATALOG);
Expand Down
3 changes: 3 additions & 0 deletions src/Core/Package.vala
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ public class AppCenterCore.Package : Object {
public ChangeInformation change_information { public get; private set; }
public State state { public get; private set; default = State.NOT_INSTALLED; }

public bool working { get { return state == INSTALLING || state == UPDATING || state == REMOVING; } }

public double progress {
get {
return change_information.progress;
Expand Down Expand Up @@ -446,6 +448,7 @@ public class AppCenterCore.Package : Object {
// Only trigger a notify if the state has changed, quite a lot of things listen to this
if (state != new_state) {
state = new_state;
notify_property ("working");
backend.notify_package_changed (this);
}
}
Expand Down
19 changes: 18 additions & 1 deletion src/Views/AppListUpdateView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,22 @@ public class AppCenter.Views.AppListUpdateView : Adw.NavigationPage {
updatable_section.append (list_box);
flatpak_backend.bind_property ("has-updatable-packages", updatable_section, "visible", SYNC_CREATE);

var in_progress_header = new Granite.HeaderLabel (_("In Progress")) {
margin_end = 12,
margin_start = 12
};

var in_progress_list = new Gtk.ListBox () {
activate_on_single_click = true,
hexpand = true,
};
in_progress_list.bind_model (flatpak_backend.working_packages, create_row_from_package);

var in_progress_section = new Granite.Box (VERTICAL, HALF);
in_progress_section.append (in_progress_header);
in_progress_section.append (in_progress_list);
flatpak_backend.bind_property ("has-working-packages", in_progress_section, "visible", SYNC_CREATE);

installed_header = new Granite.HeaderLabel (_("Up to Date")) {
margin_end = 12,
margin_start = 12
Expand All @@ -92,8 +108,9 @@ public class AppCenter.Views.AppListUpdateView : Adw.NavigationPage {
installed_section.append (installed_flowbox);
flatpak_backend.bind_property ("has-updated-packages", installed_section, "visible", SYNC_CREATE);

var box = new Granite.Box (VERTICAL, SINGLE);
var box = new Granite.Box (VERTICAL, DOUBLE);
box.append (updatable_section);
box.append (in_progress_section);
box.append (installed_section);

var clamp = new Adw.Clamp () {
Expand Down