Skip to content

Commit

Permalink
add progress indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
alainm23 committed Dec 16, 2024
1 parent a3329de commit ecf640f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
10 changes: 6 additions & 4 deletions src/Backends/SystemUpdate.vala
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ public class SettingsDaemon.Backends.SystemUpdate : Object {
construct {
current_state = {
UP_TO_DATE,
""
"",
0
};

update_details = {
Expand Down Expand Up @@ -189,7 +190,7 @@ public class SettingsDaemon.Backends.SystemUpdate : Object {
}

private void progress_callback (Pk.Progress progress, Pk.ProgressType progress_type) {
update_state (current_state.state, PkUtils.status_to_title (progress.status));
update_state (current_state.state, PkUtils.status_to_title (progress.status), progress.percentage);
}

private void send_error (string message) {
Expand All @@ -203,10 +204,11 @@ public class SettingsDaemon.Backends.SystemUpdate : Object {
update_state (ERROR, message);
}

private void update_state (PkUtils.State state, string message = "") {
private void update_state (PkUtils.State state, string message = "", uint percentage = 0) {
current_state = {
state,
message
message,
percentage
};

state_changed ();
Expand Down
6 changes: 4 additions & 2 deletions src/Backends/UbuntuDrivers.vala
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public class SettingsDaemon.Backends.UbuntuDrivers : Object {
construct {
current_state = {
UP_TO_DATE,
""
"",
0
};

available_drivers = new HashTable<string, GenericArray<string>> (str_hash, str_equal);
Expand Down Expand Up @@ -277,7 +278,8 @@ public class SettingsDaemon.Backends.UbuntuDrivers : Object {
private void update_state (PkUtils.State state, string message = "") {
current_state = {
state,
message
message,
0
};

state_changed ();
Expand Down
1 change: 1 addition & 0 deletions src/Utils/PkUtils.vala
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace SettingsDaemon.PkUtils {
public struct CurrentState {
State state;
string status;
uint percentage;
}

public static unowned string status_to_title (Pk.Status status) {
Expand Down

0 comments on commit ecf640f

Please sign in to comment.