Skip to content

Commit

Permalink
Simplify size_label, has_flatpak_updates
Browse files Browse the repository at this point in the history
  • Loading branch information
danirabbit committed Feb 7, 2024
1 parent bc7e9ef commit f68659c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 22 deletions.
4 changes: 0 additions & 4 deletions src/Core/UpdateManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public class AppCenterCore.UpdateManager : Object {
public Package runtime_updates { public get; private set; }
public int unpaid_apps_number { get; private set; default = 0; }
public uint64 updates_size { get; private set; default = 0ULL; }
public bool has_flatpak_updates { get; private set; default = false; }

construct {
var runtime_icon = new AppStream.Icon ();
Expand All @@ -40,7 +39,6 @@ public class AppCenterCore.UpdateManager : Object {
public async uint get_updates (Cancellable? cancellable = null) {
var apps_with_updates = new Gee.TreeSet<Package> ();
uint count = 0;
has_flatpak_updates = false;
unpaid_apps_number = 0;
updates_size = 0ULL;

Expand Down Expand Up @@ -70,7 +68,6 @@ public class AppCenterCore.UpdateManager : Object {

count++;
updates_size += appcenter_package.change_information.size;
has_flatpak_updates = true;

appcenter_package.change_information.updatable_packages.@set (fp_client, flatpak_update);
appcenter_package.update_state ();
Expand All @@ -95,7 +92,6 @@ public class AppCenterCore.UpdateManager : Object {
}

runtime_count++;
has_flatpak_updates = true;

runtime_desc += Markup.printf_escaped (
"%s\n\t%s\n",
Expand Down
2 changes: 1 addition & 1 deletion src/Views/AppInfoView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ public class AppCenter.Views.AppInfoView : AppCenter.AbstractAppContainer {
}

var size = yield package.get_download_size_including_deps ();
size_label.update (size, package.is_flatpak);
size_label.update (size);

ContentType? runtime_warning = null;
switch (package.runtime_status) {
Expand Down
2 changes: 1 addition & 1 deletion src/Views/AppListUpdateView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ namespace AppCenter.Views {
client.updates_number
).printf (client.updates_number);

size_label.update (update_manager.updates_size, update_manager.has_flatpak_updates);
size_label.update (update_manager.updates_size);
} else {
header_revealer.reveal_child = false;
updated_revealer.reveal_child = true;
Expand Down
21 changes: 5 additions & 16 deletions src/Widgets/SizeLabel.vala
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,14 @@
*/

public class AppCenter.Widgets.SizeLabel : Gtk.Box {
public bool using_flatpak { get; construct; }
public uint64 size { get; construct; }

private Gtk.Label size_label;
private Gtk.Image icon;
private Gtk.Revealer revealer;

public SizeLabel (uint64 _size = 0, bool _using_flatpak = false) {
Object (
size: _size,
using_flatpak: _using_flatpak
);
public SizeLabel (uint64 _size = 0) {
Object (size: _size);
}

construct {
Expand All @@ -55,20 +51,13 @@ public class AppCenter.Widgets.SizeLabel : Gtk.Box {
add (revealer);
show_all ();

update (size, using_flatpak);
update (size);
}

public void update (uint64 size = 0, bool using_flatpak = false) {
has_tooltip = using_flatpak;
icon.visible = using_flatpak;

public void update (uint64 size = 0) {
string human_size = GLib.format_size (size);

if (using_flatpak) {
size_label.label = _("Up to %s").printf (human_size);
} else {
size_label.label = "%s".printf (human_size);
}
size_label.label = _("Up to %s").printf (human_size);

revealer.reveal_child = size > 0;
}
Expand Down

0 comments on commit f68659c

Please sign in to comment.