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
21 changes: 1 addition & 20 deletions src/Core/FlatpakBackend.vala
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ public class AppCenterCore.FlatpakBackend : Object, Backend {
private Gtk.FilterListModel _updated_packages;
public ListModel updated_packages { get { return _updated_packages; } }

public bool has_updated_packages { get { return _updated_packages.n_items > 0; } }

// Right now only for runtime updates
private GLib.ListStore additional_updates;

Expand All @@ -95,9 +93,6 @@ public class AppCenterCore.FlatpakBackend : Object, Backend {

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 {
get {
uint n = 0;
Expand All @@ -121,13 +116,6 @@ public class AppCenterCore.FlatpakBackend : Object, Backend {
}
}

public bool up_to_date {
get {
return !has_updatable_packages && (!working || job_type != GET_UPDATES && job_type != REFRESH_CACHE
&& job_type != GET_DOWNLOAD_SIZE);
}
}

private Package runtime_updates;

private string user_metadata_path;
Expand Down Expand Up @@ -219,8 +207,6 @@ public class AppCenterCore.FlatpakBackend : Object, Backend {
}

construct {
notify["working"].connect (() => Idle.add_once (() => notify_property ("up-to-date")));

// Our listmodel structure including the updates:
// addtional updates => flatten the two models => filter updatable packages => sort updating packages to the top
// /\
Expand Down Expand Up @@ -267,7 +253,6 @@ public class AppCenterCore.FlatpakBackend : Object, Backend {
updated_every_filter.append (not_updating_filter);

_updated_packages = new Gtk.FilterListModel (installed_packages, updated_every_filter);
_updated_packages.items_changed.connect (() => notify_property ("has-updated-packages"));

var updates_models = new GLib.ListStore (typeof (ListModel));
updates_models.append (additional_updates);
Expand All @@ -279,18 +264,14 @@ public class AppCenterCore.FlatpakBackend : Object, Backend {

_updatable_packages = new Gtk.FilterListModel (flatten_model, updatable_filter);
_updatable_packages.items_changed.connect (() => {
notify_property ("has-updatable-packages");
notify_property ("n-updatable-packages");
notify_property ("n-unpaid-updatable-packages");
notify_property ("updates-size");
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 ();
Expand Down Expand Up @@ -2023,7 +2004,7 @@ public class AppCenterCore.FlatpakBackend : Object, Backend {
job_args.cancellable = cancellable;

// Clear any packages previously marked as updatable
for (int i = (int) n_updatable_packages - 1; i >= 0; i--) {
for (int i = (int) updatable_packages.get_n_items () - 1; i >= 0; i--) {
var package = (Package) updatable_packages.get_item (i);
package.change_information.clear_update_info ();
package.update_state ();
Expand Down
11 changes: 6 additions & 5 deletions src/Core/UpdateManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public class AppCenterCore.UpdateManager : Object {
public bool can_update_all {
get {
unowned var fp_client = FlatpakBackend.get_default ();
return !updating_all && fp_client.n_updatable_packages - fp_client.n_unpaid_updatable_packages > 0;
return !updating_all &&
fp_client.updatable_packages.get_n_items () - fp_client.n_unpaid_updatable_packages > 0;
}
}

Expand All @@ -48,7 +49,7 @@ public class AppCenterCore.UpdateManager : Object {
last_refresh_time = new DateTime.from_unix_utc (AppCenter.App.settings.get_int64 ("last-refresh-time"));

unowned var fp_client = FlatpakBackend.get_default ();
fp_client.notify["n-updatable-packages"].connect (on_n_updatable_packages_changed);
fp_client.updatable_packages.items_changed.connect (on_updatable_packages_changed);
fp_client.notify["n-unpaid-updatable-packages"].connect (() => notify_property ("can-update-all"));

AppCenter.App.settings.changed["automatic-updates"].connect (on_automatic_updates_changed);
Expand All @@ -64,13 +65,13 @@ public class AppCenterCore.UpdateManager : Object {
}
}

private void on_n_updatable_packages_changed () {
private void on_updatable_packages_changed () {
notify_property ("can-update-all");
update_badge.begin ();
}

private async void update_badge () {
var n_updatable_packages = FlatpakBackend.get_default ().n_updatable_packages;
var n_updatable_packages = FlatpakBackend.get_default ().updatable_packages.get_n_items ();

try {
yield Granite.Services.Application.set_badge (n_updatable_packages);
Expand Down Expand Up @@ -167,7 +168,7 @@ public class AppCenterCore.UpdateManager : Object {
yield update_all ();
} else {
var application = Application.get_default ();
var n_updatable_packages = fp_client.n_updatable_packages;
var n_updatable_packages = fp_client.updatable_packages.get_n_items ();
if (n_updatable_packages > 0) {
var title = ngettext ("Update Available", "Updates Available", n_updatable_packages);
var body = ngettext (
Expand Down
10 changes: 5 additions & 5 deletions src/Views/AppListUpdateView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public class AppCenter.Views.AppListUpdateView : Adw.NavigationPage {
var updatable_header_label = new Granite.HeaderLabel (_("Available Updates")) {
hexpand = true
};
flatpak_backend.bind_property (
"n-updatable-packages", updatable_header_label, "label", SYNC_CREATE,
flatpak_backend.updatable_packages.bind_property (
"n-items", updatable_header_label, "label", SYNC_CREATE,
(binding, from_value, ref to_value) => {
var n_updatable_packages = from_value.get_uint ();

Expand Down Expand Up @@ -70,7 +70,7 @@ public class AppCenter.Views.AppListUpdateView : Adw.NavigationPage {
var updatable_section = new Granite.Box (VERTICAL, HALF);
updatable_section.append (updatable_header);
updatable_section.append (list_box);
flatpak_backend.bind_property ("has-updatable-packages", updatable_section, "visible", SYNC_CREATE);
flatpak_backend.updatable_packages.bind_property ("n-items", updatable_section, "visible", SYNC_CREATE);

var in_progress_header = new Granite.HeaderLabel (_("In Progress")) {
margin_end = 12,
Expand All @@ -86,7 +86,7 @@ public class AppCenter.Views.AppListUpdateView : Adw.NavigationPage {
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);
flatpak_backend.working_packages.bind_property ("n-items", in_progress_section, "visible", SYNC_CREATE);

installed_header = new Granite.HeaderLabel (_("Up to Date")) {
margin_end = 12,
Expand All @@ -108,7 +108,7 @@ public class AppCenter.Views.AppListUpdateView : Adw.NavigationPage {
var installed_section = new Granite.Box (VERTICAL, HALF);
installed_section.append (installed_header);
installed_section.append (installed_flowbox);
flatpak_backend.bind_property ("has-updated-packages", installed_section, "visible", SYNC_CREATE);
flatpak_backend.updated_packages.bind_property ("n-items", installed_section, "visible", SYNC_CREATE);

var box = new Granite.Box (VERTICAL, DOUBLE);
box.append (updatable_section);
Expand Down
6 changes: 3 additions & 3 deletions src/Views/Homepage.vala
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ public class AppCenter.Homepage : Adw.NavigationPage {

updates_badge = new Gtk.Label ("!");
updates_badge.add_css_class (Granite.STYLE_CLASS_BADGE);
fp_client.bind_property (
"n-updatable-packages", updates_badge, "label", SYNC_CREATE,
fp_client.updatable_packages.bind_property (
"n-items", updates_badge, "label", SYNC_CREATE,
(binding, from_value, ref to_value) => {
to_value.set_string (from_value.get_uint ().to_string ());
return true;
Expand All @@ -155,7 +155,7 @@ public class AppCenter.Homepage : Adw.NavigationPage {
valign = Gtk.Align.START,
transition_type = Gtk.RevealerTransitionType.CROSSFADE
};
fp_client.bind_property ("has-updatable-packages", updates_badge_revealer, "reveal-child", SYNC_CREATE);
fp_client.updatable_packages.bind_property ("n-items", updates_badge_revealer, "reveal-child", SYNC_CREATE);

var updates_overlay = new Gtk.Overlay () {
child = updates_button
Expand Down