Skip to content

Commit

Permalink
OperatingSystemView: Suggested changes
Browse files Browse the repository at this point in the history
- Lessen scope
- Lessen coupling
- Rename the method to avoid confusion of the getter method
- Unify naming notation: "xxx_size_str" is stringfied data of "xxx_size"
  • Loading branch information
ryonakano committed Dec 27, 2024
1 parent 67fb280 commit 959c0b8
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/Views/OperatingSystemView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ public class About.OperatingSystemView : Gtk.Box {
updates_title.label = _("Downloading Updates");
updates_description.label = "%s <span font-features='tnum'>%s</span>".printf (
current_state.message,
get_progress_text ()
to_progress_text (download_size_remaining, download_size_max)
);
button_stack.visible_child_name = "cancel";
break;
Expand All @@ -604,16 +604,16 @@ public class About.OperatingSystemView : Gtk.Box {
}
}

public string get_progress_text () {
if (download_size_max == 0) {
private string to_progress_text (uint64 remain_size, uint64 total_size) {
if (total_size == 0) {
return "";
}

uint64 downloaded_size = download_size_max - download_size_remaining;
string downloaded_size_str = GLib.format_size (downloaded_size);
string total_size_str = GLib.format_size (download_size_max);
uint64 current_size = total_size - remain_size;
string current_size_str = GLib.format_size (current_size);
string total_size_str = GLib.format_size (total_size);

return "%s / %s".printf (downloaded_size_str, total_size_str);
return "%s / %s".printf (current_size_str, total_size_str);
}

private void details_clicked () {
Expand Down

0 comments on commit 959c0b8

Please sign in to comment.