diff --git a/src/Core/ChangeInformation.vala b/src/Core/ChangeInformation.vala index 67e8aace9..5fc6f7849 100644 --- a/src/Core/ChangeInformation.vala +++ b/src/Core/ChangeInformation.vala @@ -29,18 +29,6 @@ public class AppCenterCore.ChangeInformation : Object { FINISHED } - /** - * This signal is likely to be fired from a non-main thread. Ensure any UI - * logic driven from this runs on the GTK thread - */ - public signal void status_changed (); - - /** - * This signal is likely to be fired from a non-main thread. Ensure any UI - * logic driven from this runs on the GTK thread - */ - public signal void progress_changed (); - public Gee.ArrayList updatable_packages { get; private set; } public ActionGroup action_group { get; private set; } @@ -75,15 +63,12 @@ public class AppCenterCore.ChangeInformation : Object { progress = 0.0f; status = Status.WAITING; status_description = _("Waiting"); - status_changed (); - progress_changed (); } public void complete () { cancel_action.set_enabled (false); status = Status.FINISHED; status_description = _("Finished"); - status_changed (); reset_progress (); } @@ -92,7 +77,6 @@ public class AppCenterCore.ChangeInformation : Object { cancel_action.set_enabled (false); status = Status.CANCELLED; status_description = _("Cancelling"); - status_changed (); } public void clear_update_info () { @@ -106,16 +90,21 @@ public class AppCenterCore.ChangeInformation : Object { progress = 0.0f; } + /** + * This method is thread safe. It will queue any updates on the main thread. + */ public void callback (string status_description, double progress, Status status) { - if (this.status_description != status_description || this.status != status) { - this.status_description = status_description; - this.status = status; - status_changed (); - } - - if (this.progress != progress) { - this.progress = progress; - progress_changed (); - } + Idle.add (() => { + if (this.status_description != status_description || this.status != status) { + this.status_description = status_description; + this.status = status; + } + + if (this.progress != progress) { + this.progress = progress; + } + + return Source.REMOVE; + }); } } diff --git a/src/Core/Package.vala b/src/Core/Package.vala index 360366bab..46e5d5deb 100644 --- a/src/Core/Package.vala +++ b/src/Core/Package.vala @@ -186,12 +186,6 @@ public class AppCenterCore.Package : Object { } } - public bool changes_finished { - get { - return change_information.status == ChangeInformation.Status.FINISHED; - } - } - public bool is_runtime_updates { get { return component.id == RUNTIME_UPDATES_ID; @@ -601,10 +595,6 @@ public class AppCenterCore.Package : Object { return summary; } - public string get_progress_description () { - return change_information.status_description; - } - public GLib.Icon get_icon (uint size, uint scale_factor) { GLib.Icon? icon = null; uint current_size = 0; diff --git a/src/Widgets/ProgressButton.vala b/src/Widgets/ProgressButton.vala index cab52aba0..86b3d85fb 100644 --- a/src/Widgets/ProgressButton.vala +++ b/src/Widgets/ProgressButton.vala @@ -19,17 +19,14 @@ public class AppCenter.ProgressButton : Gtk.Button { add_css_class ("progress"); add_css_class ("text-button"); - package.change_information.progress_changed.connect (update_progress); - package.change_information.status_changed.connect (update_progress_status); - - update_progress_status (); - update_progress (); + package.change_information.bind_property ("status-description", this, "tooltip-text", SYNC_CREATE); var cancel_label = new Gtk.Label (_("Cancel")) { mnemonic_widget = this }; progressbar = new Gtk.ProgressBar (); + package.change_information.bind_property ("progress", progressbar, "fraction", SYNC_CREATE); var box = new Gtk.Box (VERTICAL, 0); box.append (cancel_label); @@ -39,23 +36,4 @@ public class AppCenter.ProgressButton : Gtk.Button { action_name = ACTION_PREFIX + AppCenterCore.ChangeInformation.CANCEL_ACTION_NAME; insert_action_group (ACTION_GROUP_PREFIX, package.change_information.action_group); } - - private void update_progress () { - Idle.add (() => { - progressbar.fraction = package.progress; - return GLib.Source.REMOVE; - }); - } - - private void update_progress_status () { - Idle.add (() => { - tooltip_text = package.get_progress_description (); - /* Ensure progress bar shows complete to match status (lp:1606902) */ - if (package.changes_finished) { - progressbar.fraction = 1.0f; - } - - return GLib.Source.REMOVE; - }); - } }